[tracker/direct-access: 117/122] libtracker-bus: Fix updateblank support for non-fd-passing, added tests



commit 3578694107567d0fc79ae2555d9fffc7f62fd4a1
Author: Philip Van Hoof <philip codeminded be>
Date:   Mon Jul 26 10:33:12 2010 +0200

    libtracker-bus: Fix updateblank support for non-fd-passing, added tests

 src/libtracker-bus/tracker-bus-array-update.c  |   29 +++++-----------
 src/libtracker-bus/tracker-bus-fd-update.c     |    1 -
 src/libtracker-bus/tracker-bus-shared.c        |    2 +-
 tests/functional-tests/shared-update-test.vala |   41 +++++++++++++++++++++++-
 4 files changed, 50 insertions(+), 23 deletions(-)
---
diff --git a/src/libtracker-bus/tracker-bus-array-update.c b/src/libtracker-bus/tracker-bus-array-update.c
index d9701a7..c74adec 100644
--- a/src/libtracker-bus/tracker-bus-array-update.c
+++ b/src/libtracker-bus/tracker-bus-array-update.c
@@ -77,7 +77,8 @@ async_data_new (DBusConnection      *connection,
 	AsyncData *fad = g_slice_new0 (AsyncData);
 
 	fad->connection = dbus_connection_ref (connection);
-	fad->cancellable = g_object_ref (connection);
+	if (cancellable)
+		fad->cancellable = g_object_ref (cancellable);
 	fad->user_data = user_data;
 
 	return fad;
@@ -104,27 +105,15 @@ sparql_update_callback (DBusPendingCall *call,
 		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);
-
-		async_data_free (fad);
-
-		dbus_pending_call_unref (call);
-
-		return;
+	} else {
+		result = tracker_bus_message_to_variant (reply);
+		g_simple_async_result_set_op_res_gpointer (fad->res, result, NULL);
+		g_simple_async_result_complete (fad->res);
+		g_variant_unref (result);
 	}
 
-	result = tracker_bus_message_to_variant (reply);
-	g_simple_async_result_set_op_res_gpointer (fad->res, result, NULL);
-	g_simple_async_result_complete (fad->res);
-	dbus_message_unref (reply);
-	g_variant_unref (result);
-
-
 	/* Clean up */
 	dbus_message_unref (reply);
 
@@ -159,7 +148,7 @@ tracker_bus_array_sparql_update_blank_async (DBusGConnection       *connection,
 	message = dbus_message_new_method_call (TRACKER_DBUS_SERVICE,
 	                                        TRACKER_DBUS_OBJECT_RESOURCES,
 	                                        TRACKER_DBUS_INTERFACE_RESOURCES,
-	                                        "UpdateBlank");
+	                                        "SparqlUpdateBlank");
 
 	dbus_message_iter_init_append (message, &iter);
 	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &query);
@@ -200,7 +189,7 @@ tracker_bus_array_sparql_update_blank (DBusGConnection *connection,
 	message = dbus_message_new_method_call (TRACKER_DBUS_SERVICE,
 	                                        TRACKER_DBUS_OBJECT_RESOURCES,
 	                                        TRACKER_DBUS_INTERFACE_RESOURCES,
-	                                        "UpdateBlank");
+	                                        "SparqlUpdateBlank");
 
 	dbus_message_iter_init_append (message, &iter);
 	dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &query);
diff --git a/src/libtracker-bus/tracker-bus-fd-update.c b/src/libtracker-bus/tracker-bus-fd-update.c
index ab1b772..2838cef 100644
--- a/src/libtracker-bus/tracker-bus-fd-update.c
+++ b/src/libtracker-bus/tracker-bus-fd-update.c
@@ -154,7 +154,6 @@ sparql_update_fast_callback (DBusPendingCall *call,
 		result = tracker_bus_message_to_variant (reply);
 		g_simple_async_result_set_op_res_gpointer (fad->res, result, NULL);
 		g_simple_async_result_complete (fad->res);
-		dbus_message_unref (reply);
 		g_variant_unref (result);
 
 		break;
diff --git a/src/libtracker-bus/tracker-bus-shared.c b/src/libtracker-bus/tracker-bus-shared.c
index 938f671..fbfd1d5 100644
--- a/src/libtracker-bus/tracker-bus-shared.c
+++ b/src/libtracker-bus/tracker-bus-shared.c
@@ -72,7 +72,7 @@ tracker_bus_message_to_variant (DBusMessage *message)
 
 				g_variant_builder_add (&builder, "{ss}", key, value);
 
-				dbus_message_iter_next (&subiter);
+				dbus_message_iter_next (&s_subiter);
 
 				g_variant_builder_close (&builder);
 				g_variant_builder_close (&builder);
diff --git a/tests/functional-tests/shared-update-test.vala b/tests/functional-tests/shared-update-test.vala
index 3d6c57f..355f1be 100644
--- a/tests/functional-tests/shared-update-test.vala
+++ b/tests/functional-tests/shared-update-test.vala
@@ -30,6 +30,14 @@ public class TestApp : GLib.Object {
 		return (0);
 	}
 
+	int iter_variant (GLib.Variant variant) {
+
+		// TODO: Rest the return value, also check tracker_bus_message_to_variant
+		// in libtracker-bus/tracker-bus-shared.c
+
+		return 0;
+	}
+
 	void update_query () {
 		Cursor cursor;
 		int a;
@@ -48,7 +56,6 @@ public class TestApp : GLib.Object {
 			warning ("Couldn't query: %s", eb.message);
 			res = -1;
 		}
-
 	}
 
 	async void update_query_async () {
@@ -69,15 +76,47 @@ public class TestApp : GLib.Object {
 			warning ("Couldn't query: %s", eb.message);
 			res = -1;
 		}
+	}
+
+
+	string blank_query = "INSERT { _:a2 a nie:InformationElement  . _:b2 a nie:InformationElement . _:c2 a nie:InformationElement }";
+
+	void update_blank_query () {
+		GLib.Variant variant;
+		int a;
+
+		try {
+			variant = con.update_blank (blank_query);
+			a = iter_variant (variant);
+		} catch (Tracker.Sparql.Error ea) {
+			warning ("Couldn't update: %s", ea.message);
+			res = -1;
+		}
+	}
 
+
+
+	async void update_blank_query_async () {
+		GLib.Variant variant;
+		int a;
+
+		try {
+			variant = yield con.update_blank_async (blank_query);
+			a = iter_variant (variant);
+		} catch (Tracker.Sparql.Error ea) {
+			warning ("Couldn't update: %s", ea.message);
+			res = -1;
+		}
 	}
 
 	void do_sync_tests () {
 		update_query ();
+		update_blank_query ();
 	}
 
 	async void do_async_tests () {
 		yield update_query_async ();
+		yield update_blank_query_async ();
 
 		print ("Async tests done, now I can quit the mainloop\n");
 		loop.quit ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]