[tracker/gdbus-porting] libtracker-common: Clean up FD passing code, use GDBus' APIs for errors



commit f4220619d8112070af85c33c3909608c6f0a286f
Author: Philip Van Hoof <philip codeminded be>
Date:   Thu Jan 6 15:37:01 2011 +0100

    libtracker-common: Clean up FD passing code, use GDBus' APIs for errors

 src/libtracker-common/tracker-dbus.c |   27 +++++++++------------------
 1 files changed, 9 insertions(+), 18 deletions(-)
---
diff --git a/src/libtracker-common/tracker-dbus.c b/src/libtracker-common/tracker-dbus.c
index be5359a..93cfead 100644
--- a/src/libtracker-common/tracker-dbus.c
+++ b/src/libtracker-common/tracker-dbus.c
@@ -50,7 +50,6 @@ typedef struct {
 	GInputStream *unix_input_stream;
 	GInputStream *buffered_input_stream;
 	GOutputStream *output_stream;
-	GDBusMessage *reply;
 	TrackerDBusSendAndSpliceCallback callback;
 	GCancellable *cancellable;
 	gpointer user_data;
@@ -496,9 +495,6 @@ send_and_splice_data_free (SendAndSpliceData *data)
 	if (data->cancellable) {
 		g_object_unref (data->cancellable);
 	}
-	if (data->reply) {
-		g_object_unref (data->reply);
-	}
 	g_slice_free (SendAndSpliceData, data);
 }
 
@@ -524,33 +520,24 @@ tracker_dbus_send_and_splice_async_finish (GObject      *source,
                                            gpointer      user_data)
 {
 	SendAndSpliceData *data = user_data;
+	GDBusMessage *reply;
 	GError *error = NULL;
 
-	data->reply = g_dbus_connection_send_message_with_reply_finish (G_DBUS_CONNECTION (source),
-	                                                                result, &error);
+	reply = g_dbus_connection_send_message_with_reply_finish (G_DBUS_CONNECTION (source),
+	                                                          result, &error);
 
 	if (!error) {
-		if (g_dbus_message_get_message_type (data->reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
-			gchar *print;
-
-			print = g_dbus_message_print (data->reply, 0);
-			g_set_error (&error,
-			             TRACKER_DBUS_ERROR,
-			             TRACKER_DBUS_ERROR_UNSUPPORTED,
-			             "%s", print);
-			g_free (print);
+		if (g_dbus_message_get_message_type (reply) == G_DBUS_MESSAGE_TYPE_ERROR) {
 
+			g_dbus_message_to_gerror (reply, &error);
 			g_free (g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (data->output_stream)));
-
 			(* data->callback) (NULL, -1, error, data->user_data);
-
 			g_error_free (error);
 		} else {
 			(* data->callback) (g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (data->output_stream)),
 			                    g_memory_output_stream_get_data_size (G_MEMORY_OUTPUT_STREAM (data->output_stream)),
 			                    NULL,
 			                    data->user_data);
-
 		}
 	} else {
 		g_free (g_memory_output_stream_get_data (G_MEMORY_OUTPUT_STREAM (data->output_stream)));
@@ -558,6 +545,10 @@ tracker_dbus_send_and_splice_async_finish (GObject      *source,
 		g_error_free (error);
 	}
 
+	if (reply) {
+		g_object_unref (reply);
+	}
+
 	send_and_splice_data_free (data);
 }
 



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