-rw-r--r-- | core/launcher/server.cpp | 145 | ||||
-rw-r--r-- | core/launcher/server.h | 13 |
2 files changed, 117 insertions, 41 deletions
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 08baa8e..450d8e5 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp | |||
@@ -1,657 +1,730 @@ | |||
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 "launcher.h" | 23 | #include "launcher.h" |
24 | #include "startmenu.h" | 24 | #include "startmenu.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 "launcher.h" | 32 | #include "launcher.h" |
33 | #include "shutdownimpl.h" | 33 | #include "shutdownimpl.h" |
34 | #include "applauncher.h" | 34 | #include "applauncher.h" |
35 | #if 0 | ||
35 | #include "suspendmonitor.h" | 36 | #include "suspendmonitor.h" |
37 | #endif | ||
36 | #include "documentlist.h" | 38 | #include "documentlist.h" |
37 | 39 | ||
38 | #include <qtopia/applnk.h> | 40 | #include <qtopia/applnk.h> |
39 | #include <qtopia/categories.h> | 41 | #include <qtopia/private/categories.h> |
40 | #include <qtopia/mimetype.h> | 42 | #include <qtopia/mimetype.h> |
41 | #include <qtopia/config.h> | 43 | #include <qtopia/config.h> |
42 | #include <qtopia/services.h> | ||
43 | #include <qtopia/devicebuttonmanager.h> | ||
44 | #include <qtopia/pluginloader.h> | ||
45 | #include <qtopia/resource.h> | 44 | #include <qtopia/resource.h> |
46 | #include <qtopia/version.h> | 45 | #include <qtopia/version.h> |
47 | #include <qtopia/storage.h> | 46 | #include <qtopia/storage.h> |
48 | 47 | ||
49 | #ifdef Q_WS_QWS | ||
50 | #include <qtopia/qcopenvelope_qws.h> | 48 | #include <qtopia/qcopenvelope_qws.h> |
51 | #include <qwindowsystem_qws.h> | 49 | #include <qwindowsystem_qws.h> |
52 | #include <qgfx_qws.h> | 50 | #include <qgfx_qws.h> |
53 | #endif | ||
54 | #include <qtopia/global.h> | 51 | #include <qtopia/global.h> |
55 | #include <qtopia/custom.h> | 52 | #include <qtopia/custom.h> |
56 | 53 | ||
57 | #ifdef Q_OS_WIN32 | 54 | #include <opie/odevicebutton.h> |
58 | #include <io.h> | 55 | #include <opie/odevice.h> |
59 | #include <process.h> | 56 | |
60 | #else | ||
61 | #include <unistd.h> | 57 | #include <unistd.h> |
62 | #endif | ||
63 | #include <qmainwindow.h> | 58 | #include <qmainwindow.h> |
64 | #include <qmessagebox.h> | 59 | #include <qmessagebox.h> |
65 | #include <qtimer.h> | 60 | #include <qtimer.h> |
66 | #include <qtextstream.h> | 61 | #include <qtextstream.h> |
67 | 62 | ||
68 | #include <stdlib.h> | 63 | #include <stdlib.h> |
69 | 64 | ||
70 | extern QRect qt_maxWindowRect; | 65 | extern QRect qt_maxWindowRect; |
71 | 66 | ||
67 | using namespace Opie; | ||
68 | |||
72 | static QWidget *calibrate(bool) | 69 | static QWidget *calibrate(bool) |
73 | { | 70 | { |
74 | #ifdef Q_WS_QWS | 71 | #ifdef Q_WS_QWS |
75 | Calibrate *c = new Calibrate; | 72 | Calibrate *c = new Calibrate; |
76 | c->show(); | 73 | c->show(); |
77 | return c; | 74 | return c; |
78 | #else | 75 | #else |
79 | return 0; | 76 | return 0; |
80 | #endif | 77 | #endif |
81 | } | 78 | } |
82 | 79 | ||
83 | #define FACTORY(T) \ | 80 | #define FACTORY(T) \ |
84 | static QWidget *new##T( bool maximized ) { \ | 81 | static QWidget *new##T( bool maximized ) { \ |
85 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ | 82 | QWidget *w = new T( 0, 0, QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ |
86 | if ( maximized ) { \ | 83 | if ( maximized ) { \ |
87 | if ( qApp->desktop()->width() <= 350 ) { \ | 84 | if ( qApp->desktop()->width() <= 350 ) { \ |
88 | w->showMaximized(); \ | 85 | w->showMaximized(); \ |
89 | } else { \ | 86 | } else { \ |
90 | w->resize( QSize( 300, 300 ) ); \ | 87 | w->resize( QSize( 300, 300 ) ); \ |
91 | } \ | 88 | } \ |
92 | } \ | 89 | } \ |
93 | w->show(); \ | 90 | w->show(); \ |
94 | return w; \ | 91 | return w; \ |
95 | } | 92 | } |
96 | 93 | ||
97 | 94 | ||
98 | #ifdef SINGLE_APP | 95 | #ifdef SINGLE_APP |
99 | #define APP(a,b,c,d) FACTORY(b) | 96 | #define APP(a,b,c,d) FACTORY(b) |
100 | #include "apps.h" | 97 | #include "apps.h" |
101 | #undef APP | 98 | #undef APP |
102 | #endif // SINGLE_APP | 99 | #endif // SINGLE_APP |
103 | 100 | ||
104 | static Global::Command builtins[] = { | 101 | static Global::Command builtins[] = { |
105 | 102 | ||
106 | #ifdef SINGLE_APP | 103 | #ifdef SINGLE_APP |
107 | #define APP(a,b,c,d) { a, new##b, c, d }, | 104 | #define APP(a,b,c,d) { a, new##b, c, d }, |
108 | #include "apps.h" | 105 | #include "apps.h" |
109 | #undef APP | 106 | #undef APP |
110 | #endif | 107 | #endif |
111 | 108 | ||
109 | /* FIXME defines need to be defined*/ | ||
112 | #if defined(QPE_NEED_CALIBRATION) | 110 | #if defined(QPE_NEED_CALIBRATION) |
113 | { "calibrate", calibrate,1, 0 }, // No tr | 111 | { "calibrate", calibrate, 1, 0 }, // No tr |
114 | #endif | 112 | #endif |
115 | #if !defined(QT_QWS_CASSIOPEIA) | 113 | #if !defined(QT_QWS_CASSIOPEIA) |
116 | { "shutdown", Global::shutdown, 1, 0 }, // No tr | 114 | { "shutdown", Global::shutdown, 1, 0 }, // No tr |
117 | // { "run", run, 1, 0 }, // No tr | 115 | // { "run", run, 1, 0 }, // No tr |
118 | #endif | 116 | #endif |
119 | 117 | ||
120 | { 0, calibrate,0, 0 }, | 118 | { 0, calibrate,0, 0 }, |
121 | }; | 119 | }; |
122 | 120 | ||
123 | 121 | ||
124 | //--------------------------------------------------------------------------- | 122 | //--------------------------------------------------------------------------- |
125 | 123 | ||
126 | 124 | ||
127 | //=========================================================================== | 125 | //=========================================================================== |
128 | 126 | ||
129 | Server::Server() : | 127 | Server::Server() : |
130 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 128 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
131 | qcopBridge( 0 ), | 129 | qcopBridge( 0 ), |
132 | transferServer( 0 ), | 130 | transferServer( 0 ), |
133 | packageHandler( 0 ), | 131 | packageHandler( 0 ), |
134 | syncDialog( 0 ) | 132 | syncDialog( 0 ) |
135 | { | 133 | { |
136 | Global::setBuiltinCommands(builtins); | 134 | Global::setBuiltinCommands(builtins); |
137 | 135 | ||
138 | tid_xfer = 0; | 136 | tid_xfer = 0; |
139 | tid_today = startTimer(3600*2*1000); | 137 | /* ### FIXME ### */ |
138 | /* tid_today = startTimer(3600*2*1000);*/ | ||
140 | last_today_show = QDate::currentDate(); | 139 | last_today_show = QDate::currentDate(); |
141 | 140 | ||
142 | tsmMonitor = new TempScreenSaverMonitor(); | 141 | #if 0 |
142 | tsmMonitor = new TempScreenSaverMode(); | ||
143 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); | 143 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); |
144 | #endif | ||
144 | 145 | ||
145 | serverGui = new Launcher; | 146 | serverGui = new Launcher; |
146 | serverGui->createGUI(); | 147 | serverGui->createGUI(); |
147 | 148 | ||
148 | docList = new DocumentList( serverGui ); | 149 | docList = new DocumentList( serverGui ); |
149 | appLauncher = new AppLauncher(this); | 150 | appLauncher = new AppLauncher(this); |
150 | connect(appLauncher, SIGNAL(launched(int, const QString &)), this, SLOT(applicationLaunched(int, const QString &)) ); | 151 | connect(appLauncher, SIGNAL(launched(int, const QString &)), this, SLOT(applicationLaunched(int, const QString &)) ); |
151 | connect(appLauncher, SIGNAL(terminated(int, const QString &)), this, SLOT(applicationTerminated(int, const QString &)) ); | 152 | connect(appLauncher, SIGNAL(terminated(int, const QString &)), this, SLOT(applicationTerminated(int, const QString &)) ); |
152 | connect(appLauncher, SIGNAL(connected(const QString &)), this, SLOT(applicationConnected(const QString &)) ); | 153 | connect(appLauncher, SIGNAL(connected(const QString &)), this, SLOT(applicationConnected(const QString &)) ); |
153 | 154 | ||
154 | storage = new StorageInfo( this ); | 155 | storage = new StorageInfo( this ); |
155 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); | 156 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); |
156 | 157 | ||
157 | // start services | 158 | // start services |
158 | startTransferServer(); | 159 | startTransferServer(); |
159 | (void) new IrServer( this ); | 160 | (void) new IrServer( this ); |
160 | 161 | ||
161 | packageHandler = new PackageHandler( this ); | 162 | packageHandler = new PackageHandler( this ); |
162 | connect(qApp, SIGNAL(activate(const DeviceButton*,bool)),this,SLOT(activate(const DeviceButton*,bool))); | 163 | connect(qApp, SIGNAL(activate(const Opie::ODeviceButton*,bool)), |
164 | this,SLOT(activate(const Opie::ODeviceButton*,bool))); | ||
163 | 165 | ||
164 | setGeometry( -10, -10, 9, 9 ); | 166 | setGeometry( -10, -10, 9, 9 ); |
165 | 167 | ||
166 | QCopChannel *channel = new QCopChannel("QPE/System", this); | 168 | QCopChannel *channel = new QCopChannel("QPE/System", this); |
167 | connect(channel, SIGNAL(received(const QCString &, const QByteArray &)), | 169 | connect(channel, SIGNAL(received(const QCString &, const QByteArray &)), |
168 | this, SLOT(systemMsg(const QCString &, const QByteArray &)) ); | 170 | this, SLOT(systemMsg(const QCString &, const QByteArray &)) ); |
169 | 171 | ||
170 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); | 172 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); |
171 | connect( tbChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 173 | connect( tbChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
172 | this, SLOT(receiveTaskBar(const QCString&, const QByteArray&)) ); | 174 | this, SLOT(receiveTaskBar(const QCString&, const QByteArray&)) ); |
173 | 175 | ||
174 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); | 176 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); |
175 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); | 177 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); |
176 | 178 | ||
177 | preloadApps(); | 179 | preloadApps(); |
178 | } | 180 | } |
179 | 181 | ||
180 | void Server::show() | 182 | void Server::show() |
181 | { | 183 | { |
182 | ServerApplication::login(TRUE); | 184 | ServerApplication::login(TRUE); |
183 | QWidget::show(); | 185 | QWidget::show(); |
184 | } | 186 | } |
185 | 187 | ||
186 | Server::~Server() | 188 | Server::~Server() |
187 | { | 189 | { |
188 | serverGui->destroyGUI(); | 190 | serverGui->destroyGUI(); |
189 | delete docList; | 191 | delete docList; |
190 | delete qcopBridge; | 192 | delete qcopBridge; |
191 | delete transferServer; | 193 | delete transferServer; |
192 | delete serverGui; | 194 | delete serverGui; |
195 | #if 0 | ||
193 | delete tsmMonitor; | 196 | delete tsmMonitor; |
197 | #endif | ||
194 | } | 198 | } |
195 | 199 | ||
196 | static bool hasVisibleWindow(const QString& clientname, bool partial) | 200 | static bool hasVisibleWindow(const QString& clientname, bool partial) |
197 | { | 201 | { |
198 | #ifdef QWS | 202 | #ifdef QWS |
199 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 203 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
200 | QWSWindow* w; | 204 | QWSWindow* w; |
201 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 205 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
202 | if ( w->client()->identity() == clientname ) { | 206 | if ( w->client()->identity() == clientname ) { |
203 | if ( partial && !w->isFullyObscured() ) | 207 | if ( partial && !w->isFullyObscured() ) |
204 | return TRUE; | 208 | return TRUE; |
205 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { | 209 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { |
206 | # if QT_VERSION < 0x030000 | 210 | # if QT_VERSION < 0x030000 |
207 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, | 211 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, |
208 | QSize(qt_screen->width(),qt_screen->height()) ); | 212 | QSize(qt_screen->width(),qt_screen->height()) ); |
209 | # else | 213 | # else |
210 | QRect mwr = qt_maxWindowRect; | 214 | QRect mwr = qt_maxWindowRect; |
211 | # endif | 215 | # endif |
212 | if ( mwr.contains(w->requested().boundingRect()) ) | 216 | if ( mwr.contains(w->requested().boundingRect()) ) |
213 | return TRUE; | 217 | return TRUE; |
214 | } | 218 | } |
215 | } | 219 | } |
216 | } | 220 | } |
217 | #endif | 221 | #endif |
218 | return FALSE; | 222 | return FALSE; |
219 | } | 223 | } |
220 | 224 | ||
221 | void Server::activate(const DeviceButton* button, bool held) | 225 | void Server::activate(const Opie::ODeviceButton* button, bool held) |
222 | { | 226 | { |
223 | Global::terminateBuiltin("calibrate"); // No tr | 227 | Global::terminateBuiltin("calibrate"); // No tr |
224 | ServiceRequest sr; | 228 | Opie::OQCopMessage om; |
225 | if ( held ) { | 229 | if ( held ) { |
226 | sr = button->heldAction(); | 230 | om = button->heldAction(); |
227 | } else { | 231 | } else { |
228 | sr = button->pressedAction(); | 232 | om = button->pressedAction(); |
229 | } | 233 | } |
234 | |||
235 | if ( om.channel() != "ignore" ) | ||
236 | om.send(); | ||
237 | |||
230 | // A button with no action defined, will return a null ServiceRequest. Don't attempt | 238 | // A button with no action defined, will return a null ServiceRequest. Don't attempt |
231 | // to send/do anything with this as it will crash | 239 | // to send/do anything with this as it will crash |
240 | /* ### FIXME */ | ||
241 | #if 0 | ||
232 | if ( !sr.isNull() ) { | 242 | if ( !sr.isNull() ) { |
233 | QString app = sr.app(); | 243 | QString app = sr.app(); |
234 | bool vis = hasVisibleWindow(app, app != "qpe"); | 244 | bool vis = hasVisibleWindow(app, app != "qpe"); |
235 | if ( sr.message() == "raise()" && vis ) { | 245 | if ( sr.message() == "raise()" && vis ) { |
236 | sr.setMessage("nextView()"); | 246 | sr.setMessage("nextView()"); |
237 | } else { | 247 | } else { |
238 | // "back door" | 248 | // "back door" |
239 | sr << (int)vis; | 249 | sr << (int)vis; |
240 | } | 250 | } |
241 | 251 | ||
242 | sr.send(); | 252 | sr.send(); |
243 | } | 253 | } |
254 | #endif | ||
244 | } | 255 | } |
245 | 256 | ||
246 | 257 | ||
247 | #ifdef Q_WS_QWS | 258 | #ifdef Q_WS_QWS |
248 | 259 | ||
249 | 260 | ||
250 | typedef struct KeyOverride { | 261 | typedef struct KeyOverride { |
251 | ushort scan_code; | 262 | ushort scan_code; |
252 | QWSServer::KeyMap map; | 263 | QWSServer::KeyMap map; |
253 | }; | 264 | }; |
254 | 265 | ||
255 | 266 | ||
256 | static const KeyOverride jp109keys[] = { | 267 | static const KeyOverride jp109keys[] = { |
257 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, | 268 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, |
258 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, | 269 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, |
259 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, | 270 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, |
260 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, | 271 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, |
261 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, | 272 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, |
262 | { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } }, | 273 | { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } }, |
263 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, | 274 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, |
264 | { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } }, | 275 | { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } }, |
265 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, | 276 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, |
266 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } }, | 277 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } }, |
267 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, | 278 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, |
268 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, | 279 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, |
269 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } }, | 280 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } }, |
270 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, | 281 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, |
271 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } }, | 282 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } }, |
272 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, | 283 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, |
273 | { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } }, | 284 | { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } }, |
274 | { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } }, | 285 | { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } }, |
275 | { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } }, | 286 | { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } }, |
276 | { 0x00, { 0, 0xffff , 0xffff , 0xffff } } | 287 | { 0x00, { 0, 0xffff , 0xffff , 0xffff } } |
277 | }; | 288 | }; |
278 | 289 | ||
279 | bool Server::setKeyboardLayout( const QString &kb ) | 290 | bool Server::setKeyboardLayout( const QString &kb ) |
280 | { | 291 | { |
281 | //quick demo version that can be extended | 292 | //quick demo version that can be extended |
282 | 293 | ||
283 | QIntDict<QWSServer::KeyMap> *om = 0; | 294 | QIntDict<QWSServer::KeyMap> *om = 0; |
284 | if ( kb == "us101" ) { // No tr | 295 | if ( kb == "us101" ) { // No tr |
285 | om = 0; | 296 | om = 0; |
286 | } else if ( kb == "jp109" ) { | 297 | } else if ( kb == "jp109" ) { |
287 | om = new QIntDict<QWSServer::KeyMap>(37); | 298 | om = new QIntDict<QWSServer::KeyMap>(37); |
288 | const KeyOverride *k = jp109keys; | 299 | const KeyOverride *k = jp109keys; |
289 | while ( k->scan_code ) { | 300 | while ( k->scan_code ) { |
290 | om->insert( k->scan_code, &k->map ); | 301 | om->insert( k->scan_code, &k->map ); |
291 | k++; | 302 | k++; |
292 | } | 303 | } |
293 | } | 304 | } |
294 | QWSServer::setOverrideKeys( om ); | 305 | QWSServer::setOverrideKeys( om ); |
295 | 306 | ||
296 | return TRUE; | 307 | return TRUE; |
297 | } | 308 | } |
298 | 309 | ||
299 | #endif | 310 | #endif |
300 | 311 | ||
301 | void Server::systemMsg(const QCString &msg, const QByteArray &data) | 312 | void Server::systemMsg(const QCString &msg, const QByteArray &data) |
302 | { | 313 | { |
303 | QDataStream stream( data, IO_ReadOnly ); | 314 | QDataStream stream( data, IO_ReadOnly ); |
304 | 315 | ||
305 | if ( msg == "securityChanged()" ) { | 316 | if ( msg == "securityChanged()" ) { |
306 | if ( transferServer ) | 317 | if ( transferServer ) |
307 | transferServer->authorizeConnections(); | 318 | transferServer->authorizeConnections(); |
308 | if ( qcopBridge ) | 319 | if ( qcopBridge ) |
309 | qcopBridge->authorizeConnections(); | 320 | qcopBridge->authorizeConnections(); |
310 | } else if ( msg == "setTempScreenSaverMode(int,int)" ) { | 321 | } |
322 | /* ### FIXME support TempScreenSaverMode */ | ||
323 | #if 0 | ||
324 | else if ( msg == "setTempScreenSaverMode(int,int)" ) { | ||
311 | int mode, pid; | 325 | int mode, pid; |
312 | stream >> mode >> pid; | 326 | stream >> mode >> pid; |
313 | tsmMonitor->setTempMode(mode, pid); | 327 | tsmMonitor->setTempMode(mode, pid); |
314 | } else if ( msg == "linkChanged(QString)" ) { | 328 | } |
329 | #endif | ||
330 | else if ( msg == "linkChanged(QString)" ) { | ||
315 | QString link; | 331 | QString link; |
316 | stream >> link; | 332 | stream >> link; |
317 | qDebug( "desktop.cpp systemMsg -> linkchanged( %s )", link.latin1() ); | 333 | qDebug( "desktop.cpp systemMsg -> linkchanged( %s )", link.latin1() ); |
318 | docList->linkChanged(link); | 334 | docList->linkChanged(link); |
319 | } else if ( msg == "serviceChanged(QString)" ) { | 335 | } else if ( msg == "serviceChanged(QString)" ) { |
320 | MimeType::updateApplications(); | 336 | MimeType::updateApplications(); |
321 | } else if ( msg == "mkdir(QString)" ) { | 337 | } else if ( msg == "mkdir(QString)" ) { |
322 | QString dir; | 338 | QString dir; |
323 | stream >> dir; | 339 | stream >> dir; |
324 | if ( !dir.isEmpty() ) | 340 | if ( !dir.isEmpty() ) |
325 | mkdir( dir ); | 341 | mkdir( dir ); |
326 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 342 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
327 | QString baseFile, sigFile; | 343 | QString baseFile, sigFile; |
328 | stream >> baseFile >> sigFile; | 344 | stream >> baseFile >> sigFile; |
329 | QRsync::generateSignature( baseFile, sigFile ); | 345 | QRsync::generateSignature( baseFile, sigFile ); |
330 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 346 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
331 | QString baseFile, sigFile, deltaFile; | 347 | QString baseFile, sigFile, deltaFile; |
332 | stream >> baseFile >> sigFile >> deltaFile; | 348 | stream >> baseFile >> sigFile >> deltaFile; |
333 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 349 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
334 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 350 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
335 | QString baseFile, deltaFile; | 351 | QString baseFile, deltaFile; |
336 | stream >> baseFile >> deltaFile; | 352 | stream >> baseFile >> deltaFile; |
337 | if ( !QFile::exists( baseFile ) ) { | 353 | if ( !QFile::exists( baseFile ) ) { |
338 | QFile f( baseFile ); | 354 | QFile f( baseFile ); |
339 | f.open( IO_WriteOnly ); | 355 | f.open( IO_WriteOnly ); |
340 | f.close(); | 356 | f.close(); |
341 | } | 357 | } |
342 | QRsync::applyDiff( baseFile, deltaFile ); | 358 | QRsync::applyDiff( baseFile, deltaFile ); |
343 | #ifndef QT_NO_COP | 359 | #ifndef QT_NO_COP |
344 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 360 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
345 | e << baseFile; | 361 | e << baseFile; |
346 | #endif | 362 | #endif |
347 | } else if ( msg == "rdiffCleanup()" ) { | 363 | } else if ( msg == "rdiffCleanup()" ) { |
348 | mkdir( "/tmp/rdiff" ); | 364 | mkdir( "/tmp/rdiff" ); |
349 | QDir dir; | 365 | QDir dir; |
350 | dir.setPath( "/tmp/rdiff" ); | 366 | dir.setPath( "/tmp/rdiff" ); |
351 | QStringList entries = dir.entryList(); | 367 | QStringList entries = dir.entryList(); |
352 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 368 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
353 | dir.remove( *it ); | 369 | dir.remove( *it ); |
354 | } else if ( msg == "sendHandshakeInfo()" ) { | 370 | } else if ( msg == "sendHandshakeInfo()" ) { |
355 | QString home = getenv( "HOME" ); | 371 | QString home = getenv( "HOME" ); |
356 | #ifndef QT_NO_COP | 372 | #ifndef QT_NO_COP |
357 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 373 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
358 | e << home; | 374 | e << home; |
359 | int locked = (int) ServerApplication::screenLocked(); | 375 | int locked = (int) ServerApplication::screenLocked(); |
360 | e << locked; | 376 | e << locked; |
361 | #endif | 377 | #endif |
362 | 378 | ||
363 | } else if ( msg == "sendVersionInfo()" ) { | 379 | } |
380 | /* | ||
381 | * QtopiaDesktop relies on the major number | ||
382 | * to start with 1. We're at 0.9 | ||
383 | * so wee need to fake at least 1.4 to be able | ||
384 | * to sync with QtopiaDesktop1.6 | ||
385 | */ | ||
386 | else if ( msg == "sendVersionInfo()" ) { | ||
364 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); | 387 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); |
365 | QString v = QPE_VERSION; | 388 | /* ### FIXME Architecture ### */ |
366 | e << Global::version() << Global::architecture(); | 389 | e << QString::fromLatin1("1.7") << "Uncustomized Device"; |
367 | } else if ( msg == "sendCardInfo()" ) { | 390 | } else if ( msg == "sendCardInfo()" ) { |
368 | #ifndef QT_NO_COP | 391 | #ifndef QT_NO_COP |
369 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 392 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
370 | #endif | 393 | #endif |
371 | storage->update(); | 394 | storage->update(); |
372 | const QList<FileSystem> &fs = storage->fileSystems(); | 395 | const QList<FileSystem> &fs = storage->fileSystems(); |
373 | QListIterator<FileSystem> it ( fs ); | 396 | QListIterator<FileSystem> it ( fs ); |
374 | QString s; | 397 | QString s; |
375 | QString homeDir = getenv("HOME"); | 398 | QString homeDir = getenv("HOME"); |
376 | QString homeFs, homeFsPath; | 399 | QString homeFs, homeFsPath; |
377 | for ( ; it.current(); ++it ) { | 400 | for ( ; it.current(); ++it ) { |
378 | int k4 = (*it)->blockSize()/256; | 401 | int k4 = (*it)->blockSize()/256; |
379 | if ( (*it)->isRemovable() ) { | 402 | if ( (*it)->isRemovable() ) { |
380 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr | 403 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr |
381 | + QString::number( (*it)->availBlocks() * k4/4 ) | 404 | + QString::number( (*it)->availBlocks() * k4/4 ) |
382 | + "K " + (*it)->options() + ";"; | 405 | + "K " + (*it)->options() + ";"; |
383 | } else if ( homeDir.contains( (*it)->path() ) && | 406 | } else if ( homeDir.contains( (*it)->path() ) && |
384 | (*it)->path().length() > homeFsPath.length() ) { | 407 | (*it)->path().length() > homeFsPath.length() ) { |
385 | homeFsPath = (*it)->path(); | 408 | homeFsPath = (*it)->path(); |
386 | homeFs = | 409 | homeFs = |
387 | (*it)->name() + "=" + homeDir + "/Documents " // No tr | 410 | (*it)->name() + "=" + homeDir + "/Documents " // No tr |
388 | + QString::number( (*it)->availBlocks() * k4/4 ) | 411 | + QString::number( (*it)->availBlocks() * k4/4 ) |
389 | + "K " + (*it)->options() + ";"; | 412 | + "K " + (*it)->options() + ";"; |
390 | } | 413 | } |
391 | } | 414 | } |
392 | if ( !homeFs.isEmpty() ) | 415 | if ( !homeFs.isEmpty() ) |
393 | s += homeFs; | 416 | s += homeFs; |
394 | 417 | ||
395 | #ifndef QT_NO_COP | 418 | #ifndef QT_NO_COP |
396 | e << s; | 419 | e << s; |
397 | #endif | 420 | #endif |
398 | } else if ( msg == "sendSyncDate(QString)" ) { | 421 | } else if ( msg == "sendSyncDate(QString)" ) { |
399 | QString app; | 422 | QString app; |
400 | stream >> app; | 423 | stream >> app; |
401 | Config cfg( "qpe" ); | 424 | Config cfg( "qpe" ); |
402 | cfg.setGroup("SyncDate"); | 425 | cfg.setGroup("SyncDate"); |
403 | #ifndef QT_NO_COP | 426 | #ifndef QT_NO_COP |
404 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 427 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
405 | e << app << cfg.readEntry( app ); | 428 | e << app << cfg.readEntry( app ); |
406 | #endif | 429 | #endif |
407 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 430 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
408 | //cfg.readEntry( app ).latin1() ); | 431 | //cfg.readEntry( app ).latin1() ); |
409 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 432 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
410 | QString app, date; | 433 | QString app, date; |
411 | stream >> app >> date; | 434 | stream >> app >> date; |
412 | Config cfg( "qpe" ); | 435 | Config cfg( "qpe" ); |
413 | cfg.setGroup("SyncDate"); | 436 | cfg.setGroup("SyncDate"); |
414 | cfg.writeEntry( app, date ); | 437 | cfg.writeEntry( app, date ); |
415 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 438 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
416 | } else if ( msg == "startSync(QString)" ) { | 439 | } else if ( msg == "startSync(QString)" ) { |
417 | QString what; | 440 | QString what; |
418 | stream >> what; | 441 | stream >> what; |
419 | delete syncDialog; | 442 | delete syncDialog; |
420 | syncDialog = new SyncDialog( this, what ); | 443 | syncDialog = new SyncDialog( this, what ); |
421 | syncDialog->show(); | 444 | syncDialog->show(); |
422 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); | 445 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); |
423 | } else if ( msg == "stopSync()") { | 446 | } else if ( msg == "stopSync()") { |
424 | delete syncDialog; | 447 | delete syncDialog; |
425 | syncDialog = 0; | 448 | syncDialog = 0; |
426 | } else if (msg == "restoreDone(QString)") { | 449 | } else if (msg == "restoreDone(QString)") { |
427 | docList->restoreDone(); | 450 | docList->restoreDone(); |
428 | } else if ( msg == "getAllDocLinks()" ) { | 451 | } else if ( msg == "getAllDocLinks()" ) { |
429 | docList->sendAllDocLinks(); | 452 | docList->sendAllDocLinks(); |
430 | } | 453 | } |
431 | #ifdef Q_WS_QWS | 454 | #ifdef Q_WS_QWS |
432 | else if ( msg == "setMouseProto(QString)" ) { | 455 | else if ( msg == "setMouseProto(QString)" ) { |
433 | QString mice; | 456 | QString mice; |
434 | stream >> mice; | 457 | stream >> mice; |
435 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 458 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
436 | qwsServer->openMouse(); | 459 | qwsServer->openMouse(); |
437 | } else if ( msg == "setKeyboard(QString)" ) { | 460 | } else if ( msg == "setKeyboard(QString)" ) { |
438 | QString kb; | 461 | QString kb; |
439 | stream >> kb; | 462 | stream >> kb; |
440 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 463 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
441 | qwsServer->openKeyboard(); | 464 | qwsServer->openKeyboard(); |
442 | 465 | ||
443 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { | 466 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { |
444 | int delay, period; | 467 | int delay, period; |
445 | stream >> delay >> period; | 468 | stream >> delay >> period; |
446 | qwsSetKeyboardAutoRepeat( delay, period ); | 469 | qwsSetKeyboardAutoRepeat( delay, period ); |
447 | Config cfg( "qpe" ); | 470 | Config cfg( "qpe" ); |
448 | cfg.setGroup("Keyboard"); | 471 | cfg.setGroup("Keyboard"); |
449 | cfg.writeEntry( "RepeatDelay", delay ); | 472 | cfg.writeEntry( "RepeatDelay", delay ); |
450 | cfg.writeEntry( "RepeatPeriod", period ); | 473 | cfg.writeEntry( "RepeatPeriod", period ); |
451 | } else if ( msg == "setKeyboardLayout(QString)" ) { | 474 | } else if ( msg == "setKeyboardLayout(QString)" ) { |
452 | QString kb; | 475 | QString kb; |
453 | stream >> kb; | 476 | stream >> kb; |
454 | setKeyboardLayout( kb ); | 477 | setKeyboardLayout( kb ); |
455 | Config cfg( "qpe" ); | 478 | Config cfg( "qpe" ); |
456 | cfg.setGroup("Keyboard"); | 479 | cfg.setGroup("Keyboard"); |
457 | cfg.writeEntry( "Layout", kb ); | 480 | cfg.writeEntry( "Layout", kb ); |
481 | } else if ( msg == "autoStart(QString)" ) { | ||
482 | QString appName; | ||
483 | stream >> appName; | ||
484 | Config cfg( "autostart" ); | ||
485 | cfg.setGroup( "AutoStart" ); | ||
486 | if ( appName.compare("clear") == 0){ | ||
487 | cfg.writeEntry("Apps", ""); | ||
488 | } | ||
489 | } else if ( msg == "autoStart(QString,QString)" ) { | ||
490 | QString modifier, appName; | ||
491 | stream >> modifier >> appName; | ||
492 | Config cfg( "autostart" ); | ||
493 | cfg.setGroup( "AutoStart" ); | ||
494 | if ( modifier.compare("add") == 0 ){ | ||
495 | // only add if appname is entered | ||
496 | if (!appName.isEmpty()) { | ||
497 | cfg.writeEntry("Apps", appName); | ||
498 | } | ||
499 | } else if (modifier.compare("remove") == 0 ) { | ||
500 | // need to change for multiple entries | ||
501 | // actually remove is right now simular to clear, but in future there | ||
502 | // should be multiple apps in autostart possible. | ||
503 | QString checkName; | ||
504 | checkName = cfg.readEntry("Apps", ""); | ||
505 | if (checkName == appName) { | ||
506 | cfg.writeEntry("Apps", ""); | ||
507 | } | ||
508 | } | ||
509 | // case the autostart feature should be delayed | ||
510 | } else if ( msg == "autoStart(QString,QString,QString)") { | ||
511 | QString modifier, appName, delay; | ||
512 | stream >> modifier >> appName >> delay; | ||
513 | Config cfg( "autostart" ); | ||
514 | |||
515 | cfg.setGroup( "AutoStart" ); | ||
516 | if ( modifier.compare("add") == 0 ){ | ||
517 | // only add it appname is entered | ||
518 | if (!appName.isEmpty()) { | ||
519 | cfg.writeEntry("Apps", appName); | ||
520 | cfg.writeEntry("Delay", delay); | ||
521 | } | ||
522 | } else { | ||
523 | } | ||
458 | } | 524 | } |
459 | #endif | 525 | #endif |
460 | } | 526 | } |
461 | 527 | ||
462 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) | 528 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) |
463 | { | 529 | { |
464 | QDataStream stream( data, IO_ReadOnly ); | 530 | QDataStream stream( data, IO_ReadOnly ); |
465 | 531 | ||
466 | if ( msg == "reloadApps()" ) { | 532 | if ( msg == "reloadApps()" ) { |
467 | docList->reloadAppLnks(); | 533 | docList->reloadAppLnks(); |
468 | } else if ( msg == "soundAlarm()" ) { | 534 | } else if ( msg == "soundAlarm()" ) { |
469 | soundAlarm(); | 535 | ServerApplication::soundAlarm(); |
470 | } | 536 | } |
471 | #ifdef CUSTOM_LEDS | ||
472 | else if ( msg == "setLed(int,bool)" ) { | 537 | else if ( msg == "setLed(int,bool)" ) { |
473 | int led, status; | 538 | int led, status; |
474 | stream >> led >> status; | 539 | stream >> led >> status; |
475 | CUSTOM_LEDS( led, status ); | 540 | |
541 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); | ||
542 | if ( ll. count ( )){ | ||
543 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; | ||
544 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); | ||
545 | |||
546 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); | ||
547 | } | ||
476 | } | 548 | } |
477 | #endif | ||
478 | } | 549 | } |
479 | 550 | ||
480 | void Server::cancelSync() | 551 | void Server::cancelSync() |
481 | { | 552 | { |
482 | #ifndef QT_NO_COP | 553 | #ifndef QT_NO_COP |
483 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 554 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
484 | #endif | 555 | #endif |
485 | delete syncDialog; | 556 | delete syncDialog; |
486 | syncDialog = 0; | 557 | syncDialog = 0; |
487 | } | 558 | } |
488 | 559 | ||
489 | bool Server::mkdir(const QString &localPath) | 560 | bool Server::mkdir(const QString &localPath) |
490 | { | 561 | { |
491 | QDir fullDir(localPath); | 562 | QDir fullDir(localPath); |
492 | if (fullDir.exists()) | 563 | if (fullDir.exists()) |
493 | return true; | 564 | return true; |
494 | 565 | ||
495 | // at this point the directory doesn't exist | 566 | // at this point the directory doesn't exist |
496 | // go through the directory tree and start creating the direcotories | 567 | // go through the directory tree and start creating the direcotories |
497 | // that don't exist; if we can't create the directories, return false | 568 | // that don't exist; if we can't create the directories, return false |
498 | 569 | ||
499 | QString dirSeps = "/"; | 570 | QString dirSeps = "/"; |
500 | int dirIndex = localPath.find(dirSeps); | 571 | int dirIndex = localPath.find(dirSeps); |
501 | QString checkedPath; | 572 | QString checkedPath; |
502 | 573 | ||
503 | // didn't find any seps; weird, use the cur dir instead | 574 | // didn't find any seps; weird, use the cur dir instead |
504 | if (dirIndex == -1) { | 575 | if (dirIndex == -1) { |
505 | //qDebug("No seperators found in path %s", localPath.latin1()); | 576 | //qDebug("No seperators found in path %s", localPath.latin1()); |
506 | checkedPath = QDir::currentDirPath(); | 577 | checkedPath = QDir::currentDirPath(); |
507 | } | 578 | } |
508 | 579 | ||
509 | while (checkedPath != localPath) { | 580 | while (checkedPath != localPath) { |
510 | // no more seperators found, use the local path | 581 | // no more seperators found, use the local path |
511 | if (dirIndex == -1) | 582 | if (dirIndex == -1) |
512 | checkedPath = localPath; | 583 | checkedPath = localPath; |
513 | else { | 584 | else { |
514 | // the next directory to check | 585 | // the next directory to check |
515 | checkedPath = localPath.left(dirIndex) + "/"; | 586 | checkedPath = localPath.left(dirIndex) + "/"; |
516 | // advance the iterator; the next dir seperator | 587 | // advance the iterator; the next dir seperator |
517 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 588 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
518 | } | 589 | } |
519 | 590 | ||
520 | QDir checkDir(checkedPath); | 591 | QDir checkDir(checkedPath); |
521 | if (!checkDir.exists()) { | 592 | if (!checkDir.exists()) { |
522 | //qDebug("mkdir making dir %s", checkedPath.latin1()); | 593 | //qDebug("mkdir making dir %s", checkedPath.latin1()); |
523 | 594 | ||
524 | if (!checkDir.mkdir(checkedPath)) { | 595 | if (!checkDir.mkdir(checkedPath)) { |
525 | qDebug("Unable to make directory %s", checkedPath.latin1()); | 596 | qDebug("Unable to make directory %s", checkedPath.latin1()); |
526 | return FALSE; | 597 | return FALSE; |
527 | } | 598 | } |
528 | } | 599 | } |
529 | 600 | ||
530 | } | 601 | } |
531 | return TRUE; | 602 | return TRUE; |
532 | } | 603 | } |
533 | 604 | ||
534 | void Server::styleChange( QStyle &s ) | 605 | void Server::styleChange( QStyle &s ) |
535 | { | 606 | { |
536 | QWidget::styleChange( s ); | 607 | QWidget::styleChange( s ); |
537 | } | 608 | } |
538 | 609 | ||
539 | void Server::startTransferServer() | 610 | void Server::startTransferServer() |
540 | { | 611 | { |
541 | if ( !qcopBridge ) { | 612 | if ( !qcopBridge ) { |
542 | // start qcop bridge server | 613 | // start qcop bridge server |
543 | qcopBridge = new QCopBridge( 4243 ); | 614 | qcopBridge = new QCopBridge( 4243 ); |
544 | if ( qcopBridge->ok() ) { | 615 | if ( qcopBridge->ok() ) { |
545 | // ... OK | 616 | // ... OK |
546 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress &)), | 617 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress &)), |
547 | this, SLOT(syncConnectionClosed(const QHostAddress &)) ); | 618 | this, SLOT(syncConnectionClosed(const QHostAddress &)) ); |
548 | } else { | 619 | } else { |
549 | delete qcopBridge; | 620 | delete qcopBridge; |
550 | qcopBridge = 0; | 621 | qcopBridge = 0; |
551 | } | 622 | } |
552 | } | 623 | } |
553 | if ( !transferServer ) { | 624 | if ( !transferServer ) { |
554 | // start transfer server | 625 | // start transfer server |
555 | transferServer = new TransferServer( 4242 ); | 626 | transferServer = new TransferServer( 4242 ); |
556 | if ( transferServer->ok() ) { | 627 | if ( transferServer->ok() ) { |
557 | // ... OK | 628 | // ... OK |
558 | } else { | 629 | } else { |
559 | delete transferServer; | 630 | delete transferServer; |
560 | transferServer = 0; | 631 | transferServer = 0; |
561 | } | 632 | } |
562 | } | 633 | } |
563 | if ( !transferServer || !qcopBridge ) | 634 | if ( !transferServer || !qcopBridge ) |
564 | tid_xfer = startTimer( 2000 ); | 635 | tid_xfer = startTimer( 2000 ); |
565 | } | 636 | } |
566 | 637 | ||
567 | void Server::timerEvent( QTimerEvent *e ) | 638 | void Server::timerEvent( QTimerEvent *e ) |
568 | { | 639 | { |
569 | if ( e->timerId() == tid_xfer ) { | 640 | if ( e->timerId() == tid_xfer ) { |
570 | killTimer( tid_xfer ); | 641 | killTimer( tid_xfer ); |
571 | tid_xfer = 0; | 642 | tid_xfer = 0; |
572 | startTransferServer(); | 643 | startTransferServer(); |
573 | } else if ( e->timerId() == tid_today ) { | 644 | } |
645 | /* ### FIXME today startin */ | ||
646 | #if 0 | ||
647 | else if ( e->timerId() == tid_today ) { | ||
574 | QDate today = QDate::currentDate(); | 648 | QDate today = QDate::currentDate(); |
575 | if ( today != last_today_show ) { | 649 | if ( today != last_today_show ) { |
576 | last_today_show = today; | 650 | last_today_show = today; |
577 | Config cfg("today"); | 651 | Config cfg("today"); |
578 | cfg.setGroup("Start"); | 652 | cfg.setGroup("Start"); |
579 | #ifndef QPE_DEFAULT_TODAY_MODE | 653 | #ifndef QPE_DEFAULT_TODAY_MODE |
580 | #define QPE_DEFAULT_TODAY_MODE "Never" | 654 | #define QPE_DEFAULT_TODAY_MODE "Never" |
581 | #endif | 655 | #endif |
582 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { | 656 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { |
583 | QCopEnvelope env(Service::channel("today"),"raise()"); | 657 | QCopEnvelope env(Service::channel("today"),"raise()"); |
584 | } | 658 | } |
585 | } | 659 | } |
586 | } | 660 | } |
661 | #endif | ||
587 | } | 662 | } |
588 | 663 | ||
589 | void Server::terminateServers() | 664 | void Server::terminateServers() |
590 | { | 665 | { |
591 | delete transferServer; | 666 | delete transferServer; |
592 | delete qcopBridge; | 667 | delete qcopBridge; |
593 | transferServer = 0; | 668 | transferServer = 0; |
594 | qcopBridge = 0; | 669 | qcopBridge = 0; |
595 | } | 670 | } |
596 | 671 | ||
597 | void Server::syncConnectionClosed( const QHostAddress & ) | 672 | void Server::syncConnectionClosed( const QHostAddress & ) |
598 | { | 673 | { |
599 | qDebug( "Lost sync connection" ); | 674 | qDebug( "Lost sync connection" ); |
600 | delete syncDialog; | 675 | delete syncDialog; |
601 | syncDialog = 0; | 676 | syncDialog = 0; |
602 | } | 677 | } |
603 | 678 | ||
604 | void Server::pokeTimeMonitors() | 679 | void Server::pokeTimeMonitors() |
605 | { | 680 | { |
681 | #if 0 | ||
606 | // inform all TimeMonitors | 682 | // inform all TimeMonitors |
607 | QStrList tms = Service::channels("TimeMonitor"); | 683 | QStrList tms = Service::channels("TimeMonitor"); |
608 | for (const char* ch = tms.first(); ch; ch=tms.next()) { | 684 | for (const char* ch = tms.first(); ch; ch=tms.next()) { |
609 | QString t = getenv("TZ"); | 685 | QString t = getenv("TZ"); |
610 | QCopEnvelope e(ch, "timeChange(QString)"); | 686 | QCopEnvelope e(ch, "timeChange(QString)"); |
611 | e << t; | 687 | e << t; |
612 | } | 688 | } |
689 | #endif | ||
613 | } | 690 | } |
614 | 691 | ||
615 | void Server::applicationLaunched(int, const QString &app) | 692 | void Server::applicationLaunched(int, const QString &app) |
616 | { | 693 | { |
617 | serverGui->applicationStateChanged( app, ServerInterface::Launching ); | 694 | serverGui->applicationStateChanged( app, ServerInterface::Launching ); |
618 | } | 695 | } |
619 | 696 | ||
620 | void Server::applicationTerminated(int pid, const QString &app) | 697 | void Server::applicationTerminated(int pid, const QString &app) |
621 | { | 698 | { |
622 | serverGui->applicationStateChanged( app, ServerInterface::Terminated ); | 699 | serverGui->applicationStateChanged( app, ServerInterface::Terminated ); |
700 | #if 0 | ||
623 | tsmMonitor->applicationTerminated( pid ); | 701 | tsmMonitor->applicationTerminated( pid ); |
702 | #endif | ||
624 | } | 703 | } |
625 | 704 | ||
626 | void Server::applicationConnected(const QString &app) | 705 | void Server::applicationConnected(const QString &app) |
627 | { | 706 | { |
628 | serverGui->applicationStateChanged( app, ServerInterface::Running ); | 707 | serverGui->applicationStateChanged( app, ServerInterface::Running ); |
629 | } | 708 | } |
630 | 709 | ||
631 | void Server::storageChanged() | 710 | void Server::storageChanged() |
632 | { | 711 | { |
633 | system( "qtopia-update-symlinks" ); | 712 | system( "qtopia-update-symlinks" ); |
634 | serverGui->storageChanged( storage->fileSystems() ); | 713 | serverGui->storageChanged( storage->fileSystems() ); |
635 | docList->storageChanged(); | 714 | docList->storageChanged(); |
636 | } | 715 | } |
637 | 716 | ||
638 | 717 | ||
639 | void Server::soundAlarm() | ||
640 | { | ||
641 | #ifdef CUSTOM_SOUND_ALARM | ||
642 | CUSTOM_SOUND_ALARM; | ||
643 | #endif | ||
644 | } | ||
645 | 718 | ||
646 | void Server::preloadApps() | 719 | void Server::preloadApps() |
647 | { | 720 | { |
648 | Config cfg("Launcher"); | 721 | Config cfg("Launcher"); |
649 | cfg.setGroup("Preload"); | 722 | cfg.setGroup("Preload"); |
650 | QStringList apps = cfg.readListEntry("Apps",','); | 723 | QStringList apps = cfg.readListEntry("Apps",','); |
651 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 724 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
652 | #ifndef QT_NO_COP | 725 | #ifndef QT_NO_COP |
653 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 726 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
654 | #endif | 727 | #endif |
655 | } | 728 | } |
656 | } | 729 | } |
657 | 730 | ||
diff --git a/core/launcher/server.h b/core/launcher/server.h index 21b03af..91bf883 100644 --- a/core/launcher/server.h +++ b/core/launcher/server.h | |||
@@ -1,94 +1,97 @@ | |||
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 DeviceButton; | ||
33 | class ServiceRequest; | 32 | class ServiceRequest; |
34 | class TempScreenSaverMonitor; | 33 | class TempScreenSaverMonitor; |
35 | class AppLauncher; | 34 | class AppLauncher; |
36 | class AppLnkSet; | 35 | class AppLnkSet; |
37 | class StorageInfo; | 36 | class StorageInfo; |
38 | class SyncDialog; | 37 | class SyncDialog; |
39 | class DocumentList; | 38 | class DocumentList; |
40 | class ServerInterface; | 39 | class ServerInterface; |
40 | namespace Opie { | ||
41 | class ODeviceButton; | ||
42 | } | ||
41 | 43 | ||
42 | class Server : public QWidget { | 44 | class Server : public QWidget { |
43 | Q_OBJECT | 45 | Q_OBJECT |
44 | public: | 46 | public: |
45 | Server(); | 47 | Server(); |
46 | ~Server(); | 48 | ~Server(); |
47 | 49 | ||
48 | static bool mkdir(const QString &path); | 50 | static bool mkdir(const QString &path); |
49 | 51 | ||
50 | void show(); | 52 | void show(); |
51 | 53 | ||
52 | static void soundAlarm(); | ||
53 | static bool setKeyboardLayout( const QString &kb ); | 54 | static bool setKeyboardLayout( const QString &kb ); |
54 | 55 | ||
55 | public slots: | 56 | public slots: |
56 | void systemMsg(const QCString &, const QByteArray &); | 57 | void systemMsg(const QCString &, const QByteArray &); |
57 | void receiveTaskBar(const QCString &msg, const QByteArray &data); | 58 | void receiveTaskBar(const QCString &msg, const QByteArray &data); |
58 | void terminateServers(); | 59 | void terminateServers(); |
59 | void pokeTimeMonitors(); | 60 | void pokeTimeMonitors(); |
60 | 61 | ||
61 | private slots: | 62 | private slots: |
62 | void activate(const DeviceButton*,bool); | 63 | void activate(const Opie::ODeviceButton*,bool); |
63 | void syncConnectionClosed( const QHostAddress & ); | 64 | void syncConnectionClosed( const QHostAddress & ); |
64 | void applicationLaunched(int pid, const QString &app); | 65 | void applicationLaunched(int pid, const QString &app); |
65 | void applicationTerminated(int pid, const QString &app); | 66 | void applicationTerminated(int pid, const QString &app); |
66 | void applicationConnected(const QString &app); | 67 | void applicationConnected(const QString &app); |
67 | void storageChanged(); | 68 | void storageChanged(); |
68 | void cancelSync(); | 69 | void cancelSync(); |
69 | 70 | ||
70 | protected: | 71 | protected: |
71 | void styleChange( QStyle & ); | 72 | void styleChange( QStyle & ); |
72 | void timerEvent( QTimerEvent *e ); | 73 | void timerEvent( QTimerEvent *e ); |
73 | 74 | ||
74 | private: | 75 | private: |
76 | void layout(); | ||
75 | void startTransferServer(); | 77 | void startTransferServer(); |
76 | void preloadApps(); | 78 | void preloadApps(); |
77 | 79 | ||
78 | QCopBridge *qcopBridge; | 80 | QCopBridge *qcopBridge; |
79 | TransferServer *transferServer; | 81 | TransferServer *transferServer; |
80 | PackageHandler *packageHandler; | 82 | PackageHandler *packageHandler; |
81 | QDate last_today_show; | 83 | QDate last_today_show; |
82 | int tid_xfer; | 84 | int tid_xfer; |
83 | int tid_today; | 85 | /* ### FIXME two below### */ |
84 | TempScreenSaverMonitor *tsmMonitor; | 86 | // int tid_today; |
87 | // TempScreenSaverMonitor *tsmMonitor; | ||
85 | StorageInfo *storage; | 88 | StorageInfo *storage; |
86 | SyncDialog *syncDialog; | 89 | SyncDialog *syncDialog; |
87 | AppLauncher *appLauncher; | 90 | AppLauncher *appLauncher; |
88 | DocumentList *docList; | 91 | DocumentList *docList; |
89 | ServerInterface *serverGui; | 92 | ServerInterface *serverGui; |
90 | }; | 93 | }; |
91 | 94 | ||
92 | 95 | ||
93 | #endif // DESKTOP_H | 96 | #endif // DESKTOP_H |
94 | 97 | ||