OpenSync  0.22
Functions
OpenSync Member

Used to manipulate members, which represent one device or application in a group. More...

Functions

OSyncMemberosync_member_new (OSyncGroup *group)
 Creates a new member for a group. More...
 
void osync_member_free (OSyncMember *member)
 Frees a member. More...
 
void osync_member_unload_plugin (OSyncMember *member)
 Unloads the plugin of a member. More...
 
osync_bool osync_member_instance_plugin (OSyncMember *member, const char *pluginname, OSyncError **error)
 Instances a plugin and loads it if necessary. More...
 
osync_bool osync_member_instance_default_plugin (OSyncMember *member, OSyncError **error)
 Tries to instance the default plugin of a member (if set) More...
 
OSyncPluginosync_member_get_plugin (OSyncMember *member)
 Returns the plugin of member. More...
 
const char * osync_member_get_pluginname (OSyncMember *member)
 Returns the name of the default plugin of the member. More...
 
void osync_member_set_pluginname (OSyncMember *member, const char *pluginname)
 Sets the name of the default plugin of a member. More...
 
void * osync_member_get_plugindata (OSyncMember *member)
 Returns the custom data set to the OSyncPluginInfo. More...
 
const char * osync_member_get_configdir (OSyncMember *member)
 Returns the configuration directory where this member is stored. More...
 
void osync_member_set_configdir (OSyncMember *member, const char *configdir)
 Sets the directory where a member is supposed to be stored. More...
 
osync_bool osync_member_need_config (OSyncMember *member, OSyncConfigurationTypes *type, OSyncError **error)
 
osync_bool osync_member_get_config_or_default (OSyncMember *member, char **data, int *size, OSyncError **error)
 Gets the configuration data of this member. More...
 
osync_bool osync_member_get_config (OSyncMember *member, char **data, int *size, OSyncError **error)
 Gets the configuration data of this member. More...
 
void osync_member_set_config (OSyncMember *member, const char *data, int size)
 Sets the config data for a member. More...
 
void * osync_member_get_loop (OSyncMember *member)
 Gets the loop in which the member is dispatched. More...
 
void osync_member_set_loop (OSyncMember *member, void *loop)
 Sets the loop in which the member is dispatched. More...
 
osync_bool osync_member_has_configuration (OSyncMember *member)
 Returns if the member has configuation options. More...
 
OSyncMemberosync_member_load (OSyncGroup *group, const char *path, OSyncError **error)
 Loads a member from a directory where it has been saved. More...
 
osync_bool osync_member_save (OSyncMember *member, OSyncError **error)
 Saves a member to it config directory. More...
 
long long int osync_member_get_id (OSyncMember *member)
 Gets the unique id of a member. More...
 
void * osync_member_call_plugin (OSyncMember *member, const char *function, void *data, OSyncError **error)
 Makes a custom call to the plugin that the member has instanced. More...
 
void osync_member_set_slow_sync (OSyncMember *member, const char *objtypestr, osync_bool slow_sync)
 Sets the slow-sync for a given object type on a member. More...
 
osync_bool osync_member_get_slow_sync (OSyncMember *member, const char *objtypestr)
 Returns if slow-sync has been set for a object type. More...
 
void osync_member_request_synchronization (OSyncMember *member)
 Requests synchronization from the sync engine. More...
 
OSyncObjFormatSink * osync_member_make_random_data (OSyncMember *member, OSyncChange *change, const char *objtypename)
 Makes random data of a object type that could be writen to the given member. More...
 
void * osync_member_get_data (OSyncMember *member)
 Returns the custom data of a member. More...
 
void osync_member_set_data (OSyncMember *member, void *data)
 Sets the custom data on a member. More...
 
OSyncGrouposync_member_get_group (OSyncMember *member)
 Gets the group in which the member is stored. More...
 
OSyncMemberosync_member_from_id (OSyncGroup *group, int id)
 Searches for a member by its id. More...
 
osync_bool osync_member_objtype_enabled (OSyncMember *member, const char *objtype)
 Returns if a certain object type is enabled on this member. More...
 
void osync_member_set_objtype_enabled (OSyncMember *member, const char *objtypestr, osync_bool enabled)
 Enables or disables a object type on a member. More...
 

Detailed Description

Used to manipulate members, which represent one device or application in a group.

Function Documentation

OSyncMember* osync_member_new ( OSyncGroup group)

Creates a new member for a group.

Parameters
groupThe parent group. NULL if none
Returns
A newly allocated member

Definition at line 170 of file opensync_member.c.

Referenced by osync_member_load().

void osync_member_free ( OSyncMember member)

Frees a member.

Parameters
memberThe member to free

Definition at line 189 of file opensync_member.c.

Referenced by osync_group_free(), and osync_member_load().

void osync_member_unload_plugin ( OSyncMember member)

Unloads the plugin of a member.

Parameters
memberThe member for which to unload the plugin

Definition at line 214 of file opensync_member.c.

Referenced by osync_member_instance_plugin().

osync_bool osync_member_instance_plugin ( OSyncMember member,
const char *  pluginname,
OSyncError **  error 
)

Instances a plugin and loads it if necessary.

Parameters
memberThe member
pluginnameThe name of the plugin that the member should use
errorPointer to a error
Returns
TRUE if the plugin was instanced successfull, FALSE otherwise

Definition at line 242 of file opensync_member.c.

Referenced by osync_member_instance_default_plugin().

osync_bool osync_member_instance_default_plugin ( OSyncMember member,
OSyncError **  error 
)

Tries to instance the default plugin of a member (if set)

Parameters
memberThe member
errorPointer to a error
Returns
TRUE if the default plugin was instanced successfully, FALSE otherwise

Definition at line 305 of file opensync_member.c.

Referenced by osync_member_call_plugin(), osync_member_get_config(), osync_member_get_plugin(), osync_member_initialize(), and osync_member_save().

OSyncPlugin* osync_member_get_plugin ( OSyncMember member)

Returns the plugin of member.

Parameters
memberThe member
Returns
The plugin of the member

Definition at line 324 of file opensync_member.c.

Referenced by osync_member_get_plugindata().

const char* osync_member_get_pluginname ( OSyncMember member)

Returns the name of the default plugin of the member.

Parameters
memberThe member
Returns
The name of the plugin

Definition at line 337 of file opensync_member.c.

void osync_member_set_pluginname ( OSyncMember member,
const char *  pluginname 
)

Sets the name of the default plugin of a member.

Parameters
memberThe member
pluginnameThe name of the default plugin

Definition at line 349 of file opensync_member.c.

void* osync_member_get_plugindata ( OSyncMember member)

Returns the custom data set to the OSyncPluginInfo.

You can set custom data to the OSyncPluginInfo struct using info->plugin_data = something; you can then query this data later using this function.

Parameters
memberThe member
Returns
The plugin data set before, or NULL if none was set

Definition at line 367 of file opensync_member.c.

const char* osync_member_get_configdir ( OSyncMember member)

Returns the configuration directory where this member is stored.

Parameters
memberThe member
Returns
The configuration directory

Definition at line 380 of file opensync_member.c.

void osync_member_set_configdir ( OSyncMember member,
const char *  configdir 
)

Sets the directory where a member is supposed to be stored.

Parameters
memberThe member
configdirThe name of the directory

Definition at line 392 of file opensync_member.c.

osync_bool osync_member_get_config_or_default ( OSyncMember member,
char **  data,
int *  size,
OSyncError **  error 
)

Gets the configuration data of this member.

The config file is read in this order:

  • If there is a configuration in memory that is not yet saved this is returned
  • If there is a config file in the member directory this is read and returned
  • Otherwise the default config file is loaded from one the opensync directories
Parameters
memberThe member
dataReturn location for the data
sizeReturn location for the size of the data
errorPointer to a error
Returns
TRUE if the config was loaded successfully, FALSE otherwise

Definition at line 437 of file opensync_member.c.

osync_bool osync_member_get_config ( OSyncMember member,
char **  data,
int *  size,
OSyncError **  error 
)

Gets the configuration data of this member.

The config file is read in this order:

  • If there is a configuration in memory that is not yet saved this is returned
  • If there is a config file in the member directory this is read and returned
  • Otherwise the default config file is loaded from one the opensync directories (but only if the plugin specified that it can use the default configuration)
Parameters
memberThe member
dataReturn location for the data
sizeReturn location for the size of the data
errorPointer to a error
Returns
TRUE if the config was loaded successfully, FALSE otherwise

Definition at line 483 of file opensync_member.c.

void osync_member_set_config ( OSyncMember member,
const char *  data,
int  size 
)

Sets the config data for a member.

Note that this does not save the config data

Parameters
memberThe member
dataThe new config data
sizeThe size of the data

Definition at line 538 of file opensync_member.c.

void* osync_member_get_loop ( OSyncMember member)

Gets the loop in which the member is dispatched.

Parameters
memberThe member
Returns
The loop

Definition at line 555 of file opensync_member.c.

void osync_member_set_loop ( OSyncMember member,
void *  loop 
)

Sets the loop in which the member is dispatched.

Parameters
memberThe member
loopThe pointer to the loop

Definition at line 568 of file opensync_member.c.

osync_bool osync_member_has_configuration ( OSyncMember member)

Returns if the member has configuation options.

Parameters
memberThe member
Returns
TRUE if member needs to be configured, FALSE otherwise

Definition at line 582 of file opensync_member.c.

