static void test_tracker_sparql_update_async () { guint i; GMainLoop *main_loop; AsyncData *data; main_loop = g_main_loop_new (NULL, FALSE); data = g_slice_new (AsyncData); data->len = MSIZE; data->main_loop = main_loop; data->cur = 0; for (i = 0; i < data->len; i++) { tracker_sparql_connection_update_async (connection, queries[i], 0, NULL, async_update_callback, data); } g_main_loop_run (main_loop); g_slice_free (AsyncData, data); g_main_loop_unref (main_loop); }
static void model_item_changed (GtkTreeModel *tree_model, GtkTreePath *path, GtkTreeIter *iter, ReaderEngine *engine) { int read; gchar *query; ReaderEnginePrivate *priv; ItemStatusUpdate *update; if (gtk_tree_path_get_depth (path) == 1) return; update = g_new0 (ItemStatusUpdate, 1); gtk_tree_model_get (tree_model, iter, ITEM_COLUMN_ID, &(update->id), ITEM_COLUMN_READ, &read, -1); update->read = (read == READ_FONT_WEIGHT ? TRUE : FALSE); priv = reader_engine_get_instance_private (engine); query = g_strdup_printf ("DELETE {<%s> nmo:isRead %s}", update->id, update->read ? "false" : "true"); tracker_sparql_connection_update_async (priv->tracker, query, 0, NULL, (GAsyncReadyCallback) set_new_read_status, update); g_free (query); }
static void set_new_read_status (GObject *source, GAsyncResult *res, ItemStatusUpdate *update) { gchar *query; GError *error = NULL; tracker_sparql_connection_query_finish (TRACKER_SPARQL_CONNECTION (source), res, &error); if (error != NULL) { g_warning ("Unable to update status of item in Tracker: %s", error->message); g_error_free (error); } else { query = g_strdup_printf ("INSERT {<%s> nmo:isRead %s}", update->id, update->read ? "true" : "false"); tracker_sparql_connection_update_async (TRACKER_SPARQL_CONNECTION (source), query, 0, NULL, (GAsyncReadyCallback) verify_tracker_update, NULL); g_free (query); } g_free (update->id); g_free (update); }