[Pkg-owncloud-commits] [owncloud-client] 160/498: Credential: move the implementation to the gui

Sandro Knauß hefee-guest at moszumanska.debian.org
Tue Aug 11 14:48:46 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 ce0a0e3f0d9a15d3799ce31af1b40d395a4f8574
Author: Olivier Goffart <ogoffart at woboq.com>
Date:   Mon Jun 15 15:53:45 2015 +0200

    Credential: move the implementation to the gui
---
 src/gui/CMakeLists.txt                             | 12 +++++++
 src/{libsync => gui}/authenticationdialog.cpp      |  0
 src/{libsync => gui}/authenticationdialog.h        |  0
 src/{libsync => gui}/creds/credentialsfactory.cpp  | 12 +------
 src/{libsync => gui}/creds/credentialsfactory.h    |  0
 src/gui/creds/httpcredentialsgui.cpp               | 38 ++++++++++++++++++++++
 .../creds/httpcredentialsgui.h}                    | 23 ++++---------
 .../creds/shibboleth/shibbolethrefresher.cpp       |  0
 .../creds/shibboleth/shibbolethrefresher.h         |  0
 .../creds/shibboleth/shibbolethuserjob.cpp         |  0
 .../creds/shibboleth/shibbolethuserjob.h           |  0
 .../creds/shibboleth/shibbolethwebview.cpp         |  0
 .../creds/shibboleth/shibbolethwebview.h           |  0
 .../creds/shibbolethcredentials.cpp                |  0
 src/{libsync => gui}/creds/shibbolethcredentials.h |  0
 src/gui/wizard/owncloudhttpcredspage.cpp           |  2 +-
 src/libsync/CMakeLists.txt                         | 19 +----------
 src/libsync/accessmanager.cpp                      | 32 ------------------
 src/libsync/accessmanager.h                        |  2 --
 src/libsync/account.cpp                            |  1 -
 src/libsync/configfile.cpp                         |  1 -
 src/libsync/creds/httpcredentials.cpp              | 13 --------
 src/libsync/creds/httpcredentials.h                |  8 -----
 src/libsync/networkjobs.cpp                        |  1 -
 src/libsync/theme.h                                |  4 +++
 25 files changed, 64 insertions(+), 104 deletions(-)

diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt
index 0f85c3d..fc945f2 100644
--- a/src/gui/CMakeLists.txt
+++ b/src/gui/CMakeLists.txt
@@ -65,6 +65,13 @@ set(client_SRCS
     quotainfo.cpp
     accountstate.cpp
     addcertificatedialog.cpp
+    authenticationdialog.cpp
+    creds/credentialsfactory.cpp
+    creds/httpcredentialsgui.cpp
+    creds/shibbolethcredentials.cpp
+    creds/shibboleth/shibbolethwebview.cpp
+    creds/shibboleth/shibbolethrefresher.cpp
+    creds/shibboleth/shibbolethuserjob.cpp
     wizard/abstractcredswizardpage.cpp
     wizard/owncloudadvancedsetuppage.cpp
     wizard/owncloudconnectionmethoddialog.cpp
@@ -175,6 +182,11 @@ set( final_src
     ${3rdparty_MOC}
 )
 
+if(QTKEYCHAIN_FOUND OR QT5KEYCHAIN_FOUND)
+    list(APPEND libsync_LINK_TARGETS ${QTKEYCHAIN_LIBRARY})
+    include_directories(${QTKEYCHAIN_INCLUDE_DIR})
+endif()
+
 # add executable icon on windows and osx
 include( AddAppIconMacro )
 set(ownCloud_old ${ownCloud})
diff --git a/src/libsync/authenticationdialog.cpp b/src/gui/authenticationdialog.cpp
similarity index 100%
rename from src/libsync/authenticationdialog.cpp
rename to src/gui/authenticationdialog.cpp
diff --git a/src/libsync/authenticationdialog.h b/src/gui/authenticationdialog.h
similarity index 100%
rename from src/libsync/authenticationdialog.h
rename to src/gui/authenticationdialog.h
diff --git a/src/libsync/creds/credentialsfactory.cpp b/src/gui/creds/credentialsfactory.cpp
similarity index 86%
rename from src/libsync/creds/credentialsfactory.cpp
rename to src/gui/creds/credentialsfactory.cpp
index 845930c..c7c4ef3 100644
--- a/src/libsync/creds/credentialsfactory.cpp
+++ b/src/gui/creds/credentialsfactory.cpp
@@ -14,13 +14,9 @@
 #include <QString>
 
 #include "creds/credentialsfactory.h"
-#ifdef TOKEN_AUTH_ONLY
-#include "creds/tokencredentials.h"
-#else
-#include "creds/httpcredentials.h"
+#include "creds/httpcredentialsgui.h"
 #include "creds/dummycredentials.h"
 #include "creds/shibbolethcredentials.h"
-#endif
 
 namespace OCC
 {
@@ -30,11 +26,6 @@ namespace CredentialsFactory
 
 AbstractCredentials* create(const QString& type)
 {
-#ifdef TOKEN_AUTH_ONLY
-    Q_UNUSED(type);
-	return new TokenCredentials;
-#else
-
     // empty string might happen for old version of configuration
     if (type == "http" || type == "") {
         return new HttpCredentialsGui;
@@ -46,7 +37,6 @@ AbstractCredentials* create(const QString& type)
         qWarning("Unknown credentials type: %s", qPrintable(type));
         return new DummyCredentials;
     }
-#endif
 }
 
 } // ns CredentialsFactory
diff --git a/src/libsync/creds/credentialsfactory.h b/src/gui/creds/credentialsfactory.h
similarity index 100%
rename from src/libsync/creds/credentialsfactory.h
rename to src/gui/creds/credentialsfactory.h
diff --git a/src/gui/creds/httpcredentialsgui.cpp b/src/gui/creds/httpcredentialsgui.cpp
new file mode 100644
index 0000000..ca28868
--- /dev/null
+++ b/src/gui/creds/httpcredentialsgui.cpp
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) by Klaas Freitag <freitag at kde.org>
+ * Copyright (C) by Olivier Goffart <ogoffart at woboq.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+#include <QInputDialog>
+#include "creds/httpcredentialsgui.h"
+#include "theme.h"
+
+using namespace QKeychain;
+
+namespace OCC
+{
+
+    QString HttpCredentialsGui::queryPassword(bool *ok)
+{
+    if (ok) {
+        QString str = QInputDialog::getText(0, tr("Enter Password"),
+                                     tr("Please enter %1 password for user '%2':")
+                                     .arg(Theme::instance()->appNameGUI(), _user),
+                                     QLineEdit::Password, _previousPassword, ok);
+        return str;
+    } else {
+        return QString();
+    }
+}
+
+} // namespace OCC
diff --git a/src/libsync/creds/shibboleth/shibbolethuserjob.h b/src/gui/creds/httpcredentialsgui.h
similarity index 52%
copy from src/libsync/creds/shibboleth/shibbolethuserjob.h
copy to src/gui/creds/httpcredentialsgui.h
index cf4bed0..e18de29 100644
--- a/src/libsync/creds/shibboleth/shibbolethuserjob.h
+++ b/src/gui/creds/httpcredentialsgui.h
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) by Olivier Goffart <ogoffart at owncloud.com>
+ * Copyright (C) by Klaas Freitag <freitag at kde.org>
+ * Copyright (C) by Olivier Goffart <ogoffart at woboq.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -13,28 +14,18 @@
  */
 
 #pragma once
