author | zecke <zecke> | 2003-09-20 12:42:21 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-09-20 12:42:21 (UTC) |
commit | af02302ec3615007e34cedfb8d91dd3a55832fbb (patch) (unidiff) | |
tree | 01fcb010245fb7fcba29389f128b3e652b4df9e7 | |
parent | 0468cfef459d613ae0a32a3fa03e67726d19f6e9 (diff) | |
download | opie-af02302ec3615007e34cedfb8d91dd3a55832fbb.zip opie-af02302ec3615007e34cedfb8d91dd3a55832fbb.tar.gz opie-af02302ec3615007e34cedfb8d91dd3a55832fbb.tar.bz2 |
Fix double suspend on key input
ServerApp proxied the power() signal from KeyFilter and we've
connected togglePower() twice to it. We only need to connect
to the ServerApp power signal and not to keyfilter because we emit
power() from ServerApp on QCOP
-rw-r--r-- | core/launcher/serverapp.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index 28316a4..69e083d 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp | |||
@@ -144,385 +144,385 @@ KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton | |||
144 | 144 | ||
145 | void KeyFilter::timerEvent(QTimerEvent* e) | 145 | void KeyFilter::timerEvent(QTimerEvent* e) |
146 | { | 146 | { |
147 | if ( e->timerId() == held_tid ) { | 147 | if ( e->timerId() == held_tid ) { |
148 | killTimer(held_tid); | 148 | killTimer(held_tid); |
149 | // button held | 149 | // button held |
150 | if ( heldButton ) { | 150 | if ( heldButton ) { |
151 | emit activate(heldButton, TRUE); | 151 | emit activate(heldButton, TRUE); |
152 | heldButton = 0; | 152 | heldButton = 0; |
153 | } | 153 | } |
154 | held_tid = 0; | 154 | held_tid = 0; |
155 | } | 155 | } |
156 | } | 156 | } |
157 | 157 | ||
158 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { | 158 | void KeyFilter::registerKey( const QCopKeyRegister& key ) { |
159 | m_keys.insert( key.keyCode(), key ); | 159 | m_keys.insert( key.keyCode(), key ); |
160 | } | 160 | } |
161 | 161 | ||
162 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { | 162 | void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { |
163 | m_keys.remove( key.keyCode() ); | 163 | m_keys.remove( key.keyCode() ); |
164 | } | 164 | } |
165 | 165 | ||
166 | bool KeyFilter::keyRegistered( int key ) { | 166 | bool KeyFilter::keyRegistered( int key ) { |
167 | /* | 167 | /* |
168 | * Check if we've a key registered | 168 | * Check if we've a key registered |
169 | */ | 169 | */ |
170 | if ( !m_keys[key].send()) | 170 | if ( !m_keys[key].send()) |
171 | return false; | 171 | return false; |
172 | else | 172 | else |
173 | return true; | 173 | return true; |
174 | 174 | ||
175 | } | 175 | } |
176 | 176 | ||
177 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) | 177 | bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) |
178 | { | 178 | { |
179 | if ( !loggedin | 179 | if ( !loggedin |
180 | // Permitted keys | 180 | // Permitted keys |
181 | && keycode != Key_F34 // power | 181 | && keycode != Key_F34 // power |
182 | && keycode != Key_F30 // select | 182 | && keycode != Key_F30 // select |
183 | && keycode != Key_Enter | 183 | && keycode != Key_Enter |
184 | && keycode != Key_Return | 184 | && keycode != Key_Return |
185 | && keycode != Key_Space | 185 | && keycode != Key_Space |
186 | && keycode != Key_Left | 186 | && keycode != Key_Left |
187 | && keycode != Key_Right | 187 | && keycode != Key_Right |
188 | && keycode != Key_Up | 188 | && keycode != Key_Up |
189 | && keycode != Key_Down ) | 189 | && keycode != Key_Down ) |
190 | return TRUE; | 190 | return TRUE; |
191 | 191 | ||
192 | /* check if it was registered */ | 192 | /* check if it was registered */ |
193 | if (!db ) { | 193 | if (!db ) { |
194 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) | 194 | if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) |
195 | return true; | 195 | return true; |
196 | }else { | 196 | }else { |
197 | 197 | ||
198 | 198 | ||
199 | // First check to see if DeviceButtonManager knows something about this button: | 199 | // First check to see if DeviceButtonManager knows something about this button: |
200 | const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); | 200 | const Opie::ODeviceButton* button = Opie::ODevice::inst()->buttonForKeycode(keycode); |
201 | if (button && !autoRepeat) { | 201 | if (button && !autoRepeat) { |
202 | if ( held_tid ) { | 202 | if ( held_tid ) { |
203 | killTimer(held_tid); | 203 | killTimer(held_tid); |
204 | held_tid = 0; | 204 | held_tid = 0; |
205 | } | 205 | } |
206 | if ( button->heldAction().isNull() ) { | 206 | if ( button->heldAction().isNull() ) { |
207 | if ( press ) | 207 | if ( press ) |
208 | emit activate(button, FALSE); | 208 | emit activate(button, FALSE); |
209 | } else if ( press ) { | 209 | } else if ( press ) { |
210 | heldButton = button; | 210 | heldButton = button; |
211 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); | 211 | held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); |
212 | } else if ( heldButton ) { | 212 | } else if ( heldButton ) { |
213 | heldButton = 0; | 213 | heldButton = 0; |
214 | emit activate(button, FALSE); | 214 | emit activate(button, FALSE); |
215 | } | 215 | } |
216 | QWSServer::screenSaverActivate(FALSE); | 216 | QWSServer::screenSaverActivate(FALSE); |
217 | return TRUE; | 217 | return TRUE; |
218 | } | 218 | } |
219 | return false; | 219 | return false; |
220 | } | 220 | } |
221 | if ( keycode == HardKey_Suspend ) { | 221 | if ( keycode == HardKey_Suspend ) { |
222 | if ( press ) emit power(); | 222 | if ( press ) emit power(); |
223 | return TRUE; | 223 | return TRUE; |
224 | } | 224 | } |
225 | if ( keycode == HardKey_Backlight ) { | 225 | if ( keycode == HardKey_Backlight ) { |
226 | if ( press ) emit backlight(); | 226 | if ( press ) emit backlight(); |
227 | return TRUE; | 227 | return TRUE; |
228 | } | 228 | } |
229 | if ( keycode == Key_F32 ) { | 229 | if ( keycode == Key_F32 ) { |
230 | #ifndef QT_NO_COP | 230 | #ifndef QT_NO_COP |
231 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 231 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
232 | #endif | 232 | #endif |
233 | return TRUE; | 233 | return TRUE; |
234 | } | 234 | } |
235 | if ( keycode == Key_F31 ) { | 235 | if ( keycode == Key_F31 ) { |
236 | if ( press ) emit symbol(); | 236 | if ( press ) emit symbol(); |
237 | QWSServer::screenSaverActivate(FALSE); | 237 | QWSServer::screenSaverActivate(FALSE); |
238 | return TRUE; | 238 | return TRUE; |
239 | } | 239 | } |
240 | 240 | ||
241 | if ( keycode == Key_NumLock ) | 241 | if ( keycode == Key_NumLock ) |
242 | if ( press ) emit numLockStateToggle(); | 242 | if ( press ) emit numLockStateToggle(); |
243 | 243 | ||
244 | if ( keycode == Key_CapsLock ) | 244 | if ( keycode == Key_CapsLock ) |
245 | if ( press ) emit capsLockStateToggle(); | 245 | if ( press ) emit capsLockStateToggle(); |
246 | 246 | ||
247 | if ( serverApp ) | 247 | if ( serverApp ) |
248 | serverApp->keyClick(keycode,press,autoRepeat); | 248 | serverApp->keyClick(keycode,press,autoRepeat); |
249 | 249 | ||
250 | return FALSE; | 250 | return FALSE; |
251 | } | 251 | } |
252 | 252 | ||
253 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; | 253 | enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; |
254 | 254 | ||
255 | #if defined(QPE_HAVE_MEMALERTER) | 255 | #if defined(QPE_HAVE_MEMALERTER) |
256 | QPE_MEMALERTER_IMPL | 256 | QPE_MEMALERTER_IMPL |
257 | #endif | 257 | #endif |
258 | 258 | ||
259 | 259 | ||
260 | 260 | ||
261 | //--------------------------------------------------------------------------- | 261 | //--------------------------------------------------------------------------- |
262 | 262 | ||
263 | bool ServerApplication::doRestart = FALSE; | 263 | bool ServerApplication::doRestart = FALSE; |
264 | bool ServerApplication::allowRestart = TRUE; | 264 | bool ServerApplication::allowRestart = TRUE; |
265 | 265 | ||
266 | void ServerApplication::switchLCD( bool on ) { | 266 | void ServerApplication::switchLCD( bool on ) { |
267 | if ( !qApp ) | 267 | if ( !qApp ) |
268 | return; | 268 | return; |
269 | 269 | ||
270 | ServerApplication *dapp = ServerApplication::me() ; | 270 | ServerApplication *dapp = ServerApplication::me() ; |
271 | 271 | ||
272 | if ( !dapp-> m_screensaver ) | 272 | if ( !dapp-> m_screensaver ) |
273 | return; | 273 | return; |
274 | 274 | ||
275 | if ( on ) { | 275 | if ( on ) { |
276 | dapp-> m_screensaver-> setDisplayState ( true ); | 276 | dapp-> m_screensaver-> setDisplayState ( true ); |
277 | dapp-> m_screensaver-> setBacklight ( -3 ); | 277 | dapp-> m_screensaver-> setBacklight ( -3 ); |
278 | }else | 278 | }else |
279 | dapp-> m_screensaver-> setDisplayState ( false ); | 279 | dapp-> m_screensaver-> setDisplayState ( false ); |
280 | 280 | ||
281 | 281 | ||
282 | } | 282 | } |
283 | 283 | ||
284 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) | 284 | ServerApplication::ServerApplication( int& argc, char **argv, Type t ) |
285 | : QPEApplication( argc, argv, t ) | 285 | : QPEApplication( argc, argv, t ) |
286 | { | 286 | { |
287 | 287 | ||
288 | 288 | ||
289 | // We know we'll have lots of cached pixmaps due to App/DocLnks | 289 | // We know we'll have lots of cached pixmaps due to App/DocLnks |
290 | QPixmapCache::setCacheLimit(512); | 290 | QPixmapCache::setCacheLimit(512); |
291 | 291 | ||
292 | m_ps = new PowerStatus; | 292 | m_ps = new PowerStatus; |
293 | m_ps_last = new PowerStatus; | 293 | m_ps_last = new PowerStatus; |
294 | pa = new DesktopPowerAlerter( 0 ); | 294 | pa = new DesktopPowerAlerter( 0 ); |
295 | 295 | ||
296 | m_apm_timer = new QTimer( this ); | 296 | m_apm_timer = new QTimer( this ); |
297 | connect(m_apm_timer, SIGNAL( timeout() ), | 297 | connect(m_apm_timer, SIGNAL( timeout() ), |
298 | this, SLOT( apmTimeout() ) ); | 298 | this, SLOT( apmTimeout() ) ); |
299 | 299 | ||
300 | reloadPowerWarnSettings(); | 300 | reloadPowerWarnSettings(); |
301 | 301 | ||
302 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 302 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
303 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | 303 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), |
304 | this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); | 304 | this, SLOT(systemMessage(const QCString&, const QByteArray& ) ) ); |
305 | 305 | ||
306 | channel = new QCopChannel("QPE/Launcher", this ); | 306 | channel = new QCopChannel("QPE/Launcher", this ); |
307 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), | 307 | connect(channel, SIGNAL(received( const QCString&, const QByteArray& ) ), |
308 | this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); | 308 | this, SLOT(launcherMessage( const QCString&, const QByteArray& ) ) ); |
309 | 309 | ||
310 | m_screensaver = new OpieScreenSaver(); | 310 | m_screensaver = new OpieScreenSaver(); |
311 | m_screensaver->setInterval( -1 ); | 311 | m_screensaver->setInterval( -1 ); |
312 | QWSServer::setScreenSaver( m_screensaver ); | 312 | QWSServer::setScreenSaver( m_screensaver ); |
313 | 313 | ||
314 | connect( qApp, SIGNAL( volumeChanged( bool ) ), | 314 | connect( qApp, SIGNAL( volumeChanged( bool ) ), |
315 | this, SLOT( rereadVolumes() ) ); | 315 | this, SLOT( rereadVolumes() ) ); |
316 | 316 | ||
317 | 317 | ||
318 | /* ### PluginLoader libqtopia SafeMode */ | 318 | /* ### PluginLoader libqtopia SafeMode */ |
319 | #if 0 | 319 | #if 0 |
320 | if ( PluginLoader::inSafeMode() ) | 320 | if ( PluginLoader::inSafeMode() ) |
321 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); | 321 | QTimer::singleShot(500, this, SLOT(showSafeMode()) ); |
322 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); | 322 | QTimer::singleShot(20*1000, this, SLOT(clearSafeMode()) ); |
323 | #endif | 323 | #endif |
324 | 324 | ||
325 | kf = new KeyFilter(this); | 325 | kf = new KeyFilter(this); |
326 | 326 | ||
327 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); | 327 | connect( kf, SIGNAL(launch()), this, SIGNAL(launch()) ); |
328 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); | 328 | connect( kf, SIGNAL(power()), this, SIGNAL(power()) ); |
329 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); | 329 | connect( kf, SIGNAL(backlight()), this, SIGNAL(backlight()) ); |
330 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); | 330 | connect( kf, SIGNAL(symbol()), this, SIGNAL(symbol())); |
331 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); | 331 | connect( kf, SIGNAL(numLockStateToggle()), this,SIGNAL(numLockStateToggle())); |
332 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); | 332 | connect( kf, SIGNAL(capsLockStateToggle()), this,SIGNAL(capsLockStateToggle())); |
333 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), | 333 | connect( kf, SIGNAL(activate(const Opie::ODeviceButton*,bool)), |
334 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); | 334 | this,SIGNAL(activate(const Opie::ODeviceButton*,bool))); |
335 | 335 | ||
336 | connect( kf, SIGNAL(power()), this, SLOT(togglePower()) ); | 336 | |
337 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); | 337 | connect( kf, SIGNAL(backlight()), this, SLOT(toggleLight()) ); |
338 | 338 | ||
339 | connect( this, SIGNAL(power() ), | 339 | connect( this, SIGNAL(power() ), |
340 | SLOT(togglePower() ) ); | 340 | SLOT(togglePower() ) ); |
341 | 341 | ||
342 | rereadVolumes(); | 342 | rereadVolumes(); |
343 | 343 | ||
344 | serverApp = this; | 344 | serverApp = this; |
345 | 345 | ||
346 | apmTimeout(); | 346 | apmTimeout(); |
347 | grabKeyboard(); | 347 | grabKeyboard(); |
348 | 348 | ||
349 | /* make sure the event filter is installed */ | 349 | /* make sure the event filter is installed */ |
350 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); | 350 | const Opie::ODeviceButton* but = Opie::ODevice::inst()->buttonForKeycode( -1 ); |
351 | } | 351 | } |
352 | 352 | ||
353 | 353 | ||
354 | ServerApplication::~ServerApplication() | 354 | ServerApplication::~ServerApplication() |
355 | { | 355 | { |
356 | ungrabKeyboard(); | 356 | ungrabKeyboard(); |
357 | 357 | ||
358 | 358 | ||
359 | delete pa; | 359 | delete pa; |
360 | delete m_ps; | 360 | delete m_ps; |
361 | delete m_ps_last; | 361 | delete m_ps_last; |
362 | } | 362 | } |
363 | 363 | ||
364 | void ServerApplication::apmTimeout() { | 364 | void ServerApplication::apmTimeout() { |
365 | serverApp-> checkMemory( ); // in case no events are generated | 365 | serverApp-> checkMemory( ); // in case no events are generated |
366 | *m_ps_last = *m_ps; | 366 | *m_ps_last = *m_ps; |
367 | *m_ps = PowerStatusManager::readStatus(); | 367 | *m_ps = PowerStatusManager::readStatus(); |
368 | 368 | ||
369 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) | 369 | if ( m_ps->acStatus() != m_ps_last-> acStatus() ) |
370 | m_screensaver-> powerStatusChanged( *m_ps ); | 370 | m_screensaver-> powerStatusChanged( *m_ps ); |
371 | 371 | ||
372 | if ( m_ps->acStatus() == PowerStatus::Online ) | 372 | if ( m_ps->acStatus() == PowerStatus::Online ) |
373 | return; | 373 | return; |
374 | 374 | ||
375 | int bat = m_ps-> batteryPercentRemaining(); | 375 | int bat = m_ps-> batteryPercentRemaining(); |
376 | 376 | ||
377 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { | 377 | if ( bat < m_ps_last-> batteryPercentRemaining() ) { |
378 | if ( bat <= m_powerCritical ) | 378 | if ( bat <= m_powerCritical ) |
379 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); | 379 | pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); |
380 | else if ( bat <= m_powerVeryLow ) | 380 | else if ( bat <= m_powerVeryLow ) |
381 | pa->alert( tr( "Battery is running very low. "), 2 ); | 381 | pa->alert( tr( "Battery is running very low. "), 2 ); |
382 | } | 382 | } |
383 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) | 383 | if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) |
384 | pa->alert( tr("The Back-up battery is very low.\nPlease charge the back-up battery." ), 2); | 384 | pa->alert( tr("The Back-up battery is very low.\nPlease charge the back-up battery." ), 2); |
385 | 385 | ||
386 | } | 386 | } |
387 | 387 | ||
388 | void ServerApplication::systemMessage( const QCString& msg, | 388 | void ServerApplication::systemMessage( const QCString& msg, |
389 | const QByteArray& data ) { | 389 | const QByteArray& data ) { |
390 | QDataStream stream ( data, IO_ReadOnly ); | 390 | QDataStream stream ( data, IO_ReadOnly ); |
391 | 391 | ||
392 | if ( msg == "setScreenSaverInterval(int)" ) { | 392 | if ( msg == "setScreenSaverInterval(int)" ) { |
393 | int time; | 393 | int time; |
394 | stream >> time; | 394 | stream >> time; |
395 | m_screensaver-> setInterval( time ); | 395 | m_screensaver-> setInterval( time ); |
396 | } | 396 | } |
397 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 397 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
398 | int t1, t2, t3; | 398 | int t1, t2, t3; |
399 | stream >> t1 >> t2 >> t3; | 399 | stream >> t1 >> t2 >> t3; |
400 | m_screensaver-> setIntervals( t1, t2, t3 ); | 400 | m_screensaver-> setIntervals( t1, t2, t3 ); |
401 | } | 401 | } |
402 | else if ( msg == "setBacklight(int)" ) { | 402 | else if ( msg == "setBacklight(int)" ) { |
403 | int bright; | 403 | int bright; |
404 | stream >> bright; | 404 | stream >> bright; |
405 | m_screensaver-> setBacklight( bright ); | 405 | m_screensaver-> setBacklight( bright ); |
406 | } | 406 | } |
407 | else if ( msg == "setScreenSaverMode(int)" ) { | 407 | else if ( msg == "setScreenSaverMode(int)" ) { |
408 | int mode; | 408 | int mode; |
409 | stream >> mode; | 409 | stream >> mode; |
410 | m_screensaver-> setMode ( mode ); | 410 | m_screensaver-> setMode ( mode ); |
411 | } | 411 | } |
412 | else if ( msg == "reloadPowerWarnSettings()" ) { | 412 | else if ( msg == "reloadPowerWarnSettings()" ) { |
413 | reloadPowerWarnSettings(); | 413 | reloadPowerWarnSettings(); |
414 | } | 414 | } |
415 | else if ( msg == "setDisplayState(int)" ) { | 415 | else if ( msg == "setDisplayState(int)" ) { |
416 | int state; | 416 | int state; |
417 | stream >> state; | 417 | stream >> state; |
418 | m_screensaver-> setDisplayState ( state != 0 ); | 418 | m_screensaver-> setDisplayState ( state != 0 ); |
419 | } | 419 | } |
420 | else if ( msg == "suspend()" ) { | 420 | else if ( msg == "suspend()" ) { |
421 | emit power(); | 421 | emit power(); |
422 | } | 422 | } |
423 | else if ( msg == "sendBusinessCard()" ) { | 423 | else if ( msg == "sendBusinessCard()" ) { |
424 | QString card = ::getenv ( "HOME" ); | 424 | QString card = ::getenv ( "HOME" ); |
425 | card += "/Applications/addressbook/businesscard.vcf"; | 425 | card += "/Applications/addressbook/businesscard.vcf"; |
426 | 426 | ||
427 | if ( QFile::exists( card ) ) { | 427 | if ( QFile::exists( card ) ) { |
428 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); | 428 | QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" ); |
429 | QString mimetype = "text/x-vCard"; | 429 | QString mimetype = "text/x-vCard"; |
430 | e << tr( "business card" ) << card << mimetype; | 430 | e << tr( "business card" ) << card << mimetype; |
431 | } | 431 | } |
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | void ServerApplication::reloadPowerWarnSettings ( ) | 435 | void ServerApplication::reloadPowerWarnSettings ( ) |
436 | { | 436 | { |
437 | Config cfg ( "apm" ); | 437 | Config cfg ( "apm" ); |
438 | cfg. setGroup ( "Warnings" ); | 438 | cfg. setGroup ( "Warnings" ); |
439 | 439 | ||
440 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); | 440 | int iv = cfg. readNumEntry ( "checkinterval", 10000 ); |
441 | 441 | ||
442 | m_apm_timer-> stop ( ); | 442 | m_apm_timer-> stop ( ); |
443 | if ( iv ) | 443 | if ( iv ) |
444 | m_apm_timer-> start ( iv ); | 444 | m_apm_timer-> start ( iv ); |
445 | 445 | ||
446 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); | 446 | m_powerVeryLow = cfg. readNumEntry ( "powerverylow", 10 ); |
447 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); | 447 | m_powerCritical = cfg. readNumEntry ( "powervcritical", 5 ); |
448 | } | 448 | } |
449 | 449 | ||
450 | void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) | 450 | void ServerApplication::launcherMessage( const QCString & msg, const QByteArray & data ) |
451 | { | 451 | { |
452 | QDataStream stream ( data, IO_ReadOnly ); | 452 | QDataStream stream ( data, IO_ReadOnly ); |
453 | 453 | ||
454 | if ( msg == "deviceButton(int,int,int)" ) { | 454 | if ( msg == "deviceButton(int,int,int)" ) { |
455 | int keycode, press, autoRepeat; | 455 | int keycode, press, autoRepeat; |
456 | stream >> keycode >> press >> autoRepeat; | 456 | stream >> keycode >> press >> autoRepeat; |
457 | 457 | ||
458 | kf->checkButtonAction ( true, keycode, press, autoRepeat ); | 458 | kf->checkButtonAction ( true, keycode, press, autoRepeat ); |
459 | } | 459 | } |
460 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { | 460 | else if ( msg == "keyRegister(int,QCString,QCString)" ) { |
461 | int k; | 461 | int k; |
462 | QCString c, m; | 462 | QCString c, m; |
463 | stream >> k >> c >> m; | 463 | stream >> k >> c >> m; |
464 | 464 | ||
465 | kf -> registerKey( QCopKeyRegister(k, c, m) ); | 465 | kf -> registerKey( QCopKeyRegister(k, c, m) ); |
466 | } | 466 | } |
467 | } | 467 | } |
468 | 468 | ||
469 | 469 | ||
470 | bool ServerApplication::screenLocked() | 470 | bool ServerApplication::screenLocked() |
471 | { | 471 | { |
472 | return loggedin == 0; | 472 | return loggedin == 0; |
473 | } | 473 | } |
474 | 474 | ||
475 | void ServerApplication::login(bool at_poweron) | 475 | void ServerApplication::login(bool at_poweron) |
476 | { | 476 | { |
477 | if ( !loggedin ) { | 477 | if ( !loggedin ) { |
478 | Global::terminateBuiltin("calibrate"); // No tr | 478 | Global::terminateBuiltin("calibrate"); // No tr |
479 | Password::authenticate(at_poweron); | 479 | Password::authenticate(at_poweron); |
480 | loggedin=1; | 480 | loggedin=1; |
481 | #ifndef QT_NO_COP | 481 | #ifndef QT_NO_COP |
482 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 482 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
483 | #endif | 483 | #endif |
484 | } | 484 | } |
485 | } | 485 | } |
486 | 486 | ||
487 | #if defined(QPE_HAVE_TOGGLELIGHT) | 487 | #if defined(QPE_HAVE_TOGGLELIGHT) |
488 | #include <qtopia/config.h> | 488 | #include <qtopia/config.h> |
489 | 489 | ||
490 | #include <sys/ioctl.h> | 490 | #include <sys/ioctl.h> |
491 | #include <sys/types.h> | 491 | #include <sys/types.h> |
492 | #include <fcntl.h> | 492 | #include <fcntl.h> |
493 | #include <unistd.h> | 493 | #include <unistd.h> |
494 | #include <errno.h> | 494 | #include <errno.h> |
495 | #include <linux/ioctl.h> | 495 | #include <linux/ioctl.h> |
496 | #include <time.h> | 496 | #include <time.h> |
497 | #endif | 497 | #endif |
498 | 498 | ||
499 | #if 0 | 499 | #if 0 |
500 | static bool blanked=FALSE; | 500 | static bool blanked=FALSE; |
501 | 501 | ||
502 | static void blankScreen() | 502 | static void blankScreen() |
503 | { | 503 | { |
504 | #ifdef QWS | 504 | #ifdef QWS |
505 | QWidget w(0, 0, Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool | Qt::WStyle_StaysOnTop | Qt::WPaintUnclipped); | 505 | QWidget w(0, 0, Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_Tool | Qt::WStyle_StaysOnTop | Qt::WPaintUnclipped); |
506 | w.resize( qt_screen->width(), qt_screen->height() ); | 506 | w.resize( qt_screen->width(), qt_screen->height() ); |
507 | w.move(0, 0); | 507 | w.move(0, 0); |
508 | 508 | ||
509 | QPainter p(&w); | 509 | QPainter p(&w); |
510 | p.fillRect(w.rect(), QBrush(QColor(255,255,255)) ); | 510 | p.fillRect(w.rect(), QBrush(QColor(255,255,255)) ); |
511 | p.end(); | 511 | p.end(); |
512 | w.repaint(); | 512 | w.repaint(); |
513 | 513 | ||
514 | blanked = TRUE; | 514 | blanked = TRUE; |
515 | #endif | 515 | #endif |
516 | } | 516 | } |
517 | 517 | ||
518 | static void darkScreen() | 518 | static void darkScreen() |
519 | { | 519 | { |
520 | /* ### Screen blanking ODevice */ | 520 | /* ### Screen blanking ODevice */ |
521 | #if 0 | 521 | #if 0 |
522 | qpe_setBacklight(0); // force off | 522 | qpe_setBacklight(0); // force off |
523 | #endif | 523 | #endif |
524 | } | 524 | } |
525 | #endif | 525 | #endif |
526 | 526 | ||
527 | namespace { | 527 | namespace { |
528 | void execAutoStart(const QDateTime& suspendTime ) { | 528 | void execAutoStart(const QDateTime& suspendTime ) { |