-rw-r--r-- | core/launcher/main.cpp | 42 |
1 files changed, 18 insertions, 24 deletions
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 3e7e0d2..a86aca6 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -1,91 +1,85 @@ | |||
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 | #ifdef QT_QWS_LOGIN | ||
25 | #include "../login/qdmdialogimpl.h" | ||
26 | #endif | ||
27 | #include "calibrate.h" | ||
24 | #include "server.h" | 28 | #include "server.h" |
25 | #include "serverapp.h" | 29 | #include "serverapp.h" |
26 | #include "stabmon.h" | 30 | #include "stabmon.h" |
27 | #include "firstuse.h" | 31 | #include "firstuse.h" |
28 | 32 | ||
33 | /* OPIE */ | ||
34 | #include <opie2/odebug.h> | ||
35 | #include <opie2/odevice.h> | ||
29 | #include <opie2/oglobal.h> | 36 | #include <opie2/oglobal.h> |
30 | |||
31 | #include <qtopia/network.h> | 37 | #include <qtopia/network.h> |
32 | //#include <qtopia/custom.h> | 38 | #include <qtopia/alarmserver.h> |
33 | 39 | using namespace Opie::Core; | |
34 | 40 | ||
41 | /* QT */ | ||
35 | #include <qdir.h> | 42 | #include <qdir.h> |
43 | #include <qmessagebox.h> | ||
36 | #ifdef QWS | 44 | #ifdef QWS |
37 | #include <qwindowsystem_qws.h> | 45 | #include <qwindowsystem_qws.h> |
38 | #include <qtopia/qcopenvelope_qws.h> | 46 | #include <qtopia/qcopenvelope_qws.h> |
39 | #endif | 47 | #endif |
40 | #include <qtopia/alarmserver.h> | 48 | #ifdef Q_WS_QWS |
49 | #include <qkeyboard_qws.h> | ||
50 | #endif | ||
41 | 51 | ||
52 | /* STD */ | ||
42 | #include <stdlib.h> | 53 | #include <stdlib.h> |
43 | #include <stdio.h> | 54 | #include <stdio.h> |
44 | #include <signal.h> | 55 | #include <signal.h> |
45 | #ifndef Q_OS_WIN32 | 56 | #ifndef Q_OS_WIN32 |
46 | #include <unistd.h> | 57 | #include <unistd.h> |
47 | #else | 58 | #else |
48 | #include <process.h> | 59 | #include <process.h> |
49 | #endif | 60 | #endif |
50 | 61 | ||
51 | #include "calibrate.h" | ||
52 | |||
53 | |||
54 | #ifdef QT_QWS_LOGIN | ||
55 | #include "../login/qdmdialogimpl.h" | ||
56 | #endif | ||
57 | |||
58 | #ifdef Q_WS_QWS | ||
59 | #include <qkeyboard_qws.h> | ||
60 | #endif | ||
61 | |||
62 | #include <qmessagebox.h> | ||
63 | #include <opie2/odevice.h> | ||
64 | |||
65 | using namespace Opie::Core; | ||
66 | |||
67 | |||
68 | static void cleanup() | 62 | static void cleanup() |
69 | { | 63 | { |
70 | QDir dir( "/tmp", "qcop-msg-*" ); | 64 | QDir dir( "/tmp", "qcop-msg-*" ); |
71 | 65 | ||
72 | QStringList stale = dir.entryList(); | 66 | QStringList stale = dir.entryList(); |
73 | QStringList::Iterator it; | 67 | QStringList::Iterator it; |
74 | for ( it = stale.begin(); it != stale.end(); ++it ) { | 68 | for ( it = stale.begin(); it != stale.end(); ++it ) { |
75 | dir.remove( *it ); | 69 | dir.remove( *it ); |
76 | } | 70 | } |
77 | } | 71 | } |
78 | 72 | ||
79 | static void refreshTimeZoneConfig() | 73 | static void refreshTimeZoneConfig() |
80 | { | 74 | { |
81 | /* ### FIXME timezone handling */ | 75 | /* ### FIXME timezone handling */ |
82 | #if 0 | 76 | #if 0 |
83 | // We need to help WorldTime in setting up its configuration for | 77 | // We need to help WorldTime in setting up its configuration for |
84 | // the current translation | 78 | // the current translation |
85 | // BEGIN no tr | 79 | // BEGIN no tr |
86 | const char *defaultTz[] = { | 80 | const char *defaultTz[] = { |
87 | "America/New_York", | 81 | "America/New_York", |
88 | "America/Los_Angeles", | 82 | "America/Los_Angeles", |
89 | "Europe/Oslo", | 83 | "Europe/Oslo", |
90 | "Asia/Tokyo", | 84 | "Asia/Tokyo", |
91 | "Asia/Hong_Kong", | 85 | "Asia/Hong_Kong", |
@@ -100,49 +94,49 @@ static void refreshTimeZoneConfig() | |||
100 | Config cfg = Config( "WorldTime" ); | 94 | Config cfg = Config( "WorldTime" ); |
101 | cfg.setGroup( "TimeZones" ); | 95 | cfg.setGroup( "TimeZones" ); |
102 | if (!cfg.hasKey( "Zone0" )){ | 96 | if (!cfg.hasKey( "Zone0" )){ |
103 | // We have no existing timezones use the defaults which are untranslated strings | 97 | // We have no existing timezones use the defaults which are untranslated strings |
104 | QString currTz = TimeZone::current().id(); | 98 | QString currTz = TimeZone::current().id(); |
105 | QStringList zoneDefaults; | 99 | QStringList zoneDefaults; |
106 | zoneDefaults.append( currTz ); | 100 | zoneDefaults.append( currTz ); |
107 | for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) { | 101 | for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) { |
108 | if ( defaultTz[i] != currTz ) | 102 | if ( defaultTz[i] != currTz ) |
109 | zoneDefaults.append( defaultTz[i] ); | 103 | zoneDefaults.append( defaultTz[i] ); |
110 | } | 104 | } |
111 | zoneIndex = 0; | 105 | zoneIndex = 0; |
112 | for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ | 106 | for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ |
113 | cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); | 107 | cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); |
114 | zoneIndex++; | 108 | zoneIndex++; |
115 | } | 109 | } |
116 | } | 110 | } |
117 | // We have an existing list of timezones refresh the | 111 | // We have an existing list of timezones refresh the |
118 | // translations of TimeZone name | 112 | // translations of TimeZone name |
119 | zoneIndex = 0; | 113 | zoneIndex = 0; |
120 | while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ | 114 | while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ |
121 | zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); | 115 | zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); |
122 | curZone = TimeZone( zoneID ); | 116 | curZone = TimeZone( zoneID ); |
123 | if ( !curZone.isValid() ){ | 117 | if ( !curZone.isValid() ){ |
124 | qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() ); | 118 | odebug << "initEnvironment() Invalid TimeZone " << zoneID << "" << oendl; |
125 | break; | 119 | break; |
126 | } | 120 | } |
127 | cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); | 121 | cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); |
128 | zoneIndex++; | 122 | zoneIndex++; |
129 | } | 123 | } |
130 | #endif | 124 | #endif |
131 | } | 125 | } |
132 | 126 | ||
133 | void initEnvironment() | 127 | void initEnvironment() |
134 | { | 128 | { |
135 | #ifdef Q_OS_WIN32 | 129 | #ifdef Q_OS_WIN32 |
136 | // Config file requires HOME dir which uses QDir which needs the winver | 130 | // Config file requires HOME dir which uses QDir which needs the winver |
137 | qt_init_winver(); | 131 | qt_init_winver(); |
138 | #endif | 132 | #endif |
139 | Config config("locale"); | 133 | Config config("locale"); |
140 | config.setGroup( "Location" ); | 134 | config.setGroup( "Location" ); |
141 | QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); | 135 | QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); |
142 | 136 | ||
143 | // if not timezone set, pick New York | 137 | // if not timezone set, pick New York |
144 | if (tz.isNull() || tz.isEmpty()) | 138 | if (tz.isNull() || tz.isEmpty()) |
145 | tz = "America/New_York"; | 139 | tz = "America/New_York"; |
146 | 140 | ||
147 | setenv( "TZ", tz, 1 ); | 141 | setenv( "TZ", tz, 1 ); |
148 | config.writeEntry( "Timezone", tz); | 142 | config.writeEntry( "Timezone", tz); |
@@ -248,49 +242,49 @@ int initApplication( int argc, char ** argv ) | |||
248 | 242 | ||
249 | AlarmServer::initialize(); | 243 | AlarmServer::initialize(); |
250 | 244 | ||
251 | 245 | ||
252 | 246 | ||
253 | Server *s = new Server(); | 247 | Server *s = new Server(); |
254 | 248 | ||
255 | (void)new SysFileMonitor(s); | 249 | (void)new SysFileMonitor(s); |
256 | #ifdef QWS | 250 | #ifdef QWS |
257 | Network::createServer(s); | 251 | Network::createServer(s); |
258 | #endif | 252 | #endif |
259 | 253 | ||
260 | s->show(); | 254 | s->show(); |
261 | 255 | ||
262 | /* THE ARM rtc has problem holdings the time on reset */ | 256 | /* THE ARM rtc has problem holdings the time on reset */ |
263 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { | 257 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { |
264 | 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 ) { | 258 | 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 ) { |
265 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); | 259 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); |
266 | e << QString ( ); | 260 | e << QString ( ); |
267 | } | 261 | } |
268 | } | 262 | } |
269 | 263 | ||
270 | int rv = a.exec(); | 264 | int rv = a.exec(); |
271 | 265 | ||
272 | qDebug("exiting..."); | 266 | odebug << "exiting..." << oendl; |
273 | delete s; | 267 | delete s; |
274 | 268 | ||
275 | #ifndef Q_OS_MACX | 269 | #ifndef Q_OS_MACX |
276 | ODevice::inst()->setSoftSuspend( false ); | 270 | ODevice::inst()->setSoftSuspend( false ); |
277 | #endif | 271 | #endif |
278 | 272 | ||
279 | return rv; | 273 | return rv; |
280 | } | 274 | } |
281 | 275 | ||
282 | static const char *pidfile_path = "/var/run/opie.pid"; | 276 | static const char *pidfile_path = "/var/run/opie.pid"; |
283 | 277 | ||
284 | void create_pidfile ( ) | 278 | void create_pidfile ( ) |
285 | { | 279 | { |
286 | FILE *f; | 280 | FILE *f; |
287 | 281 | ||
288 | if (( f = ::fopen ( pidfile_path, "w" ))) { | 282 | if (( f = ::fopen ( pidfile_path, "w" ))) { |
289 | ::fprintf ( f, "%d", getpid ( )); | 283 | ::fprintf ( f, "%d", getpid ( )); |
290 | ::fclose ( f ); | 284 | ::fclose ( f ); |
291 | } | 285 | } |
292 | } | 286 | } |
293 | 287 | ||
294 | void remove_pidfile ( ) | 288 | void remove_pidfile ( ) |
295 | { | 289 | { |
296 | ::unlink ( pidfile_path ); | 290 | ::unlink ( pidfile_path ); |
@@ -320,33 +314,33 @@ int main( int argc, char ** argv ) | |||
320 | int retVal = initApplication( argc, argv ); | 314 | int retVal = initApplication( argc, argv ); |
321 | 315 | ||
322 | // Have we been asked to restart? | 316 | // Have we been asked to restart? |
323 | if ( ServerApplication::doRestart ) { | 317 | if ( ServerApplication::doRestart ) { |
324 | for ( int fd = 3; fd < 100; fd++ ) | 318 | for ( int fd = 3; fd < 100; fd++ ) |
325 | close( fd ); | 319 | close( fd ); |
326 | 320 | ||
327 | execl( (QPEApplication::qpeDir()+"bin/qpe").latin1(), "qpe", 0 ); | 321 | execl( (QPEApplication::qpeDir()+"bin/qpe").latin1(), "qpe", 0 ); |
328 | } | 322 | } |
329 | 323 | ||
330 | // Kill them. Kill them all. | 324 | // Kill them. Kill them all. |
331 | ::kill ( 0, SIGTERM ); | 325 | ::kill ( 0, SIGTERM ); |
332 | ::sleep ( 1 ); | 326 | ::sleep ( 1 ); |
333 | ::kill ( 0, SIGKILL ); | 327 | ::kill ( 0, SIGKILL ); |
334 | 328 | ||
335 | return retVal; | 329 | return retVal; |
336 | } | 330 | } |
337 | #else | 331 | #else |
338 | 332 | ||
339 | int main( int argc, char ** argv ) | 333 | int main( int argc, char ** argv ) |
340 | { | 334 | { |
341 | int retVal = initApplication( argc, argv ); | 335 | int retVal = initApplication( argc, argv ); |
342 | 336 | ||
343 | if ( DesktopApplication::doRestart ) { | 337 | if ( DesktopApplication::doRestart ) { |
344 | qDebug("Trying to restart"); | 338 | odebug << "Trying to restart" << oendl; |
345 | execl( (QPEApplication::qpeDir()+"bin\\qpe").latin1(), "qpe", 0 ); | 339 | execl( (QPEApplication::qpeDir()+"bin\\qpe").latin1(), "qpe", 0 ); |
346 | } | 340 | } |
347 | 341 | ||
348 | return retVal; | 342 | return retVal; |
349 | } | 343 | } |
350 | 344 | ||
351 | #endif | 345 | #endif |
352 | 346 | ||