[next] telepathy-glib: future-account: don't allow modifications if created /creating account

Jonny Lamb jonny at kemper.freedesktop.org
Fri May 11 02:41:39 PDT 2012


Module: telepathy-glib
Branch: next
Commit: 84e6c35146ce4749fe43743e22b25c4d35609c48
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=84e6c35146ce4749fe43743e22b25c4d35609c48

Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date:   Wed May  9 09:45:42 2012 +0100

future-account: don't allow modifications if created/creating account

Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>

---

 telepathy-glib/future-account.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/telepathy-glib/future-account.c b/telepathy-glib/future-account.c
index 98415f4..70759db 100644
--- a/telepathy-glib/future-account.c
+++ b/telepathy-glib/future-account.c
@@ -765,6 +765,8 @@ tp_future_account_set_display_name (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   g_free (priv->display_name);
   priv->display_name = g_strdup (name);
 }
@@ -790,6 +792,8 @@ tp_future_account_set_icon_name (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   tp_asv_set_string (priv->properties, TP_PROP_ACCOUNT_ICON, icon);
 }
 
@@ -814,6 +818,8 @@ tp_future_account_set_nickname (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   tp_asv_set_string (priv->properties, TP_PROP_ACCOUNT_NICKNAME, nickname);
 }
 
@@ -847,6 +853,8 @@ tp_future_account_set_requested_presence (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   value = tp_g_value_slice_new_take_boxed (TP_STRUCT_TYPE_SIMPLE_PRESENCE,
       dbus_g_type_specialized_construct (TP_STRUCT_TYPE_SIMPLE_PRESENCE));
   arr = (GValueArray *) g_value_get_boxed (value);
@@ -889,6 +897,8 @@ tp_future_account_set_automatic_presence (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   value = tp_g_value_slice_new_take_boxed (TP_STRUCT_TYPE_SIMPLE_PRESENCE,
       dbus_g_type_specialized_construct (TP_STRUCT_TYPE_SIMPLE_PRESENCE));
   arr = (GValueArray *) g_value_get_boxed (value);
@@ -922,6 +932,8 @@ tp_future_account_set_enabled (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   tp_asv_set_boolean (priv->properties, TP_PROP_ACCOUNT_ENABLED, enabled);
 }
 
@@ -948,6 +960,8 @@ tp_future_account_set_connect_automatically (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   tp_asv_set_boolean (priv->properties,
       TP_PROP_ACCOUNT_CONNECT_AUTOMATICALLY,
       connect_automatically);
@@ -978,6 +992,8 @@ tp_future_account_add_supersedes (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   array = tp_asv_get_boxed (priv->properties,
       TP_PROP_ACCOUNT_SUPERSEDES,
       TP_ARRAY_TYPE_OBJECT_PATH_LIST);
@@ -1025,6 +1041,8 @@ tp_future_account_set_avatar (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   tmp = g_array_new (FALSE, FALSE, sizeof (guchar));
 
   if (len > 0)
@@ -1070,6 +1088,8 @@ tp_future_account_set_parameter (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   dbus_g_value_parse_g_variant (value, &one);
   two = tp_g_value_slice_dup (&one);
 
@@ -1100,6 +1120,8 @@ tp_future_account_unset_parameter (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   g_hash_table_remove (priv->parameters, key);
 }
 
@@ -1127,6 +1149,8 @@ tp_future_account_set_parameter_string (TpFutureAccount *self,
 
   priv = self->priv;
 
+  g_return_if_fail (priv->result == NULL && !priv->created);
+
   g_hash_table_insert (priv->parameters, g_strdup (key),
       tp_g_value_slice_new_string (value));
 }
@@ -1236,7 +1260,13 @@ tp_future_account_create_account_async (TpFutureAccount *self,
     }
 
   if (priv->created)
-    WARNING ("trying to create an account which has already been created");
+    {
+      g_simple_async_report_error_in_idle (G_OBJECT (self),
+          callback, user_data,
+          TP_ERROR, TP_ERROR_NOT_AVAILABLE,
+          "This account has already been created");
+      return;
+    }
 
   priv->result = g_simple_async_result_new (G_OBJECT (self), callback, user_data,
       tp_future_account_create_account_async);



More information about the telepathy-commits mailing list