-rw-r--r-- | core/launcher/main.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 0b38738..fa4df3c 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -1,195 +1,196 @@ | |||
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_SL5XXX ) || defined( QT_QWS_IPAQ ) | 28 | #if defined( QT_QWS_SL5XXX ) || 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 <qwsmouse_qws.h> | 38 | #include <qwsmouse_qws.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/alarmserver.h> | 40 | #include <qpe/alarmserver.h> |
41 | 41 | ||
42 | #include <stdlib.h> | 42 | #include <stdlib.h> |
43 | #include <stdio.h> | 43 | #include <stdio.h> |
44 | #include <signal.h> | 44 | #include <signal.h> |
45 | #include <unistd.h> | 45 | #include <unistd.h> |
46 | 46 | ||
47 | #include "../calibrate/calibrate.h" | 47 | #include "../calibrate/calibrate.h" |
48 | 48 | ||
49 | using namespace Opie; | 49 | using namespace Opie; |
50 | 50 | ||
51 | void initEnvironment() | 51 | void initEnvironment() |
52 | { | 52 | { |
53 | int rot; | 53 | int rot; |
54 | Config config("locale"); | 54 | Config config("locale"); |
55 | 55 | ||
56 | config.setGroup( "Location" ); | 56 | config.setGroup( "Location" ); |
57 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); | 57 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); |
58 | 58 | ||
59 | // if not timezone set, pick New York | 59 | // if not timezone set, pick New York |
60 | if (tz.isNull()) | 60 | if (tz.isNull()) |
61 | tz = "America/New_York"; | 61 | tz = "America/New_York"; |
62 | 62 | ||
63 | setenv( "TZ", tz, 1 ); | 63 | setenv( "TZ", tz, 1 ); |
64 | config.writeEntry( "Timezone", tz); | 64 | config.writeEntry( "Timezone", tz); |
65 | 65 | ||
66 | config.setGroup( "Language" ); | 66 | config.setGroup( "Language" ); |
67 | QString lang = config.readEntry( "Language", getenv("LANG") ); | 67 | QString lang = config.readEntry( "Language", getenv("LANG") ); |
68 | if ( !lang.isNull() ) | 68 | if ( !lang.isNull() ) |
69 | setenv( "LANG", lang, 1 ); | 69 | setenv( "LANG", lang, 1 ); |
70 | 70 | ||
71 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_SL5XXX) | 71 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_SL5XXX) |
72 | setenv( "QWS_SIZE", "240x320", 0 ); | 72 | setenv( "QWS_SIZE", "240x320", 0 ); |
73 | #endif | 73 | #endif |
74 | 74 | ||
75 | /* | 75 | /* |
76 | * Rotation: | 76 | * Rotation: |
77 | * 1. use env var if set | 77 | * 1. use env var if set |
78 | * 2. use saved default if set | 78 | * 2. use saved default if set |
79 | * 3. use physical orientation (currently fails due to ODevice | 79 | * 3. use physical orientation (currently fails due to ODevice |
80 | * using a QPixmap and therefore requiring a QApplication) | 80 | * using a QPixmap and therefore requiring a QApplication) |
81 | */ | 81 | */ |
82 | if ( ( rot = QPEApplication::defaultRotation ( ) ) == 0 ) { | 82 | if ( ( rot = QPEApplication::defaultRotation ( ) ) == 0 ) { |
83 | Config config("qpe"); | 83 | Config config("qpe"); |
84 | config.setGroup( "Rotation" ); | 84 | config.setGroup( "Rotation" ); |
85 | if ( ( rot = config.readNumEntry( "Rot", -1 ) ) == -1 ) | 85 | if ( ( rot = config.readNumEntry( "Rot", -1 ) ) == -1 ) |
86 | rot = ODevice::inst ( )-> rotation ( ) * 90; | 86 | rot = ODevice::inst ( )-> rotation ( ) * 90; |
87 | } | 87 | } |
88 | 88 | ||
89 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); | 89 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); |
90 | QPEApplication::defaultRotation ( ); /* to ensure deforient matches reality */ | ||
90 | } | 91 | } |
91 | 92 | ||
92 | 93 | ||
93 | int initApplication( int argc, char ** argv ) | 94 | int initApplication( int argc, char ** argv ) |
94 | { | 95 | { |
95 | initEnvironment(); | 96 | initEnvironment(); |
96 | 97 | ||
97 | //Don't flicker at startup: | 98 | //Don't flicker at startup: |
98 | QWSServer::setDesktopBackground( QImage() ); | 99 | QWSServer::setDesktopBackground( QImage() ); |
99 | 100 | ||
100 | DesktopApplication a( argc, argv, QApplication::GuiServer ); | 101 | DesktopApplication a( argc, argv, QApplication::GuiServer ); |
101 | 102 | ||
102 | ODevice::inst ( )-> setSoftSuspend ( true ); | 103 | ODevice::inst ( )-> setSoftSuspend ( true ); |
103 | 104 | ||
104 | { // init backlight | 105 | { // init backlight |
105 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | 106 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); |
106 | e << -3; // Forced on | 107 | e << -3; // Forced on |
107 | } | 108 | } |
108 | 109 | ||
109 | AlarmServer::initialize(); | 110 | AlarmServer::initialize(); |
110 | 111 | ||
111 | Desktop *d = new Desktop(); | 112 | Desktop *d = new Desktop(); |
112 | 113 | ||
113 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); | 114 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); |
114 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); | 115 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); |
115 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); | 116 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); |
116 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); | 117 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); |
117 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); | 118 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); |
118 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); | 119 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); |
119 | 120 | ||
120 | (void)new SysFileMonitor(d); | 121 | (void)new SysFileMonitor(d); |
121 | Network::createServer(d); | 122 | Network::createServer(d); |
122 | 123 | ||
123 | if ( QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { | 124 | if ( QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { |
124 | if ( !QFile::exists( "/etc/pointercal" ) ) { | 125 | if ( !QFile::exists( "/etc/pointercal" ) ) { |
125 | // Make sure calibration widget starts on top. | 126 | // Make sure calibration widget starts on top. |
126 | Calibrate *cal = new Calibrate; | 127 | Calibrate *cal = new Calibrate; |
127 | cal->exec(); | 128 | cal->exec(); |
128 | delete cal; | 129 | delete cal; |
129 | } | 130 | } |
130 | } | 131 | } |
131 | 132 | ||
132 | d->show(); | 133 | d->show(); |
133 | 134 | ||
134 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { | 135 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { |
135 | 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 ) { | 136 | 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 ) { |
136 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); | 137 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); |
137 | e << QString ( ); | 138 | e << QString ( ); |
138 | } | 139 | } |
139 | } | 140 | } |
140 | 141 | ||
141 | int rv = a.exec(); | 142 | int rv = a.exec(); |
142 | 143 | ||
143 | delete d; | 144 | delete d; |
144 | 145 | ||
145 | ODevice::inst ( )-> setSoftSuspend ( false ); | 146 | ODevice::inst ( )-> setSoftSuspend ( false ); |
146 | 147 | ||
147 | return rv; | 148 | return rv; |
148 | } | 149 | } |
149 | 150 | ||
150 | static const char *pidfile_path = "/var/run/opie.pid"; | 151 | static const char *pidfile_path = "/var/run/opie.pid"; |
151 | 152 | ||
152 | void create_pidfile ( ) | 153 | void create_pidfile ( ) |
153 | { | 154 | { |
154 | FILE *f; | 155 | FILE *f; |
155 | 156 | ||
156 | if (( f = ::fopen ( pidfile_path, "w" ))) { | 157 | if (( f = ::fopen ( pidfile_path, "w" ))) { |
157 | ::fprintf ( f, "%d", getpid ( )); | 158 | ::fprintf ( f, "%d", getpid ( )); |
158 | ::fclose ( f ); | 159 | ::fclose ( f ); |
159 | } | 160 | } |
160 | } | 161 | } |
161 | 162 | ||
162 | void remove_pidfile ( ) | 163 | void remove_pidfile ( ) |
163 | { | 164 | { |
164 | ::unlink ( pidfile_path ); | 165 | ::unlink ( pidfile_path ); |
165 | } | 166 | } |
166 | 167 | ||
167 | void handle_sigterm ( int /* sig */ ) | 168 | void handle_sigterm ( int /* sig */ ) |
168 | { | 169 | { |
169 | if ( qApp ) | 170 | if ( qApp ) |
170 | qApp-> quit ( ); | 171 | qApp-> quit ( ); |
171 | } | 172 | } |
172 | 173 | ||
173 | int main( int argc, char ** argv ) | 174 | int main( int argc, char ** argv ) |
174 | { | 175 | { |
175 | ::signal ( SIGCHLD, SIG_IGN ); | 176 | ::signal ( SIGCHLD, SIG_IGN ); |
176 | 177 | ||
177 | ::signal ( SIGTERM, handle_sigterm ); | 178 | ::signal ( SIGTERM, handle_sigterm ); |
178 | ::signal ( SIGINT, handle_sigterm ); | 179 | ::signal ( SIGINT, handle_sigterm ); |
179 | 180 | ||
180 | ::setsid ( ); | 181 | ::setsid ( ); |
181 | ::setpgid ( 0, 0 ); | 182 | ::setpgid ( 0, 0 ); |
182 | 183 | ||
183 | ::atexit ( remove_pidfile ); | 184 | ::atexit ( remove_pidfile ); |
184 | create_pidfile ( ); | 185 | create_pidfile ( ); |
185 | 186 | ||
186 | int retVal = initApplication ( argc, argv ); | 187 | int retVal = initApplication ( argc, argv ); |
187 | 188 | ||
188 | // Kill them. Kill them all. | 189 | // Kill them. Kill them all. |
189 | ::kill ( 0, SIGTERM ); | 190 | ::kill ( 0, SIGTERM ); |
190 | ::sleep ( 1 ); | 191 | ::sleep ( 1 ); |
191 | ::kill ( 0, SIGKILL ); | 192 | ::kill ( 0, SIGKILL ); |
192 | 193 | ||
193 | return retVal; | 194 | return retVal; |
194 | } | 195 | } |
195 | 196 | ||