[empathy/mc5: 462/483] Set the RequestedPresence when creating a new command



commit baa418e11bf914a99a5ce40d12c964cb394e0e63
Author: Sjoerd Simons <sjoerd simons collabora co uk>
Date:   Thu Aug 20 18:04:49 2009 +0100

    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 files changed, 36 insertions(+), 1 deletions(-)
---
diff --git a/libempathy/empathy-account-settings.c b/libempathy/empathy-account-settings.c
index 4bafac2..6d43c47 100644
--- a/libempathy/empathy-account-settings.c
+++ b/libempathy/empathy-account-settings.c
@@ -23,6 +23,8 @@
 #include <stdlib.h>
 
 #include <telepathy-glib/util.h>
+#include <telepathy-glib/interfaces.h>
+#include <telepathy-glib/gtypes.h>
 
 #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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]