From bda055367f6fe833d9281751f230d4855fd31d70 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 17 Feb 2015 18:31:12 +0100 Subject: [PATCH] use an internal package loader internal kpackage loader used to load Plasma/generic plasma/plasmoid etc directly from kpackage Change-Id: Ibd91b0d18b233291978ac667f7bf768a8bdc3c9b --- src/plasma/CMakeLists.txt | 1 + src/plasma/pluginloader.cpp | 2 + src/plasma/private/plasmakpackageloader_p.cpp | 62 +++++++++++++++++++ src/plasma/private/plasmakpackageloader_p.h | 43 +++++++++++++ 4 files changed, 108 insertions(+) create mode 100644 src/plasma/private/plasmakpackageloader_p.cpp create mode 100644 src/plasma/private/plasmakpackageloader_p.h diff --git a/src/plasma/CMakeLists.txt b/src/plasma/CMakeLists.txt index 38cdbf80c..470e37d06 100644 --- a/src/plasma/CMakeLists.txt +++ b/src/plasma/CMakeLists.txt @@ -67,6 +67,7 @@ set(Plasma_LIB_SRCS package.cpp packagestructure.cpp private/packages.cpp + private/plasmakpackageloader_p.cpp #graphics framesvg.cpp diff --git a/src/plasma/pluginloader.cpp b/src/plasma/pluginloader.cpp index 7ecdd15e3..2a4d9a160 100644 --- a/src/plasma/pluginloader.cpp +++ b/src/plasma/pluginloader.cpp @@ -44,6 +44,7 @@ #include "private/storage_p.h" #include "private/package_p.h" #include "private/packagestructure_p.h" +#include "private/plasmakpackageloader_p.h" namespace Plasma { @@ -120,6 +121,7 @@ QString PluginLoaderPrivate::parentAppConstraint(const QString &parentApp) PluginLoader::PluginLoader() : d(new PluginLoaderPrivate) { + KPackage::PackageLoader::self()->setPackageLoader(new Plasma::KPackageLoader); } PluginLoader::~PluginLoader() diff --git a/src/plasma/private/plasmakpackageloader_p.cpp b/src/plasma/private/plasmakpackageloader_p.cpp new file mode 100644 index 000000000..8cfaee438 --- /dev/null +++ b/src/plasma/private/plasmakpackageloader_p.cpp @@ -0,0 +1,62 @@ +/* + * Copyright 2015 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 "plasmakpackageloader_p.h" + +#include "packages_p.h" + + +namespace Plasma +{ +KPackageLoader::KPackageLoader() + : KPackage::PackageLoader() +{ +} + +KPackageLoader::~KPackageLoader() +{ +} + +KPackage::Package KPackageLoader::internalLoadPackage(const QString &packageFormat) +{ + KPackage::PackageStructure *structure = 0; + + if (packageFormat.startsWith("Plasma")) { + if (packageFormat.endsWith("/Applet")) { + structure = new PlasmoidPackage(); + } else if (packageFormat.endsWith("/DataEngine")) { + structure = new DataEnginePackage(); + } else if (packageFormat.endsWith("/Theme")) { + structure = new ThemePackage(); + } else if (packageFormat.endsWith("/ContainmentActions")) { + structure = new ContainmentActionsPackage(); + } else if (packageFormat.endsWith("/Generic")) { + structure = new GenericPackage(); + } + + if (structure) { + return KPackage::Package(structure); + } + } + + return KPackage::Package(); +} + +} + diff --git a/src/plasma/private/plasmakpackageloader_p.h b/src/plasma/private/plasmakpackageloader_p.h new file mode 100644 index 000000000..518aef8c4 --- /dev/null +++ b/src/plasma/private/plasmakpackageloader_p.h @@ -0,0 +1,43 @@ +/* + * Copyright 2015 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 PLASMA_PACKAGELOADER_P_H +#define PLASMA_PACKAGELOADER_P_H + +#include +#include + + +namespace Plasma +{ + +class KPackageLoader : public KPackage::PackageLoader +{ +public: + KPackageLoader(); + ~KPackageLoader(); + +protected: + + KPackage::Package internalLoadPackage(const QString &packageFormat); +}; + +} + +#endif