summaryrefslogtreecommitdiff
authorzecke <zecke>2004-07-17 17:51:32 (UTC)
committer zecke <zecke>2004-07-17 17:51:32 (UTC)
commit9b5be1aa88f98bfe939563898e8fa340dbb7fa3f (patch) (unidiff)
treedf938b8250e003b44f75c0fc0dedac2dbc782ddf
parent0f64024dc631d9043d2f6f4f6bcafaac7eddd545 (diff)
downloadopie-9b5be1aa88f98bfe939563898e8fa340dbb7fa3f.zip
opie-9b5be1aa88f98bfe939563898e8fa340dbb7fa3f.tar.gz
opie-9b5be1aa88f98bfe939563898e8fa340dbb7fa3f.tar.bz2
-Add depedenncy on OMAF
-Link against OMAF -Finally use OMAF
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/config.in2
-rw-r--r--core/launcher/server.pro2
-rw-r--r--core/launcher/serverapp.cpp14
3 files changed, 10 insertions, 8 deletions
diff --git a/core/launcher/config.in b/core/launcher/config.in
index 31da148..a11fed4 100644
--- a/core/launcher/config.in
+++ b/core/launcher/config.in
@@ -1,4 +1,4 @@
1 config LAUNCHER 1 config LAUNCHER
2 boolean "opie-taskbar (program launcher qpe for Opie)" 2 boolean "opie-taskbar (program launcher qpe for Opie)"
3 default "y" 3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBQRSYNC 4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE2CORE && LIBOPIE2UI && LIBOPIE2SECURITY && LIBQRSYNC
diff --git a/core/launcher/server.pro b/core/launcher/server.pro
index 4e6a581..f366f54 100644
--- a/core/launcher/server.pro
+++ b/core/launcher/server.pro
@@ -1,84 +1,84 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 2
3 CONFIG += qt warn_on 3 CONFIG += qt warn_on
4 4
5 DESTDIR = $$(OPIEDIR)/bin 5 DESTDIR = $$(OPIEDIR)/bin
6 6
7 HEADERS += server.h \ 7 HEADERS += server.h \
8 serverinterface.h \ 8 serverinterface.h \
9 launchertab.h \ 9 launchertab.h \
10 documentlist.h \ 10 documentlist.h \
11 appicons.h \ 11 appicons.h \
12 taskbar.h \ 12 taskbar.h \
13 runningappbar.h \ 13 runningappbar.h \
14 applauncher.h \ 14 applauncher.h \
15 stabmon.h \ 15 stabmon.h \
16 inputmethods.h \ 16 inputmethods.h \
17 systray.h \ 17 systray.h \
18 wait.h \ 18 wait.h \
19 shutdownimpl.h \ 19 shutdownimpl.h \
20 launcher.h \ 20 launcher.h \
21 launcherview.h \ 21 launcherview.h \
22 $$(OPIEDIR)/core/apps/calibrate/calibrate.h \ 22 $$(OPIEDIR)/core/apps/calibrate/calibrate.h \
23 startmenu.h \ 23 startmenu.h \
24 transferserver.h \ 24 transferserver.h \
25 qcopbridge.h \ 25 qcopbridge.h \
26 packageslave.h \ 26 packageslave.h \
27 irserver.h \ 27 irserver.h \
28 firstuse.h \ 28 firstuse.h \
29 syncdialog.h \ 29 syncdialog.h \
30 serverapp.h \ 30 serverapp.h \
31 qprocess.h \ 31 qprocess.h \
32 screensaver.h \ 32 screensaver.h \
33 $$(OPIEDIR)/noncore/settings/mediummount/mediumwidget.h \ 33 $$(OPIEDIR)/noncore/settings/mediummount/mediumwidget.h \
34 mediadlg.h 34 mediadlg.h
35 35
36 SOURCES += server.cpp \ 36 SOURCES += server.cpp \
37 serverinterface.cpp \ 37 serverinterface.cpp \
38 launchertab.cpp \ 38 launchertab.cpp \
39 documentlist.cpp \ 39 documentlist.cpp \
40 appicons.cpp \ 40 appicons.cpp \
41 taskbar.cpp \ 41 taskbar.cpp \
42 runningappbar.cpp \ 42 runningappbar.cpp \
43 applauncher.cpp \ 43 applauncher.cpp \
44 stabmon.cpp \ 44 stabmon.cpp \
45 inputmethods.cpp \ 45 inputmethods.cpp \
46 systray.cpp \ 46 systray.cpp \
47 wait.cpp \ 47 wait.cpp \
48 shutdownimpl.cpp \ 48 shutdownimpl.cpp \
49 launcher.cpp \ 49 launcher.cpp \
50 launcherview.cpp \ 50 launcherview.cpp \
51 $$(OPIEDIR)/core/apps/calibrate/calibrate.cpp \ 51 $$(OPIEDIR)/core/apps/calibrate/calibrate.cpp \
52 transferserver.cpp \ 52 transferserver.cpp \
53 packageslave.cpp \ 53 packageslave.cpp \
54 irserver.cpp \ 54 irserver.cpp \
55 qcopbridge.cpp \ 55 qcopbridge.cpp \
56 startmenu.cpp \ 56 startmenu.cpp \
57 main.cpp \ 57 main.cpp \
58 firstuse.cpp \ 58 firstuse.cpp \
59 syncdialog.cpp \ 59 syncdialog.cpp \
60 serverapp.cpp \ 60 serverapp.cpp \
61 qprocess.cpp \ 61 qprocess.cpp \
62 qprocess_unix.cpp \ 62 qprocess_unix.cpp \
63 screensaver.cpp \ 63 screensaver.cpp \
64 $$(OPIEDIR)/noncore/settings/mediummount/mediumwidget.cc \ 64 $$(OPIEDIR)/noncore/settings/mediummount/mediumwidget.cc \
65 mediadlg.cpp 65 mediadlg.cpp
66 66
67 67
68INCLUDEPATH += $(OPIEDIR)/core/apps/calibrate 68INCLUDEPATH += $(OPIEDIR)/core/apps/calibrate
69 DEPENDPATH+= $(OPIEDIR)/core/apps/calibrate 69 DEPENDPATH+= $(OPIEDIR)/core/apps/calibrate
70 70
71INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/rsync 71INCLUDEPATH += $(OPIEDIR)/include $(OPIEDIR)/rsync
72 DEPENDPATH+= $(OPIEDIR)/rsync 72 DEPENDPATH+= $(OPIEDIR)/rsync
73 73
74INCLUDEPATH += $(OPIEDIR)/noncore/settings/mediummount 74INCLUDEPATH += $(OPIEDIR)/noncore/settings/mediummount
75DEPENDPATH += $(OPIEDIR)/noncore/settings/mediummount 75DEPENDPATH += $(OPIEDIR)/noncore/settings/mediummount
76 76
77LIBS += -lqpe -lopiecore2 -lopieui2 -lqrsync 77LIBS += -lqpe -lopiecore2 -lopieui2 -lopiesecurity2 -lqrsync
78TARGET = qpe 78TARGET = qpe
79 79
80contains( $(CONFIG_TARGET_MACOSX), y ) { 80contains( $(CONFIG_TARGET_MACOSX), y ) {
81 LIBS += -lcrypt 81 LIBS += -lcrypt
82} 82}
83 83
84include ( $(OPIEDIR)/include.pro ) 84include ( $(OPIEDIR)/include.pro )
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp
index 3d88873..f1bce40 100644
--- a/core/launcher/serverapp.cpp
+++ b/core/launcher/serverapp.cpp
@@ -1,835 +1,837 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2003 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2003 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the 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 "serverapp.h" 21#include "serverapp.h"
22#include "screensaver.h" 22#include "screensaver.h"
23 23
24/* OPIE */ 24/* OPIE */
25#include <opie2/odebug.h> 25#include <opie2/odebug.h>
26#include <opie2/odevice.h> 26#include <opie2/odevice.h>
27#include <qtopia/password.h> 27#include <opie2/multiauthpassword.h>
28
28#include <qtopia/config.h> 29#include <qtopia/config.h>
29#include <qtopia/power.h> 30#include <qtopia/power.h>
30 31
31#ifdef Q_WS_QWS 32#ifdef Q_WS_QWS
32#include <qtopia/qcopenvelope_qws.h> 33#include <qtopia/qcopenvelope_qws.h>
33#endif 34#endif
34#include <qtopia/global.h> 35#include <qtopia/global.h>
35using namespace Opie::Core; 36using namespace Opie::Core;
36 37
37/* QT */ 38/* QT */
38#ifdef Q_WS_QWS 39#ifdef Q_WS_QWS
39#include <qgfx_qws.h> 40#include <qgfx_qws.h>
40#endif 41#endif
41#include <qmessagebox.h> 42#include <qmessagebox.h>
42#include <qtimer.h> 43#include <qtimer.h>
43#include <qpainter.h> 44#include <qpainter.h>
44#include <qfile.h> 45#include <qfile.h>
45#include <qpixmapcache.h> 46#include <qpixmapcache.h>
46 47
47/* STD */ 48/* STD */
48#ifdef Q_OS_WIN32 49#ifdef Q_OS_WIN32
49#include <io.h> 50#include <io.h>
50#include <process.h> 51#include <process.h>
51#else 52#else
52#include <unistd.h> 53#include <unistd.h>
53#endif 54#endif
54#include <stdlib.h> 55#include <stdlib.h>
55 56
56static ServerApplication *serverApp = 0; 57static ServerApplication *serverApp = 0;
57static int loggedin=0; 58static int loggedin=0;
58 59
59QCopKeyRegister::QCopKeyRegister() 60QCopKeyRegister::QCopKeyRegister()
60 : m_keyCode( 0 ) { 61 : m_keyCode( 0 ) {
61} 62}
62 63
63QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) 64QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m )
64 :m_keyCode( k ), m_channel( c ), m_message( m ) { 65 :m_keyCode( k ), m_channel( c ), m_message( m ) {
65} 66}
66 67
67int QCopKeyRegister::keyCode()const { 68int QCopKeyRegister::keyCode()const {
68 return m_keyCode; 69 return m_keyCode;
69} 70}
70 71
71QCString QCopKeyRegister::channel()const { 72QCString QCopKeyRegister::channel()const {
72 return m_channel; 73 return m_channel;
73} 74}
74 75
75QCString QCopKeyRegister::message()const { 76QCString QCopKeyRegister::message()const {
76 return m_message; 77 return m_message;
77} 78}
78 79
79bool QCopKeyRegister::send() { 80bool QCopKeyRegister::send() {
80 if (m_channel.isNull() ) 81 if (m_channel.isNull() )
81 return false; 82 return false;
82 83
83 QCopEnvelope( m_channel, m_message ); 84 QCopEnvelope( m_channel, m_message );
84 85
85 return true; 86 return true;
86} 87}
87 88
88//--------------------------------------------------------------------------- 89//---------------------------------------------------------------------------
89 90
90/* 91/*
91 Priority is number of alerts that are needed to pop up 92 Priority is number of alerts that are needed to pop up
92 alert. 93 alert.
93 */ 94 */
94class DesktopPowerAlerter : public QMessageBox 95class DesktopPowerAlerter : public QMessageBox
95{ 96{
96 Q_OBJECT 97 Q_OBJECT
97public: 98public:
98 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 99 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
99 : QMessageBox( tr("Battery Status"), tr("Low Battery"), 100 : QMessageBox( tr("Battery Status"), tr("Low Battery"),
100 QMessageBox::Critical, 101 QMessageBox::Critical,
101 QMessageBox::Ok | QMessageBox::Default, 102 QMessageBox::Ok | QMessageBox::Default,
102 QMessageBox::NoButton, QMessageBox::NoButton, 103 QMessageBox::NoButton, QMessageBox::NoButton,
103 parent, name, FALSE ) 104 parent, name, FALSE )
104 { 105 {
105 currentPriority = INT_MAX; 106 currentPriority = INT_MAX;
106 alertCount = 0; 107 alertCount = 0;
107 } 108 }
108 109
109 void alert( const QString &text, int priority ); 110 void alert( const QString &text, int priority );
110 void hideEvent( QHideEvent * ); 111 void hideEvent( QHideEvent * );
111private: 112private:
112 int currentPriority; 113 int currentPriority;
113 int alertCount; 114 int alertCount;
114}; 115};
115 116
116void DesktopPowerAlerter::alert( const QString &text, int priority ) 117void DesktopPowerAlerter::alert( const QString &text, int priority )
117{ 118{
118 alertCount++; 119 alertCount++;
119 if ( alertCount < priority ) 120 if ( alertCount < priority )
120 return; 121 return;
121 if ( priority > currentPriority ) 122 if ( priority > currentPriority )
122 return; 123 return;
123 currentPriority = priority; 124 currentPriority = priority;
124 setText( text ); 125 setText( text );
125 show(); 126 show();
126} 127}
127 128
128 129
129void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 130void DesktopPowerAlerter::hideEvent( QHideEvent *e )
130{ 131{
131 QMessageBox::hideEvent( e ); 132 QMessageBox::hideEvent( e );
132 alertCount = 0; 133 alertCount = 0;
133 currentPriority = INT_MAX; 134 currentPriority = INT_MAX;
134} 135}
135 136
136//--------------------------------------------------------------------------- 137//---------------------------------------------------------------------------
137 138
138KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0) 139KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton(0)
139{ 140{
140 /* We don't do this cause it would interfere with ODevice */ 141 /* We don't do this cause it would interfere with ODevice */
141#if 0 142#if 0
142 qwsServer->setKeyboardFilter(this); 143 qwsServer->setKeyboardFilter(this);
143#endif 144#endif
144} 145}
145 146
146void KeyFilter::timerEvent(QTimerEvent* e) 147void KeyFilter::timerEvent(QTimerEvent* e)
147{ 148{
148 if ( e->timerId() == held_tid ) { 149 if ( e->timerId() == held_tid ) {
149 killTimer(held_tid); 150 killTimer(held_tid);
150 // button held 151 // button held
151 if ( heldButton ) { 152 if ( heldButton ) {
152 emit activate(heldButton, TRUE); 153 emit activate(heldButton, TRUE);
153 heldButton = 0; 154 heldButton = 0;
154 } 155 }
155 held_tid = 0; 156 held_tid = 0;
156 } 157 }
157} 158}
158 159
159void KeyFilter::registerKey( const QCopKeyRegister& key ) { 160void KeyFilter::registerKey( const QCopKeyRegister& key ) {
160 m_keys.insert( key.keyCode(), key ); 161 m_keys.insert( key.keyCode(), key );
161} 162}
162 163
163void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { 164void KeyFilter::unregisterKey( const QCopKeyRegister& key ) {
164 m_keys.remove( key.keyCode() ); 165 m_keys.remove( key.keyCode() );
165} 166}
166 167
167bool KeyFilter::keyRegistered( int key ) { 168bool KeyFilter::keyRegistered( int key ) {
168 /* 169 /*
169 * Check if we've a key registered 170 * Check if we've a key registered
170 */ 171 */
171 if ( !m_keys[key].send()) 172 if ( !m_keys[key].send())
172 return false; 173 return false;
173 else 174 else
174 return true; 175 return true;
175 176
176} 177}
177 178
178bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) 179bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat)
179{ 180{
180 if ( !loggedin 181 if ( !loggedin
181 // Permitted keys 182 // Permitted keys
182 && keycode != Key_F34 // power 183 && keycode != Key_F34 // power
183 && keycode != Key_F30 // select 184 && keycode != Key_F30 // select
184 && keycode != Key_Enter 185 && keycode != Key_Enter
185 && keycode != Key_Return 186 && keycode != Key_Return
186 && keycode != Key_Space 187 && keycode != Key_Space
187 && keycode != Key_Left 188 && keycode != Key_Left
188 && keycode != Key_Right 189 && keycode != Key_Right
189 && keycode != Key_Up 190 && keycode != Key_Up
190 && keycode != Key_Down ) 191 && keycode != Key_Down )
191 return TRUE; 192 return TRUE;
192 193
193 /* check if it was registered */ 194 /* check if it was registered */
194 if (!db ) { 195 if (!db ) {
195 if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) 196 if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) )
196 return true; 197 return true;
197 }else { 198 }else {
198 199
199 200
200 // First check to see if DeviceButtonManager knows something about this button: 201 // First check to see if DeviceButtonManager knows something about this button:
201 const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); 202 const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode);
202 if (button && !autoRepeat) { 203 if (button && !autoRepeat) {
203 if ( held_tid ) { 204 if ( held_tid ) {
204 killTimer(held_tid); 205 killTimer(held_tid);
205 held_tid = 0; 206 held_tid = 0;
206 } 207 }
207 if ( button->heldAction().isNull() ) { 208 if ( button->heldAction().isNull() ) {
208 if ( press ) 209 if ( press )
209 emit activate(button, FALSE); 210 emit activate(button, FALSE);
210 } else if ( press ) { 211 } else if ( press ) {
211 heldButton = button; 212 heldButton = button;
212 held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); 213 held_tid = startTimer( ODevice::inst ()->buttonHoldTime () );
213 } else if ( heldButton ) { 214 } else if ( heldButton ) {
214 heldButton = 0; 215 heldButton = 0;
215 emit activate(button, FALSE); 216 emit activate(button, FALSE);
216 } 217 }
217 QWSServer::screenSaverActivate(FALSE); 218 QWSServer::screenSaverActivate(FALSE);
218 return TRUE; 219 return TRUE;
219 } 220 }
220 return false; 221 return false;
221 } 222 }
222 if ( keycode == HardKey_Suspend ) { 223 if ( keycode == HardKey_Suspend ) {
223 if ( press ) emit power(); 224 if ( press ) emit power();
224 return TRUE; 225 return TRUE;
225 } 226 }
226 if ( keycode == HardKey_Backlight ) { 227 if ( keycode == HardKey_Backlight ) {
227 if ( press ) emit backlight(); 228 if ( press ) emit backlight();
228 return TRUE; 229 return TRUE;
229 } 230 }
230 if ( keycode == Key_F32 ) { 231 if ( keycode == Key_F32 ) {
231#ifndef QT_NO_COP 232#ifndef QT_NO_COP
232 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 233 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
233#endif 234#endif
234 return TRUE; 235 return TRUE;
235 } 236 }
236 if ( keycode == Key_F31 ) { 237 if ( keycode == Key_F31 ) {
237 if ( press ) emit symbol(); 238 if ( press ) emit symbol();
238 QWSServer::screenSaverActivate(FALSE); 239 QWSServer::screenSaverActivate(FALSE);
239 return TRUE; 240 return TRUE;
240 } 241 }
241 242
242 if ( keycode == Key_NumLock ) 243 if ( keycode == Key_NumLock )
243 if ( press ) emit numLockStateToggle(); 244 if ( press ) emit numLockStateToggle();
244 245
245 if ( keycode == Key_CapsLock ) 246 if ( keycode == Key_CapsLock )
246 if ( press ) emit capsLockStateToggle(); 247 if ( press ) emit capsLockStateToggle();
247 248
248 if ( serverApp ) 249 if ( serverApp )
249 serverApp->keyClick(keycode,press,autoRepeat); 250 serverApp->keyClick(keycode,press,autoRepeat);
250 251
251 return FALSE; 252 return FALSE;
252} 253}
253 254
254enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; 255enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown;
255 256
256#if defined(QPE_HAVE_MEMALERTER) 257#if defined(QPE_HAVE_MEMALERTER)
257QPE_MEMALERTER_IMPL 258QPE_MEMALERTER_IMPL
258#endif 259#endif
259 260
260 261
261 262
262//--------------------------------------------------------------------------- 263//---------------------------------------------------------------------------
263 264
264bool ServerApplication::doRestart = FALSE; 265bool ServerApplication::doRestart = FALSE;
265bool ServerApplication::allowRestart = TRUE; 266bool ServerApplication::allowRestart = TRUE;
266bool ServerApplication::ms_is_starting = TRUE; 267bool ServerApplication::ms_is_starting = TRUE;
267 268
268void ServerApplication::switchLCD( bool on ) { 269void ServerApplication::switchLCD( bool on ) {
269 if ( !qApp ) 270 if ( !qApp )
270 return; 271 return;
271 272
272 ServerApplication *dapp = ServerApplication::me() ; 273 ServerApplication *dapp = ServerApplication::me() ;
273 274
274 if ( !dapp-> m_screensaver ) 275 if ( !dapp-> m_screensaver )
275 return; 276 return;
276 277
277 if ( on ) { 278 if ( on ) {
278 dapp-> m_screensaver-> setDisplayState ( true ); 279 dapp-> m_screensaver-> setDisplayState ( true );
279 dapp-> m_screensaver-> setBacklight ( -3 ); 280 dapp-> m_screensaver-> setBacklight ( -3 );
280 }else 281 }else
281 dapp-> m_screensaver-> setDisplayState ( false ); 282 dapp-> m_screensaver-> setDisplayState ( false );
282 283
283 284
284} 285}
285 286
286ServerApplication::ServerApplication( int& argc, char **argv, Type t ) 287ServerApplication::ServerApplication( int& argc, char **argv, Type t )
287 : QPEApplication( argc, argv, t ) 288 : QPEApplication( argc, argv, t )
288{ 289{
289 ms_is_starting = true; 290 ms_is_starting = true;
290 291
291 // We know we'll have lots of cached pixmaps due to App/DocLnks 292 // We know we'll have lots of cached pixmaps due to App/DocLnks
292 QPixmapCache::setCacheLimit(512); 293 QPixmapCache::setCacheLimit(512);
293 294
294 m_ps = new PowerStatus; 295 m_ps = new PowerStatus;
295 m_ps_last = new PowerStatus; 296 m_ps_last = new PowerStatus;
296 pa = new DesktopPowerAlerter( 0 ); 297 pa = new DesktopPowerAlerter( 0 );
297 298
298 m_apm_timer = new QTimer( this ); 299 m_apm_timer = new QTimer( this );
299 connect(m_apm_timer, SIGNAL( timeout() ), 300 connect(m_apm_timer, SIGNAL( timeout() ),
300 this, SLOT( apmTimeout() ) ); 301 this, SLOT( apmTimeout() ) );
301 302
302 reloadPowerWarnSettings(); 303 reloadPowerWarnSettings();
303 304
304 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 305 QCopChannel *channel = new QCopChannel( "QPE/System", this );
305 connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), 306 connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ),
306 this, SLOT(systemMessage(const QCString&,const QByteArray&) ) ); 307 this, SLOT(systemMessage(const QCString&,const QByteArray&) ) );
307 308
308 channel = new QCopChannel("QPE/Launcher", this ); 309 channel = new QCopChannel("QPE/Launcher", this );
309 connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ), 310 connect(channel, SIGNAL(received(const QCString&,const QByteArray&) ),
310 this, SLOT(launcherMessage(const QCString&,const QByteArray&) ) ); 311 this, SLOT(launcherMessage(const QCString&,const QByteArray&) ) );
311 312
312 m_screensaver = new OpieScreenSaver(); 313 m_screensaver = new OpieScreenSaver();
313 m_screensaver->setInterval( -1 ); 314 m_screensaver->setInterval( -1 );
314 QWSServer::setScreenSaver( m_screensaver ); 315 QWSServer::setScreenSaver( m_screensaver );
315 316
316 connect( qApp, SIGNAL( volumeChanged(bool) ), 317 connect( qApp, SIGNAL( volumeChanged(bool) ),
317 this, SLOT( rereadVolumes() ) ); 318 this, SLOT( rereadVolumes() ) );
318 319
319 320
320 /* ### PluginLoader libqtopia SafeMode */ 321 /* ### PluginLoader libqtopia SafeMode */
321#if 0 322#if 0
322 if ( PluginLoader::inSafeMode() ) 323 if ( PluginLoader::inSafeMode() )
323 QTimer::singleShot(500, this, SLOT(showSafeMode()) ); 324 QTimer::singleShot(500, this, SLOT(showSafeMode()) );
324 QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); 325 QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) );
325#endif 326#endif
326 327
327 kf = new KeyFilter(this); 328 kf = new KeyFilter(this);
328 329
329 connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); 330 connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) );
330 connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); 331 connect( kf, SIGNAL(power()), this, SIGNAL(power()) );
331 connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); 332 connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) );
332 connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); 333 connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol()));
333 connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); 334 connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle()));
334 connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); 335 connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle()));
335 connect( kf, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), 336 connect( kf, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)),
336 this,SIGNAL(activate(const Opie::Core::ODeviceButton*,bool))); 337 this,SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)));
337 338
338 339
339 connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); 340 connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) );
340 341
341 connect( this, SIGNAL(power() ), 342 connect( this, SIGNAL(power() ),
342 SLOT(togglePower() ) ); 343 SLOT(togglePower() ) );
343 344
344 rereadVolumes(); 345 rereadVolumes();
345 346
346 serverApp = this; 347 serverApp = this;
347 348
348 apmTimeout(); 349 apmTimeout();
349 grabKeyboard(); 350 grabKeyboard();
350 351
351 /* make sure the event filter is installed */ 352 /* make sure the event filter is installed */
352 const ODeviceButton* but = ODevice::inst()->buttonForKeycode( -1 ); 353 const ODeviceButton* but = ODevice::inst()->buttonForKeycode( -1 );
354 Q_CONST_UNUSED( but )
353} 355}
354 356
355 357
356ServerApplication::~ServerApplication() 358ServerApplication::~ServerApplication()
357{ 359{
358 ungrabKeyboard(); 360 ungrabKeyboard();
359 361
360 362
361 delete pa; 363 delete pa;
362 delete m_ps; 364 delete m_ps;
363 delete m_ps_last; 365 delete m_ps_last;
364} 366}
365 367
366void ServerApplication::apmTimeout() { 368void ServerApplication::apmTimeout() {
367 serverApp-> checkMemory( ); // in case no events are generated 369 serverApp-> checkMemory( ); // in case no events are generated
368 *m_ps_last = *m_ps; 370 *m_ps_last = *m_ps;
369 *m_ps = PowerStatusManager::readStatus(); 371 *m_ps = PowerStatusManager::readStatus();
370 372
371 if ( m_ps->acStatus() != m_ps_last-> acStatus() ) 373 if ( m_ps->acStatus() != m_ps_last-> acStatus() )
372 m_screensaver-> powerStatusChanged( *m_ps ); 374 m_screensaver-> powerStatusChanged( *m_ps );
373 375
374 if ( m_ps->acStatus() == PowerStatus::Online ) { 376 if ( m_ps->acStatus() == PowerStatus::Online ) {
375 return; 377 return;
376 } 378 }
377 379
378 int bat = m_ps-> batteryPercentRemaining(); 380 int bat = m_ps-> batteryPercentRemaining();
379 381
380 if ( bat < m_ps_last-> batteryPercentRemaining() ) { 382 if ( bat < m_ps_last-> batteryPercentRemaining() ) {
381 if ( bat <= m_powerCritical ) { 383 if ( bat <= m_powerCritical ) {
382 QMessageBox battlow( 384 QMessageBox battlow(
383 tr("WARNING"), 385 tr("WARNING"),
384 tr("<p>The battery level is critical!" 386 tr("<p>The battery level is critical!"
385 "<p>Keep power off until AC is restored"), 387 "<p>Keep power off until AC is restored"),
386 QMessageBox::Warning, 388 QMessageBox::Warning,
387 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, 389 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton,
388 0, QString::null, TRUE, WStyle_StaysOnTop); 390 0, QString::null, TRUE, WStyle_StaysOnTop);
389 battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); 391 battlow.setButtonText(QMessageBox::Cancel, tr("Ok"));
390 battlow.exec(); 392 battlow.exec();
391 } else if ( bat <= m_powerVeryLow ) 393 } else if ( bat <= m_powerVeryLow )
392 pa->alert( tr( "The battery is running very low. "), 2 ); 394 pa->alert( tr( "The battery is running very low. "), 2 );
393 } 395 }
394 396
395 if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { 397 if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) {
396 QMessageBox battlow( 398 QMessageBox battlow(
397 tr("WARNING"), 399 tr("WARNING"),
398 tr("<p>The Back-up battery is very low" 400 tr("<p>The Back-up battery is very low"
399 "<p>Please charge the back-up battery"), 401 "<p>Please charge the back-up battery"),
400 QMessageBox::Warning, 402 QMessageBox::Warning,
401 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, 403 QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton,
402 0, QString::null, TRUE, WStyle_StaysOnTop); 404 0, QString::null, TRUE, WStyle_StaysOnTop);
403 battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); 405 battlow.setButtonText(QMessageBox::Cancel, tr("Ok"));
404 battlow.exec(); 406 battlow.exec();
405 } 407 }
406} 408}
407 409
408void ServerApplication::systemMessage( const QCString& msg, 410void ServerApplication::systemMessage( const QCString& msg,
409 const QByteArray& data ) { 411 const QByteArray& data ) {
410 QDataStream stream ( data, IO_ReadOnly ); 412 QDataStream stream ( data, IO_ReadOnly );
411 413
412 if ( msg == "setScreenSaverInterval(int)" ) { 414 if ( msg == "setScreenSaverInterval(int)" ) {
413 int time; 415 int time;
414 stream >> time; 416 stream >> time;
415 m_screensaver-> setInterval( time ); 417 m_screensaver-> setInterval( time );
416 } 418 }
417 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 419 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
418 int t1, t2, t3; 420 int t1, t2, t3;
419 stream >> t1 >> t2 >> t3; 421 stream >> t1 >> t2 >> t3;
420 m_screensaver-> setIntervals( t1, t2, t3 ); 422 m_screensaver-> setIntervals( t1, t2, t3 );
421 } 423 }
422 else if ( msg == "setBacklight(int)" ) { 424 else if ( msg == "setBacklight(int)" ) {
423 int bright; 425 int bright;
424 stream >> bright; 426 stream >> bright;
425 m_screensaver-> setBacklight( bright ); 427 m_screensaver-> setBacklight( bright );
426 } 428 }
427 else if ( msg == "setScreenSaverMode(int)" ) { 429 else if ( msg == "setScreenSaverMode(int)" ) {
428 int mode; 430 int mode;
429 stream >> mode; 431 stream >> mode;
430 m_screensaver-> setMode ( mode ); 432 m_screensaver-> setMode ( mode );
431 } 433 }
432 else if ( msg == "reloadPowerWarnSettings()" ) { 434 else if ( msg == "reloadPowerWarnSettings()" ) {
433 reloadPowerWarnSettings(); 435 reloadPowerWarnSettings();
434 } 436 }
435 else if ( msg == "setDisplayState(int)" ) { 437 else if ( msg == "setDisplayState(int)" ) {
436 int state; 438 int state;
437 stream >> state; 439 stream >> state;
438 m_screensaver-> setDisplayState ( state != 0 ); 440 m_screensaver-> setDisplayState ( state != 0 );
439 } 441 }
440 else if ( msg == "suspend()" ) { 442 else if ( msg == "suspend()" ) {
441 emit power(); 443 emit power();
442 } 444 }
443 else if ( msg == "sendBusinessCard()" ) { 445 else if ( msg == "sendBusinessCard()" ) {
444 QString card = ::getenv ( "HOME" ); 446 QString card = ::getenv ( "HOME" );
445 card += "/Applications/addressbook/businesscard.vcf"; 447 card += "/Applications/addressbook/businesscard.vcf";
446 448
447 if ( QFile::exists( card ) ) { 449 if ( QFile::exists( card ) ) {
448 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); 450 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" );
449 QString mimetype = "text/x-vCard"; 451 QString mimetype = "text/x-vCard";
450 e << tr( "business card" ) << card << mimetype; 452 e << tr( "business card" ) << card << mimetype;
451 } 453 }
452 } 454 }
453} 455}
454 456
455void ServerApplication::reloadPowerWarnSettings ( ) 457void ServerApplication::reloadPowerWarnSettings ( )
456{ 458{
457 Config cfg ( "apm" ); 459 Config cfg ( "apm" );
458 cfg. setGroup ( "Warnings" ); 460 cfg. setGroup ( "Warnings" );
459 461
460 int iv = cfg. readNumEntry ( "checkinterval", 10000 ); 462 int iv = cfg. readNumEntry ( "checkinterval", 10000 );
461 463
462 m_apm_timer-> stop ( ); 464 m_apm_timer-> stop ( );
463 if ( iv ) 465 if ( iv )
464 m_apm_timer-> start ( iv ); 466 m_apm_timer-> start ( iv );
465 467
466 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); 468 m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 );
467 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); 469 m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 );
468} 470}
469 471
470void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) 472void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data )
471{ 473{
472 QDataStream stream ( data, IO_ReadOnly ); 474 QDataStream stream ( data, IO_ReadOnly );
473 475
474 if ( msg == "deviceButton(int,int,int)" ) { 476 if ( msg == "deviceButton(int,int,int)" ) {
475 int keycode, press, autoRepeat; 477 int keycode, press, autoRepeat;
476 stream >> keycode >> press >> autoRepeat; 478 stream >> keycode >> press >> autoRepeat;
477 479
478 kf->checkButtonAction ( true, keycode, press, autoRepeat ); 480 kf->checkButtonAction ( true, keycode, press, autoRepeat );
479 } 481 }
480 else if ( msg == "keyRegister(int,QCString,QCString)" ) { 482 else if ( msg == "keyRegister(int,QCString,QCString)" ) {
481 int k; 483 int k;
482 QCString c, m; 484 QCString c, m;
483 stream >> k >> c >> m; 485 stream >> k >> c >> m;
484 486
485 kf -> registerKey( QCopKeyRegister(k, c, m) ); 487 kf -> registerKey( QCopKeyRegister(k, c, m) );
486 } 488 }
487} 489}
488 490
489 491
490bool ServerApplication::screenLocked() 492bool ServerApplication::screenLocked()
491{ 493{
492 return loggedin == 0; 494 return loggedin == 0;
493} 495}
494 496
495void ServerApplication::login(bool at_poweron) 497void ServerApplication::login(bool at_poweron)
496{ 498{
497 if ( !loggedin ) { 499 if ( !loggedin ) {
498 Global::terminateBuiltin("calibrate"); // No tr 500 Global::terminateBuiltin("calibrate"); // No tr
499 Password::authenticate(at_poweron); 501 Opie::Security::MultiauthPassword::authenticate(at_poweron);
500 loggedin=1; 502 loggedin=1;
501#ifndef QT_NO_COP 503#ifndef QT_NO_COP
502 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 504 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
503#endif 505#endif
504 } 506 }
505} 507}
506 508
507#if defined(QPE_HAVE_TOGGLELIGHT) 509#if defined(QPE_HAVE_TOGGLELIGHT)
508#include <qtopia/config.h> 510#include <qtopia/config.h>
509 511
510#include <sys/ioctl.h> 512#include <sys/ioctl.h>
511#include <sys/types.h> 513#include <sys/types.h>
512#include <fcntl.h> 514#include <fcntl.h>
513#include <unistd.h> 515#include <unistd.h>
514#include <errno.h> 516#include <errno.h>
515#include <linux/ioctl.h> 517#include <linux/ioctl.h>
516#include <time.h> 518#include <time.h>
517#endif 519#endif
518 520
519namespace { 521namespace {
520 void execAutoStart(const QDateTime& suspendTime ) { 522 void execAutoStart(const QDateTime& suspendTime ) {
521 QString appName; 523 QString appName;
522 int delay; 524 int delay;
523 QDateTime now = QDateTime::currentDateTime(); 525 QDateTime now = QDateTime::currentDateTime();
524 526
525 Config cfg( "autostart" ); 527 Config cfg( "autostart" );
526 cfg.setGroup( "AutoStart" ); 528 cfg.setGroup( "AutoStart" );
527 appName = cfg.readEntry( "Apps", "" ); 529 appName = cfg.readEntry( "Apps", "" );
528 delay = cfg.readNumEntry( "Delay", 0 ); 530 delay = cfg.readNumEntry( "Delay", 0 );
529 531
530 // If the time between suspend and resume was longer then the 532 // If the time between suspend and resume was longer then the
531 // value saved as delay, start the app 533 // value saved as delay, start the app
532 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { 534 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
533 QCopEnvelope e( "QPE/System", "execute(QString)" ); 535 QCopEnvelope e( "QPE/System", "execute(QString)" );
534 e << QString( appName ); 536 e << QString( appName );
535 } 537 }
536 } 538 }
537} 539}
538 540
539 541
540void ServerApplication::togglePower() 542void ServerApplication::togglePower()
541{ 543{
542 static bool excllock = false; 544 static bool excllock = false;
543 545
544 if ( excllock ) 546 if ( excllock )
545 return ; 547 return ;
546 548
547 excllock = true; 549 excllock = true;
548 550
549 bool wasloggedin = loggedin; 551 bool wasloggedin = loggedin;
550 loggedin = 0; 552 loggedin = 0;
551 m_suspendTime = QDateTime::currentDateTime(); 553 m_suspendTime = QDateTime::currentDateTime();
552 554
553#ifdef QWS 555#ifdef QWS
554 556
555 if ( Password::needToAuthenticate ( true ) && qt_screen ) { 557 if ( Opie::Security::MultiauthPassword::needToAuthenticate ( true ) && qt_screen ) {
556 // Should use a big black window instead. 558 // Should use a big black window instead.
557 // But this would not show up fast enough 559 // But this would not show up fast enough
558 QGfx *g = qt_screen-> screenGfx ( ); 560 QGfx *g = qt_screen-> screenGfx ( );
559 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); 561 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( ));
560 delete g; 562 delete g;
561 } 563 }
562#endif 564#endif
563 565
564 ODevice::inst ( )-> suspend ( ); 566 ODevice::inst ( )-> suspend ( );
565 567
566 ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call 568 ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call
567 QWSServer::screenSaverActivate ( false ); 569 QWSServer::screenSaverActivate ( false );
568 570
569 { 571 {
570 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep 572 QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep
571 } 573 }
572 574
573 if ( wasloggedin ) 575 if ( wasloggedin )
574 login ( true ); 576 login ( true );
575 577
576 execAutoStart(m_suspendTime); 578 execAutoStart(m_suspendTime);
577 //qcopBridge->closeOpenConnections(); 579 //qcopBridge->closeOpenConnections();
578 580
579 excllock = false; 581 excllock = false;
580} 582}
581 583
582void ServerApplication::toggleLight() 584void ServerApplication::toggleLight()
583{ 585{
584#ifndef QT_NO_COP 586#ifndef QT_NO_COP
585 QCopEnvelope e("QPE/System", "setBacklight(int)"); 587 QCopEnvelope e("QPE/System", "setBacklight(int)");
586 e << -2; // toggle 588 e << -2; // toggle
587#endif 589#endif
588} 590}
589 591
590 592
591/* 593/*
592 * We still listen to key events but handle them in 594 * We still listen to key events but handle them in
593 * a special class 595 * a special class
594 */ 596 */
595 597
596bool ServerApplication::eventFilter( QObject *o, QEvent *e) { 598bool ServerApplication::eventFilter( QObject *o, QEvent *e) {
597 if ( e->type() != QEvent::KeyPress && 599 if ( e->type() != QEvent::KeyPress &&
598 e->type() != QEvent::KeyRelease ) 600 e->type() != QEvent::KeyRelease )
599 return QPEApplication::eventFilter( o, e ); 601 return QPEApplication::eventFilter( o, e );
600 602
601 QKeyEvent *ke = static_cast<QKeyEvent*>( e ); 603 QKeyEvent *ke = static_cast<QKeyEvent*>( e );
602 if ( kf->checkButtonAction( true, ke->key(), 604 if ( kf->checkButtonAction( true, ke->key(),
603 e->type() == QEvent::KeyPress, 605 e->type() == QEvent::KeyPress,
604 ke-> isAutoRepeat() )) 606 ke-> isAutoRepeat() ))
605 return true; 607 return true;
606 608
607 return QPEApplication::eventFilter( o, e ); 609 return QPEApplication::eventFilter( o, e );
608 610
609} 611}
610 612
611#ifdef Q_WS_QWS 613#ifdef Q_WS_QWS
612bool ServerApplication::qwsEventFilter( QWSEvent *e ) 614bool ServerApplication::qwsEventFilter( QWSEvent *e )
613{ 615{
614 checkMemory(); 616 checkMemory();
615 617
616 if ( e->type == QWSEvent::Mouse ) { 618 if ( e->type == QWSEvent::Mouse ) {
617 QWSMouseEvent *me = (QWSMouseEvent *)e; 619 QWSMouseEvent *me = (QWSMouseEvent *)e;
618 static bool up = TRUE; 620 static bool up = TRUE;
619 if ( me->simpleData.state&LeftButton ) { 621 if ( me->simpleData.state&LeftButton ) {
620 if ( up ) { 622 if ( up ) {
621 up = FALSE; 623 up = FALSE;
622 screenClick(TRUE); 624 screenClick(TRUE);
623 } 625 }
624 } else if ( !up ) { 626 } else if ( !up ) {
625 up = TRUE; 627 up = TRUE;
626 screenClick(FALSE); 628 screenClick(FALSE);
627 } 629 }
628 }else if ( e->type == QWSEvent::Key ) { 630 }else if ( e->type == QWSEvent::Key ) {
629 QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e ); 631 QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e );
630 if ( kf->checkButtonAction( false, 632 if ( kf->checkButtonAction( false,
631 ke-> simpleData.keycode, 633 ke-> simpleData.keycode,
632 ke-> simpleData.is_press, 634 ke-> simpleData.is_press,
633 ke-> simpleData.is_auto_repeat ) ) 635 ke-> simpleData.is_auto_repeat ) )
634 return true; 636 return true;
635 } 637 }
636 638
637 return QPEApplication::qwsEventFilter( e ); 639 return QPEApplication::qwsEventFilter( e );
638} 640}
639#endif 641#endif
640 642
641 643
642/* ### FIXME libqtopia Plugin Safe Mode */ 644/* ### FIXME libqtopia Plugin Safe Mode */
643 645
644void ServerApplication::showSafeMode() 646void ServerApplication::showSafeMode()
645{ 647{
646#if 0 648#if 0
647 if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " 649 if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, "
648 "and the system is now in Safe Mode. " 650 "and the system is now in Safe Mode. "
649 "Plugins are not loaded in Safe Mode. " 651 "Plugins are not loaded in Safe Mode. "
650 "You can use the Plugin Manager to " 652 "You can use the Plugin Manager to "
651 "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) { 653 "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) {
652 Global::execute( "pluginmanager" ); 654 Global::execute( "pluginmanager" );
653 } 655 }
654#endif 656#endif
655} 657}
656 658
657void ServerApplication::clearSafeMode() 659void ServerApplication::clearSafeMode()
658{ 660{
659#if 0 661#if 0
660 // If we've been running OK for a while then we won't bother going into 662 // If we've been running OK for a while then we won't bother going into
661 // safe mode immediately on the next crash. 663 // safe mode immediately on the next crash.
662 Config cfg( "PluginLoader" ); 664 Config cfg( "PluginLoader" );
663 cfg.setGroup( "Global" ); 665 cfg.setGroup( "Global" );
664 QString mode = cfg.readEntry( "Mode", "Normal" ); 666 QString mode = cfg.readEntry( "Mode", "Normal" );
665 if ( mode == "MaybeSafe" ) { 667 if ( mode == "MaybeSafe" ) {
666 cfg.writeEntry( "Mode", "Normal" ); 668 cfg.writeEntry( "Mode", "Normal" );
667 } 669 }
668#endif 670#endif
669} 671}
670 672
671 673
672void ServerApplication::shutdown() 674void ServerApplication::shutdown()
673{ 675{
674 if ( type() != GuiServer ) 676 if ( type() != GuiServer )
675 return; 677 return;
676 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 678 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
677 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 679 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
678 this, SLOT(shutdown(ShutdownImpl::Type)) ); 680 this, SLOT(shutdown(ShutdownImpl::Type)) );
679 QPEApplication::showWidget( sd ); 681 QPEApplication::showWidget( sd );
680} 682}
681 683
682void ServerApplication::shutdown( ShutdownImpl::Type t ) 684void ServerApplication::shutdown( ShutdownImpl::Type t )
683{ 685{
684 char *opt = 0; 686 char *opt = 0;
685 687
686 switch ( t ) { 688 switch ( t ) {
687 case ShutdownImpl::ShutdownSystem: 689 case ShutdownImpl::ShutdownSystem:
688 opt = "-h"; 690 opt = "-h";
689 // fall through 691 // fall through
690 case ShutdownImpl::RebootSystem: 692 case ShutdownImpl::RebootSystem:
691 if ( opt == 0 ) 693 if ( opt == 0 )
692 opt = "-r"; 694 opt = "-r";
693 695
694 if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 ) 696 if ( execl( "/sbin/shutdown", "shutdown", opt, "now", ( void* ) 0) < 0 )
695 perror("shutdown"); 697 perror("shutdown");
696// ::syslog ( LOG_ERR, "Erroring execing shutdown\n" ); 698// ::syslog ( LOG_ERR, "Erroring execing shutdown\n" );
697 699
698 break; 700 break;
699 case ShutdownImpl::RestartDesktop: 701 case ShutdownImpl::RestartDesktop:
700 restart(); 702 restart();
701 break; 703 break;
702 case ShutdownImpl::TerminateDesktop: 704 case ShutdownImpl::TerminateDesktop:
703 prepareForTermination( FALSE ); 705 prepareForTermination( FALSE );
704 706
705 // This is a workaround for a Qt bug 707 // This is a workaround for a Qt bug
706 // clipboard applet has to stop its poll timer, or Qt/E 708 // clipboard applet has to stop its poll timer, or Qt/E
707 // will hang on quit() right before it emits aboutToQuit() 709 // will hang on quit() right before it emits aboutToQuit()
708 emit aboutToQuit ( ); 710 emit aboutToQuit ( );
709 711
710 quit(); 712 quit();
711 break; 713 break;
712 } 714 }
713} 715}
714 716
715void ServerApplication::restart() 717void ServerApplication::restart()
716{ 718{
717 if ( allowRestart ) { 719 if ( allowRestart ) {
718 720
719 /* 721 /*
720 * Applets and restart is a problem. Some applets delete 722 * Applets and restart is a problem. Some applets delete
721 * their widgets even if ownership gets transfered to the 723 * their widgets even if ownership gets transfered to the
722 * parent (Systray ) but deleting the applet may be unsafe 724 * parent (Systray ) but deleting the applet may be unsafe
723 * as well ( double deletion ). Some have topLevel widgets 725 * as well ( double deletion ). Some have topLevel widgets
724 * and when we dlclose and then delete the widget we will 726 * and when we dlclose and then delete the widget we will
725 * crash and an crash during restart is not nice 727 * crash and an crash during restart is not nice
726 */ 728 */
727#ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED 729#ifdef ALL_APPLETS_ON_THIS_WORLD_ARE_FIXED
728 /* same as above */ 730 /* same as above */
729 emit aboutToQuit(); 731 emit aboutToQuit();
730 prepareForTermination(TRUE); 732 prepareForTermination(TRUE);
731 doRestart = TRUE; 733 doRestart = TRUE;
732 quit(); 734 quit();
733#else 735#else
734 prepareForTermination( true ); 736 prepareForTermination( true );
735 for ( int fd = 3; fd < 100; fd++ ) 737 for ( int fd = 3; fd < 100; fd++ )
736 close( fd ); 738 close( fd );
737 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 ); 739 execl( ( qpeDir() + "/bin/qpe" ).latin1(), "qpe", 0 );
738 exit( 1 ); 740 exit( 1 );
739#endif 741#endif
740 } 742 }
741} 743}
742 744
743void ServerApplication::rereadVolumes() 745void ServerApplication::rereadVolumes()
744{ 746{
745 Config cfg( "qpe" ); 747 Config cfg( "qpe" );
746 cfg. setGroup ( "Volume" ); 748 cfg. setGroup ( "Volume" );
747 749
748 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" ); 750 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" );
749 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" ); 751 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" );
750 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" ); 752 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" );
751} 753}
752 754
753 755
754void ServerApplication::checkMemory() 756void ServerApplication::checkMemory()
755{ 757{
756#if defined(QPE_HAVE_MEMALERTER) 758#if defined(QPE_HAVE_MEMALERTER)
757 static bool ignoreNormal=TRUE; 759 static bool ignoreNormal=TRUE;
758 static bool existingMessage=FALSE; 760 static bool existingMessage=FALSE;
759 761
760 if(existingMessage) 762 if(existingMessage)
761 return; // don't show a second message while still on first 763 return; // don't show a second message while still on first
762 764
763 existingMessage = TRUE; 765 existingMessage = TRUE;
764 switch ( memstate ) { 766 switch ( memstate ) {
765 case MemUnknown: 767 case MemUnknown:
766 break; 768 break;
767 case MemLow: 769 case MemLow:
768 memstate = MemUnknown; 770 memstate = MemUnknown;
769 if ( !recoverMemory() ) { 771 if ( !recoverMemory() ) {
770 QMessageBox::warning( 0 , tr("Memory Status"), 772 QMessageBox::warning( 0 , tr("Memory Status"),
771 tr("Memory Low\nPlease save data.") ); 773 tr("Memory Low\nPlease save data.") );
772 ignoreNormal = FALSE; 774 ignoreNormal = FALSE;
773 } 775 }
774 break; 776 break;
775 case MemNormal: 777 case MemNormal:
776 memstate = MemUnknown; 778 memstate = MemUnknown;
777 if ( !ignoreNormal ) { 779 if ( !ignoreNormal ) {
778 ignoreNormal = TRUE; 780 ignoreNormal = TRUE;
779 QMessageBox::information ( 0 , tr("Memory Status"), 781 QMessageBox::information ( 0 , tr("Memory Status"),
780 "Memory OK" ); 782 "Memory OK" );
781 } 783 }
782 break; 784 break;
783 case MemVeryLow: 785 case MemVeryLow:
784 memstate = MemUnknown; 786 memstate = MemUnknown;
785 QMessageBox::critical( 0 , tr("Memory Status"), 787 QMessageBox::critical( 0 , tr("Memory Status"),
786 tr("Critical Memory Shortage\n" 788 tr("Critical Memory Shortage\n"
787 "Please end this application\n" 789 "Please end this application\n"
788 "immediately.") ); 790 "immediately.") );
789 recoverMemory(); 791 recoverMemory();
790 } 792 }
791 existingMessage = FALSE; 793 existingMessage = FALSE;
792#endif 794#endif
793} 795}
794 796
795bool ServerApplication::recoverMemory() 797bool ServerApplication::recoverMemory()
796{ 798{
797 return FALSE; 799 return FALSE;
798} 800}
799 801
800void ServerApplication::keyClick(int , bool press, bool ) 802void ServerApplication::keyClick(int , bool press, bool )
801{ 803{
802 if ( press && m_keyclick_sound ) 804 if ( press && m_keyclick_sound )
803 ODevice::inst() -> playKeySound(); 805 ODevice::inst() -> playKeySound();
804 806
805} 807}
806 808
807void ServerApplication::screenClick(bool press) 809void ServerApplication::screenClick(bool press)
808{ 810{
809 if ( press && m_screentap_sound ) 811 if ( press && m_screentap_sound )
810 ODevice::inst() -> playTouchSound(); 812 ODevice::inst() -> playTouchSound();
811} 813}
812 814
813void ServerApplication::soundAlarm() { 815void ServerApplication::soundAlarm() {
814 if ( me ()->m_alarm_sound ) 816 if ( me ()->m_alarm_sound )
815 ODevice::inst()->playAlarmSound(); 817 ODevice::inst()->playAlarmSound();
816} 818}
817 819
818ServerApplication *ServerApplication::me ( ) 820ServerApplication *ServerApplication::me ( )
819{ 821{
820 return static_cast<ServerApplication*>( qApp ); 822 return static_cast<ServerApplication*>( qApp );
821} 823}
822 824
823bool ServerApplication::isStarting() 825bool ServerApplication::isStarting()
824{ 826{
825 return ms_is_starting; 827 return ms_is_starting;
826} 828}
827 829
828int ServerApplication::exec() 830int ServerApplication::exec()
829{ 831{
830 ms_is_starting = true; 832 ms_is_starting = true;
831 odebug << "Serverapp - exec" << oendl; 833 odebug << "Serverapp - exec" << oendl;
832 return QPEApplication::exec(); 834 return QPEApplication::exec();
833} 835}
834 836
835#include "serverapp.moc" 837#include "serverapp.moc"