File kdepasswd-fix.diff of Package kdelibs4

Subject: Make kdepasswd work
From: upstream
Signed-Off-By: Lubos Lunak
Bug: bnc#438250
Patch-upstream: r883955
Relates: kdebase4/kdepasswd-fix.diff


------------------------------------------------------------------------
r883955 | aacid | 2008-11-13 22:14:02 +0000 (Thu, 13 Nov 2008) | 4 lines
Changed paths:
   M /trunk/KDE/kdelibs/kdeui/dialogs/knewpassworddialog.cpp
   M /trunk/KDE/kdelibs/kdeui/dialogs/knewpassworddialog.h

Add KNewPasswordDialog::checkAndGetPassword that checks if the password passes the validity checks and returns it if they are passed

Patch based on a patch by "leo peng" <leo1295@gmail.com>

------------------------------------------------------------------------
Index: kdeui/dialogs/knewpassworddialog.h
===================================================================
--- kdeui/dialogs/knewpassworddialog.h	(revision 883954)
+++ kdeui/dialogs/knewpassworddialog.h	(revision 883955)
@@ -192,6 +192,15 @@
      */
     virtual bool checkPassword(const QString &) ;
 
+    /**
+     * Checks input password.
+     * If the password is right, returns true
+     * and fills pwd with the password.
+     * Otherwise returns false and pwd will be null.
+     * @since 4.2
+     */
+    bool checkAndGetPassword(QString *pwd);
+
 Q_SIGNALS:
 
     /**
Index: kdeui/dialogs/knewpassworddialog.cpp
===================================================================
--- kdeui/dialogs/knewpassworddialog.cpp	(revision 883954)
+++ kdeui/dialogs/knewpassworddialog.cpp	(revision 883955)
@@ -199,9 +199,9 @@
     return *d->ui.labelIcon->pixmap();
 }
 
-
-void KNewPasswordDialog::accept()
+bool KNewPasswordDialog::checkAndGetPassword(QString *pwd)
 {
+    pwd->clear();
     if ( d->ui.linePassword->text() != d->ui.lineVerifyPassword->text() ) {
         d->ui.labelMatch->setPixmap( KTitleWidget::ErrorMessage );
         d->ui.labelMatch->setText( i18n("You entered two different "
@@ -209,7 +209,7 @@
 
         d->ui.linePassword->clear();
         d->ui.lineVerifyPassword->clear();
-        return;
+        return false;
     }
     if (d->ui.strengthBar && d->ui.strengthBar->value() < d->passwordStrengthWarningLevel) {
         int retVal = KMessageBox::warningYesNo(this,
@@ -222,12 +222,23 @@
                         "\n"
                         "Would you like to use this password anyway?"),
                 i18n("Low Password Strength"));
-        if (retVal == KMessageBox::Cancel) return;
+        if (retVal == KMessageBox::Cancel) return false;
     }
     if ( !checkPassword(d->ui.linePassword->text()) ) {
+        return false;
+    }
+
+    *pwd = d->ui.linePassword->text();
+    return true;
+}
+
+void KNewPasswordDialog::accept()
+{
+    QString pwd;
+    if (!checkAndGetPassword(&pwd)) {
         return;
     }
-    d->pass = d->ui.linePassword->text();
+    d->pass = pwd;
     emit newPassword( d->pass );
     KDialog::accept();
 }
openSUSE Build Service is sponsored by