-rw-r--r-- | core/launcher/main.cpp | 142 |
1 files changed, 65 insertions, 77 deletions
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index aa0dfdf..734d072 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -2,4 +2,3 @@ | |||
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** Copyright (C) 2003-2005 The Opie Team <opie-devel@handhelds.org> |
4 | ** This file is part of the Qtopia Environment. | ||
5 | ** | 4 | ** |
@@ -12,8 +11,2 @@ | |||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | 12 | **********************************************************************/ |
@@ -55,7 +48,8 @@ using namespace Opie::Core; | |||
55 | #include <signal.h> | 48 | #include <signal.h> |
56 | #ifndef Q_OS_WIN32 | ||
57 | #include <unistd.h> | 49 | #include <unistd.h> |
58 | #else | 50 | #include <errno.h> |
59 | #include <process.h> | 51 | #include <string.h> |
60 | #endif | 52 | |
53 | void create_pidfile(); | ||
54 | void remove_pidfile(); | ||
61 | 55 | ||
@@ -72,13 +66,4 @@ static void cleanup() | |||
72 | 66 | ||
73 | static void refreshTimeZoneConfig() | ||
74 | { | ||
75 | /* ### FIXME timezone handling for qtopia */ | ||
76 | } | ||
77 | |||
78 | void initEnvironment() | 67 | void initEnvironment() |
79 | { | 68 | { |
80 | #ifdef Q_OS_WIN32 | ||
81 | // Config file requires HOME dir which uses QDir which needs the winver | ||
82 | qt_init_winver(); | ||
83 | #endif | ||
84 | Config config("locale"); | 69 | Config config("locale"); |
@@ -87,6 +72,4 @@ void initEnvironment() | |||
87 | 72 | ||
88 | // if not timezone set, pick New York | 73 | // timezone |
89 | if (tz.isNull() || tz.isEmpty()) | 74 | if (tz.isNull() || tz.isEmpty()) tz = "America/New_York"; |
90 | tz = "America/New_York"; | ||
91 | |||
92 | setenv( "TZ", tz, 1 ); | 75 | setenv( "TZ", tz, 1 ); |
@@ -94,7 +77,6 @@ void initEnvironment() | |||
94 | 77 | ||
78 | // language | ||
95 | config.setGroup( "Language" ); | 79 | config.setGroup( "Language" ); |
96 | QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); | 80 | QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); |
97 | if( lang.isNull() || lang.isEmpty()) | 81 | if( lang.isNull() || lang.isEmpty()) lang = "en_US"; |
98 | lang = "en_US"; | ||
99 | |||
100 | setenv( "LANG", lang, 1 ); | 82 | setenv( "LANG", lang, 1 ); |
@@ -103,15 +85,18 @@ void initEnvironment() | |||
103 | 85 | ||
86 | // rotation | ||
87 | int t = ODevice::inst()->rotation(); | ||
88 | odebug << "ODevice reports transformation to be " << t << oendl; | ||
89 | |||
90 | QString env( getenv("QWS_DISPLAY") ); | ||
91 | if ( env.isEmpty() ) | ||
92 | { | ||
93 | int rot = ODevice::inst()->rotation() * 90; | ||
94 | QString qws_display = QString("Transformed:Rot%1:0").arg(rot); | ||
95 | odebug << "setting QWS_DISPLAY to '" << qws_display << "'" << oendl; | ||
96 | setenv("QWS_DISPLAY", (const char*) qws_display, 1); | ||
97 | } | ||
98 | else | ||
99 | odebug << "QWS_DISPLAY already set as '" << env << "' - overriding ODevice transformation" << oendl; | ||
104 | 100 | ||
105 | QString env(getenv("QWS_DISPLAY")); | 101 | QPEApplication::defaultRotation(); /* to ensure deforient matches reality */ |
106 | if (env.contains("Transformed")) { | ||
107 | int rot; | ||
108 | // transformed driver default rotation is controlled by the hardware. | ||
109 | Config config("qpe"); | ||
110 | config.setGroup( "Rotation" ); | ||
111 | if ( ( rot = config.readNumEntry( "Rot", -1 ) ) == -1 ) | ||
112 | rot = ODevice::inst ( )-> rotation ( ) * 90; | ||
113 | |||
114 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); | ||
115 | QPEApplication::defaultRotation ( ); /* to ensure deforient matches reality */ | ||
116 | } | ||
117 | } | 102 | } |
@@ -161,7 +146,4 @@ int initApplication( int argc, char ** argv ) | |||
161 | cleanup(); | 146 | cleanup(); |
162 | |||
163 | |||
164 | initEnvironment(); | 147 | initEnvironment(); |
165 | 148 | ||
166 | //Don't flicker at startup: | ||
167 | #ifdef QWS | 149 | #ifdef QWS |
@@ -170,18 +152,16 @@ int initApplication( int argc, char ** argv ) | |||
170 | ServerApplication a( argc, argv, QApplication::GuiServer ); | 152 | ServerApplication a( argc, argv, QApplication::GuiServer ); |
171 | |||
172 | refreshTimeZoneConfig(); | ||
173 | |||
174 | initKeyboard(); | 153 | initKeyboard(); |
175 | 154 | ||
176 | // Don't use first use under Windows | 155 | if ( firstUse() ) |
177 | if ( firstUse() ) { | 156 | { |
178 | a.restart(); | 157 | a.restart(); |
179 | return 0; | 158 | return 0; |
180 | } | 159 | } |
181 | 160 | ||
182 | ODevice::inst ( )-> setSoftSuspend ( true ); | 161 | #ifndef Q_OS_MACX |
183 | 162 | ODevice::inst()->setSoftSuspend( true ); | |
163 | #endif | ||
184 | { | 164 | { |
185 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | 165 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); |
186 | e << -3; // Forced on | 166 | e << -3; // Forced on |
187 | } | 167 | } |
@@ -189,8 +169,4 @@ int initApplication( int argc, char ** argv ) | |||
189 | AlarmServer::initialize(); | 169 | AlarmServer::initialize(); |
190 | |||
191 | |||
192 | |||
193 | Server *s = new Server(); | 170 | Server *s = new Server(); |
194 | 171 | new SysFileMonitor(s); | |
195 | (void)new SysFileMonitor(s); | ||
196 | #ifdef QWS | 172 | #ifdef QWS |
@@ -198,16 +174,23 @@ int initApplication( int argc, char ** argv ) | |||
198 | #endif | 174 | #endif |
199 | |||
200 | s->show(); | 175 | s->show(); |
201 | 176 | ||
202 | /* THE ARM rtc has problem holdings the time on reset */ | 177 | #if 0 |
203 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { | 178 | if ( QDate::currentDate().year() < 2005 ) |
204 | 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 ) { | 179 | { |
205 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); | 180 | if ( QMessageBox::information ( 0, ServerApplication::tr( "Information" ), |
206 | e << QString ( ); | 181 | ServerApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ) |
207 | } | 182 | .arg( TimeString::dateString( QDate::currentDate())), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) |
183 | { | ||
184 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); | ||
185 | e << QString ( ); | ||
186 | } | ||
208 | } | 187 | } |
188 | #endif | ||
209 | 189 | ||
210 | int rv = a.exec(); | 190 | create_pidfile(); |
211 | 191 | odebug << "--> mainloop in" << oendl; | |
212 | odebug << "exiting..." << oendl; | 192 | int rv = a.exec(); |
193 | odebug << "<-- mainloop out" << oendl; | ||
194 | remove_pidfile(); | ||
195 | odebug << "removing server object..." << oendl; | ||
213 | delete s; | 196 | delete s; |
@@ -217,3 +200,4 @@ int initApplication( int argc, char ** argv ) | |||
217 | #endif | 200 | #endif |
218 | 201 | ||
202 | odebug << "returning from qpe/initapplication..." << oendl; | ||
219 | return rv; | 203 | return rv; |
@@ -223,3 +207,3 @@ static const char *pidfile_path = "/var/run/opie.pid"; | |||
223 | 207 | ||
224 | void create_pidfile ( ) | 208 | void create_pidfile() |
225 | { | 209 | { |
@@ -227,5 +211,9 @@ void create_pidfile ( ) | |||
227 | 211 | ||
228 | if (( f = ::fopen ( pidfile_path, "w" ))) { | 212 | if (( f = ::fopen( pidfile_path, "w" ))) { |
229 | ::fprintf ( f, "%d", getpid ( )); | 213 | ::fprintf( f, "%d", getpid ( )); |
230 | ::fclose ( f ); | 214 | ::fclose( f ); |
215 | } | ||
216 | else | ||
217 | { | ||
218 | odebug << "couldn't create pidfile: " << strerror( errno ) << oendl; | ||
231 | } | 219 | } |
@@ -233,9 +221,10 @@ void create_pidfile ( ) | |||
233 | 221 | ||
234 | void remove_pidfile ( ) | 222 | void remove_pidfile() |
235 | { | 223 | { |
236 | ::unlink ( pidfile_path ); | 224 | ::unlink( pidfile_path ); |
237 | } | 225 | } |
238 | 226 | ||
239 | void handle_sigterm ( int /* sig */ ) | 227 | void handle_sigterm( int sig ) |
240 | { | 228 | { |
229 | qDebug( "D'oh! QPE Server process got SIGNAL %d. Trying to exit gracefully...", sig ); | ||
241 | ::signal( SIGCHLD, SIG_IGN ); | 230 | ::signal( SIGCHLD, SIG_IGN ); |
@@ -261,3 +250,2 @@ int main( int argc, char ** argv ) | |||
261 | ::atexit( remove_pidfile ); | 250 | ::atexit( remove_pidfile ); |
262 | create_pidfile(); | ||
263 | 251 | ||