summaryrefslogtreecommitdiff
authorsandman <sandman>2002-09-05 21:24:48 (UTC)
committer sandman <sandman>2002-09-05 21:24:48 (UTC)
commit70f3ed196a462eda3dd6554daddf210438aacc8a (patch) (unidiff)
treee19256fdc5ceaa5c0b4d1492e15fc42ee87d7692
parentbaea6aaf4f0c9672a4383470a9389bca1a20bdba (diff)
downloadopie-70f3ed196a462eda3dd6554daddf210438aacc8a.zip
opie-70f3ed196a462eda3dd6554daddf210438aacc8a.tar.gz
opie-70f3ed196a462eda3dd6554daddf210438aacc8a.tar.bz2
- remove obsolete cassiopeia and single-floppy code
- use the new ODevice setPowerButtonHandler() to set and reset power button handling
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp2
-rw-r--r--core/launcher/main.cpp132
2 files changed, 7 insertions, 127 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index bf19280..dee5535 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -600,48 +600,50 @@ static void darkScreen()
600 qpe_setBacklight(0); // force off 600 qpe_setBacklight(0); // force off
601} 601}
602 602
603 603
604void Desktop::togglePower() 604void Desktop::togglePower()
605{ 605{
606 extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop 606 extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop
607 607
608 static bool excllock = false; 608 static bool excllock = false;
609 609
610 if ( excllock ) 610 if ( excllock )
611 return; 611 return;
612 612
613 excllock = true; 613 excllock = true;
614 614
615 bool wasloggedin = loggedin; 615 bool wasloggedin = loggedin;
616 loggedin=0; 616 loggedin=0;
617 suspendTime = QDateTime::currentDateTime(); 617 suspendTime = QDateTime::currentDateTime();
618 618
619// qpe_setBacklight ( 0 ); // force LCD off (sandman: why ????) 619// qpe_setBacklight ( 0 ); // force LCD off (sandman: why ????)
620 620
621 if ( wasloggedin ) 621 if ( wasloggedin )
622 blankScreen(); 622 blankScreen();
623 623
624 qDebug ( "OPIE suspending\n" );
625
624 ODevice::inst ( )-> suspend ( ); 626 ODevice::inst ( )-> suspend ( );
625 627
626 QWSServer::screenSaverActivate ( false ); 628 QWSServer::screenSaverActivate ( false );
627 629
628 qpe_setBacklight ( -3 ); // force LCD on 630 qpe_setBacklight ( -3 ); // force LCD on
629 631
630 { 632 {
631 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 633 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
632 } 634 }
633 635
634 if ( wasloggedin ) 636 if ( wasloggedin )
635 login(TRUE); 637 login(TRUE);
636 638
637 execAutoStart(); 639 execAutoStart();
638 //qcopBridge->closeOpenConnections(); 640 //qcopBridge->closeOpenConnections();
639 641
640 excllock = false; 642 excllock = false;
641} 643}
642 644
643void Desktop::toggleLight() 645void Desktop::toggleLight()
644{ 646{
645 QCopEnvelope e("QPE/System", "setBacklight(int)"); 647 QCopEnvelope e("QPE/System", "setBacklight(int)");
646 e << -2; // toggle 648 e << -2; // toggle
647} 649}
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 5cf624b..ca0bbe4 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -20,162 +20,52 @@
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_CUSTOM ) || defined( QT_QWS_IPAQ ) 28#if defined( QT_QWS_CUSTOM ) || 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 <qfile.h> 34#include <qfile.h>
35#include <qwindowsystem_qws.h> 35#include <qwindowsystem_qws.h>
36#include <qpe/qcopenvelope_qws.h> 36#include <qpe/qcopenvelope_qws.h>
37#include <qpe/alarmserver.h> 37#include <qpe/alarmserver.h>
38 38
39#include <stdlib.h> 39#include <stdlib.h>
40#include <stdio.h> 40#include <stdio.h>
41#include <signal.h> 41#include <signal.h>
42#include <unistd.h> 42#include <unistd.h>
43 43
44#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 44#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
45#include "../calibrate/calibrate.h" 45#include "../calibrate/calibrate.h"
46#endif 46#endif
47 47
48#ifdef QT_QWS_CASSIOPEIA
49static void ignoreMessage( QtMsgType, const char * )
50{
51}
52#include <sys/mount.h>
53#include <sys/types.h>
54#include <sys/stat.h>
55#include <sys/time.h>
56#include <fcntl.h>
57#include <qdatetime.h>
58
59void initCassiopeia()
60{
61 // MIPSEL-specific init - make sure /proc exists for shm
62/*
63 if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) {
64 perror("Remounting - / read/write");
65 }
66*/
67 if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) {
68 perror("mounting ramfs /tmp");
69 } else {
70 fprintf( stderr, "mounted /tmp\n" );
71 }
72 if ( mount("none", "/home", "ramfs", 0, 0 ) ) {
73 perror("mounting ramfs /home");
74 } else {
75 fprintf( stderr, "mounted /home\n" );
76 }
77 if ( mount("none","/proc","proc",0,0) ) {
78 perror("Mounting - /proc");
79 } else {
80 fprintf( stderr, "mounted /proc\n" );
81 }
82 if ( mount("none","/mnt","shm",0,0) ) {
83 perror("Mounting - shm");
84 }
85 setenv( "QTDIR", "/", 1 );
86 setenv( "OPIEDIR", "/", 1 );
87 setenv( "HOME", "/home", 1 );
88 mkdir( "/home/Documents", 0755 );
89
90 // set a reasonable starting date
91 QDateTime dt( QDate( 2001, 3, 15 ) );
92 QDateTime now = QDateTime::currentDateTime();
93 int change = now.secsTo( dt );
94
95 time_t t = ::time(0);
96 t += change;
97 stime(&t);
98
99 qInstallMsgHandler(ignoreMessage);
100}
101#endif
102
103#ifdef QPE_OWNAPM
104#include <sys/ioctl.h>
105#include <sys/types.h>
106#include <fcntl.h>
107#include <unistd.h>
108#include <errno.h>
109#include <linux/ioctl.h>
110#include <qpe/global.h>
111
112static void disableAPM()
113{
114
115 int fd, cur_val, ret;
116 char *device = "/dev/apm_bios";
117
118 fd = open (device, O_WRONLY);
119
120 if (fd == -1) {
121 perror(device);
122 return;
123 }
124
125 cur_val = ioctl(fd, APM_IOCGEVTSRC, 0);
126 if (cur_val == -1) {
127 perror("ioctl");
128 exit(errno);
129 }
130
131 ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON);
132 if (ret == -1) {
133 perror("ioctl");
134 return;
135 }
136 close(fd);
137}
138
139static void initAPM()
140{
141 // So that we have to do it ourself, but better.
142 disableAPM();
143}
144#endif
145
146#ifdef QT_DEMO_SINGLE_FLOPPY
147#include <sys/mount.h>
148
149void initFloppy()
150{
151 mount("none","/proc","proc",0,0);
152 setenv( "QTDIR", "/", 0 );
153 setenv( "HOME", "/root", 0 );
154 setenv( "QWS_SIZE", "240x320", 0 );
155}
156#endif
157
158 48
159void initEnvironment() 49void initEnvironment()
160{ 50{
161 Config config("locale"); 51 Config config("locale");
162 config.setGroup( "Location" ); 52 config.setGroup( "Location" );
163 QString tz = config.readEntry( "Timezone", getenv("TZ") ); 53 QString tz = config.readEntry( "Timezone", getenv("TZ") );
164 54
165 // if not timezone set, pick New York 55 // if not timezone set, pick New York
166 if (tz.isNull()) 56 if (tz.isNull())
167 tz = "America/New_York"; 57 tz = "America/New_York";
168 58
169 setenv( "TZ", tz, 1 ); 59 setenv( "TZ", tz, 1 );
170 config.writeEntry( "Timezone", tz); 60 config.writeEntry( "Timezone", tz);
171 61
172 config.setGroup( "Language" ); 62 config.setGroup( "Language" );
173 QString lang = config.readEntry( "Language", getenv("LANG") ); 63 QString lang = config.readEntry( "Language", getenv("LANG") );
174 if ( !lang.isNull() ) 64 if ( !lang.isNull() )
175 setenv( "LANG", lang, 1 ); 65 setenv( "LANG", lang, 1 );
176} 66}
177 67
178static void initBacklight() 68static void initBacklight()
179{ 69{
180 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 70 QCopEnvelope e("QPE/System", "setBacklight(int)" );
181 e << -3; // Forced on 71 e << -3; // Forced on
@@ -252,136 +142,124 @@ public:
252 break; 142 break;
253 } 143 }
254 default: break; 144 default: break;
255 } 145 }
256 return kill; 146 return kill;
257 } 147 }
258 148
259 virtual void timerEvent ( QTimerEvent * ) 149 virtual void timerEvent ( QTimerEvent * )
260 { 150 {
261 killTimer ( m_power_timer ); 151 killTimer ( m_power_timer );
262 m_power_timer = 0; 152 m_power_timer = 0;
263 QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); 153 QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false );
264 QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); 154 QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false );
265 } 155 }
266 156
267private: 157private:
268 OModel m_model; 158 OModel m_model;
269 int m_power_timer; 159 int m_power_timer;
270}; 160};
271 161
272 162
273 163
274int initApplication( int argc, char ** argv ) 164int initApplication( int argc, char ** argv )
275{ 165{
276#ifdef QT_QWS_CASSIOPEIA 166 ODevice::inst ( )-> setPowerButtonHandler ( ODevice::OPIE );
277 initCassiopeia();
278#endif
279
280#ifdef QPE_OWNAPM
281 initAPM();
282#endif
283
284#ifdef QT_DEMO_SINGLE_FLOPPY
285 initFloppy();
286#endif
287 167
288 initEnvironment(); 168 initEnvironment();
289 169
290#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) 170#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX)
291 setenv( "QWS_SIZE", "240x320", 0 ); 171 setenv( "QWS_SIZE", "240x320", 0 );
292#endif 172#endif
293 173
294 //Don't flicker at startup: 174 //Don't flicker at startup:
295 QWSServer::setDesktopBackground( QImage() ); 175 QWSServer::setDesktopBackground( QImage() );
296 DesktopApplication a( argc, argv, QApplication::GuiServer ); 176 DesktopApplication a( argc, argv, QApplication::GuiServer );
297 177
298 (void) new ModelKeyFilter ( ); 178 (void) new ModelKeyFilter ( );
299 179
300 initBacklight(); 180 initBacklight();
301 181
302 AlarmServer::initialize(); 182 AlarmServer::initialize();
303 183
304 Desktop *d = new Desktop(); 184 Desktop *d = new Desktop();
305 185
306 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); 186 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) );
307 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); 187 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) );
308 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); 188 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) );
309 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); 189 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) );
310 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); 190 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) );
311 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); 191 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) );
312 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); 192 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) );
313 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); 193 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) );
314 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); 194 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) );
315 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); 195 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) );
316 196
317 (void)new SysFileMonitor(d); 197 (void)new SysFileMonitor(d);
318 Network::createServer(d); 198 Network::createServer(d);
319 199
320#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 200#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
321 if ( !QFile::exists( "/etc/pointercal" ) ) { 201 if ( !QFile::exists( "/etc/pointercal" ) ) {
322 // Make sure calibration widget starts on top. 202 // Make sure calibration widget starts on top.
323 Calibrate *cal = new Calibrate; 203 Calibrate *cal = new Calibrate;
324 cal->exec(); 204 cal->exec();
325 delete cal; 205 delete cal;
326 } 206 }
327#endif 207#endif
328 208
329 d->show(); 209 d->show();
330 210
331 int rv = a.exec(); 211 int rv = a.exec();
332 212
333 delete d; 213 delete d;
334 214
215 ODevice::inst ( )-> setPowerButtonHandler ( ODevice::KERNEL );
216
335 return rv; 217 return rv;
336} 218}
337 219
338static const char *pidfile_path = "/var/run/opie.pid"; 220static const char *pidfile_path = "/var/run/opie.pid";
339 221
340void create_pidfile ( ) 222void create_pidfile ( )
341{ 223{
342 FILE *f; 224 FILE *f;
343 225
344 if (( f = ::fopen ( pidfile_path, "w" ))) { 226 if (( f = ::fopen ( pidfile_path, "w" ))) {
345 ::fprintf ( f, "%d", getpid ( )); 227 ::fprintf ( f, "%d", getpid ( ));
346 ::fclose ( f ); 228 ::fclose ( f );
347 } 229 }
348} 230}
349 231
350void remove_pidfile ( ) 232void remove_pidfile ( )
351{ 233{
352 ::unlink ( pidfile_path ); 234 ::unlink ( pidfile_path );
353} 235}
354 236
355void handle_sigterm ( int /* sig */ ) 237void handle_sigterm ( int /* sig */ )
356{ 238{
357 if ( qApp ) 239 if ( qApp )
358 qApp-> quit ( ); 240 qApp-> quit ( );
359} 241}
360 242
361int main( int argc, char ** argv ) 243int main( int argc, char ** argv )
362{ 244{
363#ifndef SINGLE_APP
364 ::signal( SIGCHLD, SIG_IGN ); 245 ::signal( SIGCHLD, SIG_IGN );
365 246
366 ::signal ( SIGTERM, handle_sigterm ); 247 ::signal ( SIGTERM, handle_sigterm );
367 ::signal ( SIGINT, handle_sigterm ); 248 ::signal ( SIGINT, handle_sigterm );
368 249
369 ::setsid ( ); 250 ::setsid ( );
370 ::setpgid ( 0, 0 ); 251 ::setpgid ( 0, 0 );
371 252
372 ::atexit ( remove_pidfile ); 253 ::atexit ( remove_pidfile );
373 create_pidfile ( ); 254 create_pidfile ( );
374#endif
375 255
376 int retVal = initApplication ( argc, argv ); 256 int retVal = initApplication ( argc, argv );
377 257
378#ifndef SINGLE_APP
379 // Kill them. Kill them all. 258 // Kill them. Kill them all.
380 ::kill ( 0, SIGTERM ); 259 ::kill ( 0, SIGTERM );
381 ::sleep( 1 ); 260 ::sleep ( 1 );
382 ::kill ( 0, SIGKILL ); 261 ::kill ( 0, SIGKILL );
383#endif
384 262
385 return retVal; 263 return retVal;
386} 264}
387 265