[tracker/gdbus: 4/43] libtracker-sparql: Port from libdbus/dbus-glib to GDBus
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/gdbus: 4/43] libtracker-sparql: Port from libdbus/dbus-glib to GDBus
- Date: Wed, 10 Nov 2010 15:56:54 +0000 (UTC)
commit 97085799a4d873a524ed5899dcce0045ea63fe1e
Author: Jürg Billeter <j bitron ch>
Date: Tue Oct 19 16:04:48 2010 +0200
libtracker-sparql: Port from libdbus/dbus-glib to GDBus
Fixes NB#199968.
configure.ac | 12 +-
src/libtracker-bus/.gitignore | 1 +
src/libtracker-bus/Makefile.am | 18 +-
src/libtracker-bus/tracker-bus-fd-cursor.c | 417 -----------
src/libtracker-bus/tracker-bus-fd-cursor.h | 45 --
src/libtracker-bus/tracker-bus-fd-cursor.vala | 121 ++++
src/libtracker-bus/tracker-bus-fd-cursor.vapi | 21 -
src/libtracker-bus/tracker-bus-fd-update.c | 877 -----------------------
src/libtracker-bus/tracker-bus-fd-update.h | 74 --
src/libtracker-bus/tracker-bus-fd-update.vapi | 35 -
src/libtracker-bus/tracker-bus-shared.c | 83 ---
src/libtracker-bus/tracker-bus-shared.h | 29 -
src/libtracker-bus/tracker-bus.vala | 310 ++++++--
src/libtracker-client/tracker-sparql-query.vapi | 52 ++
src/libtracker-common/tracker-dbus.h | 2 +
src/libtracker-direct/Makefile.am | 4 +-
src/libtracker-sparql/Makefile.am | 3 +-
src/libtracker-sparql/tracker-backend.vala | 30 +-
src/libtracker-sparql/tracker-connection.vala | 4 +-
src/miners/flickr/tracker-sparql-builder.h | 58 ++
src/miners/flickr/tracker-sparql-query.vapi | 30 +
21 files changed, 528 insertions(+), 1698 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index d506db6..a609eee 100644
--- a/configure.ac
+++ b/configure.ac
@@ -206,9 +206,7 @@ AC_SUBST(LIBPNG_LIBS)
# Check requirements for libtracker-bus
LIBTRACKER_BUS_REQUIRED="glib-2.0 >= $GLIB_REQUIRED
- gio-unix-2.0 >= $GLIB_REQUIRED
- dbus-1 >= $DBUS_REQUIRED
- dbus-glib-1 >= $DBUS_GLIB_REQUIRED"
+ gio-unix-2.0 >= $GLIB_REQUIRED"
PKG_CHECK_MODULES(LIBTRACKER_BUS, [$LIBTRACKER_BUS_REQUIRED])
# Check requirements for libtracker-client
@@ -241,9 +239,7 @@ LIBTRACKER_DATA_LIBS="$LIBTRACKER_DATA_LIBS -lz -lm"
# Check requirements for libtracker-direct
LIBTRACKER_DIRECT_REQUIRED="glib-2.0 >= $GLIB_REQUIRED
- gio-unix-2.0 >= $GLIB_REQUIRED
- dbus-1 >= $DBUS_REQUIRED
- dbus-glib-1 >= $DBUS_GLIB_REQUIRED"
+ gio-unix-2.0 >= $GLIB_REQUIRED"
PKG_CHECK_MODULES(LIBTRACKER_DIRECT, [$LIBTRACKER_DIRECT_REQUIRED])
@@ -275,9 +271,7 @@ PKG_CHECK_MODULES(LIBTRACKER_MINER, [$LIBTRACKER_MINER_REQUIRED])
# Check requirements for libtracker-sparql
LIBTRACKER_SPARQL_REQUIRED="glib-2.0 >= $GLIB_REQUIRED
- gio-unix-2.0 >= $GLIB_REQUIRED
- dbus-1 >= $DBUS_REQUIRED
- dbus-glib-1 >= $DBUS_GLIB_REQUIRED"
+ gio-unix-2.0 >= $GLIB_REQUIRED"
PKG_CHECK_MODULES(LIBTRACKER_SPARQL, [$LIBTRACKER_SPARQL_REQUIRED])
diff --git a/src/libtracker-bus/.gitignore b/src/libtracker-bus/.gitignore
index c326b36..f5dec99 100644
--- a/src/libtracker-bus/.gitignore
+++ b/src/libtracker-bus/.gitignore
@@ -1,3 +1,4 @@
tracker-bus.[ch]
tracker-bus*.vapi
tracker-array-cursor.c
+tracker-bus-fd-cursor.c
diff --git a/src/libtracker-bus/Makefile.am b/src/libtracker-bus/Makefile.am
index 08b75c8..176ab75 100644
--- a/src/libtracker-bus/Makefile.am
+++ b/src/libtracker-bus/Makefile.am
@@ -8,27 +8,22 @@ AM_VALAFLAGS = \
--includedir=libtracker-bus \
--header tracker-bus.h \
--vapi tracker-bus.vapi \
- --pkg gio-2.0 --pkg dbus-glib-1 \
+ --pkg gio-2.0 --pkg gio-unix-2.0 --pkg posix \
$(BUILD_VALAFLAGS) \
- $(top_srcdir)/src/vapi/posix.vapi \
- $(top_srcdir)/src/vapi/glib-2.0-fixes.vapi \
$(top_srcdir)/src/libtracker-common/libtracker-common.vapi \
- $(top_srcdir)/src/libtracker-sparql/tracker-sparql-$(TRACKER_API_VERSION).vapi \
- tracker-bus-fd-cursor.vapi \
- tracker-bus-fd-update.vapi
+ $(top_srcdir)/src/libtracker-sparql/tracker-sparql-$(TRACKER_API_VERSION).vapi
AM_CPPFLAGS = \
$(BUILD_CFLAGS) \
-I$(top_srcdir)/src \
-I$(top_builddir)/src \
+ -DNO_LIBDBUS \
$(LIBTRACKER_BUS_CFLAGS)
libtracker_bus_la_SOURCES = \
tracker-bus.vala \
tracker-array-cursor.vala \
- tracker-bus-fd-cursor.c \
- tracker-bus-fd-update.c \
- tracker-bus-shared.c
+ tracker-bus-fd-cursor.vala
libtracker_bus_la_LIBADD = \
$(top_builddir)/src/libtracker-sparql/libtracker-sparql-$(TRACKER_API_VERSION).la \
@@ -47,8 +42,3 @@ noinst_HEADERS = \
BUILT_SOURCES = \
libtracker_bus_la_vala.stamp
-
-EXTRA_DIST = \
- tracker-bus-fd-cursor.vapi \
- tracker-bus-fd-update.vapi
-
diff --git a/src/libtracker-bus/tracker-bus-fd-cursor.vala b/src/libtracker-bus/tracker-bus-fd-cursor.vala
new file mode 100644
index 0000000..7294aa3
--- /dev/null
+++ b/src/libtracker-bus/tracker-bus-fd-cursor.vala
@@ -0,0 +1,121 @@
+/*
+ * 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.
+ */
+
+class Tracker.Bus.FDCursor : Tracker.Sparql.Cursor {
+ internal char* buffer;
+ internal ulong buffer_index;
+ internal ulong buffer_size;
+
+ internal int _n_columns;
+ internal int* offsets;
+ internal int* types;
+ internal char* data;
+ internal string[] variable_names;
+
+ public FDCursor (char* buffer, ulong buffer_size, string[] variable_names) {
+ this.buffer = buffer;
+ this.buffer_size = buffer_size;
+ this.variable_names = variable_names;
+ _n_columns = variable_names.length;
+ }
+
+ ~FDCursor () {
+ free (buffer);
+ }
+
+ inline int buffer_read_int () {
+ int v = *((int*) (buffer + buffer_index));
+
+ buffer_index += 4;
+
+ return v;
+ }
+
+ public override int n_columns {
+ get { return _n_columns; }
+ }
+
+ public override Sparql.ValueType get_value_type (int column)
+ requires (types != null) {
+ /* Cast from int to enum */
+ return (Sparql.ValueType) types[column];
+ }
+
+ public override unowned string? get_variable_name (int column)
+ requires (variable_names != null) {
+ return variable_names[column];
+ }
+
+ public override unowned string? get_string (int column, out long length = null)
+ requires (column < n_columns && data != null) {
+ unowned string str = null;
+
+ if (column == 0) {
+ str = (string) data;
+ } else {
+ str = (string) (data + offsets[column - 1] + 1);
+ }
+
+ length = str.length;
+
+ return str;
+ }
+
+ public override bool next (Cancellable? cancellable = null) throws GLib.Error {
+ int last_offset;
+
+ if (buffer_index >= buffer_size) {
+ return false;
+ }
+
+ /* So, the make up on each cursor segment is:
+ *
+ * iteration = [4 bytes for number of columns,
+ * columns x 4 bytes for types
+ * columns x 4 bytes for offsets]
+ */
+
+ _n_columns = buffer_read_int ();
+
+ /* Storage of ints that will be cast to TrackerSparqlValueType enums,
+ * also see get_value_type */
+ types = (int*) (buffer + buffer_index);
+ buffer_index += sizeof (int) * n_columns;
+
+ offsets = (int*) (buffer + buffer_index);
+ buffer_index += sizeof (int) * (n_columns - 1);
+ last_offset = buffer_read_int ();
+
+ data = buffer + buffer_index;
+
+ buffer_index += last_offset + 1;
+
+ return true;
+ }
+
+ public override async bool next_async (Cancellable? cancellable = null) throws GLib.Error {
+ // next never blocks
+ return next (cancellable);
+ }
+
+ public override void rewind () {
+ buffer_index = 0;
+ data = buffer;
+ }
+}
diff --git a/src/libtracker-bus/tracker-bus.vala b/src/libtracker-bus/tracker-bus.vala
index 6008134..715bd75 100644
--- a/src/libtracker-bus/tracker-bus.vala
+++ b/src/libtracker-bus/tracker-bus.vala
@@ -17,26 +17,54 @@
* Boston, MA 02110-1301, USA.
*/
-[DBus (name = "org.freedesktop.Tracker1.Resources", timeout = 2147483647 /* INT_MAX */)]
-private interface Tracker.Bus.Resources : GLib.Object {
- public abstract void load (string uri) throws Sparql.Error, DBus.Error;
+[DBus (name = "org.freedesktop.Tracker1.Resources")]
+private interface Tracker.Bus.Resources : DBusProxy {
+ public abstract void load (string uri, Cancellable? cancellable) throws Sparql.Error, DBusError;
[DBus (name = "Load")]
- public abstract async void load_async (string uri) throws Sparql.Error, DBus.Error;
+ public abstract async void load_async (string uri, Cancellable? cancellable) throws Sparql.Error, DBusError;
}
-[DBus (name = "org.freedesktop.Tracker1.Statistics")]
-private interface Tracker.Bus.Statistics : GLib.Object {
- public abstract string[,] Get () throws DBus.Error;
- public async abstract string[,] Get_async () throws DBus.Error;
+[DBus (name = "org.freedesktop.Tracker1.Steroids")]
+private interface Tracker.Bus.Steroids : DBusProxy {
+ public abstract async string[] query (string query, UnixOutputStream result_stream, Cancellable? cancellable) throws Sparql.Error, DBusError;
+ public abstract async void update (UnixInputStream sparql_stream, Cancellable? cancellable) throws Sparql.Error, DBusError;
+ [DBus (signature = "aaa{ss}")]
+ public abstract async Variant update_blank (UnixInputStream sparql_stream, Cancellable? cancellable) throws Sparql.Error, DBusError;
+ public abstract async void batch_update (UnixInputStream sparql_stream, Cancellable? cancellable) throws Sparql.Error, DBusError;
+ [DBus (signature = "as")]
+ public abstract async Variant update_array (UnixInputStream sparql_stream, Cancellable? cancellable) throws Sparql.Error, DBusError;
+ [DBus (signature = "as")]
+ public abstract async Variant batch_update_array (UnixInputStream sparql_stream, Cancellable? cancellable) throws Sparql.Error, DBusError;
+
+ [DBus (visible = false)]
+ public void update_begin (UnixInputStream sparql_stream, int priority, Cancellable? cancellable, AsyncReadyCallback callback) {
+ if (priority >= GLib.Priority.DEFAULT) {
+ update.begin (sparql_stream, cancellable, callback);
+ } else {
+ batch_update.begin (sparql_stream, cancellable, callback);
+ }
+ }
+
+ [DBus (visible = false)]
+ public void update_array_begin (UnixInputStream sparql_stream, int priority, Cancellable? cancellable, AsyncReadyCallback callback) {
+ if (priority >= GLib.Priority.DEFAULT) {
+ update_array.begin (sparql_stream, cancellable, callback);
+ } else {
+ batch_update_array.begin (sparql_stream, cancellable, callback);
+ }
+ }
}
-// Imported DBus FD API until we have support with Vala
-public extern Tracker.Sparql.Cursor tracker_bus_fd_query (DBus.Connection connection, string query, Cancellable? cancellable) throws Tracker.Sparql.Error, DBus.Error, GLib.IOError;
+[DBus (name = "org.freedesktop.Tracker1.Statistics")]
+private interface Tracker.Bus.Statistics : DBusProxy {
+ public abstract string[,] Get (Cancellable? cancellable) throws DBusError;
+ public async abstract string[,] Get_async (Cancellable? cancellable) throws DBusError;
+}
// Actual class definition
public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
- static DBus.Connection connection;
static Resources resources_object;
+ static Steroids steroids_object;
static Statistics statistics_object;
static bool initialized;
@@ -45,16 +73,17 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
initialized = true;
try {
- connection = DBus.Bus.get (DBus.BusType.SESSION);
-
// FIXME: Ideally we would just get these as and when we need them
- resources_object = (Resources) connection.get_object (TRACKER_DBUS_SERVICE,
- TRACKER_DBUS_OBJECT_RESOURCES,
- TRACKER_DBUS_INTERFACE_RESOURCES);
- statistics_object = (Statistics) connection.get_object (TRACKER_DBUS_SERVICE,
- TRACKER_DBUS_OBJECT_STATISTICS,
- TRACKER_DBUS_INTERFACE_STATISTICS);
- } catch (DBus.Error e) {
+ resources_object = GLib.Bus.get_proxy_sync (BusType.SESSION,
+ TRACKER_DBUS_SERVICE,
+ TRACKER_DBUS_OBJECT_RESOURCES);
+ steroids_object = GLib.Bus.get_proxy_sync (BusType.SESSION,
+ TRACKER_DBUS_SERVICE,
+ TRACKER_DBUS_OBJECT_STEROIDS);
+ statistics_object = GLib.Bus.get_proxy_sync (BusType.SESSION,
+ TRACKER_DBUS_SERVICE,
+ TRACKER_DBUS_OBJECT_STATISTICS);
+ } catch (DBusError e) {
warning ("Could not connect to D-Bus service:'%s': %s", TRACKER_DBUS_INTERFACE_RESOURCES, e.message);
initialized = false;
return;
@@ -67,114 +96,255 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
initialized = false;
}
- public override Sparql.Cursor query (string sparql, Cancellable? cancellable) throws Sparql.Error, IOError {
- try {
- return tracker_bus_fd_query (connection, sparql, cancellable);
- } catch (DBus.Error e) {
- throw new Sparql.Error.INTERNAL (e.message);
+ void pipe (out UnixInputStream input, out UnixOutputStream output) throws IOError {
+ int pipefd[2];
+ if (Posix.pipe (pipefd) < 0) {
+ throw new IOError.FAILED ("Pipe creation failed");
}
+ input = new UnixInputStream (pipefd[0], true);
+ output = new UnixOutputStream (pipefd[1], true);
+ }
+
+ public override Sparql.Cursor query (string sparql, Cancellable? cancellable) throws Sparql.Error, IOError {
+ // use separate main context for sync operation
+ var context = new MainContext ();
+ var loop = new MainLoop (context, false);
+ context.push_thread_default ();
+ AsyncResult async_res = null;
+ query_async.begin (sparql, cancellable, (o, res) => {
+ async_res = res;
+ loop.quit ();
+ });
+ loop.run ();
+ context.pop_thread_default ();
+ return query_async.end (async_res);
}
public async override Sparql.Cursor query_async (string sparql, Cancellable? cancellable = null) throws Sparql.Error, IOError {
try {
- return yield tracker_bus_fd_query_async (connection, sparql, cancellable);
- } catch (DBus.Error e) {
+ UnixInputStream input;
+ UnixOutputStream output;
+ pipe (out input, out output);
+
+ // send D-Bus request
+ AsyncResult dbus_res = null;
+ bool received_result = false;
+ steroids_object.query.begin (sparql, output, cancellable, (o, res) => {
+ dbus_res = res;
+ if (received_result) {
+ query_async.callback ();
+ }
+ });
+
+ output = null;
+
+ // receive query results via FD
+ var mem_stream = new MemoryOutputStream (null, 0, GLib.realloc, GLib.free);
+ yield mem_stream.splice_async (input, OutputStreamSpliceFlags.CLOSE_SOURCE | OutputStreamSpliceFlags.CLOSE_TARGET, Priority.DEFAULT, cancellable);
+
+ // wait for D-Bus reply
+ received_result = true;
+ if (dbus_res == null) {
+ yield;
+ }
+ string[] variable_names = steroids_object.query.end (dbus_res);
+ mem_stream.close ();
+ return new FDCursor (mem_stream.steal_data (), mem_stream.data_size, variable_names);
+ } catch (DBusError e) {
throw new Sparql.Error.INTERNAL (e.message);
}
}
public override void update (string sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError {
- try {
- if (priority >= GLib.Priority.DEFAULT) {
- tracker_bus_fd_sparql_update (connection, sparql);
- } else {
- tracker_bus_fd_sparql_batch_update (connection, sparql);
- }
- } catch (DBus.Error e) {
- throw new Sparql.Error.INTERNAL (e.message);
- }
+ // use separate main context for sync operation
+ var context = new MainContext ();
+ var loop = new MainLoop (context, false);
+ context.push_thread_default ();
+ AsyncResult async_res = null;
+ update_async.begin (sparql, priority, cancellable, (o, res) => {
+ async_res = res;
+ loop.quit ();
+ });
+ loop.run ();
+ context.pop_thread_default ();
+ update_async.end (async_res);
}
public async override void update_async (string sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError {
try {
+ UnixInputStream input;
+ UnixOutputStream output;
+ pipe (out input, out output);
+
+ // send D-Bus request
+ AsyncResult dbus_res = null;
+ bool sent_update = false;
+ steroids_object.update_begin (input, priority, cancellable, (o, res) => {
+ dbus_res = res;
+ if (sent_update) {
+ update_async.callback ();
+ }
+ });
+
+ // send sparql string via fd
+ var data_stream = new DataOutputStream (output);
+ data_stream.set_byte_order (DataStreamByteOrder.HOST_ENDIAN);
+ data_stream.put_int32 ((int32) sparql.length);
+ data_stream.put_string (sparql);
+ data_stream = null;
+
+ // wait for D-Bus reply
+ sent_update = true;
+ if (dbus_res == null) {
+ yield;
+ }
+
if (priority >= GLib.Priority.DEFAULT) {
- yield tracker_bus_fd_sparql_update_async (connection, sparql, cancellable);
+ steroids_object.update.end (dbus_res);
} else {
- yield tracker_bus_fd_sparql_batch_update_async (connection, sparql, cancellable);
+ steroids_object.batch_update.end (dbus_res);
}
- } catch (DBus.Error e) {
+ } catch (DBusError e) {
throw new Sparql.Error.INTERNAL (e.message);
}
}
- public async override GLib.PtrArray? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError {
+ public async override GenericArray<Error?> update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError {
try {
- // helper variable necessary to work around bug in vala < 0.11
- PtrArray result;
+ UnixInputStream input;
+ UnixOutputStream output;
+ pipe (out input, out output);
+
+ // send D-Bus request
+ AsyncResult dbus_res = null;
+ bool sent_update = false;
+ steroids_object.update_array_begin (input, priority, cancellable, (o, res) => {
+ dbus_res = res;
+ if (sent_update) {
+ update_array_async.callback ();
+ }
+ });
+
+ // send sparql strings via fd
+ var data_stream = new DataOutputStream (output);
+ data_stream.set_byte_order (DataStreamByteOrder.HOST_ENDIAN);
+ data_stream.put_int32 ((int32) sparql.length);
+ for (int i = 0; i < sparql.length; i++) {
+ data_stream.put_int32 ((int32) sparql[i].length);
+ data_stream.put_string (sparql[i]);
+ }
+ data_stream = null;
+
+ // wait for D-Bus reply
+ sent_update = true;
+ if (dbus_res == null) {
+ yield;
+ }
+
+ // process results (errors)
+ var result = new GenericArray<Error?> ();
+ Variant resultv;
if (priority >= GLib.Priority.DEFAULT) {
- result = yield tracker_bus_fd_sparql_update_array_async (connection, sparql, cancellable);
+ resultv = steroids_object.update_array.end (dbus_res);
} else {
- result = yield tracker_bus_fd_sparql_batch_update_array_async (connection, sparql, cancellable);
+ resultv = steroids_object.batch_update_array.end (dbus_res);
+ }
+ var iter = resultv.iterator ();
+ string code, message;
+ while (iter.next ("s", out code)) {
+ if (iter.next ("s", out message)) {
+ if (code != "" && message != "") {
+ result.add (new Sparql.Error.INTERNAL (message));
+ } else {
+ result.add (null);
+ }
+ }
}
return result;
- } catch (DBus.Error e) {
+ } catch (DBusError e) {
throw new Sparql.Error.INTERNAL (e.message);
}
}
public override GLib.Variant? update_blank (string sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError {
- try {
- GLib.Variant res = null;
- res = tracker_bus_fd_sparql_update_blank (connection, sparql);
- return res;
- } catch (DBus.Error e) {
- throw new Sparql.Error.INTERNAL (e.message);
- }
+ // use separate main context for sync operation
+ var context = new MainContext ();
+ var loop = new MainLoop (context, false);
+ context.push_thread_default ();
+ AsyncResult async_res = null;
+ update_blank_async.begin (sparql, priority, cancellable, (o, res) => {
+ async_res = res;
+ loop.quit ();
+ });
+ loop.run ();
+ context.pop_thread_default ();
+ return update_blank_async.end (async_res);
}
public async override GLib.Variant? update_blank_async (string sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError {
try {
- GLib.Variant res = null;
- res = yield tracker_bus_fd_sparql_update_blank_async (connection, sparql, cancellable);
- return res;
- } catch (DBus.Error e) {
+ UnixInputStream input;
+ UnixOutputStream output;
+ pipe (out input, out output);
+
+ // send D-Bus request
+ AsyncResult dbus_res = null;
+ bool sent_update = false;
+ steroids_object.update_blank.begin (input, cancellable, (o, res) => {
+ dbus_res = res;
+ if (sent_update) {
+ update_blank_async.callback ();
+ }
+ });
+
+ // send sparql strings via fd
+ var data_stream = new DataOutputStream (output);
+ data_stream.set_byte_order (DataStreamByteOrder.HOST_ENDIAN);
+ data_stream.put_int32 ((int32) sparql.length);
+ data_stream.put_string (sparql);
+ data_stream = null;
+
+ // wait for D-Bus reply
+ sent_update = true;
+ if (dbus_res == null) {
+ yield;
+ }
+
+ return steroids_object.update_blank.end (dbus_res);
+ } catch (DBusError e) {
throw new Sparql.Error.INTERNAL (e.message);
}
}
public override void load (File file, Cancellable? cancellable = null) throws Sparql.Error, IOError {
try {
- resources_object.load (file.get_uri ());
+ resources_object.load (file.get_uri (), cancellable);
if (cancellable != null && cancellable.is_cancelled ()) {
throw new IOError.CANCELLED ("Operation was cancelled");
}
- } catch (DBus.Error e) {
+ } catch (DBusError e) {
throw new Sparql.Error.INTERNAL (e.message);
}
}
public async override void load_async (File file, Cancellable? cancellable = null) throws Sparql.Error, IOError {
try {
- yield resources_object.load_async (file.get_uri ());
+ yield resources_object.load_async (file.get_uri (), cancellable);
if (cancellable != null && cancellable.is_cancelled ()) {
throw new IOError.CANCELLED ("Operation was cancelled");
}
- } catch (DBus.Error e) {
+ } catch (DBusError e) {
throw new Sparql.Error.INTERNAL (e.message);
}
}
public override Sparql.Cursor? statistics (Cancellable? cancellable = null) throws Sparql.Error, IOError {
try {
- string[,] results = statistics_object.Get ();
+ string[,] results = statistics_object.Get (cancellable);
Sparql.ValueType[] types = new Sparql.ValueType[2];
string[] var_names = new string[2];
- if (cancellable != null && cancellable.is_cancelled ()) {
- throw new IOError.CANCELLED ("Operation was cancelled");
- }
-
var_names[0] = "class";
var_names[1] = "count";
types[0] = Sparql.ValueType.STRING;
@@ -185,21 +355,17 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
results.length[1],
var_names,
types);
- } catch (DBus.Error e) {
+ } catch (DBusError e) {
throw new Sparql.Error.INTERNAL (e.message);
}
}
public async override Sparql.Cursor? statistics_async (Cancellable? cancellable = null) throws Sparql.Error, IOError {
try {
- string[,] results = yield statistics_object.Get_async ();
+ string[,] results = yield statistics_object.Get_async (cancellable);
Sparql.ValueType[] types = new Sparql.ValueType[2];
string[] var_names = new string[2];
- if (cancellable != null && cancellable.is_cancelled ()) {
- throw new IOError.CANCELLED ("Operation was cancelled");
- }
-
var_names[0] = "class";
var_names[1] = "count";
types[0] = Sparql.ValueType.STRING;
@@ -210,7 +376,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
results.length[1],
var_names,
types);
- } catch (DBus.Error e) {
+ } catch (DBusError e) {
throw new Sparql.Error.INTERNAL (e.message);
}
}
diff --git a/src/libtracker-client/tracker-sparql-query.vapi b/src/libtracker-client/tracker-sparql-query.vapi
new file mode 100644
index 0000000..58dee4b
--- /dev/null
+++ b/src/libtracker-client/tracker-sparql-query.vapi
@@ -0,0 +1,52 @@
+/* tracker-sparql-query.vapi generated by valac 0.10.0, do not modify. */
+
+[CCode (cprefix = "Tracker", lower_case_cprefix = "tracker_")]
+namespace Tracker {
+ [CCode (cheader_filename = "libtracker-client/tracker-sparql-builder.h")]
+ public class SparqlBuilder : GLib.Object {
+ [CCode (cprefix = "TRACKER_SPARQL_BUILDER_STATE_", cheader_filename = "libtracker-client/tracker-sparql-builder.h")]
+ public enum State {
+ UPDATE,
+ INSERT,
+ DELETE,
+ SUBJECT,
+ PREDICATE,
+ OBJECT,
+ BLANK,
+ WHERE,
+ EMBEDDED_INSERT
+ }
+ public SparqlBuilder ();
+ public void append (string raw);
+ public void delete_close ();
+ public void delete_open (string? graph);
+ public void drop_graph (string iri);
+ public SparqlBuilder.embedded_insert ();
+ public void insert_close ();
+ public void insert_open (string? graph);
+ public void insert_silent_open (string? graph);
+ public void object (string s);
+ public void object_blank_close ();
+ public void object_blank_open ();
+ public void object_boolean (bool literal);
+ public void object_date (ref time_t literal);
+ public void object_double (double literal);
+ public void object_int64 (int64 literal);
+ public void object_iri (string iri);
+ public void object_string (string literal);
+ public void object_unvalidated (string value);
+ public void object_variable (string var_name);
+ public void predicate (string s);
+ public void predicate_iri (string iri);
+ public void prepend (string raw);
+ public void subject (string s);
+ public void subject_iri (string iri);
+ public void subject_variable (string var_name);
+ public SparqlBuilder.update ();
+ public void where_close ();
+ public void where_open ();
+ public int length { get; set; }
+ public string result { get; }
+ public Tracker.SparqlBuilder.State state { get; }
+ }
+}
diff --git a/src/libtracker-common/tracker-dbus.h b/src/libtracker-common/tracker-dbus.h
index 7890b03..3053df3 100644
--- a/src/libtracker-common/tracker-dbus.h
+++ b/src/libtracker-common/tracker-dbus.h
@@ -179,6 +179,7 @@ void tracker_dbus_request_unblock_hooks (void);
void tracker_dbus_enable_client_lookup (gboolean enable);
+#ifndef NO_LIBDBUS
/* File descriptor convenience API */
gboolean tracker_dbus_send_and_splice (DBusConnection *connection,
DBusMessage *message,
@@ -196,6 +197,7 @@ gboolean tracker_dbus_send_and_splice_async (DBusConnection
GCancellable *cancellable,
TrackerDBusSendAndSpliceCallback callback,
gpointer user_data);
+#endif
G_END_DECLS
diff --git a/src/libtracker-direct/Makefile.am b/src/libtracker-direct/Makefile.am
index eb92ee4..64fe2b4 100644
--- a/src/libtracker-direct/Makefile.am
+++ b/src/libtracker-direct/Makefile.am
@@ -8,10 +8,8 @@ AM_VALAFLAGS = \
--includedir=libtracker-direct \
--header tracker-direct.h \
--vapi tracker-direct.vapi \
- --pkg gio-2.0 --pkg dbus-glib-1 \
+ --pkg gio-2.0 \
$(BUILD_VALAFLAGS) \
- $(top_srcdir)/src/vapi/posix.vapi \
- $(top_srcdir)/src/vapi/glib-2.0-fixes.vapi \
$(top_srcdir)/src/libtracker-data/libtracker-data.vapi \
$(top_srcdir)/src/libtracker-data/tracker-sparql-query.vapi \
$(top_srcdir)/src/libtracker-common/libtracker-common.vapi \
diff --git a/src/libtracker-sparql/Makefile.am b/src/libtracker-sparql/Makefile.am
index 78d40d2..500962d 100644
--- a/src/libtracker-sparql/Makefile.am
+++ b/src/libtracker-sparql/Makefile.am
@@ -8,10 +8,9 @@ AM_VALAFLAGS = \
--includedir=libtracker-sparql \
--header tracker-sparql.h \
--vapi tracker-sparql-$(TRACKER_API_VERSION).vapi \
- --pkg gio-2.0 --pkg gmodule-2.0 --pkg dbus-glib-1 \
+ --pkg gio-2.0 --pkg gmodule-2.0 --pkg posix \
$(BUILD_VALAFLAGS) \
config.vapi \
- $(top_srcdir)/src/vapi/posix.vapi \
$(top_srcdir)/src/vapi/glib-2.0-fixes.vapi
AM_CPPFLAGS = \
diff --git a/src/libtracker-sparql/tracker-backend.vala b/src/libtracker-sparql/tracker-backend.vala
index 8595596..71706ad 100644
--- a/src/libtracker-sparql/tracker-backend.vala
+++ b/src/libtracker-sparql/tracker-backend.vala
@@ -17,11 +17,11 @@
* Boston, MA 02110-1301, USA.
*/
-[DBus (name = "org.freedesktop.Tracker1.Status", timeout = 2147483647 /* INT_MAX */)]
-interface Tracker.Backend.Status : GLib.Object {
- public abstract void wait () throws DBus.Error;
+[DBus (name = "org.freedesktop.Tracker1.Status")]
+interface Tracker.Backend.Status : DBusProxy {
+ public abstract void wait () throws DBusError;
[DBus (name = "Wait")]
- public abstract async void wait_async () throws DBus.Error;
+ public abstract async void wait_async () throws DBusError;
}
class Tracker.Sparql.Backend : Connection {
@@ -60,16 +60,16 @@ class Tracker.Sparql.Backend : Connection {
public override void init () throws Sparql.Error
requires (is_constructed) {
try {
- var connection = DBus.Bus.get (DBus.BusType.SESSION);
- var status = (Tracker.Backend.Status) connection.get_object (TRACKER_DBUS_SERVICE,
- TRACKER_DBUS_OBJECT_STATUS,
- TRACKER_DBUS_INTERFACE_STATUS);
+ Tracker.Backend.Status status = Bus.get_proxy_sync (BusType.SESSION,
+ TRACKER_DBUS_SERVICE,
+ TRACKER_DBUS_OBJECT_STATUS);
+ status.set_default_timeout (int.MAX);
// Makes sure the sevice is available
debug ("Waiting for service to become available synchronously...");
status.wait ();
debug ("Service is ready");
- } catch (DBus.Error e) {
+ } catch (DBusError e) {
warning ("Could not connect to D-Bus service:'%s': %s", TRACKER_DBUS_INTERFACE_RESOURCES, e.message);
throw new Sparql.Error.INTERNAL (e.message);
}
@@ -80,16 +80,16 @@ class Tracker.Sparql.Backend : Connection {
public async override void init_async () throws Sparql.Error
requires (is_constructed) {
try {
- var connection = DBus.Bus.get (DBus.BusType.SESSION);
- var status = (Tracker.Backend.Status) connection.get_object (TRACKER_DBUS_SERVICE,
- TRACKER_DBUS_OBJECT_STATUS,
- TRACKER_DBUS_INTERFACE_STATUS);
+ Tracker.Backend.Status status = Bus.get_proxy_sync (BusType.SESSION,
+ TRACKER_DBUS_SERVICE,
+ TRACKER_DBUS_OBJECT_STATUS);
+ status.set_default_timeout (int.MAX);
// Makes sure the sevice is available
debug ("Waiting for service to become available asynchronously...");
yield status.wait_async ();
debug ("Service is ready");
- } catch (DBus.Error e) {
+ } catch (DBusError e) {
warning ("Could not connect to D-Bus service:'%s': %s", TRACKER_DBUS_INTERFACE_RESOURCES, e.message);
throw new Sparql.Error.INTERNAL (e.message);
}
@@ -135,7 +135,7 @@ class Tracker.Sparql.Backend : Connection {
yield bus.update_async (sparql, priority, cancellable);
}
- public async override GLib.PtrArray? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError
+ public async override GenericArray<Error?> update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError
requires (bus != null) {
return yield bus.update_array_async (sparql, priority, cancellable);
}
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index f1f030a..a48ef60 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -60,7 +60,7 @@ public const string TRACKER_DBUS_OBJECT_STEROIDS = "/org/freedesktop/Tracker1/St
*
* Since: 0.10
*/
-[DBus (name = "org.freedesktop.DBus.GLib.UnmappedError.TrackerSparqlErrorQuark")]
+[DBus (name = "org.freedesktop.Tracker1.SparqlError")]
public errordomain Tracker.Sparql.Error {
PARSE,
UNKNOWN_CLASS,
@@ -487,7 +487,7 @@ public abstract class Tracker.Sparql.Connection : Object {
*
* Since: 0.10
*/
- public async virtual GLib.PtrArray? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError {
+ public async virtual GenericArray<Error?> update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError {
warning ("Interface 'update_array_async' not implemented");
return null;
}
diff --git a/src/miners/flickr/tracker-sparql-builder.h b/src/miners/flickr/tracker-sparql-builder.h
new file mode 100644
index 0000000..c05cf66
--- /dev/null
+++ b/src/miners/flickr/tracker-sparql-builder.h
@@ -0,0 +1,58 @@
+/* tracker-sparql-builder.h generated by valac 0.10.0, the Vala compiler, do not modify */
+
+
+#ifndef __TRACKER_SPARQL_BUILDER_H__
+#define __TRACKER_SPARQL_BUILDER_H__
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+#include <libtracker-miner/tracker-miner.h>
+#include <libtracker-sparql/tracker-sparql.h>
+#include <float.h>
+#include <math.h>
+
+G_BEGIN_DECLS
+
+
+#define TRACKER_TYPE_MINER_FLICKR (tracker_miner_flickr_get_type ())
+#define TRACKER_MINER_FLICKR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_TYPE_MINER_FLICKR, TrackerMinerFlickr))
+#define TRACKER_MINER_FLICKR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRACKER_TYPE_MINER_FLICKR, TrackerMinerFlickrClass))
+#define TRACKER_IS_MINER_FLICKR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRACKER_TYPE_MINER_FLICKR))
+#define TRACKER_IS_MINER_FLICKR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TYPE_MINER_FLICKR))
+#define TRACKER_MINER_FLICKR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TRACKER_TYPE_MINER_FLICKR, TrackerMinerFlickrClass))
+
+typedef struct _TrackerMinerFlickr TrackerMinerFlickr;
+typedef struct _TrackerMinerFlickrClass TrackerMinerFlickrClass;
+typedef struct _TrackerMinerFlickrPrivate TrackerMinerFlickrPrivate;
+
+typedef void (*TrackerWritebackCallback) (GHashTable* resources, void* user_data);
+struct _TrackerMinerFlickr {
+ TrackerMinerWeb parent_instance;
+ TrackerMinerFlickrPrivate * priv;
+};
+
+struct _TrackerMinerFlickrClass {
+ TrackerMinerWebClass parent_class;
+};
+
+
+void tracker_writeback_init (void);
+void tracker_writeback_shutdown (void);
+guint tracker_writeback_connect (TrackerWritebackCallback callback, void* callback_target, void* user_data);
+void tracker_writeback_disconnect (guint handle);
+GType tracker_miner_flickr_get_type (void) G_GNUC_CONST;
+void tracker_miner_flickr_shutdown (TrackerMinerFlickr* self);
+void tracker_miner_flickr_writeback (TrackerMinerFlickr* self, GHashTable* properties);
+void tracker_miner_flickr_update_triple_string (TrackerMinerFlickr* self, TrackerSparqlBuilder* builder, const char* graph, const char* urn, const char* property, const char* new_value);
+void tracker_miner_flickr_update_triple_object (TrackerMinerFlickr* self, TrackerSparqlBuilder* builder, const char* graph, const char* urn, const char* property, const char* new_value);
+void tracker_miner_flickr_update_triple_double (TrackerMinerFlickr* self, TrackerSparqlBuilder* builder, const char* graph, const char* urn, const char* property, double new_value);
+void tracker_miner_flickr_update_triple_int64 (TrackerMinerFlickr* self, TrackerSparqlBuilder* builder, const char* graph, const char* urn, const char* property, gint64 new_value);
+void tracker_miner_flickr_main (char** args, int args_length1);
+TrackerMinerFlickr* tracker_miner_flickr_new (void);
+TrackerMinerFlickr* tracker_miner_flickr_construct (GType object_type);
+
+
+G_END_DECLS
+
+#endif
diff --git a/src/miners/flickr/tracker-sparql-query.vapi b/src/miners/flickr/tracker-sparql-query.vapi
new file mode 100644
index 0000000..5c34cec
--- /dev/null
+++ b/src/miners/flickr/tracker-sparql-query.vapi
@@ -0,0 +1,30 @@
+/* tracker-sparql-query.vapi generated by valac 0.10.0, do not modify. */
+
+[CCode (cprefix = "Tracker", lower_case_cprefix = "tracker_")]
+namespace Tracker {
+ [CCode (cheader_filename = "libtracker-client/tracker-sparql-builder.h")]
+ public class MinerFlickr : Tracker.MinerWeb {
+ public MinerFlickr ();
+ public override void associate (GLib.HashTable<string,string> association_data) throws Tracker.MinerWebError;
+ public override void authenticate () throws Tracker.MinerWebError;
+ public override void dissociate () throws Tracker.MinerWebError;
+ public override GLib.HashTable<string,string> get_association_data () throws Tracker.MinerWebError;
+ public static void main (string[] args);
+ public void shutdown ();
+ public void update_triple_double (Tracker.Sparql.Builder builder, string graph, string urn, string property, double new_value);
+ public void update_triple_int64 (Tracker.Sparql.Builder builder, string graph, string urn, string property, int64 new_value);
+ public void update_triple_object (Tracker.Sparql.Builder builder, string graph, string urn, string property, string new_value);
+ public void update_triple_string (Tracker.Sparql.Builder builder, string graph, string urn, string property, string new_value);
+ public void writeback (GLib.HashTable<int,GLib.Array<int>?> properties);
+ }
+}
+[CCode (cheader_filename = "libtracker-client/tracker-sparql-builder.h")]
+public delegate void TrackerWritebackCallback (GLib.HashTable<string,weak void*> resources);
+[CCode (cheader_filename = "libtracker-client/tracker-sparql-builder.h")]
+public static void tracker_writeback_init ();
+[CCode (cheader_filename = "libtracker-client/tracker-sparql-builder.h")]
+public static void tracker_writeback_shutdown ();
+[CCode (cheader_filename = "libtracker-client/tracker-sparql-builder.h")]
+public static uint tracker_writeback_connect (TrackerWritebackCallback callback, void* user_data);
+[CCode (cheader_filename = "libtracker-client/tracker-sparql-builder.h")]
+public static void tracker_writeback_disconnect (uint handle);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]