Fix no newlines warnings. Patch by Peter Oberndorfer
[kdevelopdvcssupport.git] / shell / plugincontroller.h
blob00da6ba5b321dc212e93ad416237a3ae0c45ec11
1 /* This file is part of the KDE project
2 Copyright 2007 Andreas Pakulat <apaku@gmx.de>
3 Copyright 2004, 2007 Alexander Dymo <adymo@kdevelop.org>
4 Copyright 2006 Matt Rogers <mattr@kde.org
6 Based on code from Kopete
7 Copyright (c) 2002-2003 Martijn Klingens <klingens@kde.org>
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02110-1301, USA.
24 #ifndef KDEVPLUGINCONTROLLER_H
25 #define KDEVPLUGINCONTROLLER_H
28 #include <QtCore/QHash>
30 #include <kurl.h>
31 #include <kservice.h>
32 #include <kplugininfo.h>
33 #include <kservicetypetrader.h>
35 #include <interfaces/iplugincontroller.h>
37 #include "shellexport.h"
40 namespace KDevelop
42 class Core;
43 class IPlugin;
44 class ProfileEngine;
45 class PluginControllerPrivate;
46 /**
47 * The KDevelop plugin controller.
48 * The Plugin controller is responsible for querying, loading and unloading
49 * available plugins.
51 class KDEVPLATFORMSHELL_EXPORT PluginController: public IPluginController
54 Q_OBJECT
55 friend class Core;
57 public:
59 PluginController(Core *core);
61 virtual ~PluginController();
63 /**
64 * Get the plugin instance based on the ID. The ID should be whatever is
65 * in X-KDE-PluginInfo-Name
67 IPlugin* plugin( const QString& );
69 /**
70 * Get the plugin info for a loaded plugin
72 KPluginInfo pluginInfo( const IPlugin* ) const;
74 /**
75 * Get a list of currently loaded plugins
77 QList<IPlugin*> loadedPlugins() const;
79 /**
80 * Returns a uniquely specified plugin. If it isn't already loaded, it will be.
81 * @param pluginName the name of the plugin, as given in the X-KDE-PluginInfo-Name property
82 * @returns a pointer to the plugin instance or 0
84 IPlugin * loadPlugin( const QString & pluginName );
86 /**
87 * @brief Unloads the plugin specified by @p plugin
89 * @param plugin The name of the plugin as specified by the
90 * X-KDE-PluginInfo-Name key of the .desktop file for the plugin
92 void unloadPlugin( const QString & plugin );
94 enum PluginDeletion {
95 Now,
96 Later
99 /**
100 * Directly unload the given \a plugin, either deleting it now or \a later.
102 * \param plugin plugin to unload
103 * \param later if true, delete the plugin later, if false, delete it now.
105 void unloadPlugin(IPlugin* plugin, PluginDeletion deletion);
108 * Queries for the plugin which supports given extension interface.
109 * All already loaded plugins will be queried and the first one to support the extension interface
110 * will be returned. Any plugin can be an extension, only "ServiceTypes=..." entry is
111 * required in .desktop file for that plugin.
112 * @param extension The extension interface
113 * @param pluginname The name of the plugin to load if multiple plugins for the extension exist, corresponds to the X-KDE-PluginInfo-Name
114 * @return A KDevelop extension plugin for given service type or 0 if no plugin supports it
116 IPlugin *pluginForExtension(const QString &extension, const QString &pluginname = "");
117 IPlugin *pluginForExtension(const QString &extension, const QStringList &constraints);
119 QList<IPlugin*> allPluginsForExtension(const QString &extension, const QStringList &constraints = QStringList());
121 static KPluginInfo::List queryExtensionPlugins(const QString &extension, const QStringList &constraints);
124 * Reimplement this function only if your shell supports plugin profiles.
125 * @return The list of URLs to the profile resources (files) with given @p extension.
126 * @param nameFilter Name filter for files. @see QDir::setNameFilter documentation
127 * for name filters syntax.
129 KUrl::List profileResources( const QString &nameFilter );
132 * Reimplement this function only if your shell supports plugin profiles.
133 * @return The list of URLs to the resources (files) with given @p extension.
134 * This list is obtained by a recursive search that process given profile
135 * and all it's subprofiles.
136 * @param nameFilter Name filter for files. @see QDir::setNameFilter documentation
137 * for name filters syntax.
139 KUrl::List profileResourcesRecursive( const QString &nameFilter );
141 QString currentProfile() const;
143 void loadPlugins( PluginType offer );
144 void unloadPlugins( PluginType offer );
146 ProfileEngine &engine() const;
148 //returns the name of an old profile that was unloaded
149 QString changeProfile( const QString &newProfile );
151 QExtensionManager* extensionManager();
153 QStringList allPluginNames();
155 QList<ContextMenuExtension> queryPluginsForContextMenuExtensions( KDevelop::Context* context ) const;
157 QStringList projectPlugins();
159 private:
162 * @internal
164 * The internal method for loading plugins.
165 * Called by @ref loadPlugin directly or through the queue for async plugin
166 * loading.
168 IPlugin* loadPluginInternal( const QString &pluginId );
171 * @internal
173 * Find the KPluginInfo structure by key. Reduces some code duplication.
175 * Returns a null pointer when no plugin info is found.
177 KPluginInfo infoForPluginId( const QString &pluginId ) const;
179 bool checkForDependencies( const KPluginInfo& info, QStringList& missing ) const;
181 void loadDependencies( const KPluginInfo& );
182 void loadOptionalDependencies( const KPluginInfo& info );
184 void cleanup();
186 private:
187 class PluginControllerPrivate* const d;
191 #endif