OpenSync  0.22
Enumerations | Functions

A groups represent several device or application that should be synchronized. More...

Enumerations

enum  OSyncLockState { OSYNC_LOCK_OK, OSYNC_LOCKED, OSYNC_LOCK_STALE }
 The lock state of a group.
 

Functions

OSyncGrouposync_group_new (OSyncEnv *env)
 Creates a new group for the given environment. More...
 
void osync_group_free (OSyncGroup *group)
 Frees the given group. More...
 
OSyncLockState osync_group_lock (OSyncGroup *group)
 Locks a group. More...
 
void osync_group_unlock (OSyncGroup *group, osync_bool remove)
 Unlocks a group. More...
 
void osync_group_set_name (OSyncGroup *group, const char *name)
 Sets the name for the group. More...
 
const char * osync_group_get_name (OSyncGroup *group)
 Returns the name of a group. More...
 
osync_bool osync_group_save (OSyncGroup *group, OSyncError **error)
 Saves the group to disc. More...
 
osync_bool osync_group_delete (OSyncGroup *group, OSyncError **error)
 Deletes a group from disc. More...
 
OSyncGrouposync_group_load (OSyncEnv *env, const char *path, OSyncError **error)
 Loads a group from a directory. More...
 
void osync_group_reset (OSyncGroup *group)
 Resets all databases of a group. More...
 
void osync_group_add_member (OSyncGroup *group, OSyncMember *member)
 Appends a member to the group. More...
 
void osync_group_remove_member (OSyncGroup *group, OSyncMember *member)
 Removes a member from the group. More...
 
OSyncMemberosync_group_nth_member (OSyncGroup *group, int nth)
 Returns the nth member of the group. More...
 
int osync_group_num_members (OSyncGroup *group)
 Counts the members of the group. More...
 
const char * osync_group_get_configdir (OSyncGroup *group)
 Returns the configdir for the group. More...
 
void osync_group_set_configdir (OSyncGroup *group, const char *directory)
 Sets the configdir of the group. More...
 
void osync_group_set_slow_sync (OSyncGroup *group, const char *objtypestr, osync_bool slow_sync)
 Sets if the group requires slow-sync for the given object type. More...
 
void osync_group_reset_slow_sync (OSyncGroup *group, const char *objtypestr)
 Reset slow-sync for this group. More...
 
osync_bool osync_group_get_slow_sync (OSyncGroup *group, const char *objtype)
 Returns if the group will perform a slow-sync for the object type. More...
 
osync_bool osync_group_objtype_enabled (OSyncGroup *group, const char *objtype)
 Returns if the object type is enabled for the group. More...
 
void osync_group_set_objtype_enabled (OSyncGroup *group, const char *objtypestr, osync_bool enabled)
 Sets if the object type is accepted for ALL members. More...
 
int osync_group_num_filters (OSyncGroup *group)
 Returns the number of filters registered in a group. More...
 
OSyncFilterosync_group_nth_filter (OSyncGroup *group, int nth)
 Gets the nth filter of a group. More...
 
void osync_group_flush_filters (OSyncGroup *group)
 Flushes the list of filters for a group. More...
 
osync_bool osync_group_open_changelog (OSyncGroup *group, char ***uids, char ***objtype, long long int **memberids, int **changetypes, OSyncError **error)
 Can be used to load all items from the changelog. Loaded items will be removed. More...
 
osync_bool osync_group_save_changelog (OSyncGroup *group, OSyncChange *change, OSyncError **error)
 Saves a change to the changelog. More...
 
osync_bool osync_group_remove_changelog (OSyncGroup *group, OSyncChange *change, OSyncError **error)
 Removes a change from the changelog. More...
 
void osync_group_set_last_synchronization (OSyncGroup *group, time_t last_sync)
 Sets the last synchronization date of this group. More...
 
time_t osync_group_get_last_synchronization (OSyncGroup *group)
 Gets the last synchronization date from this group. More...
 

Detailed Description

A groups represent several device or application that should be synchronized.

Function Documentation

OSyncGroup* osync_group_new ( OSyncEnv *  env)

Creates a new group for the given environment.

Creates a newly allocated group

Parameters
envThe environment for which to create the group. Might be NULL if you which to not add the group at the point of creation
Returns
Pointer to a new group

Definition at line 204 of file opensync_group.c.

Referenced by osync_group_load().

void osync_group_free ( OSyncGroup group)

Frees the given group.

Frees the given group

Parameters
groupThe group

Definition at line 224 of file opensync_group.c.

Referenced by osync_env_finalize(), osync_group_delete(), and osync_group_load().

OSyncLockState osync_group_lock ( OSyncGroup group)

Locks a group.

Tries to acquire a lock for the given group.

