From baa418e11bf914a99a5ce40d12c964cb394e0e63 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Thu, 20 Aug 2009 18:04:49 +0100 Subject: Set the RequestedPresence when creating a new command When we create a new account set the initial value of RequestedPresence to the global requested presence, but don't enable it by default. This will cause its requested presence to always be in sync with the rest of empathy. --- libempathy/empathy-account-settings.c | 37 ++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'libempathy/empathy-account-settings.c') diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c index 4bafac2c9..6d43c4788 100644 --- a/libempathy/empathy-account-settings.c +++ b/libempathy/empathy-account-settings.c @@ -23,6 +23,8 @@ #include #include +#include +#include #include "empathy-account-settings.h" #include "empathy-account-manager.h" @@ -942,8 +944,41 @@ empathy_account_settings_do_create_account (EmpathyAccountSettings *settings) { EmpathyAccountSettingsPriv *priv = GET_PRIV (settings); GHashTable *properties; + TpConnectionPresenceType type; + gchar *status; + gchar *message; - properties = g_hash_table_new (NULL, NULL); + properties = tp_asv_new (NULL, NULL); + + type = empathy_account_manager_get_requested_global_presence + (priv->account_manager, &status, &message); + + if (type != TP_CONNECTION_PRESENCE_TYPE_UNSET) + { + /* Create the account with the requested presence the same as the current + * global requested presence, but don't enable it */ + GValueArray *presence; + GValue vtype = { 0, }; + GValue vstatus = { 0, }; + GValue vmessage = { 0, }; + + presence = g_value_array_new (3); + + g_value_init (&vtype, G_TYPE_UINT); + g_value_set_uint (&vtype, type); + g_value_array_append (presence, &vtype); + + g_value_init (&vstatus, G_TYPE_STRING); + g_value_take_string (&vstatus, status); + g_value_array_append (presence, &vstatus); + + g_value_init (&vmessage, G_TYPE_STRING); + g_value_take_string (&vmessage, message); + g_value_array_append (presence, &vmessage); + + tp_asv_take_boxed (properties, TP_IFACE_ACCOUNT ".RequestedPresence", + TP_STRUCT_TYPE_SIMPLE_PRESENCE, presence); + } empathy_account_manager_create_account_async (priv->account_manager, priv->cm_name, priv->protocol, priv->display_name, -- cgit v1.2.3