OpenSync Groups
[OpenSync Public API]

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.
void osync_group_free (OSyncGroup *group)
 Frees the given group.
OSyncLockState osync_group_lock (OSyncGroup *group)
 Locks a group.
void osync_group_unlock (OSyncGroup *group, osync_bool remove)
 Unlocks a group.
void osync_group_set_name (OSyncGroup *group, const char *name)
 Sets the name for the group.
const char * osync_group_get_name (OSyncGroup *group)
 Returns the name of a group.
osync_bool osync_group_save (OSyncGroup *group, OSyncError **error)
 Saves the group to disc.
osync_bool osync_group_delete (OSyncGroup *group, OSyncError **error)
 Deletes a group from disc.
OSyncGrouposync_group_load (OSyncEnv *env, const char *path, OSyncError **error)
 Loads a group from a directory.
void osync_group_reset (OSyncGroup *group)
 Resets all databases of a group.
void osync_group_add_member (OSyncGroup *group, OSyncMember *member)
 Appends a member to the group.
void osync_group_remove_member (OSyncGroup *group, OSyncMember *member)
 Removes a member from the group.
OSyncMemberosync_group_nth_member (OSyncGroup *group, int nth)
 Returns the nth member of the group.
int osync_group_num_members (OSyncGroup *group)
 Counts the members of the group.
const char * osync_group_get_configdir (OSyncGroup *group)
 Returns the configdir for the group.
void osync_group_set_configdir (OSyncGroup *group, const char *directory)
 Sets the configdir of the group.
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.
void osync_group_reset_slow_sync (OSyncGroup *group, const char *objtypestr)
 Reset slow-sync for this group.
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.
osync_bool osync_group_objtype_enabled (OSyncGroup *group, const char *objtype)
 Returns if the object type is enabled for the group.
void osync_group_set_objtype_enabled (OSyncGroup *group, const char *objtypestr, osync_bool enabled)
 Sets if the object type is accepted for ALL members.
int osync_group_num_filters (OSyncGroup *group)
 Returns the number of filters registered in a group.
OSyncFilterosync_group_nth_filter (OSyncGroup *group, int nth)
 Gets the nth filter of a group.
void osync_group_flush_filters (OSyncGroup *group)
 Flushes the list of filters for a group.
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.
osync_bool osync_group_save_changelog (OSyncGroup *group, OSyncChange *change, OSyncError **error)
 Saves a change to the changelog.
osync_bool osync_group_remove_changelog (OSyncGroup *group, OSyncChange *change, OSyncError **error)
 Removes a change from the changelog.
void osync_group_set_last_synchronization (OSyncGroup *group, time_t last_sync)
 Sets the last synchronization date of this group.
time_t osync_group_get_last_synchronization (OSyncGroup *group)
 Gets the last synchronization date from this group.


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:
env The 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:
group The 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:
group The 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:
group The group
remove If 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:
group The group
name The 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:
group The group
Returns:
Name of the group

Definition at line 400 of file opensync_group.c.

osync_bool osync_group_save ( OSyncGroup group,
OSyncError **  error 
)

Saves the group to disc.

Saves the group to disc possibly creating the configdirectory

Parameters:
group The group
error Pointer 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:
group The group
error Pointer 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:
env The environment in which to create the group. Can be NULL
path The path to the config directory of the group
error Pointer 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:
group The 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:
group The group to which to append
member The 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:
group The group from which to remove
member The 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:
group The group
nth Which 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:
group The 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:
group The 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:
group The group
directory The 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:
group The group
objtypestr The name of the object type
slow_sync Set 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:
group The group to reset slow-sync on
objtypestr The name of the object type

Definition at line 809 of file opensync_group.c.

Referenced by osengine_reset().

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:
group The group
objtype The 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:
group The group
objtype The 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:
group The group
objtypestr The name of the object type
enabled What 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:
group The 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:
group The group
nth Which 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:
group The group for which to load the log
uids Place to return an array with the saved uids
objtype Place to return an array with the saved objtypes
memberids Place to return an array with the saved memberids
changetypes Place to return an array with the saved changetypes. Same size as uids
error Place 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:
group The group in which to save
change The change to save
error Place 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:
group The group in which to save
change The change to remove
error Place 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:
group The group in which to save
tm The 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:
group The group
Returns:
The synchronization info

Definition at line 1029 of file opensync_group.c.


Generated on Sun Jul 26 17:48:22 2009 for OpenSync by  doxygen 1.5.9