-
-#include <networkjobs.h>
+#include "creds/httpcredentials.h"
 
 namespace OCC
 {
 
-/**
-  * @brief Fetch the user name of the shibboleth connection
-  */
-class ShibbolethUserJob : public JsonApiJob {
+class OWNCLOUDSYNC_EXPORT HttpCredentialsGui : public HttpCredentials {
     Q_OBJECT
 public:
-    explicit ShibbolethUserJob(AccountPtr account, QObject* parent = 0);
-
-signals:
-    // is always emitted when the job is finished.  user is empty in case of error.
-    void userFetched(const QString &user);
-
-private slots:
-    void slotJsonRecieved(const QVariantMap &);
+    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;
 };
 
-
 } // namespace OCC
 
diff --git a/src/libsync/creds/shibboleth/shibbolethrefresher.cpp b/src/gui/creds/shibboleth/shibbolethrefresher.cpp
similarity index 100%
rename from src/libsync/creds/shibboleth/shibbolethrefresher.cpp
rename to src/gui/creds/shibboleth/shibbolethrefresher.cpp
diff --git a/src/libsync/creds/shibboleth/shibbolethrefresher.h b/src/gui/creds/shibboleth/shibbolethrefresher.h
similarity index 100%
rename from src/libsync/creds/shibboleth/shibbolethrefresher.h
rename to src/gui/creds/shibboleth/shibbolethrefresher.h
diff --git a/src/libsync/creds/shibboleth/shibbolethuserjob.cpp b/src/gui/creds/shibboleth/shibbolethuserjob.cpp
similarity index 100%
rename from src/libsync/creds/shibboleth/shibbolethuserjob.cpp
rename to src/gui/creds/shibboleth/shibbolethuserjob.cpp
diff --git a/src/libsync/creds/shibboleth/shibbolethuserjob.h b/src/gui/creds/shibboleth/shibbolethuserjob.h
similarity index 100%
rename from src/libsync/creds/shibboleth/shibbolethuserjob.h
rename to src/gui/creds/shibboleth/shibbolethuserjob.h
diff --git a/src/libsync/creds/shibboleth/shibbolethwebview.cpp b/src/gui/creds/shibboleth/shibbolethwebview.cpp
similarity index 100%
rename from src/libsync/creds/shibboleth/shibbolethwebview.cpp
rename to src/gui/creds/shibboleth/shibbolethwebview.cpp
diff --git a/src/libsync/creds/shibboleth/shibbolethwebview.h b/src/gui/creds/shibboleth/shibbolethwebview.h
similarity index 100%
rename from src/libsync/creds/shibboleth/shibbolethwebview.h
rename to src/gui/creds/shibboleth/shibbolethwebview.h
diff --git a/src/libsync/creds/shibbolethcredentials.cpp b/src/gui/creds/shibbolethcredentials.cpp
similarity index 100%
rename from src/libsync/creds/shibbolethcredentials.cpp
rename to src/gui/creds/shibbolethcredentials.cpp
diff --git a/src/libsync/creds/shibbolethcredentials.h b/src/gui/creds/shibbolethcredentials.h
similarity index 100%
rename from src/libsync/creds/shibbolethcredentials.h
rename to src/gui/creds/shibbolethcredentials.h
diff --git a/src/gui/wizard/owncloudhttpcredspage.cpp b/src/gui/wizard/owncloudhttpcredspage.cpp
index 096a3d1..c74d164 100644
--- a/src/gui/wizard/owncloudhttpcredspage.cpp
+++ b/src/gui/wizard/owncloudhttpcredspage.cpp
@@ -15,7 +15,7 @@
 
 #include "QProgressIndicator.h"
 
-#include "creds/httpcredentials.h"
+#include "creds/httpcredentialsgui.h"
 #include "theme.h"
 #include "account.h"
 #include "configfile.h"
diff --git a/src/libsync/CMakeLists.txt b/src/libsync/CMakeLists.txt
index 7247d16..cbf11f0 100644
--- a/src/libsync/CMakeLists.txt
+++ b/src/libsync/CMakeLists.txt
@@ -64,27 +64,11 @@ set(libsync_SRCS
     transmissionchecksumvalidator.cpp
     creds/dummycredentials.cpp
     creds/abstractcredentials.cpp
-    creds/credentialsfactory.cpp
     creds/credentialscommon.cpp
+    creds/httpcredentials.cpp
     ../3rdparty/qjson/json.cpp
     ../3rdparty/certificates/p12topem.cpp
 )
-if(TOKEN_AUTH_ONLY)
-	set (libsync_SRCS
-		${libsync_SRCS}
-		creds/tokencredentials.cpp
-	)
-else()
-    set (libsync_SRCS
-        ${libsync_SRCS}
-        creds/httpcredentials.cpp
-        creds/shibbolethcredentials.cpp
-        creds/shibboleth/shibbolethwebview.cpp
-        creds/shibboleth/shibbolethrefresher.cpp
-        creds/shibboleth/shibbolethuserjob.cpp
-        authenticationdialog.cpp
-    )
-endif()
 
 if(USE_NEON)
     list(APPEND libsync_SRCS
@@ -155,7 +139,6 @@ GENERATE_EXPORT_HEADER( ${synclib_NAME}
 	STATIC_DEFINE OWNCLOUD_BUILT_AS_STATIC
 )
 
-
 if(TOKEN_AUTH_ONLY)
     qt5_use_modules(${synclib_NAME} Network Concurrent)
 else()
diff --git a/src/libsync/accessmanager.cpp b/src/libsync/accessmanager.cpp
index 331f9d0..e380171 100644
--- a/src/libsync/accessmanager.cpp
+++ b/src/libsync/accessmanager.cpp
@@ -19,10 +19,6 @@
 #include <QNetworkCookie>
 #include <QNetworkCookieJar>
 
-#ifndef TOKEN_AUTH_ONLY
-#include "authenticationdialog.h"
-#endif
-
 #include "cookiejar.h"
 #include "accessmanager.h"
 #include "utility.h"
@@ -42,8 +38,6 @@ AccessManager::AccessManager(QObject* parent)
     setCookieJar(new CookieJar);
     connect(this, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
             this, SLOT(slotProxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
-    connect(this, SIGNAL(authenticationRequired(QNetworkReply*,QAuthenticator*)),
-            this, SLOT(slotAuthenticationRequired(QNetworkReply*,QAuthenticator*)));
 
 }
 
@@ -88,32 +82,6 @@ void AccessManager::slotProxyAuthenticationRequired(const QNetworkProxy &proxy,
         authenticator->setPassword(proxy.password());
     }
 }
-void AccessManager::slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator)
-{
-#ifndef TOKEN_AUTH_ONLY
-    // do not handle 401 created by the networkjobs. We may want
-    // to eventually exempt some, but for now we need
-    // it only for other things, e.g. the browser. Would we handle
-    // network jobs, this would break the wizard logic
-    if (reply->property("doNotHandleAuth").toBool()) {
-        return;
-    }
-    QUrl url = reply->url();
-    // show only scheme, host and port
-    QUrl reducedUrl;
-    reducedUrl.setScheme(url.scheme());
-    reducedUrl.setHost(url.host());
-    reducedUrl.setPort(url.port());
 
-    AuthenticationDialog dialog(authenticator->realm(), reducedUrl.toString());
-    if (dialog.exec() == QDialog::Accepted) {
-        authenticator->setUser(dialog.user());
-        authenticator->setPassword(dialog.password());
-    }
-#else
-    Q_UNUSED(reply) Q_UNUSED(authenticator)
-    Q_ASSERT(!"OCC::AccessManager::slotAuthenticationRequired called");
-#endif
-}
 
 } // namespace OCC
