author | tille <tille> | 2002-10-31 21:15:33 (UTC) |
---|---|---|
committer | tille <tille> | 2002-10-31 21:15:33 (UTC) |
commit | 9453519728734e52aac9ea81a4ca3a867f013bda (patch) (unidiff) | |
tree | fc5a36cd1f01401f580a76d86fd087e0e41440cb | |
parent | 00a211621ea11ed73d803a3e52c09ce1e76864eb (diff) | |
download | opie-9453519728734e52aac9ea81a4ca3a867f013bda.zip opie-9453519728734e52aac9ea81a4ca3a867f013bda.tar.gz opie-9453519728734e52aac9ea81a4ca3a867f013bda.tar.bz2 |
remove netsystemtime
-rw-r--r-- | core/launcher/main.cpp | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 715239f..b517c7d 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -1,187 +1,182 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of 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 "desktop.h" | 21 | #include "desktop.h" |
22 | #include "taskbar.h" | 22 | #include "taskbar.h" |
23 | #include "stabmon.h" | 23 | #include "stabmon.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/network.h> | 26 | #include <qpe/network.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) | 28 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) |
29 | #include <qpe/custom.h> | 29 | #include <qpe/custom.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #include <opie/odevice.h> | 32 | #include <opie/odevice.h> |
33 | 33 | ||
34 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
35 | #include <qfile.h> | 35 | #include <qfile.h> |
36 | #include <qimage.h> | 36 | #include <qimage.h> |
37 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
38 | #include <qpe/qcopenvelope_qws.h> | 38 | #include <qpe/qcopenvelope_qws.h> |
39 | #include <qpe/alarmserver.h> | 39 | #include <qpe/alarmserver.h> |
40 | 40 | ||
41 | #include <stdlib.h> | 41 | #include <stdlib.h> |
42 | #include <stdio.h> | 42 | #include <stdio.h> |
43 | #include <signal.h> | 43 | #include <signal.h> |
44 | #include <unistd.h> | 44 | #include <unistd.h> |
45 | 45 | ||
46 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 46 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
47 | #include "../calibrate/calibrate.h" | 47 | #include "../calibrate/calibrate.h" |
48 | #endif | 48 | #endif |
49 | 49 | ||
50 | using namespace Opie; | 50 | using namespace Opie; |
51 | 51 | ||
52 | void initEnvironment() | 52 | void initEnvironment() |
53 | { | 53 | { |
54 | Config config("locale"); | 54 | Config config("locale"); |
55 | config.setGroup( "Location" ); | 55 | config.setGroup( "Location" ); |
56 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); | 56 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); |
57 | 57 | ||
58 | // if not timezone set, pick New York | 58 | // if not timezone set, pick New York |
59 | if (tz.isNull()) | 59 | if (tz.isNull()) |
60 | tz = "America/New_York"; | 60 | tz = "America/New_York"; |
61 | 61 | ||
62 | setenv( "TZ", tz, 1 ); | 62 | setenv( "TZ", tz, 1 ); |
63 | config.writeEntry( "Timezone", tz); | 63 | config.writeEntry( "Timezone", tz); |
64 | 64 | ||
65 | config.setGroup( "Language" ); | 65 | config.setGroup( "Language" ); |
66 | QString lang = config.readEntry( "Language", getenv("LANG") ); | 66 | QString lang = config.readEntry( "Language", getenv("LANG") ); |
67 | if ( !lang.isNull() ) | 67 | if ( !lang.isNull() ) |
68 | setenv( "LANG", lang, 1 ); | 68 | setenv( "LANG", lang, 1 ); |
69 | } | 69 | } |
70 | 70 | ||
71 | 71 | ||
72 | int initApplication( int argc, char ** argv ) | 72 | int initApplication( int argc, char ** argv ) |
73 | { | 73 | { |
74 | initEnvironment(); | 74 | initEnvironment(); |
75 | 75 | ||
76 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) | 76 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) |
77 | setenv( "QWS_SIZE", "240x320", 0 ); | 77 | setenv( "QWS_SIZE", "240x320", 0 ); |
78 | #endif | 78 | #endif |
79 | 79 | ||
80 | //Don't flicker at startup: | 80 | //Don't flicker at startup: |
81 | QWSServer::setDesktopBackground( QImage() ); | 81 | QWSServer::setDesktopBackground( QImage() ); |
82 | DesktopApplication a( argc, argv, QApplication::GuiServer ); | 82 | DesktopApplication a( argc, argv, QApplication::GuiServer ); |
83 | 83 | ||
84 | ODevice::inst ( )-> setSoftSuspend ( true ); | 84 | ODevice::inst ( )-> setSoftSuspend ( true ); |
85 | 85 | ||
86 | { // init backlight | 86 | { // init backlight |
87 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | 87 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); |
88 | e << -3; // Forced on | 88 | e << -3; // Forced on |
89 | } | 89 | } |
90 | 90 | ||
91 | AlarmServer::initialize(); | 91 | AlarmServer::initialize(); |
92 | 92 | ||
93 | Desktop *d = new Desktop(); | 93 | Desktop *d = new Desktop(); |
94 | 94 | ||
95 | QObject::connect( &a, SIGNAL(menu()), d, SLOT(raiseMenu()) ); | 95 | QObject::connect( &a, SIGNAL(menu()), d, SLOT(raiseMenu()) ); |
96 | QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); | 96 | QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); |
97 | QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); | 97 | QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); |
98 | QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); | 98 | QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); |
99 | QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); | 99 | QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); |
100 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); | 100 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); |
101 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); | 101 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); |
102 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); | 102 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); |
103 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); | 103 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); |
104 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); | 104 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); |
105 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); | 105 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); |
106 | 106 | ||
107 | (void)new SysFileMonitor(d); | 107 | (void)new SysFileMonitor(d); |
108 | Network::createServer(d); | 108 | Network::createServer(d); |
109 | 109 | ||
110 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 110 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
111 | if ( !QFile::exists( "/etc/pointercal" ) ) { | 111 | if ( !QFile::exists( "/etc/pointercal" ) ) { |
112 | // Make sure calibration widget starts on top. | 112 | // Make sure calibration widget starts on top. |
113 | Calibrate *cal = new Calibrate; | 113 | Calibrate *cal = new Calibrate; |
114 | cal->exec(); | 114 | cal->exec(); |
115 | delete cal; | 115 | delete cal; |
116 | } | 116 | } |
117 | #endif | 117 | #endif |
118 | 118 | ||
119 | d->show(); | 119 | d->show(); |
120 | 120 | ||
121 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { | 121 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { |
122 | if ( QMessageBox::information ( 0, DesktopApplication::tr( "Information" ), DesktopApplication::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 ) { | 122 | if ( QMessageBox::information ( 0, DesktopApplication::tr( "Information" ), DesktopApplication::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 ) { |
123 | QCString app; | 123 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); |
124 | if ( QFile::exists ( QPEApplication::qpeDir ( ) + "/bin/netsystemtime" )) | ||
125 | app = "netsystemtime"; | ||
126 | else | ||
127 | app = "systemtime"; | ||
128 | QCopEnvelope e ( "QPE/Application/" + app, "setDocument(QString)" ); | ||
129 | e << QString ( ); | 124 | e << QString ( ); |
130 | } | 125 | } |
131 | } | 126 | } |
132 | 127 | ||
133 | int rv = a.exec(); | 128 | int rv = a.exec(); |
134 | 129 | ||
135 | delete d; | 130 | delete d; |
136 | 131 | ||
137 | ODevice::inst ( )-> setSoftSuspend ( false ); | 132 | ODevice::inst ( )-> setSoftSuspend ( false ); |
138 | 133 | ||
139 | return rv; | 134 | return rv; |
140 | } | 135 | } |
141 | 136 | ||
142 | static const char *pidfile_path = "/var/run/opie.pid"; | 137 | static const char *pidfile_path = "/var/run/opie.pid"; |
143 | 138 | ||
144 | void create_pidfile ( ) | 139 | void create_pidfile ( ) |
145 | { | 140 | { |
146 | FILE *f; | 141 | FILE *f; |
147 | 142 | ||
148 | if (( f = ::fopen ( pidfile_path, "w" ))) { | 143 | if (( f = ::fopen ( pidfile_path, "w" ))) { |
149 | ::fprintf ( f, "%d", getpid ( )); | 144 | ::fprintf ( f, "%d", getpid ( )); |
150 | ::fclose ( f ); | 145 | ::fclose ( f ); |
151 | } | 146 | } |
152 | } | 147 | } |
153 | 148 | ||
154 | void remove_pidfile ( ) | 149 | void remove_pidfile ( ) |
155 | { | 150 | { |
156 | ::unlink ( pidfile_path ); | 151 | ::unlink ( pidfile_path ); |
157 | } | 152 | } |
158 | 153 | ||
159 | void handle_sigterm ( int /* sig */ ) | 154 | void handle_sigterm ( int /* sig */ ) |
160 | { | 155 | { |
161 | if ( qApp ) | 156 | if ( qApp ) |
162 | qApp-> quit ( ); | 157 | qApp-> quit ( ); |
163 | } | 158 | } |
164 | 159 | ||
165 | int main( int argc, char ** argv ) | 160 | int main( int argc, char ** argv ) |
166 | { | 161 | { |
167 | ::signal ( SIGCHLD, SIG_IGN ); | 162 | ::signal ( SIGCHLD, SIG_IGN ); |
168 | 163 | ||
169 | ::signal ( SIGTERM, handle_sigterm ); | 164 | ::signal ( SIGTERM, handle_sigterm ); |
170 | ::signal ( SIGINT, handle_sigterm ); | 165 | ::signal ( SIGINT, handle_sigterm ); |
171 | 166 | ||
172 | ::setsid ( ); | 167 | ::setsid ( ); |
173 | ::setpgid ( 0, 0 ); | 168 | ::setpgid ( 0, 0 ); |
174 | 169 | ||
175 | ::atexit ( remove_pidfile ); | 170 | ::atexit ( remove_pidfile ); |
176 | create_pidfile ( ); | 171 | create_pidfile ( ); |
177 | 172 | ||
178 | int retVal = initApplication ( argc, argv ); | 173 | int retVal = initApplication ( argc, argv ); |
179 | 174 | ||
180 | // Kill them. Kill them all. | 175 | // Kill them. Kill them all. |
181 | ::kill ( 0, SIGTERM ); | 176 | ::kill ( 0, SIGTERM ); |
182 | ::sleep ( 1 ); | 177 | ::sleep ( 1 ); |
183 | ::kill ( 0, SIGKILL ); | 178 | ::kill ( 0, SIGKILL ); |
184 | 179 | ||
185 | return retVal; | 180 | return retVal; |
186 | } | 181 | } |
187 | 182 | ||