[Pkg-owncloud-commits] [owncloud-client] 275/333: Add an simple SSL error handler for owncloudcmd.

Sandro Knauß hefee-guest at moszumanska.debian.org
Thu Apr 17 23:17:03 UTC 2014


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 d731f4718db3c134b6d2d43faddc0c95164816b4
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Tue Apr 1 15:57:37 2014 +0200

    Add an simple SSL error handler for owncloudcmd.
---
 src/CMakeLists.txt                        |  2 +-
 src/owncloudcmd/owncloudcmd.cpp           | 15 +++++++----
 src/owncloudcmd/simplesslerrorhandler.cpp | 45 +++++++++++++++++++++++++++++++
 src/owncloudcmd/simplesslerrorhandler.h   | 33 +++++++++++++++++++++++
 4 files changed, 89 insertions(+), 6 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 82ec37d..77712a4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -462,7 +462,7 @@ if(KRAZY2_EXECUTABLE)
 endif()
 
 set(owncloudcmd_NAME ${APPLICATION_EXECUTABLE}cmd)
-set(OWNCLOUDCMD_SRC owncloudcmd/owncloudcmd.cpp)
+set(OWNCLOUDCMD_SRC owncloudcmd/simplesslerrorhandler.cpp owncloudcmd/owncloudcmd.cpp)
 if(NOT BUILD_LIBRARIES_ONLY)
    add_executable(${owncloudcmd_NAME}  ${OWNCLOUDCMD_SRC})
 	qt5_use_modules(${owncloudcmd_NAME} Network Sql)
diff --git a/src/owncloudcmd/owncloudcmd.cpp b/src/owncloudcmd/owncloudcmd.cpp
index 31ad39e..bf92a91 100644
--- a/src/owncloudcmd/owncloudcmd.cpp
+++ b/src/owncloudcmd/owncloudcmd.cpp
@@ -22,13 +22,15 @@
 
 #include <neon/ne_socket.h>
 
-#include "syncengine.h"
-#include <syncjournaldb.h>
-#include "logger.h"
+#include "mirall/syncengine.h"
+#include "mirall/syncjournaldb.h"
+#include "mirall/logger.h"
 #include "csync.h"
 #include "mirall/clientproxy.h"
-#include "account.h"
-#include <creds/httpcredentials.h>
+#include "mirall/account.h"
+#include "creds/httpcredentials.h"
+
+#include "simplesslerrorhandler.h"
 
 using namespace Mirall;
 
@@ -143,8 +145,11 @@ int main(int argc, char **argv) {
     url.setScheme(url.scheme().replace("owncloud", "http"));
     QString folder = splitted.value(1);
 
+    SimpleSslErrorHandler *sslErrorHandler = new SimpleSslErrorHandler;
+
     account.setUrl(url);
     account.setCredentials(new HttpCredentials(url.userName(), url.password()));
+    account.setSslErrorHandler(sslErrorHandler);
     AccountManager::instance()->setAccount(&account);
 
 
diff --git a/src/owncloudcmd/simplesslerrorhandler.cpp b/src/owncloudcmd/simplesslerrorhandler.cpp
new file mode 100644
index 0000000..5a6dcec
--- /dev/null
+++ b/src/owncloudcmd/simplesslerrorhandler.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) by Klaas Freitag <freitag at owncloud.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; version 2 of the License.
+ *
+ * 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 "mirall/mirallconfigfile.h"
+#include "mirall/utility.h"
+#include "mirall/account.h"
+#include "simplesslerrorhandler.h"
+
+#include <QtGui>
+#include <QtNetwork>
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#include <QtWidgets>
+#endif
+
+
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+namespace Utility {
+    //  Used for QSSLCertificate::subjectInfo which returns a QStringList in Qt5, but a QString in Qt4
+    QString escape(const QStringList &l) { return escape(l.join(';')); }
+}
+#endif
+
+bool SimpleSslErrorHandler::handleErrors(QList<QSslError> errors, QList<QSslCertificate> *certs, Account *account)
+{
+    (void) account;
+
+    if (!certs) {
+        qDebug() << "Certs parameter required but is NULL!";
+        return false;
+    }
+
+    foreach( QSslError error, errors ) {
+        certs->append( error.certificate() );
+    }
+    return true;
+}
diff --git a/src/owncloudcmd/simplesslerrorhandler.h b/src/owncloudcmd/simplesslerrorhandler.h
new file mode 100644
index 0000000..4add72d
--- /dev/null
+++ b/src/owncloudcmd/simplesslerrorhandler.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) by Klaas Freitag <freitag at owncloud.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; version 2 of the License.
+ *
+ * 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.
+ */
+#ifndef SIMPLESSLERRORHANDLER_H
+#define SIMPLESSLERRORHANDLER_H
+
+#include <QtCore>
+#include <QDialog>
+#include <QSslCertificate>
+#include <QList>
+
+#include "mirall/account.h"
+
+class QSslError;
+class QSslCertificate;
+
+using namespace Mirall;
+
+class SimpleSslErrorHandler : public AbstractSslErrorHandler {
+public:
+    bool handleErrors(QList<QSslError> errors, QList<QSslCertificate> *certs, Account*);
+};
+
+#endif // SIMPLESSLERRORHANDLER_H

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