let PluginLoader do the work for us

This commit is contained in:
Aaron Seigo 2011-07-19 21:41:10 +02:00
parent d010143b6f
commit d687e0d4b6
2 changed files with 0 additions and 84 deletions

View File

@ -68,55 +68,6 @@ ContainmentActions::~ContainmentActions()
delete d;
}
KPluginInfo::List ContainmentActions::listContainmentActionsInfo()
{
QString constraint;
KService::List offers = KServiceTypeTrader::self()->query("Plasma/ContainmentActions", constraint);
return KPluginInfo::fromServices(offers);
}
ContainmentActions *ContainmentActions::load(Containment *parent, const QString &containmentActionsName, const QVariantList &args)
{
if (containmentActionsName.isEmpty()) {
return 0;
}
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(containmentActionsName);
KService::List offers = KServiceTypeTrader::self()->query("Plasma/ContainmentActions", constraint);
if (offers.isEmpty()) {
kDebug() << "offers is empty for " << containmentActionsName;
return 0;
}
KService::Ptr offer = offers.first();
KPluginLoader plugin(*offer);
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
return 0;
}
QVariantList allArgs;
allArgs << offer->storageId() << args;
QString error;
ContainmentActions *containmentActions = offer->createInstance<Plasma::ContainmentActions>(parent, allArgs, &error);
if (!containmentActions) {
kDebug() << "Couldn't load containmentActions \"" << containmentActionsName << "\"! reason given: " << error;
}
return containmentActions;
}
ContainmentActions *ContainmentActions::load(Containment *parent, const KPluginInfo &info, const QVariantList &args)
{
if (!info.isValid()) {
return 0;
}
return load(parent, info.pluginName(), args);
}
Containment *ContainmentActions::containment()
{
if (d->containment) {

View File

@ -66,41 +66,6 @@ class PLASMA_EXPORT ContainmentActions : public QObject
~ContainmentActions();
/**
* Returns a list of all known containmentactions plugins.
*
* @return list of containmentactions plugins
**/
static KPluginInfo::List listContainmentActionsInfo();
/**
* Attempts to load a containmentactions
*
* Returns a pointer to the containmentactions if successful.
* The caller takes responsibility for the containmentactions, including
* deleting it when no longer needed.
*
* @param parent the parent containment. @since 4.6 null is allowed.
* @param name the plugin name, as returned by KPluginInfo::pluginName()
* @param args to send the containmentactions extra arguments
* @return a pointer to the loaded containmentactions, or 0 on load failure
**/
static ContainmentActions *load(Containment *parent, const QString &name, const QVariantList &args = QVariantList());
/**
* Attempts to load a containmentactions
*
* Returns a pointer to the containmentactions if successful.
* The caller takes responsibility for the containmentactions, including
* deleting it when no longer needed.
*
* @param parent the parent containment. @since 4.6 null is allowed.
* @param info KPluginInfo object for the desired containmentactions
* @param args to send the containmentactions extra arguments
* @return a pointer to the loaded containmentactions, or 0 on load failure
**/
static ContainmentActions *load(Containment *parent, const KPluginInfo &info, const QVariantList &args = QVariantList());
/**
* Returns the user-visible name for the containmentactions, as specified in the
* .desktop file.