OSyncMember* osync_member_load ( OSyncGroup group,
const char *  path,
OSyncError **  error 
)

Loads a member from a directory where it has been saved.

Parameters
groupThe group which is the parent
pathThe path of the member
errorPointer to a error
Returns
A newly allocated member thats stored in the group or NULL if error

Definition at line 601 of file opensync_member.c.

Referenced by osync_group_load_members().

osync_bool osync_member_save ( OSyncMember member,
OSyncError **  error 
)

Saves a member to it config directory.

Parameters
memberThe member to save
errorPointer to a error
Returns
TRUE if the member was saved successfully, FALSE otherwise

Definition at line 647 of file opensync_member.c.

Referenced by osync_group_save().

long long int osync_member_get_id ( OSyncMember member)

Gets the unique id of a member.

Parameters
memberThe member
Returns
The id of the member thats unique in its group

Definition at line 714 of file opensync_member.c.

Referenced by _new_change_receiver().

void* osync_member_call_plugin ( OSyncMember member,
const char *  function,
void *  data,
OSyncError **  error 
)

Makes a custom call to the plugin that the member has instanced.

A custom function on the plugin must have the form (void *, void *, OSyncError **)

Parameters
memberThe member
functionThe name of the function on the plugin to call
dataThe custom data to pass as the second arg to the function on the plugin
errorA pointer to a error
Returns
The return value of the function call

Definition at line 731 of file opensync_member.c.

void osync_member_set_slow_sync ( OSyncMember member,
const char *  objtypestr,
osync_bool  slow_sync 
)

Sets the slow-sync for a given object type on a member.

Parameters
memberThe member
objtypestrThe name of the object type for which to set slow-sync
slow_syncSet to TRUE if you want slow-sync, to FALSE if you want normal fast-sync (or remove slow-sync)

Definition at line 749 of file opensync_member.c.

Referenced by osync_member_sync_done().

osync_bool osync_member_get_slow_sync ( OSyncMember member,
const char *  objtypestr 
)

Returns if slow-sync has been set for a object type.

Parameters
memberThe member
objtypestrThe name of the object type to look up
Returns
TRUE if slow-sync is enabled, FALSE otherwise

Definition at line 765 of file opensync_member.c.

void osync_member_request_synchronization ( OSyncMember member)

Requests synchronization from the sync engine.

Parameters
memberThe member

Definition at line 783 of file opensync_member.c.

OSyncObjFormatSink* osync_member_make_random_data ( OSyncMember member,
OSyncChange change,
const char *  objtypename 
)

Makes random data of a object type that could be writen to the given member.

Parameters
memberThe member
changeThe change that will receive the random data
objtypenameThe name of the object type for which to create random data
Returns
The sink of the member that could store this data

Definition at line 806 of file opensync_member.c.

Referenced by osync_member_add_random_data(), and osync_member_modify_random_data().

void* osync_member_get_data ( OSyncMember member)

Returns the custom data of a member.

Parameters
memberThe member
Returns
The custom data

Definition at line 875 of file opensync_member.c.

void osync_member_set_data ( OSyncMember member,
void *  data 
)

Sets the custom data on a member.

Parameters
memberThe member
dataThe custom data

Definition at line 887 of file opensync_member.c.

OSyncGroup* osync_member_get_group ( OSyncMember member)

Gets the group in which the member is stored.

Parameters
memberThe member
Returns
The parental group

Definition at line 899 of file opensync_member.c.

Referenced by osync_member_get_slow_sync(), and osync_member_set_slow_sync().

OSyncMember* osync_member_from_id ( OSyncGroup group,
int  id 
)

Searches for a member by its id.

Parameters
groupThe group in which to search
idThe id of the member
Returns
The member, or NULL if not found

Definition at line 912 of file opensync_member.c.

osync_bool osync_member_objtype_enabled ( OSyncMember member,
const char *  objtype 
)

Returns if a certain object type is enabled on this member.

Parameters
memberThe member
objtypeThe name of the object type to check
Returns
TRUE if the object type is enabled, FALSE otherwise

Definition at line 935 of file opensync_member.c.

Referenced by osync_group_objtype_enabled().

void osync_member_set_objtype_enabled ( OSyncMember member,
const char *  objtypestr,
osync_bool  enabled 
)

Enables or disables a object type on a member.

Parameters
memberThe member
objtypestrThe name of the object type to change
enabledSet to TRUE if you want to sync the object type, FALSE otherwise

Note: this function should be called only after sink information for the member is available (osync_member_require_sink_info())

Todo:
Change function interface to not require the plugin to be instanced manually. See comments on osync_group_set_objtype_enabled()

Definition at line 955 of file opensync_member.c.

Referenced by osync_group_set_objtype_enabled().