static void open_cb (GObject *object, GAsyncResult *result, gpointer user_data) { GomRepository *repository; GomAdapter *adapter = (GomAdapter *)object; gboolean ret; GError *error = NULL; GList *object_types; ret = gom_adapter_open_finish(adapter, result, &error); g_assert_no_error(error); g_assert(ret); repository = gom_repository_new(adapter); /* This allows switching between automatic and manual DB upgrades */ #if 0 gom_repository_migrate_async(repository, 2, do_migrate, NULL, migrate_cb, user_data); #else object_types = g_list_prepend(NULL, GINT_TO_POINTER(BOOKMARKS_TYPE_RESOURCE)); gom_repository_automatic_migrate_async(repository, 2, object_types, migrate_cb, user_data); #endif g_object_unref(repository); }
/** * gom_repository_automatic_migrate_async: * @repository: (in): A #GomRepository. * @version: (in): The version to migrate to. * @object_types: (element-type GType) (transfer container): a #GList of #GType * @callback: (in): A callback to execute upon completion. * @user_data: (in): User data for @callback. * * Performs an automatic migration on the underlying database. See * gom_repository_automatic_migrate_sync() for details. * * Upon completion, @callback will be executed and it must call * gom_repository_automatic_migrate_finish(). */ void gom_repository_automatic_migrate_async (GomRepository *repository, guint version, GList *object_types, GAsyncReadyCallback callback, gpointer user_data) { g_return_if_fail(GOM_IS_REPOSITORY(repository)); g_return_if_fail(callback != NULL); g_return_if_fail(version >= 1); g_return_if_fail(object_types != NULL); g_object_set_data_full (G_OBJECT (repository), "object-types", object_types, (GDestroyNotify) g_list_free); gom_repository_migrate_async (repository, version, gom_repository_automatic_migrator, object_types, callback, user_data); }
static void open_cb (GObject *object, GAsyncResult *result, gpointer user_data) { GomRepository *repository; GomAdapter *adapter = (GomAdapter *)object; gboolean ret; GError *error = NULL; ret = gom_adapter_open_finish(adapter, result, &error); g_assert_no_error(error); g_assert(ret); repository = gom_repository_new(adapter); gom_repository_migrate_async(repository, 2, do_migrate, NULL, migrate_cb, user_data); g_object_unref(repository); }