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