mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Merge branches/work/kdelibs_kpassworddialog/
- the old KPasswordDialog has been moved to kde3support and renamed into K3PasswordDialog - new class KNewPasswordDialog that could be used to ask for a new password - KIO::PasswordDialog has been moved to kdeui and renamed KPasswordDialog svn path=/trunk/KDE/kdebase/kdepasswd/; revision=621085
This commit is contained in:
parent
875a5cbc4c
commit
fa656934e0
4 changed files with 32 additions and 30 deletions
|
@ -214,11 +214,9 @@ void KCMUserAccount::save()
|
|||
/* Save realname to /etc/passwd */
|
||||
if ( _mw->leRealname->isModified() )
|
||||
{
|
||||
QByteArray password;
|
||||
int ret = KPasswordDialog::getPassword( _mw, password, i18n("Please enter "
|
||||
"your password in order to save your settings:"));
|
||||
|
||||
if ( !ret )
|
||||
KPasswordDialog dlg( _mw );
|
||||
dlg.setPrompt(i18n("Please enter your password in order to save your settings:"));
|
||||
if ( !dlg.exec() )
|
||||
{
|
||||
KMessageBox::sorry( this, i18n("You must enter "
|
||||
"your password in order to change your information."));
|
||||
|
@ -226,7 +224,7 @@ void KCMUserAccount::save()
|
|||
}
|
||||
|
||||
ChfnProcess *proc = new ChfnProcess();
|
||||
ret = proc->exec(password, _mw->leRealname->text().toAscii() );
|
||||
int ret = proc->exec(dlg.password().toAscii() , _mw->leRealname->text().toAscii() );
|
||||
if ( ret )
|
||||
{
|
||||
if ( ret == ChfnProcess::PasswordError )
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include "passwddlg.h"
|
||||
|
||||
KDEpasswd1Dialog::KDEpasswd1Dialog()
|
||||
: KPasswordDialog(Password, false, 0)
|
||||
: KPasswordDialog()
|
||||
{
|
||||
setCaption(i18n("Change Password"));
|
||||
setPrompt(i18n("Please enter your current password:"));
|
||||
|
@ -24,12 +24,11 @@ KDEpasswd1Dialog::~KDEpasswd1Dialog()
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
bool KDEpasswd1Dialog::checkPassword(const char *password)
|
||||
void KDEpasswd1Dialog::accept()
|
||||
{
|
||||
PasswdProcess proc(0);
|
||||
|
||||
int ret = proc.checkCurrent(password);
|
||||
int ret = proc.checkCurrent(password().toLocal8Bit());
|
||||
switch (ret)
|
||||
{
|
||||
case -1:
|
||||
|
@ -40,26 +39,26 @@ bool KDEpasswd1Dialog::checkPassword(const char *password)
|
|||
msg = "<qt>" + i18n("Conversation with 'passwd' failed.") + msg;
|
||||
KMessageBox::error(this, msg);
|
||||
done(Rejected);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
case 0:
|
||||
return true;
|
||||
return KPasswordDialog::accept();
|
||||
|
||||
case PasswdProcess::PasswdNotFound:
|
||||
KMessageBox::error(this, i18n("Could not find the program 'passwd'."));
|
||||
done(Rejected);
|
||||
return false;
|
||||
return;
|
||||
|
||||
case PasswdProcess::PasswordIncorrect:
|
||||
KMessageBox::sorry(this, i18n("Incorrect password. Please try again."));
|
||||
return false;
|
||||
return;
|
||||
|
||||
default:
|
||||
KMessageBox::error(this, i18n("Internal error: illegal return value "
|
||||
"from PasswdProcess::checkCurrent."));
|
||||
done(Rejected);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +77,7 @@ int KDEpasswd1Dialog::getPassword(QByteArray &password)
|
|||
|
||||
|
||||
KDEpasswd2Dialog::KDEpasswd2Dialog(const char *oldpass, QByteArray user)
|
||||
: KPasswordDialog(NewPassword, false, 0)
|
||||
: KNewPasswordDialog()
|
||||
{
|
||||
m_Pass = oldpass;
|
||||
m_User = user;
|
||||
|
@ -96,11 +95,13 @@ KDEpasswd2Dialog::~KDEpasswd2Dialog()
|
|||
}
|
||||
|
||||
|
||||
bool KDEpasswd2Dialog::checkPassword(const char *password)
|
||||
void KDEpasswd2Dialog::accept()
|
||||
{
|
||||
PasswdProcess proc(m_User);
|
||||
|
||||
QString p=password();
|
||||
|
||||
if (strlen(password) > 8)
|
||||
if (p.length() > 8)
|
||||
{
|
||||
switch(KMessageBox::warningYesNoCancel(this,
|
||||
m_User.isEmpty() ?
|
||||
|
@ -117,15 +118,15 @@ bool KDEpasswd2Dialog::checkPassword(const char *password)
|
|||
"truncatePassword"))
|
||||
{
|
||||
case KMessageBox::Yes :
|
||||
const_cast<char *>(password)[8] = '\000';
|
||||
p=p.left(8);
|
||||
break;
|
||||
case KMessageBox::No :
|
||||
break;
|
||||
default : return false;
|
||||
default : return;
|
||||
}
|
||||
}
|
||||
|
||||
int ret = proc.exec(m_Pass, password);
|
||||
int ret = proc.exec(m_Pass, p.toLocal8Bit());
|
||||
switch (ret)
|
||||
{
|
||||
case 0:
|
||||
|
@ -136,7 +137,7 @@ bool KDEpasswd2Dialog::checkPassword(const char *password)
|
|||
msg = "<p>\"<i>" + msg + "</i>\"";
|
||||
msg = "<qt>" + i18n("Your password has been changed.") + msg;
|
||||
KMessageBox::information(0L, msg);
|
||||
return true;
|
||||
return KNewPasswordDialog::accept();
|
||||
}
|
||||
|
||||
case PasswdProcess::PasswordNotGood:
|
||||
|
@ -148,7 +149,7 @@ bool KDEpasswd2Dialog::checkPassword(const char *password)
|
|||
|
||||
// The pw change did not succeed. Print the error.
|
||||
KMessageBox::sorry(this, msg);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
|
@ -158,10 +159,11 @@ bool KDEpasswd2Dialog::checkPassword(const char *password)
|
|||
msg = "<qt>" + i18n("Conversation with 'passwd' failed.") + msg;
|
||||
KMessageBox::sorry(this, msg);
|
||||
done(Rejected);
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
return true;
|
||||
return KNewPasswordDialog::accept();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#define __PasswdDlg_h_Incluced__
|
||||
|
||||
#include <kpassworddialog.h>
|
||||
#include <knewpassworddialog.h>
|
||||
#include <QByteArray>
|
||||
|
||||
class KDEpasswd1Dialog
|
||||
|
@ -23,13 +24,12 @@ public:
|
|||
|
||||
static int getPassword(QByteArray &password);
|
||||
|
||||
protected:
|
||||
bool checkPassword(const char *password);
|
||||
void accept();
|
||||
};
|
||||
|
||||
|
||||
class KDEpasswd2Dialog
|
||||
: public KPasswordDialog
|
||||
: public KNewPasswordDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
@ -37,6 +37,9 @@ public:
|
|||
KDEpasswd2Dialog(const char *oldpass, QByteArray user);
|
||||
~KDEpasswd2Dialog();
|
||||
|
||||
void accept();
|
||||
|
||||
|
||||
protected:
|
||||
bool checkPassword(const char *password);
|
||||
|
||||
|
|
|
@ -74,8 +74,7 @@ bool Widgets::inputBox(QWidget *parent, const QString& title, const QString& tex
|
|||
|
||||
bool Widgets::passwordBox(QWidget *parent, const QString& title, const QString& text, QString &result)
|
||||
{
|
||||
KPasswordDialog dlg( KPasswordDialog::Password, false, 0, parent );
|
||||
|
||||
KPasswordDialog dlg( parent );
|
||||
kapp->setTopWidget( &dlg );
|
||||
dlg.setCaption(title);
|
||||
dlg.setPrompt(text);
|
||||
|
|
Loading…
Reference in a new issue