author | zecke <zecke> | 2005-03-03 21:01:18 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-03-03 21:01:18 (UTC) |
commit | 67ddc501f2a52c7f35ca4044fb0094e759a45d76 (patch) (unidiff) | |
tree | 7c863f306e6fb7c1aecfb2f8c1ff4a217bfefa1c | |
parent | 585c9fe0efbc0cf4037a79cac3b22ac38c08fec2 (diff) | |
download | opie-67ddc501f2a52c7f35ca4044fb0094e759a45d76.zip opie-67ddc501f2a52c7f35ca4044fb0094e759a45d76.tar.gz opie-67ddc501f2a52c7f35ca4044fb0094e759a45d76.tar.bz2 |
Start and Restart the QSound-Server
-rw-r--r-- | core/launcher/server.cpp | 22 | ||||
-rw-r--r-- | core/launcher/server.h | 7 |
2 files changed, 28 insertions, 1 deletions
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 15cd686..921b790 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp | |||
@@ -1,553 +1,558 @@ | |||
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 | #include "qrr.h" | 38 | #include "qrr.h" |
39 | 39 | ||
40 | /* OPIE */ | 40 | /* OPIE */ |
41 | #include <opie2/odebug.h> | 41 | #include <opie2/odebug.h> |
42 | #include <opie2/odevicebutton.h> | 42 | #include <opie2/odevicebutton.h> |
43 | #include <opie2/odevice.h> | 43 | #include <opie2/odevice.h> |
44 | #include <opie2/oprocess.h> | ||
45 | |||
44 | #include <qtopia/applnk.h> | 46 | #include <qtopia/applnk.h> |
45 | #include <qtopia/private/categories.h> | 47 | #include <qtopia/private/categories.h> |
46 | #include <qtopia/mimetype.h> | 48 | #include <qtopia/mimetype.h> |
47 | #include <qtopia/config.h> | 49 | #include <qtopia/config.h> |
48 | #include <qtopia/resource.h> | 50 | #include <qtopia/resource.h> |
49 | #include <qtopia/version.h> | 51 | #include <qtopia/version.h> |
50 | #include <qtopia/storage.h> | 52 | #include <qtopia/storage.h> |
51 | #include <qtopia/qcopenvelope_qws.h> | 53 | #include <qtopia/qcopenvelope_qws.h> |
52 | #include <qtopia/global.h> | 54 | #include <qtopia/global.h> |
53 | using namespace Opie::Core; | 55 | using namespace Opie::Core; |
54 | 56 | ||
55 | /* QT */ | 57 | /* QT */ |
56 | #include <qmainwindow.h> | 58 | #include <qmainwindow.h> |
57 | #include <qmessagebox.h> | 59 | #include <qmessagebox.h> |
58 | #include <qtimer.h> | 60 | #include <qtimer.h> |
59 | #include <qtextstream.h> | 61 | #include <qtextstream.h> |
60 | #include <qwindowsystem_qws.h> | 62 | #include <qwindowsystem_qws.h> |
61 | #include <qgfx_qws.h> | 63 | #include <qgfx_qws.h> |
62 | 64 | ||
63 | /* STD */ | 65 | /* STD */ |
64 | #include <unistd.h> | 66 | #include <unistd.h> |
65 | #include <stdlib.h> | 67 | #include <stdlib.h> |
66 | 68 | ||
67 | extern QRect qt_maxWindowRect; | 69 | extern QRect qt_maxWindowRect; |
68 | 70 | ||
69 | static QWidget *calibrate(bool) | 71 | static QWidget *calibrate(bool) |
70 | { | 72 | { |
71 | #ifdef Q_WS_QWS | 73 | #ifdef Q_WS_QWS |
72 | Calibrate *c = new Calibrate; | 74 | Calibrate *c = new Calibrate; |
73 | c->show(); | 75 | c->show(); |
74 | return c; | 76 | return c; |
75 | #else | 77 | #else |
76 | return 0; | 78 | return 0; |
77 | #endif | 79 | #endif |
78 | } | 80 | } |
79 | 81 | ||
80 | #define FACTORY(T) \ | 82 | #define FACTORY(T) \ |
81 | static QWidget *new##T( bool maximized ) { \ | 83 | static QWidget *new##T( bool maximized ) { \ |
82 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ | 84 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ |
83 | if ( maximized ) { \ | 85 | if ( maximized ) { \ |
84 | if ( qApp->desktop()->width() <= 350 ) { \ | 86 | if ( qApp->desktop()->width() <= 350 ) { \ |
85 | w->showMaximized(); \ | 87 | w->showMaximized(); \ |
86 | } else { \ | 88 | } else { \ |
87 | w->resize( QSize( 300, 300 ) ); \ | 89 | w->resize( QSize( 300, 300 ) ); \ |
88 | } \ | 90 | } \ |
89 | } \ | 91 | } \ |
90 | w->show(); \ | 92 | w->show(); \ |
91 | return w; \ | 93 | return w; \ |
92 | } | 94 | } |
93 | 95 | ||
94 | 96 | ||
95 | #ifdef SINGLE_APP | 97 | #ifdef SINGLE_APP |
96 | #define APP(a,b,c,d) FACTORY(b) | 98 | #define APP(a,b,c,d) FACTORY(b) |
97 | #include "apps.h" | 99 | #include "apps.h" |
98 | #undef APP | 100 | #undef APP |
99 | #endif // SINGLE_APP | 101 | #endif // SINGLE_APP |
100 | 102 | ||
101 | static Global::Command builtins[] = { | 103 | static Global::Command builtins[] = { |
102 | 104 | ||
103 | #ifdef SINGLE_APP | 105 | #ifdef SINGLE_APP |
104 | #define APP(a,b,c,d) { a, new##b, c, d }, | 106 | #define APP(a,b,c,d) { a, new##b, c, d }, |
105 | #include "apps.h" | 107 | #include "apps.h" |
106 | #undef APP | 108 | #undef APP |
107 | #endif | 109 | #endif |
108 | 110 | ||
109 | /* FIXME defines need to be defined*/ | 111 | /* FIXME defines need to be defined*/ |
110 | #if !defined(OPIE_NO_BUILTIN_CALIBRATE) | 112 | #if !defined(OPIE_NO_BUILTIN_CALIBRATE) |
111 | { "calibrate", calibrate, 1, 0 }, // No tr | 113 | { "calibrate", calibrate, 1, 0 }, // No tr |
112 | #endif | 114 | #endif |
113 | #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) | 115 | #if !defined(OPIE_NO_BUILTIN_SHUTDOWN) |
114 | { "shutdown", Global::shutdown, 1, 0 }, // No tr | 116 | { "shutdown", Global::shutdown, 1, 0 }, // No tr |
115 | // { "run", run, 1, 0 }, // No tr | 117 | // { "run", run, 1, 0 }, // No tr |
116 | #endif | 118 | #endif |
117 | 119 | ||
118 | { 0, calibrate, 0, 0 }, | 120 | { 0, calibrate, 0, 0 }, |
119 | }; | 121 | }; |
120 | 122 | ||
121 | #ifdef QPE_HAVE_DIRECT_ACCESS | 123 | #ifdef QPE_HAVE_DIRECT_ACCESS |
122 | extern void readyDirectAccess(QString cardInfo, QString installLocations); | 124 | extern void readyDirectAccess(QString cardInfo, QString installLocations); |
123 | extern const char *directAccessQueueFile(); | 125 | extern const char *directAccessQueueFile(); |
124 | #endif | 126 | #endif |
125 | 127 | ||
126 | //--------------------------------------------------------------------------- | 128 | //--------------------------------------------------------------------------- |
127 | 129 | ||
128 | 130 | ||
129 | //=========================================================================== | 131 | //=========================================================================== |
130 | 132 | ||
131 | Server::Server() : | 133 | Server::Server() : |
132 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 134 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
133 | qcopBridge( 0 ), | 135 | qcopBridge( 0 ), |
134 | transferServer( 0 ), | 136 | transferServer( 0 ), |
135 | packageHandler( 0 ), | 137 | packageHandler( 0 ), |
136 | syncDialog( 0 ) | 138 | syncDialog( 0 ), |
139 | process( 0 ) | ||
137 | { | 140 | { |
138 | Global::setBuiltinCommands(builtins); | 141 | Global::setBuiltinCommands(builtins); |
139 | 142 | ||
140 | tid_xfer = 0; | 143 | tid_xfer = 0; |
141 | /* ### FIXME ### */ | 144 | /* ### FIXME ### */ |
142 | /* tid_today = startTimer(3600*2*1000);*/ | 145 | /* tid_today = startTimer(3600*2*1000);*/ |
143 | last_today_show = QDate::currentDate(); | 146 | last_today_show = QDate::currentDate(); |
144 | 147 | ||
145 | #warning FIXME support TempScreenSaverMode | 148 | #warning FIXME support TempScreenSaverMode |
146 | #if 0 | 149 | #if 0 |
147 | tsmMonitor = new TempScreenSaverMode(); | 150 | tsmMonitor = new TempScreenSaverMode(); |
148 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); | 151 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); |
149 | #endif | 152 | #endif |
150 | 153 | ||
151 | serverGui = new Launcher; | 154 | serverGui = new Launcher; |
152 | serverGui->createGUI(); | 155 | serverGui->createGUI(); |
153 | 156 | ||
154 | docList = new DocumentList( serverGui ); | 157 | docList = new DocumentList( serverGui ); |
155 | appLauncher = new AppLauncher(this); | 158 | appLauncher = new AppLauncher(this); |
156 | connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); | 159 | connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); |
157 | connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); | 160 | connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); |
158 | connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); | 161 | connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); |
159 | 162 | ||
160 | storage = new StorageInfo( this ); | 163 | storage = new StorageInfo( this ); |
161 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); | 164 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); |
162 | 165 | ||
163 | 166 | ||
164 | #ifdef QPE_HAVE_DIRECT_ACCESS | 167 | #ifdef QPE_HAVE_DIRECT_ACCESS |
165 | QCopChannel *desktopChannel = new QCopChannel( "QPE/Desktop", this ); | 168 | QCopChannel *desktopChannel = new QCopChannel( "QPE/Desktop", this ); |
166 | connect( desktopChannel, SIGNAL(received( const QCString &, const QByteArray & )), | 169 | connect( desktopChannel, SIGNAL(received( const QCString &, const QByteArray & )), |
167 | this, SLOT(desktopMessage( const QCString &, const QByteArray & )) ); | 170 | this, SLOT(desktopMessage( const QCString &, const QByteArray & )) ); |
168 | #endif | 171 | #endif |
169 | 172 | ||
173 | soundServerExited(); | ||
174 | |||
170 | // start services | 175 | // start services |
171 | startTransferServer(); | 176 | startTransferServer(); |
172 | (void) new IrServer( this ); | 177 | (void) new IrServer( this ); |
173 | 178 | ||
174 | packageHandler = new PackageHandler( this ); | 179 | packageHandler = new PackageHandler( this ); |
175 | connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), | 180 | connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), |
176 | this,SLOT(activate(const Opie::Core::ODeviceButton*,bool))); | 181 | this,SLOT(activate(const Opie::Core::ODeviceButton*,bool))); |
177 | 182 | ||
178 | setGeometry( -10, -10, 9, 9 ); | 183 | setGeometry( -10, -10, 9, 9 ); |
179 | 184 | ||
180 | QCopChannel *channel = new QCopChannel("QPE/System", this); | 185 | QCopChannel *channel = new QCopChannel("QPE/System", this); |
181 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), | 186 | connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), |
182 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); | 187 | this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); |
183 | 188 | ||
184 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); | 189 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); |
185 | connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 190 | connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
186 | this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); | 191 | this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); |
187 | 192 | ||
188 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); | 193 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); |
189 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); | 194 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); |
190 | 195 | ||
191 | preloadApps(); | 196 | preloadApps(); |
192 | } | 197 | } |
193 | 198 | ||
194 | void Server::show() | 199 | void Server::show() |
195 | { | 200 | { |
196 | ServerApplication::login(TRUE); | 201 | ServerApplication::login(TRUE); |
197 | QWidget::show(); | 202 | QWidget::show(); |
198 | } | 203 | } |
199 | 204 | ||
200 | Server::~Server() | 205 | Server::~Server() |
201 | { | 206 | { |
202 | serverGui->destroyGUI(); | 207 | serverGui->destroyGUI(); |
203 | delete docList; | 208 | delete docList; |
204 | delete qcopBridge; | 209 | delete qcopBridge; |
205 | delete transferServer; | 210 | delete transferServer; |
206 | delete serverGui; | 211 | delete serverGui; |
207 | #if 0 | 212 | #if 0 |
208 | delete tsmMonitor; | 213 | delete tsmMonitor; |
209 | #endif | 214 | #endif |
210 | } | 215 | } |
211 | 216 | ||
212 | 217 | ||
213 | static bool hasVisibleWindow(const QString& clientname, bool partial) | 218 | static bool hasVisibleWindow(const QString& clientname, bool partial) |
214 | { | 219 | { |
215 | #ifdef QWS | 220 | #ifdef QWS |
216 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 221 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
217 | QWSWindow* w; | 222 | QWSWindow* w; |
218 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 223 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
219 | if ( w->client()->identity() == clientname ) { | 224 | if ( w->client()->identity() == clientname ) { |
220 | if ( partial && !w->isFullyObscured() ) | 225 | if ( partial && !w->isFullyObscured() ) |
221 | return TRUE; | 226 | return TRUE; |
222 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { | 227 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { |
223 | # if QT_VERSION < 0x030000 | 228 | # if QT_VERSION < 0x030000 |
224 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, | 229 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, |
225 | QSize(qt_screen->width(),qt_screen->height()) ); | 230 | QSize(qt_screen->width(),qt_screen->height()) ); |
226 | # else | 231 | # else |
227 | QRect mwr = qt_maxWindowRect; | 232 | QRect mwr = qt_maxWindowRect; |
228 | # endif | 233 | # endif |
229 | if ( mwr.contains(w->requested().boundingRect()) ) | 234 | if ( mwr.contains(w->requested().boundingRect()) ) |
230 | return TRUE; | 235 | return TRUE; |
231 | } | 236 | } |
232 | } | 237 | } |
233 | } | 238 | } |
234 | #endif | 239 | #endif |
235 | return FALSE; | 240 | return FALSE; |
236 | } | 241 | } |
237 | 242 | ||
238 | void Server::activate(const ODeviceButton* button, bool held) | 243 | void Server::activate(const ODeviceButton* button, bool held) |
239 | { | 244 | { |
240 | Global::terminateBuiltin("calibrate"); // No tr | 245 | Global::terminateBuiltin("calibrate"); // No tr |
241 | OQCopMessage om; | 246 | OQCopMessage om; |
242 | if ( held ) { | 247 | if ( held ) { |
243 | om = button->heldAction(); | 248 | om = button->heldAction(); |
244 | } else { | 249 | } else { |
245 | om = button->pressedAction(); | 250 | om = button->pressedAction(); |
246 | } | 251 | } |
247 | 252 | ||
248 | if ( om.channel() != "ignore" ) | 253 | if ( om.channel() != "ignore" ) |
249 | om.send(); | 254 | om.send(); |
250 | 255 | ||
251 | // A button with no action defined, will return a null ServiceRequest. Don't attempt | 256 | // A button with no action defined, will return a null ServiceRequest. Don't attempt |
252 | // to send/do anything with this as it will crash | 257 | // to send/do anything with this as it will crash |
253 | /* ### FIXME */ | 258 | /* ### FIXME */ |
254 | #if 0 | 259 | #if 0 |
255 | if ( !sr.isNull() ) { | 260 | if ( !sr.isNull() ) { |
256 | QString app = sr.app(); | 261 | QString app = sr.app(); |
257 | bool vis = hasVisibleWindow(app, app != "qpe"); | 262 | bool vis = hasVisibleWindow(app, app != "qpe"); |
258 | if ( sr.message() == "raise()" && vis ) { | 263 | if ( sr.message() == "raise()" && vis ) { |
259 | sr.setMessage("nextView()"); | 264 | sr.setMessage("nextView()"); |
260 | } else { | 265 | } else { |
261 | // "back door" | 266 | // "back door" |
262 | sr << (int)vis; | 267 | sr << (int)vis; |
263 | } | 268 | } |
264 | 269 | ||
265 | sr.send(); | 270 | sr.send(); |
266 | } | 271 | } |
267 | #endif | 272 | #endif |
268 | } | 273 | } |
269 | 274 | ||
270 | 275 | ||
271 | #ifdef Q_WS_QWS | 276 | #ifdef Q_WS_QWS |
272 | 277 | ||
273 | typedef struct KeyOverride { | 278 | typedef struct KeyOverride { |
274 | ushort scan_code; | 279 | ushort scan_code; |
275 | QWSServer::KeyMap map; | 280 | QWSServer::KeyMap map; |
276 | }; | 281 | }; |
277 | 282 | ||
278 | 283 | ||
279 | static const KeyOverride jp109keys[] = { | 284 | static const KeyOverride jp109keys[] = { |
280 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, | 285 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, |
281 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, | 286 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, |
282 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, | 287 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, |
283 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, | 288 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, |
284 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, | 289 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, |
285 | { 0x0b, { Qt::Key_0, '0' , 0xffff, 0xffff } }, | 290 | { 0x0b, { Qt::Key_0, '0' , 0xffff, 0xffff } }, |
286 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, | 291 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, |
287 | { 0x0d, { Qt::Key_AsciiCircum, '^' , '~' , '^'-64 } }, | 292 | { 0x0d, { Qt::Key_AsciiCircum, '^' , '~' , '^'-64 } }, |
288 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, | 293 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, |
289 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '['-64 } }, | 294 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '['-64 } }, |
290 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, | 295 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, |
291 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, | 296 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, |
292 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff, 0xffff, 0xffff } }, | 297 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff, 0xffff, 0xffff } }, |
293 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, | 298 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, |
294 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff, 0xffff, 0xffff } }, | 299 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff, 0xffff, 0xffff } }, |
295 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, | 300 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, |
296 | { 0x79, { Qt::Key_Henkan, 0xffff, 0xffff, 0xffff } }, | 301 | { 0x79, { Qt::Key_Henkan, 0xffff, 0xffff, 0xffff } }, |
297 | { 0x7b, { Qt::Key_Muhenkan, 0xffff, 0xffff, 0xffff } }, | 302 | { 0x7b, { Qt::Key_Muhenkan, 0xffff, 0xffff, 0xffff } }, |
298 | { 0x7d, { Qt::Key_yen, 0x00a5, '|' , 0xffff } }, | 303 | { 0x7d, { Qt::Key_yen, 0x00a5, '|' , 0xffff } }, |
299 | { 0x00, { 0, 0xffff, 0xffff, 0xffff } } | 304 | { 0x00, { 0, 0xffff, 0xffff, 0xffff } } |
300 | }; | 305 | }; |
301 | 306 | ||
302 | bool Server::setKeyboardLayout( const QString &kb ) | 307 | bool Server::setKeyboardLayout( const QString &kb ) |
303 | { | 308 | { |
304 | //quick demo version that can be extended | 309 | //quick demo version that can be extended |
305 | 310 | ||
306 | QIntDict<QWSServer::KeyMap> *om = 0; | 311 | QIntDict<QWSServer::KeyMap> *om = 0; |
307 | if ( kb == "us101" ) { // No tr | 312 | if ( kb == "us101" ) { // No tr |
308 | om = 0; | 313 | om = 0; |
309 | } else if ( kb == "jp109" ) { | 314 | } else if ( kb == "jp109" ) { |
310 | om = new QIntDict<QWSServer::KeyMap>(37); | 315 | om = new QIntDict<QWSServer::KeyMap>(37); |
311 | const KeyOverride *k = jp109keys; | 316 | const KeyOverride *k = jp109keys; |
312 | while ( k->scan_code ) { | 317 | while ( k->scan_code ) { |
313 | om->insert( k->scan_code, &k->map ); | 318 | om->insert( k->scan_code, &k->map ); |
314 | k++; | 319 | k++; |
315 | } | 320 | } |
316 | } | 321 | } |
317 | QWSServer::setOverrideKeys( om ); | 322 | QWSServer::setOverrideKeys( om ); |
318 | 323 | ||
319 | return TRUE; | 324 | return TRUE; |
320 | } | 325 | } |
321 | #endif | 326 | #endif |
322 | 327 | ||
323 | void Server::systemMsg(const QCString &msg, const QByteArray &data) | 328 | void Server::systemMsg(const QCString &msg, const QByteArray &data) |
324 | { | 329 | { |
325 | QDataStream stream( data, IO_ReadOnly ); | 330 | QDataStream stream( data, IO_ReadOnly ); |
326 | 331 | ||
327 | if ( msg == "securityChanged()" ) { | 332 | if ( msg == "securityChanged()" ) { |
328 | if ( transferServer ) | 333 | if ( transferServer ) |
329 | transferServer->authorizeConnections(); | 334 | transferServer->authorizeConnections(); |
330 | 335 | ||
331 | if ( qcopBridge ) | 336 | if ( qcopBridge ) |
332 | qcopBridge->authorizeConnections(); | 337 | qcopBridge->authorizeConnections(); |
333 | #warning FIXME support TempScreenSaverMode | 338 | #warning FIXME support TempScreenSaverMode |
334 | #if 0 | 339 | #if 0 |
335 | } else if ( msg == "setTempScreenSaverMode(int,int)" ) { | 340 | } else if ( msg == "setTempScreenSaverMode(int,int)" ) { |
336 | int mode, pid; | 341 | int mode, pid; |
337 | stream >> mode >> pid; | 342 | stream >> mode >> pid; |
338 | tsmMonitor->setTempMode(mode, pid); | 343 | tsmMonitor->setTempMode(mode, pid); |
339 | #endif | 344 | #endif |
340 | } else if ( msg == "linkChanged(QString)" ) { | 345 | } else if ( msg == "linkChanged(QString)" ) { |
341 | QString link; | 346 | QString link; |
342 | stream >> link; | 347 | stream >> link; |
343 | odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; | 348 | odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; |
344 | docList->linkChanged(link); | 349 | docList->linkChanged(link); |
345 | } else if (msg =="reforceDocuments()") { | 350 | } else if (msg =="reforceDocuments()") { |
346 | docList->reforceDocuments(); | 351 | docList->reforceDocuments(); |
347 | } else if ( msg == "serviceChanged(QString)" ) { | 352 | } else if ( msg == "serviceChanged(QString)" ) { |
348 | MimeType::updateApplications(); | 353 | MimeType::updateApplications(); |
349 | } else if ( msg == "mkdir(QString)" ) { | 354 | } else if ( msg == "mkdir(QString)" ) { |
350 | QString dir; | 355 | QString dir; |
351 | stream >> dir; | 356 | stream >> dir; |
352 | if ( !dir.isEmpty() ) | 357 | if ( !dir.isEmpty() ) |
353 | mkdir( dir ); | 358 | mkdir( dir ); |
354 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 359 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
355 | QString baseFile, sigFile; | 360 | QString baseFile, sigFile; |
356 | stream >> baseFile >> sigFile; | 361 | stream >> baseFile >> sigFile; |
357 | QRsync::generateSignature( baseFile, sigFile ); | 362 | QRsync::generateSignature( baseFile, sigFile ); |
358 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 363 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
359 | QString baseFile, sigFile, deltaFile; | 364 | QString baseFile, sigFile, deltaFile; |
360 | stream >> baseFile >> sigFile >> deltaFile; | 365 | stream >> baseFile >> sigFile >> deltaFile; |
361 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 366 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
362 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 367 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
363 | QString baseFile, deltaFile; | 368 | QString baseFile, deltaFile; |
364 | stream >> baseFile >> deltaFile; | 369 | stream >> baseFile >> deltaFile; |
365 | if ( !QFile::exists( baseFile ) ) { | 370 | if ( !QFile::exists( baseFile ) ) { |
366 | QFile f( baseFile ); | 371 | QFile f( baseFile ); |
367 | f.open( IO_WriteOnly ); | 372 | f.open( IO_WriteOnly ); |
368 | f.close(); | 373 | f.close(); |
369 | } | 374 | } |
370 | QRsync::applyDiff( baseFile, deltaFile ); | 375 | QRsync::applyDiff( baseFile, deltaFile ); |
371 | #ifndef QT_NO_COP | 376 | #ifndef QT_NO_COP |
372 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 377 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
373 | e << baseFile; | 378 | e << baseFile; |
374 | #endif | 379 | #endif |
375 | } else if ( msg == "rdiffCleanup()" ) { | 380 | } else if ( msg == "rdiffCleanup()" ) { |
376 | mkdir( "/tmp/rdiff" ); | 381 | mkdir( "/tmp/rdiff" ); |
377 | QDir dir; | 382 | QDir dir; |
378 | dir.setPath( "/tmp/rdiff" ); | 383 | dir.setPath( "/tmp/rdiff" ); |
379 | QStringList entries = dir.entryList(); | 384 | QStringList entries = dir.entryList(); |
380 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 385 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
381 | dir.remove( *it ); | 386 | dir.remove( *it ); |
382 | } else if ( msg == "sendHandshakeInfo()" ) { | 387 | } else if ( msg == "sendHandshakeInfo()" ) { |
383 | QString home = getenv( "HOME" ); | 388 | QString home = getenv( "HOME" ); |
384 | #ifndef QT_NO_COP | 389 | #ifndef QT_NO_COP |
385 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 390 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
386 | e << home; | 391 | e << home; |
387 | int locked = (int) ServerApplication::screenLocked(); | 392 | int locked = (int) ServerApplication::screenLocked(); |
388 | e << locked; | 393 | e << locked; |
389 | #endif | 394 | #endif |
390 | } else if ( msg == "sendVersionInfo()" ) { | 395 | } else if ( msg == "sendVersionInfo()" ) { |
391 | /* | 396 | /* |
392 | * @&$*! Qtopiadesktop relies on the major number | 397 | * @&$*! Qtopiadesktop relies on the major number |
393 | * to start with 1. (or 2 as the case of version 2.1 will be) | 398 | * to start with 1. (or 2 as the case of version 2.1 will be) |
394 | * we need to fake 1.7 to be able | 399 | * we need to fake 1.7 to be able |
395 | * to sync with Qtopiadesktop 1.7. | 400 | * to sync with Qtopiadesktop 1.7. |
396 | * We'll send it Opie's version in the platform string for now, | 401 | * We'll send it Opie's version in the platform string for now, |
397 | * until such time when QD gets rewritten correctly. | 402 | * until such time when QD gets rewritten correctly. |
398 | */ | 403 | */ |
399 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); | 404 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); |
400 | 405 | ||
401 | QString opiename = "Opie "+QString(QPE_VERSION); | 406 | QString opiename = "Opie "+QString(QPE_VERSION); |
402 | QString QDVersion="1.7"; | 407 | QString QDVersion="1.7"; |
403 | e << QDVersion << opiename; | 408 | e << QDVersion << opiename; |
404 | 409 | ||
405 | } else if ( msg == "sendCardInfo()" ) { | 410 | } else if ( msg == "sendCardInfo()" ) { |
406 | #ifndef QT_NO_COP | 411 | #ifndef QT_NO_COP |
407 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 412 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
408 | #endif | 413 | #endif |
409 | storage->update(); | 414 | storage->update(); |
410 | const QList<FileSystem> &fs = storage->fileSystems(); | 415 | const QList<FileSystem> &fs = storage->fileSystems(); |
411 | QListIterator<FileSystem> it ( fs ); | 416 | QListIterator<FileSystem> it ( fs ); |
412 | QString s; | 417 | QString s; |
413 | QString homeDir = getenv("HOME"); | 418 | QString homeDir = getenv("HOME"); |
414 | QString homeFs, homeFsPath; | 419 | QString homeFs, homeFsPath; |
415 | for ( ; it.current(); ++it ) { | 420 | for ( ; it.current(); ++it ) { |
416 | int k4 = (*it)->blockSize()/256; | 421 | int k4 = (*it)->blockSize()/256; |
417 | if ( (*it)->isRemovable() ) { | 422 | if ( (*it)->isRemovable() ) { |
418 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr | 423 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr |
419 | + QString::number( (*it)->availBlocks() * k4/4 ) | 424 | + QString::number( (*it)->availBlocks() * k4/4 ) |
420 | + "K " + (*it)->options() + ";"; | 425 | + "K " + (*it)->options() + ";"; |
421 | } else if ( homeDir.contains( (*it)->path() ) && | 426 | } else if ( homeDir.contains( (*it)->path() ) && |
422 | (*it)->path().length() > homeFsPath.length() ) { | 427 | (*it)->path().length() > homeFsPath.length() ) { |
423 | homeFsPath = (*it)->path(); | 428 | homeFsPath = (*it)->path(); |
424 | homeFs = | 429 | homeFs = |
425 | (*it)->name() + "=" + homeDir + "/Documents " // No tr | 430 | (*it)->name() + "=" + homeDir + "/Documents " // No tr |
426 | + QString::number( (*it)->availBlocks() * k4/4 ) | 431 | + QString::number( (*it)->availBlocks() * k4/4 ) |
427 | + "K " + (*it)->options() + ";"; | 432 | + "K " + (*it)->options() + ";"; |
428 | } | 433 | } |
429 | } | 434 | } |
430 | if ( !homeFs.isEmpty() ) | 435 | if ( !homeFs.isEmpty() ) |
431 | s += homeFs; | 436 | s += homeFs; |
432 | #ifndef QT_NO_COP | 437 | #ifndef QT_NO_COP |
433 | e << s; | 438 | e << s; |
434 | #endif | 439 | #endif |
435 | } else if ( msg == "sendInstallLocations()" ) { | 440 | } else if ( msg == "sendInstallLocations()" ) { |
436 | #ifndef QT_NO_COP | 441 | #ifndef QT_NO_COP |
437 | QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" ); | 442 | QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" ); |
438 | e << installLocationsString(); | 443 | e << installLocationsString(); |
439 | #endif | 444 | #endif |
440 | } else if ( msg == "sendSyncDate(QString)" ) { | 445 | } else if ( msg == "sendSyncDate(QString)" ) { |
441 | QString app; | 446 | QString app; |
442 | stream >> app; | 447 | stream >> app; |
443 | Config cfg( "qpe" ); | 448 | Config cfg( "qpe" ); |
444 | cfg.setGroup("SyncDate"); | 449 | cfg.setGroup("SyncDate"); |
445 | #ifndef QT_NO_COP | 450 | #ifndef QT_NO_COP |
446 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 451 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
447 | e << app << cfg.readEntry( app ); | 452 | e << app << cfg.readEntry( app ); |
448 | #endif | 453 | #endif |
449 | //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " | 454 | //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " |
450 | // << cfg.readEntry( app ).latin1() << oendl; | 455 | // << cfg.readEntry( app ).latin1() << oendl; |
451 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 456 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
452 | QString app, date; | 457 | QString app, date; |
453 | stream >> app >> date; | 458 | stream >> app >> date; |
454 | Config cfg( "qpe" ); | 459 | Config cfg( "qpe" ); |
455 | cfg.setGroup("SyncDate"); | 460 | cfg.setGroup("SyncDate"); |
456 | cfg.writeEntry( app, date ); | 461 | cfg.writeEntry( app, date ); |
457 | //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; | 462 | //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; |
458 | } else if ( msg == "startSync(QString)" ) { | 463 | } else if ( msg == "startSync(QString)" ) { |
459 | QString what; | 464 | QString what; |
460 | stream >> what; | 465 | stream >> what; |
461 | delete syncDialog; | 466 | delete syncDialog; |
462 | syncDialog = new SyncDialog( this, what ); | 467 | syncDialog = new SyncDialog( this, what ); |
463 | syncDialog->show(); | 468 | syncDialog->show(); |
464 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); | 469 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); |
465 | } else if ( msg == "stopSync()") { | 470 | } else if ( msg == "stopSync()") { |
466 | delete syncDialog; | 471 | delete syncDialog; |
467 | syncDialog = 0; | 472 | syncDialog = 0; |
468 | } else if (msg == "restoreDone(QString)") { | 473 | } else if (msg == "restoreDone(QString)") { |
469 | docList->restoreDone(); | 474 | docList->restoreDone(); |
470 | } else if ( msg == "getAllDocLinks()" ) { | 475 | } else if ( msg == "getAllDocLinks()" ) { |
471 | docList->sendAllDocLinks(); | 476 | docList->sendAllDocLinks(); |
472 | } | 477 | } |
473 | #ifdef QPE_HAVE_DIRECT_ACCESS | 478 | #ifdef QPE_HAVE_DIRECT_ACCESS |
474 | else if ( msg == "prepareDirectAccess()" ) { | 479 | else if ( msg == "prepareDirectAccess()" ) { |
475 | prepareDirectAccess(); | 480 | prepareDirectAccess(); |
476 | } else if ( msg == "postDirectAccess()" ) { | 481 | } else if ( msg == "postDirectAccess()" ) { |
477 | postDirectAccess(); | 482 | postDirectAccess(); |
478 | } | 483 | } |
479 | #endif | 484 | #endif |
480 | #ifdef Q_WS_QWS | 485 | #ifdef Q_WS_QWS |
481 | 486 | ||
482 | else if ( msg == "setMouseProto(QString)" ) { | 487 | else if ( msg == "setMouseProto(QString)" ) { |
483 | QString mice; | 488 | QString mice; |
484 | stream >> mice; | 489 | stream >> mice; |
485 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 490 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
486 | qwsServer->openMouse(); | 491 | qwsServer->openMouse(); |
487 | } else if ( msg == "setKeyboard(QString)" ) { | 492 | } else if ( msg == "setKeyboard(QString)" ) { |
488 | QString kb; | 493 | QString kb; |
489 | stream >> kb; | 494 | stream >> kb; |
490 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 495 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
491 | qwsServer->openKeyboard(); | 496 | qwsServer->openKeyboard(); |
492 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { | 497 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { |
493 | int delay, period; | 498 | int delay, period; |
494 | stream >> delay >> period; | 499 | stream >> delay >> period; |
495 | qwsSetKeyboardAutoRepeat( delay, period ); | 500 | qwsSetKeyboardAutoRepeat( delay, period ); |
496 | Config cfg( "qpe" ); | 501 | Config cfg( "qpe" ); |
497 | cfg.setGroup("Keyboard"); | 502 | cfg.setGroup("Keyboard"); |
498 | cfg.writeEntry( "RepeatDelay", delay ); | 503 | cfg.writeEntry( "RepeatDelay", delay ); |
499 | cfg.writeEntry( "RepeatPeriod", period ); | 504 | cfg.writeEntry( "RepeatPeriod", period ); |
500 | } else if ( msg == "setKeyboardLayout(QString)" ) { | 505 | } else if ( msg == "setKeyboardLayout(QString)" ) { |
501 | QString kb; | 506 | QString kb; |
502 | stream >> kb; | 507 | stream >> kb; |
503 | setKeyboardLayout( kb ); | 508 | setKeyboardLayout( kb ); |
504 | Config cfg( "qpe" ); | 509 | Config cfg( "qpe" ); |
505 | cfg.setGroup("Keyboard"); | 510 | cfg.setGroup("Keyboard"); |
506 | cfg.writeEntry( "Layout", kb ); | 511 | cfg.writeEntry( "Layout", kb ); |
507 | } else if ( msg == "autoStart(QString)" ) { | 512 | } else if ( msg == "autoStart(QString)" ) { |
508 | QString appName; | 513 | QString appName; |
509 | stream >> appName; | 514 | stream >> appName; |
510 | Config cfg( "autostart" ); | 515 | Config cfg( "autostart" ); |
511 | cfg.setGroup( "AutoStart" ); | 516 | cfg.setGroup( "AutoStart" ); |
512 | if ( appName.compare("clear") == 0){ | 517 | if ( appName.compare("clear") == 0){ |
513 | cfg.writeEntry("Apps", ""); | 518 | cfg.writeEntry("Apps", ""); |
514 | } | 519 | } |
515 | } else if ( msg == "autoStart(QString,QString)" ) { | 520 | } else if ( msg == "autoStart(QString,QString)" ) { |
516 | QString modifier, appName; | 521 | QString modifier, appName; |
517 | stream >> modifier >> appName; | 522 | stream >> modifier >> appName; |
518 | Config cfg( "autostart" ); | 523 | Config cfg( "autostart" ); |
519 | cfg.setGroup( "AutoStart" ); | 524 | cfg.setGroup( "AutoStart" ); |
520 | if ( modifier.compare("add") == 0 ){ | 525 | if ( modifier.compare("add") == 0 ){ |
521 | // only add if appname is entered | 526 | // only add if appname is entered |
522 | if (!appName.isEmpty()) { | 527 | if (!appName.isEmpty()) { |
523 | cfg.writeEntry("Apps", appName); | 528 | cfg.writeEntry("Apps", appName); |
524 | } | 529 | } |
525 | } else if (modifier.compare("remove") == 0 ) { | 530 | } else if (modifier.compare("remove") == 0 ) { |
526 | // need to change for multiple entries | 531 | // need to change for multiple entries |
527 | // actually remove is right now simular to clear, but in future there | 532 | // actually remove is right now simular to clear, but in future there |
528 | // should be multiple apps in autostart possible. | 533 | // should be multiple apps in autostart possible. |
529 | QString checkName; | 534 | QString checkName; |
530 | checkName = cfg.readEntry("Apps", ""); | 535 | checkName = cfg.readEntry("Apps", ""); |
531 | if (checkName == appName) { | 536 | if (checkName == appName) { |
532 | cfg.writeEntry("Apps", ""); | 537 | cfg.writeEntry("Apps", ""); |
533 | } | 538 | } |
534 | } | 539 | } |
535 | // case the autostart feature should be delayed | 540 | // case the autostart feature should be delayed |
536 | } else if ( msg == "autoStart(QString,QString,QString)") { | 541 | } else if ( msg == "autoStart(QString,QString,QString)") { |
537 | QString modifier, appName, delay; | 542 | QString modifier, appName, delay; |
538 | stream >> modifier >> appName >> delay; | 543 | stream >> modifier >> appName >> delay; |
539 | Config cfg( "autostart" ); | 544 | Config cfg( "autostart" ); |
540 | 545 | ||
541 | cfg.setGroup( "AutoStart" ); | 546 | cfg.setGroup( "AutoStart" ); |
542 | if ( modifier.compare("add") == 0 ){ | 547 | if ( modifier.compare("add") == 0 ){ |
543 | // only add it appname is entered | 548 | // only add it appname is entered |
544 | if (!appName.isEmpty()) { | 549 | if (!appName.isEmpty()) { |
545 | cfg.writeEntry("Apps", appName); | 550 | cfg.writeEntry("Apps", appName); |
546 | cfg.writeEntry("Delay", delay); | 551 | cfg.writeEntry("Delay", delay); |
547 | } | 552 | } |
548 | } | 553 | } |
549 | } | 554 | } |
550 | #endif | 555 | #endif |
551 | } | 556 | } |
552 | 557 | ||
553 | QString Server::cardInfoString() | 558 | QString Server::cardInfoString() |
@@ -603,384 +608,399 @@ QString Server::installLocationsString() | |||
603 | } | 608 | } |
604 | if ( !homeFs.isEmpty() ) | 609 | if ( !homeFs.isEmpty() ) |
605 | s = homeFs + s; | 610 | s = homeFs + s; |
606 | return s; | 611 | return s; |
607 | } | 612 | } |
608 | 613 | ||
609 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) | 614 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) |
610 | { | 615 | { |
611 | QDataStream stream( data, IO_ReadOnly ); | 616 | QDataStream stream( data, IO_ReadOnly ); |
612 | 617 | ||
613 | if ( msg == "reloadApps()" ) { | 618 | if ( msg == "reloadApps()" ) { |
614 | docList->reloadAppLnks(); | 619 | docList->reloadAppLnks(); |
615 | } else if ( msg == "soundAlarm()" ) { | 620 | } else if ( msg == "soundAlarm()" ) { |
616 | ServerApplication::soundAlarm(); | 621 | ServerApplication::soundAlarm(); |
617 | } else if ( msg == "setLed(int,bool)" ) { | 622 | } else if ( msg == "setLed(int,bool)" ) { |
618 | int led, status; | 623 | int led, status; |
619 | stream >> led >> status; | 624 | stream >> led >> status; |
620 | 625 | ||
621 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); | 626 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); |
622 | if ( ll. count ( )) { | 627 | if ( ll. count ( )) { |
623 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; | 628 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; |
624 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); | 629 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); |
625 | 630 | ||
626 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); | 631 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); |
627 | } | 632 | } |
628 | } | 633 | } |
629 | } | 634 | } |
630 | 635 | ||
631 | void Server::cancelSync() | 636 | void Server::cancelSync() |
632 | { | 637 | { |
633 | #ifndef QT_NO_COP | 638 | #ifndef QT_NO_COP |
634 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 639 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
635 | #endif | 640 | #endif |
636 | delete syncDialog; | 641 | delete syncDialog; |
637 | syncDialog = 0; | 642 | syncDialog = 0; |
638 | } | 643 | } |
639 | 644 | ||
640 | bool Server::mkdir(const QString &localPath) | 645 | bool Server::mkdir(const QString &localPath) |
641 | { | 646 | { |
642 | QDir fullDir(localPath); | 647 | QDir fullDir(localPath); |
643 | if (fullDir.exists()) | 648 | if (fullDir.exists()) |
644 | return true; | 649 | return true; |
645 | 650 | ||
646 | // at this point the directory doesn't exist | 651 | // at this point the directory doesn't exist |
647 | // go through the directory tree and start creating the direcotories | 652 | // go through the directory tree and start creating the direcotories |
648 | // that don't exist; if we can't create the directories, return false | 653 | // that don't exist; if we can't create the directories, return false |
649 | 654 | ||
650 | QString dirSeps = "/"; | 655 | QString dirSeps = "/"; |
651 | int dirIndex = localPath.find(dirSeps); | 656 | int dirIndex = localPath.find(dirSeps); |
652 | QString checkedPath; | 657 | QString checkedPath; |
653 | 658 | ||
654 | // didn't find any seps; weird, use the cur dir instead | 659 | // didn't find any seps; weird, use the cur dir instead |
655 | if (dirIndex == -1) { | 660 | if (dirIndex == -1) { |
656 | //odebug << "No seperators found in path " << localPath << "" << oendl; | 661 | //odebug << "No seperators found in path " << localPath << "" << oendl; |
657 | checkedPath = QDir::currentDirPath(); | 662 | checkedPath = QDir::currentDirPath(); |
658 | } | 663 | } |
659 | 664 | ||
660 | while (checkedPath != localPath) { | 665 | while (checkedPath != localPath) { |
661 | // no more seperators found, use the local path | 666 | // no more seperators found, use the local path |
662 | if (dirIndex == -1) { | 667 | if (dirIndex == -1) { |
663 | checkedPath = localPath; | 668 | checkedPath = localPath; |
664 | } else { | 669 | } else { |
665 | // the next directory to check | 670 | // the next directory to check |
666 | checkedPath = localPath.left(dirIndex) + "/"; | 671 | checkedPath = localPath.left(dirIndex) + "/"; |
667 | // advance the iterator; the next dir seperator | 672 | // advance the iterator; the next dir seperator |
668 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 673 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
669 | } | 674 | } |
670 | 675 | ||
671 | QDir checkDir(checkedPath); | 676 | QDir checkDir(checkedPath); |
672 | if (!checkDir.exists()) { | 677 | if (!checkDir.exists()) { |
673 | //odebug << "mkdir making dir " << checkedPath << "" << oendl; | 678 | //odebug << "mkdir making dir " << checkedPath << "" << oendl; |
674 | 679 | ||
675 | if (!checkDir.mkdir(checkedPath)) { | 680 | if (!checkDir.mkdir(checkedPath)) { |
676 | odebug << "Unable to make directory " << checkedPath << "" << oendl; | 681 | odebug << "Unable to make directory " << checkedPath << "" << oendl; |
677 | return FALSE; | 682 | return FALSE; |
678 | } | 683 | } |
679 | } | 684 | } |
680 | 685 | ||
681 | } | 686 | } |
682 | return TRUE; | 687 | return TRUE; |
683 | } | 688 | } |
684 | 689 | ||
685 | void Server::styleChange( QStyle &s ) | 690 | void Server::styleChange( QStyle &s ) |
686 | { | 691 | { |
687 | QWidget::styleChange( s ); | 692 | QWidget::styleChange( s ); |
688 | } | 693 | } |
689 | 694 | ||
690 | void Server::startTransferServer() | 695 | void Server::startTransferServer() |
691 | { | 696 | { |
692 | if ( !qcopBridge ) { | 697 | if ( !qcopBridge ) { |
693 | // start qcop bridge server | 698 | // start qcop bridge server |
694 | qcopBridge = new QCopBridge( 4243 ); | 699 | qcopBridge = new QCopBridge( 4243 ); |
695 | if ( qcopBridge->ok() ) { | 700 | if ( qcopBridge->ok() ) { |
696 | // ... OK | 701 | // ... OK |
697 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), | 702 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), |
698 | this, SLOT(syncConnectionClosed(const QHostAddress&)) ); | 703 | this, SLOT(syncConnectionClosed(const QHostAddress&)) ); |
699 | } else { | 704 | } else { |
700 | delete qcopBridge; | 705 | delete qcopBridge; |
701 | qcopBridge = 0; | 706 | qcopBridge = 0; |
702 | } | 707 | } |
703 | } | 708 | } |
704 | 709 | ||
705 | if ( !transferServer ) { | 710 | if ( !transferServer ) { |
706 | // start transfer server | 711 | // start transfer server |
707 | transferServer = new TransferServer( 4242 ); | 712 | transferServer = new TransferServer( 4242 ); |
708 | if ( transferServer->ok() ) { | 713 | if ( transferServer->ok() ) { |
709 | // ... OK | 714 | // ... OK |
710 | } else { | 715 | } else { |
711 | delete transferServer; | 716 | delete transferServer; |
712 | transferServer = 0; | 717 | transferServer = 0; |
713 | } | 718 | } |
714 | 719 | ||
715 | if ( !qcopBridge ) | 720 | if ( !qcopBridge ) |
716 | tid_xfer = startTimer( 2000 ); | 721 | tid_xfer = startTimer( 2000 ); |
717 | } | 722 | } |
718 | } | 723 | } |
719 | 724 | ||
720 | void Server::timerEvent( QTimerEvent *e ) | 725 | void Server::timerEvent( QTimerEvent *e ) |
721 | { | 726 | { |
722 | if ( e->timerId() == tid_xfer ) { | 727 | if ( e->timerId() == tid_xfer ) { |
723 | killTimer( tid_xfer ); | 728 | killTimer( tid_xfer ); |
724 | tid_xfer = 0; | 729 | tid_xfer = 0; |
725 | startTransferServer(); | 730 | startTransferServer(); |
726 | } | 731 | } |
727 | #if 0 | 732 | #if 0 |
728 | /* ### FIXME today startin */ | 733 | /* ### FIXME today startin */ |
729 | else if ( e->timerId() == tid_today ) { | 734 | else if ( e->timerId() == tid_today ) { |
730 | QDate today = QDate::currentDate(); | 735 | QDate today = QDate::currentDate(); |
731 | if ( today != last_today_show ) { | 736 | if ( today != last_today_show ) { |
732 | last_today_show = today; | 737 | last_today_show = today; |
733 | Config cfg("today"); | 738 | Config cfg("today"); |
734 | cfg.setGroup("Start"); | 739 | cfg.setGroup("Start"); |
735 | #ifndef QPE_DEFAULT_TODAY_MODE | 740 | #ifndef QPE_DEFAULT_TODAY_MODE |
736 | #define QPE_DEFAULT_TODAY_MODE "Never" | 741 | #define QPE_DEFAULT_TODAY_MODE "Never" |
737 | #endif | 742 | #endif |
738 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { | 743 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { |
739 | QCopEnvelope env(Service::channel("today"),"raise()"); | 744 | QCopEnvelope env(Service::channel("today"),"raise()"); |
740 | } | 745 | } |
741 | } | 746 | } |
742 | } | 747 | } |
743 | #endif | 748 | #endif |
744 | } | 749 | } |
745 | 750 | ||
746 | void Server::terminateServers() | 751 | void Server::terminateServers() |
747 | { | 752 | { |
748 | delete transferServer; | 753 | delete transferServer; |
749 | delete qcopBridge; | 754 | delete qcopBridge; |
750 | transferServer = 0; | 755 | transferServer = 0; |
751 | qcopBridge = 0; | 756 | qcopBridge = 0; |
752 | } | 757 | } |
753 | 758 | ||
754 | void Server::syncConnectionClosed( const QHostAddress & ) | 759 | void Server::syncConnectionClosed( const QHostAddress & ) |
755 | { | 760 | { |
756 | odebug << "Lost sync connection" << oendl; | 761 | odebug << "Lost sync connection" << oendl; |
757 | delete syncDialog; | 762 | delete syncDialog; |
758 | syncDialog = 0; | 763 | syncDialog = 0; |
759 | } | 764 | } |
760 | 765 | ||
761 | void Server::pokeTimeMonitors() | 766 | void Server::pokeTimeMonitors() |
762 | { | 767 | { |
763 | #if 0 | 768 | #if 0 |
764 | // inform all TimeMonitors | 769 | // inform all TimeMonitors |
765 | QStrList tms = Service::channels("TimeMonitor"); | 770 | QStrList tms = Service::channels("TimeMonitor"); |
766 | for (const char* ch = tms.first(); ch; ch=tms.next()) { | 771 | for (const char* ch = tms.first(); ch; ch=tms.next()) { |
767 | QString t = getenv("TZ"); | 772 | QString t = getenv("TZ"); |
768 | QCopEnvelope e(ch, "timeChange(QString)"); | 773 | QCopEnvelope e(ch, "timeChange(QString)"); |
769 | e << t; | 774 | e << t; |
770 | } | 775 | } |
771 | #endif | 776 | #endif |
772 | } | 777 | } |
773 | 778 | ||
774 | void Server::applicationLaunched(int, const QString &app) | 779 | void Server::applicationLaunched(int, const QString &app) |
775 | { | 780 | { |
776 | serverGui->applicationStateChanged( app, ServerInterface::Launching ); | 781 | serverGui->applicationStateChanged( app, ServerInterface::Launching ); |
777 | } | 782 | } |
778 | 783 | ||
779 | void Server::applicationTerminated(int pid, const QString &app) | 784 | void Server::applicationTerminated(int pid, const QString &app) |
780 | { | 785 | { |
781 | serverGui->applicationStateChanged( app, ServerInterface::Terminated ); | 786 | serverGui->applicationStateChanged( app, ServerInterface::Terminated ); |
782 | #if 0 | 787 | #if 0 |
783 | tsmMonitor->applicationTerminated( pid ); | 788 | tsmMonitor->applicationTerminated( pid ); |
784 | #else | 789 | #else |
785 | Q_UNUSED( pid ) | 790 | Q_UNUSED( pid ) |
786 | #endif | 791 | #endif |
787 | } | 792 | } |
788 | 793 | ||
789 | void Server::applicationConnected(const QString &app) | 794 | void Server::applicationConnected(const QString &app) |
790 | { | 795 | { |
791 | serverGui->applicationStateChanged( app, ServerInterface::Running ); | 796 | serverGui->applicationStateChanged( app, ServerInterface::Running ); |
792 | } | 797 | } |
793 | 798 | ||
794 | void Server::storageChanged() | 799 | void Server::storageChanged() |
795 | { | 800 | { |
796 | system( "opie-update-symlinks" ); | 801 | system( "opie-update-symlinks" ); |
797 | serverGui->storageChanged( storage->fileSystems() ); | 802 | serverGui->storageChanged( storage->fileSystems() ); |
798 | docList->storageChanged(); | 803 | docList->storageChanged(); |
799 | } | 804 | } |
800 | 805 | ||
801 | 806 | ||
802 | 807 | ||
803 | void Server::preloadApps() | 808 | void Server::preloadApps() |
804 | { | 809 | { |
805 | Config cfg("Launcher"); | 810 | Config cfg("Launcher"); |
806 | cfg.setGroup("Preload"); | 811 | cfg.setGroup("Preload"); |
807 | QStringList apps = cfg.readListEntry("Apps",','); | 812 | QStringList apps = cfg.readListEntry("Apps",','); |
808 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 813 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
809 | #ifndef QT_NO_COP | 814 | #ifndef QT_NO_COP |
810 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 815 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
811 | #endif | 816 | #endif |
812 | } | 817 | } |
813 | } | 818 | } |
814 | 819 | ||
815 | // This is only called if QPE_HAVE_DIRECT_ACCESS is defined | 820 | // This is only called if QPE_HAVE_DIRECT_ACCESS is defined |
816 | void Server::prepareDirectAccess() | 821 | void Server::prepareDirectAccess() |
817 | { | 822 | { |
818 | qDebug( "Server::prepareDirectAccess()" ); | 823 | qDebug( "Server::prepareDirectAccess()" ); |
819 | // Put up a pretty dialog | 824 | // Put up a pretty dialog |
820 | syncDialog = new SyncDialog( this, tr("USB Lock") ); | 825 | syncDialog = new SyncDialog( this, tr("USB Lock") ); |
821 | syncDialog->show(); | 826 | syncDialog->show(); |
822 | 827 | ||
823 | // Prevent the PDA from acting as a PDA | 828 | // Prevent the PDA from acting as a PDA |
824 | terminateServers(); | 829 | terminateServers(); |
825 | 830 | ||
826 | // suspend the mtab monitor | 831 | // suspend the mtab monitor |
827 | #ifndef QT_NO_COP | 832 | #ifndef QT_NO_COP |
828 | { | 833 | { |
829 | QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" ); | 834 | QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" ); |
830 | } | 835 | } |
831 | #endif | 836 | #endif |
832 | 837 | ||
833 | // send out a flush message | 838 | // send out a flush message |
834 | // once flushes are done call runDirectAccess() | 839 | // once flushes are done call runDirectAccess() |
835 | // We just count the number of apps and set a timer. | 840 | // We just count the number of apps and set a timer. |
836 | // Either the timer expires or the correct number of apps responds. | 841 | // Either the timer expires or the correct number of apps responds. |
837 | // Note: quicklauncher isn't in the runningApps list but it responds | 842 | // Note: quicklauncher isn't in the runningApps list but it responds |
838 | // to the flush so we start the counter at 1 | 843 | // to the flush so we start the counter at 1 |
839 | pendingFlushes = 1; | 844 | pendingFlushes = 1; |
840 | directAccessRun = FALSE; | 845 | directAccessRun = FALSE; |
841 | for ( QMap<int,QString>::ConstIterator it = | 846 | for ( QMap<int,QString>::ConstIterator it = |
842 | appLauncher->runningApplications().begin(); | 847 | appLauncher->runningApplications().begin(); |
843 | it != appLauncher->runningApplications().end(); | 848 | it != appLauncher->runningApplications().end(); |
844 | ++it ) { | 849 | ++it ) { |
845 | pendingFlushes++; | 850 | pendingFlushes++; |
846 | } | 851 | } |
847 | #ifndef QT_NO_COP | 852 | #ifndef QT_NO_COP |
848 | QCopEnvelope e1( "QPE/System", "flush()" ); | 853 | QCopEnvelope e1( "QPE/System", "flush()" ); |
849 | #endif | 854 | #endif |
850 | QTimer::singleShot( 10000, this, SLOT(runDirectAccess()) ); | 855 | QTimer::singleShot( 10000, this, SLOT(runDirectAccess()) ); |
851 | #warning FIXME support TempScreenSaverMode | 856 | #warning FIXME support TempScreenSaverMode |
852 | #if 0 | 857 | #if 0 |
853 | QPEApplication::setTempScreenSaverMode(QPEApplication::DisableSuspend); | 858 | QPEApplication::setTempScreenSaverMode(QPEApplication::DisableSuspend); |
854 | #endif | 859 | #endif |
855 | } | 860 | } |
856 | 861 | ||
857 | // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined | 862 | // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined |
858 | // It fakes the presence of Qtopia Desktop | 863 | // It fakes the presence of Qtopia Desktop |
859 | void Server::desktopMessage( const QCString &message, const QByteArray &data ) | 864 | void Server::desktopMessage( const QCString &message, const QByteArray &data ) |
860 | { | 865 | { |
861 | QDataStream stream( data, IO_ReadOnly ); | 866 | QDataStream stream( data, IO_ReadOnly ); |
862 | if ( message == "flushDone(QString)" ) { | 867 | if ( message == "flushDone(QString)" ) { |
863 | QString app; | 868 | QString app; |
864 | stream >> app; | 869 | stream >> app; |
865 | qDebug( "flushDone from %s", app.latin1() ); | 870 | qDebug( "flushDone from %s", app.latin1() ); |
866 | if ( --pendingFlushes == 0 ) { | 871 | if ( --pendingFlushes == 0 ) { |
867 | qDebug( "pendingFlushes == 0, all the apps responded" ); | 872 | qDebug( "pendingFlushes == 0, all the apps responded" ); |
868 | runDirectAccess(); | 873 | runDirectAccess(); |
869 | } | 874 | } |
870 | } else if ( message == "installStarted(QString)" ) { | 875 | } else if ( message == "installStarted(QString)" ) { |
871 | QString package; | 876 | QString package; |
872 | stream >> package; | 877 | stream >> package; |
873 | qDebug( "\tInstall Started for package %s", package.latin1() ); | 878 | qDebug( "\tInstall Started for package %s", package.latin1() ); |
874 | } else if ( message == "installStep(QString)" ) { | 879 | } else if ( message == "installStep(QString)" ) { |
875 | QString step; | 880 | QString step; |
876 | stream >> step; | 881 | stream >> step; |
877 | qDebug( "\tInstall Step %s", step.latin1() ); | 882 | qDebug( "\tInstall Step %s", step.latin1() ); |
878 | } else if ( message == "installDone(QString)" ) { | 883 | } else if ( message == "installDone(QString)" ) { |
879 | QString package; | 884 | QString package; |
880 | stream >> package; | 885 | stream >> package; |
881 | qDebug( "\tInstall Finished for package %s", package.latin1() ); | 886 | qDebug( "\tInstall Finished for package %s", package.latin1() ); |
882 | } else if ( message == "installFailed(QString,int,QString)" ) { | 887 | } else if ( message == "installFailed(QString,int,QString)" ) { |
883 | QString package, error; | 888 | QString package, error; |
884 | int status; | 889 | int status; |
885 | stream >> package >> status >> error; | 890 | stream >> package >> status >> error; |
886 | qDebug( "\tInstall Failed for package %s with error code %d and error message %s", | 891 | qDebug( "\tInstall Failed for package %s with error code %d and error message %s", |
887 | package.latin1(), status, error.latin1() ); | 892 | package.latin1(), status, error.latin1() ); |
888 | } else if ( message == "removeStarted(QString)" ) { | 893 | } else if ( message == "removeStarted(QString)" ) { |
889 | QString package; | 894 | QString package; |
890 | stream >> package; | 895 | stream >> package; |
891 | qDebug( "\tRemove Started for package %s", package.latin1() ); | 896 | qDebug( "\tRemove Started for package %s", package.latin1() ); |
892 | } else if ( message == "removeDone(QString)" ) { | 897 | } else if ( message == "removeDone(QString)" ) { |
893 | QString package; | 898 | QString package; |
894 | stream >> package; | 899 | stream >> package; |
895 | qDebug( "\tRemove Finished for package %s", package.latin1() ); | 900 | qDebug( "\tRemove Finished for package %s", package.latin1() ); |
896 | } else if ( message == "removeFailed(QString)" ) { | 901 | } else if ( message == "removeFailed(QString)" ) { |
897 | QString package; | 902 | QString package; |
898 | stream >> package; | 903 | stream >> package; |
899 | qDebug( "\tRemove Failed for package %s", package.latin1() ); | 904 | qDebug( "\tRemove Failed for package %s", package.latin1() ); |
900 | } | 905 | } |
901 | 906 | ||
902 | if ( qrr && qrr->waitingForMessages ) | 907 | if ( qrr && qrr->waitingForMessages ) |
903 | qrr->desktopMessage( message, data ); | 908 | qrr->desktopMessage( message, data ); |
904 | } | 909 | } |
905 | 910 | ||
906 | 911 | ||
907 | // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined | 912 | // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined |
908 | void Server::runDirectAccess() | 913 | void Server::runDirectAccess() |
909 | { | 914 | { |
910 | #ifdef QPE_HAVE_DIRECT_ACCESS | 915 | #ifdef QPE_HAVE_DIRECT_ACCESS |
911 | // The timer must have fired after all the apps responded | 916 | // The timer must have fired after all the apps responded |
912 | // with flushDone(). Just ignore it. | 917 | // with flushDone(). Just ignore it. |
913 | if ( directAccessRun ) | 918 | if ( directAccessRun ) |
914 | return; | 919 | return; |
915 | 920 | ||
916 | directAccessRun = TRUE; | 921 | directAccessRun = TRUE; |
917 | ::readyDirectAccess(cardInfoString(), installLocationsString()); | 922 | ::readyDirectAccess(cardInfoString(), installLocationsString()); |
918 | #endif | 923 | #endif |
919 | } | 924 | } |
920 | 925 | ||
921 | // This is only called if QPE_HAVE_DIRECT_ACCESS is defined | 926 | // This is only called if QPE_HAVE_DIRECT_ACCESS is defined |
922 | void Server::postDirectAccess() | 927 | void Server::postDirectAccess() |
923 | { | 928 | { |
924 | #ifdef QPE_HAVE_DIRECT_ACCESS | 929 | #ifdef QPE_HAVE_DIRECT_ACCESS |
925 | qDebug( "Server::postDirectAccess()" ); | 930 | qDebug( "Server::postDirectAccess()" ); |
926 | 931 | ||
927 | // Categories may have changed | 932 | // Categories may have changed |
928 | QCopEnvelope e1( "QPE/System", "categoriesChanged()" ); | 933 | QCopEnvelope e1( "QPE/System", "categoriesChanged()" ); |
929 | // Apps need to reload their data | 934 | // Apps need to reload their data |
930 | QCopEnvelope e2( "QPE/System", "reload()" ); | 935 | QCopEnvelope e2( "QPE/System", "reload()" ); |
931 | // Reload DocLinks | 936 | // Reload DocLinks |
932 | docList->storageChanged(); | 937 | docList->storageChanged(); |
933 | // Restart the PDA server stuff | 938 | // Restart the PDA server stuff |
934 | startTransferServer(); | 939 | startTransferServer(); |
935 | 940 | ||
936 | // restart the mtab monitor | 941 | // restart the mtab monitor |
937 | #ifndef QT_NO_COP | 942 | #ifndef QT_NO_COP |
938 | { | 943 | { |
939 | QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" ); | 944 | QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" ); |
940 | } | 945 | } |
941 | #endif | 946 | #endif |
942 | 947 | ||
943 | // Process queued requests | 948 | // Process queued requests |
944 | const char *queueFile = ::directAccessQueueFile(); | 949 | const char *queueFile = ::directAccessQueueFile(); |
945 | QFile *file = new QFile( queueFile ); | 950 | QFile *file = new QFile( queueFile ); |
946 | if ( !file->exists() ) { | 951 | if ( !file->exists() ) { |
947 | delete file; | 952 | delete file; |
948 | // Get rid of the dialog | 953 | // Get rid of the dialog |
949 | if ( syncDialog ) { | 954 | if ( syncDialog ) { |
950 | delete syncDialog; | 955 | delete syncDialog; |
951 | syncDialog = 0; | 956 | syncDialog = 0; |
952 | } | 957 | } |
953 | #warning FIXME support TempScreenSaverMode | 958 | #warning FIXME support TempScreenSaverMode |
954 | #if 0 | 959 | #if 0 |
955 | QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); | 960 | QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); |
956 | #endif | 961 | #endif |
957 | } else { | 962 | } else { |
958 | qrr = new QueuedRequestRunner( file, syncDialog ); | 963 | qrr = new QueuedRequestRunner( file, syncDialog ); |
959 | connect( qrr, SIGNAL(finished()), | 964 | connect( qrr, SIGNAL(finished()), |
960 | this, SLOT(finishedQueuedRequests()) ); | 965 | this, SLOT(finishedQueuedRequests()) ); |
961 | QTimer::singleShot( 100, qrr, SLOT(process()) ); | 966 | QTimer::singleShot( 100, qrr, SLOT(process()) ); |
962 | // qrr will remove the sync dialog later | 967 | // qrr will remove the sync dialog later |
963 | } | 968 | } |
964 | #endif | 969 | #endif |
965 | } | 970 | } |
966 | 971 | ||
967 | void Server::finishedQueuedRequests() | 972 | void Server::finishedQueuedRequests() |
968 | { | 973 | { |
969 | if ( qrr->readyToDelete ) { | 974 | if ( qrr->readyToDelete ) { |
970 | delete qrr; | 975 | delete qrr; |
971 | qrr = 0; | 976 | qrr = 0; |
972 | // Get rid of the dialog | 977 | // Get rid of the dialog |
973 | if ( syncDialog ) { | 978 | if ( syncDialog ) { |
974 | delete syncDialog; | 979 | delete syncDialog; |
975 | syncDialog = 0; | 980 | syncDialog = 0; |
976 | } | 981 | } |
977 | #warning FIXME support TempScreenSaverMode | 982 | #warning FIXME support TempScreenSaverMode |
978 | #if 0 | 983 | #if 0 |
979 | QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); | 984 | QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); |
980 | #endif | 985 | #endif |
981 | } else { | 986 | } else { |
982 | qrr->readyToDelete = TRUE; | 987 | qrr->readyToDelete = TRUE; |
983 | QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); | 988 | QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); |
984 | } | 989 | } |
985 | } | 990 | } |
986 | 991 | ||
992 | void Server::startSoundServer() { | ||
993 | if ( !process ) { | ||
994 | process = new Opie::Core::OProcess( this ); | ||
995 | connect(process, SIGNAL(processExited(Opie::Core::OProcess*)), | ||
996 | SLOT(soundServerExited())); | ||
997 | } | ||
998 | |||
999 | process->clearArguments(); | ||
1000 | *process << QPEApplication::qpeDir() + "bin/qss"; | ||
1001 | process->start(); | ||
1002 | } | ||
1003 | |||
1004 | void Server::soundServerExited() { | ||
1005 | QTimer::singleShot(5000, this, SLOT(startSoundServer())); | ||
1006 | } | ||
diff --git a/core/launcher/server.h b/core/launcher/server.h index d71d68a..5b2f995 100644 --- a/core/launcher/server.h +++ b/core/launcher/server.h | |||
@@ -1,111 +1,118 @@ | |||
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 | class QueuedRequestRunner; | 40 | class QueuedRequestRunner; |
41 | namespace Opie { | 41 | namespace Opie { |
42 | namespace Core { | 42 | namespace Core { |
43 | class ODeviceButton; | 43 | class ODeviceButton; |
44 | class OProcess; | ||
44 | } | 45 | } |
45 | } | 46 | } |
46 | 47 | ||
47 | class Server : public QWidget { | 48 | class Server : public QWidget { |
48 | Q_OBJECT | 49 | Q_OBJECT |
49 | public: | 50 | public: |
50 | Server(); | 51 | Server(); |
51 | ~Server(); | 52 | ~Server(); |
52 | 53 | ||
53 | static bool mkdir(const QString &path); | 54 | static bool mkdir(const QString &path); |
54 | 55 | ||
55 | void show(); | 56 | void show(); |
56 | 57 | ||
57 | static bool setKeyboardLayout( const QString &kb ); | 58 | static bool setKeyboardLayout( const QString &kb ); |
58 | 59 | ||
59 | public slots: | 60 | public slots: |
60 | void systemMsg(const QCString &, const QByteArray &); | 61 | void systemMsg(const QCString &, const QByteArray &); |
61 | void receiveTaskBar(const QCString &msg, const QByteArray &data); | 62 | void receiveTaskBar(const QCString &msg, const QByteArray &data); |
62 | void terminateServers(); | 63 | void terminateServers(); |
63 | void pokeTimeMonitors(); | 64 | void pokeTimeMonitors(); |
64 | 65 | ||
65 | private slots: | 66 | private slots: |
67 | //@{ | ||
68 | void startSoundServer(); | ||
69 | void soundServerExited(); | ||
70 | //@} | ||
66 | void activate(const Opie::Core::ODeviceButton*,bool); | 71 | void activate(const Opie::Core::ODeviceButton*,bool); |
67 | void syncConnectionClosed( const QHostAddress & ); | 72 | void syncConnectionClosed( const QHostAddress & ); |
68 | void applicationLaunched(int pid, const QString &app); | 73 | void applicationLaunched(int pid, const QString &app); |
69 | void applicationTerminated(int pid, const QString &app); | 74 | void applicationTerminated(int pid, const QString &app); |
70 | void applicationConnected(const QString &app); | 75 | void applicationConnected(const QString &app); |
71 | void storageChanged(); | 76 | void storageChanged(); |
72 | void cancelSync(); | 77 | void cancelSync(); |
73 | void desktopMessage( const QCString &, const QByteArray & ); | 78 | void desktopMessage( const QCString &, const QByteArray & ); |
74 | void runDirectAccess(); | 79 | void runDirectAccess(); |
75 | void finishedQueuedRequests(); | 80 | void finishedQueuedRequests(); |
76 | 81 | ||
77 | protected: | 82 | protected: |
78 | void styleChange( QStyle & ); | 83 | void styleChange( QStyle & ); |
79 | void timerEvent( QTimerEvent *e ); | 84 | void timerEvent( QTimerEvent *e ); |
80 | 85 | ||
81 | private: | 86 | private: |
82 | void layout(); | 87 | void layout(); |
83 | void startTransferServer(); | 88 | void startTransferServer(); |
84 | void preloadApps(); | 89 | void preloadApps(); |
85 | void prepareDirectAccess(); | 90 | void prepareDirectAccess(); |
86 | void postDirectAccess(); | 91 | void postDirectAccess(); |
87 | QString cardInfoString(); | 92 | QString cardInfoString(); |
88 | QString installLocationsString(); | 93 | QString installLocationsString(); |
89 | 94 | ||
90 | QCopBridge *qcopBridge; | 95 | QCopBridge *qcopBridge; |
91 | TransferServer *transferServer; | 96 | TransferServer *transferServer; |
92 | PackageHandler *packageHandler; | 97 | PackageHandler *packageHandler; |
93 | QDate last_today_show; | 98 | QDate last_today_show; |
94 | int tid_xfer; | 99 | int tid_xfer; |
95 | /* ### FIXME two below### */ | 100 | /* ### FIXME two below### */ |
96 | // int tid_today; | 101 | // int tid_today; |
97 | // TempScreenSaverMonitor *tsmMonitor; | 102 | // TempScreenSaverMonitor *tsmMonitor; |
98 | StorageInfo *storage; | 103 | StorageInfo *storage; |
99 | SyncDialog *syncDialog; | 104 | SyncDialog *syncDialog; |
100 | AppLauncher *appLauncher; | 105 | AppLauncher *appLauncher; |
101 | DocumentList *docList; | 106 | DocumentList *docList; |
102 | ServerInterface *serverGui; | 107 | ServerInterface *serverGui; |
103 | 108 | ||
104 | int pendingFlushes; | 109 | int pendingFlushes; |
105 | bool directAccessRun; | 110 | bool directAccessRun; |
106 | QueuedRequestRunner *qrr; | 111 | QueuedRequestRunner *qrr; |
112 | |||
113 | Opie::Core::OProcess *process; | ||
107 | }; | 114 | }; |
108 | 115 | ||
109 | 116 | ||
110 | #endif // DESKTOP_H | 117 | #endif // DESKTOP_H |
111 | 118 | ||