From 6f5e7b211009bf3a5b6816ee3cb064d7f393dfb9 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Fri, 18 Sep 2015 23:01:01 -0500 Subject: Streamline cryptographic card logon process --- tdmlib/kgreet_classic.cpp | 45 +++++++++++++++++++++++++++++++++++++-------- tdmlib/kgreet_classic.h | 4 +++- tdmlib/kgreet_pam.cpp | 35 +++++++++++++++++++++++++++++++---- tdmlib/kgreet_pam.h | 3 ++- tdmlib/kgreet_winbind.cpp | 35 +++++++++++++++++++++++++++++++---- tdmlib/kgreet_winbind.h | 3 ++- tdmlib/kgreeterplugin.h | 6 ++++++ 7 files changed, 112 insertions(+), 19 deletions(-) (limited to 'tdmlib') diff --git a/tdmlib/kgreet_classic.cpp b/tdmlib/kgreet_classic.cpp index 7eb983583..f99acfb3c 100644 --- a/tdmlib/kgreet_classic.cpp +++ b/tdmlib/kgreet_classic.cpp @@ -67,6 +67,7 @@ KClassicGreeter::KClassicGreeter( KGreeterPluginHandler *_handler, exp( -1 ), pExp( -1 ), running( false ), + userEntryLocked(false), suppressInfoMsg(false) { KdmItem *user_entry = 0, *pw_entry = 0; @@ -224,6 +225,7 @@ KClassicGreeter::setUser( const TQString &user ) } void KClassicGreeter::lockUserEntry( const bool lock ) { + userEntryLocked = lock; loginEdit->setEnabled(!lock); } @@ -251,6 +253,23 @@ 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() { @@ -311,7 +330,9 @@ KClassicGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking ) passwdLabel->setText(prompt); } else { - passwdLabel->setText(passwordPrompt()); + if (passwdPromptCustomString == TQString::null) { + passwdLabel->setText(passwordPrompt()); + } } if (grid) { grid->invalidate(); @@ -349,8 +370,9 @@ KClassicGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking ) has = -1; } - if (has >= exp || nonBlocking) + if (has >= exp || nonBlocking) { returnData(); + } } bool // virtual @@ -432,7 +454,7 @@ KClassicGreeter::succeeded() void // virtual KClassicGreeter::failed() { - if (passwdLabel) { + if (passwdLabel && (passwdPromptCustomString == TQString::null)) { // reset password prompt passwdLabel->setText(passwordPrompt()); if (grid) { @@ -451,7 +473,7 @@ KClassicGreeter::failed() void // virtual KClassicGreeter::revive() { - if (passwdLabel) { + if (passwdLabel && (passwdPromptCustomString == TQString::null)) { // reset password prompt passwdLabel->setText(passwordPrompt()); if (grid) { @@ -483,7 +505,7 @@ KClassicGreeter::revive() void // virtual KClassicGreeter::clear() { - if (passwdLabel) { + if (passwdLabel && (passwdPromptCustomString == TQString::null)) { // reset password prompt passwdLabel->setText(passwordPrompt()); if (grid) { @@ -508,10 +530,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 diff --git a/tdmlib/kgreet_classic.h b/tdmlib/kgreet_classic.h index 4f023db02..3f36d5000 100644 --- a/tdmlib/kgreet_classic.h +++ b/tdmlib/kgreet_classic.h @@ -52,6 +52,7 @@ class KClassicGreeter : public TQObject, public KGreeterPlugin { virtual void setUser( const TQString &user ); virtual void lockUserEntry( const bool lock ); virtual void setPassword( const TQString &pass ); + virtual void setPasswordPrompt( const TQString &prompt ); virtual void setEnabled( bool on ); virtual void setInfoMessageDisplay( bool on ); virtual bool textMessage( const char *message, bool error ); @@ -86,7 +87,8 @@ class KClassicGreeter : public TQObject, public KGreeterPlugin { Context ctx; TQGridLayout* grid; int exp, pExp, has; - bool running, authTok, suppressInfoMsg; + bool running, authTok, userEntryLocked, suppressInfoMsg; + TQString passwdPromptCustomString; }; #endif /* KGREET_CLASSIC_H */ diff --git a/tdmlib/kgreet_pam.cpp b/tdmlib/kgreet_pam.cpp index 7fcfafc8b..2aea2ae04 100644 --- a/tdmlib/kgreet_pam.cpp +++ b/tdmlib/kgreet_pam.cpp @@ -89,6 +89,7 @@ KPamGreeter::KPamGreeter( KGreeterPluginHandler *_handler, exp( -1 ), pExp( -1 ), running( false ), + userEntryLocked(false), suppressInfoMsg(false) { ctx = Login; @@ -265,6 +266,7 @@ KPamGreeter::setUser( const TQString &user ) } void KPamGreeter::lockUserEntry( const bool lock ) { + userEntryLocked = lock; loginEdit->setEnabled(!lock); } @@ -284,14 +286,32 @@ KPamGreeter::setEnabled(bool enable) // loginLabel->setEnabled( enable ); authEdit[0]->setEnabled( enable ); setActive( enable ); - if (enable) + if (enable) { authEdit[0]->setFocus(); + } } void KPamGreeter::setInfoMessageDisplay(bool enable) { suppressInfoMsg = !enable; } +void KPamGreeter::setPasswordPrompt(const TQString &prompt) { +#if 0 + if (passwdLabel) { + if (prompt != TQString::null) { + passwdLabel->setText(prompt); + } + else { + passwdLabel->setText(passwordPrompt()); + } + if (grid) { + grid->invalidate(); + grid->activate(); + } + } +#endif +} + void // private KPamGreeter::returnData() { @@ -349,8 +369,9 @@ KPamGreeter::textPrompt( const char *prompt, bool echo, bool nonBlocking ) kg_debug("state is %d, authEdit.size is %d\n", state, authEdit.size()); if (state == 0 && echo) { - if (loginLabel) + if (loginLabel) { loginLabel->setText(TQString::fromUtf8(prompt)); + } else if (m_themer) { KdmLabel *tdmlabel = static_cast(m_themer->findNode("user-label")); if (tdmlabel) { @@ -612,8 +633,14 @@ KPamGreeter::clear() void KPamGreeter::setActive( bool enable ) { - if (loginEdit) - loginEdit->setEnabled( enable ); + if (loginEdit) { + if (userEntryLocked) { + loginEdit->setEnabled( false ); + } + else { + loginEdit->setEnabled( enable ); + } + } } void diff --git a/tdmlib/kgreet_pam.h b/tdmlib/kgreet_pam.h index 79e92b33a..f579f9522 100644 --- a/tdmlib/kgreet_pam.h +++ b/tdmlib/kgreet_pam.h @@ -52,6 +52,7 @@ class KPamGreeter : public TQObject, public KGreeterPlugin { virtual void setUser( const TQString &user ); virtual void lockUserEntry( const bool lock ); virtual void setPassword( const TQString &pass ); + virtual void setPasswordPrompt( const TQString &prompt ); virtual void setEnabled( bool on ); virtual void setInfoMessageDisplay( bool on ); virtual bool textMessage( const char *message, bool error ); @@ -90,7 +91,7 @@ class KPamGreeter : public TQObject, public KGreeterPlugin { Context ctx; int exp, pExp, has; unsigned state; - bool running, authTok, suppressInfoMsg; + bool running, authTok, userEntryLocked, suppressInfoMsg; }; #endif /* KGREET_CLASSIC_H */ diff --git a/tdmlib/kgreet_winbind.cpp b/tdmlib/kgreet_winbind.cpp index 1efd170ba..cddb2866b 100644 --- a/tdmlib/kgreet_winbind.cpp +++ b/tdmlib/kgreet_winbind.cpp @@ -75,6 +75,7 @@ KWinbindGreeter::KWinbindGreeter( KGreeterPluginHandler *_handler, exp( -1 ), pExp( -1 ), running( false ), + userEntryLocked(false), suppressInfoMsg(false) { KdmItem *user_entry = 0, *pw_entry = 0, *domain_entry = 0; @@ -299,6 +300,7 @@ KWinbindGreeter::setUser( const TQString &user ) } void KWinbindGreeter::lockUserEntry( const bool lock ) { + userEntryLocked = lock; loginEdit->setEnabled(!lock); } @@ -328,6 +330,23 @@ void KWinbindGreeter::setInfoMessageDisplay(bool enable) { suppressInfoMsg = !enable; } +void KWinbindGreeter::setPasswordPrompt(const TQString &prompt) { +#if 0 + if (passwdLabel) { + if (prompt != TQString::null) { + passwdLabel->setText(prompt); + } + else { + passwdLabel->setText(passwordPrompt()); + } + if (grid) { + grid->invalidate(); + grid->activate(); + } + } +#endif +} + void // private KWinbindGreeter::returnData() { @@ -537,12 +556,20 @@ KWinbindGreeter::clear() void KWinbindGreeter::setActive( bool enable ) { - if (domainCombo) + if (domainCombo) { domainCombo->setEnabled( 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 diff --git a/tdmlib/kgreet_winbind.h b/tdmlib/kgreet_winbind.h index e21fce35b..85565628e 100644 --- a/tdmlib/kgreet_winbind.h +++ b/tdmlib/kgreet_winbind.h @@ -56,6 +56,7 @@ class KWinbindGreeter : public TQObject, public KGreeterPlugin { virtual void setUser( const TQString &user ); virtual void lockUserEntry( const bool lock ); virtual void setPassword( const TQString &pass ); + virtual void setPasswordPrompt( const TQString &prompt ); virtual void setEnabled( bool on ); virtual void setInfoMessageDisplay( bool on ); virtual bool textMessage( const char *message, bool error ); @@ -97,7 +98,7 @@ class KWinbindGreeter : public TQObject, public KGreeterPlugin { Function func; Context ctx; int exp, pExp, has; - bool running, authTok, suppressInfoMsg; + bool running, authTok, userEntryLocked, suppressInfoMsg; }; #endif /* KGREET_WINBIND_H */ diff --git a/tdmlib/kgreeterplugin.h b/tdmlib/kgreeterplugin.h index 029da236c..1dcd0233b 100644 --- a/tdmlib/kgreeterplugin.h +++ b/tdmlib/kgreeterplugin.h @@ -163,6 +163,12 @@ public: */ virtual void setPassword( const TQString &pass ) = 0; + /** + * Set the talker's password prompt to a custom string + * @param prompt the password prompt to set, or TQString::null for default + */ + virtual void setPasswordPrompt( const TQString &prompt ) = 0; + /** * En-/disable any widgets contained in the talker. * Will be called only when not running. -- cgit v1.2.1