summaryrefslogtreecommitdiffstats
path: root/noatun/library/noatun/pluginloader.h
blob: 04c1b750c5ae0a0fa027e7de6d79a3be8e0261c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef PLUGIN_LOADER_H
#define PLUGIN_LOADER_H

#include <tqstring.h>
#include <tqvaluelist.h>
#include <tqstringlist.h>
#include <noatun/app.h>

#include <klibloader.h>
#include <tqdict.h>
#include <kdemacros.h>

struct NoatunLibraryInfo
{
	TQString specfile;
	TQString filename;
	TQString author;
	TQString license;
	TQString type;
	TQString site;
	TQString email;
	TQString name;
	TQString comment;
	TQStringList require;
};

bool operator ==(const NoatunLibraryInfo &, const NoatunLibraryInfo &);

class Playlist;
class Visualization;
class Plugin;

/**
 * Used for loading plugins at runtime
 **/
class KDE_EXPORT LibraryLoader
{
	friend class Plugin;
	struct PluginLibrary
	{
		Plugin *plugin;
		KLibrary *library;
	};

public:
	LibraryLoader();
	~LibraryLoader();

	TQValueList<NoatunLibraryInfo> available() const;
	TQValueList<NoatunLibraryInfo> loaded() const;
	TQValueList<NoatunLibraryInfo> loadedByType(const TQString &type) const;

	/**
	 * loads all the enabled plugins
	 **/
	bool loadAll(void);
	bool loadAll(const TQStringList &);

	bool isLoaded(const TQString &spec) const;
	void add(const TQString &spec);
	void setModules(const TQStringList &mods);
	/**
	 * unload the plugin specified by spec
	 **/
	bool remove(const TQString &spec);
	/**
	 * Same as the above, but does not call kapp->exit() even
	 * when the last userinterface plugin is removed. Necessary
	 * during session management (see marquis plugin).
	 * ### BIC: merge with above with terminateOnLastUI = true
	 */
	bool remove(const TQString &spec, bool terminateOnLastUI);
	/**
	 * unload the plugin that is referenced by @par plugin
	 **/
	bool remove(const LibraryLoader::PluginLibrary *plugin);
	bool remove(const Plugin *plugin);

	Playlist *playlist() const;

	/**
	 * This is needed for the Plugin-List-View
	 * to see what plugins are required to show
	 * (when required by another noatun-plugin)
	 **/
	NoatunLibraryInfo getInfo(const TQString &spec) const;
	TQPtrList<Plugin> plugins() const;

private:
	bool loadSO(const TQString &spec);
	void removeNow(const TQString &spec);

private:
	TQDict<LibraryLoader::PluginLibrary> mLibHash;
	Playlist *mPlaylist;
};

#endif