OpenSync  0.22
Data Structures | Typedefs | Enumerations | Functions

Functions to register and manage plugins. More...

Data Structures

struct  OSyncPluginFunctions
 The functions that can be called on a plugin. More...
 
struct  OSyncPluginTimeouts
 The timeouts for the asynchronous functions of a plugin. More...
 
struct  OSyncFormatFunctions
 The functions for accessing formats on a plugin. More...
 
struct  OSyncPluginInfo
 Gives information about a plugin. More...
 

Typedefs

typedef struct OSyncPluginFunctions OSyncPluginFunctions
 The functions that can be called on a plugin.
 
typedef struct OSyncPluginTimeouts OSyncPluginTimeouts
 The timeouts for the asynchronous functions of a plugin. More...
 
typedef struct OSyncFormatFunctions OSyncFormatFunctions
 The functions for accessing formats on a plugin.
 
typedef struct OSyncPluginInfo OSyncPluginInfo
 Gives information about a plugin.
 

Enumerations

enum  OSyncConfigurationTypes { NO_CONFIGURATION = 0, OPTIONAL_CONFIGURATION = 1, NEEDS_CONFIGURATION = 2 }
 Gives information about wether the plugin has to be configured or not. More...
 

Functions

OSyncPluginosync_plugin_new (OSyncEnv *env)
 This will create a new plugin struct. More...
 
OSyncPluginInfoosync_plugin_new_info (OSyncEnv *env)
 Registers a new plugin. More...
 
void osync_plugin_free (OSyncPlugin *plugin)
 Used to free a plugin. More...
 
void * osync_plugin_get_function (OSyncPlugin *plugin, const char *name, OSyncError **error)
 Used to look up a symbol on the plugin. More...
 
osync_bool osync_module_load (OSyncEnv *env, const char *path, OSyncError **error)
 dlopen()s a format plugin More...
 
void osync_module_unload (OSyncEnv *env, GModule *module)
 Closes a module. More...
 
osync_bool osync_module_load_dir (OSyncEnv *env, const char *path, osync_bool must_exist, OSyncError **error)
 Loads the modules from a given directory. More...
 
const char * osync_plugin_get_name (OSyncPlugin *plugin)
 Returns the name of the loaded plugin. More...
 
const char * osync_plugin_get_longname (OSyncPlugin *plugin)
 Returns the long name of the loaded plugin. More...
 
const char * osync_plugin_get_description (OSyncPlugin *plugin)
 Returns the description of the plugin. More...
 
OSyncPluginTimeouts osync_plugin_get_timeouts (OSyncPlugin *plugin)
 Returns the timeouts of the plugin. More...
 
void * osync_plugin_get_plugin_data (OSyncPlugin *plugin)
 Returns the plugin_info data, set by the plugin. More...
 
const char * osync_plugin_get_path (OSyncPlugin *plugin)
 Get full path for plugin module. More...
 
void osync_plugin_set_commit_objformat (OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, OSyncFormatCommitFn commit_change)
 Sets the commit function of a format. More...
 
void osync_plugin_set_access_objformat (OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, OSyncFormatAccessFn access)
 Sets the access function of a format. More...
 
void osync_plugin_set_read_objformat (OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, OSyncFormatReadFn read)
 Sets the read function of a format. More...
 
void osync_plugin_set_batch_commit_objformat (OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, OSyncFormatBatchCommitFn batch)
 Sets the batch_commit function of a format. More...
 
void osync_plugin_set_committed_all_objformat (OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, OSyncFormatCommittedAllFn committed_all)
 Sets the committed_all function of a format. More...
 
void osync_plugin_accept_objtype (OSyncPluginInfo *info, const char *objtypestr)
 Tells opensync that the plugin can accepts this object. More...
 
void osync_plugin_accept_objformat (OSyncPluginInfo *info, const char *objtypestr, const char *formatstr, const char *extension)
 Tells opensync that the plugin can accepts this format for the given object. More...
 

