Esempio n. 1
0
gint
main (gint argc, gchar *argv[])
{
	MyData *md;

	g_type_init ();

	md = g_new0 (MyData, 1);
	md->loop = g_main_loop_new (NULL, FALSE);
	md->timer = g_timer_new ();
	md->cancellable = g_cancellable_new ();

	tracker_sparql_connection_get_async (md->cancellable,
	                                     connection_cb,
	                                     md);

	g_main_loop_run (md->loop);

	if (md->connection) {
		g_object_unref (md->connection);
	}

	g_cancellable_cancel (md->cancellable);
	g_object_unref (md->cancellable);
	g_timer_destroy (md->timer);
	g_main_loop_unref (md->loop);

	g_free (md);

	return EXIT_SUCCESS;
}
void
nul_sparql_query_util_query_async (gchar const         *const sparql,
                                   GCancellable        *const cancellable,
                                   GAsyncReadyCallback  const callback,
                                   gpointer             const user_data)
{

  nul_debug ("scheduling query %s", sparql);

  GTask *const task = g_task_new (NULL, cancellable, callback, user_data);

  SparqlQueryWork *const work = g_new0 (SparqlQueryWork, 1);
  work->sparql = g_strdup (sparql);

  g_task_set_task_data (task, work, (GDestroyNotify) sparql_query_work_free);

  tracker_sparql_connection_get_async (
    cancellable,
    (GAsyncReadyCallback) do_sparql_query_async_connection_cb,
    task
  );

}