diff --git a/src/libsync/accessmanager.h b/src/libsync/accessmanager.h
index 943e3b4..161f5c6 100644
--- a/src/libsync/accessmanager.h
+++ b/src/libsync/accessmanager.h
@@ -36,8 +36,6 @@ protected:
     QNetworkReply* createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest& request, QIODevice* outgoingData = 0) Q_DECL_OVERRIDE;
 protected slots:
     void slotProxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
-    void slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator);
-
 };
 
 } // namespace OCC
diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp
index c116a3e..df8e59a 100644
--- a/src/libsync/account.cpp
+++ b/src/libsync/account.cpp
@@ -19,7 +19,6 @@
 #include "accessmanager.h"
 #include "owncloudtheme.h"
 #include "creds/abstractcredentials.h"
-#include "creds/credentialsfactory.h"
 #include "../3rdparty/certificates/p12topem.h"
 
 #include <QSettings>
diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp
index 2b04b11..d3c39c0 100644
--- a/src/libsync/configfile.cpp
+++ b/src/libsync/configfile.cpp
@@ -19,7 +19,6 @@
 #include "utility.h"
 
 #include "creds/abstractcredentials.h"
-#include "creds/credentialsfactory.h"
 
 #ifndef TOKEN_AUTH_ONLY
 #include <QWidget>
diff --git a/src/libsync/creds/httpcredentials.cpp b/src/libsync/creds/httpcredentials.cpp
index 2cd0f85..70cee4e 100644
--- a/src/libsync/creds/httpcredentials.cpp
+++ b/src/libsync/creds/httpcredentials.cpp
@@ -386,17 +386,4 @@ void HttpCredentials::slotAuthentication(QNetworkReply* reply, QAuthenticator* a
     reply->setProperty(authenticationFailedC, true);
 }
 
-QString HttpCredentialsGui::queryPassword(bool *ok)
-{
-    if (ok) {
-        QString str = QInputDialog::getText(0, tr("Enter Password"),
-                                     tr("Please enter %1 password for user '%2':")
-                                     .arg(Theme::instance()->appNameGUI(), _user),
-                                     QLineEdit::Password, _previousPassword, ok);
-        return str;
-    } else {
-        return QString();
-    }
-}
-
 } // namespace OCC
diff --git a/src/libsync/creds/httpcredentials.h b/src/libsync/creds/httpcredentials.h
index f20561a..222e57e 100644
--- a/src/libsync/creds/httpcredentials.h
+++ b/src/libsync/creds/httpcredentials.h
@@ -77,14 +77,6 @@ private:
     bool _readPwdFromDeprecatedPlace;
 };
 
-class OWNCLOUDSYNC_EXPORT HttpCredentialsGui : public HttpCredentials {
-    Q_OBJECT
-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;
-};
-
 } // namespace OCC
 
 #endif
diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp
index 4b14aeb..c2f2dab 100644
--- a/src/libsync/networkjobs.cpp
+++ b/src/libsync/networkjobs.cpp
@@ -33,7 +33,6 @@
 #include "account.h"
 #include "owncloudpropagator.h"
 
-#include "creds/credentialsfactory.h"
 #include "creds/abstractcredentials.h"
 
 Q_DECLARE_METATYPE(QTimer*)
diff --git a/src/libsync/theme.h b/src/libsync/theme.h
index 7f30950..0edb69c 100644
--- a/src/libsync/theme.h
+++ b/src/libsync/theme.h
@@ -18,6 +18,10 @@
 #include <QObject>
 #include "syncresult.h"
 
+#ifndef TOKEN_AUTH_ONLY
+#include <QIcon>
+#endif
+
 
 class QIcon;
 class QString;

-- 
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