telepathy-gabble: write-mgr-file: write Presence properties

Guillaume Desmottes gdesmott at kemper.freedesktop.org
Wed Sep 18 05:58:39 PDT 2013


Module: telepathy-gabble
Branch: master
Commit: 1e173554d91bce1db263cf88d141fbbfdb5139e7
URL:    http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=1e173554d91bce1db263cf88d141fbbfdb5139e7

Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date:   Wed Sep 18 11:03:14 2013 +0200

write-mgr-file: write Presence properties

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

---

 src/write-mgr-file.c |   41 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/src/write-mgr-file.c b/src/write-mgr-file.c
index d0cddab..8670e43 100644
--- a/src/write-mgr-file.c
+++ b/src/write-mgr-file.c
@@ -277,6 +277,45 @@ write_rccs (GKeyFile *f, const gchar *section_name, GHashTable *props)
   g_strfreev (group_names);
 }
 
+static void
+write_presence (GKeyFile *f,
+    const gchar *section_name,
+    GHashTable *props)
+{
+  GHashTable *statuses;
+  GHashTableIter iter;
+  gpointer k, v;
+
+  statuses = tp_asv_get_boxed (props,
+      TP_PROP_PROTOCOL_INTERFACE_PRESENCE_STATUSES,
+      TP_HASH_TYPE_SIMPLE_STATUS_SPEC_MAP);
+  g_return_if_fail (statuses != NULL);
+
+  g_hash_table_iter_init (&iter, statuses);
+  while (g_hash_table_iter_next (&iter, &k, &v))
+    {
+      const gchar *id = k;
+      GValueArray *status = v;
+      TpConnectionPresenceType type;
+      gboolean may_set_on_self, can_have_msg;
+      gchar *key, *value;
+
+      key = g_strdup_printf("status-%s", id);
+
+      tp_value_array_unpack (status, 3, &type, &may_set_on_self, &can_have_msg);
+
+      value = g_strdup_printf ("%u%s%s",
+              type,
+              may_set_on_self ? " settable" : "",
+              can_have_msg ? " message" : "");
+
+      g_key_file_set_string (f, section_name, key, value);
+
+      g_free (key);
+      g_free (value);
+    }
+}
+
 static gchar *
 mgr_file_contents (const char *busname,
                    const char *objpath,
@@ -369,6 +408,8 @@ mgr_file_contents (const char *busname,
               TP_PROP_PROTOCOL_INTERFACE_AVATARS_MAXIMUM_AVATAR_BYTES,
               NULL));
 
+      write_presence (f, section_name, props);
+
       WRITE_STR (TP_PROP_PROTOCOL_VCARD_FIELD, "VCardField");
       WRITE_STR (TP_PROP_PROTOCOL_ENGLISH_NAME, "EnglishName");
       WRITE_STR (TP_PROP_PROTOCOL_ICON, "Icon");



More information about the telepathy-commits mailing list