[Telepathy-commits] [telepathy-glib/master] TpPresenceMixin: warn if a CM sets an offline status to be available for setting on yourself

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Jan 29 03:41:19 PST 2009


---
 telepathy-glib/presence-mixin.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/telepathy-glib/presence-mixin.c b/telepathy-glib/presence-mixin.c
index 2270596..5e5fd90 100644
--- a/telepathy-glib/presence-mixin.c
+++ b/telepathy-glib/presence-mixin.c
@@ -216,6 +216,7 @@ tp_presence_mixin_class_init (GObjectClass *obj_cls,
                               const TpPresenceStatusSpec *statuses)
 {
   TpPresenceMixinClass *mixin_cls;
+  guint i;
 
   DEBUG ("called.");
 
@@ -235,6 +236,26 @@ tp_presence_mixin_class_init (GObjectClass *obj_cls,
   mixin_cls->get_contact_statuses = get_contact_statuses;
   mixin_cls->set_own_status = set_own_status;
   mixin_cls->statuses = statuses;
+
+  for (i = 0; statuses[i].name != NULL; i++)
+    {
+      if (statuses[i].self)
+        {
+          switch (statuses[i].presence_type)
+            {
+            case TP_CONNECTION_PRESENCE_TYPE_OFFLINE:
+            case TP_CONNECTION_PRESENCE_TYPE_UNKNOWN:
+            case TP_CONNECTION_PRESENCE_TYPE_ERROR:
+              g_warning ("Status \"%s\" of type %u should not be available "
+                  "to set on yourself", statuses[i].name,
+                  statuses[i].presence_type);
+              break;
+
+            default:
+              break;
+            }
+        }
+    }
 }
 
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list