-rw-r--r-- | core/launcher/serverapp.cpp | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/core/launcher/serverapp.cpp b/core/launcher/serverapp.cpp index f1bce40..a2302d8 100644 --- a/core/launcher/serverapp.cpp +++ b/core/launcher/serverapp.cpp @@ -45,52 +45,58 @@ using namespace Opie::Core; #include <qfile.h> #include <qpixmapcache.h> /* STD */ #ifdef Q_OS_WIN32 #include <io.h> #include <process.h> #else #include <unistd.h> #endif #include <stdlib.h> static ServerApplication *serverApp = 0; static int loggedin=0; QCopKeyRegister::QCopKeyRegister() - : m_keyCode( 0 ) { + : m_keyCode( 0 ) +{ } QCopKeyRegister::QCopKeyRegister( int k, const QCString& c, const QCString& m ) - :m_keyCode( k ), m_channel( c ), m_message( m ) { + :m_keyCode( k ), m_channel( c ), m_message( m ) +{ } -int QCopKeyRegister::keyCode()const { +int QCopKeyRegister::keyCode() const +{ return m_keyCode; } -QCString QCopKeyRegister::channel()const { +QCString QCopKeyRegister::channel() const +{ return m_channel; } -QCString QCopKeyRegister::message()const { +QCString QCopKeyRegister::message() const +{ return m_message; } -bool QCopKeyRegister::send() { +bool QCopKeyRegister::send() +{ if (m_channel.isNull() ) return false; QCopEnvelope( m_channel, m_message ); return true; } //--------------------------------------------------------------------------- /* Priority is number of alerts that are needed to pop up alert. */ class DesktopPowerAlerter : public QMessageBox { @@ -144,73 +150,74 @@ KeyFilter::KeyFilter(QObject* parent) : QObject(parent), held_tid(0), heldButton #endif } void KeyFilter::timerEvent(QTimerEvent* e) { if ( e->timerId() == held_tid ) { killTimer(held_tid); // button held if ( heldButton ) { emit activate(heldButton, TRUE); heldButton = 0; } held_tid = 0; } } -void KeyFilter::registerKey( const QCopKeyRegister& key ) { +void KeyFilter::registerKey( const QCopKeyRegister& key ) +{ m_keys.insert( key.keyCode(), key ); } -void KeyFilter::unregisterKey( const QCopKeyRegister& key ) { +void KeyFilter::unregisterKey( const QCopKeyRegister& key ) +{ m_keys.remove( key.keyCode() ); } -bool KeyFilter::keyRegistered( int key ) { +bool KeyFilter::keyRegistered( int key ) +{ /* * Check if we've a key registered */ if ( !m_keys[key].send()) return false; else return true; - } bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepeat) { if ( !loggedin // Permitted keys && keycode != Key_F34 // power && keycode != Key_F30 // select && keycode != Key_Enter && keycode != Key_Return && keycode != Key_Space && keycode != Key_Left && keycode != Key_Right && keycode != Key_Up && keycode != Key_Down ) return TRUE; /* check if it was registered */ if (!db ) { if (keycode != 0 &&press && !autoRepeat && keyRegistered(keycode) ) return true; }else { - // First check to see if DeviceButtonManager knows something about this button: const ODeviceButton* button = ODevice::inst()->buttonForKeycode(keycode); if (button && !autoRepeat) { if ( held_tid ) { killTimer(held_tid); held_tid = 0; } if ( button->heldAction().isNull() ) { if ( press ) emit activate(button, FALSE); } else if ( press ) { heldButton = button; held_tid = startTimer( ODevice::inst ()->buttonHoldTime () ); } else if ( heldButton ) { heldButton = 0; emit activate(button, FALSE); @@ -253,33 +260,34 @@ bool KeyFilter::checkButtonAction(bool db, int keycode, int press, int autoRepe } enum MemState { MemUnknown, MemVeryLow, MemLow, MemNormal } memstate=MemUnknown; #if defined(QPE_HAVE_MEMALERTER) QPE_MEMALERTER_IMPL #endif //--------------------------------------------------------------------------- bool ServerApplication::doRestart = FALSE; bool ServerApplication::allowRestart = TRUE; bool ServerApplication::ms_is_starting = TRUE; -void ServerApplication::switchLCD( bool on ) { +void ServerApplication::switchLCD( bool on ) +{ if ( !qApp ) return; ServerApplication *dapp = ServerApplication::me() ; if ( !dapp-> m_screensaver ) return; if ( on ) { dapp-> m_screensaver-> setDisplayState ( true ); dapp-> m_screensaver-> setBacklight ( -3 ); }else dapp-> m_screensaver-> setDisplayState ( false ); } @@ -346,39 +354,39 @@ ServerApplication::ServerApplication( int& argc, char **argv, Type t ) serverApp = this; apmTimeout(); grabKeyboard(); /* make sure the event filter is installed */ const ODeviceButton* but = ODevice::inst()->buttonForKeycode( -1 ); Q_CONST_UNUSED( but ) } ServerApplication::~ServerApplication() { ungrabKeyboard(); - delete pa; delete m_ps; delete m_ps_last; } -void ServerApplication::apmTimeout() { +void ServerApplication::apmTimeout() +{ serverApp-> checkMemory( ); // in case no events are generated *m_ps_last = *m_ps; *m_ps = PowerStatusManager::readStatus(); if ( m_ps->acStatus() != m_ps_last-> acStatus() ) m_screensaver-> powerStatusChanged( *m_ps ); if ( m_ps->acStatus() == PowerStatus::Online ) { return; } int bat = m_ps-> batteryPercentRemaining(); if ( bat < m_ps_last-> batteryPercentRemaining() ) { if ( bat <= m_powerCritical ) { QMessageBox battlow( @@ -395,33 +403,34 @@ void ServerApplication::apmTimeout() { } if ( m_ps-> backupBatteryStatus() == PowerStatus::VeryLow ) { QMessageBox battlow( tr("WARNING"), tr("<p>The Back-up battery is very low" "<p>Please charge the back-up battery"), QMessageBox::Warning, QMessageBox::Cancel, QMessageBox::NoButton, QMessageBox::NoButton, 0, QString::null, TRUE, WStyle_StaysOnTop); battlow.setButtonText(QMessageBox::Cancel, tr("Ok")); battlow.exec(); } } void ServerApplication::systemMessage( const QCString& msg, - const QByteArray& data ) { + const QByteArray& data ) +{ QDataStream stream ( data, IO_ReadOnly ); if ( msg == "setScreenSaverInterval(int)" ) { int time; stream >> time; m_screensaver-> setInterval( time ); } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { int t1, t2, t3; stream >> t1 >> t2 >> t3; m_screensaver-> setIntervals( t1, t2, t3 ); } else if ( msg == "setBacklight(int)" ) { int bright; stream >> bright; m_screensaver-> setBacklight( bright ); @@ -540,33 +549,32 @@ namespace { void ServerApplication::togglePower() { static bool excllock = false; if ( excllock ) return ; excllock = true; bool wasloggedin = loggedin; loggedin = 0; m_suspendTime = QDateTime::currentDateTime(); #ifdef QWS - if ( Opie::Security::MultiauthPassword::needToAuthenticate ( true ) && qt_screen ) { // Should use a big black window instead. // But this would not show up fast enough QGfx *g = qt_screen-> screenGfx ( ); g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); delete g; } #endif ODevice::inst ( )-> suspend ( ); ServerApplication::switchLCD ( true ); // force LCD on without slow qcop call QWSServer::screenSaverActivate ( false ); { QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep @@ -614,56 +622,58 @@ bool ServerApplication::eventFilter( QObject *o, QEvent *e) { bool ServerApplication::qwsEventFilter( QWSEvent *e ) { checkMemory(); if ( e->type == QWSEvent::Mouse ) { QWSMouseEvent *me = (QWSMouseEvent *)e; static bool up = TRUE; if ( me->simpleData.state&LeftButton ) { if ( up ) { up = FALSE; screenClick(TRUE); } } else if ( !up ) { up = TRUE; screenClick(FALSE); } - }else if ( e->type == QWSEvent::Key ) { + } else + if ( e->type == QWSEvent::Key ) { QWSKeyEvent * ke = static_cast<QWSKeyEvent*>( e ); if ( kf->checkButtonAction( false, ke-> simpleData.keycode, ke-> simpleData.is_press, ke-> simpleData.is_auto_repeat ) ) return true; } return QPEApplication::qwsEventFilter( e ); } #endif /* ### FIXME libqtopia Plugin Safe Mode */ void ServerApplication::showSafeMode() { #if 0 if ( QMessageBox::warning(0, tr("Safe Mode"), tr("<P>A system startup error occurred, " "and the system is now in Safe Mode. " "Plugins are not loaded in Safe Mode. " "You can use the Plugin Manager to " - "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) { + "disable plugins that cause system error."), tr("OK"), tr("Plugin Manager..."), 0) == 1 ) + { Global::execute( "pluginmanager" ); } #endif } void ServerApplication::clearSafeMode() { #if 0 // If we've been running OK for a while then we won't bother going into // safe mode immediately on the next crash. Config cfg( "PluginLoader" ); cfg.setGroup( "Global" ); QString mode = cfg.readEntry( "Mode", "Normal" ); if ( mode == "MaybeSafe" ) { cfg.writeEntry( "Mode", "Normal" ); } |