[empathy/gnome-2-28] empathy-tp-contact-factory: ensure that empathy_tp_contact_factory_get_from_handle always return an



commit 05138abca45f3a9cb21112ac5ce32dda5f978061
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Nov 11 15:58:37 2009 +0000

    empathy-tp-contact-factory: ensure that empathy_tp_contact_factory_get_from_handle always return an error if the contact hasn't been created

 libempathy/empathy-tp-contact-factory.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c
index dd6b605..7b98331 100644
--- a/libempathy/empathy-tp-contact-factory.c
+++ b/libempathy/empathy-tp-contact-factory.c
@@ -1069,18 +1069,35 @@ get_contact_by_handle_cb (TpConnection *connection,
 {
 	GetContactsData *data = user_data;
 	EmpathyContact  *contact = NULL;
+	GError *err = NULL;
 
 	if (n_contacts == 1) {
 		contact = dup_contact_for_tp_contact (data->tp_factory,
 						      contacts[0]);
 	}
+	else {
+		if (error == NULL) {
+			/* tp-glib will provide an error only if the whole operation failed,
+			 * but not if, for example, the handle was invalid. We create an error
+			 * so the caller of empathy_tp_contact_factory_get_from_handle can
+			 * rely on the error to check if the operation succeeded or not. */
+
+			err = g_error_new_literal (TP_ERRORS, TP_ERROR_INVALID_HANDLE,
+						      "handle is invalid");
+		}
+		else {
+			err = g_error_copy (error);
+		}
+	}
 
 	if (data->callback.contact_cb) {
 		data->callback.contact_cb (data->tp_factory,
 				           contact,
-				           error,
+				           err,
 				           data->user_data, weak_object);
 	}
+
+	g_clear_error (&err);
 }
 
 void



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