author | zecke <zecke> | 2003-10-07 12:51:21 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-10-07 12:51:21 (UTC) |
commit | c21de570e101058c5f1c4c5973a96df5a9bf62b2 (patch) (unidiff) | |
tree | 5b5b2b440990eac3757549745f7e467d23bde08f | |
parent | 37ddd7628c5406f05806b97471db72e2ee943d86 (diff) | |
download | opie-c21de570e101058c5f1c4c5973a96df5a9bf62b2.zip opie-c21de570e101058c5f1c4c5973a96df5a9bf62b2.tar.gz opie-c21de570e101058c5f1c4c5973a96df5a9bf62b2.tar.bz2 |
-Kill stupid define which sets QWS_SIZE to 240x320
-Include built-in shutdown only if OPIE_NO_BUILTIN_SHUTDOWN is defined
-rw-r--r-- | core/launcher/main.cpp | 2 | ||||
-rw-r--r-- | core/launcher/server.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index ad40536..74965df 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -1,354 +1,354 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #ifndef QTOPIA_INTERNAL_FILEOPERATIONS | 21 | #ifndef QTOPIA_INTERNAL_FILEOPERATIONS |
22 | #define QTOPIA_INTERNAL_FILEOPERATIONS | 22 | #define QTOPIA_INTERNAL_FILEOPERATIONS |
23 | #endif | 23 | #endif |
24 | #include "server.h" | 24 | #include "server.h" |
25 | #include "serverapp.h" | 25 | #include "serverapp.h" |
26 | #include "taskbar.h" | 26 | #include "taskbar.h" |
27 | #include "stabmon.h" | 27 | #include "stabmon.h" |
28 | #include "launcher.h" | 28 | #include "launcher.h" |
29 | #include "firstuse.h" | 29 | #include "firstuse.h" |
30 | #include "launcherglobal.h" | 30 | #include "launcherglobal.h" |
31 | 31 | ||
32 | #include <qtopia/qpeapplication.h> | 32 | #include <qtopia/qpeapplication.h> |
33 | #include <qtopia/network.h> | 33 | #include <qtopia/network.h> |
34 | #include <qtopia/config.h> | 34 | #include <qtopia/config.h> |
35 | #include <qtopia/custom.h> | 35 | #include <qtopia/custom.h> |
36 | #include <qtopia/global.h> | 36 | #include <qtopia/global.h> |
37 | 37 | ||
38 | #include <qfile.h> | 38 | #include <qfile.h> |
39 | #include <qdir.h> | 39 | #include <qdir.h> |
40 | #ifdef QWS | 40 | #ifdef QWS |
41 | #include <qwindowsystem_qws.h> | 41 | #include <qwindowsystem_qws.h> |
42 | #include <qtopia/qcopenvelope_qws.h> | 42 | #include <qtopia/qcopenvelope_qws.h> |
43 | #endif | 43 | #endif |
44 | #include <qtopia/alarmserver.h> | 44 | #include <qtopia/alarmserver.h> |
45 | 45 | ||
46 | #include <stdlib.h> | 46 | #include <stdlib.h> |
47 | #include <stdio.h> | 47 | #include <stdio.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #ifndef Q_OS_WIN32 | 49 | #ifndef Q_OS_WIN32 |
50 | #include <unistd.h> | 50 | #include <unistd.h> |
51 | #else | 51 | #else |
52 | #include <process.h> | 52 | #include <process.h> |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | #include "calibrate.h" | 55 | #include "calibrate.h" |
56 | 56 | ||
57 | 57 | ||
58 | #ifdef QT_QWS_LOGIN | 58 | #ifdef QT_QWS_LOGIN |
59 | #include "../login/qdmdialogimpl.h" | 59 | #include "../login/qdmdialogimpl.h" |
60 | #endif | 60 | #endif |
61 | 61 | ||
62 | #ifdef Q_WS_QWS | 62 | #ifdef Q_WS_QWS |
63 | #include <qkeyboard_qws.h> | 63 | #include <qkeyboard_qws.h> |
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | #include <qmessagebox.h> | 66 | #include <qmessagebox.h> |
67 | #include <opie/odevice.h> | 67 | #include <opie/odevice.h> |
68 | 68 | ||
69 | using namespace Opie; | 69 | using namespace Opie; |
70 | 70 | ||
71 | 71 | ||
72 | static void cleanup() | 72 | static void cleanup() |
73 | { | 73 | { |
74 | QDir dir( Opie::Global::tempDir(), "qcop-msg-*" ); | 74 | QDir dir( Opie::Global::tempDir(), "qcop-msg-*" ); |
75 | 75 | ||
76 | QStringList stale = dir.entryList(); | 76 | QStringList stale = dir.entryList(); |
77 | QStringList::Iterator it; | 77 | QStringList::Iterator it; |
78 | for ( it = stale.begin(); it != stale.end(); ++it ) { | 78 | for ( it = stale.begin(); it != stale.end(); ++it ) { |
79 | dir.remove( *it ); | 79 | dir.remove( *it ); |
80 | } | 80 | } |
81 | } | 81 | } |
82 | 82 | ||
83 | static void refreshTimeZoneConfig() | 83 | static void refreshTimeZoneConfig() |
84 | { | 84 | { |
85 | /* ### FIXME timezone handling */ | 85 | /* ### FIXME timezone handling */ |
86 | #if 0 | 86 | #if 0 |
87 | // We need to help WorldTime in setting up its configuration for | 87 | // We need to help WorldTime in setting up its configuration for |
88 | // the current translation | 88 | // the current translation |
89 | // BEGIN no tr | 89 | // BEGIN no tr |
90 | const char *defaultTz[] = { | 90 | const char *defaultTz[] = { |
91 | "America/New_York", | 91 | "America/New_York", |
92 | "America/Los_Angeles", | 92 | "America/Los_Angeles", |
93 | "Europe/Oslo", | 93 | "Europe/Oslo", |
94 | "Asia/Tokyo", | 94 | "Asia/Tokyo", |
95 | "Asia/Hong_Kong", | 95 | "Asia/Hong_Kong", |
96 | "Australia/Brisbane", | 96 | "Australia/Brisbane", |
97 | 0 | 97 | 0 |
98 | }; | 98 | }; |
99 | // END no tr | 99 | // END no tr |
100 | 100 | ||
101 | TimeZone curZone; | 101 | TimeZone curZone; |
102 | QString zoneID; | 102 | QString zoneID; |
103 | int zoneIndex; | 103 | int zoneIndex; |
104 | Config cfg = Config( "WorldTime" ); | 104 | Config cfg = Config( "WorldTime" ); |
105 | cfg.setGroup( "TimeZones" ); | 105 | cfg.setGroup( "TimeZones" ); |
106 | if (!cfg.hasKey( "Zone0" )){ | 106 | if (!cfg.hasKey( "Zone0" )){ |
107 | // We have no existing timezones use the defaults which are untranslated strings | 107 | // We have no existing timezones use the defaults which are untranslated strings |
108 | QString currTz = TimeZone::current().id(); | 108 | QString currTz = TimeZone::current().id(); |
109 | QStringList zoneDefaults; | 109 | QStringList zoneDefaults; |
110 | zoneDefaults.append( currTz ); | 110 | zoneDefaults.append( currTz ); |
111 | for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) { | 111 | for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) { |
112 | if ( defaultTz[i] != currTz ) | 112 | if ( defaultTz[i] != currTz ) |
113 | zoneDefaults.append( defaultTz[i] ); | 113 | zoneDefaults.append( defaultTz[i] ); |
114 | } | 114 | } |
115 | zoneIndex = 0; | 115 | zoneIndex = 0; |
116 | for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ | 116 | for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ |
117 | cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); | 117 | cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); |
118 | zoneIndex++; | 118 | zoneIndex++; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | // We have an existing list of timezones refresh the | 121 | // We have an existing list of timezones refresh the |
122 | // translations of TimeZone name | 122 | // translations of TimeZone name |
123 | zoneIndex = 0; | 123 | zoneIndex = 0; |
124 | while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ | 124 | while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ |
125 | zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); | 125 | zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); |
126 | curZone = TimeZone( zoneID ); | 126 | curZone = TimeZone( zoneID ); |
127 | if ( !curZone.isValid() ){ | 127 | if ( !curZone.isValid() ){ |
128 | qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() ); | 128 | qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() ); |
129 | break; | 129 | break; |
130 | } | 130 | } |
131 | cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); | 131 | cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); |
132 | zoneIndex++; | 132 | zoneIndex++; |
133 | } | 133 | } |
134 | #endif | 134 | #endif |
135 | } | 135 | } |
136 | 136 | ||
137 | void initEnvironment() | 137 | void initEnvironment() |
138 | { | 138 | { |
139 | #ifdef Q_OS_WIN32 | 139 | #ifdef Q_OS_WIN32 |
140 | // Config file requires HOME dir which uses QDir which needs the winver | 140 | // Config file requires HOME dir which uses QDir which needs the winver |
141 | qt_init_winver(); | 141 | qt_init_winver(); |
142 | #endif | 142 | #endif |
143 | Config config("locale"); | 143 | Config config("locale"); |
144 | config.setGroup( "Location" ); | 144 | config.setGroup( "Location" ); |
145 | QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); | 145 | QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); |
146 | 146 | ||
147 | // if not timezone set, pick New York | 147 | // if not timezone set, pick New York |
148 | if (tz.isNull() || tz.isEmpty()) | 148 | if (tz.isNull() || tz.isEmpty()) |
149 | tz = "America/New_York"; | 149 | tz = "America/New_York"; |
150 | 150 | ||
151 | setenv( "TZ", tz, 1 ); | 151 | setenv( "TZ", tz, 1 ); |
152 | config.writeEntry( "Timezone", tz); | 152 | config.writeEntry( "Timezone", tz); |
153 | 153 | ||
154 | config.setGroup( "Language" ); | 154 | config.setGroup( "Language" ); |
155 | QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); | 155 | QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); |
156 | if( lang.isNull() || lang.isEmpty()) | 156 | if( lang.isNull() || lang.isEmpty()) |
157 | lang = "en_US"; | 157 | lang = "en_US"; |
158 | 158 | ||
159 | setenv( "LANG", lang, 1 ); | 159 | setenv( "LANG", lang, 1 ); |
160 | config.writeEntry("Language", lang); | 160 | config.writeEntry("Language", lang); |
161 | config.write(); | 161 | config.write(); |
162 | 162 | ||
163 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_SL5XXX) | 163 | #if 0 |
164 | setenv( "QWS_SIZE", "240x320", 0 ); | 164 | setenv( "QWS_SIZE", "240x320", 0 ); |
165 | #endif | 165 | #endif |
166 | 166 | ||
167 | 167 | ||
168 | 168 | ||
169 | QString env(getenv("QWS_DISPLAY")); | 169 | QString env(getenv("QWS_DISPLAY")); |
170 | if (env.contains("Transformed")) { | 170 | if (env.contains("Transformed")) { |
171 | int rot; | 171 | int rot; |
172 | // transformed driver default rotation is controlled by the hardware. | 172 | // transformed driver default rotation is controlled by the hardware. |
173 | Config config("qpe"); | 173 | Config config("qpe"); |
174 | config.setGroup( "Rotation" ); | 174 | config.setGroup( "Rotation" ); |
175 | if ( ( rot = config.readNumEntry( "Rot", -1 ) ) == -1 ) | 175 | if ( ( rot = config.readNumEntry( "Rot", -1 ) ) == -1 ) |
176 | rot = ODevice::inst ( )-> rotation ( ) * 90; | 176 | rot = ODevice::inst ( )-> rotation ( ) * 90; |
177 | 177 | ||
178 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); | 178 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); |
179 | QPEApplication::defaultRotation ( ); /* to ensure deforient matches reality */ | 179 | QPEApplication::defaultRotation ( ); /* to ensure deforient matches reality */ |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | static void initKeyboard() | 183 | static void initKeyboard() |
184 | { | 184 | { |
185 | Config config("qpe"); | 185 | Config config("qpe"); |
186 | 186 | ||
187 | config.setGroup( "Keyboard" ); | 187 | config.setGroup( "Keyboard" ); |
188 | 188 | ||
189 | int ard = config.readNumEntry( "RepeatDelay" ); | 189 | int ard = config.readNumEntry( "RepeatDelay" ); |
190 | int arp = config.readNumEntry( "RepeatPeriod" ); | 190 | int arp = config.readNumEntry( "RepeatPeriod" ); |
191 | if ( ard > 0 && arp > 0 ) | 191 | if ( ard > 0 && arp > 0 ) |
192 | qwsSetKeyboardAutoRepeat( ard, arp ); | 192 | qwsSetKeyboardAutoRepeat( ard, arp ); |
193 | 193 | ||
194 | QString layout = config.readEntry( "Layout", "us101" ); | 194 | QString layout = config.readEntry( "Layout", "us101" ); |
195 | Server::setKeyboardLayout( layout ); | 195 | Server::setKeyboardLayout( layout ); |
196 | } | 196 | } |
197 | 197 | ||
198 | static bool firstUse() | 198 | static bool firstUse() |
199 | { | 199 | { |
200 | bool needFirstUse = FALSE; | 200 | bool needFirstUse = FALSE; |
201 | if ( QWSServer::mouseHandler() && | 201 | if ( QWSServer::mouseHandler() && |
202 | QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { | 202 | QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { |
203 | if ( !QFile::exists( "/etc/pointercal" ) ) | 203 | if ( !QFile::exists( "/etc/pointercal" ) ) |
204 | needFirstUse = TRUE; | 204 | needFirstUse = TRUE; |
205 | } | 205 | } |
206 | 206 | ||
207 | { | 207 | { |
208 | Config config( "qpe" ); | 208 | Config config( "qpe" ); |
209 | config.setGroup( "Startup" ); | 209 | config.setGroup( "Startup" ); |
210 | needFirstUse |= config.readBoolEntry( "FirstUse", TRUE ); | 210 | needFirstUse |= config.readBoolEntry( "FirstUse", TRUE ); |
211 | } | 211 | } |
212 | 212 | ||
213 | if ( !needFirstUse ) | 213 | if ( !needFirstUse ) |
214 | return FALSE; | 214 | return FALSE; |
215 | 215 | ||
216 | FirstUse *fu = new FirstUse(); | 216 | FirstUse *fu = new FirstUse(); |
217 | fu->exec(); | 217 | fu->exec(); |
218 | bool rs = fu->restartNeeded(); | 218 | bool rs = fu->restartNeeded(); |
219 | delete fu; | 219 | delete fu; |
220 | return rs; | 220 | return rs; |
221 | } | 221 | } |
222 | 222 | ||
223 | int initApplication( int argc, char ** argv ) | 223 | int initApplication( int argc, char ** argv ) |
224 | { | 224 | { |
225 | cleanup(); | 225 | cleanup(); |
226 | 226 | ||
227 | 227 | ||
228 | initEnvironment(); | 228 | initEnvironment(); |
229 | 229 | ||
230 | //Don't flicker at startup: | 230 | //Don't flicker at startup: |
231 | #ifdef QWS | 231 | #ifdef QWS |
232 | QWSServer::setDesktopBackground( QImage() ); | 232 | QWSServer::setDesktopBackground( QImage() ); |
233 | #endif | 233 | #endif |
234 | ServerApplication a( argc, argv, QApplication::GuiServer ); | 234 | ServerApplication a( argc, argv, QApplication::GuiServer ); |
235 | 235 | ||
236 | refreshTimeZoneConfig(); | 236 | refreshTimeZoneConfig(); |
237 | 237 | ||
238 | initKeyboard(); | 238 | initKeyboard(); |
239 | 239 | ||
240 | // Don't use first use under Windows | 240 | // Don't use first use under Windows |
241 | if ( firstUse() ) { | 241 | if ( firstUse() ) { |
242 | a.restart(); | 242 | a.restart(); |
243 | return 0; | 243 | return 0; |
244 | } | 244 | } |
245 | 245 | ||
246 | ODevice::inst ( )-> setSoftSuspend ( true ); | 246 | ODevice::inst ( )-> setSoftSuspend ( true ); |
247 | 247 | ||
248 | { | 248 | { |
249 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | 249 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); |
250 | e << -3; // Forced on | 250 | e << -3; // Forced on |
251 | } | 251 | } |
252 | 252 | ||
253 | AlarmServer::initialize(); | 253 | AlarmServer::initialize(); |
254 | 254 | ||
255 | 255 | ||
256 | 256 | ||
257 | Server *s = new Server(); | 257 | Server *s = new Server(); |
258 | 258 | ||
259 | (void)new SysFileMonitor(s); | 259 | (void)new SysFileMonitor(s); |
260 | #ifdef QWS | 260 | #ifdef QWS |
261 | Network::createServer(s); | 261 | Network::createServer(s); |
262 | #endif | 262 | #endif |
263 | 263 | ||
264 | s->show(); | 264 | s->show(); |
265 | 265 | ||
266 | /* THE ARM rtc has problem holdings the time on reset */ | 266 | /* THE ARM rtc has problem holdings the time on reset */ |
267 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { | 267 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { |
268 | if ( QMessageBox::information ( 0, ServerApplication::tr( "Information" ), ServerApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { | 268 | if ( QMessageBox::information ( 0, ServerApplication::tr( "Information" ), ServerApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { |
269 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); | 269 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); |
270 | e << QString ( ); | 270 | e << QString ( ); |
271 | } | 271 | } |
272 | } | 272 | } |
273 | 273 | ||
274 | int rv = a.exec(); | 274 | int rv = a.exec(); |
275 | 275 | ||
276 | qDebug("exiting..."); | 276 | qDebug("exiting..."); |
277 | delete s; | 277 | delete s; |
278 | 278 | ||
279 | ODevice::inst()->setSoftSuspend( false ); | 279 | ODevice::inst()->setSoftSuspend( false ); |
280 | 280 | ||
281 | return rv; | 281 | return rv; |
282 | } | 282 | } |
283 | 283 | ||
284 | static const char *pidfile_path = "/var/run/opie.pid"; | 284 | static const char *pidfile_path = "/var/run/opie.pid"; |
285 | 285 | ||
286 | void create_pidfile ( ) | 286 | void create_pidfile ( ) |
287 | { | 287 | { |
288 | FILE *f; | 288 | FILE *f; |
289 | 289 | ||
290 | if (( f = ::fopen ( pidfile_path, "w" ))) { | 290 | if (( f = ::fopen ( pidfile_path, "w" ))) { |
291 | ::fprintf ( f, "%d", getpid ( )); | 291 | ::fprintf ( f, "%d", getpid ( )); |
292 | ::fclose ( f ); | 292 | ::fclose ( f ); |
293 | } | 293 | } |
294 | } | 294 | } |
295 | 295 | ||
296 | void remove_pidfile ( ) | 296 | void remove_pidfile ( ) |
297 | { | 297 | { |
298 | ::unlink ( pidfile_path ); | 298 | ::unlink ( pidfile_path ); |
299 | } | 299 | } |
300 | 300 | ||
301 | void handle_sigterm ( int /* sig */ ) | 301 | void handle_sigterm ( int /* sig */ ) |
302 | { | 302 | { |
303 | if ( qApp ) | 303 | if ( qApp ) |
304 | qApp-> quit ( ); | 304 | qApp-> quit ( ); |
305 | } | 305 | } |
306 | 306 | ||
307 | #ifndef Q_OS_WIN32 | 307 | #ifndef Q_OS_WIN32 |
308 | int main( int argc, char ** argv ) | 308 | int main( int argc, char ** argv ) |
309 | { | 309 | { |
310 | 310 | ||
311 | ::signal ( SIGCHLD, SIG_IGN ); | 311 | ::signal ( SIGCHLD, SIG_IGN ); |
312 | 312 | ||
313 | ::signal ( SIGTERM, handle_sigterm ); | 313 | ::signal ( SIGTERM, handle_sigterm ); |
314 | ::signal ( SIGINT, handle_sigterm ); | 314 | ::signal ( SIGINT, handle_sigterm ); |
315 | 315 | ||
316 | ::setsid ( ); | 316 | ::setsid ( ); |
317 | ::setpgid ( 0, 0 ); | 317 | ::setpgid ( 0, 0 ); |
318 | 318 | ||
319 | ::atexit ( remove_pidfile ); | 319 | ::atexit ( remove_pidfile ); |
320 | create_pidfile ( ); | 320 | create_pidfile ( ); |
321 | 321 | ||
322 | int retVal = initApplication( argc, argv ); | 322 | int retVal = initApplication( argc, argv ); |
323 | 323 | ||
324 | // Have we been asked to restart? | 324 | // Have we been asked to restart? |
325 | if ( ServerApplication::doRestart ) { | 325 | if ( ServerApplication::doRestart ) { |
326 | for ( int fd = 3; fd < 100; fd++ ) | 326 | for ( int fd = 3; fd < 100; fd++ ) |
327 | close( fd ); | 327 | close( fd ); |
328 | 328 | ||
329 | execl( (QPEApplication::qpeDir()+"bin/qpe").latin1(), "qpe", 0 ); | 329 | execl( (QPEApplication::qpeDir()+"bin/qpe").latin1(), "qpe", 0 ); |
330 | } | 330 | } |
331 | 331 | ||
332 | // Kill them. Kill them all. | 332 | // Kill them. Kill them all. |
333 | ::kill ( 0, SIGTERM ); | 333 | ::kill ( 0, SIGTERM ); |
334 | ::sleep ( 1 ); | 334 | ::sleep ( 1 ); |
335 | ::kill ( 0, SIGKILL ); | 335 | ::kill ( 0, SIGKILL ); |
336 | 336 | ||
337 | return retVal; | 337 | return retVal; |
338 | } | 338 | } |
339 | #else | 339 | #else |
340 | 340 | ||
341 | int main( int argc, char ** argv ) | 341 | int main( int argc, char ** argv ) |
342 | { | 342 | { |
343 | int retVal = initApplication( argc, argv ); | 343 | int retVal = initApplication( argc, argv ); |
344 | 344 | ||
345 | if ( DesktopApplication::doRestart ) { | 345 | if ( DesktopApplication::doRestart ) { |
346 | qDebug("Trying to restart"); | 346 | qDebug("Trying to restart"); |
347 | execl( (QPEApplication::qpeDir()+"bin\\qpe").latin1(), "qpe", 0 ); | 347 | execl( (QPEApplication::qpeDir()+"bin\\qpe").latin1(), "qpe", 0 ); |
348 | } | 348 | } |
349 | 349 | ||
350 | return retVal; | 350 | return retVal; |
351 | } | 351 | } |
352 | 352 | ||
353 | #endif | 353 | #endif |
354 | 354 | ||
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 450d8e5..4c62b78 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp | |||
@@ -1,497 +1,497 @@ | |||
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 | #if 0 |
36 | #include "suspendmonitor.h" | 36 | #include "suspendmonitor.h" |
37 | #endif | 37 | #endif |
38 | #include "documentlist.h" | 38 | #include "documentlist.h" |
39 | 39 | ||
40 | #include <qtopia/applnk.h> | 40 | #include <qtopia/applnk.h> |
41 | #include <qtopia/private/categories.h> | 41 | #include <qtopia/private/categories.h> |
42 | #include <qtopia/mimetype.h> | 42 | #include <qtopia/mimetype.h> |
43 | #include <qtopia/config.h> | 43 | #include <qtopia/config.h> |
44 | #include <qtopia/resource.h> | 44 | #include <qtopia/resource.h> |
45 | #include <qtopia/version.h> | 45 | #include <qtopia/version.h> |
46 | #include <qtopia/storage.h> | 46 | #include <qtopia/storage.h> |
47 | 47 | ||
48 | #include <qtopia/qcopenvelope_qws.h> | 48 | #include <qtopia/qcopenvelope_qws.h> |
49 | #include <qwindowsystem_qws.h> | 49 | #include <qwindowsystem_qws.h> |
50 | #include <qgfx_qws.h> | 50 | #include <qgfx_qws.h> |
51 | #include <qtopia/global.h> | 51 | #include <qtopia/global.h> |
52 | #include <qtopia/custom.h> | 52 | #include <qtopia/custom.h> |
53 | 53 | ||
54 | #include <opie/odevicebutton.h> | 54 | #include <opie/odevicebutton.h> |
55 | #include <opie/odevice.h> | 55 | #include <opie/odevice.h> |
56 | 56 | ||
57 | #include <unistd.h> | 57 | #include <unistd.h> |
58 | #include <qmainwindow.h> | 58 | #include <qmainwindow.h> |
59 | #include <qmessagebox.h> | 59 | #include <qmessagebox.h> |
60 | #include <qtimer.h> | 60 | #include <qtimer.h> |
61 | #include <qtextstream.h> | 61 | #include <qtextstream.h> |
62 | 62 | ||
63 | #include <stdlib.h> | 63 | #include <stdlib.h> |
64 | 64 | ||
65 | extern QRect qt_maxWindowRect; | 65 | extern QRect qt_maxWindowRect; |
66 | 66 | ||
67 | using namespace Opie; | 67 | using namespace Opie; |
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(QPE_NEED_CALIBRATION) | 110 | #if defined(QPE_NEED_CALIBRATION) |
111 | { "calibrate", calibrate, 1, 0 }, // No tr | 111 | { "calibrate", calibrate, 1, 0 }, // No tr |
112 | #endif | 112 | #endif |
113 | #if !defined(QT_QWS_CASSIOPEIA) | 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 | 121 | ||
122 | //--------------------------------------------------------------------------- | 122 | //--------------------------------------------------------------------------- |
123 | 123 | ||
124 | 124 | ||
125 | //=========================================================================== | 125 | //=========================================================================== |
126 | 126 | ||
127 | Server::Server() : | 127 | Server::Server() : |
128 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 128 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
129 | qcopBridge( 0 ), | 129 | qcopBridge( 0 ), |
130 | transferServer( 0 ), | 130 | transferServer( 0 ), |
131 | packageHandler( 0 ), | 131 | packageHandler( 0 ), |
132 | syncDialog( 0 ) | 132 | syncDialog( 0 ) |
133 | { | 133 | { |
134 | Global::setBuiltinCommands(builtins); | 134 | Global::setBuiltinCommands(builtins); |
135 | 135 | ||
136 | tid_xfer = 0; | 136 | tid_xfer = 0; |
137 | /* ### FIXME ### */ | 137 | /* ### FIXME ### */ |
138 | /* tid_today = startTimer(3600*2*1000);*/ | 138 | /* tid_today = startTimer(3600*2*1000);*/ |
139 | last_today_show = QDate::currentDate(); | 139 | last_today_show = QDate::currentDate(); |
140 | 140 | ||
141 | #if 0 | 141 | #if 0 |
142 | tsmMonitor = new TempScreenSaverMode(); | 142 | tsmMonitor = new TempScreenSaverMode(); |
143 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); | 143 | connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); |
144 | #endif | 144 | #endif |
145 | 145 | ||
146 | serverGui = new Launcher; | 146 | serverGui = new Launcher; |
147 | serverGui->createGUI(); | 147 | serverGui->createGUI(); |
148 | 148 | ||
149 | docList = new DocumentList( serverGui ); | 149 | docList = new DocumentList( serverGui ); |
150 | appLauncher = new AppLauncher(this); | 150 | appLauncher = new AppLauncher(this); |
151 | 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 &)) ); |
152 | 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 &)) ); |
153 | connect(appLauncher, SIGNAL(connected(const QString &)), this, SLOT(applicationConnected(const QString &)) ); | 153 | connect(appLauncher, SIGNAL(connected(const QString &)), this, SLOT(applicationConnected(const QString &)) ); |
154 | 154 | ||
155 | storage = new StorageInfo( this ); | 155 | storage = new StorageInfo( this ); |
156 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); | 156 | connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); |
157 | 157 | ||
158 | // start services | 158 | // start services |
159 | startTransferServer(); | 159 | startTransferServer(); |
160 | (void) new IrServer( this ); | 160 | (void) new IrServer( this ); |
161 | 161 | ||
162 | packageHandler = new PackageHandler( this ); | 162 | packageHandler = new PackageHandler( this ); |
163 | connect(qApp, SIGNAL(activate(const Opie::ODeviceButton*,bool)), | 163 | connect(qApp, SIGNAL(activate(const Opie::ODeviceButton*,bool)), |
164 | this,SLOT(activate(const Opie::ODeviceButton*,bool))); | 164 | this,SLOT(activate(const Opie::ODeviceButton*,bool))); |
165 | 165 | ||
166 | setGeometry( -10, -10, 9, 9 ); | 166 | setGeometry( -10, -10, 9, 9 ); |
167 | 167 | ||
168 | QCopChannel *channel = new QCopChannel("QPE/System", this); | 168 | QCopChannel *channel = new QCopChannel("QPE/System", this); |
169 | connect(channel, SIGNAL(received(const QCString &, const QByteArray &)), | 169 | connect(channel, SIGNAL(received(const QCString &, const QByteArray &)), |
170 | this, SLOT(systemMsg(const QCString &, const QByteArray &)) ); | 170 | this, SLOT(systemMsg(const QCString &, const QByteArray &)) ); |
171 | 171 | ||
172 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); | 172 | QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); |
173 | connect( tbChannel, SIGNAL(received(const QCString&, const QByteArray&)), | 173 | connect( tbChannel, SIGNAL(received(const QCString&, const QByteArray&)), |
174 | this, SLOT(receiveTaskBar(const QCString&, const QByteArray&)) ); | 174 | this, SLOT(receiveTaskBar(const QCString&, const QByteArray&)) ); |
175 | 175 | ||
176 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); | 176 | connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); |
177 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); | 177 | connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); |
178 | 178 | ||
179 | preloadApps(); | 179 | preloadApps(); |
180 | } | 180 | } |
181 | 181 | ||
182 | void Server::show() | 182 | void Server::show() |
183 | { | 183 | { |
184 | ServerApplication::login(TRUE); | 184 | ServerApplication::login(TRUE); |
185 | QWidget::show(); | 185 | QWidget::show(); |
186 | } | 186 | } |
187 | 187 | ||
188 | Server::~Server() | 188 | Server::~Server() |
189 | { | 189 | { |
190 | serverGui->destroyGUI(); | 190 | serverGui->destroyGUI(); |
191 | delete docList; | 191 | delete docList; |
192 | delete qcopBridge; | 192 | delete qcopBridge; |
193 | delete transferServer; | 193 | delete transferServer; |
194 | delete serverGui; | 194 | delete serverGui; |
195 | #if 0 | 195 | #if 0 |
196 | delete tsmMonitor; | 196 | delete tsmMonitor; |
197 | #endif | 197 | #endif |
198 | } | 198 | } |
199 | 199 | ||
200 | static bool hasVisibleWindow(const QString& clientname, bool partial) | 200 | static bool hasVisibleWindow(const QString& clientname, bool partial) |
201 | { | 201 | { |
202 | #ifdef QWS | 202 | #ifdef QWS |
203 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 203 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
204 | QWSWindow* w; | 204 | QWSWindow* w; |
205 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { | 205 | for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { |
206 | if ( w->client()->identity() == clientname ) { | 206 | if ( w->client()->identity() == clientname ) { |
207 | if ( partial && !w->isFullyObscured() ) | 207 | if ( partial && !w->isFullyObscured() ) |
208 | return TRUE; | 208 | return TRUE; |
209 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { | 209 | if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { |
210 | # if QT_VERSION < 0x030000 | 210 | # if QT_VERSION < 0x030000 |
211 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, | 211 | QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, |
212 | QSize(qt_screen->width(),qt_screen->height()) ); | 212 | QSize(qt_screen->width(),qt_screen->height()) ); |
213 | # else | 213 | # else |
214 | QRect mwr = qt_maxWindowRect; | 214 | QRect mwr = qt_maxWindowRect; |
215 | # endif | 215 | # endif |
216 | if ( mwr.contains(w->requested().boundingRect()) ) | 216 | if ( mwr.contains(w->requested().boundingRect()) ) |
217 | return TRUE; | 217 | return TRUE; |
218 | } | 218 | } |
219 | } | 219 | } |
220 | } | 220 | } |
221 | #endif | 221 | #endif |
222 | return FALSE; | 222 | return FALSE; |
223 | } | 223 | } |
224 | 224 | ||
225 | void Server::activate(const Opie::ODeviceButton* button, bool held) | 225 | void Server::activate(const Opie::ODeviceButton* button, bool held) |
226 | { | 226 | { |
227 | Global::terminateBuiltin("calibrate"); // No tr | 227 | Global::terminateBuiltin("calibrate"); // No tr |
228 | Opie::OQCopMessage om; | 228 | Opie::OQCopMessage om; |
229 | if ( held ) { | 229 | if ( held ) { |
230 | om = button->heldAction(); | 230 | om = button->heldAction(); |
231 | } else { | 231 | } else { |
232 | om = button->pressedAction(); | 232 | om = button->pressedAction(); |
233 | } | 233 | } |
234 | 234 | ||
235 | if ( om.channel() != "ignore" ) | 235 | if ( om.channel() != "ignore" ) |
236 | om.send(); | 236 | om.send(); |
237 | 237 | ||
238 | // 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 |
239 | // to send/do anything with this as it will crash | 239 | // to send/do anything with this as it will crash |
240 | /* ### FIXME */ | 240 | /* ### FIXME */ |
241 | #if 0 | 241 | #if 0 |
242 | if ( !sr.isNull() ) { | 242 | if ( !sr.isNull() ) { |
243 | QString app = sr.app(); | 243 | QString app = sr.app(); |
244 | bool vis = hasVisibleWindow(app, app != "qpe"); | 244 | bool vis = hasVisibleWindow(app, app != "qpe"); |
245 | if ( sr.message() == "raise()" && vis ) { | 245 | if ( sr.message() == "raise()" && vis ) { |
246 | sr.setMessage("nextView()"); | 246 | sr.setMessage("nextView()"); |
247 | } else { | 247 | } else { |
248 | // "back door" | 248 | // "back door" |
249 | sr << (int)vis; | 249 | sr << (int)vis; |
250 | } | 250 | } |
251 | 251 | ||
252 | sr.send(); | 252 | sr.send(); |
253 | } | 253 | } |
254 | #endif | 254 | #endif |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | #ifdef Q_WS_QWS | 258 | #ifdef Q_WS_QWS |
259 | 259 | ||
260 | 260 | ||
261 | typedef struct KeyOverride { | 261 | typedef struct KeyOverride { |
262 | ushort scan_code; | 262 | ushort scan_code; |
263 | QWSServer::KeyMap map; | 263 | QWSServer::KeyMap map; |
264 | }; | 264 | }; |
265 | 265 | ||
266 | 266 | ||
267 | static const KeyOverride jp109keys[] = { | 267 | static const KeyOverride jp109keys[] = { |
268 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, | 268 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, |
269 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, | 269 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, |
270 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, | 270 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, |
271 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, | 271 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, |
272 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, | 272 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, |
273 | { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } }, | 273 | { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } }, |
274 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, | 274 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, |
275 | { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } }, | 275 | { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } }, |
276 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, | 276 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, |
277 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } }, | 277 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } }, |
278 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, | 278 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, |
279 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, | 279 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, |
280 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } }, | 280 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } }, |
281 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, | 281 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, |
282 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } }, | 282 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } }, |
283 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, | 283 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, |
284 | { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } }, | 284 | { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } }, |
285 | { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } }, | 285 | { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } }, |
286 | { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } }, | 286 | { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } }, |
287 | { 0x00, { 0, 0xffff , 0xffff , 0xffff } } | 287 | { 0x00, { 0, 0xffff , 0xffff , 0xffff } } |
288 | }; | 288 | }; |
289 | 289 | ||
290 | bool Server::setKeyboardLayout( const QString &kb ) | 290 | bool Server::setKeyboardLayout( const QString &kb ) |
291 | { | 291 | { |
292 | //quick demo version that can be extended | 292 | //quick demo version that can be extended |
293 | 293 | ||
294 | QIntDict<QWSServer::KeyMap> *om = 0; | 294 | QIntDict<QWSServer::KeyMap> *om = 0; |
295 | if ( kb == "us101" ) { // No tr | 295 | if ( kb == "us101" ) { // No tr |
296 | om = 0; | 296 | om = 0; |
297 | } else if ( kb == "jp109" ) { | 297 | } else if ( kb == "jp109" ) { |
298 | om = new QIntDict<QWSServer::KeyMap>(37); | 298 | om = new QIntDict<QWSServer::KeyMap>(37); |
299 | const KeyOverride *k = jp109keys; | 299 | const KeyOverride *k = jp109keys; |
300 | while ( k->scan_code ) { | 300 | while ( k->scan_code ) { |
301 | om->insert( k->scan_code, &k->map ); | 301 | om->insert( k->scan_code, &k->map ); |
302 | k++; | 302 | k++; |
303 | } | 303 | } |
304 | } | 304 | } |
305 | QWSServer::setOverrideKeys( om ); | 305 | QWSServer::setOverrideKeys( om ); |
306 | 306 | ||
307 | return TRUE; | 307 | return TRUE; |
308 | } | 308 | } |
309 | 309 | ||
310 | #endif | 310 | #endif |
311 | 311 | ||
312 | void Server::systemMsg(const QCString &msg, const QByteArray &data) | 312 | void Server::systemMsg(const QCString &msg, const QByteArray &data) |
313 | { | 313 | { |
314 | QDataStream stream( data, IO_ReadOnly ); | 314 | QDataStream stream( data, IO_ReadOnly ); |
315 | 315 | ||
316 | if ( msg == "securityChanged()" ) { | 316 | if ( msg == "securityChanged()" ) { |
317 | if ( transferServer ) | 317 | if ( transferServer ) |
318 | transferServer->authorizeConnections(); | 318 | transferServer->authorizeConnections(); |
319 | if ( qcopBridge ) | 319 | if ( qcopBridge ) |
320 | qcopBridge->authorizeConnections(); | 320 | qcopBridge->authorizeConnections(); |
321 | } | 321 | } |
322 | /* ### FIXME support TempScreenSaverMode */ | 322 | /* ### FIXME support TempScreenSaverMode */ |
323 | #if 0 | 323 | #if 0 |
324 | else if ( msg == "setTempScreenSaverMode(int,int)" ) { | 324 | else if ( msg == "setTempScreenSaverMode(int,int)" ) { |
325 | int mode, pid; | 325 | int mode, pid; |
326 | stream >> mode >> pid; | 326 | stream >> mode >> pid; |
327 | tsmMonitor->setTempMode(mode, pid); | 327 | tsmMonitor->setTempMode(mode, pid); |
328 | } | 328 | } |
329 | #endif | 329 | #endif |
330 | else if ( msg == "linkChanged(QString)" ) { | 330 | else if ( msg == "linkChanged(QString)" ) { |
331 | QString link; | 331 | QString link; |
332 | stream >> link; | 332 | stream >> link; |
333 | qDebug( "desktop.cpp systemMsg -> linkchanged( %s )", link.latin1() ); | 333 | qDebug( "desktop.cpp systemMsg -> linkchanged( %s )", link.latin1() ); |
334 | docList->linkChanged(link); | 334 | docList->linkChanged(link); |
335 | } else if ( msg == "serviceChanged(QString)" ) { | 335 | } else if ( msg == "serviceChanged(QString)" ) { |
336 | MimeType::updateApplications(); | 336 | MimeType::updateApplications(); |
337 | } else if ( msg == "mkdir(QString)" ) { | 337 | } else if ( msg == "mkdir(QString)" ) { |
338 | QString dir; | 338 | QString dir; |
339 | stream >> dir; | 339 | stream >> dir; |
340 | if ( !dir.isEmpty() ) | 340 | if ( !dir.isEmpty() ) |
341 | mkdir( dir ); | 341 | mkdir( dir ); |
342 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 342 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { |
343 | QString baseFile, sigFile; | 343 | QString baseFile, sigFile; |
344 | stream >> baseFile >> sigFile; | 344 | stream >> baseFile >> sigFile; |
345 | QRsync::generateSignature( baseFile, sigFile ); | 345 | QRsync::generateSignature( baseFile, sigFile ); |
346 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 346 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
347 | QString baseFile, sigFile, deltaFile; | 347 | QString baseFile, sigFile, deltaFile; |
348 | stream >> baseFile >> sigFile >> deltaFile; | 348 | stream >> baseFile >> sigFile >> deltaFile; |
349 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 349 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
350 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 350 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { |
351 | QString baseFile, deltaFile; | 351 | QString baseFile, deltaFile; |
352 | stream >> baseFile >> deltaFile; | 352 | stream >> baseFile >> deltaFile; |
353 | if ( !QFile::exists( baseFile ) ) { | 353 | if ( !QFile::exists( baseFile ) ) { |
354 | QFile f( baseFile ); | 354 | QFile f( baseFile ); |
355 | f.open( IO_WriteOnly ); | 355 | f.open( IO_WriteOnly ); |
356 | f.close(); | 356 | f.close(); |
357 | } | 357 | } |
358 | QRsync::applyDiff( baseFile, deltaFile ); | 358 | QRsync::applyDiff( baseFile, deltaFile ); |
359 | #ifndef QT_NO_COP | 359 | #ifndef QT_NO_COP |
360 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 360 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
361 | e << baseFile; | 361 | e << baseFile; |
362 | #endif | 362 | #endif |
363 | } else if ( msg == "rdiffCleanup()" ) { | 363 | } else if ( msg == "rdiffCleanup()" ) { |
364 | mkdir( "/tmp/rdiff" ); | 364 | mkdir( "/tmp/rdiff" ); |
365 | QDir dir; | 365 | QDir dir; |
366 | dir.setPath( "/tmp/rdiff" ); | 366 | dir.setPath( "/tmp/rdiff" ); |
367 | QStringList entries = dir.entryList(); | 367 | QStringList entries = dir.entryList(); |
368 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 368 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
369 | dir.remove( *it ); | 369 | dir.remove( *it ); |
370 | } else if ( msg == "sendHandshakeInfo()" ) { | 370 | } else if ( msg == "sendHandshakeInfo()" ) { |
371 | QString home = getenv( "HOME" ); | 371 | QString home = getenv( "HOME" ); |
372 | #ifndef QT_NO_COP | 372 | #ifndef QT_NO_COP |
373 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 373 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
374 | e << home; | 374 | e << home; |
375 | int locked = (int) ServerApplication::screenLocked(); | 375 | int locked = (int) ServerApplication::screenLocked(); |
376 | e << locked; | 376 | e << locked; |
377 | #endif | 377 | #endif |
378 | 378 | ||
379 | } | 379 | } |
380 | /* | 380 | /* |
381 | * QtopiaDesktop relies on the major number | 381 | * QtopiaDesktop relies on the major number |
382 | * to start with 1. We're at 0.9 | 382 | * to start with 1. We're at 0.9 |
383 | * so wee need to fake at least 1.4 to be able | 383 | * so wee need to fake at least 1.4 to be able |
384 | * to sync with QtopiaDesktop1.6 | 384 | * to sync with QtopiaDesktop1.6 |
385 | */ | 385 | */ |
386 | else if ( msg == "sendVersionInfo()" ) { | 386 | else if ( msg == "sendVersionInfo()" ) { |
387 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); | 387 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); |
388 | /* ### FIXME Architecture ### */ | 388 | /* ### FIXME Architecture ### */ |
389 | e << QString::fromLatin1("1.7") << "Uncustomized Device"; | 389 | e << QString::fromLatin1("1.7") << "Uncustomized Device"; |
390 | } else if ( msg == "sendCardInfo()" ) { | 390 | } else if ( msg == "sendCardInfo()" ) { |
391 | #ifndef QT_NO_COP | 391 | #ifndef QT_NO_COP |
392 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 392 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
393 | #endif | 393 | #endif |
394 | storage->update(); | 394 | storage->update(); |
395 | const QList<FileSystem> &fs = storage->fileSystems(); | 395 | const QList<FileSystem> &fs = storage->fileSystems(); |
396 | QListIterator<FileSystem> it ( fs ); | 396 | QListIterator<FileSystem> it ( fs ); |
397 | QString s; | 397 | QString s; |
398 | QString homeDir = getenv("HOME"); | 398 | QString homeDir = getenv("HOME"); |
399 | QString homeFs, homeFsPath; | 399 | QString homeFs, homeFsPath; |
400 | for ( ; it.current(); ++it ) { | 400 | for ( ; it.current(); ++it ) { |
401 | int k4 = (*it)->blockSize()/256; | 401 | int k4 = (*it)->blockSize()/256; |
402 | if ( (*it)->isRemovable() ) { | 402 | if ( (*it)->isRemovable() ) { |
403 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr | 403 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr |
404 | + QString::number( (*it)->availBlocks() * k4/4 ) | 404 | + QString::number( (*it)->availBlocks() * k4/4 ) |
405 | + "K " + (*it)->options() + ";"; | 405 | + "K " + (*it)->options() + ";"; |
406 | } else if ( homeDir.contains( (*it)->path() ) && | 406 | } else if ( homeDir.contains( (*it)->path() ) && |
407 | (*it)->path().length() > homeFsPath.length() ) { | 407 | (*it)->path().length() > homeFsPath.length() ) { |
408 | homeFsPath = (*it)->path(); | 408 | homeFsPath = (*it)->path(); |
409 | homeFs = | 409 | homeFs = |
410 | (*it)->name() + "=" + homeDir + "/Documents " // No tr | 410 | (*it)->name() + "=" + homeDir + "/Documents " // No tr |
411 | + QString::number( (*it)->availBlocks() * k4/4 ) | 411 | + QString::number( (*it)->availBlocks() * k4/4 ) |
412 | + "K " + (*it)->options() + ";"; | 412 | + "K " + (*it)->options() + ";"; |
413 | } | 413 | } |
414 | } | 414 | } |
415 | if ( !homeFs.isEmpty() ) | 415 | if ( !homeFs.isEmpty() ) |
416 | s += homeFs; | 416 | s += homeFs; |
417 | 417 | ||
418 | #ifndef QT_NO_COP | 418 | #ifndef QT_NO_COP |
419 | e << s; | 419 | e << s; |
420 | #endif | 420 | #endif |
421 | } else if ( msg == "sendSyncDate(QString)" ) { | 421 | } else if ( msg == "sendSyncDate(QString)" ) { |
422 | QString app; | 422 | QString app; |
423 | stream >> app; | 423 | stream >> app; |
424 | Config cfg( "qpe" ); | 424 | Config cfg( "qpe" ); |
425 | cfg.setGroup("SyncDate"); | 425 | cfg.setGroup("SyncDate"); |
426 | #ifndef QT_NO_COP | 426 | #ifndef QT_NO_COP |
427 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 427 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
428 | e << app << cfg.readEntry( app ); | 428 | e << app << cfg.readEntry( app ); |
429 | #endif | 429 | #endif |
430 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), | 430 | //qDebug("QPE/System sendSyncDate for %s: response %s", app.latin1(), |
431 | //cfg.readEntry( app ).latin1() ); | 431 | //cfg.readEntry( app ).latin1() ); |
432 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 432 | } else if ( msg == "setSyncDate(QString,QString)" ) { |
433 | QString app, date; | 433 | QString app, date; |
434 | stream >> app >> date; | 434 | stream >> app >> date; |
435 | Config cfg( "qpe" ); | 435 | Config cfg( "qpe" ); |
436 | cfg.setGroup("SyncDate"); | 436 | cfg.setGroup("SyncDate"); |
437 | cfg.writeEntry( app, date ); | 437 | cfg.writeEntry( app, date ); |
438 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); | 438 | //qDebug("setSyncDate(QString,QString) %s %s", app.latin1(), date.latin1()); |
439 | } else if ( msg == "startSync(QString)" ) { | 439 | } else if ( msg == "startSync(QString)" ) { |
440 | QString what; | 440 | QString what; |
441 | stream >> what; | 441 | stream >> what; |
442 | delete syncDialog; | 442 | delete syncDialog; |
443 | syncDialog = new SyncDialog( this, what ); | 443 | syncDialog = new SyncDialog( this, what ); |
444 | syncDialog->show(); | 444 | syncDialog->show(); |
445 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); | 445 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); |
446 | } else if ( msg == "stopSync()") { | 446 | } else if ( msg == "stopSync()") { |
447 | delete syncDialog; | 447 | delete syncDialog; |
448 | syncDialog = 0; | 448 | syncDialog = 0; |
449 | } else if (msg == "restoreDone(QString)") { | 449 | } else if (msg == "restoreDone(QString)") { |
450 | docList->restoreDone(); | 450 | docList->restoreDone(); |
451 | } else if ( msg == "getAllDocLinks()" ) { | 451 | } else if ( msg == "getAllDocLinks()" ) { |
452 | docList->sendAllDocLinks(); | 452 | docList->sendAllDocLinks(); |
453 | } | 453 | } |
454 | #ifdef Q_WS_QWS | 454 | #ifdef Q_WS_QWS |
455 | else if ( msg == "setMouseProto(QString)" ) { | 455 | else if ( msg == "setMouseProto(QString)" ) { |
456 | QString mice; | 456 | QString mice; |
457 | stream >> mice; | 457 | stream >> mice; |
458 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 458 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
459 | qwsServer->openMouse(); | 459 | qwsServer->openMouse(); |
460 | } else if ( msg == "setKeyboard(QString)" ) { | 460 | } else if ( msg == "setKeyboard(QString)" ) { |
461 | QString kb; | 461 | QString kb; |
462 | stream >> kb; | 462 | stream >> kb; |
463 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 463 | setenv("QWS_KEYBOARD",kb.latin1(),1); |
464 | qwsServer->openKeyboard(); | 464 | qwsServer->openKeyboard(); |
465 | 465 | ||
466 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { | 466 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { |
467 | int delay, period; | 467 | int delay, period; |
468 | stream >> delay >> period; | 468 | stream >> delay >> period; |
469 | qwsSetKeyboardAutoRepeat( delay, period ); | 469 | qwsSetKeyboardAutoRepeat( delay, period ); |
470 | Config cfg( "qpe" ); | 470 | Config cfg( "qpe" ); |
471 | cfg.setGroup("Keyboard"); | 471 | cfg.setGroup("Keyboard"); |
472 | cfg.writeEntry( "RepeatDelay", delay ); | 472 | cfg.writeEntry( "RepeatDelay", delay ); |
473 | cfg.writeEntry( "RepeatPeriod", period ); | 473 | cfg.writeEntry( "RepeatPeriod", period ); |
474 | } else if ( msg == "setKeyboardLayout(QString)" ) { | 474 | } else if ( msg == "setKeyboardLayout(QString)" ) { |
475 | QString kb; | 475 | QString kb; |
476 | stream >> kb; | 476 | stream >> kb; |
477 | setKeyboardLayout( kb ); | 477 | setKeyboardLayout( kb ); |
478 | Config cfg( "qpe" ); | 478 | Config cfg( "qpe" ); |
479 | cfg.setGroup("Keyboard"); | 479 | cfg.setGroup("Keyboard"); |
480 | cfg.writeEntry( "Layout", kb ); | 480 | cfg.writeEntry( "Layout", kb ); |
481 | } else if ( msg == "autoStart(QString)" ) { | 481 | } else if ( msg == "autoStart(QString)" ) { |
482 | QString appName; | 482 | QString appName; |
483 | stream >> appName; | 483 | stream >> appName; |
484 | Config cfg( "autostart" ); | 484 | Config cfg( "autostart" ); |
485 | cfg.setGroup( "AutoStart" ); | 485 | cfg.setGroup( "AutoStart" ); |
486 | if ( appName.compare("clear") == 0){ | 486 | if ( appName.compare("clear") == 0){ |
487 | cfg.writeEntry("Apps", ""); | 487 | cfg.writeEntry("Apps", ""); |
488 | } | 488 | } |
489 | } else if ( msg == "autoStart(QString,QString)" ) { | 489 | } else if ( msg == "autoStart(QString,QString)" ) { |
490 | QString modifier, appName; | 490 | QString modifier, appName; |
491 | stream >> modifier >> appName; | 491 | stream >> modifier >> appName; |
492 | Config cfg( "autostart" ); | 492 | Config cfg( "autostart" ); |
493 | cfg.setGroup( "AutoStart" ); | 493 | cfg.setGroup( "AutoStart" ); |
494 | if ( modifier.compare("add") == 0 ){ | 494 | if ( modifier.compare("add") == 0 ){ |
495 | // only add if appname is entered | 495 | // only add if appname is entered |
496 | if (!appName.isEmpty()) { | 496 | if (!appName.isEmpty()) { |
497 | cfg.writeEntry("Apps", appName); | 497 | cfg.writeEntry("Apps", appName); |