summaryrefslogtreecommitdiff
path: root/core/launcher
authormickeyl <mickeyl>2005-01-23 20:30:10 (UTC)
committer mickeyl <mickeyl>2005-01-23 20:30:10 (UTC)
commitab0242ff1bbc40ec8bc38c3cb748a44797ffe3db (patch) (unidiff)
treef9d2e15eb124bf3d39a90c25811c9609d9fd1db0 /core/launcher
parent8f2fbef1de1b3803a21d51752fee1014c951cc12 (diff)
downloadopie-ab0242ff1bbc40ec8bc38c3cb748a44797ffe3db.zip
opie-ab0242ff1bbc40ec8bc38c3cb748a44797ffe3db.tar.gz
opie-ab0242ff1bbc40ec8bc38c3cb748a44797ffe3db.tar.bz2
New QWS_DISPLAY handling for gathering the default launcher rotation on startup:
1.) If QWS_DISPLAY is not set, then use ODevice::rotation() 2.) If QWS_DISPLAY is set, then just use whatever it is set to
Diffstat (limited to 'core/launcher') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/main.cpp142
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
@@ -1,7 +1,6 @@
1/********************************************************************** 1/**********************************************************************
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**
6** This file may be distributed and/or modified under the terms of the 5** 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 6** GNU General Public License version 2 as published by the Free Software
@@ -10,12 +9,6 @@
10** 9**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 10** 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. 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**********************************************************************/
20 13
21#ifndef QTOPIA_INTERNAL_FILEOPERATIONS 14#ifndef QTOPIA_INTERNAL_FILEOPERATIONS
@@ -53,11 +46,12 @@ using namespace Opie::Core;
53#include <stdlib.h> 46#include <stdlib.h>
54#include <stdio.h> 47#include <stdio.h>
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
53void create_pidfile();
54void remove_pidfile();
61 55
62static void cleanup() 56static void cleanup()
63{ 57{
@@ -70,50 +64,41 @@ static void cleanup()
70 } 64 }
71} 65}
72 66
73static void refreshTimeZoneConfig()
74{
75 /* ### FIXME timezone handling for qtopia */
76}
77
78void initEnvironment() 67void 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");
85 config.setGroup( "Location" ); 70 config.setGroup( "Location" );
86 QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); 71 QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace();
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 );
93 config.writeEntry( "Timezone", tz); 76 config.writeEntry( "Timezone", tz);
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 );
101 config.writeEntry("Language", lang); 83 config.writeEntry("Language", lang);
102 config.write(); 84 config.write();
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}
118 103
119static void initKeyboard() 104static void initKeyboard()
@@ -159,85 +144,89 @@ static bool firstUse()
159int initApplication( int argc, char ** argv ) 144int initApplication( int argc, char ** argv )
160{ 145{
161 cleanup(); 146 cleanup();
162
163
164 initEnvironment(); 147 initEnvironment();
165 148
166 //Don't flicker at startup:
167#ifdef QWS 149#ifdef QWS
168 QWSServer::setDesktopBackground( QImage() ); 150 QWSServer::setDesktopBackground( QImage() );
169#endif 151#endif
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 }
188 168
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
197 Network::createServer(s); 173 Network::createServer(s);
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;
214 197
215#ifndef Q_OS_MACX 198#ifndef Q_OS_MACX
216 ODevice::inst()->setSoftSuspend( false ); 199 ODevice::inst()->setSoftSuspend( false );
217#endif 200#endif
218 201
202 odebug << "returning from qpe/initapplication..." << oendl;
219 return rv; 203 return rv;
220} 204}
221 205
222static const char *pidfile_path = "/var/run/opie.pid"; 206static const char *pidfile_path = "/var/run/opie.pid";
223 207
224void create_pidfile ( ) 208void create_pidfile()
225{ 209{
226 FILE *f; 210 FILE *f;
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 }
232} 220}
233 221
234void remove_pidfile ( ) 222void remove_pidfile()
235{ 223{
236 ::unlink ( pidfile_path ); 224 ::unlink( pidfile_path );
237} 225}
238 226
239void handle_sigterm ( int /* sig */ ) 227void 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 );
242 ::signal( SIGSEGV, SIG_IGN ); 231 ::signal( SIGSEGV, SIG_IGN );
243 ::signal( SIGBUS, SIG_IGN ); 232 ::signal( SIGBUS, SIG_IGN );
@@ -259,7 +248,6 @@ int main( int argc, char ** argv )
259 ::setpgid( 0, 0 ); 248 ::setpgid( 0, 0 );
260 249
261 ::atexit( remove_pidfile ); 250 ::atexit( remove_pidfile );
262 create_pidfile();
263 251
264 int retVal = initApplication( argc, argv ); 252 int retVal = initApplication( argc, argv );
265 253