]> git.0d.be Git - empathy.git/commitdiff
empathy-tp-contact-factory: ensure that empathy_tp_contact_factory_get_from_handle...
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 11 Nov 2009 15:58:37 +0000 (15:58 +0000)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 11 Nov 2009 17:16:43 +0000 (17:16 +0000)
libempathy/empathy-tp-contact-factory.c

index 2acbdd99183677b7ff29cbe30a288826e0f4a805..d326626a1edde448f1580c66a7ee75f4166817c0 100644 (file)
@@ -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