KPPlugin

KPPlugin —

Synopsis




typedef     KPPluginInfo;
struct      KPPluginInfo_;
struct      KPPlugin_;
typedef     KPPlugin;
struct      KPPluginClass_;
KPPlugin*   kp_plugin_new                   (const gchar *file);
gboolean    kp_plugin_load                  (KPPlugin *plugin);
gboolean    kp_plugin_load_by_name          (const gchar *name);
gboolean    kp_plugin_load_by_id            (const gchar *id);
void        kp_plugin_unload                (KPPlugin *plugin);
void        kp_plugin_unload_by_name        (const gchar *name);
void        kp_plugin_scan                  (const gchar *dir);
gboolean    kp_plugin_loaded                (const gchar *name);
GList*      kp_plugin_get_plugins           (void);
GList*      kp_plugin_get_plugins_loaded    (void);
KPPlugin*   kp_plugin_get_plugin_by_name    (const gchar *name);
void        kp_plugin_load_plugins          (void);
gboolean    kp_plugin_register              (KPPlugin *plugin);
#define     KP_PLUGIN_INIT                  (name, initfunc, info)

Description

Details

KPPluginInfo

typedef struct KPPluginInfo_  KPPluginInfo;


struct KPPluginInfo_

struct KPPluginInfo_ {
  unsigned int api_version;
  
  char *id;
  char *name;
  char *version;
  char *summary;
  char *description;
  char *author;
  char *homepage;
  char *requires;  /* "simpleplugin,otherplugin" */
 
  gboolean (*load)(KPPlugin *plugin);
  gboolean (*unload)(KPPlugin *plugin);
  void (*destroy)(KPPlugin *plugin);  
};


struct KPPlugin_

struct KPPlugin_ {
  GObject           parent_instance;

  gchar            *fn;
  gboolean          loaded;

  KPPluginInfo     *info;
  
  GModule          *handle;
};


KPPlugin

typedef struct KPPlugin_      KPPlugin;


struct KPPluginClass_

struct KPPluginClass_ {
  GObjectClass      parent_class;  
};


kp_plugin_new ()

KPPlugin*   kp_plugin_new                   (const gchar *file);

Creates a new KPPlugin object and prepare to load it later. This function should probably be called from this module only.

file : Full path to the plugin file.
Returns : a KPPlugin.

kp_plugin_load ()

gboolean    kp_plugin_load                  (KPPlugin *plugin);

Runs a plugin that is registered earlier.

plugin : a KPPlugin
Returns : TRUE if successful and FALSE otherwise.

kp_plugin_load_by_name ()

gboolean    kp_plugin_load_by_name          (const gchar *name);

Load a plugin. See kp_plugin_load() for more.

name : The name of the plugin
Returns : TRUE if ok, FALSE otherwise.

kp_plugin_load_by_id ()

gboolean    kp_plugin_load_by_id            (const gchar *id);

Load a plugin. See kp_plugin_load() for more.

id : The id of the plugin
Returns : TRUE if ok, FALSE otherwise.

kp_plugin_unload ()

void        kp_plugin_unload                (KPPlugin *plugin);

Unload the plugin. That means, the plugin will be removed from the list of loaded plugins and all memory allocated for the plugin will be freed, but KPPlugin structure must be destroyed too. That should probably be done by g_object_unref().

plugin : The plugin

kp_plugin_unload_by_name ()

void        kp_plugin_unload_by_name        (const gchar *name);

Unloads the plugin with name name if found from the list of loaded plugins. See kp_plugin_unload() for more information.

name : the name of the plugin

kp_plugin_scan ()

void        kp_plugin_scan                  (const gchar *dir);

Scans directory or directories for loadable plugins and adds them to list of available plugins but it will not load them!

dir : The directory to scan or NULL to scan default directories.

kp_plugin_loaded ()

gboolean    kp_plugin_loaded                (const gchar *name);

Checks if plugin named name is loaded.

name : the name of the plugin
Returns : TRUE if plugin is loaded and FALSE otherwise.

kp_plugin_get_plugins ()

GList*      kp_plugin_get_plugins           (void);

Returns :

kp_plugin_get_plugins_loaded ()

GList*      kp_plugin_get_plugins_loaded    (void);

Returns :

kp_plugin_get_plugin_by_name ()

KPPlugin*   kp_plugin_get_plugin_by_name    (const gchar *name);

name :
Returns :

kp_plugin_load_plugins ()

void        kp_plugin_load_plugins          (void);

Load all the plugins that are in the config file and marked for loading at the startup.


kp_plugin_register ()

gboolean    kp_plugin_register              (KPPlugin *plugin);

plugin :
Returns :

KP_PLUGIN_INIT()

#define     KP_PLUGIN_INIT(name, initfunc, info)

name :
initfunc :
info :