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