[tracker/multi-insert: 2/11] libtracker-sparql, -bus: Provide API skeleton for multi-insert
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/multi-insert: 2/11] libtracker-sparql, -bus: Provide API skeleton for multi-insert
- Date: Thu, 7 Oct 2010 12:43:45 +0000 (UTC)
commit 0f67e5e2b994e34e1eaf35ee758061bc59bf0f49
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Oct 5 17:46:46 2010 +0200
libtracker-sparql, -bus: Provide API skeleton for multi-insert
autogen.sh | 2 +-
src/libtracker-bus/tracker-bus-fd-update.c | 42 ++++++++++++++
src/libtracker-bus/tracker-bus-fd-update.h | 75 +++++++++++++++----------
src/libtracker-bus/tracker-bus-fd-update.vapi | 5 ++
src/libtracker-bus/tracker-bus.vala | 12 ++++
src/libtracker-sparql/tracker-backend.vala | 5 ++
src/libtracker-sparql/tracker-connection.vala | 6 ++
7 files changed, 116 insertions(+), 31 deletions(-)
---
diff --git a/autogen.sh b/autogen.sh
index b2cda32..4e919ac 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -8,7 +8,7 @@ test -z "$srcdir" && srcdir=.
PKG_NAME="tracker"
REQUIRED_AUTOMAKE_VERSION=1.11
-REQUIRED_VALA_VERSION=0.9.4
+REQUIRED_VALA_VERSION=0.9.5
(test -f $srcdir/configure.ac \
&& test -f $srcdir/README) || {
diff --git a/src/libtracker-bus/tracker-bus-fd-update.c b/src/libtracker-bus/tracker-bus-fd-update.c
index a7baa13..6ee3ca1 100644
--- a/src/libtracker-bus/tracker-bus-fd-update.c
+++ b/src/libtracker-bus/tracker-bus-fd-update.c
@@ -396,6 +396,17 @@ tracker_bus_fd_sparql_update_async (DBusGConnection *connection,
}
void
+tracker_bus_fd_sparql_update_array_async (DBusGConnection *connection,
+ const char **queries,
+ guint queries_len,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ // todo
+}
+
+void
tracker_bus_fd_sparql_update_finish (GAsyncResult *res,
GError **error)
{
@@ -404,6 +415,7 @@ tracker_bus_fd_sparql_update_finish (GAsyncResult *res,
g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
+
GVariant *
tracker_bus_fd_sparql_update_blank_finish (GAsyncResult *res,
GError **error)
@@ -529,6 +541,18 @@ tracker_bus_fd_sparql_batch_update_async (DBusGConnection *connection,
}
}
+
+void
+tracker_bus_fd_sparql_batch_update_array_async (DBusGConnection *connection,
+ const char **queries,
+ guint queries_len,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ // todo
+}
+
void
tracker_bus_fd_sparql_batch_update_finish (GAsyncResult *res,
GError **error)
@@ -537,3 +561,21 @@ tracker_bus_fd_sparql_batch_update_finish (GAsyncResult *res,
g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
+
+GPtrArray*
+tracker_bus_fd_sparql_update_array_finish (GAsyncResult *res)
+{
+ g_return_if_fail (res != NULL);
+
+ // todo: check if ref is needed here
+ return g_ptr_array_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
+}
+
+GPtrArray*
+tracker_bus_fd_sparql_batch_update_array_finish (GAsyncResult *res)
+{
+ g_return_if_fail (res != NULL);
+
+ // todo: check if ref is needed here
+ return g_ptr_array_ref (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
+}
diff --git a/src/libtracker-bus/tracker-bus-fd-update.h b/src/libtracker-bus/tracker-bus-fd-update.h
index b844a13..46fdd46 100644
--- a/src/libtracker-bus/tracker-bus-fd-update.h
+++ b/src/libtracker-bus/tracker-bus-fd-update.h
@@ -23,35 +23,50 @@
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);
-GVariant * 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);
-void tracker_bus_fd_sparql_batch_update (DBusGConnection *connection,
- const char *query,
- GError **error);
-void tracker_bus_fd_sparql_batch_update_async (DBusGConnection *connection,
- const char *query,
- GCancellable *cancellable,
- GAsyncReadyCallback callback,
- gpointer user_data);
-void tracker_bus_fd_sparql_update_finish (GAsyncResult *res,
- GError **error);
-GVariant * tracker_bus_fd_sparql_update_blank_finish (GAsyncResult *res,
- GError **error);
-void tracker_bus_fd_sparql_batch_update_finish (GAsyncResult *res,
- GError **error);
+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);
+void tracker_bus_fd_sparql_update_array_async (DBusGConnection *connection,
+ const char **queries,
+ guint queries_len,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+GVariant * 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);
+void tracker_bus_fd_sparql_batch_update (DBusGConnection *connection,
+ const char *query,
+ GError **error);
+void tracker_bus_fd_sparql_batch_update_async (DBusGConnection *connection,
+ const char *query,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+void tracker_bus_fd_sparql_batch_update_array_async (DBusGConnection *connection,
+ const char **queries,
+ guint queries_len,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+void tracker_bus_fd_sparql_update_finish (GAsyncResult *res,
+ GError **error);
+GVariant * tracker_bus_fd_sparql_update_blank_finish (GAsyncResult *res,
+ GError **error);
+void tracker_bus_fd_sparql_batch_update_finish (GAsyncResult *res,
+ GError **error);
+
+GPtrArray* tracker_bus_fd_sparql_update_array_finish (GAsyncResult *res);
+GPtrArray* tracker_bus_fd_sparql_batch_update_array_finish (GAsyncResult *res);
G_END_DECLS
diff --git a/src/libtracker-bus/tracker-bus-fd-update.vapi b/src/libtracker-bus/tracker-bus-fd-update.vapi
index a94ed3d..e5f1dc2 100644
--- a/src/libtracker-bus/tracker-bus-fd-update.vapi
+++ b/src/libtracker-bus/tracker-bus-fd-update.vapi
@@ -29,3 +29,8 @@ public extern async void tracker_bus_fd_sparql_update_async (DBus.Connection con
public extern async GLib.Variant tracker_bus_fd_sparql_update_blank_async (DBus.Connection connection, string query, GLib.Cancellable? cancellable = null) throws Tracker.Sparql.Error, DBus.Error, GLib.IOError;
[CCode (cheader_filename = "tracker-bus-fd-update.h")]
public extern async void tracker_bus_fd_sparql_batch_update_async (DBus.Connection connection, string query, GLib.Cancellable? cancellable = null) throws Tracker.Sparql.Error, DBus.Error, GLib.IOError;
+
+[CCode (cheader_filename = "tracker-bus-fd-update.h")]
+public extern async GLib.PtrArray? tracker_bus_fd_sparql_update_array_async (DBus.Connection connection, string query[], GLib.Cancellable? cancellable = null);
+[CCode (cheader_filename = "tracker-bus-fd-update.h")]
+public extern async GLib.PtrArray? tracker_bus_fd_sparql_batch_update_array_async (DBus.Connection connection, string[] query, GLib.Cancellable? cancellable = null);
diff --git a/src/libtracker-bus/tracker-bus.vala b/src/libtracker-bus/tracker-bus.vala
index ce3f941..252785f 100644
--- a/src/libtracker-bus/tracker-bus.vala
+++ b/src/libtracker-bus/tracker-bus.vala
@@ -107,6 +107,18 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
}
}
+ public async override GLib.PtrArray? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) {
+ try {
+ if (priority >= GLib.Priority.DEFAULT) {
+ return yield tracker_bus_fd_sparql_update_array_async (connection, sparql, cancellable);
+ } else {
+ return yield tracker_bus_fd_sparql_batch_update_array_async (connection, sparql, cancellable);
+ }
+ } catch (DBus.Error e) {
+ critical (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;
diff --git a/src/libtracker-sparql/tracker-backend.vala b/src/libtracker-sparql/tracker-backend.vala
index dd07bb6..da34d21 100644
--- a/src/libtracker-sparql/tracker-backend.vala
+++ b/src/libtracker-sparql/tracker-backend.vala
@@ -135,6 +135,11 @@ 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)
+ requires (bus != null) {
+ return yield bus.update_array_async (sparql, priority, cancellable);
+ }
+
public async override GLib.Variant? update_blank_async (string sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) throws Sparql.Error, IOError
requires (bus != null) {
debug ("%s(priority:%d): '%s'", Log.METHOD, priority, sparql);
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index b11a614..2b7cb84 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -419,6 +419,12 @@ public abstract class Tracker.Sparql.Connection : Object {
warning ("Interface 'update_async' not implemented");
}
+ /* Private API */
+ public async virtual GLib.PtrArray? update_array_async (string[] sparql, int priority = GLib.Priority.DEFAULT, Cancellable? cancellable = null) {
+ warning ("Interface 'update_array_async' not implemented");
+ return null;
+ }
+
/**
* tracker_sparql_connection_update_blank:
* @self: a #TrackerSparqlConnection
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]