[next] telepathy-glib: TpPresenceMixinGetContactStatusesFunc: remove the GError argument

Xavier Claessens xclaesse at kemper.freedesktop.org
Thu Sep 6 04:30:51 PDT 2012


Module: telepathy-glib
Branch: next
Commit: e1bd85725106ee84a996823d8d5459b4e46eff26
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=e1bd85725106ee84a996823d8d5459b4e46eff26

Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Wed Jul 11 16:14:34 2012 +0200

TpPresenceMixinGetContactStatusesFunc: remove the GError argument

It is useless since handles are already guaranteed to be valid.

https://bugs.freedesktop.org/show_bug.cgi?id=21796

---

 examples/cm/call/conn.c         |    3 +-
 examples/cm/contactlist/conn.c  |    3 +-
 telepathy-glib/presence-mixin.c |   41 ++++++++++++++------------------------
 telepathy-glib/presence-mixin.h |    2 +-
 tests/lib/contacts-conn.c       |    3 +-
 5 files changed, 19 insertions(+), 33 deletions(-)

diff --git a/examples/cm/call/conn.c b/examples/cm/call/conn.c
index bc35a85..87c5485 100644
--- a/examples/cm/call/conn.c
+++ b/examples/cm/call/conn.c
@@ -242,8 +242,7 @@ status_available (GObject *object,
 
 static GHashTable *
 get_contact_statuses (GObject *object,
-    const GArray *contacts,
-    GError **error)
+    const GArray *contacts)
 {
   ExampleCallConnection *self =
     EXAMPLE_CALL_CONNECTION (object);
diff --git a/examples/cm/contactlist/conn.c b/examples/cm/contactlist/conn.c
index 651d796..b233b25 100644
--- a/examples/cm/contactlist/conn.c
+++ b/examples/cm/contactlist/conn.c
@@ -313,8 +313,7 @@ status_available (GObject *object,
 
 static GHashTable *
 get_contact_statuses (GObject *object,
-                      const GArray *contacts,
-                      GError **error)
+                      const GArray *contacts)
 {
   ExampleContactListConnection *self =
     EXAMPLE_CONTACT_LIST_CONNECTION (object);
diff --git a/telepathy-glib/presence-mixin.c b/telepathy-glib/presence-mixin.c
index e481903..f5776e5 100644
--- a/telepathy-glib/presence-mixin.c
+++ b/telepathy-glib/presence-mixin.c
@@ -150,7 +150,6 @@
  * TpPresenceMixinGetContactStatusesFunc:
  * @obj: An object with this mixin.
  * @contacts: An array of #TpHandle for the contacts to get presence status for
- * @error: Used to return a Telepathy D-Bus error if %NULL is returned
  *
  * Signature of the callback used to get the stored presence status of
  * contacts. The returned hash table should have contact handles mapped to
@@ -160,8 +159,7 @@
  * callback is responsible for ensuring that this does any cleanup that
  * may be necessary.
  *
- * Returns: (transfer full): The contact presence on success, %NULL with
- *  error set on error
+ * Returns: (transfer full): The contact presence, must not be %NULL.
  */
 
 /**
@@ -851,19 +849,6 @@ construct_presence_value_array (TpPresenceStatus *status,
   return presence;
 }
 
-static void
-construct_presence_hash_foreach (
-    GHashTable *presence_hash,
-    const TpPresenceStatusSpec *supported_statuses,
-    TpHandle handle,
-    TpPresenceStatus *status)
-{
-  GValueArray *presence;
-
-  presence = construct_presence_value_array (status, supported_statuses);
-  g_hash_table_insert (presence_hash, GUINT_TO_POINTER (handle), presence);
-}
-
 static GHashTable *
 construct_presence_hash (const TpPresenceStatusSpec *supported_statuses,
                          GHashTable *contact_statuses)
@@ -877,8 +862,12 @@ construct_presence_hash (const TpPresenceStatusSpec *supported_statuses,
 
   g_hash_table_iter_init (&iter, contact_statuses);
   while (g_hash_table_iter_next (&iter, &key, &value))
-    construct_presence_hash_foreach (presence_hash, supported_statuses,
-        GPOINTER_TO_UINT (key), value);
+    {
+      GValueArray *presence;
+
+      presence = construct_presence_value_array (value, supported_statuses);
+      g_hash_table_insert (presence_hash, key, presence);
+    }
 
   return presence_hash;
 }
@@ -928,12 +917,15 @@ tp_presence_mixin_get_presences (
       return;
     }
 
-  contact_statuses = mixin_cls->get_contact_statuses (obj, contacts, &error);
+  contact_statuses = mixin_cls->get_contact_statuses (obj, contacts);
 
   if (!contact_statuses)
     {
-      dbus_g_method_return_error (context, error);
-      g_error_free (error);
+      GError e = { TP_ERROR, TP_ERROR_CONFUSED,
+          "TpPresenceMixin::get_contact_statuses returned NULL - Broken CM" };
+
+      g_warning ("%s", e.message);
+      dbus_g_method_return_error (context, &e);
       return;
     }
 
@@ -977,14 +969,11 @@ tp_presence_mixin_fill_contact_attributes (GObject *obj,
   TpPresenceMixinClass *mixin_cls =
     TP_PRESENCE_MIXIN_CLASS (G_OBJECT_GET_CLASS (obj));
   GHashTable *contact_statuses;
-  GError *error = NULL;
-
-  contact_statuses = mixin_cls->get_contact_statuses (obj, contacts, &error);
 
+  contact_statuses = mixin_cls->get_contact_statuses (obj, contacts);
   if (contact_statuses == NULL)
     {
-      DEBUG ("get_contact_statuses failed: %s", error->message);
-      g_error_free (error);
+      g_warning ("get_contact_statuses returned NULL");
     }
   else
     {
diff --git a/telepathy-glib/presence-mixin.h b/telepathy-glib/presence-mixin.h
index bda9bc1..f94bf65 100644
--- a/telepathy-glib/presence-mixin.h
+++ b/telepathy-glib/presence-mixin.h
@@ -74,7 +74,7 @@ typedef gboolean (*TpPresenceMixinStatusAvailableFunc) (GObject *obj,
     guint which);
 
 typedef GHashTable *(*TpPresenceMixinGetContactStatusesFunc) (GObject *obj,
-    const GArray *contacts, GError **error);
+    const GArray *contacts);
 
 typedef gboolean (*TpPresenceMixinSetOwnStatusFunc) (GObject *obj,
     const TpPresenceStatus *status, GError **error);
diff --git a/tests/lib/contacts-conn.c b/tests/lib/contacts-conn.c
index 49b8c47..cda0020 100644
--- a/tests/lib/contacts-conn.c
+++ b/tests/lib/contacts-conn.c
@@ -460,8 +460,7 @@ my_status_available (GObject *object,
 
 static GHashTable *
 my_get_contact_statuses (GObject *object,
-                         const GArray *contacts,
-                         GError **error)
+                         const GArray *contacts)
 {
   TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (object);
   GHashTable *result = g_hash_table_new_full (g_direct_hash, g_direct_equal,



More information about the telepathy-commits mailing list