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