Detailed Description

Functions to register and manage plugins.

Typedef Documentation

The timeouts for the asynchronous functions of a plugin.

The default timeout it 60 seconds. Set this to 0 if you dont want to have a timeout

Enumeration Type Documentation

Gives information about wether the plugin has to be configured or not.

Enumerator
NO_CONFIGURATION 

Plugin has no configuration options

OPTIONAL_CONFIGURATION 

Plugin can be configured, but will accept the default config in the initialize function

NEEDS_CONFIGURATION 

Plugin must be configured to run correctly

Definition at line 80 of file opensync_plugin.h.

Function Documentation

OSyncPlugin* osync_plugin_new ( OSyncEnv *  env)

This will create a new plugin struct.

The plugin struct represents a sync plugin

Parameters
envFor which environment to register this plugin. May be NULL
Returns
A pointer to a newly allocated plugin.

Definition at line 167 of file opensync_plugin.c.

Referenced by osync_plugin_new_info().

OSyncPluginInfo* osync_plugin_new_info ( OSyncEnv *  env)

Registers a new plugin.

This function creates a new OSyncPluginInfo object, that can be used to register a new plugin dynamically. This can be used by a module to register multiple plugins, instead of using get_info() function, that allows registering of only one plugin.

Definition at line 205 of file opensync_plugin.c.

void osync_plugin_free ( OSyncPlugin plugin)

Used to free a plugin.

Frees a plugin

Parameters
pluginPointer to the plugin

Definition at line 222 of file opensync_plugin.c.

Referenced by osync_env_finalize().

void* osync_plugin_get_function ( OSyncPlugin plugin,
const char *  name,
OSyncError **  error 
)

Used to look up a symbol on the plugin.

Looks up and returns a function

Parameters
pluginPointer to the plugin
nameThe name of the function to look up
errorPointer to a error struct
Returns
Pointer to the function

Definition at line 243 of file opensync_plugin.c.

Referenced by osync_member_call_plugin().

osync_bool osync_module_load ( OSyncEnv *  env,
const char *  path,
OSyncError **  error 
)

dlopen()s a format plugin

The get_info() function on the format plugin gets called

Parameters
envThe environment in which to open the plugin
pathWhere to find this plugin
errorPointer to a error struct
Returns
Pointer to the plugin on success, NULL otherwise

Definition at line 270 of file opensync_plugin.c.

Referenced by osync_module_load_dir().

void osync_module_unload ( OSyncEnv *  env,
GModule *  module 
)

Closes a module.

Parameters
envThe environment from which to remove the module
moduleThe module to unload

Definition at line 317 of file opensync_plugin.c.

Referenced by osync_env_finalize().

osync_bool osync_module_load_dir ( OSyncEnv *  env,
const char *  path,
osync_bool  must_exist,
OSyncError **  error 
)

Loads the modules from a given directory.

Loads all modules from a directory into a osync environment

Parameters
envPointer to a OSyncEnv environment
pathThe path where to look for plugins, NULL for the default sync module directory
must_existIf set to TRUE, this function will return an error if the directory does not exist
errorPointer to a error struct to return a error
Returns
TRUE on success, FALSE otherwise

Definition at line 336 of file opensync_plugin.c.

Referenced by osync_env_load_formats(), and osync_env_load_plugins().

const char* osync_plugin_get_name ( OSyncPlugin plugin)

Returns the name of the loaded plugin.

Parameters
pluginPointer to the plugin
Returns
Name of the plugin

Definition at line 397 of file opensync_plugin.c.

Referenced by osync_member_instance_plugin(), and osync_member_save().

const char* osync_plugin_get_longname ( OSyncPlugin plugin)

Returns the long name of the loaded plugin.

Parameters
pluginPointer to the plugin
Returns
Long name of the plugin

Definition at line 409 of file opensync_plugin.c.

const char* osync_plugin_get_description ( OSyncPlugin plugin)

Returns the description of the plugin.

