[tracker/direct-access: 100/121] Initial implementation update api in bus, squash this with future commits
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/direct-access: 100/121] Initial implementation update api in bus, squash this with future commits
- Date: Thu, 22 Jul 2010 14:50:58 +0000 (UTC)
commit 43b21493746c14f81115d0c60681a0d841b34c88
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Jul 20 17:24:13 2010 +0200
Initial implementation update api in bus, squash this with future commits
src/Makefile.am | 1 -
src/libtracker-bus/.gitignore | 1 +
src/libtracker-bus/Makefile.am | 16 +-
src/libtracker-bus/tracker-bus-fd-update.c | 553 +++++++++++++++++++++++++
src/libtracker-bus/tracker-bus-fd-update.h | 47 +++
src/libtracker-bus/tracker-bus-fd-update.vapi | 30 ++
src/libtracker-bus/tracker-bus.vala | 14 +-
7 files changed, 652 insertions(+), 10 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 640e0ec..ebbaac6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,7 +24,6 @@ SUBDIRS = \
plugins \
tracker-store \
tracker-control \
- tracker-utils \
tracker-extract \
tracker-writeback \
vapi
diff --git a/src/libtracker-bus/.gitignore b/src/libtracker-bus/.gitignore
index 3a09e04..f0b768e 100644
--- a/src/libtracker-bus/.gitignore
+++ b/src/libtracker-bus/.gitignore
@@ -1,2 +1,3 @@
tracker-bus.[ch]
tracker-bus-*.vapi
+tracker-array-cursor.c
diff --git a/src/libtracker-bus/Makefile.am b/src/libtracker-bus/Makefile.am
index 49c9986..4afcf57 100644
--- a/src/libtracker-bus/Makefile.am
+++ b/src/libtracker-bus/Makefile.am
@@ -11,7 +11,8 @@ INCLUDES = \
$(WARN_CFLAGS) \
$(DBUS_CFLAGS) \
$(GLIB2_CFLAGS) \
- $(GCOV_CFLAGS)
+ $(GCOV_CFLAGS) \
+ $(GIO_CFLAGS)
if HAVE_DBUS_FD_PASSING
INCLUDES += -DHAVE_DBUS_FD_PASSING_IN_VALA=\"1\"
@@ -26,9 +27,11 @@ libtracker_bus_la_VALASOURCES = \
tracker-array-cursor.vala
libtracker_bus_la_SOURCES = \
- libtracker-bus.vala.stamp \
- $(libtracker_bus_la_VALASOURCES:.vala=.c) \
- tracker-bus-fd-cursor.c
+ libtracker-bus.vala.stamp \
+ $(libtracker_bus_la_VALASOURCES:.vala=.c) \
+ tracker-bus-fd-cursor.c \
+ tracker-bus-fd-update.c \
+ tracker-bus-fd-update.h
libtracker_bus_la_LDFLAGS = \
-module -avoid-version -no-undefined
@@ -44,13 +47,14 @@ vapi_sources = \
$(top_srcdir)/src/libtracker-common/libtracker-common.vapi
libtracker-bus.vala.stamp: $(libtracker_bus_la_VALASOURCES) $(vapi_sources)
- $(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 --pkg dbus-glib-1 -H tracker-bus.h --vapi tracker-bus-$(TRACKER_API_VERSION).vapi $^
+ $(AM_V_GEN)$(VALAC) $(GCOV_VALAFLAGS) -C $(VALAFLAGS) --pkg gio-2.0 --pkg dbus-glib-1 -H tracker-bus.h --vapi tracker-bus-$(TRACKER_API_VERSION).vapi tracker-bus-fd-update.vapi $^
$(AM_V_GEN)touch $@
libtracker_bus_la_LIBADD = \
$(top_builddir)/src/libtracker-common/libtracker-common.la \
$(GLIB2_LIBS) \
- $(DBUS_LIBS)
+ $(DBUS_LIBS) \
+ $(GIO_LIBS)
BUILT_SOURCES = \
libtracker-bus.vala.stamp
diff --git a/src/libtracker-bus/tracker-bus-fd-update.c b/src/libtracker-bus/tracker-bus-fd-update.c
new file mode 100644
index 0000000..28e43df
--- /dev/null
+++ b/src/libtracker-bus/tracker-bus-fd-update.c
@@ -0,0 +1,553 @@
+/*
+ * Copyright (C) 2006, Jamie McCracken <jamiemcc gnome org>
+ * Copyright (C) 2008-2010, Nokia <ivan frade nokia com>
+ * Copyright (C) 2010, Codeminded BVBA <philip codeminded be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <glib-object.h>
+#include <gio/gunixoutputstream.h>
+
+#include <libtracker-common/tracker-common.h>
+#include <libtracker-sparql/tracker-sparql.h>
+
+#include "tracker-bus-fd-update.h"
+#include "tracker-bus.h"
+
+#ifdef HAVE_DBUS_FD_PASSING
+
+typedef enum {
+ FAST_UPDATE,
+ FAST_UPDATE_BLANK
+} FastOperationType;
+
+typedef struct {
+ DBusConnection *connection;
+ FastOperationType operation_type;
+ GCancellable *cancellable;
+ DBusPendingCall *dbus_call;
+ GSimpleAsyncResult *res;
+ gpointer user_data;
+ gulong cancelid;
+} FastAsyncData;
+
+
+static void
+fast_async_data_free (gpointer data)
+{
+ FastAsyncData *fad = data;
+
+ if (fad) {
+ if (fad->cancellable) {
+ if (fad->cancelid != 0)
+ g_cancellable_disconnect (fad->cancellable, fad->cancelid);
+ g_object_unref (fad->cancellable);
+ }
+
+ if (fad->connection) {
+ dbus_connection_unref (fad->connection);
+ }
+
+ if (fad->res) {
+ /* Don't free, weak */
+ }
+
+ g_slice_free (FastAsyncData, fad);
+ }
+}
+
+static void
+on_cancel (FastAsyncData *fad)
+{
+ if (fad->dbus_call) {
+ dbus_pending_call_cancel (fad->dbus_call);
+ dbus_pending_call_unref (fad->dbus_call);
+ fad->dbus_call = NULL;
+ }
+
+ fast_async_data_free (fad);
+}
+
+static FastAsyncData *
+fast_async_data_new (DBusConnection *connection,
+ FastOperationType operation_type,
+ GCancellable *cancellable,
+ gpointer user_data)
+{
+ FastAsyncData *data;
+
+ data = g_slice_new0 (FastAsyncData);
+
+ data->connection = dbus_connection_ref (connection);
+ data->operation_type = operation_type;
+ data->cancellable = g_object_ref (cancellable);
+ data->user_data = user_data;
+
+ data->cancelid = g_cancellable_connect (cancellable, G_CALLBACK (on_cancel), data, NULL);
+
+ return data;
+}
+
+
+static GHashTable *
+unmarshal_hash_table (DBusMessageIter *iter)
+{
+ GHashTable *result;
+ DBusMessageIter subiter, subsubiter;
+
+ result = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ (GDestroyNotify) g_free,
+ (GDestroyNotify) g_free);
+
+ dbus_message_iter_recurse (iter, &subiter);
+
+ while (dbus_message_iter_get_arg_type (&subiter) != DBUS_TYPE_INVALID) {
+ const gchar *key, *value;
+
+ dbus_message_iter_recurse (&subiter, &subsubiter);
+ dbus_message_iter_get_basic (&subsubiter, &key);
+ dbus_message_iter_next (&subsubiter);
+ dbus_message_iter_get_basic (&subsubiter, &value);
+ g_hash_table_insert (result, g_strdup (key), g_strdup (value));
+
+ dbus_message_iter_next (&subiter);
+ }
+
+ return result;
+}
+
+static void
+free_inner_array (gpointer elem)
+{
+ g_ptr_array_free (elem, TRUE);
+}
+
+static void
+sparql_update_fast_callback (DBusPendingCall *call,
+ void *user_data)
+{
+ FastAsyncData *fad = user_data;
+ DBusMessage *reply;
+ GError *error = NULL;
+ DBusMessageIter iter, subiter, subsubiter;
+ GPtrArray *result;
+
+ /* Check for errors */
+ reply = dbus_pending_call_steal_reply (call);
+
+ if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) {
+ DBusError dbus_error;
+
+ dbus_error_init (&dbus_error);
+ dbus_set_error_from_message (&dbus_error, reply);
+ dbus_set_g_error (&error, &dbus_error);
+ dbus_error_free (&dbus_error);
+
+ g_simple_async_result_set_from_error (fad->res, error);
+
+ dbus_message_unref (reply);
+
+ g_simple_async_result_complete (fad->res);
+
+ fast_async_data_free (fad);
+
+ return;
+ }
+
+ /* Call iterator callback */
+ switch (fad->operation_type) {
+ case FAST_UPDATE:
+ case FAST_UPDATE_BLANK:
+ result = g_ptr_array_new_with_free_func (free_inner_array);
+ dbus_message_iter_init (reply, &iter);
+ dbus_message_iter_recurse (&iter, &subiter);
+
+ while (dbus_message_iter_get_arg_type (&subiter) != DBUS_TYPE_INVALID) {
+ GPtrArray *inner_array;
+
+ inner_array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_hash_table_unref);
+ g_ptr_array_add (result, inner_array);
+ dbus_message_iter_recurse (&subiter, &subsubiter);
+
+ while (dbus_message_iter_get_arg_type (&subsubiter) != DBUS_TYPE_INVALID) {
+ g_ptr_array_add (inner_array, unmarshal_hash_table (&subsubiter));
+ dbus_message_iter_next (&subsubiter);
+ }
+
+ dbus_message_iter_next (&subiter);
+ }
+
+ g_simple_async_result_set_op_res_gpointer (fad->res, result, NULL);
+
+ g_simple_async_result_complete (fad->res);
+
+ g_ptr_array_free (result, TRUE);
+
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ /* Clean up */
+ dbus_message_unref (reply);
+
+ fast_async_data_free (fad);
+}
+
+static DBusPendingCall *
+sparql_update_fast_send (DBusConnection *connection,
+ const gchar *query,
+ FastOperationType type,
+ GError **error)
+{
+ const gchar *dbus_method;
+ DBusMessage *message;
+ DBusMessageIter iter;
+ DBusPendingCall *call;
+ int pipefd[2];
+ GOutputStream *output_stream;
+ GOutputStream *buffered_output_stream;
+ GDataOutputStream *data_output_stream;
+ GError *inner_error = NULL;
+
+ g_return_val_if_fail (query != NULL, NULL);
+
+ if (pipe (pipefd) < 0) {
+ g_set_error (error,
+ TRACKER_SPARQL_ERROR,
+ TRACKER_SPARQL_ERROR_UNSUPPORTED,
+ "Cannot open pipe");
+ return NULL;
+ }
+
+ switch (type) {
+ case FAST_UPDATE:
+ dbus_method = "Update";
+ break;
+ case FAST_UPDATE_BLANK:
+ dbus_method = "UpdateBlank";
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
+ message = dbus_message_new_method_call (TRACKER_DBUS_SERVICE,
+ TRACKER_DBUS_OBJECT_STEROIDS,
+ TRACKER_DBUS_INTERFACE_STEROIDS,
+ dbus_method);
+ dbus_message_iter_init_append (message, &iter);
+ dbus_message_iter_append_basic (&iter, DBUS_TYPE_UNIX_FD, &pipefd[0]);
+ dbus_connection_send_with_reply (connection, message, &call, -1);
+ dbus_message_unref (message);
+ close (pipefd[0]);
+
+ if (!call) {
+ g_set_error (error,
+ TRACKER_SPARQL_ERROR,
+ TRACKER_SPARQL_ERROR_UNSUPPORTED,
+ "FD passing unsupported or connection disconnected");
+ return NULL;
+ }
+
+ output_stream = g_unix_output_stream_new (pipefd[1], TRUE);
+ buffered_output_stream = g_buffered_output_stream_new_sized (output_stream,
+ TRACKER_DBUS_PIPE_BUFFER_SIZE);
+ data_output_stream = g_data_output_stream_new (buffered_output_stream);
+
+ g_data_output_stream_put_int32 (data_output_stream, strlen (query),
+ NULL, &inner_error);
+
+ if (inner_error) {
+ g_propagate_error (error, inner_error);
+ g_object_unref (data_output_stream);
+ g_object_unref (buffered_output_stream);
+ g_object_unref (output_stream);
+ return NULL;
+ }
+
+ g_data_output_stream_put_string (data_output_stream,
+ query,
+ NULL,
+ &inner_error);
+
+ if (inner_error) {
+ g_propagate_error (error, inner_error);
+ g_object_unref (data_output_stream);
+ g_object_unref (buffered_output_stream);
+ g_object_unref (output_stream);
+ return NULL;
+ }
+
+ g_object_unref (data_output_stream);
+ g_object_unref (buffered_output_stream);
+ g_object_unref (output_stream);
+
+ return call;
+}
+
+static DBusMessage *
+sparql_update_fast (DBusConnection *connection,
+ const gchar *query,
+ FastOperationType type,
+ GError **error)
+{
+ DBusPendingCall *call;
+ DBusMessage *reply;
+
+ call = sparql_update_fast_send (connection, query, type, error);
+ if (!call) {
+ return NULL;
+ }
+
+ dbus_pending_call_block (call);
+
+ reply = dbus_pending_call_steal_reply (call);
+
+ if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) {
+ DBusError dbus_error;
+
+ dbus_error_init (&dbus_error);
+ dbus_set_error_from_message (&dbus_error, reply);
+ dbus_set_g_error (error, &dbus_error);
+ dbus_pending_call_unref (call);
+ dbus_error_free (&dbus_error);
+
+ return NULL;
+ }
+
+ dbus_pending_call_unref (call);
+
+ return reply;
+}
+
+static void
+sparql_update_fast_async (DBusConnection *connection,
+ const gchar *query,
+ FastAsyncData *fad,
+ GError **error)
+{
+ DBusPendingCall *call;
+
+ call = sparql_update_fast_send (connection, query, fad->operation_type, error);
+ if (!call) {
+ /* Do some clean up ?*/
+ return;
+ }
+
+ fad->dbus_call = call;
+
+ dbus_pending_call_set_notify (call, sparql_update_fast_callback, fad, NULL);
+}
+
+#endif /* HAVE_DBUS_FD_PASSING */
+
+/* Public API */
+
+void
+tracker_bus_fd_sparql_update (DBusGConnection *connection,
+ const char *query,
+ GError **error)
+{
+#ifdef HAVE_DBUS_FD_PASSING
+ DBusMessage *reply;
+
+ g_return_if_fail (query != NULL);
+
+ reply = sparql_update_fast (dbus_g_connection_get_connection (connection),
+ query, FAST_UPDATE, error);
+
+ if (!reply) {
+ return;
+ }
+
+ dbus_message_unref (reply);
+#else
+ g_assert_not_reached ();
+#endif /* HAVE_DBUS_FD_PASSING */
+}
+
+void
+tracker_bus_fd_sparql_update_async (DBusGConnection *connection,
+ const char *query,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+#ifdef HAVE_DBUS_FD_PASSING
+ FastAsyncData *fad;
+ GError *error = NULL;
+
+ g_return_if_fail (query != NULL);
+
+ fad = fast_async_data_new (dbus_g_connection_get_connection (connection),
+ FAST_UPDATE, cancellable, user_data);
+
+ fad->res = g_simple_async_result_new (G_OBJECT (connection), callback, user_data,
+ tracker_bus_fd_sparql_update_async);
+
+ sparql_update_fast_async (dbus_g_connection_get_connection (connection),
+ query, fad, &error);
+
+ if (error) {
+ g_critical ("Could not initiate update: %s", error->message);
+ g_error_free (error);
+ g_object_unref (fad->res);
+ fast_async_data_free (fad);
+ }
+
+#else
+ g_assert_not_reached ();
+#endif /* HAVE_DBUS_FD_PASSING */
+}
+
+GPtrArray*
+tracker_bus_fd_sparql_update_finish (GAsyncResult *res,
+ GError **error)
+{
+#ifdef HAVE_DBUS_FD_PASSING
+ g_return_val_if_fail (res != NULL, NULL);
+
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) {
+ return NULL;
+ }
+
+ return g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
+#else /* HAVE_DBUS_FD_PASSING */
+ g_assert_not_reached ();
+ return NULL;
+#endif /* HAVE_DBUS_FD_PASSING */
+}
+
+GPtrArray*
+tracker_bus_fd_sparql_update_blank_finish (GAsyncResult *res,
+ GError **error)
+{
+#ifdef HAVE_DBUS_FD_PASSING
+ g_return_val_if_fail (res != NULL, NULL);
+
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) {
+ return NULL;
+ }
+
+ return g_object_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
+#else /* HAVE_DBUS_FD_PASSING */
+ g_assert_not_reached ();
+ return NULL;
+#endif /* HAVE_DBUS_FD_PASSING */
+}
+
+GPtrArray *
+tracker_bus_fd_sparql_update_blank (DBusGConnection *connection,
+ const gchar *query,
+ GError **error)
+{
+#ifdef HAVE_DBUS_FD_PASSING
+ DBusMessage *reply;
+ DBusMessageIter iter, subiter, subsubiter;
+ GPtrArray *result;
+
+ g_return_val_if_fail (query != NULL, NULL);
+
+ reply = sparql_update_fast (dbus_g_connection_get_connection (connection),
+ query, FAST_UPDATE_BLANK, error);
+
+ if (!reply) {
+ return NULL;
+ }
+
+ if (g_strcmp0 (dbus_message_get_signature (reply), "aaa{ss}")) {
+ g_set_error (error,
+ TRACKER_SPARQL_ERROR,
+ TRACKER_SPARQL_ERROR_UNSUPPORTED,
+ "Server returned invalid results");
+ dbus_message_unref (reply);
+ return NULL;
+ }
+
+ result = g_ptr_array_new_with_free_func (free_inner_array);
+ dbus_message_iter_init (reply, &iter);
+ dbus_message_iter_recurse (&iter, &subiter);
+
+ while (dbus_message_iter_get_arg_type (&subiter) != DBUS_TYPE_INVALID) {
+ GPtrArray *inner_array;
+
+ inner_array = g_ptr_array_new_with_free_func ((GDestroyNotify) g_hash_table_destroy);
+ g_ptr_array_add (result, inner_array);
+ dbus_message_iter_recurse (&subiter, &subsubiter);
+
+ while (dbus_message_iter_get_arg_type (&subsubiter) != DBUS_TYPE_INVALID) {
+ g_ptr_array_add (inner_array, unmarshal_hash_table (&subsubiter));
+ dbus_message_iter_next (&subsubiter);
+ }
+
+ dbus_message_iter_next (&subiter);
+ }
+
+ dbus_message_unref (reply);
+
+ return result;
+#else /* HAVE_DBUS_FD_PASSING */
+ g_assert_not_reached ();
+ return NULL;
+#endif /* HAVE_DBUS_FD_PASSING */
+}
+
+void
+tracker_bus_fd_sparql_update_blank_async (DBusGConnection *connection,
+ const gchar *query,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+#ifdef HAVE_DBUS_FD_PASSING
+ FastAsyncData *fad;
+ GError *error = NULL;
+
+ g_return_if_fail (query != NULL);
+ g_return_if_fail (callback != NULL);
+
+ fad = fast_async_data_new (dbus_g_connection_get_connection (connection),
+ FAST_UPDATE_BLANK,
+ cancellable,
+ user_data);
+
+ fad->res = g_simple_async_result_new (G_OBJECT (connection), callback, user_data,
+ tracker_bus_fd_sparql_update_blank_async);
+
+ sparql_update_fast_async (dbus_g_connection_get_connection (connection),
+ query, fad, &error);
+
+ if (error) {
+ g_critical ("Could not initiate update: %s", error->message);
+ g_error_free (error);
+ g_object_unref (fad->res);
+ fast_async_data_free (fad);
+ }
+
+#else /* HAVE_DBUS_FD_PASSING */
+ g_assert_not_reached ();
+#endif /* HAVE_DBUS_FD_PASSING */
+}
diff --git a/src/libtracker-bus/tracker-bus-fd-update.h b/src/libtracker-bus/tracker-bus-fd-update.h
new file mode 100644
index 0000000..97dffcf
--- /dev/null
+++ b/src/libtracker-bus/tracker-bus-fd-update.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2008-2010, Nokia <ivan frade nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <dbus/dbus.h>
+#include <dbus/dbus-glib-lowlevel.h>
+#include <dbus/dbus-glib.h>
+
+G_BEGIN_DECLS
+
+void tracker_bus_fd_sparql_update (DBusGConnection *connection,
+ const char *query,
+ GError **error);
+void tracker_bus_fd_sparql_update_async (DBusGConnection *connection,
+ const char *query,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+GPtrArray * tracker_bus_fd_sparql_update_blank (DBusGConnection *connection,
+ const gchar *query,
+ GError **error);
+void tracker_bus_fd_sparql_update_blank_async (DBusGConnection *connection,
+ const gchar *query,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+GPtrArray* tracker_bus_fd_sparql_update_finish (GAsyncResult *res,
+ GError **error);
+GPtrArray* tracker_bus_fd_sparql_update_blank_finish (GAsyncResult *res,
+ GError **error);
+
+G_END_DECLS
diff --git a/src/libtracker-bus/tracker-bus-fd-update.vapi b/src/libtracker-bus/tracker-bus-fd-update.vapi
new file mode 100644
index 0000000..2546a56
--- /dev/null
+++ b/src/libtracker-bus/tracker-bus-fd-update.vapi
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010, Nokia <ivan frade nokia com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+/* This .vapi file is a workaround for bug fixed in this commit for valac:
+ * http://git.gnome.org/browse/vala/commit/?id=7757cf9ecf6084413f409ba31c31ed73cacd6ec1*/
+
+[CCode (cheader_filename = "tracker-bus-fd-update.h")]
+public void tracker_bus_fd_sparql_update (DBus.Connection connection, string query) throws Tracker.Sparql.Error;
+[CCode (cheader_filename = "tracker-bus-fd-update.h")]
+public extern GLib.PtrArray tracker_bus_fd_sparql_update_blank (DBus.Connection connection, string query) throws Tracker.Sparql.Error;
+[CCode (cheader_filename = "tracker-bus-fd-update.h")]
+public extern async void tracker_bus_fd_sparql_update_async (DBus.Connection connection, string query, GLib.Cancellable? cancellable = null) throws Tracker.Sparql.Error;
+[CCode (cheader_filename = "tracker-bus-fd-update.h")]
+public extern async uint tracker_bus_fd_sparql_update_blank_async (DBus.Connection connection, string query, GLib.Cancellable? cancellable = null) throws Tracker.Sparql.Error;
diff --git a/src/libtracker-bus/tracker-bus.vala b/src/libtracker-bus/tracker-bus.vala
index 13112c9..331c7ab 100644
--- a/src/libtracker-bus/tracker-bus.vala
+++ b/src/libtracker-bus/tracker-bus.vala
@@ -51,7 +51,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
static Statistics statistics_object;
static bool initialized;
static bool use_steroids;
-
+
public Connection ()
requires (!initialized) {
initialized = true;
@@ -115,7 +115,11 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
public override void update (string sparql, Cancellable? cancellable = null) throws Sparql.Error {
try {
- resources_object.sparql_update (sparql);
+ if (use_steroids) {
+ tracker_bus_fd_sparql_update (connection, sparql);
+ } else {
+ resources_object.sparql_update (sparql);
+ }
} catch (DBus.Error e) {
throw new Sparql.Error.INTERNAL (e.message);
}
@@ -123,7 +127,11 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
public async override void update_async (string sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error {
try {
- yield resources_object.sparql_update_async (sparql);
+ if (use_steroids) {
+ yield tracker_bus_fd_sparql_update_async (connection, sparql, cancellable);
+ } else {
+ yield resources_object.sparql_update_async (sparql);
+ }
} catch (DBus.Error e) {
throw new Sparql.Error.INTERNAL (e.message);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]