summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/main.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 1e741d5..3ee5e26 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -48,337 +48,339 @@
48#ifdef QT_QWS_CASSIOPEIA 48#ifdef QT_QWS_CASSIOPEIA
49static void ignoreMessage( QtMsgType, const char * ) 49static void ignoreMessage( QtMsgType, const char * )
50{ 50{
51} 51}
52#include <sys/mount.h> 52#include <sys/mount.h>
53#include <sys/types.h> 53#include <sys/types.h>
54#include <sys/stat.h> 54#include <sys/stat.h>
55#include <sys/time.h> 55#include <sys/time.h>
56#include <fcntl.h> 56#include <fcntl.h>
57#include <qdatetime.h> 57#include <qdatetime.h>
58 58
59void initCassiopeia() 59void initCassiopeia()
60{ 60{
61 // MIPSEL-specific init - make sure /proc exists for shm 61 // MIPSEL-specific init - make sure /proc exists for shm
62/* 62/*
63 if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) { 63 if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) {
64 perror("Remounting - / read/write"); 64 perror("Remounting - / read/write");
65 } 65 }
66*/ 66*/
67 if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) { 67 if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) {
68 perror("mounting ramfs /tmp"); 68 perror("mounting ramfs /tmp");
69 } else { 69 } else {
70 fprintf( stderr, "mounted /tmp\n" ); 70 fprintf( stderr, "mounted /tmp\n" );
71 } 71 }
72 if ( mount("none", "/home", "ramfs", 0, 0 ) ) { 72 if ( mount("none", "/home", "ramfs", 0, 0 ) ) {
73 perror("mounting ramfs /home"); 73 perror("mounting ramfs /home");
74 } else { 74 } else {
75 fprintf( stderr, "mounted /home\n" ); 75 fprintf( stderr, "mounted /home\n" );
76 } 76 }
77 if ( mount("none","/proc","proc",0,0) ) { 77 if ( mount("none","/proc","proc",0,0) ) {
78 perror("Mounting - /proc"); 78 perror("Mounting - /proc");
79 } else { 79 } else {
80 fprintf( stderr, "mounted /proc\n" ); 80 fprintf( stderr, "mounted /proc\n" );
81 } 81 }
82 if ( mount("none","/mnt","shm",0,0) ) { 82 if ( mount("none","/mnt","shm",0,0) ) {
83 perror("Mounting - shm"); 83 perror("Mounting - shm");
84 } 84 }
85 setenv( "QTDIR", "/", 1 ); 85 setenv( "QTDIR", "/", 1 );
86 setenv( "OPIEDIR", "/", 1 ); 86 setenv( "OPIEDIR", "/", 1 );
87 setenv( "HOME", "/home", 1 ); 87 setenv( "HOME", "/home", 1 );
88 mkdir( "/home/Documents", 0755 ); 88 mkdir( "/home/Documents", 0755 );
89 89
90 // set a reasonable starting date 90 // set a reasonable starting date
91 QDateTime dt( QDate( 2001, 3, 15 ) ); 91 QDateTime dt( QDate( 2001, 3, 15 ) );
92 QDateTime now = QDateTime::currentDateTime(); 92 QDateTime now = QDateTime::currentDateTime();
93 int change = now.secsTo( dt ); 93 int change = now.secsTo( dt );
94 94
95 time_t t = ::time(0); 95 time_t t = ::time(0);
96 t += change; 96 t += change;
97 stime(&t); 97 stime(&t);
98 98
99 qInstallMsgHandler(ignoreMessage); 99 qInstallMsgHandler(ignoreMessage);
100} 100}
101#endif 101#endif
102 102
103#ifdef QPE_OWNAPM 103#ifdef QPE_OWNAPM
104#include <sys/ioctl.h> 104#include <sys/ioctl.h>
105#include <sys/types.h> 105#include <sys/types.h>
106#include <fcntl.h> 106#include <fcntl.h>
107#include <unistd.h> 107#include <unistd.h>
108#include <errno.h> 108#include <errno.h>
109#include <linux/ioctl.h> 109#include <linux/ioctl.h>
110#include <qpe/global.h> 110#include <qpe/global.h>
111 111
112static void disableAPM() 112static void disableAPM()
113{ 113{
114 114
115 int fd, cur_val, ret; 115 int fd, cur_val, ret;
116 char *device = "/dev/apm_bios"; 116 char *device = "/dev/apm_bios";
117 117
118 fd = open (device, O_WRONLY); 118 fd = open (device, O_WRONLY);
119 119
120 if (fd == -1) { 120 if (fd == -1) {
121 perror(device); 121 perror(device);
122 return; 122 return;
123 } 123 }
124 124
125 cur_val = ioctl(fd, APM_IOCGEVTSRC, 0); 125 cur_val = ioctl(fd, APM_IOCGEVTSRC, 0);
126 if (cur_val == -1) { 126 if (cur_val == -1) {
127 perror("ioctl"); 127 perror("ioctl");
128 exit(errno); 128 exit(errno);
129 } 129 }
130 130
131 ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON); 131 ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON);
132 if (ret == -1) { 132 if (ret == -1) {
133 perror("ioctl"); 133 perror("ioctl");
134 return; 134 return;
135 } 135 }
136 close(fd); 136 close(fd);
137} 137}
138 138
139static void initAPM() 139static void initAPM()
140{ 140{
141 // So that we have to do it ourself, but better. 141 // So that we have to do it ourself, but better.
142 disableAPM(); 142 disableAPM();
143} 143}
144#endif 144#endif
145 145
146#ifdef QT_DEMO_SINGLE_FLOPPY 146#ifdef QT_DEMO_SINGLE_FLOPPY
147#include <sys/mount.h> 147#include <sys/mount.h>
148 148
149void initFloppy() 149void initFloppy()
150{ 150{
151 mount("none","/proc","proc",0,0); 151 mount("none","/proc","proc",0,0);
152 setenv( "QTDIR", "/", 0 ); 152 setenv( "QTDIR", "/", 0 );
153 setenv( "HOME", "/root", 0 ); 153 setenv( "HOME", "/root", 0 );
154 setenv( "QWS_SIZE", "240x320", 0 ); 154 setenv( "QWS_SIZE", "240x320", 0 );
155} 155}
156#endif 156#endif
157 157
158 158
159void initEnvironment() 159void initEnvironment()
160{ 160{
161 Config config("locale"); 161 Config config("locale");
162 config.setGroup( "Location" ); 162 config.setGroup( "Location" );
163 QString tz = config.readEntry( "Timezone", getenv("TZ") ); 163 QString tz = config.readEntry( "Timezone", getenv("TZ") );
164 164
165 // if not timezone set, pick New York 165 // if not timezone set, pick New York
166 if (tz.isNull()) 166 if (tz.isNull())
167 tz = "America/New_York"; 167 tz = "America/New_York";
168 168
169 setenv( "TZ", tz, 1 ); 169 setenv( "TZ", tz, 1 );
170 config.writeEntry( "Timezone", tz); 170 config.writeEntry( "Timezone", tz);
171 171
172 config.setGroup( "Language" ); 172 config.setGroup( "Language" );
173 QString lang = config.readEntry( "Language", getenv("LANG") ); 173 QString lang = config.readEntry( "Language", getenv("LANG") );
174 if ( !lang.isNull() ) 174 if ( !lang.isNull() )
175 setenv( "LANG", lang, 1 ); 175 setenv( "LANG", lang, 1 );
176} 176}
177 177
178static void initBacklight() 178static void initBacklight()
179{ 179{
180 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 180 QCopEnvelope e("QPE/System", "setBacklight(int)" );
181 e << -3; // Forced on 181 e << -3; // Forced on
182} 182}
183 183
184 184
185class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter 185class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter
186{ 186{
187public: 187public:
188 ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) 188 ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" )
189 { 189 {
190 bool doinst = false; 190 bool doinst = false;
191 191
192 m_model = ODevice::inst ( )-> model ( ); 192 m_model = ODevice::inst ( )-> model ( );
193 m_power_timer = 0; 193 m_power_timer = 0;
194 194
195 switch ( m_model ) { 195 switch ( m_model ) {
196 case OMODEL_iPAQ_H31xx: 196 case OMODEL_iPAQ_H31xx:
197 case OMODEL_iPAQ_H36xx: 197 case OMODEL_iPAQ_H36xx:
198 case OMODEL_iPAQ_H37xx: 198 case OMODEL_iPAQ_H37xx:
199 case OMODEL_iPAQ_H38xx: doinst = true; 199 case OMODEL_iPAQ_H38xx: doinst = true;
200 break; 200 break;
201 default : break; 201 default : break;
202 } 202 }
203 if ( doinst ) 203 if ( doinst )
204 QWSServer::setKeyboardFilter ( this ); 204 QWSServer::setKeyboardFilter ( this );
205 } 205 }
206 206
207 virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 207 virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
208 { 208 {
209 bool kill = false; 209 bool kill = false;
210 210
211 // Rotate cursor keys 180° 211 // Rotate cursor keys 180°
212 switch ( m_model ) { 212 switch ( m_model ) {
213 case OMODEL_iPAQ_H31xx: 213 case OMODEL_iPAQ_H31xx:
214 case OMODEL_iPAQ_H38xx: { 214 case OMODEL_iPAQ_H38xx: {
215 int newkeycode = keycode; 215 int newkeycode = keycode;
216 216
217 switch ( keycode ) { 217 switch ( keycode ) {
218 case Key_Left : newkeycode = Key_Right; break; 218 case Key_Left : newkeycode = Key_Right; break;
219 case Key_Right: newkeycode = Key_Left; break; 219 case Key_Right: newkeycode = Key_Left; break;
220 case Key_Up : newkeycode = Key_Down; break; 220 case Key_Up : newkeycode = Key_Down; break;
221 case Key_Down : newkeycode = Key_Up; break; 221 case Key_Down : newkeycode = Key_Up; break;
222 } 222 }
223 if ( newkeycode != keycode ) { 223 if ( newkeycode != keycode ) {
224 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 224 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
225 kill = true; 225 kill = true;
226 } 226 }
227 break; 227 break;
228 } 228 }
229 default: break; 229 default: break;
230 } 230 }
231 231
232 // map Power Button short/long press to F34/F35 232 // map Power Button short/long press to F34/F35
233 switch ( m_model ) { 233 switch ( m_model ) {
234 case OMODEL_iPAQ_H31xx: 234 case OMODEL_iPAQ_H31xx:
235 case OMODEL_iPAQ_H36xx: 235 case OMODEL_iPAQ_H36xx:
236 case OMODEL_iPAQ_H37xx: 236 case OMODEL_iPAQ_H37xx:
237 case OMODEL_iPAQ_H38xx: { 237 case OMODEL_iPAQ_H38xx: {
238 if ( keycode == Key_SysReq ) { 238 if ( keycode == Key_SysReq ) {
239 if ( isPress ) { 239 if ( isPress ) {
240 if ( m_power_timer )
241 killTimer ( m_power_timer );
240 m_power_timer = startTimer ( 500 ); 242 m_power_timer = startTimer ( 500 );
241 } 243 }
242 else if ( m_power_timer ) { 244 else if ( m_power_timer ) {
243 killTimer ( m_power_timer ); 245 killTimer ( m_power_timer );
244 m_power_timer = 0; 246 m_power_timer = 0;
245 QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); 247 QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false );
246 QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); 248 QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false );
247 } 249 }
248 kill = true; 250 kill = true;
249 } 251 }
250 break; 252 break;
251 } 253 }
252 default: break; 254 default: break;
253 } 255 }
254 return kill; 256 return kill;
255 } 257 }
256 258
257 virtual void timerEvent ( QTimerEvent * ) 259 virtual void timerEvent ( QTimerEvent * )
258 { 260 {
259 killTimer ( m_power_timer ); 261 killTimer ( m_power_timer );
260 m_power_timer = 0; 262 m_power_timer = 0;
261 QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); 263 QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false );
262 QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); 264 QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false );
263 } 265 }
264 266
265private: 267private:
266 OModel m_model; 268 OModel m_model;
267 int m_power_timer; 269 int m_power_timer;
268}; 270};
269 271
270 272
271 273
272int initApplication( int argc, char ** argv ) 274int initApplication( int argc, char ** argv )
273{ 275{
274#ifdef QT_QWS_CASSIOPEIA 276#ifdef QT_QWS_CASSIOPEIA
275 initCassiopeia(); 277 initCassiopeia();
276#endif 278#endif
277 279
278#ifdef QPE_OWNAPM 280#ifdef QPE_OWNAPM
279 initAPM(); 281 initAPM();
280#endif 282#endif
281 283
282#ifdef QT_DEMO_SINGLE_FLOPPY 284#ifdef QT_DEMO_SINGLE_FLOPPY
283 initFloppy(); 285 initFloppy();
284#endif 286#endif
285 287
286 initEnvironment(); 288 initEnvironment();
287 289
288#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) 290#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX)
289 setenv( "QWS_SIZE", "240x320", 0 ); 291 setenv( "QWS_SIZE", "240x320", 0 );
290#endif 292#endif
291 293
292 //Don't flicker at startup: 294 //Don't flicker at startup:
293 QWSServer::setDesktopBackground( QImage() ); 295 QWSServer::setDesktopBackground( QImage() );
294 DesktopApplication a( argc, argv, QApplication::GuiServer ); 296 DesktopApplication a( argc, argv, QApplication::GuiServer );
295 297
296 (void) new ModelKeyFilter ( ); 298 (void) new ModelKeyFilter ( );
297 299
298 initBacklight(); 300 initBacklight();
299 301
300 AlarmServer::initialize(); 302 AlarmServer::initialize();
301 303
302 Desktop *d = new Desktop(); 304 Desktop *d = new Desktop();
303 305
304 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); 306 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) );
305 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); 307 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) );
306 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); 308 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) );
307 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); 309 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) );
308 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); 310 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) );
309 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); 311 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) );
310 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); 312 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) );
311 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); 313 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) );
312 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); 314 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) );
313 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); 315 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) );
314 316
315 (void)new SysFileMonitor(d); 317 (void)new SysFileMonitor(d);
316 Network::createServer(d); 318 Network::createServer(d);
317 319
318#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 320#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
319 if ( !QFile::exists( "/etc/pointercal" ) ) { 321 if ( !QFile::exists( "/etc/pointercal" ) ) {
320 // Make sure calibration widget starts on top. 322 // Make sure calibration widget starts on top.
321 Calibrate *cal = new Calibrate; 323 Calibrate *cal = new Calibrate;
322 cal->exec(); 324 cal->exec();
323 delete cal; 325 delete cal;
324 } 326 }
325#endif 327#endif
326 328
327 d->show(); 329 d->show();
328 330
329 int rv = a.exec(); 331 int rv = a.exec();
330 332
331 delete d; 333 delete d;
332 334
333 return rv; 335 return rv;
334} 336}
335 337
336static const char *pidfile_path = "/var/run/opie.pid"; 338static const char *pidfile_path = "/var/run/opie.pid";
337 339
338void create_pidfile ( ) 340void create_pidfile ( )
339{ 341{
340 FILE *f; 342 FILE *f;
341 343
342 if (( f = ::fopen ( pidfile_path, "w" ))) { 344 if (( f = ::fopen ( pidfile_path, "w" ))) {
343 ::fprintf ( f, "%d", getpid ( )); 345 ::fprintf ( f, "%d", getpid ( ));
344 ::fclose ( f ); 346 ::fclose ( f );
345 } 347 }
346} 348}
347 349
348void remove_pidfile ( ) 350void remove_pidfile ( )
349{ 351{
350 ::unlink ( pidfile_path ); 352 ::unlink ( pidfile_path );
351} 353}
352 354
353void handle_sigterm ( int sig ) 355void handle_sigterm ( int sig )
354{ 356{
355 if ( qApp ) 357 if ( qApp )
356 qApp-> quit ( ); 358 qApp-> quit ( );
357} 359}
358 360
359int main( int argc, char ** argv ) 361int main( int argc, char ** argv )
360{ 362{
361#ifndef SINGLE_APP 363#ifndef SINGLE_APP
362 ::signal( SIGCHLD, SIG_IGN ); 364 ::signal( SIGCHLD, SIG_IGN );
363 365
364 ::signal ( SIGTERM, handle_sigterm ); 366 ::signal ( SIGTERM, handle_sigterm );
365 367
366 ::setsid ( ); 368 ::setsid ( );
367 ::setpgid ( 0, 0 ); 369 ::setpgid ( 0, 0 );
368 370
369 ::atexit ( remove_pidfile ); 371 ::atexit ( remove_pidfile );
370 create_pidfile ( ); 372 create_pidfile ( );
371#endif 373#endif
372 374
373 int retVal = initApplication ( argc, argv ); 375 int retVal = initApplication ( argc, argv );
374 376
375#ifndef SINGLE_APP 377#ifndef SINGLE_APP
376 // Kill them. Kill them all. 378 // Kill them. Kill them all.
377 ::kill ( 0, SIGTERM ); 379 ::kill ( 0, SIGTERM );
378 ::sleep( 1 ); 380 ::sleep( 1 );
379 ::kill ( 0, SIGKILL ); 381 ::kill ( 0, SIGKILL );
380#endif 382#endif
381 383
382 return retVal; 384 return retVal;
383} 385}
384 386