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