You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
320 lines
10 KiB
320 lines
10 KiB
15 years ago
|
/* This file is part of the KDE project
|
||
|
Copyright (C) 2003 Matthias Kretz <kretz@kde.org>
|
||
|
|
||
|
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
|
||
|
|
||
14 years ago
|
#include <tqstring.h>
|
||
|
#include <tqmap.h>
|
||
|
#include <tqstringlist.h>
|
||
|
#include <tqvaluelist.h>
|
||
15 years ago
|
#include <kservice.h>
|
||
|
|
||
12 years ago
|
class TDEConfigGroup;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @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 <kretz@kde.org>
|
||
|
* @since 3.2
|
||
|
*/
|
||
|
class KUTILS_EXPORT KPluginInfo
|
||
|
{
|
||
|
public:
|
||
14 years ago
|
typedef TQValueList<KPluginInfo*> List;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* 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
|
||
|
|
||
13 years ago
|
[X-TDE Plugin Info]
|
||
15 years ago
|
Author=Author's Name
|
||
|
Email=author@foo.bar
|
||
|
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.
|
||
|
*
|
||
13 years ago
|
* The "X-TDE-PluginInfo" keys you may add further entries which
|
||
15 years ago
|
* 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.
|
||
|
*/
|
||
14 years ago
|
KPluginInfo( const TQString & filename, const char* resource = 0 );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* 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
|
||
|
|
||
13 years ago
|
X-TDE-PluginInfo-Author=Author's Name
|
||
|
X-TDE-PluginInfo-Email=author@foo.bar
|
||
|
X-TDE-PluginInfo-Name=internalname
|
||
|
X-TDE-PluginInfo-Version=1.1
|
||
|
X-TDE-PluginInfo-Website=http://www.plugin.org/
|
||
|
X-TDE-PluginInfo-Category=playlist
|
||
|
X-TDE-PluginInfo-Depends=plugin1,plugin3
|
||
|
X-TDE-PluginInfo-License=GPL
|
||
|
X-TDE-PluginInfo-EnabledByDefault=true
|
||
15 years ago
|
|
||
|
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.
|
||
|
*/
|
||
12 years ago
|
static KPluginInfo::List fromServices( const KService::List & services, TDEConfig * config = 0, const TQString & group = TQString::null );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @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.
|
||
|
*/
|
||
12 years ago
|
static KPluginInfo::List fromFiles( const TQStringList & files, TDEConfig * config = 0, const TQString & group = TQString::null );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @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
|
||
12 years ago
|
* TDEInstance object.
|
||
15 years ago
|
*/
|
||
12 years ago
|
static KPluginInfo::List fromKPartsInstanceName( const TQString &, TDEConfig * config = 0, const TQString & group = TQString::null );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @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[]
|
||
|
*/
|
||
14 years ago
|
TQVariant property( const TQString & key ) const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* This is the same as property(). It is provided for convenience.
|
||
|
*
|
||
|
* @return The value associated with the @p key.
|
||
|
*
|
||
|
* @see property()
|
||
|
*/
|
||
14 years ago
|
TQVariant operator[]( const TQString & key ) const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return The user visible name of the plugin.
|
||
|
*/
|
||
14 years ago
|
const TQString & name() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return A comment describing the plugin.
|
||
|
*/
|
||
14 years ago
|
const TQString & comment() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return The iconname for this plugin
|
||
|
*/
|
||
14 years ago
|
const TQString & icon() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return The file containing the information about the plugin.
|
||
|
*/
|
||
14 years ago
|
const TQString & specfile() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return The author of this plugin.
|
||
|
*/
|
||
14 years ago
|
const TQString & author() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return The email address of the author.
|
||
|
*/
|
||
14 years ago
|
const TQString & email() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return The category of this plugin (e.g. playlist/skin).
|
||
|
*/
|
||
14 years ago
|
const TQString & category() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return The internal name of the plugin (for KParts Plugins this is
|
||
|
* the same name as set in the .rc file).
|
||
|
*/
|
||
14 years ago
|
const TQString & pluginName() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return The version of the plugin.
|
||
|
*/
|
||
14 years ago
|
const TQString & version() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return The website of the plugin/author.
|
||
|
*/
|
||
14 years ago
|
const TQString & website() const;
|
||
15 years ago
|
|
||
|
|
||
|
/**
|
||
|
* @return The license of this plugin.
|
||
|
*/
|
||
14 years ago
|
const TQString & license() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @return A list of plugins required for this plugin to be enabled. Use
|
||
|
* the pluginName in this list.
|
||
|
*/
|
||
14 years ago
|
const TQStringList & dependencies() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* @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
|
||
12 years ago
|
* TDECModule
|
||
15 years ago
|
*/
|
||
14 years ago
|
const TQValueList<KService::Ptr> & kcmServices() const;
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* Set the TDEConfigGroup to use for load()ing and save()ing the
|
||
|
* configuration. This will be overridden by the TDEConfigGroup passed to
|
||
15 years ago
|
* save() or load() (if one is passed).
|
||
|
*/
|
||
12 years ago
|
void setConfig( TDEConfig * config, const TQString & group );
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* @return If the KPluginInfo object has a TDEConfig object set return
|
||
15 years ago
|
* it, else return 0.
|
||
|
*/
|
||
12 years ago
|
TDEConfig * config() const;
|
||
15 years ago
|
|
||
|
/**
|
||
12 years ago
|
* @return The groupname used in the TDEConfig object for load()ing and
|
||
15 years ago
|
* save()ing whether the plugin is enabled.
|
||
|
*/
|
||
14 years ago
|
const TQString & configgroup() const;
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Save state of the plugin - enabled or not. This function is provided
|
||
|
* for reimplementation if you need to save somewhere else.
|
||
12 years ago
|
* @param config The TDEConfigGroup holding the information whether
|
||
15 years ago
|
* plugin is enabled.
|
||
|
*/
|
||
12 years ago
|
virtual void save( TDEConfigGroup * config = 0 );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* Load the state of the plugin - enabled or not. This function is provided
|
||
|
* for reimplementation if you need to save somewhere else.
|
||
12 years ago
|
* @param config The TDEConfigGroup holding the information whether
|
||
15 years ago
|
* plugin is enabled.
|
||
|
*/
|
||
12 years ago
|
virtual void load( TDEConfigGroup * config = 0 );
|
||
15 years ago
|
|
||
|
/**
|
||
|
* 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
|