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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
/* This file is part of the KDE project
Copyright (C) 2003 Matthias Kretz <[email protected]>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KPLUGININFO_H
#define KPLUGININFO_H
#include <tqstring.h>
#include <tqmap.h>
#include <tqstringlist.h>
#include <tqvaluelist.h>
#include <kservice.h>
class KConfigGroup;
/**
* @ingroup main
* @ingroup plugin
* Information about a plugin.
*
* This holds all the information about a plugin there is. It's used for the
* user to decide whether he wants to use this plugin or not.
*
* @author Matthias Kretz <[email protected]>
* @since 3.2
*/
class KUTILS_EXPORT KPluginInfo
{
public:
typedef TQValueList<KPluginInfo*> List;
/**
* Read plugin info from @p filename.
*
* The file should be of the following form:
* \verbatim
[Desktop Entry]
Name=User Visible Name
Comment=Description of what the plugin does
[X-KDE Plugin Info]
Author=Author's Name
[email protected]
PluginName=internalname
Version=1.1
Website=http://www.plugin.org/
Category=playlist
Depends=plugin1,plugin3
License=GPL
EnabledByDefault=true
\endverbatim
* The first two entries in the "Desktop Entry" group always need to
* be present.
*
* The "X-KDE-PluginInfo" keys you may add further entries which
* will be available using property(). The Website,Category,Require
* keys are optional.
* For EnabledByDefault look at isPluginEnabledByDefault.
*
* @param filename The filename of the .desktop file.
* @param resource If filename is relative, you need to specify a resource type
* (e.g. "service", "apps"... KStandardDirs). Otherwise,
* resource isn't used.
*/
KPluginInfo( const TQString & filename, const char* resource = 0 );
/**
* Read plugin info from a KService object.
*
* The .desktop file should look like this:
* \verbatim
[Desktop Entry]
Encoding=UTF-8
Icon=mypluginicon
Type=Service
ServiceTypes=KPluginInfo
X-KDE-PluginInfo-Author=Author's Name
[email protected]
X-KDE-PluginInfo-Name=internalname
X-KDE-PluginInfo-Version=1.1
X-KDE-PluginInfo-Website=http://www.plugin.org/
X-KDE-PluginInfo-Category=playlist
X-KDE-PluginInfo-Depends=plugin1,plugin3
X-KDE-PluginInfo-License=GPL
X-KDE-PluginInfo-EnabledByDefault=true
Name=User Visible Name
Comment=Description of what the plugin does
\endverbatim
* In the first three entries the Icon entry is optional.
*/
KPluginInfo( const KService::Ptr service );
//X /**
//X * Create an empty hidden plugin.
//X * @internal
//X */
//X KPluginInfo();
virtual ~KPluginInfo();
/**
* @return A list of KPluginInfo objects constructed from a list of
* KService objects. If you get a trader offer of the plugins you want
* to use you can just pass them to this function.
*/
static KPluginInfo::List fromServices( const KService::List & services, KConfig * config = 0, const TQString & group = TQString::null );
/**
* @return A list of KPluginInfo objects constructed from a list of
* filenames. If you make a lookup using, for example,
* KStandardDirs::findAllResources() you pass the list of files to this
* function.
*/
static KPluginInfo::List fromFiles( const TQStringList & files, KConfig * config = 0, const TQString & group = TQString::null );
/**
* @return A list of KPluginInfo objects for the KParts plugins of an
* instance. You only need the name of the instance not a pointer to the
* KInstance object.
*/
static KPluginInfo::List fromKPartsInstanceName( const TQString &, KConfig * config = 0, const TQString & group = TQString::null );
/**
* @return Whether the plugin should be hidden.
*/
bool isHidden() const;
/**
* Set whether the plugin is currently loaded.
*
* You might need to reimplement this method for special needs.
*
* @see isPluginEnabled()
* @see save()
*/
virtual void setPluginEnabled( bool enabled );
/**
* @return Whether the plugin is currently loaded.
*
* You might need to reimplement this method for special needs.
*
* @see setPluginEnabled()
* @see load()
*/
virtual bool isPluginEnabled() const;
/**
* @return The default value whether the plugin is enabled or not.
* Defaults to the value set in the desktop file, or if that isn't set
* to false.
*/
bool isPluginEnabledByDefault() const;
/**
* @return The value associated the the @p key. You can use it if you
* want to read custom values. To do this you need to define
* your own servicetype and add it to the ServiceTypes keys.
*
* @see operator[]
*/
TQVariant property( const TQString & key ) const;
/**
* This is the same as property(). It is provided for convenience.
*
* @return The value associated with the @p key.
*
* @see property()
*/
TQVariant operator[]( const TQString & key ) const;
/**
* @return The user visible name of the plugin.
*/
const TQString & name() const;
/**
* @return A comment describing the plugin.
*/
const TQString & comment() const;
/**
* @return The iconname for this plugin
*/
const TQString & icon() const;
/**
* @return The file containing the information about the plugin.
*/
const TQString & specfile() const;
/**
* @return The author of this plugin.
*/
const TQString & author() const;
/**
* @return The email address of the author.
*/
const TQString & email() const;
/**
* @return The category of this plugin (e.g. playlist/skin).
*/
const TQString & category() const;
/**
* @return The internal name of the plugin (for KParts Plugins this is
* the same name as set in the .rc file).
*/
const TQString & pluginName() const;
/**
* @return The version of the plugin.
*/
const TQString & version() const;
/**
* @return The website of the plugin/author.
*/
const TQString & website() const;
/**
* @return The license of this plugin.
*/
const TQString & license() const;
/**
* @return A list of plugins required for this plugin to be enabled. Use
* the pluginName in this list.
*/
const TQStringList & dependencies() const;
/**
* @return The KService object for this plugin. You might need it if you
* want to read custom values. To do this you need to define
* your own servicetype and add it to the ServiceTypes keys.
* Then you can use the KService::property() method to read your
* keys.
*
* @see property()
*/
KService::Ptr service() const;
/**
* @return A list of Service pointers if the plugin installs one or more
* KCModule
*/
const TQValueList<KService::Ptr> & kcmServices() const;
/**
* Set the KConfigGroup to use for load()ing and save()ing the
* configuration. This will be overridden by the KConfigGroup passed to
* save() or load() (if one is passed).
*/
void setConfig( KConfig * config, const TQString & group );
/**
* @return If the KPluginInfo object has a KConfig object set return
* it, else return 0.
*/
KConfig * config() const;
/**
* @return The groupname used in the KConfig object for load()ing and
* save()ing whether the plugin is enabled.
*/
const TQString & configgroup() const;
/**
* Save state of the plugin - enabled or not. This function is provided
* for reimplementation if you need to save somewhere else.
* @param config The KConfigGroup holding the information whether
* plugin is enabled.
*/
virtual void save( KConfigGroup * config = 0 );
/**
* Load the state of the plugin - enabled or not. This function is provided
* for reimplementation if you need to save somewhere else.
* @param config The KConfigGroup holding the information whether
* plugin is enabled.
*/
virtual void load( KConfigGroup * config = 0 );
/**
* Restore defaults (enabled or not).
*/
virtual void defaults();
private:
KPluginInfo( const KPluginInfo & );
const KPluginInfo & operator=( const KPluginInfo & );
class KPluginInfoPrivate;
KPluginInfoPrivate * d;
};
// vim: sw=4 sts=4 et tw=80
#endif // KPLUGININFO_H
|