[Telepathy-commits] [telepathy-glib/master] TpGroupMixin: if flags allow adding or removing a member, but the callback is NULL, raise error rather than segfaulting

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Mar 12 07:59:24 PDT 2009


---
 telepathy-glib/group-mixin.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/telepathy-glib/group-mixin.c b/telepathy-glib/group-mixin.c
index e7f9600..3a6f290 100644
--- a/telepathy-glib/group-mixin.c
+++ b/telepathy-glib/group-mixin.c
@@ -546,6 +546,12 @@ tp_group_mixin_add_members (GObject *obj,
           continue;
         }
 
+      if (mixin_cls->add_member == NULL)
+        {
+          g_set_error (error, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
+              "Adding members to this Group channel is not possible");
+          return FALSE;
+        }
       if (!mixin_cls->add_member (obj, handle, message, error))
         {
           return FALSE;
@@ -683,7 +689,7 @@ tp_group_mixin_remove_members_with_reason (GObject *obj,
     {
       handle = g_array_index (contacts, TpHandle, i);
 
-      if (mixin_cls->priv->remove_with_reason)
+      if (mixin_cls->priv->remove_with_reason != NULL)
         {
           if (!mixin_cls->priv->remove_with_reason (obj, handle, message,
                                                     reason, error))
@@ -691,13 +697,19 @@ tp_group_mixin_remove_members_with_reason (GObject *obj,
               return FALSE;
             }
         }
-      else
+      else if (mixin_cls->remove_member != NULL)
         {
           if (!mixin_cls->remove_member (obj, handle, message, error))
             {
               return FALSE;
             }
         }
+      else
+        {
+          g_set_error (error, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
+              "Removing contacts from this Group channel is not possible");
+          return FALSE;
+        }
     }
 
   return TRUE;
-- 
1.5.6.5




More information about the telepathy-commits mailing list