Пример #1
0
static void dump_map_objtype(OSyncGroupEnv *env, const char *objtype, const char *groupname)
{
	printf("Dumping of mappings got temporarliy disabled\n");

/* FIXME: Temporarily disabled - OSyncArchive got removed from 0.40 API draft */
#if 0	

	OSyncError *error = NULL;
	OSyncGroup *group = osync_group_env_find_group(env, groupname);

	char *path = g_strdup_printf("%s/archive.db", osync_group_get_configdir(group));
	OSyncArchive *archive = osync_archive_new(path, &error);
	OSyncList *ids = NULL;
	OSyncList *uids = NULL;
	OSyncList *mappingids = NULL;
	OSyncList *memberids = NULL;
	OSyncList *d , *u, *m, *i;

	if (!archive)
		goto error;
	g_free(path);
	
	if (!osync_archive_load_changes(archive, objtype, &ids, &uids, &mappingids, &memberids, &error))
		goto error;
	
	d = ids;
	u = uids;
	m = mappingids;
	i = memberids;
	
	for (; u; u = u->next) {
		long long int id = (long long int)GPOINTER_TO_INT(d->data);
		char *uid = u->data;
		long long int memberid = (long long int)GPOINTER_TO_INT(i->data);
		long long int mappingid = (long long int)GPOINTER_TO_INT(m->data);
		
		printf("ID: %lli UID: %s MEMBER: %lli MAPPINGID: %lli\n", id, uid, memberid, mappingid);
		
		m = m->next;
		d = d->next;
		i = i->next;
	}
	
	osync_list_free(ids);
	osync_list_free(uids);
	osync_list_free(mappingids);
	osync_list_free(memberids);
	
	osync_archive_unref(archive);
	return;

 error:
	printf("ERROR: %s", osync_error_print(&error));
	osync_error_unref(&error);
#endif	
}
Пример #2
0
static void reset(OSyncGroupEnv *osync, char *groupname)
{
	OSyncGroup *group = osync_group_env_find_group(osync, groupname);
	
	if (!group) {
		printf("Unable to find group with name \"%s\"\n", groupname);
		return;
	}
	
	osync_group_reset(group, NULL);
}
Пример #3
0
static void dump_hash(OSyncGroupEnv *env, const char *objtype, const char *groupname, char *memberid)
{
	OSyncGroup *group = osync_group_env_find_group(env, groupname);
#if 0 /* Unused */	
	OSyncError *error = NULL;
	long long int id = 0;
	OSyncMember *member = NULL;
	char *path = NULL;
	OSyncHashTable *table = NULL;
#endif	
	
	if (!group) {
		printf("Unable to find group with name \"%s\"\n", groupname);
		return;
	}

	printf("Dumping hashtable is currently not implemented!\n");
	
	return;

/* FIXME: public interface osync_hashltable_new() is gone!
 * no interface to access the disk directly!
 * */
#if 0	
	id = atoi(memberid);
	member = osync_group_find_member(group, id);
	if (!member) {
		printf("Unable to find member with id %s\n", memberid);
		return;
	}
	
	path = g_strdup_printf("%s/hashtable.db", osync_member_get_configdir(member));
	table = osync_hashtable_new(path, objtype, &error);
	if (!table)
		goto error;
	g_free(path);

	if (!osync_hashtable_load(table, &error))
		goto error;
	
	osync_hashtable_foreach(table, print_hashtable, NULL);

	osync_hashtable_unref(table);

 error:
	printf("ERROR: %s", osync_error_print(&error));
	osync_error_unref(&error);

#endif	
}
Пример #4
0
static void dump_hash(OSyncGroupEnv *env, const char *objtype, const char *groupname, char *memberid)
{
  OSyncError *error = NULL;
  OSyncGroup *group = osync_group_env_find_group(env, groupname);
  long long int id = 0;
  OSyncMember *member = NULL;
  char *path = NULL;
  OSyncHashTable *table = NULL;

	
  if (!group) {
    printf("Unable to find group with name \"%s\"\n", groupname);
    return;
  }
	
  id = atoi(memberid);
  member = osync_group_find_member(group, id);
  if (!member) {
    printf("Unable to find member with id %s\n", memberid);
    return;
  }
	
  path = g_strdup_printf("%s/hashtable.db", osync_member_get_configdir(member));
  table = osync_hashtable_new(path, objtype, &error);
  if (!table)
    goto error;
  g_free(path);
	
  osync_hashtable_foreach(table, print_hashtable, NULL);

  osync_hashtable_unref(table);
	
  return;

 error:
  printf("ERROR: %s", osync_error_print(&error));
  osync_error_unref(&error);
}
Пример #5
0
static void dump_map(OSyncGroupEnv *env, const char *groupname)
{

  OSyncGroup *group = osync_group_env_find_group(env, groupname);
  int i, num_objtypes;
	
  if (!group) {
    printf("Unable to find group with name \"%s\"\n", groupname);
    return;
  }

  num_objtypes = osync_group_num_objtypes(group); 
  if (num_objtypes == 0) { 
    printf("Group has no objtypes. Have the objtypes already been discovered?\n"); 
    return;
  }

  for (i = 0; i < num_objtypes; i++) {
    const char *objtype = osync_group_nth_objtype(group, i);
    printf("Mappings for objtype \"%s\":\n", objtype);
    dump_map_objtype(env, objtype, groupname);
  }

}