[Pkg-owncloud-commits] [owncloud-client] 357/498: HttpCreds: Add keychain failure hint. #3268

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Aug 11 14:49:06 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit 5d9e752c71ff1c006d6880003667cb28ea5156aa
Author: Christian Kamm <kamm at incasoftware.de>
Date:   Fri Jul 17 14:39:43 2015 +0200

    HttpCreds: Add keychain failure hint. #3268
---
 src/cmd/cmd.cpp                       |  2 +-
 src/gui/creds/httpcredentialsgui.cpp  | 23 +++++++++++++++--------
 src/gui/creds/httpcredentialsgui.h    |  2 +-
 src/libsync/creds/httpcredentials.cpp |  9 ++++++++-
 src/libsync/creds/httpcredentials.h   |  2 +-
 5 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp
index a75be04..b9205c0 100644
--- a/src/cmd/cmd.cpp
+++ b/src/cmd/cmd.cpp
@@ -114,7 +114,7 @@ public:
           _sslTrusted(false)
     {}
 
-    QString queryPassword(bool *ok) Q_DECL_OVERRIDE {
+    QString queryPassword(bool *ok, const QString&) Q_DECL_OVERRIDE {
         if (ok) {
             *ok = true;
         }
diff --git a/src/gui/creds/httpcredentialsgui.cpp b/src/gui/creds/httpcredentialsgui.cpp
index 1d6dfd7..2357aad 100644
--- a/src/gui/creds/httpcredentialsgui.cpp
+++ b/src/gui/creds/httpcredentialsgui.cpp
@@ -23,17 +23,24 @@ using namespace QKeychain;
 namespace OCC
 {
 
-    QString HttpCredentialsGui::queryPassword(bool *ok)
+    QString HttpCredentialsGui::queryPassword(bool *ok, const QString& hint)
 {
-    if (ok) {
-        QString str = QInputDialog::getText(0, tr("Enter Password"),
-                                     tr("Please enter %1 password:\n\nUser: %2\nAccount: %3\n")
-                                     .arg(Theme::instance()->appNameGUI(), _user, _account->displayName()),
-                                     QLineEdit::Password, _previousPassword, ok);
-        return str;
-    } else {
+    if (!ok) {
         return QString();
     }
+
+    QString msg = tr("Please enter %1 password:\n"
+                     "\n"
+                     "User: %2\n"
+                     "Account: %3\n")
+                  .arg(Theme::instance()->appNameGUI(), _user, _account->displayName());
+    if (!hint.isEmpty()) {
+        msg += QLatin1String("\n") + hint + QLatin1String("\n");
+    }
+
+    return QInputDialog::getText(0, tr("Enter Password"), msg,
+                                 QLineEdit::Password, _previousPassword,
+                                 ok);
 }
 
 } // namespace OCC
diff --git a/src/gui/creds/httpcredentialsgui.h b/src/gui/creds/httpcredentialsgui.h
index f53210d..22c9d43 100644
--- a/src/gui/creds/httpcredentialsgui.h
+++ b/src/gui/creds/httpcredentialsgui.h
@@ -28,7 +28,7 @@ class HttpCredentialsGui : public HttpCredentials {
 public:
     explicit HttpCredentialsGui() : HttpCredentials() {}
     HttpCredentialsGui(const QString& user, const QString& password, const QString& certificatePath, const QString& certificatePasswd) : HttpCredentials(user, password, certificatePath, certificatePasswd) {}
-    QString queryPassword(bool *ok) Q_DECL_OVERRIDE;
+    QString queryPassword(bool *ok, const QString& hint) Q_DECL_OVERRIDE;
 };
 
 } // namespace OCC
diff --git a/src/libsync/creds/httpcredentials.cpp b/src/libsync/creds/httpcredentials.cpp
index 4865cc1..ba2c6e4 100644
--- a/src/libsync/creds/httpcredentials.cpp
+++ b/src/libsync/creds/httpcredentials.cpp
@@ -284,8 +284,15 @@ void HttpCredentials::slotReadJobDone(QKeychain::Job *job)
             // NOT persisted into the new account.
         } else {
             // interactive password dialog starts here
+
+            QString hint;
+            if (job->error() != EntryNotFound) {
+                hint = tr("Reading from keychain failed with error: '%1'").arg(
+                        job->errorString());
+            }
+
             bool ok;
-            QString pwd = queryPassword(&ok);
+            QString pwd = queryPassword(&ok, hint);
             _fetchJobInProgress = false;
             if (ok) {
                 _password = pwd;
diff --git a/src/libsync/creds/httpcredentials.h b/src/libsync/creds/httpcredentials.h
index 222e57e..95c6ba4 100644
--- a/src/libsync/creds/httpcredentials.h
+++ b/src/libsync/creds/httpcredentials.h
@@ -49,7 +49,7 @@ public:
     void persist() Q_DECL_OVERRIDE;
     QString user() const Q_DECL_OVERRIDE;
     QString password() const;
-    virtual QString queryPassword(bool *ok) = 0;
+    virtual QString queryPassword(bool *ok, const QString& hint) = 0;
     void invalidateToken() Q_DECL_OVERRIDE;
     QString fetchUser();
     virtual bool sslIsTrusted() { return false; }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list