Blokkal
an Extendable KDE Blogging Client
SourceForge.net Logo

Blokkal::Plugin Class Reference

Base class for blokkal plugins. More...

#include <blokkalplugin.h>

Inheritance diagram for Blokkal::Plugin:

Blokkal::Protocol Blokkal::Ui::BrowseEntryViewFactory Blokkal::Ui::EditEntryViewFactory

List of all members.


Public Slots

virtual void prepareToUnload (void)

Signals

void readyToUnload (Blokkal::Plugin *plugin)

Public Member Functions

KIcon icon (void) const
 Plugin (const KComponentData &instance, QObject *parent=0)
KPluginInfo pluginInfo (void) const
QString pluginName (void) const
QString visibleName (void) const
virtual ~Plugin (void)

Detailed Description

Base class for blokkal plugins.

All plugins must implement this class.

For a general tutorial about plugins and applications using plugins see http://developer.kde.org/documentation/tutorials/developing-a-plugin-structure/index.html for a nice tutorial.

You must pass the instance of your plugin to the constructor of this class. The instance is used to load the ui.rc file for your plugin. Simply call the constructor from your implementation like this:

 Plugin( KGenericFactory<MyPlugin>::instance(), parent, name )

You will also need to create a desktop file to make your plugin available to Blokkal:

 [Desktop Entry]
 Encoding=UTF-8
 Type=Service
 Icon=blokkal
 ServiceTypes=Blokkal/Plugin
 X-KDE-Library=blokkal_myplugin
 X-KDE-PluginInfo-Author=Your Name
 X-KDE-PluginInfo-Email=someone@somewhere.org
 X-KDE-PluginInfo-Name=blokkal_myplugin
 X-KDE-PluginInfo-Version=0.0.1
 X-KDE-PluginInfo-Website=
 X-KDE-PluginInfo-Category=Plugins
 X-KDE-PluginInfo-Depends=
 X-KDE-PluginInfo-License=GPL
 X-KDE-PluginInfo-EnabledByDefault=false
 Name=MyPlugin
 Comment=A short description of what your plugin actually does.
If you want to create a Blokkal::Protocol or Blokkal::UI::EditEntryViewPlugin the value of ServiceTypes must be Blokkal/Protocol or Blokkal/EditEntryViewPlugin respectively.

Note:
You will not get the application name set in the about data of your plugin, even if you specify the Name-key in the desktop file. If you provide any GUI elements in your plugin (which is almost certainly the case for protocols and view plugins ) you can load your plugin like this:
 static const KAboutData aboutData("blokkal_myplugin", I18N_NOOP("MyPlugin") , "0.0.1" );
 K_EXPORT_COMPONENT_FACTORY( blokkal_myplugin, KGenericFactory<MyPluginClass>( &aboutData ) )
In conclusion, do the following steps to create a plugin:

Create the desktop file.

Implement the plugin class:
Header:

 #include <blokkalplugin.h>
 class MyPlugin : public Blokkal::Plugin {
 Q_OBJECT
 public:
   MyPlugin( QObject * parent, const QVariantList & args );
   virtual ~MyPlugin( void );
 };

Source:

 #include "myplugin.h"
 #include "myplugin.moc"

 #include <kpluginfactory.h>
 
 static const KAboutData aboutData("blokkal_myplugin", I18N_NOOP("MyPlugin") , "0.0.1" );
 K_EXPORT_COMPONENT_FACTORY( blokkal_myplugin, KGenericFactory<MyPlugin>( &aboutData ) )
 K_PLUGIN_FACTORY( MyPluginFactory, registerPlugin<MyPlugin>(); )
 K_EXPORT_PLUGIN( MyPluginFactory("blokkal_myplugin") )
 

 MyPlugin::MyPlugin( QObject * parent, const QStringList & args ) :
 Blokkal::Protocol( MyPluginFactory::componentData(), parent )
 {}

 MyPlugin::~MyPlugin( void )
 {}
To build the module you must define the build target this way:
 kde4_add_plugin(blokkal_myplugin ${blokkal_myplugin_PART_SRCS})
 target_link_libraries(blokkal_myplugin  ${KDE4_KDECORE_LIBS} blokkal )
 install(TARGETS blokkal_myplugin DESTINATION ${PLUGIN_INSTALL_DIR} )

To install everything in the right place your Makefile.am should also contain these lines:

 install( FILES  blokkal_mypluginui.rc DESTINATION ${DATA_INSTALL_DIR}/blokkal_myplugin )
 install( FILES  blokkal_myplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR} )

Author:
Martin Mueller <orvio@orvio.de>

Definition at line 135 of file blokkalplugin.h.


Constructor & Destructor Documentation

Blokkal::Plugin::Plugin ( const KComponentData &  instance,
QObject *  parent = 0 
)

Creates a new Plugin object.

Parameters:
parent owning object
instance the instance of this plugin

Definition at line 27 of file blokkalplugin.cpp.

Blokkal::Plugin::~Plugin ( void   )  [virtual]

Destructor

Definition at line 34 of file blokkalplugin.cpp.


Member Function Documentation

KIcon Blokkal::Plugin::icon ( void   )  const

Returns the icon for this plugin.

Returns:
the icon for this plugin

Definition at line 47 of file blokkalplugin.cpp.

KPluginInfo Blokkal::Plugin::pluginInfo ( void   )  const

Returns the plugin info for this plugin.

Returns:
the plugin info

Definition at line 42 of file blokkalplugin.cpp.

QString Blokkal::Plugin::pluginName ( void   )  const

Returns the internal plugin name.

Returns:
the plugin name

Definition at line 37 of file blokkalplugin.cpp.

void Blokkal::Plugin::prepareToUnload ( void   )  [virtual, slot]

This slot is called prior to deleting the plugin object. If you need to do some cleanup when shutting down, do it here. The default implementation just emits readyToUnload().

Reimplemented in Blokkal::Protocol.

Definition at line 57 of file blokkalplugin.cpp.

void Blokkal::Plugin::readyToUnload ( Blokkal::Plugin plugin  )  [signal]

This signal is emitted after a call prepareToUnload(). The plugin object may be safely deleted after this signal.

Parameters:
plugin the plugin that has just shut down

QString Blokkal::Plugin::visibleName ( void   )  const

Returns the user visible name of the plugin.

Returns:
the visible name

Definition at line 52 of file blokkalplugin.cpp.


The documentation for this class was generated from the following files: