prep for Package loading

This commit is contained in:
Aaron Seigo 2011-07-13 20:20:36 +02:00
parent 0633f2fd28
commit aabb8d47f9
2 changed files with 46 additions and 2 deletions

View File

@ -204,7 +204,7 @@ AbstractRunner *PluginLoader::loadRunner(const QString &name)
} }
Service *PluginLoader::loadService(const QString &name, const QVariantList &args, QObject *parent) Service *PluginLoader::loadService(const QString &name, const QVariantList &args, QObject *parent)
{ {
Service *service = internalLoadService(name, args, parent); Service *service = internalLoadService(name, args, parent);
if (service) { if (service) {
return service; return service;
@ -244,6 +244,17 @@ Service *PluginLoader::loadService(const QString &name, const QVariantList &args
return service; return service;
} }
Package PluginLoader::loadPackage(const QString &name, const QVariantList &args)
{
Package p = internalLoadPackage(name, args);
if (p.isValid()) {
return p;
}
//TODO: pull code from PackageStructure over here
return p;
}
KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QString &parentApp) KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QString &parentApp)
{ {
KPluginInfo::List list; KPluginInfo::List list;
@ -337,13 +348,20 @@ AbstractRunner* PluginLoader::internalLoadRunner(const QString &name)
} }
Service* PluginLoader::internalLoadService(const QString &name, const QVariantList &args, QObject *parent) Service* PluginLoader::internalLoadService(const QString &name, const QVariantList &args, QObject *parent)
{ {
Q_UNUSED(name) Q_UNUSED(name)
Q_UNUSED(args) Q_UNUSED(args)
Q_UNUSED(parent) Q_UNUSED(parent)
return 0; return 0;
} }
Package PluginLoader::internalLoadPackage(const QString &name, const QVariantList &args)
{
Q_UNUSED(name);
Q_UNUSED(args);
return Package();
}
KPluginInfo::List PluginLoader::internalAppletInfo(const QString &category) const KPluginInfo::List PluginLoader::internalAppletInfo(const QString &category) const
{ {
Q_UNUSED(category) Q_UNUSED(category)

View File

@ -20,6 +20,7 @@
#ifndef PLUGIN_LOADER_H #ifndef PLUGIN_LOADER_H
#define PLUGIN_LOADER_H #define PLUGIN_LOADER_H
#include <plasma/package.h>
#include <plasma/plasma.h> #include <plasma/plasma.h>
#include <kplugininfo.h> #include <kplugininfo.h>
@ -93,6 +94,16 @@ public:
**/ **/
Service *loadService(const QString &name, const QVariantList &args, QObject *parent = 0); Service *loadService(const QString &name, const QVariantList &args, QObject *parent = 0);
/**
* Load a Package plugin.
*
* @param name the plugin name of the package to load
* @param args a list of arguments to supply to the service plugin when loading it
*
* @return a Package object matching name, or an invalid package on failure
**/
Package loadPackage(const QString &name, const QVariantList &args);
/** /**
* Returns a list of all known applets. * Returns a list of all known applets.
* This may skip applets based on security settings and ExcludeCategories in the application's config. * This may skip applets based on security settings and ExcludeCategories in the application's config.
@ -205,6 +216,21 @@ protected:
**/ **/
virtual Service *internalLoadService(const QString &name, const QVariantList &args, QObject *parent = 0); virtual Service *internalLoadService(const QString &name, const QVariantList &args, QObject *parent = 0);
/**
* A re-implementable method that allows subclasses to override
* the default behaviour of loadPackage. If the service requested is not recognized,
* then the implementation should return a NULL pointer. This method is called
* by loadService prior to attempting to load a Service using the standard Plasma
* plugin mechanisms.
*
* @param name the plugin name of the service to load
* @param args a list of arguments to supply to the service plugin when loading it
* @param parent the parent object, if any, for the service
*
* @return a Service object, unlike Plasma::Service::loadService, this can return null.
**/
virtual Package internalLoadPackage(const QString &name, const QVariantList &args);
/** /**
* A re-implementable method that allows subclasses to provide additional applets * A re-implementable method that allows subclasses to provide additional applets
* for listAppletInfo. If the application has no applets to give to the application, * for listAppletInfo. If the application has no applets to give to the application,