OSyncMappingTable *mappingtable_load(const char *path, const char *objtype, unsigned int num_mappings) { OSyncError *error = NULL; OSyncMappingTable *table = NULL; OSyncArchive *archive = NULL; osync_trace(TRACE_ENTRY, "%s(%s, %s, %i)", __func__, path, objtype, num_mappings); table = osync_mapping_table_new(&error); fail_unless(table != NULL, NULL); fail_unless(error == NULL, NULL); archive = osync_archive_new(path, &error); fail_unless(archive != NULL, NULL); fail_unless(error == NULL, NULL); fail_unless(osync_mapping_table_load(table, archive, objtype, &error), NULL); fail_unless(error == NULL, NULL); osync_archive_unref(archive); fail_unless(osync_mapping_table_num_mappings(table) == num_mappings, NULL); osync_trace(TRACE_EXIT, "%s: %p", __func__, table); return table; }
osync_bool osync_obj_engine_initialize(OSyncObjEngine *engine, OSyncError **error) { const char *objtype = NULL; int num = 0; int i = 0; osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, engine, error); osync_trace(TRACE_INTERNAL, "Loaded %i mappings", osync_mapping_table_num_mappings(engine->mapping_table)); objtype = osync_obj_engine_get_objtype(engine); num = osync_engine_num_proxies(engine->parent); for (i = 0; i < num; i++) { OSyncClientProxy *proxy = osync_engine_nth_proxy(engine->parent, i); OSyncObjTypeSink *sink = osync_client_proxy_find_objtype_sink(proxy, objtype); OSyncSinkEngine *sinkengine = NULL; if (!sink) { /* "data" sink engine counts also as valid. */ sink = osync_client_proxy_find_objtype_sink(proxy, "data"); if (!sink) continue; } sinkengine = osync_sink_engine_new(i, proxy, engine, error); if (!sinkengine) goto error; engine->sink_engines = g_list_append(engine->sink_engines, sinkengine); } if (engine->archive && engine->slowsync) { if (!osync_mapping_table_flush(engine->mapping_table, engine->archive, engine->objtype, error)) goto error; } if (engine->archive) { if (!osync_mapping_table_load(engine->mapping_table, engine->archive, engine->objtype, error)) goto error; } if (!_create_mapping_engines(engine, error)) goto error; osync_trace(TRACE_INTERNAL, "Created %i mapping engine", g_list_length(engine->mapping_engines)); if (engine->archive) { /* inject ignored conflicts from previous syncs */ if (!_inject_changelog_entries(engine, error)) goto error; } osync_trace(TRACE_EXIT, "%s", __func__); return TRUE; error: osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error)); return FALSE; }