コード例 #1
0
END_TEST


START_TEST (detect_smart_no)
{
    OSyncError *error = NULL;

    OSyncFormatEnv *env = osync_format_env_new(&error);
    fail_unless(error == NULL);

    OSyncObjFormat *format1 = osync_objformat_new("Format1", "Type1", &error);
    OSyncObjFormat *format2 = osync_objformat_new("Format2", "Type1", &error);
    fail_unless(error == NULL);

    OSyncFormatConverter *conv = osync_converter_new_detector(format2, format1, detect_false, &error);
    fail_unless(error == NULL);

    osync_format_env_register_converter(env, conv, &error);

    mark_point();

    OSyncData *data = osync_data_new("test", 5, format2, &error);
    fail_unless(error == NULL);

    OSyncObjFormat *result = osync_format_env_detect_objformat(env, data);
    fail_unless(!result);
    fail_unless(osync_data_get_objformat(data) == format2);

    osync_data_unref(data);
    osync_format_env_unref(env);
}
コード例 #2
0
ファイル: mock_format.c プロジェクト: ianmartin/opensync
osync_bool get_format_info(OSyncFormatEnv *env, OSyncError **error)
{
    OSyncObjFormat *format = NULL;

    /* mockformat1 */
    format = osync_objformat_new("mockformat1", "mockobjtype1", error);
    osync_assert(format);

    _format_set_functions(format);

    osync_format_env_register_objformat(env, format);
    osync_objformat_unref(format);

    /* mockformat2 */
    format = osync_objformat_new("mockformat2", "mockobjtype2", error);
    osync_assert(format);

    _format_set_functions(format);

    osync_format_env_register_objformat(env, format);
    osync_objformat_unref(format);

    /* mockformat3 */
    format = osync_objformat_new("mockformat3", "mockobjtype3", error);
    osync_assert(format);

    _format_set_functions(format);

    osync_format_env_register_objformat(env, format);
    osync_objformat_unref(format);

    return TRUE;
}
コード例 #3
0
static osync_bool _inject_changelog_entries(OSyncObjEngine *engine, OSyncError **error) {
  OSyncList *ids = NULL;
  OSyncList *changetypes = NULL;
  OSyncList *j = NULL, *t = NULL;

  osync_trace(TRACE_ENTRY, "%s(%p)", __func__, engine);

  osync_assert(engine);
  osync_assert(engine->archive);
  osync_assert(engine->objtype);
	
  if (!osync_archive_load_ignored_conflicts(engine->archive, engine->objtype, &ids, &changetypes, error)) {
    osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error));
    return FALSE;
  }

  t = changetypes;
  for (j = ids; j; j = j->next) {
    long long int id = (long long int)GPOINTER_TO_INT(j->data);

    OSyncMapping *ignored_mapping = osync_mapping_table_find_mapping(engine->mapping_table, id);

    GList *e;
    for (e = engine->mapping_engines; e; e = e->next) {
      OSyncMappingEngine *mapping_engine = e->data;

      if (mapping_engine->mapping == ignored_mapping) {
        GList *m;
        for (m = mapping_engine->entries; m; m = m->next) {
          OSyncMappingEntryEngine *entry = m->data;
          OSyncChangeType changetype = (OSyncChangeType) t->data;
          OSyncChange *ignored_change = osync_change_new(error);
          OSyncObjFormat *dummyformat = NULL;
          OSyncData *data = NULL;

          osync_change_set_changetype(ignored_change, changetype); 
          osync_entry_engine_update(entry, ignored_change);

          dummyformat = osync_objformat_new("plain", engine->objtype, NULL);
          data = osync_data_new(NULL, 0, dummyformat, NULL);
          osync_change_set_data(ignored_change, data);
          osync_objformat_unref(dummyformat);

          osync_change_set_uid(ignored_change, osync_mapping_entry_get_uid(entry->entry));

          osync_trace(TRACE_INTERNAL, "CHANGE: %p", entry->change);
        }
        break;
      }
    }

    t = t->next;
  }

  osync_list_free(ids);
  osync_list_free(changetypes);

  osync_trace(TRACE_EXIT, "%s", __func__);
  return TRUE;
}
コード例 #4
0
ファイル: file.c プロジェクト: luizluca/opensync-file-sync
osync_bool get_format_info(OSyncFormatEnv *env, OSyncError **error)
{
	OSyncObjFormat *format = osync_objformat_new("file", "data", error);
	if (!format)
		goto error;

	osync_objformat_set_compare_func(format, compare_file);
	osync_objformat_set_destroy_func(format, destroy_file);
	osync_objformat_set_duplicate_func(format, duplicate_file);
	osync_objformat_set_print_func(format, print_file);
	osync_objformat_set_revision_func(format, revision_file);
	osync_objformat_set_copy_func(format, copy_file);

	osync_objformat_set_marshal_func(format, marshal_file);
	osync_objformat_set_demarshal_func(format, demarshal_file);

	if (!osync_format_env_register_objformat(env, format, error))
		goto error;

	osync_objformat_unref(format);
	return TRUE;

error:
	return FALSE;
}