From c0ed3ce2fc4e905372ba44920e5fa6429c522c01 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Thu, 19 Sep 2013 13:44:29 +0200 Subject: [PATCH 3/3] write-mgr-file: write presences Bare copy from Gabble. https://bugs.freedesktop.org/show_bug.cgi?id=31108 --- src/write-mgr-file.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/write-mgr-file.c b/src/write-mgr-file.c index 09b28b3..7194688 100644 --- a/src/write-mgr-file.c +++ b/src/write-mgr-file.c @@ -275,6 +275,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, @@ -350,6 +389,8 @@ mgr_file_contents (const char *busname, TP_PROP_PROTOCOL_INTERFACE_AVATARS_MAXIMUM_AVATAR_BYTES, NULL)); + write_presence (f, section_name, props); + g_free (section_name); g_hash_table_unref (props); protocols = protocols->next; -- 1.8.3.1