diff options
Diffstat (limited to 'tdmlib/kgreet_classic.cpp')
-rw-r--r-- | tdmlib/kgreet_classic.cpp | 157 |
1 files changed, 132 insertions, 25 deletions
diff --git a/tdmlib/kgreet_classic.cpp b/tdmlib/kgreet_classic.cpp index 3d1cedc19..d22f6979f 100644 --- a/tdmlib/kgreet_classic.cpp +++ b/tdmlib/kgreet_classic.cpp @@ -45,6 +45,15 @@ protected: static int echoMode; +TQString KClassicGreeter::passwordPrompt() { + if (func == Authenticate) { + return i18n("&Password:"); + } + else { + return i18n("Current &password:"); + } +} + KClassicGreeter::KClassicGreeter( KGreeterPluginHandler *_handler, KdmThemer *themer, TQWidget *parent, TQWidget *pred, @@ -57,10 +66,12 @@ KClassicGreeter::KClassicGreeter( KGreeterPluginHandler *_handler, ctx( _ctx ), exp( -1 ), pExp( -1 ), - running( false ) + running( false ), + userEntryLocked(false), + suppressInfoMsg(false) { KdmItem *user_entry = 0, *pw_entry = 0; - TQGridLayout *grid = 0; + grid = 0; int line = 0; layoutItem = 0; @@ -120,11 +131,7 @@ KClassicGreeter::KClassicGreeter( KGreeterPluginHandler *_handler, passwdEdit->adjustSize(); pw_entry->setWidget( passwdEdit ); } else { - passwdLabel = new TQLabel( passwdEdit, - func == Authenticate ? - i18n("&Password:") : - i18n("Current &password:"), - parent ); + passwdLabel = new TQLabel( passwdEdit, passwordPrompt(), parent ); grid->addWidget( passwdLabel, line, 0 ); grid->addWidget( passwdEdit, line++, 1 ); } @@ -217,6 +224,11 @@ KClassicGreeter::setUser( const TQString &user ) passwdEdit->selectAll(); } +void KClassicGreeter::lockUserEntry( const bool lock ) { + userEntryLocked = lock; + loginEdit->setEnabled(!lock); +} + void // virtual KClassicGreeter::setPassword( const TQString &pass ) { @@ -237,6 +249,27 @@ KClassicGreeter::setEnabled( bool enable ) passwdEdit->setFocus(); } +void KClassicGreeter::setInfoMessageDisplay(bool enable) { + suppressInfoMsg = !enable; +} + +void KClassicGreeter::setPasswordPrompt(const TQString &prompt) { + if (passwdLabel) { + passwdPromptCustomString = prompt; + + if (prompt != TQString::null) { + passwdLabel->setText(prompt); + } + else { + passwdLabel->setText(passwordPrompt()); + } + if (grid) { + grid->invalidate(); + grid->activate(); + } + } +} + void // private KClassicGreeter::returnData() { @@ -267,8 +300,19 @@ bool // virtual KClassicGreeter::textMessage( const char *text, bool err ) { if (!err && - TQString( text ).find( TQRegExp( "^Changing password for [^ ]+$" ) ) >= 0) + TQString( text ).find( TQRegExp( "^Changing password for [^ ]+$" ) ) >= 0) { + return true; + } + if (!err && suppressInfoMsg) { return true; + } + if ((!err && ((TQString(text).lower().find("smartcard") >= 0) || (TQString(text).lower().find("smart card") >= 0))) + || (err && (TQString(text).lower().find(" 2306:") >= 0)) || (err && (TQString(text).lower().find("PKINIT") >= 0))) { + // FIXME + // pam_pkcs11 is extremely chatty, even with no card inserted, + // and there is no apparent way to disable the unwanted messages! + return true; + } return false; } @@ -276,13 +320,30 @@ void // virtual KClassicGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking ) { pExp = exp; - if (echo) + if (echo) { exp = 0; - else if (!authTok) + } + else if (!authTok) { exp = 1; + if (passwdLabel) { + if (prompt && (prompt[0] != 0)) { + passwdLabel->setText(prompt); + } + else { + if (passwdPromptCustomString == TQString::null) { + passwdLabel->setText(passwordPrompt()); + } + } + if (grid) { + grid->invalidate(); + grid->activate(); + } + } + } else { TQString pr( prompt ); - if (pr.find( TQRegExp( "\\bpassword\\b", false ) ) >= 0) { + if ((pr.find( TQRegExp( "\\bpassword\\b", false ) ) >= 0) + || (pr.find( TQRegExp( "\\bPIN\\b", false ) ) >= 0)) { if (pr.find( TQRegExp( "\\b(re-?(enter|type)|again|confirm|repeat)\\b", false ) ) >= 0) exp = 3; @@ -294,7 +355,8 @@ KClassicGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking ) KGreeterPluginHandler::IsSecret ); return; } - } else { + } + else { handler->gplugMsgBox( TQMessageBox::Critical, i18n("Unrecognized prompt \"%1\"") .arg( prompt ) ); @@ -309,8 +371,9 @@ KClassicGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking ) has = -1; } - if (has >= exp || nonBlocking) + if (has >= exp || nonBlocking) { returnData(); + } } bool // virtual @@ -392,6 +455,15 @@ KClassicGreeter::succeeded() void // virtual KClassicGreeter::failed() { + if (passwdLabel && (passwdPromptCustomString == TQString::null)) { + // reset password prompt + passwdLabel->setText(passwordPrompt()); + if (grid) { + grid->invalidate(); + grid->activate(); + } + } + // assert( running || timed_login ); setActive( false ); setActive2( false ); @@ -402,22 +474,41 @@ KClassicGreeter::failed() void // virtual KClassicGreeter::revive() { - // assert( !running ); - setActive2( true ); + if (passwdLabel && (passwdPromptCustomString == TQString::null)) { + // reset password prompt + passwdLabel->setText(passwordPrompt()); + if (grid) { + grid->invalidate(); + grid->activate(); + } + } + + // assert(!running); + setActive2(true); if (authTok) { - passwd1Edit->erase(); - passwd2Edit->erase(); - passwd1Edit->setFocus(); - } else { + if (passwd1Edit) { + passwd1Edit->erase(); + } + if (passwd2Edit) { + passwd2Edit->erase(); + } + if (passwd1Edit) { + passwd1Edit->setFocus(); + } + } + else { passwdEdit->erase(); - if (loginEdit && loginEdit->isEnabled()) + if (loginEdit && loginEdit->isEnabled()) { passwdEdit->setEnabled( true ); + } else { setActive( true ); - if (loginEdit && loginEdit->text().isEmpty()) + if (loginEdit && loginEdit->text().isEmpty()) { loginEdit->setFocus(); - else + } + else { passwdEdit->setFocus(); + } } } } @@ -425,6 +516,15 @@ KClassicGreeter::revive() void // virtual KClassicGreeter::clear() { + if (passwdLabel && (passwdPromptCustomString == TQString::null)) { + // reset password prompt + passwdLabel->setText(passwordPrompt()); + if (grid) { + grid->invalidate(); + grid->activate(); + } + } + // assert( !running && !passwd1Edit ); passwdEdit->erase(); if (loginEdit) { @@ -441,10 +541,17 @@ KClassicGreeter::clear() void KClassicGreeter::setActive( bool enable ) { - if (loginEdit) - loginEdit->setEnabled( enable ); - if (passwdEdit) + if (loginEdit) { + if (userEntryLocked) { + loginEdit->setEnabled( false ); + } + else { + loginEdit->setEnabled( enable ); + } + } + if (passwdEdit) { passwdEdit->setEnabled( enable ); + } } void |