From 990fd3b860b23c45fca73491f642554c29a3a748 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 24 Oct 2013 13:27:02 +0200 Subject: [PATCH] get completely rid of the packageaccessmanager --- src/plasmaquick/CMakeLists.txt | 4 - .../autotests/packageurlinterceptortest.cpp | 6 +- src/plasmaquick/packageurlinterceptor.cpp | 6 +- src/plasmaquick/packageurlinterceptor.h | 3 - .../private/packageaccessmanager.cpp | 82 ------------------- .../private/packageaccessmanager.h | 56 ------------- .../private/packageaccessmanagerfactory.cpp | 39 --------- .../private/packageaccessmanagerfactory.h | 42 ---------- 8 files changed, 2 insertions(+), 236 deletions(-) delete mode 100644 src/plasmaquick/private/packageaccessmanager.cpp delete mode 100644 src/plasmaquick/private/packageaccessmanager.h delete mode 100644 src/plasmaquick/private/packageaccessmanagerfactory.cpp delete mode 100644 src/plasmaquick/private/packageaccessmanagerfactory.h diff --git a/src/plasmaquick/CMakeLists.txt b/src/plasmaquick/CMakeLists.txt index 4b7bc5c8c..c361df2d9 100644 --- a/src/plasmaquick/CMakeLists.txt +++ b/src/plasmaquick/CMakeLists.txt @@ -6,10 +6,6 @@ set(plasmaquick_LIB_SRC configview.cpp packageurlinterceptor.cpp private/configcategory_p.cpp - private/packageaccessmanager.cpp - private/packageaccessmanagerfactory.cpp - #private/containmentconfigview_p.cpp - #private/currentcontainmentactionsmodel_p.cpp ) add_library(PlasmaQuick SHARED ${plasmaquick_LIB_SRC}) diff --git a/src/plasmaquick/autotests/packageurlinterceptortest.cpp b/src/plasmaquick/autotests/packageurlinterceptortest.cpp index 805be0415..d39a89aab 100644 --- a/src/plasmaquick/autotests/packageurlinterceptortest.cpp +++ b/src/plasmaquick/autotests/packageurlinterceptortest.cpp @@ -21,8 +21,6 @@ #include -#include - #include #include @@ -31,9 +29,7 @@ QTEST_MAIN(PackageUrlInterceptorTest) void PackageUrlInterceptorTest::loadAccessManager() { const Plasma::Package &pkg = Plasma::Package(); - QQmlNetworkAccessManagerFactory* pui = PackageUrlInterceptor::createPackageAccessManagerFactory(pkg); - QVERIFY(pui != 0); - delete pui; + //TODO: tests on path resolution } #include "moc_packageurlinterceptortest.cpp" diff --git a/src/plasmaquick/packageurlinterceptor.cpp b/src/plasmaquick/packageurlinterceptor.cpp index 360898f0d..390697b2c 100644 --- a/src/plasmaquick/packageurlinterceptor.cpp +++ b/src/plasmaquick/packageurlinterceptor.cpp @@ -18,7 +18,6 @@ */ #include "packageurlinterceptor.h" -#include "private/packageaccessmanagerfactory.h" #include #include @@ -116,9 +115,6 @@ QUrl PackageUrlInterceptor::intercept(const QUrl &path, QQmlAbstractUrlIntercept return path; } -QQmlNetworkAccessManagerFactory* PackageUrlInterceptor::createPackageAccessManagerFactory(const Plasma::Package& package) -{ - return new PackageAccessManagerFactory(package); -} + diff --git a/src/plasmaquick/packageurlinterceptor.h b/src/plasmaquick/packageurlinterceptor.h index 8e477b2a9..cd45d97c4 100644 --- a/src/plasmaquick/packageurlinterceptor.h +++ b/src/plasmaquick/packageurlinterceptor.h @@ -21,7 +21,6 @@ #define PACKAGEURLINTERCEPTOR_H #include -#include #include @@ -38,8 +37,6 @@ public: virtual QUrl intercept(const QUrl &path, QQmlAbstractUrlInterceptor::DataType type); - static QQmlNetworkAccessManagerFactory* createPackageAccessManagerFactory(const Plasma::Package &package); - static inline QByteArray prefixForType(QQmlAbstractUrlInterceptor::DataType type, const QString &fileName) { switch (type) { diff --git a/src/plasmaquick/private/packageaccessmanager.cpp b/src/plasmaquick/private/packageaccessmanager.cpp deleted file mode 100644 index 1b24d4221..000000000 --- a/src/plasmaquick/private/packageaccessmanager.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2010 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "packageaccessmanager.h" - -#include - -class ErrorReply : public QNetworkReply -{ -public: - ErrorReply(QNetworkAccessManager::Operation op, const QNetworkRequest &req) - : QNetworkReply() - { - setError(QNetworkReply::ContentOperationNotPermittedError, QStringLiteral("The plasmoid has not been authorized to load remote content")); - setOperation(op); - setRequest(req); - setUrl(req.url()); - } - - qint64 readData(char *data, qint64 maxSize) - { - Q_UNUSED(data); - Q_UNUSED(maxSize); - return 0; - } - - void abort() - { - } -}; - -PackageAccessManager::PackageAccessManager(const Plasma::Package &package, QObject *parent) - : KIO::AccessManager(parent), - m_package(package) -{ -} - -PackageAccessManager::~PackageAccessManager() -{ -} - - -QNetworkReply *PackageAccessManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *outgoingData) -{ - QUrl reqUrl(req.url()); - - if (reqUrl.scheme() == QStringLiteral("plasmapackage")) { - QNetworkRequest request = req; - reqUrl.setScheme(QStringLiteral("file")); - reqUrl.setPath(m_package.filePath(0, reqUrl.path())); - request.setUrl(reqUrl); - return QNetworkAccessManager::createRequest(op, request, outgoingData); - } else if ((reqUrl.scheme() == QStringLiteral("http")) || - ((reqUrl.scheme() == QStringLiteral("file") || reqUrl.scheme() == QStringLiteral("desktop")))) { - return new ErrorReply(op, req); - } else { -#ifndef PLASMA_NO_KIO - return KIO::AccessManager::createRequest(op, req, outgoingData); -#else - return QNetworkAccessManager::createRequest(op, req, outgoingData); -#endif - } -} - - - diff --git a/src/plasmaquick/private/packageaccessmanager.h b/src/plasmaquick/private/packageaccessmanager.h deleted file mode 100644 index 2dc200a18..000000000 --- a/src/plasmaquick/private/packageaccessmanager.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2010 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef PACKAGEACCESSMANAGER_H -#define PACKAGEACCESSMANAGER_H - -#include - -#include - -#ifndef PLASMA_NO_KIO -#include -#else -#include -#endif - -namespace Plasma -{ - class Package; -} - -class PackageAccessManager : -#ifdef PLASMA_NO_KIO -public QNetworkAccessManager -#else -public KIO::AccessManager -#endif -{ -public: - PackageAccessManager(const Plasma::Package &package, QObject *parent = 0); - ~PackageAccessManager(); - -protected: - QNetworkReply *createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &req, QIODevice *outgoingData = 0); - -private: - Plasma::Package m_package; -}; - -#endif diff --git a/src/plasmaquick/private/packageaccessmanagerfactory.cpp b/src/plasmaquick/private/packageaccessmanagerfactory.cpp deleted file mode 100644 index eabca1c2c..000000000 --- a/src/plasmaquick/private/packageaccessmanagerfactory.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2010 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#include "packageaccessmanagerfactory.h" - -#include "packageaccessmanager.h" - -PackageAccessManagerFactory::PackageAccessManagerFactory(const Plasma::Package &package) - : QQmlNetworkAccessManagerFactory(), - m_package(package) -{ -} - -PackageAccessManagerFactory::~PackageAccessManagerFactory() -{ -} - -QNetworkAccessManager *PackageAccessManagerFactory::create(QObject *parent) -{ - return new PackageAccessManager(m_package, parent); -} - - diff --git a/src/plasmaquick/private/packageaccessmanagerfactory.h b/src/plasmaquick/private/packageaccessmanagerfactory.h deleted file mode 100644 index 2622bb820..000000000 --- a/src/plasmaquick/private/packageaccessmanagerfactory.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2010 Marco Martin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2, 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 - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -#ifndef PACKAGEACCESSMANAGERFACTORY_H -#define PACKAGEACCESSMANAGERFACTORY_H - -#include - -#include - -#include - -class AppletAuthorization; - -class PackageAccessManagerFactory : public QQmlNetworkAccessManagerFactory -{ -public: - PackageAccessManagerFactory(const Plasma::Package &package); - ~PackageAccessManagerFactory(); - QNetworkAccessManager *create(QObject *parent); - -private: - Plasma::Package m_package; -}; - -#endif