summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-03-24 01:24:56 (UTC)
committer kergoth <kergoth>2003-03-24 01:24:56 (UTC)
commit1b4836ba28ca57947d37699fc67cddd74fb29fbe (patch) (unidiff)
treece940472f7ca14c5c7f0c88eebcf95ca953cfef9
parentc8205a610f350b8bde7c5aa0522944f0418f1fc9 (diff)
downloadopie-1b4836ba28ca57947d37699fc67cddd74fb29fbe.zip
opie-1b4836ba28ca57947d37699fc67cddd74fb29fbe.tar.gz
opie-1b4836ba28ca57947d37699fc67cddd74fb29fbe.tar.bz2
Remove ifdefs based on device as the means by which we decide to run calibrate, and instead check if the mouse handler inherits from QCalibratedMouseHandler.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/main.cpp14
-rw-r--r--core/opie-login/main.cpp14
2 files changed, 14 insertions, 14 deletions
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 8eaea17..64fb968 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -1,177 +1,177 @@
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 <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_SL5XXX) 46#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX)
47#include "../calibrate/calibrate.h" 47#include "../calibrate/calibrate.h"
48#endif 48#endif
49 49
50using namespace Opie; 50using namespace Opie;
51 51
52void initEnvironment() 52void 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
72int initApplication( int argc, char ** argv ) 72int 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_SL5XXX) 76#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_SL5XXX)
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(power()), d, SLOT(togglePower()) ); 95 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) );
96 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); 96 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) );
97 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); 97 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) );
98 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); 98 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) );
99 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); 99 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) );
100 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); 100 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) );
101 101
102 (void)new SysFileMonitor(d); 102 (void)new SysFileMonitor(d);
103 Network::createServer(d); 103 Network::createServer(d);
104 104
105#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) 105 if ( QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
106 if ( !QFile::exists( "/etc/pointercal" ) ) { 106 if ( !QFile::exists( "/etc/pointercal" ) ) {
107 // Make sure calibration widget starts on top. 107 // Make sure calibration widget starts on top.
108 Calibrate *cal = new Calibrate; 108 Calibrate *cal = new Calibrate;
109 cal->exec(); 109 cal->exec();
110 delete cal; 110 delete cal;
111 }
111 } 112 }
112#endif
113 113
114 d->show(); 114 d->show();
115 115
116 if ( QDate::currentDate ( ). year ( ) < 2000 ) { 116 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 ) { 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 ) {
118 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); 118 QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" );
119 e << QString ( ); 119 e << QString ( );
120 } 120 }
121 } 121 }
122 122
123 int rv = a.exec(); 123 int rv = a.exec();
124 124
125 delete d; 125 delete d;
126 126
127 ODevice::inst ( )-> setSoftSuspend ( false ); 127 ODevice::inst ( )-> setSoftSuspend ( false );
128 128
129 return rv; 129 return rv;
130} 130}
131 131
132static const char *pidfile_path = "/var/run/opie.pid"; 132static const char *pidfile_path = "/var/run/opie.pid";
133 133
134void create_pidfile ( ) 134void create_pidfile ( )
135{ 135{
136 FILE *f; 136 FILE *f;
137 137
138 if (( f = ::fopen ( pidfile_path, "w" ))) { 138 if (( f = ::fopen ( pidfile_path, "w" ))) {
139 ::fprintf ( f, "%d", getpid ( )); 139 ::fprintf ( f, "%d", getpid ( ));
140 ::fclose ( f ); 140 ::fclose ( f );
141 } 141 }
142} 142}
143 143
144void remove_pidfile ( ) 144void remove_pidfile ( )
145{ 145{
146 ::unlink ( pidfile_path ); 146 ::unlink ( pidfile_path );
147} 147}
148 148
149void handle_sigterm ( int /* sig */ ) 149void handle_sigterm ( int /* sig */ )
150{ 150{
151 if ( qApp ) 151 if ( qApp )
152 qApp-> quit ( ); 152 qApp-> quit ( );
153} 153}
154 154
155int main( int argc, char ** argv ) 155int main( int argc, char ** argv )
156{ 156{
157 ::signal ( SIGCHLD, SIG_IGN ); 157 ::signal ( SIGCHLD, SIG_IGN );
158 158
159 ::signal ( SIGTERM, handle_sigterm ); 159 ::signal ( SIGTERM, handle_sigterm );
160 ::signal ( SIGINT, handle_sigterm ); 160 ::signal ( SIGINT, handle_sigterm );
161 161
162 ::setsid ( ); 162 ::setsid ( );
163 ::setpgid ( 0, 0 ); 163 ::setpgid ( 0, 0 );
164 164
165 ::atexit ( remove_pidfile ); 165 ::atexit ( remove_pidfile );
166 create_pidfile ( ); 166 create_pidfile ( );
167 167
168 int retVal = initApplication ( argc, argv ); 168 int retVal = initApplication ( argc, argv );
169 169
170 // Kill them. Kill them all. 170 // Kill them. Kill them all.
171 ::kill ( 0, SIGTERM ); 171 ::kill ( 0, SIGTERM );
172 ::sleep ( 1 ); 172 ::sleep ( 1 );
173 ::kill ( 0, SIGKILL ); 173 ::kill ( 0, SIGKILL );
174 174
175 return retVal; 175 return retVal;
176} 176}
177 177
diff --git a/core/opie-login/main.cpp b/core/opie-login/main.cpp
index 1800be0..9c40fc4 100644
--- a/core/opie-login/main.cpp
+++ b/core/opie-login/main.cpp
@@ -198,171 +198,171 @@ int main ( int argc, char **argv )
198} 198}
199 199
200void sigterm ( int /*sig*/ ) 200void sigterm ( int /*sig*/ )
201{ 201{
202 ::exit ( 0 ); 202 ::exit ( 0 );
203} 203}
204 204
205 205
206void exit_closelog ( ) 206void exit_closelog ( )
207{ 207{
208 ::closelog ( ); 208 ::closelog ( );
209} 209}
210 210
211 211
212class LoginScreenSaver : public QWSScreenSaver 212class LoginScreenSaver : public QWSScreenSaver
213{ 213{
214public: 214public:
215 LoginScreenSaver ( ) 215 LoginScreenSaver ( )
216 { 216 {
217 m_lcd_status = true; 217 m_lcd_status = true;
218 218
219 m_backlight_bright = -1; 219 m_backlight_bright = -1;
220 m_backlight_forcedoff = false; 220 m_backlight_forcedoff = false;
221 221
222 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 222 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
223 ODevice::inst ( )-> setDisplayStatus ( true ); 223 ODevice::inst ( )-> setDisplayStatus ( true );
224 } 224 }
225 void restore() 225 void restore()
226 { 226 {
227 if ( !m_lcd_status ) // We must have turned it off 227 if ( !m_lcd_status ) // We must have turned it off
228 ODevice::inst ( ) -> setDisplayStatus ( true ); 228 ODevice::inst ( ) -> setDisplayStatus ( true );
229 229
230 setBacklight ( -3 ); 230 setBacklight ( -3 );
231 } 231 }
232 bool save( int level ) 232 bool save( int level )
233 { 233 {
234 switch ( level ) { 234 switch ( level ) {
235 case 0: 235 case 0:
236 if ( backlight() > 1 ) 236 if ( backlight() > 1 )
237 setBacklight( 1 ); // lowest non-off 237 setBacklight( 1 ); // lowest non-off
238 return true; 238 return true;
239 break; 239 break;
240 case 1: 240 case 1:
241 setBacklight( 0 ); // off 241 setBacklight( 0 ); // off
242 return true; 242 return true;
243 break; 243 break;
244 case 2: 244 case 2:
245 // We're going to suspend the whole machine 245 // We're going to suspend the whole machine
246 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) { 246 if ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) {
247 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 247 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
248 return true; 248 return true;
249 } 249 }
250 break; 250 break;
251 } 251 }
252 return false; 252 return false;
253 } 253 }
254 254
255private: 255private:
256public: 256public:
257 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 ) 257 void setIntervals( int i1 = 30, int i2 = 20, int i3 = 60 )
258 { 258 {
259 int v [4]; 259 int v [4];
260 260
261 v [ 0 ] = QMAX( 1000 * i1, 100 ); 261 v [ 0 ] = QMAX( 1000 * i1, 100 );
262 v [ 1 ] = QMAX( 1000 * i2, 100 ); 262 v [ 1 ] = QMAX( 1000 * i2, 100 );
263 v [ 2 ] = QMAX( 1000 * i3, 100 ); 263 v [ 2 ] = QMAX( 1000 * i3, 100 );
264 v [ 3 ] = 0; 264 v [ 3 ] = 0;
265 265
266 if ( !i1 && !i2 && !i3 ) 266 if ( !i1 && !i2 && !i3 )
267 QWSServer::setScreenSaverInterval ( 0 ); 267 QWSServer::setScreenSaverInterval ( 0 );
268 else 268 else
269 QWSServer::setScreenSaverIntervals ( v ); 269 QWSServer::setScreenSaverIntervals ( v );
270 } 270 }
271 271
272 int backlight ( ) 272 int backlight ( )
273 { 273 {
274 if ( m_backlight_bright == -1 ) 274 if ( m_backlight_bright == -1 )
275 m_backlight_bright = 255; 275 m_backlight_bright = 255;
276 276
277 return m_backlight_bright; 277 return m_backlight_bright;
278 } 278 }
279 279
280 void setBacklight ( int bright ) 280 void setBacklight ( int bright )
281 { 281 {
282 if ( bright == -3 ) { 282 if ( bright == -3 ) {
283 // Forced on 283 // Forced on
284 m_backlight_forcedoff = false; 284 m_backlight_forcedoff = false;
285 bright = -1; 285 bright = -1;
286 } 286 }
287 if ( m_backlight_forcedoff && bright != -2 ) 287 if ( m_backlight_forcedoff && bright != -2 )
288 return ; 288 return ;
289 if ( bright == -2 ) { 289 if ( bright == -2 ) {
290 // Toggle between off and on 290 // Toggle between off and on
291 bright = m_backlight_bright ? 0 : -1; 291 bright = m_backlight_bright ? 0 : -1;
292 m_backlight_forcedoff = !bright; 292 m_backlight_forcedoff = !bright;
293 } 293 }
294 294
295 m_backlight_bright = bright; 295 m_backlight_bright = bright;
296 296
297 bright = backlight ( ); 297 bright = backlight ( );
298 ODevice::inst ( ) -> setDisplayBrightness ( bright ); 298 ODevice::inst ( ) -> setDisplayBrightness ( bright );
299 299
300 m_backlight_bright = bright; 300 m_backlight_bright = bright;
301 } 301 }
302 302
303private: 303private:
304 bool m_lcd_status; 304 bool m_lcd_status;
305 305
306 int m_backlight_bright; 306 int m_backlight_bright;
307 bool m_backlight_forcedoff; 307 bool m_backlight_forcedoff;
308}; 308};
309 309
310 310
311namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting 311namespace Opie { extern int force_appearance; } // HACK to get around the force-style setting
312 312
313 313
314int login_main ( int argc, char **argv, pid_t ppid ) 314int login_main ( int argc, char **argv, pid_t ppid )
315{ 315{
316 QWSServer::setDesktopBackground( QImage() ); 316 QWSServer::setDesktopBackground( QImage() );
317 LoginApplication *app = new LoginApplication ( argc, argv, ppid ); 317 LoginApplication *app = new LoginApplication ( argc, argv, ppid );
318 318
319 Opie::force_appearance = 0; 319 Opie::force_appearance = 0;
320 320
321 app-> setFont ( QFont ( "Helvetica", 10 )); 321 app-> setFont ( QFont ( "Helvetica", 10 ));
322 app-> setStyle ( new QPEStyle ( )); 322 app-> setStyle ( new QPEStyle ( ));
323 323
324 ODevice::inst ( )-> setSoftSuspend ( true ); 324 ODevice::inst ( )-> setSoftSuspend ( true );
325 325
326#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) 326 if ( QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) {
327 if ( !QFile::exists ( "/etc/pointercal" )) { 327 if ( !QFile::exists ( "/etc/pointercal" )) {
328 // Make sure calibration widget starts on top. 328 // Make sure calibration widget starts on top.
329 Calibrate *cal = new Calibrate; 329 Calibrate *cal = new Calibrate;
330 cal-> exec ( ); 330 cal-> exec ( );
331 delete cal; 331 delete cal;
332 }
332 } 333 }
333#endif
334 334
335 LoginScreenSaver *saver = new LoginScreenSaver; 335 LoginScreenSaver *saver = new LoginScreenSaver;
336 336
337 saver-> setIntervals ( ); 337 saver-> setIntervals ( );
338 QWSServer::setScreenSaver ( saver ); 338 QWSServer::setScreenSaver ( saver );
339 saver-> restore ( ); 339 saver-> restore ( );
340 340
341 341
342 LoginWindowImpl *lw = new LoginWindowImpl ( ); 342 LoginWindowImpl *lw = new LoginWindowImpl ( );
343 app-> setMainWidget ( lw ); 343 app-> setMainWidget ( lw );
344 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( )); 344 lw-> setGeometry ( 0, 0, app-> desktop ( )-> width ( ), app-> desktop ( )-> height ( ));
345 lw-> show ( ); 345 lw-> show ( );
346 346
347 int rc = app-> exec ( ); 347 int rc = app-> exec ( );
348 348
349 ODevice::inst ( )-> setSoftSuspend ( false ); 349 ODevice::inst ( )-> setSoftSuspend ( false );
350 350
351 if ( app-> loginAs ( )) { 351 if ( app-> loginAs ( )) {
352 if ( app-> changeIdentity ( )) { 352 if ( app-> changeIdentity ( )) {
353 app-> login ( ); 353 app-> login ( );
354 354
355 // if login succeeds, it never comes back 355 // if login succeeds, it never comes back
356 356
357 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start OPIE." )); 357 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not start OPIE." ));
358 rc = 1; 358 rc = 1;
359 } 359 }
360 else { 360 else {
361 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" )); 361 QMessageBox::critical ( 0, LoginWindowImpl::tr( "Failure" ), LoginWindowImpl::tr( "Could not switch to new user identity" ));
362 rc = 2; 362 rc = 2;
363 } 363 }
364 364
365 } 365 }
366 return rc; 366 return rc;
367} 367}
368 368