mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
plasma: remove unused internal API of plugin loader
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
d50bb33c01
commit
fd48bb91cf
2 changed files with 9 additions and 277 deletions
|
@ -83,11 +83,6 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari
|
|||
return 0;
|
||||
}
|
||||
|
||||
Applet *applet = internalLoadApplet(name, appletId, args);
|
||||
if (applet) {
|
||||
return applet;
|
||||
}
|
||||
|
||||
const QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Applet", constraint);
|
||||
|
||||
|
@ -142,6 +137,8 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari
|
|||
}
|
||||
|
||||
|
||||
|
||||
Applet *applet = 0;
|
||||
QString error;
|
||||
if (name == "internal:extender") {
|
||||
applet = new ExtenderApplet(0, allArgs);
|
||||
|
@ -158,17 +155,13 @@ Applet *PluginLoader::loadApplet(const QString &name, uint appletId, const QVari
|
|||
|
||||
DataEngine *PluginLoader::loadDataEngine(const QString &name)
|
||||
{
|
||||
DataEngine *engine = internalLoadDataEngine(name);
|
||||
if (engine) {
|
||||
return engine;
|
||||
}
|
||||
|
||||
// load the engine, add it to the engines
|
||||
QString constraint = QString("[X-KDE-PluginInfo-Name] == '%1'").arg(name);
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine",
|
||||
constraint);
|
||||
QString error;
|
||||
|
||||
DataEngine *engine = 0;
|
||||
QString error;
|
||||
if (offers.isEmpty()) {
|
||||
kDebug() << "offers are empty for " << name << " with constraint " << constraint;
|
||||
} else {
|
||||
|
@ -198,16 +191,11 @@ AbstractRunner *PluginLoader::loadRunner(const QString &name)
|
|||
{
|
||||
// FIXME: RunnerManager is all wrapped around runner loading; that should be sorted out
|
||||
// and the actual plugin loading added here
|
||||
return internalLoadRunner(name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Service *PluginLoader::loadService(const QString &name, const QVariantList &args, QObject *parent)
|
||||
{
|
||||
Service *service = internalLoadService(name, args, parent);
|
||||
if (service) {
|
||||
return service;
|
||||
}
|
||||
|
||||
//TODO: scripting API support
|
||||
if (name.isEmpty()) {
|
||||
return new NullService(QString(), parent);
|
||||
|
@ -223,10 +211,10 @@ Service *PluginLoader::loadService(const QString &name, const QVariantList &args
|
|||
return new NullService(name, parent);
|
||||
}
|
||||
|
||||
KService::Ptr offer = offers.first();
|
||||
Service *service = 0;
|
||||
QString error;
|
||||
KService::Ptr offer = offers.first();
|
||||
KPluginLoader plugin(*offer);
|
||||
|
||||
if (Plasma::isPluginCompatible(plugin.pluginName(), plugin.pluginVersion())) {
|
||||
service = offer->createInstance<Plasma::Service>(parent, args, &error);
|
||||
}
|
||||
|
@ -245,12 +233,6 @@ Service *PluginLoader::loadService(const QString &name, const QVariantList &args
|
|||
|
||||
KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QString &parentApp)
|
||||
{
|
||||
KPluginInfo::List list;
|
||||
|
||||
if (parentApp.isEmpty() || parentApp == KGlobal::mainComponent().componentName()) {
|
||||
list = internalAppletInfo(category);
|
||||
}
|
||||
|
||||
QString constraint = AppletPrivate::parentAppConstraint(parentApp);
|
||||
|
||||
//note: constraint guaranteed non-empty from here down
|
||||
|
@ -279,12 +261,6 @@ KPluginInfo::List PluginLoader::listAppletInfo(const QString &category, const QS
|
|||
|
||||
KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp)
|
||||
{
|
||||
KPluginInfo::List list;
|
||||
|
||||
if (parentApp.isEmpty() || parentApp == KGlobal::mainComponent().componentName()) {
|
||||
list = internalDataEngineInfo();
|
||||
}
|
||||
|
||||
QString constraint;
|
||||
if (parentApp.isEmpty()) {
|
||||
constraint.append("not exist [X-KDE-ParentApp]");
|
||||
|
@ -293,17 +269,11 @@ KPluginInfo::List PluginLoader::listDataEngineInfo(const QString &parentApp)
|
|||
}
|
||||
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/DataEngine", constraint);
|
||||
return list + KPluginInfo::fromServices(offers);
|
||||
return KPluginInfo::fromServices(offers);
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::listRunnerInfo(const QString &parentApp)
|
||||
{
|
||||
KPluginInfo::List list;
|
||||
|
||||
if (parentApp.isEmpty() || parentApp == KGlobal::mainComponent().componentName()) {
|
||||
list = internalRunnerInfo();
|
||||
}
|
||||
|
||||
QString constraint;
|
||||
if (parentApp.isEmpty()) {
|
||||
constraint.append("not exist [X-KDE-ParentApp]");
|
||||
|
@ -312,98 +282,7 @@ KPluginInfo::List PluginLoader::listRunnerInfo(const QString &parentApp)
|
|||
}
|
||||
|
||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/Runner", constraint);
|
||||
return list + KPluginInfo::fromServices(offers);
|
||||
}
|
||||
|
||||
Applet* PluginLoader::internalLoadApplet(const QString &name, uint appletId, const QVariantList &args)
|
||||
{
|
||||
Q_UNUSED(name)
|
||||
Q_UNUSED(appletId)
|
||||
Q_UNUSED(args)
|
||||
return 0;
|
||||
}
|
||||
|
||||
DataEngine* PluginLoader::internalLoadDataEngine(const QString &name)
|
||||
{
|
||||
Q_UNUSED(name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
AbstractRunner* PluginLoader::internalLoadRunner(const QString &name)
|
||||
{
|
||||
Q_UNUSED(name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
Service* PluginLoader::internalLoadService(const QString &name, const QVariantList &args, QObject *parent)
|
||||
{
|
||||
Q_UNUSED(name)
|
||||
Q_UNUSED(args)
|
||||
Q_UNUSED(parent)
|
||||
return 0;
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::internalAppletInfo(const QString &category) const
|
||||
{
|
||||
Q_UNUSED(category)
|
||||
return KPluginInfo::List();
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::internalDataEngineInfo() const
|
||||
{
|
||||
return KPluginInfo::List();
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::internalRunnerInfo() const
|
||||
{
|
||||
return KPluginInfo::List();
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::internalServiceInfo() const
|
||||
{
|
||||
return KPluginInfo::List();
|
||||
}
|
||||
|
||||
static KPluginInfo::List standardInternalInfo(const QString &type, const QString &category = QString())
|
||||
{
|
||||
QStringList files = KGlobal::dirs()->findAllResources("appdata",
|
||||
"plasma/internal/" + type + "/*.desktop",
|
||||
KStandardDirs::NoDuplicates);
|
||||
|
||||
KPluginInfo::List allInfo = KPluginInfo::fromFiles(files);
|
||||
|
||||
if (category.isEmpty() || allInfo.isEmpty()) {
|
||||
return allInfo;
|
||||
}
|
||||
|
||||
KPluginInfo::List matchingInfo;
|
||||
foreach (const KPluginInfo &info, allInfo) {
|
||||
if (info.category().compare(category, Qt::CaseInsensitive) == 0) {
|
||||
matchingInfo << info;
|
||||
}
|
||||
}
|
||||
|
||||
return matchingInfo;
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::standardInternalAppletInfo(const QString &category) const
|
||||
{
|
||||
return standardInternalInfo("applets", category);
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::standardInternalDataEngineInfo() const
|
||||
{
|
||||
return standardInternalInfo("dataengines");
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::standardInternalRunnerInfo() const
|
||||
{
|
||||
return standardInternalInfo("runners");
|
||||
}
|
||||
|
||||
KPluginInfo::List PluginLoader::standardInternalServiceInfo() const
|
||||
{
|
||||
return standardInternalInfo("services");
|
||||
return KPluginInfo::fromServices(offers);
|
||||
}
|
||||
|
||||
} // Plasma Namespace
|
||||
|
|
|
@ -149,153 +149,6 @@ public:
|
|||
**/
|
||||
static PluginLoader* pluginLoader();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* A re-implementable method that allows subclasses to override
|
||||
* the default behaviour of loadApplet. If the applet requested is not recognized,
|
||||
* then the implementation should return a NULL pointer. This method is called
|
||||
* by loadApplet prior to attempting to load an applet using the standard Plasma
|
||||
* plugin mechanisms.
|
||||
*
|
||||
* @param name the plugin name, as returned by KPluginInfo::pluginName()
|
||||
* @param appletId unique ID to assign the applet, or zero to have one
|
||||
* assigned automatically.
|
||||
* @param args to send the applet extra arguments
|
||||
* @return a pointer to the loaded applet, or 0 on load failure
|
||||
**/
|
||||
virtual Applet *internalLoadApplet(const QString &name, uint appletId = 0,
|
||||
const QVariantList &args = QVariantList());
|
||||
|
||||
/**
|
||||
* A re-implementable method that allows subclasses to override
|
||||
* the default behaviour of loadRunner. If the runner requested is not recognized,
|
||||
* then the implementation should return a NULL pointer. This method is called
|
||||
* by loadRunner prior to attempting to load a DataEgine using the standard Plasma
|
||||
* plugin mechanisms.
|
||||
*
|
||||
* @param name the name of the engine
|
||||
* @return the data engine that was loaded, or the NullEngine on failure.
|
||||
**/
|
||||
virtual AbstractRunner *internalLoadRunner(const QString &name);
|
||||
|
||||
/**
|
||||
* A re-implementable method that allows subclasses to override
|
||||
* the default behaviour of loadDataEngine. If the engine requested is not recognized,
|
||||
* then the implementation should return a NULL pointer. This method is called
|
||||
* by loadDataEngine prior to attempting to load a DataEgine using the standard Plasma
|
||||
* plugin mechanisms.
|
||||
*
|
||||
* @param name the name of the engine
|
||||
* @return the data engine that was loaded, or the NullEngine on failure.
|
||||
**/
|
||||
virtual DataEngine *internalLoadDataEngine(const QString &name);
|
||||
|
||||
/**
|
||||
* A re-implementable method that allows subclasses to override
|
||||
* the default behaviour of loadService. 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 Service *internalLoadService(const QString &name, const QVariantList &args, QObject *parent = 0);
|
||||
|
||||
/**
|
||||
* A re-implementable method that allows subclasses to provide additional applets
|
||||
* for listAppletInfo. If the application has no applets to give to the application,
|
||||
* then the implementation should return an empty list.
|
||||
*
|
||||
* This method is called by listAppletInfo prior to generating the list of applets installed
|
||||
* on the system using the standard Plasma plugin mechanisms, and will try to find .desktop
|
||||
* files for your applets.
|
||||
*
|
||||
* @param category Only applets matching this category will be returned.
|
||||
* Useful in conjunction with knownCategories.
|
||||
* If "Misc" is passed in, then applets without a
|
||||
* Categories= entry are also returned.
|
||||
* If an empty string is passed in, all applets are
|
||||
* returned.
|
||||
* @return list of applets
|
||||
**/
|
||||
virtual KPluginInfo::List internalAppletInfo(const QString &category) const;
|
||||
|
||||
/**
|
||||
* A re-implementable method that allows subclasses to provide additional DataEngines
|
||||
* for DataEngineManager::listDataEngines.
|
||||
*
|
||||
* @return list of DataEngines, or an empty list if none
|
||||
**/
|
||||
virtual KPluginInfo::List internalDataEngineInfo() const;
|
||||
|
||||
/**
|
||||
* Returns a list of all known Runner implementations
|
||||
*
|
||||
* @return list of AbstractRunners, or an empty list if none
|
||||
*/
|
||||
virtual KPluginInfo::List internalRunnerInfo() const;
|
||||
|
||||
/**
|
||||
* Returns a list of all known Runner implementations
|
||||
*
|
||||
* @return list of AbstractRunners, or an empty list if none
|
||||
*/
|
||||
virtual KPluginInfo::List internalServiceInfo() const;
|
||||
|
||||
/**
|
||||
* Standardized mechanism for providing internal Applets by install .desktop files
|
||||
* in $APPPDATA/plasma/internal/applets/
|
||||
*
|
||||
* For applications that do this, internalAppletInfo can be implemented as a one-liner
|
||||
* call to this method.
|
||||
*
|
||||
* @param category Only applets matching this category will be returned.
|
||||
* Useful in conjunction with knownCategories.
|
||||
* If "Misc" is passed in, then applets without a
|
||||
* Categories= entry are also returned.
|
||||
* If an empty string is passed in, all applets are
|
||||
* returned.
|
||||
* @return list of Applets, or an empty list if none
|
||||
*/
|
||||
KPluginInfo::List standardInternalAppletInfo(const QString &category) const;
|
||||
|
||||
/**
|
||||
* Standardized mechanism for providing internal Applets by install .desktop files
|
||||
* in $APPPDATA/plasma/internal/dataengines/
|
||||
*
|
||||
* For applications that do this, internalDataEngineInfo can be implemented as a one-liner
|
||||
* call to this method.
|
||||
*
|
||||
* @return list of applets
|
||||
*/
|
||||
KPluginInfo::List standardInternalDataEngineInfo() const;
|
||||
|
||||
/**
|
||||
* Standardized mechanism for providing internal Applets by install .desktop files
|
||||
* in $APPPDATA/plasma/internal/runners/
|
||||
*
|
||||
* For applications that do this, internalRunnerInfo can be implemented as a one-liner
|
||||
* call to this method.
|
||||
*
|
||||
* @return list of applets
|
||||
*/
|
||||
KPluginInfo::List standardInternalRunnerInfo() const;
|
||||
|
||||
/**
|
||||
* Standardized mechanism for providing internal Applets by install .desktop files
|
||||
* in $APPPDATA/plasma/internal/services/
|
||||
*
|
||||
* For applications that do this, internalRunnerInfo can be implemented as a one-liner
|
||||
* call to this method.
|
||||
*
|
||||
* @return list of applets
|
||||
*/
|
||||
KPluginInfo::List standardInternalServiceInfo() const;
|
||||
|
||||
private:
|
||||
PluginLoaderPrivate * const d;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue