telepathy-glib: future-account: add set_enabled function and : enabled property
Jonny Lamb
jonny at kemper.freedesktop.org
Thu May 10 07:41:18 PDT 2012
Module: telepathy-glib
Branch: master
Commit: 81d3a71c8043bf7892a7ebaa048c0297bfbec745
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=81d3a71c8043bf7892a7ebaa048c0297bfbec745
Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date: Thu Apr 26 17:18:31 2012 +0100
future-account: add set_enabled function and :enabled property
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
telepathy-glib/future-account.c | 38 ++++++++++++++++++++++++++++++++++++++
telepathy-glib/future-account.h | 3 +++
tests/dbus/future-account.c | 15 ++++++++++++++-
3 files changed, 55 insertions(+), 1 deletions(-)
diff --git a/telepathy-glib/future-account.c b/telepathy-glib/future-account.c
index 3cb708f..3f26ead 100644
--- a/telepathy-glib/future-account.c
+++ b/telepathy-glib/future-account.c
@@ -93,6 +93,7 @@ enum {
PROP_REQUESTED_PRESENCE_TYPE,
PROP_REQUESTED_STATUS,
PROP_REQUESTED_STATUS_MESSAGE,
+ PROP_ENABLED,
N_PROPS
};
@@ -189,6 +190,10 @@ tp_future_account_get_property (GObject *object,
g_value_set_string (value, "");
}
break;
+ case PROP_ENABLED:
+ g_value_set_boolean (value,
+ tp_asv_get_boolean (self->priv->properties, "Enabled", NULL));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -414,6 +419,19 @@ tp_future_account_class_init (TpFutureAccountClass *klass)
"The requested Status message string of the account",
NULL,
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+
+ /**
+ * TpFutureAccount:enabled:
+ *
+ * Whether the account is enabled or not. To change this property
+ * use tp_future_account_set_enabled().
+ */
+ g_object_class_install_property (object_class, PROP_ENABLED,
+ g_param_spec_boolean ("enabled",
+ "Enabled",
+ "Whether this account is enabled or not",
+ FALSE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}
/**
@@ -543,6 +561,26 @@ tp_future_account_set_requested_presence (TpFutureAccount *self,
}
/**
+ * tp_future_account_set_enabled:
+ * @self: a #TpFutureAccount
+ * @enabled: %TRUE if the account is to be enabled
+ *
+ * Set the enabled property of the account on creation to @enabled.
+ */
+void
+tp_future_account_set_enabled (TpFutureAccount *self,
+ gboolean enabled)
+{
+ TpFutureAccountPrivate *priv;
+
+ g_return_if_fail (TP_IS_FUTURE_ACCOUNT (self));
+
+ priv = self->priv;
+
+ tp_asv_set_boolean (priv->properties, "Enabled", enabled);
+}
+
+/**
* tp_future_account_set_parameter:
* @self: a #TpFutureAccount
* @key: the parameter key
diff --git a/telepathy-glib/future-account.h b/telepathy-glib/future-account.h
index 353ca38..15a2022 100644
--- a/telepathy-glib/future-account.h
+++ b/telepathy-glib/future-account.h
@@ -75,6 +75,9 @@ void tp_future_account_set_requested_presence (TpFutureAccount *self,
TpConnectionPresenceType presence,
const gchar *status, const gchar *message);
+void tp_future_account_set_enabled (TpFutureAccount *self,
+ gboolean enabled);
+
/* parameters */
void tp_future_account_set_parameter (TpFutureAccount *self,
const gchar *key, GVariant *value);
diff --git a/tests/dbus/future-account.c b/tests/dbus/future-account.c
index 21c9f56..dc8135e 100644
--- a/tests/dbus/future-account.c
+++ b/tests/dbus/future-account.c
@@ -177,6 +177,7 @@ test_properties (Test *test,
gchar *icon_name, *nickname;
TpConnectionPresenceType presence_type;
gchar *presence_status, *presence_message;
+ gboolean enabled;
test->account = tp_future_account_new (test->account_manager,
"gabble", "jabber");
@@ -237,6 +238,15 @@ test_properties (Test *test,
g_free (presence_status);
g_free (presence_message);
+
+ /* now enabled */
+ tp_future_account_set_enabled (test->account, FALSE);
+
+ g_object_get (test->account,
+ "enabled", &enabled,
+ NULL);
+
+ g_assert_cmpint (enabled, ==, FALSE);
}
static void
@@ -255,6 +265,7 @@ test_create_succeed (Test *test,
tp_future_account_set_requested_presence (test->account,
TP_CONNECTION_PRESENCE_TYPE_AVAILABLE, "available",
"Better call Saul!");
+ tp_future_account_set_enabled (test->account, TRUE);
tp_future_account_set_parameter_string (test->account,
"account", "walter at white.us");
@@ -278,11 +289,13 @@ test_create_succeed (Test *test,
==, "walter at white.us");
g_assert_cmpstr (tp_asv_get_string (test->am->create_parameters, "password"),
==, "holly");
- g_assert_cmpuint (g_hash_table_size (test->am->create_properties), ==, 3);
+ g_assert_cmpuint (g_hash_table_size (test->am->create_properties), ==, 4);
g_assert_cmpstr (tp_asv_get_string (test->am->create_properties, "Icon"),
==, "gasmask");
g_assert_cmpstr (tp_asv_get_string (test->am->create_properties, "Nickname"),
==, "Heisenberg");
+ g_assert_cmpint (tp_asv_get_boolean (test->am->create_properties, "Enabled", NULL),
+ ==, TRUE);
array = tp_asv_get_boxed (test->am->create_properties, "RequestedPresence",
TP_STRUCT_TYPE_SIMPLE_PRESENCE);
More information about the telepathy-commits
mailing list