author | sandman <sandman> | 2002-10-17 00:39:31 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-17 00:39:31 (UTC) |
commit | 259d10f40405fd77ba0a8947782f716be94da3a5 (patch) (side-by-side diff) | |
tree | 636cb3a899d27a8fe41f377fabc5bd170a74c6dc /library/password.cpp | |
parent | 5d28c61d84da1814d356540b557bbfe026da98aa (diff) | |
download | opie-259d10f40405fd77ba0a8947782f716be94da3a5.zip opie-259d10f40405fd77ba0a8947782f716be94da3a5.tar.gz opie-259d10f40405fd77ba0a8947782f716be94da3a5.tar.bz2 |
- fix for bug #292 (Improper behaviour of frontlight disabling)
- fix for bug #199 (Desktop visible on resume before password dialog
appears)
-rw-r--r-- | library/password.cpp | 24 |
1 files changed, 22 insertions, 2 deletions
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" |