-rw-r--r-- | core/launcher/applauncher.cpp | 1 | ||||
-rw-r--r-- | core/launcher/documentlist.cpp | 1 | ||||
-rw-r--r-- | core/launcher/main.cpp | 2 | ||||
-rw-r--r-- | core/launcher/qcopbridge.cpp | 1 | ||||
-rw-r--r-- | core/launcher/screensaver.cpp | 20 | ||||
-rw-r--r-- | core/launcher/server.cpp | 10 | ||||
-rw-r--r-- | core/launcher/server.h | 4 | ||||
-rw-r--r-- | core/launcher/serverapp.cpp | 9 | ||||
-rw-r--r-- | core/launcher/serverapp.h | 10 | ||||
-rw-r--r-- | core/launcher/transferserver.cpp | 1 | ||||
-rw-r--r-- | core/launcher/wait.cpp | 1 | ||||
-rw-r--r-- | core/launcher/wait.h | 4 |
12 files changed, 37 insertions, 27 deletions
diff --git a/core/launcher/applauncher.cpp b/core/launcher/applauncher.cpp index efbf426..5a5517c 100644 --- a/core/launcher/applauncher.cpp +++ b/core/launcher/applauncher.cpp | |||
@@ -1,156 +1,157 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef QTOPIA_INTERNAL_PRELOADACCESS | 21 | #ifndef QTOPIA_INTERNAL_PRELOADACCESS |
22 | #define QTOPIA_INTERNAL_PRELOADACCESS | 22 | #define QTOPIA_INTERNAL_PRELOADACCESS |
23 | #endif | 23 | #endif |
24 | #ifndef QTOPIA_INTERNAL_FILEOPERATIONS | 24 | #ifndef QTOPIA_INTERNAL_FILEOPERATIONS |
25 | #define QTOPIA_INTERNAL_FILEOPERATIONS | 25 | #define QTOPIA_INTERNAL_FILEOPERATIONS |
26 | #endif | 26 | #endif |
27 | #ifndef QTOPIA_PROGRAM_MONITOR | 27 | #ifndef QTOPIA_PROGRAM_MONITOR |
28 | #define QTOPIA_PROGRAM_MONITOR | 28 | #define QTOPIA_PROGRAM_MONITOR |
29 | #endif | 29 | #endif |
30 | #include <opie2/oglobal.h> | 30 | #include <opie2/oglobal.h> |
31 | 31 | ||
32 | #ifndef Q_OS_WIN32 | 32 | #ifndef Q_OS_WIN32 |
33 | #include <sys/stat.h> | 33 | #include <sys/stat.h> |
34 | #include <sys/wait.h> | 34 | #include <sys/wait.h> |
35 | #include <sys/file.h> | 35 | #include <sys/file.h> |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | #include <sys/time.h> | 37 | #include <sys/time.h> |
38 | #include <sys/resource.h> | 38 | #include <sys/resource.h> |
39 | #include <errno.h> | 39 | #include <errno.h> |
40 | #else | 40 | #else |
41 | #include <process.h> | 41 | #include <process.h> |
42 | #include <windows.h> | 42 | #include <windows.h> |
43 | #include <winbase.h> | 43 | #include <winbase.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #include <signal.h> | 46 | #include <signal.h> |
47 | #include <sys/types.h> | 47 | #include <sys/types.h> |
48 | #include <stdlib.h> | 48 | #include <stdlib.h> |
49 | 49 | ||
50 | #include <qtimer.h> | 50 | #include <qtimer.h> |
51 | #include <qwindowsystem_qws.h> | 51 | #include <qwindowsystem_qws.h> |
52 | #include <qmessagebox.h> | 52 | #include <qmessagebox.h> |
53 | #include <qfileinfo.h> | 53 | #include <qfileinfo.h> |
54 | 54 | ||
55 | #include <qtopia/qcopenvelope_qws.h> | 55 | #include <qtopia/qcopenvelope_qws.h> |
56 | #include <qtopia/qpeapplication.h> | 56 | #include <qtopia/qpeapplication.h> |
57 | 57 | ||
58 | #include "applauncher.h" | 58 | #include "applauncher.h" |
59 | #include "documentlist.h" | 59 | #include "documentlist.h" |
60 | 60 | ||
61 | using namespace Opie::Core; | ||
61 | const int AppLauncher::RAISE_TIMEOUT_MS = 5000; | 62 | const int AppLauncher::RAISE_TIMEOUT_MS = 5000; |
62 | 63 | ||
63 | //--------------------------------------------------------------------------- | 64 | //--------------------------------------------------------------------------- |
64 | 65 | ||
65 | static AppLauncher* appLauncherPtr; | 66 | static AppLauncher* appLauncherPtr; |
66 | 67 | ||
67 | const int appStopEventID = 1290; | 68 | const int appStopEventID = 1290; |
68 | 69 | ||
69 | class AppStoppedEvent : public QCustomEvent | 70 | class AppStoppedEvent : public QCustomEvent |
70 | { | 71 | { |
71 | public: | 72 | public: |
72 | AppStoppedEvent(int pid, int status) | 73 | AppStoppedEvent(int pid, int status) |
73 | : QCustomEvent( appStopEventID ), mPid(pid), mStatus(status) { } | 74 | : QCustomEvent( appStopEventID ), mPid(pid), mStatus(status) { } |
74 | 75 | ||
75 | int pid() { return mPid; } | 76 | int pid() { return mPid; } |
76 | int status() { return mStatus; } | 77 | int status() { return mStatus; } |
77 | 78 | ||
78 | private: | 79 | private: |
79 | int mPid, mStatus; | 80 | int mPid, mStatus; |
80 | }; | 81 | }; |
81 | 82 | ||
82 | AppLauncher::AppLauncher(QObject *parent, const char *name) | 83 | AppLauncher::AppLauncher(QObject *parent, const char *name) |
83 | : QObject(parent, name), qlPid(0), qlReady(FALSE), | 84 | : QObject(parent, name), qlPid(0), qlReady(FALSE), |
84 | appKillerBox(0) | 85 | appKillerBox(0) |
85 | { | 86 | { |
86 | connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); | 87 | connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); |
87 | connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); | 88 | connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); |
88 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); | 89 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); |
89 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 90 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
90 | this, SLOT(received(const QCString&,const QByteArray&)) ); | 91 | this, SLOT(received(const QCString&,const QByteArray&)) ); |
91 | 92 | ||
92 | channel = new QCopChannel( "QPE/Server", this ); | 93 | channel = new QCopChannel( "QPE/Server", this ); |
93 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), | 94 | connect( channel, SIGNAL(received(const QCString&,const QByteArray&)), |
94 | this, SLOT(received(const QCString&,const QByteArray&)) ); | 95 | this, SLOT(received(const QCString&,const QByteArray&)) ); |
95 | 96 | ||
96 | #ifndef Q_OS_WIN32 | 97 | #ifndef Q_OS_WIN32 |
97 | signal(SIGCHLD, signalHandler); | 98 | signal(SIGCHLD, signalHandler); |
98 | #else | 99 | #else |
99 | runningAppsProc.setAutoDelete( TRUE ); | 100 | runningAppsProc.setAutoDelete( TRUE ); |
100 | #endif | 101 | #endif |
101 | QString tmp = qApp->argv()[0]; | 102 | QString tmp = qApp->argv()[0]; |
102 | int pos = tmp.findRev('/'); | 103 | int pos = tmp.findRev('/'); |
103 | if ( pos > -1 ) | 104 | if ( pos > -1 ) |
104 | tmp = tmp.mid(++pos); | 105 | tmp = tmp.mid(++pos); |
105 | runningApps[::getpid()] = tmp; | 106 | runningApps[::getpid()] = tmp; |
106 | 107 | ||
107 | appLauncherPtr = this; | 108 | appLauncherPtr = this; |
108 | 109 | ||
109 | QTimer::singleShot( 1000, this, SLOT(createQuickLauncher()) ); | 110 | QTimer::singleShot( 1000, this, SLOT(createQuickLauncher()) ); |
110 | } | 111 | } |
111 | 112 | ||
112 | AppLauncher::~AppLauncher() | 113 | AppLauncher::~AppLauncher() |
113 | { | 114 | { |
114 | appLauncherPtr = 0; | 115 | appLauncherPtr = 0; |
115 | #ifndef Q_OS_WIN32 | 116 | #ifndef Q_OS_WIN32 |
116 | signal(SIGCHLD, SIG_DFL); | 117 | signal(SIGCHLD, SIG_DFL); |
117 | #endif | 118 | #endif |
118 | if ( qlPid ) { | 119 | if ( qlPid ) { |
119 | int status; | 120 | int status; |
120 | ::kill( qlPid, SIGTERM ); | 121 | ::kill( qlPid, SIGTERM ); |
121 | waitpid( qlPid, &status, 0 ); | 122 | waitpid( qlPid, &status, 0 ); |
122 | } | 123 | } |
123 | } | 124 | } |
124 | 125 | ||
125 | /* We use the QCopChannel of the app as an indicator of when it has been launched | 126 | /* We use the QCopChannel of the app as an indicator of when it has been launched |
126 | so that we can disable the busy indicators */ | 127 | so that we can disable the busy indicators */ |
127 | void AppLauncher::newQcopChannel(const QString& channelName) | 128 | void AppLauncher::newQcopChannel(const QString& channelName) |
128 | { | 129 | { |
129 | // qDebug("channel %s added", channelName.data() ); | 130 | // qDebug("channel %s added", channelName.data() ); |
130 | QString prefix("QPE/Application/"); | 131 | QString prefix("QPE/Application/"); |
131 | if (channelName.startsWith(prefix)) { | 132 | if (channelName.startsWith(prefix)) { |
132 | { | 133 | { |
133 | QCopEnvelope e("QPE/System", "newChannel(QString)"); | 134 | QCopEnvelope e("QPE/System", "newChannel(QString)"); |
134 | e << channelName; | 135 | e << channelName; |
135 | } | 136 | } |
136 | QString appName = channelName.mid(prefix.length()); | 137 | QString appName = channelName.mid(prefix.length()); |
137 | if ( appName != "quicklauncher" ) { | 138 | if ( appName != "quicklauncher" ) { |
138 | emit connected( appName ); | 139 | emit connected( appName ); |
139 | QCopEnvelope e("QPE/System", "notBusy(QString)"); | 140 | QCopEnvelope e("QPE/System", "notBusy(QString)"); |
140 | e << appName; | 141 | e << appName; |
141 | } | 142 | } |
142 | } else if (channelName.startsWith("QPE/QuickLauncher-")) { | 143 | } else if (channelName.startsWith("QPE/QuickLauncher-")) { |
143 | qDebug("Registered %s", channelName.latin1()); | 144 | qDebug("Registered %s", channelName.latin1()); |
144 | int pid = channelName.mid(18).toInt(); | 145 | int pid = channelName.mid(18).toInt(); |
145 | if (pid == qlPid) | 146 | if (pid == qlPid) |
146 | qlReady = TRUE; | 147 | qlReady = TRUE; |
147 | } | 148 | } |
148 | } | 149 | } |
149 | 150 | ||
150 | void AppLauncher::removedQcopChannel(const QString& channelName) | 151 | void AppLauncher::removedQcopChannel(const QString& channelName) |
151 | { | 152 | { |
152 | if (channelName.startsWith("QPE/Application/")) { | 153 | if (channelName.startsWith("QPE/Application/")) { |
153 | QCopEnvelope e("QPE/System", "removedChannel(QString)"); | 154 | QCopEnvelope e("QPE/System", "removedChannel(QString)"); |
154 | e << channelName; | 155 | e << channelName; |
155 | } | 156 | } |
156 | } | 157 | } |
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index 63f853e..3e0a96c 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp | |||
@@ -1,145 +1,146 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "documentlist.h" | 20 | #include "documentlist.h" |
21 | #include "serverinterface.h" | 21 | #include "serverinterface.h" |
22 | #include "mediadlg.h" | 22 | #include "mediadlg.h" |
23 | 23 | ||
24 | #include <opie2/oglobal.h> | 24 | #include <opie2/oglobal.h> |
25 | 25 | ||
26 | #include <qtopia/config.h> | 26 | #include <qtopia/config.h> |
27 | #include <qtopia/mimetype.h> | 27 | #include <qtopia/mimetype.h> |
28 | #include <qtopia/resource.h> | 28 | #include <qtopia/resource.h> |
29 | #include <qtopia/private/categories.h> | 29 | #include <qtopia/private/categories.h> |
30 | #include <qtopia/qpeapplication.h> | 30 | #include <qtopia/qpeapplication.h> |
31 | #include <qtopia/applnk.h> | 31 | #include <qtopia/applnk.h> |
32 | #include <qtopia/storage.h> | 32 | #include <qtopia/storage.h> |
33 | #ifdef Q_WS_QWS | 33 | #ifdef Q_WS_QWS |
34 | #include <qtopia/qcopenvelope_qws.h> | 34 | #include <qtopia/qcopenvelope_qws.h> |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #include <qtimer.h> | 37 | #include <qtimer.h> |
38 | #include <qfileinfo.h> | 38 | #include <qfileinfo.h> |
39 | #include <qtextstream.h> | 39 | #include <qtextstream.h> |
40 | #include <qfile.h> | 40 | #include <qfile.h> |
41 | #include <qdir.h> | 41 | #include <qdir.h> |
42 | #include <qpainter.h> | 42 | #include <qpainter.h> |
43 | #include <qimage.h> | 43 | #include <qimage.h> |
44 | #include <qcopchannel_qws.h> | 44 | #include <qcopchannel_qws.h> |
45 | #include <qlistview.h> | 45 | #include <qlistview.h> |
46 | #include <qlist.h> | 46 | #include <qlist.h> |
47 | #include <qpixmap.h> | 47 | #include <qpixmap.h> |
48 | 48 | ||
49 | 49 | ||
50 | using namespace Opie::Core; | ||
50 | AppLnkSet *DocumentList::appLnkSet = 0; | 51 | AppLnkSet *DocumentList::appLnkSet = 0; |
51 | 52 | ||
52 | static const int MAX_SEARCH_DEPTH = 10; | 53 | static const int MAX_SEARCH_DEPTH = 10; |
53 | 54 | ||
54 | 55 | ||
55 | class DocumentListPrivate : public QObject { | 56 | class DocumentListPrivate : public QObject { |
56 | Q_OBJECT | 57 | Q_OBJECT |
57 | public: | 58 | public: |
58 | DocumentListPrivate( ServerInterface *gui ); | 59 | DocumentListPrivate( ServerInterface *gui ); |
59 | ~DocumentListPrivate(); | 60 | ~DocumentListPrivate(); |
60 | 61 | ||
61 | void initialize(); | 62 | void initialize(); |
62 | 63 | ||
63 | const QString nextFile(); | 64 | const QString nextFile(); |
64 | const DocLnk *iterate(); | 65 | const DocLnk *iterate(); |
65 | bool store( DocLnk* dl ); | 66 | bool store( DocLnk* dl ); |
66 | void estimatedPercentScanned(); | 67 | void estimatedPercentScanned(); |
67 | void appendDocpath(FileSystem*); | 68 | void appendDocpath(FileSystem*); |
68 | 69 | ||
69 | 70 | ||
70 | DocLnkSet dls; | 71 | DocLnkSet dls; |
71 | QDict<void> reference; | 72 | QDict<void> reference; |
72 | QDictIterator<void> *dit; | 73 | QDictIterator<void> *dit; |
73 | enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state; | 74 | enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state; |
74 | 75 | ||
75 | QStringList docPaths; | 76 | QStringList docPaths; |
76 | unsigned int docPathsSearched; | 77 | unsigned int docPathsSearched; |
77 | 78 | ||
78 | int searchDepth; | 79 | int searchDepth; |
79 | QDir *listDirs[MAX_SEARCH_DEPTH]; | 80 | QDir *listDirs[MAX_SEARCH_DEPTH]; |
80 | const QFileInfoList *lists[MAX_SEARCH_DEPTH]; | 81 | const QFileInfoList *lists[MAX_SEARCH_DEPTH]; |
81 | unsigned int listPositions[MAX_SEARCH_DEPTH]; | 82 | unsigned int listPositions[MAX_SEARCH_DEPTH]; |
82 | 83 | ||
83 | StorageInfo *storage; | 84 | StorageInfo *storage; |
84 | 85 | ||
85 | int tid; | 86 | int tid; |
86 | 87 | ||
87 | ServerInterface *serverGui; | 88 | ServerInterface *serverGui; |
88 | 89 | ||
89 | bool needToSendAllDocLinks; | 90 | bool needToSendAllDocLinks; |
90 | bool sendAppLnks; | 91 | bool sendAppLnks; |
91 | bool sendDocLnks; | 92 | bool sendDocLnks; |
92 | bool scanDocs; | 93 | bool scanDocs; |
93 | }; | 94 | }; |
94 | 95 | ||
95 | 96 | ||
96 | /* | 97 | /* |
97 | * scandocs will be read from Config | 98 | * scandocs will be read from Config |
98 | */ | 99 | */ |
99 | DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, | 100 | DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, |
100 | QObject *parent, const char *name ) | 101 | QObject *parent, const char *name ) |
101 | : QObject( parent, name ) | 102 | : QObject( parent, name ) |
102 | { | 103 | { |
103 | appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); | 104 | appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); |
104 | d = new DocumentListPrivate( serverGui ); | 105 | d = new DocumentListPrivate( serverGui ); |
105 | d->needToSendAllDocLinks = false; | 106 | d->needToSendAllDocLinks = false; |
106 | 107 | ||
107 | Config cfg( "Launcher" ); | 108 | Config cfg( "Launcher" ); |
108 | cfg.setGroup( "DocTab" ); | 109 | cfg.setGroup( "DocTab" ); |
109 | d->scanDocs = cfg.readBoolEntry( "Enable", true ); | 110 | d->scanDocs = cfg.readBoolEntry( "Enable", true ); |
110 | qDebug( "DocumentList::DocumentList() : scanDocs = %d", d->scanDocs ); | 111 | qDebug( "DocumentList::DocumentList() : scanDocs = %d", d->scanDocs ); |
111 | 112 | ||
112 | QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); | 113 | QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); |
113 | } | 114 | } |
114 | 115 | ||
115 | void DocumentList::startInitialScan() | 116 | void DocumentList::startInitialScan() |
116 | { | 117 | { |
117 | reloadAppLnks(); | 118 | reloadAppLnks(); |
118 | reloadDocLnks(); | 119 | reloadDocLnks(); |
119 | } | 120 | } |
120 | 121 | ||
121 | DocumentList::~DocumentList() | 122 | DocumentList::~DocumentList() |
122 | { | 123 | { |
123 | delete appLnkSet; | 124 | delete appLnkSet; |
124 | delete d; | 125 | delete d; |
125 | } | 126 | } |
126 | 127 | ||
127 | 128 | ||
128 | void DocumentList::add( const DocLnk& doc ) | 129 | void DocumentList::add( const DocLnk& doc ) |
129 | { | 130 | { |
130 | if ( d->serverGui && QFile::exists( doc.file() ) ) | 131 | if ( d->serverGui && QFile::exists( doc.file() ) ) |
131 | d->serverGui->documentAdded( doc ); | 132 | d->serverGui->documentAdded( doc ); |
132 | } | 133 | } |
133 | 134 | ||
134 | 135 | ||
135 | void DocumentList::start() | 136 | void DocumentList::start() |
136 | { | 137 | { |
137 | resume(); | 138 | resume(); |
138 | } | 139 | } |
139 | 140 | ||
140 | 141 | ||
141 | void DocumentList::pause() | 142 | void DocumentList::pause() |
142 | { | 143 | { |
143 | //qDebug("pause %i", d->tid); | 144 | //qDebug("pause %i", d->tid); |
144 | killTimer( d->tid ); | 145 | killTimer( d->tid ); |
145 | d->tid = 0; | 146 | d->tid = 0; |
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index c136bd9..3e7e0d2 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -1,161 +1,161 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef QTOPIA_INTERNAL_FILEOPERATIONS | 21 | #ifndef QTOPIA_INTERNAL_FILEOPERATIONS |
22 | #define QTOPIA_INTERNAL_FILEOPERATIONS | 22 | #define QTOPIA_INTERNAL_FILEOPERATIONS |
23 | #endif | 23 | #endif |
24 | #include "server.h" | 24 | #include "server.h" |
25 | #include "serverapp.h" | 25 | #include "serverapp.h" |
26 | #include "stabmon.h" | 26 | #include "stabmon.h" |
27 | #include "firstuse.h" | 27 | #include "firstuse.h" |
28 | 28 | ||
29 | #include <opie2/oglobal.h> | 29 | #include <opie2/oglobal.h> |
30 | 30 | ||
31 | #include <qtopia/network.h> | 31 | #include <qtopia/network.h> |
32 | //#include <qtopia/custom.h> | 32 | //#include <qtopia/custom.h> |
33 | 33 | ||
34 | 34 | ||
35 | #include <qdir.h> | 35 | #include <qdir.h> |
36 | #ifdef QWS | 36 | #ifdef QWS |
37 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
38 | #include <qtopia/qcopenvelope_qws.h> | 38 | #include <qtopia/qcopenvelope_qws.h> |
39 | #endif | 39 | #endif |
40 | #include <qtopia/alarmserver.h> | 40 | #include <qtopia/alarmserver.h> |
41 | 41 | ||
42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
43 | #include <stdio.h> | 43 | #include <stdio.h> |
44 | #include <signal.h> | 44 | #include <signal.h> |
45 | #ifndef Q_OS_WIN32 | 45 | #ifndef Q_OS_WIN32 |
46 | #include <unistd.h> | 46 | #include <unistd.h> |
47 | #else | 47 | #else |
48 | #include <process.h> | 48 | #include <process.h> |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #include "calibrate.h" | 51 | #include "calibrate.h" |
52 | 52 | ||
53 | 53 | ||
54 | #ifdef QT_QWS_LOGIN | 54 | #ifdef QT_QWS_LOGIN |
55 | #include "../login/qdmdialogimpl.h" | 55 | #include "../login/qdmdialogimpl.h" |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #ifdef Q_WS_QWS | 58 | #ifdef Q_WS_QWS |
59 | #include <qkeyboard_qws.h> | 59 | #include <qkeyboard_qws.h> |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | #include <qmessagebox.h> | 62 | #include <qmessagebox.h> |
63 | #include <opie2/odevice.h> | 63 | #include <opie2/odevice.h> |
64 | 64 | ||
65 | using namespace Opie; | 65 | using namespace Opie::Core; |
66 | 66 | ||
67 | 67 | ||
68 | static void cleanup() | 68 | static void cleanup() |
69 | { | 69 | { |
70 | QDir dir( "/tmp", "qcop-msg-*" ); | 70 | QDir dir( "/tmp", "qcop-msg-*" ); |
71 | 71 | ||
72 | QStringList stale = dir.entryList(); | 72 | QStringList stale = dir.entryList(); |
73 | QStringList::Iterator it; | 73 | QStringList::Iterator it; |
74 | for ( it = stale.begin(); it != stale.end(); ++it ) { | 74 | for ( it = stale.begin(); it != stale.end(); ++it ) { |
75 | dir.remove( *it ); | 75 | dir.remove( *it ); |
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | static void refreshTimeZoneConfig() | 79 | static void refreshTimeZoneConfig() |
80 | { | 80 | { |
81 | /* ### FIXME timezone handling */ | 81 | /* ### FIXME timezone handling */ |
82 | #if 0 | 82 | #if 0 |
83 | // We need to help WorldTime in setting up its configuration for | 83 | // We need to help WorldTime in setting up its configuration for |
84 | // the current translation | 84 | // the current translation |
85 | // BEGIN no tr | 85 | // BEGIN no tr |
86 | const char *defaultTz[] = { | 86 | const char *defaultTz[] = { |
87 | "America/New_York", | 87 | "America/New_York", |
88 | "America/Los_Angeles", | 88 | "America/Los_Angeles", |
89 | "Europe/Oslo", | 89 | "Europe/Oslo", |
90 | "Asia/Tokyo", | 90 | "Asia/Tokyo", |
91 | "Asia/Hong_Kong", | 91 | "Asia/Hong_Kong", |
92 | "Australia/Brisbane", | 92 | "Australia/Brisbane", |
93 | 0 | 93 | 0 |
94 | }; | 94 | }; |
95 | // END no tr | 95 | // END no tr |
96 | 96 | ||
97 | TimeZone curZone; | 97 | TimeZone curZone; |
98 | QString zoneID; | 98 | QString zoneID; |
99 | int zoneIndex; | 99 | int zoneIndex; |
100 | Config cfg = Config( "WorldTime" ); | 100 | Config cfg = Config( "WorldTime" ); |
101 | cfg.setGroup( "TimeZones" ); | 101 | cfg.setGroup( "TimeZones" ); |
102 | if (!cfg.hasKey( "Zone0" )){ | 102 | if (!cfg.hasKey( "Zone0" )){ |
103 | // We have no existing timezones use the defaults which are untranslated strings | 103 | // We have no existing timezones use the defaults which are untranslated strings |
104 | QString currTz = TimeZone::current().id(); | 104 | QString currTz = TimeZone::current().id(); |
105 | QStringList zoneDefaults; | 105 | QStringList zoneDefaults; |
106 | zoneDefaults.append( currTz ); | 106 | zoneDefaults.append( currTz ); |
107 | for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) { | 107 | for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) { |
108 | if ( defaultTz[i] != currTz ) | 108 | if ( defaultTz[i] != currTz ) |
109 | zoneDefaults.append( defaultTz[i] ); | 109 | zoneDefaults.append( defaultTz[i] ); |
110 | } | 110 | } |
111 | zoneIndex = 0; | 111 | zoneIndex = 0; |
112 | for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ | 112 | for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ |
113 | cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); | 113 | cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); |
114 | zoneIndex++; | 114 | zoneIndex++; |
115 | } | 115 | } |
116 | } | 116 | } |
117 | // We have an existing list of timezones refresh the | 117 | // We have an existing list of timezones refresh the |
118 | // translations of TimeZone name | 118 | // translations of TimeZone name |
119 | zoneIndex = 0; | 119 | zoneIndex = 0; |
120 | while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ | 120 | while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ |
121 | zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); | 121 | zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); |
122 | curZone = TimeZone( zoneID ); | 122 | curZone = TimeZone( zoneID ); |
123 | if ( !curZone.isValid() ){ | 123 | if ( !curZone.isValid() ){ |
124 | qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() ); | 124 | qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() ); |
125 | break; | 125 | break; |
126 | } | 126 | } |
127 | cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); | 127 | cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); |
128 | zoneIndex++; | 128 | zoneIndex++; |
129 | } | 129 | } |
130 | #endif | 130 | #endif |
131 | } | 131 | } |
132 | 132 | ||
133 | void initEnvironment() | 133 | void initEnvironment() |
134 | { | 134 | { |
135 | #ifdef Q_OS_WIN32 | 135 | #ifdef Q_OS_WIN32 |
136 | // Config file requires HOME dir which uses QDir which needs the winver | 136 | // Config file requires HOME dir which uses QDir which needs the winver |
137 | qt_init_winver(); | 137 | qt_init_winver(); |
138 | #endif | 138 | #endif |
139 | Config config("locale"); | 139 | Config config("locale"); |
140 | config.setGroup( "Location" ); | 140 | config.setGroup( "Location" ); |
141 | QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); | 141 | QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); |
142 | 142 | ||
143 | // if not timezone set, pick New York | 143 | // if not timezone set, pick New York |
144 | if (tz.isNull() || tz.isEmpty()) | 144 | if (tz.isNull() || tz.isEmpty()) |
145 | tz = "America/New_York"; | 145 | tz = "America/New_York"; |
146 | 146 | ||
147 | setenv( "TZ", tz, 1 ); | 147 | setenv( "TZ", tz, 1 ); |
148 | config.writeEntry( "Timezone", tz); | 148 | config.writeEntry( "Timezone", tz); |
149 | 149 | ||
150 | config.setGroup( "Language" ); | 150 | config.setGroup( "Language" ); |
151 | QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); | 151 | QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); |
152 | if( lang.isNull() || lang.isEmpty()) | 152 | if( lang.isNull() || lang.isEmpty()) |
153 | lang = "en_US"; | 153 | lang = "en_US"; |
154 | 154 | ||
155 | setenv( "LANG", lang, 1 ); | 155 | setenv( "LANG", lang, 1 ); |
156 | config.writeEntry("Language", lang); | 156 | config.writeEntry("Language", lang); |
157 | config.write(); | 157 | config.write(); |
158 | 158 | ||
159 | #if 0 | 159 | #if 0 |
160 | setenv( "QWS_SIZE", "240x320", 0 ); | 160 | setenv( "QWS_SIZE", "240x320", 0 ); |
161 | #endif | 161 | #endif |
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp index 53efba4..33df6c4 100644 --- a/core/launcher/qcopbridge.cpp +++ b/core/launcher/qcopbridge.cpp | |||
@@ -1,152 +1,153 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qcopbridge.h" | 21 | #include "qcopbridge.h" |
22 | #include "transferserver.h" | 22 | #include "transferserver.h" |
23 | 23 | ||
24 | #include <opie2/oglobal.h> | 24 | #include <opie2/oglobal.h> |
25 | 25 | ||
26 | #ifdef Q_WS_QWS | 26 | #ifdef Q_WS_QWS |
27 | #include <qtopia/qcopenvelope_qws.h> | 27 | #include <qtopia/qcopenvelope_qws.h> |
28 | #endif | 28 | #endif |
29 | #include <qtopia/qpeapplication.h> | 29 | #include <qtopia/qpeapplication.h> |
30 | 30 | ||
31 | #include <qtopia/version.h> | 31 | #include <qtopia/version.h> |
32 | 32 | ||
33 | #include <qtextstream.h> | 33 | #include <qtextstream.h> |
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
35 | #ifdef Q_WS_QWS | 35 | #ifdef Q_WS_QWS |
36 | #include <qcopchannel_qws.h> | 36 | #include <qcopchannel_qws.h> |
37 | #endif | 37 | #endif |
38 | 38 | ||
39 | #ifndef _XOPEN_SOURCE | 39 | #ifndef _XOPEN_SOURCE |
40 | #define _XOPEN_SOURCE | 40 | #define _XOPEN_SOURCE |
41 | #endif | 41 | #endif |
42 | #ifndef Q_OS_WIN32 | 42 | #ifndef Q_OS_WIN32 |
43 | #include <pwd.h> | 43 | #include <pwd.h> |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | #include <sys/types.h> | 45 | #include <sys/types.h> |
46 | #endif | 46 | #endif |
47 | 47 | ||
48 | #if defined(_OS_LINUX_) | 48 | #if defined(_OS_LINUX_) |
49 | #include <shadow.h> | 49 | #include <shadow.h> |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | 52 | ||
53 | //#define INSECURE | 53 | //#define INSECURE |
54 | 54 | ||
55 | const int block_size = 51200; | 55 | const int block_size = 51200; |
56 | 56 | ||
57 | using namespace Opie::Core; | ||
57 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, | 58 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, |
58 | const char* name ) | 59 | const char* name ) |
59 | : QServerSocket( port, 1, parent, name ), | 60 | : QServerSocket( port, 1, parent, name ), |
60 | desktopChannel( 0 ), | 61 | desktopChannel( 0 ), |
61 | cardChannel( 0 ) | 62 | cardChannel( 0 ) |
62 | { | 63 | { |
63 | if ( !ok() ) | 64 | if ( !ok() ) |
64 | qWarning( "Failed to bind to port %d", port ); | 65 | qWarning( "Failed to bind to port %d", port ); |
65 | else { | 66 | else { |
66 | #ifndef QT_NO_COP | 67 | #ifndef QT_NO_COP |
67 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); | 68 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); |
68 | connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 69 | connect( desktopChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
69 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); | 70 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
70 | cardChannel = new QCopChannel( "QPE/Card", this ); | 71 | cardChannel = new QCopChannel( "QPE/Card", this ); |
71 | connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 72 | connect( cardChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
72 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); | 73 | this, SLOT(desktopMessage(const QCString&,const QByteArray&)) ); |
73 | #endif | 74 | #endif |
74 | } | 75 | } |
75 | sendSync = FALSE; | 76 | sendSync = FALSE; |
76 | openConnections.setAutoDelete( TRUE ); | 77 | openConnections.setAutoDelete( TRUE ); |
77 | authorizeConnections(); | 78 | authorizeConnections(); |
78 | } | 79 | } |
79 | 80 | ||
80 | QCopBridge::~QCopBridge() | 81 | QCopBridge::~QCopBridge() |
81 | { | 82 | { |
82 | #ifndef QT_NO_COP | 83 | #ifndef QT_NO_COP |
83 | delete desktopChannel; | 84 | delete desktopChannel; |
84 | #endif | 85 | #endif |
85 | } | 86 | } |
86 | 87 | ||
87 | void QCopBridge::authorizeConnections() | 88 | void QCopBridge::authorizeConnections() |
88 | { | 89 | { |
89 | Config cfg("Security"); | 90 | Config cfg("Security"); |
90 | cfg.setGroup("SyncMode"); | 91 | cfg.setGroup("SyncMode"); |
91 | m_mode = Mode(cfg.readNumEntry("Mode", Sharp )); | 92 | m_mode = Mode(cfg.readNumEntry("Mode", Sharp )); |
92 | QListIterator<QCopBridgePI> it(openConnections); | 93 | QListIterator<QCopBridgePI> it(openConnections); |
93 | while ( it.current() ) { | 94 | while ( it.current() ) { |
94 | if ( !it.current()->verifyAuthorised() ) { | 95 | if ( !it.current()->verifyAuthorised() ) { |
95 | disconnect ( it.current(), SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) ); | 96 | disconnect ( it.current(), SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) ); |
96 | openConnections.removeRef( it.current() ); | 97 | openConnections.removeRef( it.current() ); |
97 | } else | 98 | } else |
98 | ++it; | 99 | ++it; |
99 | } | 100 | } |
100 | } | 101 | } |
101 | 102 | ||
102 | void QCopBridge::newConnection( int socket ) | 103 | void QCopBridge::newConnection( int socket ) |
103 | { | 104 | { |
104 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); | 105 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); |
105 | openConnections.append( pi ); | 106 | openConnections.append( pi ); |
106 | connect ( pi, SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) ); | 107 | connect ( pi, SIGNAL( connectionClosed(QCopBridgePI*) ), this, SLOT( closed(QCopBridgePI*) ) ); |
107 | 108 | ||
108 | /* ### libqtopia merge FIXME */ | 109 | /* ### libqtopia merge FIXME */ |
109 | #if 0 | 110 | #if 0 |
110 | QPEApplication::setTempScreenSaverMode( QPEApplication::DisableSuspend ); | 111 | QPEApplication::setTempScreenSaverMode( QPEApplication::DisableSuspend ); |
111 | #endif | 112 | #endif |
112 | #ifndef QT_NO_COP | 113 | #ifndef QT_NO_COP |
113 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 114 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
114 | #endif | 115 | #endif |
115 | 116 | ||
116 | if ( sendSync ) { | 117 | if ( sendSync ) { |
117 | pi ->startSync(); | 118 | pi ->startSync(); |
118 | sendSync = FALSE; | 119 | sendSync = FALSE; |
119 | } | 120 | } |
120 | } | 121 | } |
121 | 122 | ||
122 | void QCopBridge::closed( QCopBridgePI *pi ) | 123 | void QCopBridge::closed( QCopBridgePI *pi ) |
123 | { | 124 | { |
124 | emit connectionClosed( pi->peerAddress() ); | 125 | emit connectionClosed( pi->peerAddress() ); |
125 | openConnections.removeRef( pi ); | 126 | openConnections.removeRef( pi ); |
126 | if ( openConnections.count() == 0 ) { | 127 | if ( openConnections.count() == 0 ) { |
127 | /* ### FIXME libqtopia merge */ | 128 | /* ### FIXME libqtopia merge */ |
128 | #if 0 | 129 | #if 0 |
129 | QPEApplication::setTempScreenSaverMode( QPEApplication::Enable ); | 130 | QPEApplication::setTempScreenSaverMode( QPEApplication::Enable ); |
130 | #endif | 131 | #endif |
131 | #ifndef QT_NO_COP | 132 | #ifndef QT_NO_COP |
132 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 133 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
133 | #endif | 134 | #endif |
134 | } | 135 | } |
135 | } | 136 | } |
136 | 137 | ||
137 | void QCopBridge::closeOpenConnections() | 138 | void QCopBridge::closeOpenConnections() |
138 | { | 139 | { |
139 | QCopBridgePI *pi; | 140 | QCopBridgePI *pi; |
140 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) | 141 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) |
141 | pi->close(); | 142 | pi->close(); |
142 | } | 143 | } |
143 | 144 | ||
144 | 145 | ||
145 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data ) | 146 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &data ) |
146 | { | 147 | { |
147 | if ( command == "startSync()" ) { | 148 | if ( command == "startSync()" ) { |
148 | // we need to buffer it a bit | 149 | // we need to buffer it a bit |
149 | sendSync = TRUE; | 150 | sendSync = TRUE; |
150 | startTimer( 20000 ); | 151 | startTimer( 20000 ); |
151 | } | 152 | } |
152 | 153 | ||
diff --git a/core/launcher/screensaver.cpp b/core/launcher/screensaver.cpp index e544c61..6aaab3a 100644 --- a/core/launcher/screensaver.cpp +++ b/core/launcher/screensaver.cpp | |||
@@ -1,328 +1,328 @@ | |||
1 | 1 | ||
2 | #include "screensaver.h" | 2 | #include "screensaver.h" |
3 | 3 | ||
4 | #include <qpe/config.h> | 4 | #include <qpe/config.h> |
5 | #include <qpe/network.h> | 5 | #include <qpe/network.h> |
6 | 6 | ||
7 | #include <opie2/odevice.h> | 7 | #include <opie2/odevice.h> |
8 | 8 | ||
9 | 9 | ||
10 | using namespace Opie; | 10 | using namespace Opie::Core; |
11 | 11 | ||
12 | 12 | ||
13 | 13 | ||
14 | OpieScreenSaver::OpieScreenSaver ( ) | 14 | OpieScreenSaver::OpieScreenSaver ( ) |
15 | : QObject ( 0, "screensaver" ), QWSScreenSaver ( ) | 15 | : QObject ( 0, "screensaver" ), QWSScreenSaver ( ) |
16 | { | 16 | { |
17 | m_disable_suspend = 100; | 17 | m_disable_suspend = 100; |
18 | m_enable_dim = false; | 18 | m_enable_dim = false; |
19 | m_enable_lightoff = false; | 19 | m_enable_lightoff = false; |
20 | m_enable_suspend = false; | 20 | m_enable_suspend = false; |
21 | m_onlylcdoff = false; | 21 | m_onlylcdoff = false; |
22 | 22 | ||
23 | m_enable_dim_ac = false; | 23 | m_enable_dim_ac = false; |
24 | m_enable_lightoff_ac = false; | 24 | m_enable_lightoff_ac = false; |
25 | m_enable_suspend_ac = false; | 25 | m_enable_suspend_ac = false; |
26 | m_onlylcdoff_ac = false; | 26 | m_onlylcdoff_ac = false; |
27 | 27 | ||
28 | m_use_light_sensor = false; | 28 | m_use_light_sensor = false; |
29 | m_backlight_sensor = -1; | 29 | m_backlight_sensor = -1; |
30 | ::memset ( m_sensordata, 0xff, LS_Count * sizeof( m_sensordata [0] )); | 30 | ::memset ( m_sensordata, 0xff, LS_Count * sizeof( m_sensordata [0] )); |
31 | 31 | ||
32 | m_lcd_status = true; | 32 | m_lcd_status = true; |
33 | 33 | ||
34 | m_backlight_normal = -1; | 34 | m_backlight_normal = -1; |
35 | m_backlight_current = -1; | 35 | m_backlight_current = -1; |
36 | m_backlight_forcedoff = false; | 36 | m_backlight_forcedoff = false; |
37 | 37 | ||
38 | m_on_ac = false; | 38 | m_on_ac = false; |
39 | 39 | ||
40 | m_level = -1; | 40 | m_level = -1; |
41 | 41 | ||
42 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 42 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
43 | ODevice::inst ( )-> setDisplayStatus ( true ); | 43 | ODevice::inst ( )-> setDisplayStatus ( true ); |
44 | setBacklight ( -1 ); | 44 | setBacklight ( -1 ); |
45 | } | 45 | } |
46 | 46 | ||
47 | 47 | ||
48 | /** | 48 | /** |
49 | * Stops the screen saver | 49 | * Stops the screen saver |
50 | */ | 50 | */ |
51 | void OpieScreenSaver::restore() | 51 | void OpieScreenSaver::restore() |
52 | { | 52 | { |
53 | m_level = -1; | 53 | m_level = -1; |
54 | 54 | ||
55 | if ( !m_lcd_status ) { // We must have turned it off | 55 | if ( !m_lcd_status ) { // We must have turned it off |
56 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 56 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
57 | m_lcd_status = true; | 57 | m_lcd_status = true; |
58 | } | 58 | } |
59 | 59 | ||
60 | setBacklightInternal ( -1 ); | 60 | setBacklightInternal ( -1 ); |
61 | } | 61 | } |
62 | 62 | ||
63 | 63 | ||
64 | /** | 64 | /** |
65 | * Starts the screen saver | 65 | * Starts the screen saver |
66 | * | 66 | * |
67 | * @param level what level of screen saving should happen (0=lowest non-off, 1=off, | 67 | * @param level what level of screen saving should happen (0=lowest non-off, 1=off, |
68 | * 2=suspend whole machine) | 68 | * 2=suspend whole machine) |
69 | * @returns true on success | 69 | * @returns true on success |
70 | */ | 70 | */ |
71 | bool OpieScreenSaver::save( int level ) | 71 | bool OpieScreenSaver::save( int level ) |
72 | { | 72 | { |
73 | m_level = level; | 73 | m_level = level; |
74 | 74 | ||
75 | switch ( level ) { | 75 | switch ( level ) { |
76 | case 0: | 76 | case 0: |
77 | if (( m_on_ac && m_enable_dim_ac ) || | 77 | if (( m_on_ac && m_enable_dim_ac ) || |
78 | ( !m_on_ac && m_enable_dim )) { | 78 | ( !m_on_ac && m_enable_dim )) { |
79 | if (( m_disable_suspend > 0 ) && ( m_backlight_current > 1 ) && !m_use_light_sensor ) | 79 | if (( m_disable_suspend > 0 ) && ( m_backlight_current > 1 ) && !m_use_light_sensor ) |
80 | setBacklightInternal ( 1 ); // lowest non-off | 80 | setBacklightInternal ( 1 ); // lowest non-off |
81 | } | 81 | } |
82 | return true; | 82 | return true; |
83 | break; | 83 | break; |
84 | 84 | ||
85 | case 1: | 85 | case 1: |
86 | if (( m_on_ac && m_enable_lightoff_ac ) || | 86 | if (( m_on_ac && m_enable_lightoff_ac ) || |
87 | ( !m_on_ac && m_enable_lightoff )) { | 87 | ( !m_on_ac && m_enable_lightoff )) { |
88 | if ( m_disable_suspend > 1 ) | 88 | if ( m_disable_suspend > 1 ) |
89 | setBacklightInternal ( 0 ); // off | 89 | setBacklightInternal ( 0 ); // off |
90 | } | 90 | } |
91 | return true; | 91 | return true; |
92 | break; | 92 | break; |
93 | 93 | ||
94 | case 2: | 94 | case 2: |
95 | if (( m_on_ac && !m_enable_suspend_ac ) || | 95 | if (( m_on_ac && !m_enable_suspend_ac ) || |
96 | ( !m_on_ac && !m_enable_suspend )) { | 96 | ( !m_on_ac && !m_enable_suspend )) { |
97 | return true; | 97 | return true; |
98 | } | 98 | } |
99 | 99 | ||
100 | if (( m_on_ac && m_onlylcdoff_ac ) || | 100 | if (( m_on_ac && m_onlylcdoff_ac ) || |
101 | ( !m_on_ac && m_onlylcdoff )) { | 101 | ( !m_on_ac && m_onlylcdoff )) { |
102 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 102 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
103 | m_lcd_status = false; | 103 | m_lcd_status = false; |
104 | return true; | 104 | return true; |
105 | } | 105 | } |
106 | 106 | ||
107 | // We're going to suspend the whole machine | 107 | // We're going to suspend the whole machine |
108 | 108 | ||
109 | if (( m_disable_suspend > 2 ) && !Network::networkOnline ( )) { | 109 | if (( m_disable_suspend > 2 ) && !Network::networkOnline ( )) { |
110 | // TODO: why is this key F34 hard coded? -- schurig | 110 | // TODO: why is this key F34 hard coded? -- schurig |
111 | // Does this now only work an devices with a ODevice::filter? | 111 | // Does this now only work an devices with a ODevice::filter? |
112 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 112 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
113 | return true; | 113 | return true; |
114 | } | 114 | } |
115 | 115 | ||
116 | break; | 116 | break; |
117 | } | 117 | } |
118 | return false; | 118 | return false; |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | /** | 122 | /** |
123 | * Set intervals in seconds for automatic dimming, light off and suspend | 123 | * Set intervals in seconds for automatic dimming, light off and suspend |
124 | * | 124 | * |
125 | * This function also sets the member variables m_m_enable_dim[_ac], | 125 | * This function also sets the member variables m_m_enable_dim[_ac], |
126 | * m_enable_lightoff[_ac], m_enable_suspend[_ac], m_onlylcdoff[_ac] | 126 | * m_enable_lightoff[_ac], m_enable_suspend[_ac], m_onlylcdoff[_ac] |
127 | * | 127 | * |
128 | * @param dim time in seconds to dim, -1 to read value from config file, | 128 | * @param dim time in seconds to dim, -1 to read value from config file, |
129 | * 0 to disable | 129 | * 0 to disable |
130 | * @param lightoff time in seconds to turn LCD backlight off, -1 to | 130 | * @param lightoff time in seconds to turn LCD backlight off, -1 to |
131 | * read value from config file, 0 to disable | 131 | * read value from config file, 0 to disable |
132 | * @param suspend time in seconds to do an APM suspend, -1 to | 132 | * @param suspend time in seconds to do an APM suspend, -1 to |
133 | * read value from config file, 0 to disable | 133 | * read value from config file, 0 to disable |
134 | */ | 134 | */ |
135 | void OpieScreenSaver::setIntervals ( int dim, int lightoff, int suspend ) | 135 | void OpieScreenSaver::setIntervals ( int dim, int lightoff, int suspend ) |
136 | { | 136 | { |
137 | Config config ( "apm" ); | 137 | Config config ( "apm" ); |
138 | config. setGroup ( m_on_ac ? "AC" : "Battery" ); | 138 | config. setGroup ( m_on_ac ? "AC" : "Battery" ); |
139 | 139 | ||
140 | int v[ 4 ]; | 140 | int v[ 4 ]; |
141 | if ( dim < 0 ) | 141 | if ( dim < 0 ) |
142 | dim = config. readNumEntry ( "Dim", m_on_ac ? 60 : 30 ); | 142 | dim = config. readNumEntry ( "Dim", m_on_ac ? 60 : 30 ); |
143 | if ( lightoff < 0 ) | 143 | if ( lightoff < 0 ) |
144 | lightoff = config. readNumEntry ( "LightOff", m_on_ac ? 120 : 20 ); | 144 | lightoff = config. readNumEntry ( "LightOff", m_on_ac ? 120 : 20 ); |
145 | if ( suspend < 0 ) | 145 | if ( suspend < 0 ) |
146 | suspend = config. readNumEntry ( "Suspend", m_on_ac ? 0 : 60 ); | 146 | suspend = config. readNumEntry ( "Suspend", m_on_ac ? 0 : 60 ); |
147 | 147 | ||
148 | if ( m_on_ac ) { | 148 | if ( m_on_ac ) { |
149 | m_enable_dim_ac = ( dim > 0 ); | 149 | m_enable_dim_ac = ( dim > 0 ); |
150 | m_enable_lightoff_ac = ( lightoff > 0 ); | 150 | m_enable_lightoff_ac = ( lightoff > 0 ); |
151 | m_enable_suspend_ac = ( suspend > 0 ); | 151 | m_enable_suspend_ac = ( suspend > 0 ); |
152 | m_onlylcdoff_ac = config.readBoolEntry ( "LcdOffOnly", false ); | 152 | m_onlylcdoff_ac = config.readBoolEntry ( "LcdOffOnly", false ); |
153 | } | 153 | } |
154 | else { | 154 | else { |
155 | m_enable_dim = ( dim > 0 ); | 155 | m_enable_dim = ( dim > 0 ); |
156 | m_enable_lightoff = ( lightoff > 0 ); | 156 | m_enable_lightoff = ( lightoff > 0 ); |
157 | m_enable_suspend = ( suspend > 0 ); | 157 | m_enable_suspend = ( suspend > 0 ); |
158 | m_onlylcdoff = config.readBoolEntry ( "LcdOffOnly", false ); | 158 | m_onlylcdoff = config.readBoolEntry ( "LcdOffOnly", false ); |
159 | } | 159 | } |
160 | 160 | ||
161 | //qDebug("screen saver intervals: %d %d %d", dim, lightoff, suspend); | 161 | //qDebug("screen saver intervals: %d %d %d", dim, lightoff, suspend); |
162 | 162 | ||
163 | v [ 0 ] = QMAX( 1000 * dim, 100 ); | 163 | v [ 0 ] = QMAX( 1000 * dim, 100 ); |
164 | v [ 1 ] = QMAX( 1000 * lightoff, 100 ); | 164 | v [ 1 ] = QMAX( 1000 * lightoff, 100 ); |
165 | v [ 2 ] = QMAX( 1000 * suspend, 100 ); | 165 | v [ 2 ] = QMAX( 1000 * suspend, 100 ); |
166 | v [ 3 ] = 0; | 166 | v [ 3 ] = 0; |
167 | 167 | ||
168 | if ( !dim && !lightoff && !suspend ) | 168 | if ( !dim && !lightoff && !suspend ) |
169 | QWSServer::setScreenSaverInterval( 0 ); | 169 | QWSServer::setScreenSaverInterval( 0 ); |
170 | else | 170 | else |
171 | QWSServer::setScreenSaverIntervals( v ); | 171 | QWSServer::setScreenSaverIntervals( v ); |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | /** | 175 | /** |
176 | * Set suspend time. Will read the dim and lcd-off times from the config file. | 176 | * Set suspend time. Will read the dim and lcd-off times from the config file. |
177 | * | 177 | * |
178 | * @param suspend time in seconds to go into APM suspend, -1 to | 178 | * @param suspend time in seconds to go into APM suspend, -1 to |
179 | * read value from config file, 0 to disable | 179 | * read value from config file, 0 to disable |
180 | */ | 180 | */ |
181 | void OpieScreenSaver::setInterval ( int interval ) | 181 | void OpieScreenSaver::setInterval ( int interval ) |
182 | { | 182 | { |
183 | setIntervals ( -1, -1, interval ); | 183 | setIntervals ( -1, -1, interval ); |
184 | } | 184 | } |
185 | 185 | ||
186 | 186 | ||
187 | void OpieScreenSaver::setMode ( int mode ) | 187 | void OpieScreenSaver::setMode ( int mode ) |
188 | { | 188 | { |
189 | if ( mode > m_disable_suspend ) | 189 | if ( mode > m_disable_suspend ) |
190 | setInterval ( -1 ); | 190 | setInterval ( -1 ); |
191 | m_disable_suspend = mode; | 191 | m_disable_suspend = mode; |
192 | } | 192 | } |
193 | 193 | ||
194 | 194 | ||
195 | /** | 195 | /** |
196 | * Set display brightness | 196 | * Set display brightness |
197 | * | 197 | * |
198 | * Get's default values for backlight, contrast and light sensor from config file. | 198 | * Get's default values for backlight, contrast and light sensor from config file. |
199 | * | 199 | * |
200 | * @param bright desired brighness (-1 to use automatic sensor data or value | 200 | * @param bright desired brighness (-1 to use automatic sensor data or value |
201 | * from config file, -2 to toggle backlight on and off, -3 to | 201 | * from config file, -2 to toggle backlight on and off, -3 to |
202 | * force backlight off) | 202 | * force backlight off) |
203 | */ | 203 | */ |
204 | void OpieScreenSaver::setBacklight ( int bright ) | 204 | void OpieScreenSaver::setBacklight ( int bright ) |
205 | { | 205 | { |
206 | // Read from config | 206 | // Read from config |
207 | Config config ( "apm" ); | 207 | Config config ( "apm" ); |
208 | config. setGroup ( m_on_ac ? "AC" : "Battery" ); | 208 | config. setGroup ( m_on_ac ? "AC" : "Battery" ); |
209 | m_backlight_normal = config. readNumEntry ( "Brightness", m_on_ac ? 255 : 127 ); | 209 | m_backlight_normal = config. readNumEntry ( "Brightness", m_on_ac ? 255 : 127 ); |
210 | int contrast = config. readNumEntry ( "Contrast", 127); | 210 | int contrast = config. readNumEntry ( "Contrast", 127); |
211 | m_use_light_sensor = config. readBoolEntry ( "LightSensor", false ); | 211 | m_use_light_sensor = config. readBoolEntry ( "LightSensor", false ); |
212 | 212 | ||
213 | //qDebug ( "setBacklight: %d (norm: %d) (ls: %d)", bright, m_backlight_normal, m_use_light_sensor ? 1 : 0 ); | 213 | //qDebug ( "setBacklight: %d (norm: %d) (ls: %d)", bright, m_backlight_normal, m_use_light_sensor ? 1 : 0 ); |
214 | 214 | ||
215 | killTimers ( ); | 215 | killTimers ( ); |
216 | if (( bright < 0 ) && m_use_light_sensor ) { | 216 | if (( bright < 0 ) && m_use_light_sensor ) { |
217 | QStringList sl = config. readListEntry ( "LightSensorData", ';' ); | 217 | QStringList sl = config. readListEntry ( "LightSensorData", ';' ); |
218 | 218 | ||
219 | m_sensordata [LS_SensorMin] = 40; | 219 | m_sensordata [LS_SensorMin] = 40; |
220 | m_sensordata [LS_SensorMax] = 215; | 220 | m_sensordata [LS_SensorMax] = 215; |
221 | m_sensordata [LS_LightMin] = 1; | 221 | m_sensordata [LS_LightMin] = 1; |
222 | m_sensordata [LS_LightMax] = 255; | 222 | m_sensordata [LS_LightMax] = 255; |
223 | m_sensordata [LS_Steps] = 12; | 223 | m_sensordata [LS_Steps] = 12; |
224 | m_sensordata [LS_Interval] = 2000; | 224 | m_sensordata [LS_Interval] = 2000; |
225 | 225 | ||
226 | for ( uint i = 0; i < LS_Count; i++ ) { | 226 | for ( uint i = 0; i < LS_Count; i++ ) { |
227 | if ( i < sl. count ( )) | 227 | if ( i < sl. count ( )) |
228 | m_sensordata [i] = sl [i]. toInt ( ); | 228 | m_sensordata [i] = sl [i]. toInt ( ); |
229 | } | 229 | } |
230 | if ( m_sensordata [LS_Steps] < 2 ) // sanity check to avoid SIGFPE | 230 | if ( m_sensordata [LS_Steps] < 2 ) // sanity check to avoid SIGFPE |
231 | m_sensordata [LS_Steps] = 2; | 231 | m_sensordata [LS_Steps] = 2; |
232 | 232 | ||
233 | timerEvent ( 0 ); | 233 | timerEvent ( 0 ); |
234 | startTimer ( m_sensordata [LS_Interval] ); | 234 | startTimer ( m_sensordata [LS_Interval] ); |
235 | } | 235 | } |
236 | 236 | ||
237 | setBacklightInternal ( bright ); | 237 | setBacklightInternal ( bright ); |
238 | ODevice::inst ( )-> setDisplayContrast(contrast); | 238 | ODevice::inst ( )-> setDisplayContrast(contrast); |
239 | } | 239 | } |
240 | 240 | ||
241 | 241 | ||
242 | /** | 242 | /** |
243 | * Internal brightness setting method | 243 | * Internal brightness setting method |
244 | * | 244 | * |
245 | * Get's default values for backlight and light sensor from config file. | 245 | * Get's default values for backlight and light sensor from config file. |
246 | * | 246 | * |
247 | * @param bright desired brighness (-1 to use automatic sensor data or value | 247 | * @param bright desired brighness (-1 to use automatic sensor data or value |
248 | * from config file, -2 to toggle backlight on and off, -3 to | 248 | * from config file, -2 to toggle backlight on and off, -3 to |
249 | * force backlight off) | 249 | * force backlight off) |
250 | */ | 250 | */ |
251 | void OpieScreenSaver::setBacklightInternal ( int bright ) | 251 | void OpieScreenSaver::setBacklightInternal ( int bright ) |
252 | { | 252 | { |
253 | if ( bright == -3 ) { | 253 | if ( bright == -3 ) { |
254 | // Forced on | 254 | // Forced on |
255 | m_backlight_forcedoff = false; | 255 | m_backlight_forcedoff = false; |
256 | bright = -1; | 256 | bright = -1; |
257 | } | 257 | } |
258 | if ( m_backlight_forcedoff && bright != -2 ) | 258 | if ( m_backlight_forcedoff && bright != -2 ) |
259 | return ; | 259 | return ; |
260 | if ( bright == -2 ) { | 260 | if ( bright == -2 ) { |
261 | // Toggle between off and on | 261 | // Toggle between off and on |
262 | bright = m_backlight_current ? 0 : -1; | 262 | bright = m_backlight_current ? 0 : -1; |
263 | m_backlight_forcedoff = !bright; | 263 | m_backlight_forcedoff = !bright; |
264 | } | 264 | } |
265 | if ( bright == -1 ) | 265 | if ( bright == -1 ) |
266 | bright = m_use_light_sensor ? m_backlight_sensor : m_backlight_normal; | 266 | bright = m_use_light_sensor ? m_backlight_sensor : m_backlight_normal; |
267 | 267 | ||
268 | if ( bright != m_backlight_current ) { | 268 | if ( bright != m_backlight_current ) { |
269 | ODevice::inst ( )-> setDisplayBrightness ( bright ); | 269 | ODevice::inst ( )-> setDisplayBrightness ( bright ); |
270 | m_backlight_current = bright; | 270 | m_backlight_current = bright; |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | 274 | ||
275 | /** | 275 | /** |
276 | * Timer event used for automatic setting the backlight according to a light sensor | 276 | * Timer event used for automatic setting the backlight according to a light sensor |
277 | * and to set the default brightness | 277 | * and to set the default brightness |
278 | */ | 278 | */ |
279 | void OpieScreenSaver::timerEvent ( QTimerEvent * ) | 279 | void OpieScreenSaver::timerEvent ( QTimerEvent * ) |
280 | { | 280 | { |
281 | int s = ODevice::inst ( )-> readLightSensor ( ) * 256 / ODevice::inst ( )-> lightSensorResolution ( ); | 281 | int s = ODevice::inst ( )-> readLightSensor ( ) * 256 / ODevice::inst ( )-> lightSensorResolution ( ); |
282 | 282 | ||
283 | if ( s < m_sensordata [LS_SensorMin] ) | 283 | if ( s < m_sensordata [LS_SensorMin] ) |
284 | m_backlight_sensor = m_sensordata [LS_LightMax]; | 284 | m_backlight_sensor = m_sensordata [LS_LightMax]; |
285 | else if ( s >= m_sensordata [LS_SensorMax] ) | 285 | else if ( s >= m_sensordata [LS_SensorMax] ) |
286 | m_backlight_sensor = m_sensordata [LS_LightMin]; | 286 | m_backlight_sensor = m_sensordata [LS_LightMin]; |
287 | else { | 287 | else { |
288 | int dx = m_sensordata [LS_SensorMax] - m_sensordata [LS_SensorMin]; | 288 | int dx = m_sensordata [LS_SensorMax] - m_sensordata [LS_SensorMin]; |
289 | int dy = m_sensordata [LS_LightMax] - m_sensordata [LS_LightMin]; | 289 | int dy = m_sensordata [LS_LightMax] - m_sensordata [LS_LightMin]; |
290 | 290 | ||
291 | int stepno = ( s - m_sensordata [LS_SensorMin] ) * m_sensordata [LS_Steps] / dx; // dx is never 0 | 291 | int stepno = ( s - m_sensordata [LS_SensorMin] ) * m_sensordata [LS_Steps] / dx; // dx is never 0 |
292 | 292 | ||
293 | m_backlight_sensor = m_sensordata [LS_LightMax] - dy * stepno / ( m_sensordata [LS_Steps] - 1 ); | 293 | m_backlight_sensor = m_sensordata [LS_LightMax] - dy * stepno / ( m_sensordata [LS_Steps] - 1 ); |
294 | } | 294 | } |
295 | 295 | ||
296 | //qDebug ( "f(%d) = %d [%d - %d] -> [%d - %d] / %d", s, m_backlight_sensor, m_sensordata [LS_SensorMin], m_sensordata [LS_SensorMax], m_sensordata [LS_LightMin], m_sensordata [LS_LightMax], m_sensordata [LS_Steps] ); | 296 | //qDebug ( "f(%d) = %d [%d - %d] -> [%d - %d] / %d", s, m_backlight_sensor, m_sensordata [LS_SensorMin], m_sensordata [LS_SensorMax], m_sensordata [LS_LightMin], m_sensordata [LS_LightMax], m_sensordata [LS_Steps] ); |
297 | 297 | ||
298 | if ( m_level <= 0 ) | 298 | if ( m_level <= 0 ) |
299 | setBacklightInternal ( -1 ); | 299 | setBacklightInternal ( -1 ); |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | /** | 303 | /** |
304 | * Like ODevice::setDisplayStatus(), but keep current state in m_lcd_status. | 304 | * Like ODevice::setDisplayStatus(), but keep current state in m_lcd_status. |
305 | */ | 305 | */ |
306 | void OpieScreenSaver::setDisplayState ( bool on ) | 306 | void OpieScreenSaver::setDisplayState ( bool on ) |
307 | { | 307 | { |
308 | if ( m_lcd_status != on ) { | 308 | if ( m_lcd_status != on ) { |
309 | ODevice::inst ( ) -> setDisplayStatus ( on ); | 309 | ODevice::inst ( ) -> setDisplayStatus ( on ); |
310 | m_lcd_status = on; | 310 | m_lcd_status = on; |
311 | } | 311 | } |
312 | } | 312 | } |
313 | 313 | ||
314 | 314 | ||
315 | /** | 315 | /** |
316 | * Set display to default ac/battery settings when power status changed. | 316 | * Set display to default ac/battery settings when power status changed. |
317 | */ | 317 | */ |
318 | void OpieScreenSaver::powerStatusChanged ( PowerStatus ps ) | 318 | void OpieScreenSaver::powerStatusChanged ( PowerStatus ps ) |
319 | { | 319 | { |
320 | bool newonac = ( ps. acStatus ( ) == PowerStatus::Online ); | 320 | bool newonac = ( ps. acStatus ( ) == PowerStatus::Online ); |
321 | 321 | ||
322 | if ( newonac != m_on_ac ) { | 322 | if ( newonac != m_on_ac ) { |
323 | m_on_ac = newonac; | 323 | m_on_ac = newonac; |
324 | setInterval ( -1 ); | 324 | setInterval ( -1 ); |
325 | setBacklight ( -1 ); | 325 | setBacklight ( -1 ); |
326 | restore ( ); | 326 | restore ( ); |
327 | } | 327 | } |
328 | } | 328 | } |
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index ea0b792..634082b 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp | |||
@@ -1,323 +1,323 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "server.h" | 21 | #include "server.h" |
22 | #include "serverapp.h" | 22 | #include "serverapp.h" |
23 | #include "startmenu.h" | 23 | #include "startmenu.h" |
24 | #include "launcher.h" | 24 | #include "launcher.h" |
25 | #include "transferserver.h" | 25 | #include "transferserver.h" |
26 | #include "qcopbridge.h" | 26 | #include "qcopbridge.h" |
27 | #include "irserver.h" | 27 | #include "irserver.h" |
28 | #include "packageslave.h" | 28 | #include "packageslave.h" |
29 | #include "calibrate.h" | 29 | #include "calibrate.h" |
30 | #include "qrsync.h" | 30 | #include "qrsync.h" |
31 | #include "syncdialog.h" | 31 | #include "syncdialog.h" |
32 | #include "shutdownimpl.h" | 32 | #include "shutdownimpl.h" |
33 | #include "applauncher.h" | 33 | #include "applauncher.h" |
34 | #if 0 | 34 | #if 0 |
35 | #include "suspendmonitor.h" | 35 | #include "suspendmonitor.h" |
36 | #endif | 36 | #endif |
37 | #include "documentlist.h" | 37 | #include "documentlist.h" |
38 | 38 | ||
39 | #include <qtopia/applnk.h> | 39 | #include <qtopia/applnk.h> |
40 | #include <qtopia/private/categories.h> | 40 | #include <qtopia/private/categories.h> |
41 | #include <qtopia/mimetype.h> | 41 | #include <qtopia/mimetype.h> |
42 | #include <qtopia/config.h> | 42 | #include <qtopia/config.h> |
43 | #include <qtopia/resource.h> | 43 | #include <qtopia/resource.h> |
44 | #include <qtopia/version.h> | 44 | #include <qtopia/version.h> |
45 | #include <qtopia/storage.h> | 45 | #include <qtopia/storage.h> |
46 | 46 | ||
47 | #include <qtopia/qcopenvelope_qws.h> | 47 | #include <qtopia/qcopenvelope_qws.h> |
48 | #include <qwindowsystem_qws.h> | 48 | #include <qwindowsystem_qws.h> |
49 | #include <qgfx_qws.h> | 49 | #include <qgfx_qws.h> |
50 | #include <qtopia/global.h> | 50 | #include <qtopia/global.h> |
51 | //#include <qtopia/custom.h> | 51 | //#include <qtopia/custom.h> |
52 | 52 | ||
53 | #include <opie2/odevicebutton.h> | 53 | #include <opie2/odevicebutton.h> |
54 | #include <opie2/odevice.h> | 54 | #include <opie2/odevice.h> |
55 | 55 | ||
56 | #include <unistd.h> | 56 | #include <unistd.h> |
57 | #include <qmainwindow.h> | 57 | #include <qmainwindow.h> |
58 | #include <qmessagebox.h> | 58 | #include <qmessagebox.h> |
59 | #include <qtimer.h> | 59 | #include <qtimer.h> |
60 | #include <qtextstream.h> | 60 | #include <qtextstream.h> |
61 | 61 | ||
62 | #include <stdlib.h> | 62 | #include <stdlib.h> |
63 | 63 | ||
64 | extern QRect qt_maxWindowRect; | 64 | extern QRect qt_maxWindowRect; |
65 | 65 | ||
66 | using namespace Opie; | ||
67 | 66 | ||
67 | using namespace Opie::Core; | ||
68 | static QWidget *calibrate(bool) | 68 | static QWidget *calibrate(bool) |
69 | { | 69 | { |
70 | #ifdef Q_WS_QWS | 70 | #ifdef Q_WS_QWS |
71 | Calibrate *c = new Calibrate; | 71 | Calibrate *c = new Calibrate; |
72 | c->show(); | 72 | c->show(); |
73 | return c; | 73 | return c; |
74 | #else | 74 | #else |
75 | return 0; | 75 | return 0; |
76 | #endif | 76 | #endif |
77 | } | 77 | } |
78 | 78 | ||
79 | #define FACTORY(T) \ | 79 | #define FACTORY(T) \ |
80 | static QWidget *new##T( bool maximized ) { \ | 80 | static QWidget *new##T( bool maximized ) { \ |
81 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ | 81 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ |
82 | if ( maximized ) { \ | 82 | if ( maximized ) { \ |
83 | if ( qApp->desktop()->width() <= 350 ) { \ | 83 | if ( qApp->desktop()->width() <= 350 ) { \ |
84 | w->showMaximized(); \ | 84 | w->showMaximized(); \ |
85 | } else { \ | 85 | } else { \ |
86 | w->resize( QSize( 300, 300 ) ); \ | 86 | w->resize( QSize( 300, 300 ) ); \ |
87 | } \ | 87 | } \ |
88 | } \ | 88 | } \ |
89 | w->show(); \ | 89 | w->show(); \ |
90 | return w; \ | 90 | return w; \ |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | #ifdef SINGLE_APP | 94 | #ifdef SINGLE_APP |
95 | #define APP(a,b,c,d) FACTORY(b) | 95 | #define APP(a,b,c,d) FACTORY(b) |
96 | #include "apps.h" | 96 | #include "apps.h" |
97 | #undef APP | 97 | #undef APP |
98 | #endif // SINGLE_APP | 98 | #endif // SINGLE_APP |
99 | 99 | ||
100 | static Global::Command builtins[] = { | 100 | static Global::Command builtins[] = { |
101 | 101 | ||
102 | #ifdef SINGLE_APP | 102 | #ifdef SINGLE_APP |
103 | #define APP(a,b,c,d) { a, new##b, c, d }, | 103 | #define APP(a,b,c,d) { a, new##b, c, d }, |
104 | #include "apps.h" | 104 | #include "apps.h" |
105 | #undef APP | 105 | #undef APP |
106 | #endif | 106 | #endif |
107 | 107 | ||
108 | /* FIXME defines need to be defined*/ | 108 | /* FIXME defines need to be defined*/ |
109 | #if !defined(OPIE_NO_BUILTIN_CALIBRATE) | 109 | #if !defined(OPIE_NO_BUILTIN_CALIBRATE) |
110 | { "calibrate", calibrate, 1, 0 }, // No tr | 110 | { "calibrate", calibrate, 1, 0 }, // No tr |
111 | #endif | 111 | #endif |
112 | #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) | 112 | #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) |
113 | { "shutdown", Global::shutdown, 1, 0 }, // No tr | 113 | { "shutdown", Global::shutdown, 1, 0 }, // No tr |
114 | // { "run", run, 1, 0 }, // No tr | 114 | // { "run", run, 1, 0 }, // No tr |
115 | #endif | 115 | #endif |
116 | 116 | ||
117 | { 0, calibrate,0, 0 }, | 117 | { 0, calibrate,0, 0 }, |
118 | }; | 118 | }; |
119 | 119 | ||
120 | 120 | ||
121 | //--------------------------------------------------------------------------- | 121 | //--------------------------------------------------------------------------- |
122 | 122 | ||
123 | 123 | ||
124 | //=========================================================================== | 124 | //=========================================================================== |
125 | 125 | ||
126 | Server::Server() : | 126 | Server::Server() : |
127 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 127 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
128 | qcopBridge( 0 ), | 128 | qcopBridge( 0 ), |
129 | transferServer( 0 ), | 129 | transferServer( 0 ), |
130 | packageHandler( 0 ), | 130 | packageHandler( 0 ), |
131 | syncDialog( 0 ) | 131 | syncDialog( 0 ) |
132 | { | 132 | { |
133 | Global::setBuiltinCommands(builtins); | 133 | Global::setBuiltinCommands(builtins); |
134 | 134 | ||
135 | tid_xfer = 0; | 135 | tid_xfer = 0; |
136 | /* ### FIXME ### */ | 136 | /* ### FIXME ### */ |
137 | /* tid_today = startTimer(3600*2*1000);*/ | 137 | /* tid_today = startTimer(3600*2*1000);*/ |
138 | last_today_show = QDate::currentDate(); | 138 | last_today_show = QDate::currentDate(); |
139 | 139 | ||
140 | #if 0 | 140 | #if 0 |
141 | tsmMonitor = new TempScreenSaverMode(); | 141 | tsmMonitor = new TempScreenSaverMode(); |
142 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); | 142 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); |
143 | #endif | 143 | #endif |
144 | 144 | ||
145 | serverGui = new Launcher; | 145 | serverGui = new Launcher; |
146 | serverGui->createGUI(); | 146 | serverGui->createGUI(); |
147 | 147 | ||
148 | docList = new DocumentList( serverGui ); | 148 | docList = new DocumentList( serverGui ); |
149 | appLauncher = new AppLauncher(this); | 149 | appLauncher = new AppLauncher(this); |
150 | connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); | 150 | connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); |
151 | connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); | 151 | connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); |
152 | connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); | 152 | connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); |
153 | 153 | ||
154 | storage = new StorageInfo( this ); | 154 | storage = new StorageInfo( this ); |
155 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); | 155 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); |
156 | 156 | ||
157 | // start services | 157 | // start services |
158 | startTransferServer(); | 158 | startTransferServer(); |
159 | (void) new IrServer( this ); | 159 | (void) new IrServer( this ); |
160 | 160 | ||
161 | packageHandler = new PackageHandler( this ); | 161 | packageHandler = new PackageHandler( this ); |
162 | connect(qApp, SIGNAL(activate(const Opie::ODeviceButton*,bool)), | 162 | connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), |
163 | this,SLOT(activate(const Opie::ODeviceButton*,bool))); | 163 | this,SLOT(activate(const Opie::Core::ODeviceButton*,bool))); |
164 | 164 | ||
165 | setGeometry( -10, -10, 9, 9 ); | 165 | setGeometry( -10, -10, 9, 9 ); |
166 | 166 | ||
167 | QCopChannel *channel = new QCopChannel("QPE/System", this); | 167 | QCopChannel *channel = new QCopChannel("QPE/System", this); |
168 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), | 168 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), |
169 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); | 169 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); |
170 | 170 | ||
171 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); | 171 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); |
172 | connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 172 | connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
173 | this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); | 173 | this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); |
174 | 174 | ||
175 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); | 175 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); |
176 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); | 176 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); |
177 | 177 | ||
178 | preloadApps(); | 178 | preloadApps(); |
179 | } | 179 | } |
180 | 180 | ||
181 | void Server::show() | 181 | void Server::show() |
182 | { | 182 | { |
183 | ServerApplication::login(TRUE); | 183 | ServerApplication::login(TRUE); |
184 | QWidget::show(); | 184 | QWidget::show(); |
185 | } | 185 | } |
186 | 186 | ||
187 | Server::~Server() | 187 | Server::~Server() |
188 | { | 188 | { |
189 | serverGui->destroyGUI(); | 189 | serverGui->destroyGUI(); |
190 | delete docList; | 190 | delete docList; |
191 | delete qcopBridge; | 191 | delete qcopBridge; |
192 | delete transferServer; | 192 | delete transferServer; |
193 | delete serverGui; | 193 | delete serverGui; |
194 | #if 0 | 194 | #if 0 |
195 | delete tsmMonitor; | 195 | delete tsmMonitor; |
196 | #endif | 196 | #endif |
197 | } | 197 | } |
198 | 198 | ||
199 | static bool hasVisibleWindow(const QString& clientname, bool partial) | 199 | static bool hasVisibleWindow(const QString& clientname, bool partial) |
200 | { | 200 | { |
201 | #ifdef QWS | 201 | #ifdef QWS |
202 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 202 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
203 | QWSWindow* w; | 203 | QWSWindow* w; |
204 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 204 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
205 | if ( w->client()->identity() == clientname ) { | 205 | if ( w->client()->identity() == clientname ) { |
206 | if ( partial && !w->isFullyObscured() ) | 206 | if ( partial && !w->isFullyObscured() ) |
207 | return TRUE; | 207 | return TRUE; |
208 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { | 208 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { |
209 | # if QT_VERSION < 0x030000 | 209 | # if QT_VERSION < 0x030000 |
210 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, | 210 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, |
211 | QSize(qt_screen->width(),qt_screen->height()) ); | 211 | QSize(qt_screen->width(),qt_screen->height()) ); |
212 | # else | 212 | # else |
213 | QRect mwr = qt_maxWindowRect; | 213 | QRect mwr = qt_maxWindowRect; |
214 | # endif | 214 | # endif |
215 | if ( mwr.contains(w->requested().boundingRect()) ) | 215 | if ( mwr.contains(w->requested().boundingRect()) ) |
216 | return TRUE; | 216 | return TRUE; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } | 219 | } |
220 | #endif | 220 | #endif |
221 | return FALSE; | 221 | return FALSE; |
222 | } | 222 | } |
223 | 223 | ||
224 | void Server::activate(const Opie::ODeviceButton* button, bool held) | 224 | void Server::activate(const ODeviceButton* button, bool held) |
225 | { | 225 | { |
226 | Global::terminateBuiltin("calibrate"); // No tr | 226 | Global::terminateBuiltin("calibrate"); // No tr |
227 | Opie::OQCopMessage om; | 227 | OQCopMessage om; |
228 | if ( held ) { | 228 | if ( held ) { |
229 | om = button->heldAction(); | 229 | om = button->heldAction(); |
230 | } else { | 230 | } else { |
231 | om = button->pressedAction(); | 231 | om = button->pressedAction(); |
232 | } | 232 | } |
233 | 233 | ||
234 | if ( om.channel() != "ignore" ) | 234 | if ( om.channel() != "ignore" ) |
235 | om.send(); | 235 | om.send(); |
236 | 236 | ||
237 | // A button with no action defined, will return a null ServiceRequest. Don't attempt | 237 | // A button with no action defined, will return a null ServiceRequest. Don't attempt |
238 | // to send/do anything with this as it will crash | 238 | // to send/do anything with this as it will crash |
239 | /* ### FIXME */ | 239 | /* ### FIXME */ |
240 | #if 0 | 240 | #if 0 |
241 | if ( !sr.isNull() ) { | 241 | if ( !sr.isNull() ) { |
242 | QString app = sr.app(); | 242 | QString app = sr.app(); |
243 | bool vis = hasVisibleWindow(app, app != "qpe"); | 243 | bool vis = hasVisibleWindow(app, app != "qpe"); |
244 | if ( sr.message() == "raise()" && vis ) { | 244 | if ( sr.message() == "raise()" && vis ) { |
245 | sr.setMessage("nextView()"); | 245 | sr.setMessage("nextView()"); |
246 | } else { | 246 | } else { |
247 | // "back door" | 247 | // "back door" |
248 | sr << (int)vis; | 248 | sr << (int)vis; |
249 | } | 249 | } |
250 | 250 | ||
251 | sr.send(); | 251 | sr.send(); |
252 | } | 252 | } |
253 | #endif | 253 | #endif |
254 | } | 254 | } |
255 | 255 | ||
256 | 256 | ||
257 | #ifdef Q_WS_QWS | 257 | #ifdef Q_WS_QWS |
258 | 258 | ||
259 | 259 | ||
260 | typedef struct KeyOverride { | 260 | typedef struct KeyOverride { |
261 | ushort scan_code; | 261 | ushort scan_code; |
262 | QWSServer::KeyMap map; | 262 | QWSServer::KeyMap map; |
263 | }; | 263 | }; |
264 | 264 | ||
265 | 265 | ||
266 | static const KeyOverride jp109keys[] = { | 266 | static const KeyOverride jp109keys[] = { |
267 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, | 267 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, |
268 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, | 268 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, |
269 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, | 269 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, |
270 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, | 270 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, |
271 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, | 271 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, |
272 | { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } }, | 272 | { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } }, |
273 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, | 273 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, |
274 | { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } }, | 274 | { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } }, |
275 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, | 275 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, |
276 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } }, | 276 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } }, |
277 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, | 277 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, |
278 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, | 278 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, |
279 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } }, | 279 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } }, |
280 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, | 280 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, |
281 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } }, | 281 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } }, |
282 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, | 282 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, |
283 | { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } }, | 283 | { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } }, |
284 | { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } }, | 284 | { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } }, |
285 | { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } }, | 285 | { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } }, |
286 | { 0x00, { 0, 0xffff , 0xffff , 0xffff } } | 286 | { 0x00, { 0, 0xffff , 0xffff , 0xffff } } |
287 | }; | 287 | }; |
288 | 288 | ||
289 | bool Server::setKeyboardLayout( const QString &kb ) | 289 | bool Server::setKeyboardLayout( const QString &kb ) |
290 | { | 290 | { |
291 | //quick demo version that can be extended | 291 | //quick demo version that can be extended |
292 | 292 | ||
293 | QIntDict<QWSServer::KeyMap> *om = 0; | 293 | QIntDict<QWSServer::KeyMap> *om = 0; |
294 | if ( kb == "us101" ) { // No tr | 294 | if ( kb == "us101" ) { // No tr |
295 | om = 0; | 295 | om = 0; |
296 | } else if ( kb == "jp109" ) { | 296 | } else if ( kb == "jp109" ) { |
297 | om = new QIntDict<QWSServer::KeyMap>(37); | 297 | om = new QIntDict<QWSServer::KeyMap>(37); |
298 | const KeyOverride *k = jp109keys; | 298 | const KeyOverride *k = jp109keys; |
299 | while ( k->scan_code ) { | 299 | while ( k->scan_code ) { |
300 | om->insert( k->scan_code, &k->map ); | 300 | om->insert( k->scan_code, &k->map ); |
301 | k++; | 301 | k++; |
302 | } | 302 | } |
303 | } | 303 | } |
304 | QWSServer::setOverrideKeys( om ); | 304 | QWSServer::setOverrideKeys( om ); |
305 | 305 | ||
306 | return TRUE; | 306 | return TRUE; |
307 | } | 307 | } |
308 | 308 | ||
309 | #endif | 309 | #endif |
310 | 310 | ||
311 | void Server::systemMsg(const QCString &msg, const QByteArray &data) | 311 | void Server::systemMsg(const QCString &msg, const QByteArray &data) |
312 | { | 312 | { |
313 | QDataStream stream( data, IO_ReadOnly ); | 313 | QDataStream stream( data, IO_ReadOnly ); |
314 | 314 | ||
315 | if ( msg == "securityChanged()" ) { | 315 | if ( msg == "securityChanged()" ) { |
316 | if ( transferServer ) | 316 | if ( transferServer ) |
317 | transferServer->authorizeConnections(); | 317 | transferServer->authorizeConnections(); |
318 | if ( qcopBridge ) | 318 | if ( qcopBridge ) |
319 | qcopBridge->authorizeConnections(); | 319 | qcopBridge->authorizeConnections(); |
320 | } | 320 | } |
321 | /* ### FIXME support TempScreenSaverMode */ | 321 | /* ### FIXME support TempScreenSaverMode */ |
322 | #if 0 | 322 | #if 0 |
323 | else if ( msg == "setTempScreenSaverMode(int,int)" ) { | 323 | else if ( msg == "setTempScreenSaverMode(int,int)" ) { |
diff --git a/core/launcher/server.h b/core/launcher/server.h index 91bf883..1dc5e7e 100644 --- a/core/launcher/server.h +++ b/core/launcher/server.h | |||
@@ -1,97 +1,99 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef DESKTOP_H | 20 | #ifndef DESKTOP_H |
21 | #define DESKTOP_H | 21 | #define DESKTOP_H |
22 | 22 | ||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | #include <qdatetime.h> | 24 | #include <qdatetime.h> |
25 | 25 | ||
26 | //#include "qcopbridge.h" | 26 | //#include "qcopbridge.h" |
27 | 27 | ||
28 | class QCopBridge; | 28 | class QCopBridge; |
29 | class QHostAddress; | 29 | class QHostAddress; |
30 | class TransferServer; | 30 | class TransferServer; |
31 | class PackageHandler; | 31 | class PackageHandler; |
32 | class ServiceRequest; | 32 | class ServiceRequest; |
33 | class TempScreenSaverMonitor; | 33 | class TempScreenSaverMonitor; |
34 | class AppLauncher; | 34 | class AppLauncher; |
35 | class AppLnkSet; | 35 | class AppLnkSet; |
36 | class StorageInfo; | 36 | class StorageInfo; |
37 | class SyncDialog; | 37 | class SyncDialog; |
38 | class DocumentList; | 38 | class DocumentList; |
39 | class ServerInterface; | 39 | class ServerInterface; |
40 | namespace Opie { | 40 | namespace Opie { |
41 | namespace Core { | ||
41 | class ODeviceButton; | 42 | class ODeviceButton; |
42 | } | 43 | } |
44 | } | ||
43 | 45 | ||
44 | class Server : public QWidget { | 46 | class Server : public QWidget { |
45 | Q_OBJECT | 47 | Q_OBJECT |
46 | public: | 48 | public: |
47 | Server(); | 49 | Server(); |
48 | ~Server(); | 50 | ~Server(); |
49 | 51 | ||
50 | static bool mkdir(const QString &path); | 52 | static bool mkdir(const QString &path); |
51 | 53 | ||
52 | void show(); | 54 | void show(); |
53 | 55 | ||
54 | static bool setKeyboardLayout( const QString &kb ); | 56 | static bool setKeyboardLayout( const QString &kb ); |
55 | 57 | ||
56 | public slots: | 58 | public slots: |
57 | void systemMsg(const QCString &, const QByteArray &); | 59 | void systemMsg(const QCString &, const QByteArray &); |
58 | void receiveTaskBar(const QCString &msg, const QByteArray &data); | 60 | void receiveTaskBar(const QCString &msg, const QByteArray &data); |
59 | void terminateServers(); | 61 | void terminateServers(); |
60 | void pokeTimeMonitors(); | 62 | void pokeTimeMonitors(); |
61 | 63 | ||
62 | private slots: | 64 | private slots: |
63 | void activate(const Opie::ODeviceButton*,bool); | 65 | void activate(const Opie::Core::ODeviceButton*,bool); |
64 | void syncConnectionClosed( const QHostAddress & ); | 66 | void syncConnectionClosed( const QHostAddress & ); |
65 | void applicationLaunched(int pid, const QString &app); | 67 | void applicationLaunched(int pid, const QString &app); |
66 | void applicationTerminated(int pid, const QString &app); | 68 | void applicationTerminated(int pid, const QString &app); |
67 | void applicationConnected(const QString &app); | 69 | void applicationConnected(const QString &app); |
68 | void storageChanged(); | 70 | void storageChanged(); |
69 | void cancelSync(); | 71 | void cancelSync(); |
70 | 72 | ||
71 | protected: | 73 | protected: |
72 | void styleChange( QStyle & ); | 74 | void styleChange( QStyle & ); |
73 | void timerEvent( QTimerEvent *e ); | 75 | void timerEvent( QTimerEvent *e ); |
74 | 76 | ||
75 | private: | 77 | private: |
76 | void layout(); | 78 | void layout(); |
77 | void startTransferServer(); | 79 | void startTransferServer(); |
78 | void preloadApps(); | 80 | void preloadApps(); |
79 | 81 | ||
80 | QCopBridge *qcopBridge; | 82 | QCopBridge *qcopBridge; |
81 | TransferServer *transferServer; | 83 | TransferServer *transferServer; |
82 | PackageHandler *packageHandler; | 84 | PackageHandler *packageHandler; |
83 | QDate last_today_show; | 85 | QDate last_today_show; |
84 | int tid_xfer; | 86 | int tid_xfer; |
85 | /* ### FIXME two below### */ | 87 | /* ### FIXME two below### */ |
86 | // int tid_today; | 88 | // int tid_today; |
87 | // TempScreenSaverMonitor *tsmMonitor; | 89 | // TempScreenSaverMonitor *tsmMonitor; |
88 | StorageInfo *storage; | 90 | StorageInfo *storage; |
89 | SyncDialog *syncDialog; | 91 | SyncDialog *syncDialog; |
90 | AppLauncher *appLauncher; | 92 | AppLauncher *appLauncher; |
91 | DocumentList *docList; | 93 | DocumentList *docList; |
92 | ServerInterface *serverGui; | 94 | ServerInterface *serverGui; |
93 | }; | 95 | }; |
94 | 96 | ||
95 | 97 | ||
96 | #endif // DESKTOP_H | 98 | #endif // DESKTOP_H |
97 | 99 | ||
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index d38dd97..e4e16f2 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -1,447 +1,448 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "serverapp.h" | 21 | #include "serverapp.h" |
22 | 22 | ||
23 | #include <opie2/odevice.h> | 23 | #include <opie2/odevice.h> |
24 | 24 | ||
25 | #include <qtopia/password.h> | 25 | #include <qtopia/password.h> |
26 | #include <qtopia/config.h> | 26 | #include <qtopia/config.h> |
27 | #include <qtopia/power.h> | 27 | #include <qtopia/power.h> |
28 | 28 | ||
29 | #ifdef Q_WS_QWS | 29 | #ifdef Q_WS_QWS |
30 | #include <qtopia/qcopenvelope_qws.h> | 30 | #include <qtopia/qcopenvelope_qws.h> |
31 | #endif | 31 | #endif |
32 | #include <qtopia/global.h> | 32 | #include <qtopia/global.h> |
33 | //#include <qtopia/custom.h> | 33 | //#include <qtopia/custom.h> |
34 | 34 | ||
35 | #ifdef Q_WS_QWS | 35 | #ifdef Q_WS_QWS |
36 | #include <qgfx_qws.h> | 36 | #include <qgfx_qws.h> |
37 | #endif | 37 | #endif |
38 | #ifdef Q_OS_WIN32 | 38 | #ifdef Q_OS_WIN32 |
39 | #include <io.h> | 39 | #include <io.h> |
40 | #include <process.h> | 40 | #include <process.h> |
41 | #else | 41 | #else |
42 | #include <unistd.h> | 42 | #include <unistd.h> |
43 | #endif | 43 | #endif |
44 | #include <qmessagebox.h> | 44 | #include <qmessagebox.h> |
45 | #include <qtimer.h> | 45 | #include <qtimer.h> |
46 | #include <qpainter.h> | 46 | #include <qpainter.h> |
47 | #include <qfile.h> | 47 | #include <qfile.h> |
48 | #include <qpixmapcache.h> | 48 | #include <qpixmapcache.h> |
49 | 49 | ||
50 | #include <stdlib.h> | 50 | #include <stdlib.h> |
51 | #include "screensaver.h" | 51 | #include "screensaver.h" |
52 | 52 | ||
53 | static ServerApplication *serverApp = 0; | 53 | static ServerApplication *serverApp = 0; |
54 | static int loggedin=0; | 54 | static int loggedin=0; |
55 | 55 | ||
56 | using namespace Opie; | 56 | using namespace Opie; |
57 | 57 | ||
58 | using namespace Opie::Core; | ||
58 | QCopKeyRegister::QCopKeyRegister() | 59 | QCopKeyRegister::QCopKeyRegister() |
59 | : m_keyCode( 0 ) { | 60 | : m_keyCode( 0 ) { |
60 | } | 61 | } |
61 | 62 | ||
62 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) | 63 | QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) |
63 | :m_keyCode( k ), m_channel( c ), m_message( m ) { | 64 | :m_keyCode( k ), m_channel( c ), m_message( m ) { |
64 | } | 65 | } |
65 | 66 | ||
66 | int QCopKeyRegister::keyCode()const { | 67 | int QCopKeyRegister::keyCode()const { |
67 | return m_keyCode; | 68 | return m_keyCode; |
68 | } | 69 | } |
69 | 70 | ||
70 | QCString QCopKeyRegister::channel()const { | 71 | QCString QCopKeyRegister::channel()const { |
71 | return m_channel; | 72 | return m_channel; |
72 | } | 73 | } |
73 | 74 | ||
74 | QCString QCopKeyRegister::message()const { | 75 | QCString QCopKeyRegister::message()const { |
75 | return m_message; | 76 | return m_message; |
76 | } | 77 | } |
77 | 78 | ||
78 | bool QCopKeyRegister::send() { | 79 | bool QCopKeyRegister::send() { |
79 | if (m_channel.isNull() ) | 80 | if (m_channel.isNull() ) |
80 | return false; | 81 | return false; |
81 | 82 | ||
82 | QCopEnvelope( m_channel, m_message ); | 83 | QCopEnvelope( m_channel, m_message ); |
83 | 84 | ||
84 | return true; | 85 | return true; |
85 | } | 86 | } |
86 | 87 | ||
87 | //--------------------------------------------------------------------------- | 88 | //--------------------------------------------------------------------------- |
88 | 89 | ||
89 | /* | 90 | /* |
90 | Priority is number of alerts that are needed to pop up | 91 | Priority is number of alerts that are needed to pop up |
91 | alert. | 92 | alert. |
92 | */ | 93 | */ |
93 | class DesktopPowerAlerter : public QMessageBox | 94 | class DesktopPowerAlerter : public QMessageBox |
94 | { | 95 | { |
95 | Q_OBJECT | 96 | Q_OBJECT |
96 | public: | 97 | public: |
97 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 98 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
98 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), | 99 | : QMessageBox( tr("Battery Status"), tr("Low Battery"), |
99 | QMessageBox::Critical, | 100 | QMessageBox::Critical, |
100 | QMessageBox::Ok | QMessageBox::Default, | 101 | QMessageBox::Ok | QMessageBox::Default, |
101 | QMessageBox::NoButton, QMessageBox::NoButton, | 102 | QMessageBox::NoButton, QMessageBox::NoButton, |
102 | parent, name, FALSE ) | 103 | parent, name, FALSE ) |
103 | { | 104 | { |
104 | currentPriority = INT_MAX; | 105 | currentPriority = INT_MAX; |
105 | alertCount = 0; | 106 | alertCount = 0; |
106 | } | 107 | } |
107 | 108 | ||
108 | void alert( const QString &text, int priority ); | 109 | void alert( const QString &text, int priority ); |
109 | void hideEvent( QHideEvent * ); | 110 | void hideEvent( QHideEvent * ); |
110 | private: | 111 | private: |
111 | int currentPriority; | 112 | int currentPriority; |
112 | int alertCount; | 113 | int alertCount; |
113 | }; | 114 | }; |
114 | 115 | ||
115 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 116 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
116 | { | 117 | { |
117 | alertCount++; | 118 | alertCount++; |
118 | if ( alertCount < priority ) | 119 | if ( alertCount < priority ) |
119 | return; | 120 | return; |
120 | if ( priority > currentPriority ) | 121 | if ( priority > currentPriority ) |
121 | return; | 122 | return; |
122 | currentPriority = priority; | 123 | currentPriority = priority; |
123 | setText( text ); | 124 | setText( text ); |
124 | show(); | 125 | show(); |
125 | } | 126 | } |
126 | 127 | ||
127 | 128 | ||
128 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 129 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
129 | { | 130 | { |
130 | QMessageBox::hideEvent( e ); | 131 | QMessageBox::hideEvent( e ); |
131 | alertCount = 0; | 132 | alertCount = 0; |
132 | currentPriority = INT_MAX; | 133 | currentPriority = INT_MAX; |
133 | } | 134 | } |
134 | 135 | ||
135 | //--------------------------------------------------------------------------- | 136 | //--------------------------------------------------------------------------- |
136 | 137 | ||
137 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) | 138 | KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) |
138 | { | 139 | { |
139 | /* We don't do this cause it would interfere with ODevice */ | 140 | /* We don't do this cause it would interfere with ODevice */ |
140 | #if 0 | 141 | #if 0 |
141 | qwsServer->setKeyboardFilter(this); | 142 | qwsServer->setKeyboardFilter(this); |
142 | #endif | 143 | #endif |
143 | } | 144 | } |
144 | 145 | ||
145 | void KeyFilter::timerEvent(QTimerEvent* e) | 146 | void KeyFilter::timerEvent(QTimerEvent* e) |
146 | { | 147 | { |
147 | if ( e->timerId() == held_tid ) { | 148 | if ( e->timerId() == held_tid ) { |
148 | killTimer(held_tid); | 149 | killTimer(held_tid); |
149 | // button held | 150 | // button held |
150 | if ( heldButton ) { | 151 | if ( heldButton ) { |
151 | emit activate(heldButton, TRUE); | 152 | emit activate(heldButton, TRUE); |
152 | heldButton = 0; | 153 | heldButton = 0; |
153 | } | 154 | } |
154 | held_tid = 0; | 155 | held_tid = 0; |
155 | } | 156 | } |
156 | } | 157 | } |
157 | 158 | ||
158 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { | 159 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { |
159 | m_keys.insert( key.keyCode(), key ); | 160 | m_keys.insert( key.keyCode(), key ); |
160 | } | 161 | } |
161 | 162 | ||
162 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { | 163 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { |
163 | m_keys.remove( key.keyCode() ); | 164 | m_keys.remove( key.keyCode() ); |
164 | } | 165 | } |
165 | 166 | ||
166 | bool KeyFilter::keyRegistered( int key ) { | 167 | bool KeyFilter::keyRegistered( int key ) { |
167 | /* | 168 | /* |
168 | * Check if we've a key registered | 169 | * Check if we've a key registered |
169 | */ | 170 | */ |
170 | if ( !m_keys[key].send()) | 171 | if ( !m_keys[key].send()) |
171 | return false; | 172 | return false; |
172 | else | 173 | else |
173 | return true; | 174 | return true; |
174 | 175 | ||
175 | } | 176 | } |
176 | 177 | ||
177 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) | 178 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) |
178 | { | 179 | { |
179 | if ( !loggedin | 180 | if ( !loggedin |
180 | // Permitted keys | 181 | // Permitted keys |
181 | && keycode != Key_F34 // power | 182 | && keycode != Key_F34 // power |
182 | && keycode != Key_F30 // select | 183 | && keycode != Key_F30 // select |
183 | && keycode != Key_Enter | 184 | && keycode != Key_Enter |
184 | && keycode != Key_Return | 185 | && keycode != Key_Return |
185 | && keycode != Key_Space | 186 | && keycode != Key_Space |
186 | && keycode != Key_Left | 187 | && keycode != Key_Left |
187 | && keycode != Key_Right | 188 | && keycode != Key_Right |
188 | && keycode != Key_Up | 189 | && keycode != Key_Up |
189 | && keycode != Key_Down ) | 190 | && keycode != Key_Down ) |
190 | return TRUE; | 191 | return TRUE; |
191 | 192 | ||
192 | /* check if it was registered */ | 193 | /* check if it was registered */ |
193 | if (!db ) { | 194 | if (!db ) { |
194 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) | 195 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) |
195 | return true; | 196 | return true; |
196 | }else { | 197 | }else { |
197 | 198 | ||
198 | 199 | ||
199 | // First check to see if DeviceButtonManager knows something about this button: | 200 | // First check to see if DeviceButtonManager knows something about this button: |
200 | const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); | 201 | const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); |
201 | if (button && !autoRepeat) { | 202 | if (button && !autoRepeat) { |
202 | if ( held_tid ) { | 203 | if ( held_tid ) { |
203 | killTimer(held_tid); | 204 | killTimer(held_tid); |
204 | held_tid = 0; | 205 | held_tid = 0; |
205 | } | 206 | } |
206 | if ( button->heldAction().isNull() ) { | 207 | if ( button->heldAction().isNull() ) { |
207 | if ( press ) | 208 | if ( press ) |
208 | emit activate(button, FALSE); | 209 | emit activate(button, FALSE); |
209 | } else if ( press ) { | 210 | } else if ( press ) { |
210 | heldButton = button; | 211 | heldButton = button; |
211 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); | 212 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); |
212 | } else if ( heldButton ) { | 213 | } else if ( heldButton ) { |
213 | heldButton = 0; | 214 | heldButton = 0; |
214 | emit activate(button, FALSE); | 215 | emit activate(button, FALSE); |
215 | } | 216 | } |
216 | QWSServer::screenSaverActivate(FALSE); | 217 | QWSServer::screenSaverActivate(FALSE); |
217 | return TRUE; | 218 | return TRUE; |
218 | } | 219 | } |
219 | return false; | 220 | return false; |
220 | } | 221 | } |
221 | if ( keycode == HardKey_Suspend ) { | 222 | if ( keycode == HardKey_Suspend ) { |
222 | if ( press ) emit power(); | 223 | if ( press ) emit power(); |
223 | return TRUE; | 224 | return TRUE; |
224 | } | 225 | } |
225 | if ( keycode == HardKey_Backlight ) { | 226 | if ( keycode == HardKey_Backlight ) { |
226 | if ( press ) emit backlight(); | 227 | if ( press ) emit backlight(); |
227 | return TRUE; | 228 | return TRUE; |
228 | } | 229 | } |
229 | if ( keycode == Key_F32 ) { | 230 | if ( keycode == Key_F32 ) { |
230 | #ifndef QT_NO_COP | 231 | #ifndef QT_NO_COP |
231 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 232 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
232 | #endif | 233 | #endif |
233 | return TRUE; | 234 | return TRUE; |
234 | } | 235 | } |
235 | if ( keycode == Key_F31 ) { | 236 | if ( keycode == Key_F31 ) { |
236 | if ( press ) emit symbol(); | 237 | if ( press ) emit symbol(); |
237 | QWSServer::screenSaverActivate(FALSE); | 238 | QWSServer::screenSaverActivate(FALSE); |
238 | return TRUE; | 239 | return TRUE; |
239 | } | 240 | } |
240 | 241 | ||
241 | if ( keycode == Key_NumLock ) | 242 | if ( keycode == Key_NumLock ) |
242 | if ( press ) emit numLockStateToggle(); | 243 | if ( press ) emit numLockStateToggle(); |
243 | 244 | ||
244 | if ( keycode == Key_CapsLock ) | 245 | if ( keycode == Key_CapsLock ) |
245 | if ( press ) emit capsLockStateToggle(); | 246 | if ( press ) emit capsLockStateToggle(); |
246 | 247 | ||
247 | if ( serverApp ) | 248 | if ( serverApp ) |
248 | serverApp->keyClick(keycode,press,autoRepeat); | 249 | serverApp->keyClick(keycode,press,autoRepeat); |
249 | 250 | ||
250 | return FALSE; | 251 | return FALSE; |
251 | } | 252 | } |
252 | 253 | ||
253 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; | 254 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; |
254 | 255 | ||
255 | #if defined(QPE_HAVE_MEMALERTER) | 256 | #if defined(QPE_HAVE_MEMALERTER) |
256 | QPE_MEMALERTER_IMPL | 257 | QPE_MEMALERTER_IMPL |
257 | #endif | 258 | #endif |
258 | 259 | ||
259 | 260 | ||
260 | 261 | ||
261 | //--------------------------------------------------------------------------- | 262 | //--------------------------------------------------------------------------- |
262 | 263 | ||
263 | bool ServerApplication::doRestart = FALSE; | 264 | bool ServerApplication::doRestart = FALSE; |
264 | bool ServerApplication::allowRestart = TRUE; | 265 | bool ServerApplication::allowRestart = TRUE; |
265 | bool ServerApplication::ms_is_starting = TRUE; | 266 | bool ServerApplication::ms_is_starting = TRUE; |
266 | 267 | ||
267 | void ServerApplication::switchLCD( bool on ) { | 268 | void ServerApplication::switchLCD( bool on ) { |
268 | if ( !qApp ) | 269 | if ( !qApp ) |
269 | return; | 270 | return; |
270 | 271 | ||
271 | ServerApplication *dapp = ServerApplication::me() ; | 272 | ServerApplication *dapp = ServerApplication::me() ; |
272 | 273 | ||
273 | if ( !dapp-> m_screensaver ) | 274 | if ( !dapp-> m_screensaver ) |
274 | return; | 275 | return; |
275 | 276 | ||
276 | if ( on ) { | 277 | if ( on ) { |
277 | dapp-> m_screensaver-> setDisplayState ( true ); | 278 | dapp-> m_screensaver-> setDisplayState ( true ); |
278 | dapp-> m_screensaver-> setBacklight ( -3 ); | 279 | dapp-> m_screensaver-> setBacklight ( -3 ); |
279 | }else | 280 | }else |
280 | dapp-> m_screensaver-> setDisplayState ( false ); | 281 | dapp-> m_screensaver-> setDisplayState ( false ); |
281 | 282 | ||
282 | 283 | ||
283 | } | 284 | } |
284 | 285 | ||
285 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | 286 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) |
286 | : QPEApplication( argc, argv, t ) | 287 | : QPEApplication( argc, argv, t ) |
287 | { | 288 | { |
288 | ms_is_starting = true; | 289 | ms_is_starting = true; |
289 | 290 | ||
290 | // We know we'll have lots of cached pixmaps due to App/DocLnks | 291 | // We know we'll have lots of cached pixmaps due to App/DocLnks |
291 | QPixmapCache::setCacheLimit(512); | 292 | QPixmapCache::setCacheLimit(512); |
292 | 293 | ||
293 | m_ps = new PowerStatus; | 294 | m_ps = new PowerStatus; |
294 | m_ps_last = new PowerStatus; | 295 | m_ps_last = new PowerStatus; |
295 | pa = new DesktopPowerAlerter( 0 ); | 296 | pa = new DesktopPowerAlerter( 0 ); |
296 | 297 | ||
297 | m_apm_timer = new QTimer( this ); | 298 | m_apm_timer = new QTimer( this ); |
298 | connect(m_apm_timer, SIGNAL( timeout() ), | 299 | connect(m_apm_timer, SIGNAL( timeout() ), |
299 | this, SLOT( apmTimeout() ) ); | 300 | this, SLOT( apmTimeout() ) ); |
300 | 301 | ||
301 | reloadPowerWarnSettings(); | 302 | reloadPowerWarnSettings(); |
302 | 303 | ||
303 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 304 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
304 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), | 305 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), |
305 | this, SLOT(systemMessage(const QCString&,const QByteArray&) ) ); | 306 | this, SLOT(systemMessage(const QCString&,const QByteArray&) ) ); |
306 | 307 | ||
307 | channel = new QCopChannel("QPE/Launcher", this ); | 308 | channel = new QCopChannel("QPE/Launcher", this ); |
308 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), | 309 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), |
309 | this, SLOT(launcherMessage(const QCString&,const QByteArray&) ) ); | 310 | this, SLOT(launcherMessage(const QCString&,const QByteArray&) ) ); |
310 | 311 | ||
311 | m_screensaver = new OpieScreenSaver(); | 312 | m_screensaver = new OpieScreenSaver(); |
312 | m_screensaver->setInterval( -1 ); | 313 | m_screensaver->setInterval( -1 ); |
313 | QWSServer::setScreenSaver( m_screensaver ); | 314 | QWSServer::setScreenSaver( m_screensaver ); |
314 | 315 | ||
315 | connect( qApp, SIGNAL( volumeChanged(bool) ), | 316 | connect( qApp, SIGNAL( volumeChanged(bool) ), |
316 | this, SLOT( rereadVolumes() ) ); | 317 | this, SLOT( rereadVolumes() ) ); |
317 | 318 | ||
318 | 319 | ||
319 | /* ### PluginLoader libqtopia SafeMode */ | 320 | /* ### PluginLoader libqtopia SafeMode */ |
320 | #if 0 | 321 | #if 0 |
321 | if ( PluginLoader::inSafeMode() ) | 322 | if ( PluginLoader::inSafeMode() ) |
322 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); | 323 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); |
323 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); | 324 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); |
324 | #endif | 325 | #endif |
325 | 326 | ||
326 | kf = new KeyFilter(this); | 327 | kf = new KeyFilter(this); |
327 | 328 | ||
328 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); | 329 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); |
329 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); | 330 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); |
330 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); | 331 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); |
331 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); | 332 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); |
332 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); | 333 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); |
333 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); | 334 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); |
334 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), | 335 | connect( kf, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), |
335 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); | 336 | this,SIGNAL(activate(const Opie::Core::ODeviceButton*,bool))); |
336 | 337 | ||
337 | 338 | ||
338 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); | 339 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); |
339 | 340 | ||
340 | connect( this, SIGNAL(power() ), | 341 | connect( this, SIGNAL(power() ), |
341 | SLOT(togglePower() ) ); | 342 | SLOT(togglePower() ) ); |
342 | 343 | ||
343 | rereadVolumes(); | 344 | rereadVolumes(); |
344 | 345 | ||
345 | serverApp = this; | 346 | serverApp = this; |
346 | 347 | ||
347 | apmTimeout(); | 348 | apmTimeout(); |
348 | grabKeyboard(); | 349 | grabKeyboard(); |
349 | 350 | ||
350 | /* make sure the event filter is installed */ | 351 | /* make sure the event filter is installed */ |
351 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); | 352 | const ODeviceButton* but = ODevice::inst()->buttonForKeycode( -1 ); |
352 | } | 353 | } |
353 | 354 | ||
354 | 355 | ||
355 | ServerApplication::~ServerApplication() | 356 | ServerApplication::~ServerApplication() |
356 | { | 357 | { |
357 | ungrabKeyboard(); | 358 | ungrabKeyboard(); |
358 | 359 | ||
359 | 360 | ||
360 | delete pa; | 361 | delete pa; |
361 | delete m_ps; | 362 | delete m_ps; |
362 | delete m_ps_last; | 363 | delete m_ps_last; |
363 | } | 364 | } |
364 | 365 | ||
365 | void ServerApplication::apmTimeout() { | 366 | void ServerApplication::apmTimeout() { |
366 | serverApp-> checkMemory( ); // in case no events are generated | 367 | serverApp-> checkMemory( ); // in case no events are generated |
367 | *m_ps_last = *m_ps; | 368 | *m_ps_last = *m_ps; |
368 | *m_ps = PowerStatusManager::readStatus(); | 369 | *m_ps = PowerStatusManager::readStatus(); |
369 | 370 | ||
370 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) | 371 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) |
371 | m_screensaver-> powerStatusChanged( *m_ps ); | 372 | m_screensaver-> powerStatusChanged( *m_ps ); |
372 | 373 | ||
373 | if ( m_ps->acStatus() == PowerStatus::Online ) { | 374 | if ( m_ps->acStatus() == PowerStatus::Online ) { |
374 | return; | 375 | return; |
375 | } | 376 | } |
376 | 377 | ||
377 | int bat = m_ps-> batteryPercentRemaining(); | 378 | int bat = m_ps-> batteryPercentRemaining(); |
378 | 379 | ||
379 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { | 380 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { |
380 | if ( bat <= m_powerCritical ) { | 381 | if ( bat <= m_powerCritical ) { |
381 | QMessageBox battlow( | 382 | QMessageBox battlow( |
382 | tr("WARNING"), | 383 | tr("WARNING"), |
383 | tr("<p>The battery level is critical!" | 384 | tr("<p>The battery level is critical!" |
384 | "<p>Keep power off until AC is restored"), | 385 | "<p>Keep power off until AC is restored"), |
385 | QMessageBox::Warning, | 386 | QMessageBox::Warning, |
386 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 387 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
387 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 388 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
388 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); | 389 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); |
389 | battlow.exec(); | 390 | battlow.exec(); |
390 | } else if ( bat <= m_powerVeryLow ) | 391 | } else if ( bat <= m_powerVeryLow ) |
391 | pa->alert( tr( "The battery is running very low. "), 2 ); | 392 | pa->alert( tr( "The battery is running very low. "), 2 ); |
392 | } | 393 | } |
393 | 394 | ||
394 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { | 395 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { |
395 | QMessageBox battlow( | 396 | QMessageBox battlow( |
396 | tr("WARNING"), | 397 | tr("WARNING"), |
397 | tr("<p>The Back-up battery is very low" | 398 | tr("<p>The Back-up battery is very low" |
398 | "<p>Please charge the back-up battery"), | 399 | "<p>Please charge the back-up battery"), |
399 | QMessageBox::Warning, | 400 | QMessageBox::Warning, |
400 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, | 401 | QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, |
401 | 0, QString::null, TRUE, WStyle_StaysOnTop); | 402 | 0, QString::null, TRUE, WStyle_StaysOnTop); |
402 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); | 403 | battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); |
403 | battlow.exec(); | 404 | battlow.exec(); |
404 | } | 405 | } |
405 | } | 406 | } |
406 | 407 | ||
407 | void ServerApplication::systemMessage( const QCString& msg, | 408 | void ServerApplication::systemMessage( const QCString& msg, |
408 | const QByteArray& data ) { | 409 | const QByteArray& data ) { |
409 | QDataStream stream ( data, IO_ReadOnly ); | 410 | QDataStream stream ( data, IO_ReadOnly ); |
410 | 411 | ||
411 | if ( msg == "setScreenSaverInterval(int)" ) { | 412 | if ( msg == "setScreenSaverInterval(int)" ) { |
412 | int time; | 413 | int time; |
413 | stream >> time; | 414 | stream >> time; |
414 | m_screensaver-> setInterval( time ); | 415 | m_screensaver-> setInterval( time ); |
415 | } | 416 | } |
416 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 417 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
417 | int t1, t2, t3; | 418 | int t1, t2, t3; |
418 | stream >> t1 >> t2 >> t3; | 419 | stream >> t1 >> t2 >> t3; |
419 | m_screensaver-> setIntervals( t1, t2, t3 ); | 420 | m_screensaver-> setIntervals( t1, t2, t3 ); |
420 | } | 421 | } |
421 | else if ( msg == "setBacklight(int)" ) { | 422 | else if ( msg == "setBacklight(int)" ) { |
422 | int bright; | 423 | int bright; |
423 | stream >> bright; | 424 | stream >> bright; |
424 | m_screensaver-> setBacklight( bright ); | 425 | m_screensaver-> setBacklight( bright ); |
425 | } | 426 | } |
426 | else if ( msg == "setScreenSaverMode(int)" ) { | 427 | else if ( msg == "setScreenSaverMode(int)" ) { |
427 | int mode; | 428 | int mode; |
428 | stream >> mode; | 429 | stream >> mode; |
429 | m_screensaver-> setMode ( mode ); | 430 | m_screensaver-> setMode ( mode ); |
430 | } | 431 | } |
431 | else if ( msg == "reloadPowerWarnSettings()" ) { | 432 | else if ( msg == "reloadPowerWarnSettings()" ) { |
432 | reloadPowerWarnSettings(); | 433 | reloadPowerWarnSettings(); |
433 | } | 434 | } |
434 | else if ( msg == "setDisplayState(int)" ) { | 435 | else if ( msg == "setDisplayState(int)" ) { |
435 | int state; | 436 | int state; |
436 | stream >> state; | 437 | stream >> state; |
437 | m_screensaver-> setDisplayState ( state != 0 ); | 438 | m_screensaver-> setDisplayState ( state != 0 ); |
438 | } | 439 | } |
439 | else if ( msg == "suspend()" ) { | 440 | else if ( msg == "suspend()" ) { |
440 | emit power(); | 441 | emit power(); |
441 | } | 442 | } |
442 | else if ( msg == "sendBusinessCard()" ) { | 443 | else if ( msg == "sendBusinessCard()" ) { |
443 | QString card = ::getenv ( "HOME" ); | 444 | QString card = ::getenv ( "HOME" ); |
444 | card += "/Applications/addressbook/businesscard.vcf"; | 445 | card += "/Applications/addressbook/businesscard.vcf"; |
445 | 446 | ||
446 | if ( QFile::exists( card ) ) { | 447 | if ( QFile::exists( card ) ) { |
447 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); | 448 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); |
diff --git a/core/launcher/serverapp.h b/core/launcher/serverapp.h index 4d9f808..916d83c 100644 --- a/core/launcher/serverapp.h +++ b/core/launcher/serverapp.h | |||
@@ -1,169 +1,171 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef SERVERAPP_H | 21 | #ifndef SERVERAPP_H |
22 | #define SERVERAPP_H | 22 | #define SERVERAPP_H |
23 | 23 | ||
24 | #include <qtopia/qpeapplication.h> | 24 | #include <qtopia/qpeapplication.h> |
25 | 25 | ||
26 | #include <qwidget.h> | 26 | #include <qwidget.h> |
27 | #ifdef QWS | 27 | #ifdef QWS |
28 | #include <qwindowsystem_qws.h> | 28 | #include <qwindowsystem_qws.h> |
29 | #endif | 29 | #endif |
30 | 30 | ||
31 | #include "shutdownimpl.h" | 31 | #include "shutdownimpl.h" |
32 | 32 | ||
33 | class PowerStatus; | 33 | class PowerStatus; |
34 | class DesktopPowerAlerter; | 34 | class DesktopPowerAlerter; |
35 | 35 | ||
36 | class OpieScreenSaver; | 36 | class OpieScreenSaver; |
37 | namespace Opie { | 37 | namespace Opie { |
38 | namespace Core { | ||
38 | class ODeviceButton; | 39 | class ODeviceButton; |
39 | } | 40 | } |
41 | } | ||
40 | 42 | ||
41 | struct QCopKeyRegister { | 43 | struct QCopKeyRegister { |
42 | QCopKeyRegister(); | 44 | QCopKeyRegister(); |
43 | QCopKeyRegister( int k, const QCString&, const QCString& ); | 45 | QCopKeyRegister( int k, const QCString&, const QCString& ); |
44 | int keyCode()const; | 46 | int keyCode()const; |
45 | QCString channel()const; | 47 | QCString channel()const; |
46 | QCString message()const; | 48 | QCString message()const; |
47 | inline bool send(); | 49 | inline bool send(); |
48 | 50 | ||
49 | private: | 51 | private: |
50 | int m_keyCode; | 52 | int m_keyCode; |
51 | QCString m_channel, m_message; | 53 | QCString m_channel, m_message; |
52 | }; | 54 | }; |
53 | 55 | ||
54 | typedef QMap<int, QCopKeyRegister> KeyRegisterList; | 56 | typedef QMap<int, QCopKeyRegister> KeyRegisterList; |
55 | 57 | ||
56 | class KeyFilter : public QObject { | 58 | class KeyFilter : public QObject { |
57 | Q_OBJECT | 59 | Q_OBJECT |
58 | public: | 60 | public: |
59 | KeyFilter(QObject* parent); | 61 | KeyFilter(QObject* parent); |
60 | void registerKey( const QCopKeyRegister& ); | 62 | void registerKey( const QCopKeyRegister& ); |
61 | void unregisterKey( const QCopKeyRegister& ); | 63 | void unregisterKey( const QCopKeyRegister& ); |
62 | bool checkButtonAction( bool, int, int, int ); | 64 | bool checkButtonAction( bool, int, int, int ); |
63 | 65 | ||
64 | 66 | ||
65 | 67 | ||
66 | protected: | 68 | protected: |
67 | void timerEvent(QTimerEvent*); | 69 | void timerEvent(QTimerEvent*); |
68 | 70 | ||
69 | signals: | 71 | signals: |
70 | void launch(); | 72 | void launch(); |
71 | void power(); | 73 | void power(); |
72 | void backlight(); | 74 | void backlight(); |
73 | void symbol(); | 75 | void symbol(); |
74 | void numLockStateToggle(); | 76 | void numLockStateToggle(); |
75 | void capsLockStateToggle(); | 77 | void capsLockStateToggle(); |
76 | void activate(const Opie::ODeviceButton*,bool); | 78 | void activate(const Opie::Core::ODeviceButton*,bool); |
77 | 79 | ||
78 | 80 | ||
79 | private: | 81 | private: |
80 | bool keyRegistered( int key ); | 82 | bool keyRegistered( int key ); |
81 | int held_tid; | 83 | int held_tid; |
82 | const Opie::ODeviceButton* heldButton; | 84 | const Opie::Core::ODeviceButton* heldButton; |
83 | KeyRegisterList m_keys; | 85 | KeyRegisterList m_keys; |
84 | }; | 86 | }; |
85 | 87 | ||
86 | class ServerApplication : public QPEApplication | 88 | class ServerApplication : public QPEApplication |
87 | { | 89 | { |
88 | Q_OBJECT | 90 | Q_OBJECT |
89 | public: | 91 | public: |
90 | ServerApplication( int& argc, char **argv, Type t ); | 92 | ServerApplication( int& argc, char **argv, Type t ); |
91 | ~ServerApplication(); | 93 | ~ServerApplication(); |
92 | 94 | ||
93 | static bool doRestart; | 95 | static bool doRestart; |
94 | static bool allowRestart; | 96 | static bool allowRestart; |
95 | static bool screenLocked(); | 97 | static bool screenLocked(); |
96 | static void login(bool at_poweron); | 98 | static void login(bool at_poweron); |
97 | 99 | ||
98 | static bool isStarting(); | 100 | static bool isStarting(); |
99 | 101 | ||
100 | static void switchLCD ( bool on ); // only for togglePower in Desktop | 102 | static void switchLCD ( bool on ); // only for togglePower in Desktop |
101 | static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar | 103 | static void soundAlarm(); // only because QCop soundAlarm() is defined in QPE/TaskBar |
102 | 104 | ||
103 | void restart(); | 105 | void restart(); |
104 | int exec(); | 106 | int exec(); |
105 | 107 | ||
106 | signals: | 108 | signals: |
107 | void menu(); | 109 | void menu(); |
108 | void home(); | 110 | void home(); |
109 | void launch(); | 111 | void launch(); |
110 | void power(); | 112 | void power(); |
111 | void backlight(); | 113 | void backlight(); |
112 | void symbol(); | 114 | void symbol(); |
113 | void numLockStateToggle(); | 115 | void numLockStateToggle(); |
114 | void capsLockStateToggle(); | 116 | void capsLockStateToggle(); |
115 | void prepareForRestart(); | 117 | void prepareForRestart(); |
116 | void activate(const Opie::ODeviceButton*,bool); | 118 | void activate(const Opie::Core::ODeviceButton*,bool); |
117 | 119 | ||
118 | public slots: | 120 | public slots: |
119 | virtual void systemMessage( const QCString& msg, const QByteArray& ); | 121 | virtual void systemMessage( const QCString& msg, const QByteArray& ); |
120 | virtual void launcherMessage( const QCString& msg, const QByteArray& ); | 122 | virtual void launcherMessage( const QCString& msg, const QByteArray& ); |
121 | void rereadVolumes(); | 123 | void rereadVolumes(); |
122 | 124 | ||
123 | protected: | 125 | protected: |
124 | bool eventFilter( QObject*, QEvent* ); | 126 | bool eventFilter( QObject*, QEvent* ); |
125 | #ifdef Q_WS_QWS | 127 | #ifdef Q_WS_QWS |
126 | bool qwsEventFilter( QWSEvent * ); | 128 | bool qwsEventFilter( QWSEvent * ); |
127 | #endif | 129 | #endif |
128 | void shutdown(); | 130 | void shutdown(); |
129 | void checkMemory(); | 131 | void checkMemory(); |
130 | bool recoverMemory(); | 132 | bool recoverMemory(); |
131 | void keyClick(int keycode, bool press, bool repeat); | 133 | void keyClick(int keycode, bool press, bool repeat); |
132 | void screenClick(bool press); | 134 | void screenClick(bool press); |
133 | 135 | ||
134 | protected slots: | 136 | protected slots: |
135 | void shutdown(ShutdownImpl::Type); | 137 | void shutdown(ShutdownImpl::Type); |
136 | void apmTimeout(); | 138 | void apmTimeout(); |
137 | void showSafeMode(); | 139 | void showSafeMode(); |
138 | void clearSafeMode(); | 140 | void clearSafeMode(); |
139 | void togglePower(); | 141 | void togglePower(); |
140 | void toggleLight(); | 142 | void toggleLight(); |
141 | 143 | ||
142 | private: | 144 | private: |
143 | static ServerApplication *me (); | 145 | static ServerApplication *me (); |
144 | void reloadPowerWarnSettings(); | 146 | void reloadPowerWarnSettings(); |
145 | KeyFilter *kf; | 147 | KeyFilter *kf; |
146 | 148 | ||
147 | 149 | ||
148 | private: | 150 | private: |
149 | DesktopPowerAlerter *pa; | 151 | DesktopPowerAlerter *pa; |
150 | PowerStatus *m_ps, *m_ps_last; | 152 | PowerStatus *m_ps, *m_ps_last; |
151 | OpieScreenSaver *m_screensaver; | 153 | OpieScreenSaver *m_screensaver; |
152 | QTimer *m_apm_timer; | 154 | QTimer *m_apm_timer; |
153 | QDateTime m_suspendTime; | 155 | QDateTime m_suspendTime; |
154 | int m_powerVeryLow; | 156 | int m_powerVeryLow; |
155 | int m_powerCritical; | 157 | int m_powerCritical; |
156 | int m_currentPowerLevel; | 158 | int m_currentPowerLevel; |
157 | 159 | ||
158 | bool m_keyclick_sound : 1; | 160 | bool m_keyclick_sound : 1; |
159 | bool m_screentap_sound : 1; | 161 | bool m_screentap_sound : 1; |
160 | bool m_alarm_sound : 1; | 162 | bool m_alarm_sound : 1; |
161 | static bool ms_is_starting; | 163 | static bool ms_is_starting; |
162 | 164 | ||
163 | 165 | ||
164 | friend class KeyFilter; | 166 | friend class KeyFilter; |
165 | }; | 167 | }; |
166 | 168 | ||
167 | 169 | ||
168 | #endif // SERVERAPP_H | 170 | #endif // SERVERAPP_H |
169 | 171 | ||
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index a5e20b2..e32cf41 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -1,157 +1,158 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | //#define _XOPEN_SOURCE | 20 | //#define _XOPEN_SOURCE |
21 | 21 | ||
22 | #include <opie2/oglobal.h> | 22 | #include <opie2/oglobal.h> |
23 | 23 | ||
24 | #ifndef Q_OS_WIN32 | 24 | #ifndef Q_OS_WIN32 |
25 | #include <pwd.h> | 25 | #include <pwd.h> |
26 | #include <sys/types.h> | 26 | #include <sys/types.h> |
27 | #include <unistd.h> | 27 | #include <unistd.h> |
28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
29 | #include <time.h> | 29 | #include <time.h> |
30 | 30 | ||
31 | #ifndef Q_OS_MACX | 31 | #ifndef Q_OS_MACX |
32 | #include <shadow.h> | 32 | #include <shadow.h> |
33 | #include <crypt.h> | 33 | #include <crypt.h> |
34 | #endif /* Q_OS_MACX */ | 34 | #endif /* Q_OS_MACX */ |
35 | 35 | ||
36 | #else | 36 | #else |
37 | #include <stdlib.h> | 37 | #include <stdlib.h> |
38 | #include <time.h> | 38 | #include <time.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | 41 | ||
42 | #if defined(_OS_LINUX_) | 42 | #if defined(_OS_LINUX_) |
43 | #include <shadow.h> | 43 | #include <shadow.h> |
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | #include <qtextstream.h> | 46 | #include <qtextstream.h> |
47 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
48 | //#include <qtopia/qcopchannel_qws.h> | 48 | //#include <qtopia/qcopchannel_qws.h> |
49 | #include <qtopia/process.h> | 49 | #include <qtopia/process.h> |
50 | #include <qtopia/private/contact.h> | 50 | #include <qtopia/private/contact.h> |
51 | #include <qtopia/version.h> | 51 | #include <qtopia/version.h> |
52 | #ifdef Q_WS_QWS | 52 | #ifdef Q_WS_QWS |
53 | #include <qtopia/qcopenvelope_qws.h> | 53 | #include <qtopia/qcopenvelope_qws.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | 56 | ||
57 | #include "transferserver.h" | 57 | #include "transferserver.h" |
58 | #include <qtopia/qprocess.h> | 58 | #include <qtopia/qprocess.h> |
59 | 59 | ||
60 | const int block_size = 51200; | 60 | const int block_size = 51200; |
61 | 61 | ||
62 | using namespace Opie::Core; | ||
62 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent, | 63 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent, |
63 | const char* name) | 64 | const char* name) |
64 | : QServerSocket( port, 1, parent, name ) | 65 | : QServerSocket( port, 1, parent, name ) |
65 | { | 66 | { |
66 | connections.setAutoDelete( TRUE ); | 67 | connections.setAutoDelete( TRUE ); |
67 | if ( !ok() ) | 68 | if ( !ok() ) |
68 | qWarning( "Failed to bind to port %d", port ); | 69 | qWarning( "Failed to bind to port %d", port ); |
69 | } | 70 | } |
70 | 71 | ||
71 | void TransferServer::authorizeConnections() | 72 | void TransferServer::authorizeConnections() |
72 | { | 73 | { |
73 | QListIterator<ServerPI> it(connections); | 74 | QListIterator<ServerPI> it(connections); |
74 | while ( it.current() ) { | 75 | while ( it.current() ) { |
75 | if ( !it.current()->verifyAuthorised() ) { | 76 | if ( !it.current()->verifyAuthorised() ) { |
76 | disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); | 77 | disconnect( it.current(), SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); |
77 | connections.removeRef( it.current() ); | 78 | connections.removeRef( it.current() ); |
78 | } else | 79 | } else |
79 | ++it; | 80 | ++it; |
80 | } | 81 | } |
81 | } | 82 | } |
82 | 83 | ||
83 | void TransferServer::closed(ServerPI *item) | 84 | void TransferServer::closed(ServerPI *item) |
84 | { | 85 | { |
85 | connections.removeRef(item); | 86 | connections.removeRef(item); |
86 | } | 87 | } |
87 | 88 | ||
88 | TransferServer::~TransferServer() | 89 | TransferServer::~TransferServer() |
89 | { | 90 | { |
90 | } | 91 | } |
91 | 92 | ||
92 | void TransferServer::newConnection( int socket ) | 93 | void TransferServer::newConnection( int socket ) |
93 | { | 94 | { |
94 | ServerPI *ptr = new ServerPI( socket, this ); | 95 | ServerPI *ptr = new ServerPI( socket, this ); |
95 | connect( ptr, SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); | 96 | connect( ptr, SIGNAL(connectionClosed(ServerPI*)), this, SLOT( closed(ServerPI*)) ); |
96 | connections.append( ptr ); | 97 | connections.append( ptr ); |
97 | } | 98 | } |
98 | 99 | ||
99 | QString SyncAuthentication::serverId() | 100 | QString SyncAuthentication::serverId() |
100 | { | 101 | { |
101 | Config cfg("Security"); | 102 | Config cfg("Security"); |
102 | cfg.setGroup("Sync"); | 103 | cfg.setGroup("Sync"); |
103 | QString r = cfg.readEntry("serverid"); | 104 | QString r = cfg.readEntry("serverid"); |
104 | 105 | ||
105 | if ( r.isEmpty() ) { | 106 | if ( r.isEmpty() ) { |
106 | r = OGlobal::generateUuid(); | 107 | r = OGlobal::generateUuid(); |
107 | cfg.writeEntry("serverid", r ); | 108 | cfg.writeEntry("serverid", r ); |
108 | } | 109 | } |
109 | return r; | 110 | return r; |
110 | } | 111 | } |
111 | 112 | ||
112 | QString SyncAuthentication::ownerName() | 113 | QString SyncAuthentication::ownerName() |
113 | { | 114 | { |
114 | QString vfilename = Global::applicationFileName("addressbook", | 115 | QString vfilename = Global::applicationFileName("addressbook", |
115 | "businesscard.vcf"); | 116 | "businesscard.vcf"); |
116 | if (QFile::exists(vfilename)) { | 117 | if (QFile::exists(vfilename)) { |
117 | Contact c; | 118 | Contact c; |
118 | c = Contact::readVCard( vfilename )[0]; | 119 | c = Contact::readVCard( vfilename )[0]; |
119 | return c.fullName(); | 120 | return c.fullName(); |
120 | } | 121 | } |
121 | 122 | ||
122 | return QString::null; | 123 | return QString::null; |
123 | } | 124 | } |
124 | 125 | ||
125 | QString SyncAuthentication::loginName() | 126 | QString SyncAuthentication::loginName() |
126 | { | 127 | { |
127 | struct passwd *pw = 0L; | 128 | struct passwd *pw = 0L; |
128 | #ifndef Q_OS_WIN32 | 129 | #ifndef Q_OS_WIN32 |
129 | pw = getpwuid( geteuid() ); | 130 | pw = getpwuid( geteuid() ); |
130 | return QString::fromLocal8Bit( pw->pw_name ); | 131 | return QString::fromLocal8Bit( pw->pw_name ); |
131 | #else | 132 | #else |
132 | //### revise | 133 | //### revise |
133 | return QString(); | 134 | return QString(); |
134 | #endif | 135 | #endif |
135 | } | 136 | } |
136 | 137 | ||
137 | int SyncAuthentication::isAuthorized(QHostAddress peeraddress) | 138 | int SyncAuthentication::isAuthorized(QHostAddress peeraddress) |
138 | { | 139 | { |
139 | Config cfg("Security"); | 140 | Config cfg("Security"); |
140 | cfg.setGroup("Sync"); | 141 | cfg.setGroup("Sync"); |
141 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); | 142 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); |
142 | uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); | 143 | uint auth_peer = cfg.readNumEntry("auth_peer", 0xc0a80100); |
143 | 144 | ||
144 | // QHostAddress allowed; | 145 | // QHostAddress allowed; |
145 | // allowed.setAddress(allowedstr); | 146 | // allowed.setAddress(allowedstr); |
146 | // uint auth_peer = allowed.ip4Addr(); | 147 | // uint auth_peer = allowed.ip4Addr(); |
147 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); | 148 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits", 24); |
148 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined | 149 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined |
149 | ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); | 150 | ? 0xffffffff : (((1 << auth_peer_bits) - 1) << (32 - auth_peer_bits)); |
150 | 151 | ||
151 | return (peeraddress.ip4Addr() & mask) == auth_peer; | 152 | return (peeraddress.ip4Addr() & mask) == auth_peer; |
152 | } | 153 | } |
153 | 154 | ||
154 | bool SyncAuthentication::checkUser( const QString& user ) | 155 | bool SyncAuthentication::checkUser( const QString& user ) |
155 | { | 156 | { |
156 | if ( user.isEmpty() ) return FALSE; | 157 | if ( user.isEmpty() ) return FALSE; |
157 | QString euser = loginName(); | 158 | QString euser = loginName(); |
diff --git a/core/launcher/wait.cpp b/core/launcher/wait.cpp index 4148e57..a5b329d 100644 --- a/core/launcher/wait.cpp +++ b/core/launcher/wait.cpp | |||
@@ -1,74 +1,75 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "wait.h" | 21 | #include "wait.h" |
22 | 22 | ||
23 | #include <qtopia/config.h> | 23 | #include <qtopia/config.h> |
24 | 24 | ||
25 | #include <opie2/owait.h> | 25 | #include <opie2/owait.h> |
26 | 26 | ||
27 | 27 | ||
28 | 28 | ||
29 | Wait *lastWaitObject = NULL; | 29 | Wait *lastWaitObject = NULL; |
30 | 30 | ||
31 | 31 | ||
32 | using namespace Opie::Ui; | ||
32 | Wait::Wait( QWidget *parent ) : QWidget( parent ), | 33 | Wait::Wait( QWidget *parent ) : QWidget( parent ), |
33 | pm( Resource::loadPixmap( "wait" ) ), waiting( FALSE ) | 34 | pm( Resource::loadPixmap( "wait" ) ), waiting( FALSE ) |
34 | { | 35 | { |
35 | setFixedSize( pm.size() ); | 36 | setFixedSize( pm.size() ); |
36 | lastWaitObject = this; | 37 | lastWaitObject = this; |
37 | m_centralWait = new OWait( 0l ); | 38 | m_centralWait = new OWait( 0l ); |
38 | m_centralWait->hide(); | 39 | m_centralWait->hide(); |
39 | hide(); | 40 | hide(); |
40 | } | 41 | } |
41 | 42 | ||
42 | 43 | ||
43 | Wait *Wait::getWaitObject() | 44 | Wait *Wait::getWaitObject() |
44 | { | 45 | { |
45 | return lastWaitObject; | 46 | return lastWaitObject; |
46 | } | 47 | } |
47 | 48 | ||
48 | 49 | ||
49 | void Wait::setWaiting( bool w ) | 50 | void Wait::setWaiting( bool w ) |
50 | { | 51 | { |
51 | Config cfg ( "Launcher" ); | 52 | Config cfg ( "Launcher" ); |
52 | cfg.setGroup("GUI"); | 53 | cfg.setGroup("GUI"); |
53 | 54 | ||
54 | 55 | ||
55 | waiting = w; | 56 | waiting = w; |
56 | if ( w ) { | 57 | if ( w ) { |
57 | if ( cfg. readBoolEntry( "BigBusy" ) ) | 58 | if ( cfg. readBoolEntry( "BigBusy" ) ) |
58 | m_centralWait->show(); | 59 | m_centralWait->show(); |
59 | else | 60 | else |
60 | show(); | 61 | show(); |
61 | }else{ | 62 | }else{ |
62 | m_centralWait->hide(); | 63 | m_centralWait->hide(); |
63 | hide(); | 64 | hide(); |
64 | } | 65 | } |
65 | } | 66 | } |
66 | 67 | ||
67 | 68 | ||
68 | void Wait::paintEvent( QPaintEvent * ) | 69 | void Wait::paintEvent( QPaintEvent * ) |
69 | { | 70 | { |
70 | QPainter p( this ); | 71 | QPainter p( this ); |
71 | p.drawPixmap( 0, 0, pm ); | 72 | p.drawPixmap( 0, 0, pm ); |
72 | } | 73 | } |
73 | 74 | ||
74 | 75 | ||
diff --git a/core/launcher/wait.h b/core/launcher/wait.h index e7294d2..010fcc3 100644 --- a/core/launcher/wait.h +++ b/core/launcher/wait.h | |||
@@ -1,46 +1,46 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef __WAIT_H__ | 21 | #ifndef __WAIT_H__ |
22 | #define __WAIT_H__ | 22 | #define __WAIT_H__ |
23 | 23 | ||
24 | #include <qtopia/resource.h> | 24 | #include <qtopia/resource.h> |
25 | 25 | ||
26 | #include <qwidget.h> | 26 | #include <qwidget.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | 29 | ||
30 | class OWait; | 30 | namespace Opie {namespace Ui {class OWait;}} |
31 | class Wait : public QWidget | 31 | class Wait : public QWidget |
32 | { | 32 | { |
33 | public: | 33 | public: |
34 | Wait( QWidget *parent ); | 34 | Wait( QWidget *parent ); |
35 | void setWaiting( bool w ); | 35 | void setWaiting( bool w ); |
36 | void paintEvent( QPaintEvent * ); | 36 | void paintEvent( QPaintEvent * ); |
37 | static Wait *getWaitObject(); | 37 | static Wait *getWaitObject(); |
38 | private: | 38 | private: |
39 | QPixmap pm; | 39 | QPixmap pm; |
40 | bool waiting; | 40 | bool waiting; |
41 | OWait* m_centralWait; | 41 | Opie::Ui::OWait* m_centralWait; |
42 | }; | 42 | }; |
43 | 43 | ||
44 | 44 | ||
45 | #endif // __WAIT_H__ | 45 | #endif // __WAIT_H__ |
46 | 46 | ||