[tracker/dbus-fd-experiment: 13/15] Steroids server: Implement SparqlUpdateBlank
- From: Adrien Bustany <abustany src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/dbus-fd-experiment: 13/15] Steroids server: Implement SparqlUpdateBlank
- Date: Thu, 3 Jun 2010 17:03:15 +0000 (UTC)
commit 8d5ac6fbe395b879c1232bd5049618c1923dc7e0
Author: Adrien Bustany <abustany gnome org>
Date: Thu Jun 3 12:49:15 2010 -0400
Steroids server: Implement SparqlUpdateBlank
src/tracker-store/tracker-steroids.c | 96 ++++++++++++++++++++++++++++++++--
1 files changed, 91 insertions(+), 5 deletions(-)
---
diff --git a/src/tracker-store/tracker-steroids.c b/src/tracker-store/tracker-steroids.c
index 30485a7..2122f78 100644
--- a/src/tracker-store/tracker-steroids.c
+++ b/src/tracker-store/tracker-steroids.c
@@ -266,6 +266,80 @@ update_callback (GError *error, gpointer user_data)
dbus_message_unref (reply);
}
+static void
+marshall_hash_table_item (gpointer key, gpointer value, gpointer user_data)
+{
+ DBusMessageIter *iter = user_data;
+ DBusMessageIter subiter;
+
+ dbus_message_iter_open_container (iter, DBUS_TYPE_DICT_ENTRY, NULL, &subiter);
+ dbus_message_iter_append_basic (&subiter, DBUS_TYPE_STRING, &key);
+ dbus_message_iter_append_basic (&subiter, DBUS_TYPE_STRING, &value);
+ dbus_message_iter_close_container (iter, &subiter);
+}
+
+static void
+marshall_hash_table (DBusMessageIter *iter, GHashTable *hash)
+{
+ DBusMessageIter subiter;
+
+ dbus_message_iter_open_container (iter, DBUS_TYPE_ARRAY, "{ss}", &subiter);
+ g_hash_table_foreach (hash, marshall_hash_table_item, &subiter);
+ dbus_message_iter_close_container (iter, &subiter);
+}
+
+static void
+update_blank_callback (GPtrArray *blank_nodes, GError *error, gpointer user_data)
+{
+ ClientInfo *info = user_data;
+ DBusMessage *reply;
+ int i, j;
+ /* Reply type is aaa{ss} */
+ DBusMessageIter iter;
+ DBusMessageIter subiter;
+ DBusMessageIter subsubiter;
+
+ if (info->fd) {
+ close (info->fd);
+ }
+
+ if (error) {
+ tracker_dbus_request_failed (info->request_id,
+ NULL,
+ &error,
+ NULL);
+ reply = dbus_message_new_error (info->call_message,
+ TRACKER_STEROIDS_INTERFACE ".UpdateBlankError",
+ error->message);
+ dbus_connection_send (info->connection, reply, NULL);
+ dbus_message_unref (reply);
+ return;
+ }
+
+ tracker_dbus_request_success (info->request_id,
+ NULL);
+ reply = dbus_message_new_method_return (info->call_message);
+ dbus_message_iter_init_append (reply, &iter);
+
+ dbus_message_iter_open_container (&iter, DBUS_TYPE_ARRAY, "aa{ss}", &subiter);
+ for (i = 0; i < blank_nodes->len; i++) {
+ GPtrArray *inner_array;
+ inner_array = g_ptr_array_index (blank_nodes, i);
+
+ dbus_message_iter_open_container (&subiter, DBUS_TYPE_ARRAY, "a{ss}", &subsubiter);
+ for (j = 0; j < inner_array->len; j++) {
+ GHashTable *hash = g_ptr_array_index (inner_array, j);
+
+ marshall_hash_table (&subsubiter, hash);
+ }
+ dbus_message_iter_close_container (&subiter, &subsubiter);
+ }
+ dbus_message_iter_close_container (&iter, &subiter);
+
+ dbus_connection_send (info->connection, reply, NULL);
+ dbus_message_unref (reply);
+}
+
static gpointer
query_inthread (TrackerDBCursor *cursor,
GError *error,
@@ -450,7 +524,8 @@ tracker_steroids_query (TrackerSteroids *steroids,
static void
tracker_steroids_update (TrackerSteroids *steroids,
DBusConnection *connection,
- DBusMessage *message)
+ DBusMessage *message,
+ gboolean update_blank)
{
DBusError dbus_error;
ClientInfo *info;
@@ -507,9 +582,15 @@ tracker_steroids_update (TrackerSteroids *steroids,
close (info->fd);
info->fd = 0;
- tracker_store_sparql_update (query, TRACKER_STORE_PRIORITY_HIGH, FALSE,
- update_callback, sender,
- info, destroy_client_info);
+ if (update_blank) {
+ tracker_store_sparql_update_blank (query, TRACKER_STORE_PRIORITY_HIGH,
+ update_blank_callback, sender,
+ info, destroy_client_info);
+ } else {
+ tracker_store_sparql_update (query, TRACKER_STORE_PRIORITY_HIGH, FALSE,
+ update_callback, sender,
+ info, destroy_client_info);
+ }
}
DBusHandlerResult
@@ -535,7 +616,12 @@ tracker_steroids_connection_filter (DBusConnection *connection,
}
if (!g_strcmp0 ("Update", dbus_message_get_member (message))) {
- tracker_steroids_update (steroids, connection, message);
+ tracker_steroids_update (steroids, connection, message, FALSE);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+
+ if (!g_strcmp0 ("UpdateBlank", dbus_message_get_member (message))) {
+ tracker_steroids_update (steroids, connection, message, TRUE);
return DBUS_HANDLER_RESULT_HANDLED;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]