]> git.0d.be Git - empathy.git/commitdiff
Set the RequestedPresence when creating a new command
authorSjoerd Simons <sjoerd.simons@collabora.co.uk>
Thu, 20 Aug 2009 17:04:49 +0000 (18:04 +0100)
committerSjoerd Simons <sjoerd.simons@collabora.co.uk>
Thu, 20 Aug 2009 17:04:49 +0000 (18:04 +0100)
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

index 4bafac2c9ebe8c4321af5c5a53b2dd611ed3ccb7..6d43c478878dd6013c5b22084100312dc4c40d2f 100644 (file)
@@ -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,