summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-09-19 13:44:29 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2013-09-19 13:45:14 +0200
commitc0ed3ce2fc4e905372ba44920e5fa6429c522c01 (patch)
tree713197ec9147ca610cbecb7436e1d40da12a0584
parent0979408634389bb28853820c2f7cfc840f74c026 (diff)
downloadtelepathy-salut-c0ed3ce2fc4e905372ba44920e5fa6429c522c01.tar.gz
write-mgr-file: write presences
Bare copy from Gabble. https://bugs.freedesktop.org/show_bug.cgi?id=31108
-rw-r--r--src/write-mgr-file.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/write-mgr-file.c b/src/write-mgr-file.c
index 09b28b35..71946889 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;