-rw-r--r-- | core/launcher/desktop.cpp | 28 | ||||
-rw-r--r-- | library/password.cpp | 24 | ||||
-rw-r--r-- | library/password.h | 1 |
3 files changed, 43 insertions, 10 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 0e60839..d74b745 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp @@ -160,49 +160,49 @@ private: public: QPEScreenSaver() { m_disable_suspend = 100; m_enable_dim = false; m_enable_lightoff = false; m_enable_onlylcdoff = false; m_lcd_status = true; m_backlight_bright = -1; m_backlight_forcedoff = false; // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) ODevice::inst ( ) -> setDisplayStatus ( true ); } void restore() { if ( !m_lcd_status ) { // We must have turned it off ODevice::inst ( ) -> setDisplayStatus ( true ); m_lcd_status = true; } - setBacklight ( -3 ); + setBacklight ( -1 ); } bool save( int level ) { switch ( level ) { case 0: if ( m_disable_suspend > 0 && m_enable_dim ) { if ( backlight() > 1 ) setBacklight( 1 ); // lowest non-off } return true; break; case 1: if ( m_disable_suspend > 1 && m_enable_lightoff ) { setBacklight( 0 ); // off } return true; break; case 2: if ( m_enable_onlylcdoff ) { ODevice::inst ( ) -> setDisplayStatus ( false ); m_lcd_status = false; return true; } else // We're going to suspend the whole machine @@ -311,53 +311,55 @@ public: ODevice::inst ( ) -> setDisplayStatus ( on ); m_lcd_status = on; } } private: int m_disable_suspend; bool m_enable_dim; bool m_enable_lightoff; bool m_enable_onlylcdoff; bool m_lcd_status; int m_backlight_bright; bool m_backlight_forcedoff; }; void DesktopApplication::switchLCD ( bool on ) { if ( qApp ) { DesktopApplication *dapp = (DesktopApplication *) qApp; if ( dapp-> m_screensaver ) { - if ( on ) - dapp-> m_screensaver-> restore ( ); //setBacklight ( on ? -3 : -1 ); - else - dapp-> m_screensaver-> save ( 1 ); - + if ( on ) { + dapp-> m_screensaver-> setDisplayState ( true ); + dapp-> m_screensaver-> setBacklight ( -3 ); + } + else { + dapp-> m_screensaver-> setDisplayState ( false ); + } } } } DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) : QPEApplication( argc, argv, appType ) { QTimer * t = new QTimer( this ); connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); t->start( 10000 ); ps = new PowerStatus; pa = new DesktopPowerAlerter( 0 ); channel = new QCopChannel( "QPE/Desktop", this ); connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); channel = new QCopChannel( "QPE/System", this ); connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); m_screensaver = new QPEScreenSaver; @@ -849,59 +851,69 @@ void Desktop::execAutoStart() #include <sys/types.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> #include <linux/ioctl.h> #include <time.h> #endif void Desktop::togglePower() { static bool excllock = false; qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); if ( excllock ) return ; excllock = true; bool wasloggedin = loggedin; loggedin = 0; suspendTime = QDateTime::currentDateTime(); +#ifdef QWS + if ( Password::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 ( ); - QWSServer::screenSaverActivate ( false ); DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call + QWSServer::screenSaverActivate ( false ); { QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep } if ( wasloggedin ) - login( TRUE ); + login ( true ); execAutoStart(); //qcopBridge->closeOpenConnections(); excllock = false; } void Desktop::toggleLight() { QCopEnvelope e( "QPE/System", "setBacklight(int)" ); e << -2; // toggle } void Desktop::toggleSymbolInput() { tb->toggleSymbolInput(); } void Desktop::toggleNumLockState() { tb->toggleNumLockState(); } void Desktop::toggleCapsLockState() diff --git a/library/password.cpp b/library/password.cpp index 4b22b65..6d126c4 100644 --- a/library/password.cpp +++ b/library/password.cpp @@ -6,49 +6,49 @@ ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #include "password.h" #include "config.h" #include "global.h" #include "backend/contact.h" #include <qlabel.h> #include <qlineedit.h> #include <qtextview.h> #include <qstring.h> #include <qapplication.h> #include <qfile.h> -#include <qwindowsystem_qws.h> +//#include <qwindowsystem_qws.h> #include <qdialog.h> #include <unistd.h> //for sleep #include "passwordbase_p.h" class PasswordDialog : public PasswordBase { Q_OBJECT public: PasswordDialog( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); ~PasswordDialog(); void clear(); void setPrompt( const QString& ); signals: void passwordEntered( const QString& ); protected: bool eventFilter( QObject*, QEvent* ); void keyPressEvent( QKeyEvent * ); @@ -264,70 +264,90 @@ private: or the empty string if the user enters no password (but confirms the dialog). */ QString Password::getPassword( const QString& prompt ) { PasswdDlg pd(0,0,TRUE); pd.passw->setPrompt( prompt ); pd.showMaximized(); int r = pd.exec(); if ( r == QDialog::Accepted ) { if (pd.passw->text.isEmpty()) return ""; else return qcrypt(pd.passw->text,"a0"); } else { return QString::null; } } /*! + Return if a prompt for the user's passcode is needed. + + If \a at_poweron is TRUE, the dialog is only used if the user's + preference request it at poweron + + Opie extension to speed up suspend/resume. +*/ + +bool Password::needToAuthenticate(bool at_poweron) +{ + Config cfg("Security"); + cfg.setGroup("Passcode"); + QString passcode = cfg.readEntry("passcode"); + + return ( !passcode.isEmpty() + && (!at_poweron || cfg.readNumEntry("passcode_poweron",0)) ); +} + +/*! Prompt, fullscreen, for the user's passcode until they get it right. If \a at_poweron is TRUE, the dialog is only used if the user's preference request it at poweron; either way, the screen is always repainted by this function. (this functionality may move to the caller of this function). */ void Password::authenticate(bool at_poweron) { Config cfg("Security"); cfg.setGroup("Passcode"); QString passcode = cfg.readEntry("passcode"); if ( !passcode.isEmpty() && (!at_poweron || cfg.readNumEntry("passcode_poweron",0)) ) { // Do it as a fullscreen modal dialog PasswdDlg pd(0,0,TRUE,TRUE); // see if there is contact information. OwnerDlg *oi = 0; QString vfilename = Global::applicationFileName("addressbook", "businesscard.vcf"); if (QFile::exists(vfilename)) { Contact c; c = Contact::readVCard( vfilename )[0]; oi = new OwnerDlg(0, 0, c, TRUE, TRUE); } pd.reset(); pd.exec(); while (qcrypt(pd.passw->text, "a0") != passcode) { if (oi) oi->exec(); pd.reset(); pd.exec(); } } else if ( at_poweron ) { // refresh screen #### should probably be in caller - // Not needed (we took away the screen blacking) + // Not needed (we took away the screen blacking) TT + // Not needed (we have intelligent screen blacking) sandman //if ( qwsServer ) //qwsServer->refresh(); } } #include "password.moc" diff --git a/library/password.h b/library/password.h index a3a3e45..a2f2c3c 100644 --- a/library/password.h +++ b/library/password.h @@ -4,29 +4,30 @@ ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef PASSWORD_H #define PASSWORD_H #include <qstring.h> class Password { public: + static bool needToAuthenticate(bool atpoweron=FALSE); // Opie extension to speed up suspend/resume (sandman) static void authenticate(bool atpoweron=FALSE); static QString getPassword( const QString& prompt ); }; #endif // PASSWORD_H |