Parameters
pluginPointer to the plugin
Returns
Description of the plugin

Definition at line 421 of file opensync_plugin.c.

OSyncPluginTimeouts osync_plugin_get_timeouts ( OSyncPlugin plugin)

Returns the timeouts of the plugin.

Parameters
pluginPointer to the plugin
Returns
Timeouts of the plugin

Definition at line 433 of file opensync_plugin.c.

void* osync_plugin_get_plugin_data ( OSyncPlugin plugin)

Returns the plugin_info data, set by the plugin.

Parameters
pluginPointer to the plugin
Returns
The void pointer set on plugin->info.plugin_data

Definition at line 444 of file opensync_plugin.c.

Referenced by osync_member_get_plugindata().

const char* osync_plugin_get_path ( OSyncPlugin plugin)

Get full path for plugin module.

Parameters
pluginPointer to the plugin
Returns
full path of plugin module

Definition at line 455 of file opensync_plugin.c.

void osync_plugin_set_commit_objformat ( OSyncPluginInfo info,
const char *  objtypestr,
const char *  formatstr,
OSyncFormatCommitFn  commit_change 
)

Sets the commit function of a format.

Parameters
infoPointer to a plugin info struct to fill
objtypestrThe name of the object type
formatstrThe name of the format
commit_changeThe pointer to your commit_change function

Definition at line 469 of file opensync_plugin.c.

void osync_plugin_set_access_objformat ( OSyncPluginInfo info,
const char *  objtypestr,
const char *  formatstr,
OSyncFormatAccessFn  access 
)

Sets the access function of a format.

Parameters
infoPointer to a plugin info struct to fill
objtypestrThe name of the object type
formatstrThe name of the format
accessThe pointer to your access function

Definition at line 494 of file opensync_plugin.c.

void osync_plugin_set_read_objformat ( OSyncPluginInfo info,
const char *  objtypestr,
const char *  formatstr,
OSyncFormatReadFn  read 
)

Sets the read function of a format.

Parameters
infoPointer to a plugin info struct to fill
objtypestrThe name of the object type
formatstrThe name of the format
readThe pointer to your read function

Definition at line 519 of file opensync_plugin.c.

void osync_plugin_set_batch_commit_objformat ( OSyncPluginInfo info,
const char *  objtypestr,
const char *  formatstr,
OSyncFormatBatchCommitFn  batch 
)

Sets the batch_commit function of a format.

Parameters
infoPointer to a plugin info struct to fill
objtypestrThe name of the object type
formatstrThe name of the format
batchThe pointer to your batch_commit function

Definition at line 536 of file opensync_plugin.c.

void osync_plugin_set_committed_all_objformat ( OSyncPluginInfo info,
const char *  objtypestr,
const char *  formatstr,
OSyncFormatCommittedAllFn  committed_all 
)

Sets the committed_all function of a format.

Parameters
infoPointer to a plugin info struct to fill
objtypestrThe name of the object type
formatstrThe name of the format
committed_allThe pointer to your committed_all function

Definition at line 561 of file opensync_plugin.c.

void osync_plugin_accept_objtype ( OSyncPluginInfo info,
const char *  objtypestr 
)

Tells opensync that the plugin can accepts this object.

Tells opensync that the plugin can accepts this object. Used by the plugin in the get_info() function

Parameters
infoThe plugin info on which to operate
objtypestrThe name of the object which to accept

Definition at line 579 of file opensync_plugin.c.

void osync_plugin_accept_objformat ( OSyncPluginInfo info,
const char *  objtypestr,
const char *  formatstr,
const char *  extension 
)

Tells opensync that the plugin can accepts this format for the given object.

Tells opensync that the plugin can accepts this format. Used by the plugin in the get_info() function

Parameters
infoThe plugin info on which to operate
objtypestrThe name of the objecttype
formatstrThe name of the format to accept
extensionThe name of the extension that the plugin wants. NULL if none

Definition at line 597 of file opensync_plugin.c.