From: Guillaume Desmottes Date: Wed, 11 Nov 2009 15:58:37 +0000 (+0000) Subject: empathy-tp-contact-factory: ensure that empathy_tp_contact_factory_get_from_handle... X-Git-Url: https://git.0d.be/?p=empathy.git;a=commitdiff_plain;h=4950a9c2e79b6c92510c738283a2b40c936570d6 empathy-tp-contact-factory: ensure that empathy_tp_contact_factory_get_from_handle always return an error if the contact hasn't been created --- diff --git a/libempathy/empathy-tp-contact-factory.c b/libempathy/empathy-tp-contact-factory.c index 2acbdd99..d326626a 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