If the lock was successfully acquired, OSYNC_LOCK_OK will be returned.

If the lock was acquired, but a old lock file was detected, OSYNC_LOCK_STALE will be returned. Use this to detect if the last sync of this group was successfull, or if this something crashed. If you get this answer you should perform a slow-sync

If the group is locked, OSYNC_LOCKED is returned

Parameters
groupThe group
Returns
if the lockfile was acquired

Definition at line 267 of file opensync_group.c.

Referenced by osengine_init().

void osync_group_unlock ( OSyncGroup group,
osync_bool  remove 
)

Unlocks a group.

if you set remove = FALSE, the lock file will not be removed and the next call to osync_lock_group() for this group will return OSYNC_LOCK_STALE.

Parameters
groupThe group
removeIf the lockfile should be removed

Definition at line 348 of file opensync_group.c.

Referenced by osengine_finalize(), osengine_init(), and osync_group_free().

void osync_group_set_name ( OSyncGroup group,
const char *  name 
)

Sets the name for the group.

Sets the name for a group

Parameters
groupThe group
nameThe name to set

Definition at line 384 of file opensync_group.c.

const char* osync_group_get_name ( OSyncGroup group)

Returns the name of a group.

Returns the name of a group

Parameters
groupThe group
Returns
Name of the group

Definition at line 400 of file opensync_group.c.

Referenced by _new_change_receiver().

osync_bool osync_group_save ( OSyncGroup group,
OSyncError **  error 
)

Saves the group to disc.

Saves the group to disc possibly creating the configdirectory

Parameters
groupThe group
errorPointer to a error struct
Returns
TRUE on success, FALSE otherwise

Definition at line 415 of file opensync_group.c.

osync_bool osync_group_delete ( OSyncGroup group,
OSyncError **  error 
)

Deletes a group from disc.

Deletes to group directories and removes it from its environment

Parameters
groupThe group
errorPointer to a error struct
Returns
TRUE on success, FALSE otherwise

Definition at line 512 of file opensync_group.c.

OSyncGroup* osync_group_load ( OSyncEnv *  env,
const char *  path,
OSyncError **  error 
)

Loads a group from a directory.

Loads a group from a directory

Parameters
envThe environment in which to create the group. Can be NULL
pathThe path to the config directory of the group
errorPointer to a error struct
Returns
Pointer to the loaded group

Definition at line 536 of file opensync_group.c.

Referenced by osync_env_load_groups().

void osync_group_reset ( OSyncGroup group)

Resets all databases of a group.

This will reset all databases of a group. So all anchors, mappings hashtables etc will be forgotten (as if the group was never synced)

Parameters
groupThe group to reset

Definition at line 667 of file opensync_group.c.

void osync_group_add_member ( OSyncGroup group,
OSyncMember member 
)

Appends a member to the group.

Appends a member to the group

Parameters
groupThe group to which to append
memberThe member to append

Definition at line 687 of file opensync_group.c.

Referenced by osync_member_new().

void osync_group_remove_member ( OSyncGroup group,
OSyncMember member 
)

Removes a member from the group.

Parameters
groupThe group from which to remove
memberThe member to remove

Definition at line 699 of file opensync_group.c.

Referenced by osync_member_free().

OSyncMember* osync_group_nth_member ( OSyncGroup group,
int  nth 
)

Returns the nth member of the group.

Returns a pointer to the nth member of the group

Parameters
groupThe group
nthWhich member to return
Returns
Pointer to the member

Definition at line 714 of file opensync_group.c.

Referenced by osengine_new(), osync_group_free(), osync_group_save(), and osync_member_from_id().

int osync_group_num_members ( OSyncGroup group)

Counts the members of the group.

Returns the number of members in the group

Parameters
groupThe group
Returns
Number of members

Definition at line 728 of file opensync_group.c.

Referenced by osengine_init(), osengine_new(), osync_group_save(), and osync_member_from_id().

const char* osync_group_get_configdir ( OSyncGroup group)

Returns the configdir for the group.

Returns the configdir for the group

Parameters
groupThe group
Returns
String with the path of the config directory

Definition at line 742 of file opensync_group.c.

Referenced by osync_group_load_members().

void osync_group_set_configdir ( OSyncGroup group,
const char *  directory 
)

Sets the configdir of the group.

Parameters
groupThe group
directoryThe new configdir
Returns
String with the path of the config directory

Definition at line 755 of file opensync_group.c.

void osync_group_set_slow_sync ( OSyncGroup group,
const char *  objtypestr,
osync_bool  slow_sync 
)

Sets if the group requires slow-sync for the given object type.

Sets if the group requires slow-sync for the given object type. This will be reset once the group performs a successfull slow-sync.

Parameters
groupThe group
objtypestrThe name of the object type
slow_syncSet to TRUE if you want to perform a slow-sync, FALSE otherwise

