telepathy-mission-control: McdAccount: consolidate AutomaticPresence setting

Simon McVittie smcv at kemper.freedesktop.org
Wed Feb 13 06:45:04 PST 2013


Module: telepathy-mission-control
Branch: master
Commit: f2cfc78ac1a37cb9a85055602cf7c001045492bf
URL:    http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=f2cfc78ac1a37cb9a85055602cf7c001045492bf

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Tue Sep 11 18:42:22 2012 +0100

McdAccount: consolidate AutomaticPresence setting

---

 src/mcd-account.c |   42 +++++++++++++++---------------------------
 1 files changed, 15 insertions(+), 27 deletions(-)

diff --git a/src/mcd-account.c b/src/mcd-account.c
index addc0c0..031ed3f 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -1471,29 +1471,12 @@ set_automatic_presence (TpSvcDBusProperties *self,
 
     if (priv->auto_presence_type != type)
     {
-        GValue presence = G_VALUE_INIT;
-
-        g_value_init (&presence, G_TYPE_INT);
-        g_value_set_int (&presence, type);
-
-        mcd_storage_set_attribute (priv->storage, account_name,
-                                   MC_ACCOUNTS_KEY_AUTO_PRESENCE_TYPE,
-                                   &presence);
         priv->auto_presence_type = type;
         changed = TRUE;
     }
 
     if (tp_strdiff (priv->auto_presence_status, status))
     {
-        const gchar *new_status = NULL;
-
-        if (status != NULL && status[0] != 0)
-            new_status = status;
-
-        mcd_storage_set_string (priv->storage, account_name,
-                                MC_ACCOUNTS_KEY_AUTO_PRESENCE_STATUS,
-                                new_status);
-
         g_free (priv->auto_presence_status);
         priv->auto_presence_status = g_strdup (status);
         changed = TRUE;
@@ -1501,23 +1484,28 @@ set_automatic_presence (TpSvcDBusProperties *self,
 
     if (tp_strdiff (priv->auto_presence_message, message))
     {
-        const gchar *new_message = NULL;
-
-        if (!tp_str_empty (message))
-            new_message = message;
-
-        mcd_storage_set_string (priv->storage, account_name,
-                                MC_ACCOUNTS_KEY_AUTO_PRESENCE_MESSAGE,
-                                new_message);
-
         g_free (priv->auto_presence_message);
         priv->auto_presence_message = g_strdup (message);
         changed = TRUE;
     }
 
-
     if (changed)
     {
+        GValue presence = G_VALUE_INIT;
+
+        g_value_init (&presence, G_TYPE_INT);
+        g_value_set_int (&presence, priv->auto_presence_type);
+
+        mcd_storage_set_attribute (priv->storage, account_name,
+                                   MC_ACCOUNTS_KEY_AUTO_PRESENCE_TYPE,
+                                   &presence);
+        mcd_storage_set_string (priv->storage, account_name,
+                                MC_ACCOUNTS_KEY_AUTO_PRESENCE_STATUS,
+                                priv->auto_presence_status);
+        mcd_storage_set_string (priv->storage, account_name,
+                                MC_ACCOUNTS_KEY_AUTO_PRESENCE_MESSAGE,
+                                priv->auto_presence_message);
+
         mcd_storage_commit (priv->storage, account_name);
         mcd_account_changed_property (account, name, value);
     }



More information about the telepathy-commits mailing list