static void cursor_callback (GObject *object, GAsyncResult *result, gpointer user_data) { GtkSearchEngineTracker *tracker; GError *error = NULL; TrackerSparqlCursor *cursor; GList *hits; gboolean success; gdk_threads_enter (); tracker = GTK_SEARCH_ENGINE_TRACKER (user_data); cursor = TRACKER_SPARQL_CURSOR (object); success = tracker_sparql_cursor_next_finish (cursor, result, &error); if (error) { _gtk_search_engine_error (GTK_SEARCH_ENGINE (tracker), error->message); g_error_free (error); if (cursor) g_object_unref (cursor); gdk_threads_leave (); return; } if (!success) { _gtk_search_engine_finished (GTK_SEARCH_ENGINE (tracker)); if (cursor) g_object_unref (cursor); gdk_threads_leave (); return; } /* We iterate result by result, not n at a time. */ hits = g_list_append (NULL, (gchar*) tracker_sparql_cursor_get_string (cursor, 0, NULL)); _gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (tracker), hits); g_list_free (hits); /* Get next */ cursor_next (tracker, cursor); gdk_threads_leave (); }
static void search_callback (gchar **results, GError *error, gpointer user_data) { GtkSearchEngineTracker *tracker; gchar **results_p; GList *hit_uris; tracker = GTK_SEARCH_ENGINE_TRACKER (user_data); hit_uris = NULL; tracker->priv->query_pending = FALSE; if (error) { _gtk_search_engine_error ( GTK_SEARCH_ENGINE (tracker), error->message); g_error_free (error); return; } if (!results) return; for (results_p = results; *results_p; results_p++) { gchar *uri; if (tracker->priv->version == TRACKER_0_6) uri = g_filename_to_uri (*results_p, NULL, NULL); else uri = *results_p; if (uri) hit_uris = g_list_prepend (hit_uris, uri); } _gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (tracker), hit_uris); _gtk_search_engine_finished (GTK_SEARCH_ENGINE (tracker)); g_strfreev (results); if (tracker->priv->version == TRACKER_0_6) g_list_foreach (hit_uris, (GFunc)g_free, NULL); g_list_free (hit_uris); }
static void query_callback (GObject *object, GAsyncResult *result, gpointer user_data) { GtkSearchEngineTracker *tracker; TrackerSparqlConnection *connection; TrackerSparqlCursor *cursor; GError *error = NULL; gdk_threads_enter (); tracker = GTK_SEARCH_ENGINE_TRACKER (user_data); tracker->priv->query_pending = FALSE; connection = TRACKER_SPARQL_CONNECTION (object); cursor = tracker_sparql_connection_query_finish (connection, result, &error); g_debug ("Query returned cursor:%p", cursor); if (error) { _gtk_search_engine_error (GTK_SEARCH_ENGINE (tracker), error->message); g_error_free (error); gdk_threads_leave (); return; } if (!cursor) { _gtk_search_engine_finished (GTK_SEARCH_ENGINE (tracker)); gdk_threads_leave (); return; } cursor_next (tracker, cursor); gdk_threads_leave (); }
static void finalize (GObject *object) { GtkSearchEngine *engine = GTK_SEARCH_ENGINE (object); g_clear_object (&engine->priv->native); g_free (engine->priv->native_error); g_clear_object (&engine->priv->simple); g_free (engine->priv->simple_error); g_clear_pointer (&engine->priv->hits, g_hash_table_unref); G_OBJECT_CLASS (_gtk_search_engine_parent_class)->finalize (object); }
static gboolean search_thread_done_idle (gpointer user_data) { SearchThreadData *data; data = user_data; if (!data->cancelled) _gtk_search_engine_finished (GTK_SEARCH_ENGINE (data->engine)); data->engine->priv->active_search = NULL; search_thread_data_free (data); return FALSE; }
static gboolean search_thread_add_hits_idle (gpointer user_data) { SearchHits *hits; hits = user_data; if (!hits->thread_data->cancelled) { _gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (hits->thread_data->engine), hits->uris); } g_list_free_full (hits->uris, g_free); g_free (hits); return FALSE; }