Definition at line 773 of file opensync_group.c.

Referenced by osengine_init(), osengine_reset(), and osync_member_set_slow_sync().

void osync_group_reset_slow_sync ( OSyncGroup group,
const char *  objtypestr 
)

Reset slow-sync for this group.

You can use this function to reset the slow-sync status for the given group. This is normally done if a synchronization succeeds.

Parameters
groupThe group to reset slow-sync on
objtypestrThe name of the object type

Definition at line 809 of file opensync_group.c.

Referenced by osengine_reset(), and osync_member_delete_data().

osync_bool osync_group_get_slow_sync ( OSyncGroup group,
const char *  objtype 
)

Returns if the group will perform a slow-sync for the object type.

Returns if the group will perform a slow-sync for the object type

Parameters
groupThe group
objtypeThe name of the object type
Returns
TRUE if a slow-sync will be performed, FALSE otherwise

Definition at line 839 of file opensync_group.c.

Referenced by _new_change_receiver(), osengine_synchronize(), osync_group_set_slow_sync(), and osync_member_get_slow_sync().

osync_bool osync_group_objtype_enabled ( OSyncGroup group,
const char *  objtype 
)

Returns if the object type is enabled for the group.

Returns TRUE if the object type is enabled for the group. Note that this information is saved on a per member basis. If one of the members has this object type enabled this function will return TRUE

Parameters
groupThe group
objtypeThe name of the object type
Returns
TRUE if the object type is enabled for at least one member. FALSE if for none

Definition at line 870 of file opensync_group.c.

void osync_group_set_objtype_enabled ( OSyncGroup group,
const char *  objtypestr,
osync_bool  enabled 
)

Sets if the object type is accepted for ALL members.

BUG We loose information if only some members are enabled

Parameters
groupThe group
objtypestrThe name of the object type
enabledWhat do you want to set today?

Note: the plugin needs to be instanced for this function to be called

Todo:
Change interface to remove requirement to instance the plugin manually. It needs to be able to return error in order to load the plugin

Definition at line 899 of file opensync_group.c.

int osync_group_num_filters ( OSyncGroup group)

Returns the number of filters registered in a group.

Parameters
groupThe group
Returns
The number of filters

Definition at line 928 of file opensync_group.c.

OSyncFilter* osync_group_nth_filter ( OSyncGroup group,
int  nth 
)

Gets the nth filter of a group.

Note that you should not add or delete filters while iterating over them

Parameters
groupThe group
nthWhich filter to return
Returns
The filter or NULL if not found

Definition at line 944 of file opensync_group.c.

void osync_group_flush_filters ( OSyncGroup group)

Flushes the list of filters for a group.

Clean the list of filters on the group

Definition at line 954 of file opensync_group.c.

osync_bool osync_group_open_changelog ( OSyncGroup group,
char ***  uids,
char ***  objtype,
long long int **  memberids,
int **  changetypes,
OSyncError **  error 
)

Can be used to load all items from the changelog. Loaded items will be removed.

Parameters
groupThe group for which to load the log
uidsPlace to return an array with the saved uids
objtypePlace to return an array with the saved objtypes
memberidsPlace to return an array with the saved memberids
changetypesPlace to return an array with the saved changetypes. Same size as uids
errorPlace to return the error
Returns
TRUE if successfull, FALSE otherwise

Definition at line 976 of file opensync_group.c.

osync_bool osync_group_save_changelog ( OSyncGroup group,
OSyncChange change,
OSyncError **  error 
)

Saves a change to the changelog.

Parameters
groupThe group in which to save
changeThe change to save
errorPlace to return the error
Returns
TRUE if successfull, FALSE otherwise

Definition at line 988 of file opensync_group.c.

Referenced by osengine_mapping_ignore_conflict().

osync_bool osync_group_remove_changelog ( OSyncGroup group,
OSyncChange change,
OSyncError **  error 
)

Removes a change from the changelog.

Parameters
groupThe group in which to save
changeThe change to remove
errorPlace to return the error
Returns
TRUE if successfull, FALSE otherwise

Definition at line 1000 of file opensync_group.c.

Referenced by _new_change_receiver().

void osync_group_set_last_synchronization ( OSyncGroup group,
time_t  last_sync 
)

Sets the last synchronization date of this group.

The information will be stored on disc after osync_group_save()

Parameters
groupThe group in which to save
tmThe time info to set

Definition at line 1012 of file opensync_group.c.

time_t osync_group_get_last_synchronization ( OSyncGroup group)

Gets the last synchronization date from this group.

The information will available on the group after osync_group_load()

Parameters
groupThe group
Returns
The synchronization info

Definition at line 1029 of file opensync_group.c.