telepathy-glib: future-account: add _set_connect_automatically function and property
Jonny Lamb
jonny at kemper.freedesktop.org
Thu May 10 07:41:18 PDT 2012
Module: telepathy-glib
Branch: master
Commit: 282a5314bd3c67be264295751c2f4893148e455d
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=282a5314bd3c67be264295751c2f4893148e455d
Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date: Fri Apr 27 09:14:36 2012 +0100
future-account: add _set_connect_automatically function and property
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
telepathy-glib/future-account.c | 42 +++++++++++++++++++++++++++++++++++++++
telepathy-glib/future-account.h | 3 ++
tests/dbus/future-account.c | 13 +++++++++--
3 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/telepathy-glib/future-account.c b/telepathy-glib/future-account.c
index 3f26ead..24443af 100644
--- a/telepathy-glib/future-account.c
+++ b/telepathy-glib/future-account.c
@@ -94,6 +94,7 @@ enum {
PROP_REQUESTED_STATUS,
PROP_REQUESTED_STATUS_MESSAGE,
PROP_ENABLED,
+ PROP_CONNECT_AUTOMATICALLY,
N_PROPS
};
@@ -194,6 +195,11 @@ tp_future_account_get_property (GObject *object,
g_value_set_boolean (value,
tp_asv_get_boolean (self->priv->properties, "Enabled", NULL));
break;
+ case PROP_CONNECT_AUTOMATICALLY:
+ g_value_set_boolean (value,
+ tp_asv_get_boolean (self->priv->properties, "ConnectAutomatically",
+ NULL));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -432,6 +438,19 @@ tp_future_account_class_init (TpFutureAccountClass *klass)
"Whether this account is enabled or not",
FALSE,
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+
+ /**
+ * TpFutureAccount:connect-automatically:
+ *
+ * Whether the account should connect automatically or not. To change this
+ * property, use tp_future_account_set_connect_automatically().
+ */
+ g_object_class_install_property (object_class, PROP_CONNECT_AUTOMATICALLY,
+ g_param_spec_boolean ("connect-automatically",
+ "ConnectAutomatically",
+ "Whether this account should connect automatically or not",
+ FALSE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}
/**
@@ -581,6 +600,29 @@ tp_future_account_set_enabled (TpFutureAccount *self,
}
/**
+ * tp_future_account_set_connect_automatically:
+ * @self: a #TpFutureAccount
+ * @connect_automatically: %TRUE if the account is to connect automatically
+ *
+ * Set the connect automatically property of the account on creation
+ * to @connect_automatically so that the account is brought online to
+ * the automatic presence.
+ */
+void
+tp_future_account_set_connect_automatically (TpFutureAccount *self,
+ gboolean connect_automatically)
+{
+ TpFutureAccountPrivate *priv;
+
+ g_return_if_fail (TP_IS_FUTURE_ACCOUNT (self));
+
+ priv = self->priv;
+
+ tp_asv_set_boolean (priv->properties, "ConnectAutomatically",
+ connect_automatically);
+}
+
+/**
* 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 15a2022..e8a4f33 100644
--- a/telepathy-glib/future-account.h
+++ b/telepathy-glib/future-account.h
@@ -78,6 +78,9 @@ void tp_future_account_set_requested_presence (TpFutureAccount *self,
void tp_future_account_set_enabled (TpFutureAccount *self,
gboolean enabled);
+void tp_future_account_set_connect_automatically (TpFutureAccount *self,
+ gboolean connect_automatically);
+
/* 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 dc8135e..4d4dc54 100644
--- a/tests/dbus/future-account.c
+++ b/tests/dbus/future-account.c
@@ -177,7 +177,7 @@ test_properties (Test *test,
gchar *icon_name, *nickname;
TpConnectionPresenceType presence_type;
gchar *presence_status, *presence_message;
- gboolean enabled;
+ gboolean enabled, connect_automatically;
test->account = tp_future_account_new (test->account_manager,
"gabble", "jabber");
@@ -239,14 +239,17 @@ test_properties (Test *test,
g_free (presence_status);
g_free (presence_message);
- /* now enabled */
+ /* now enabled and connect automatically */
tp_future_account_set_enabled (test->account, FALSE);
+ tp_future_account_set_connect_automatically (test->account, TRUE);
g_object_get (test->account,
"enabled", &enabled,
+ "connect-automatically", &connect_automatically,
NULL);
g_assert_cmpint (enabled, ==, FALSE);
+ g_assert_cmpint (connect_automatically, ==, TRUE);
}
static void
@@ -266,6 +269,7 @@ test_create_succeed (Test *test,
TP_CONNECTION_PRESENCE_TYPE_AVAILABLE, "available",
"Better call Saul!");
tp_future_account_set_enabled (test->account, TRUE);
+ tp_future_account_set_connect_automatically (test->account, TRUE);
tp_future_account_set_parameter_string (test->account,
"account", "walter at white.us");
@@ -289,13 +293,16 @@ 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), ==, 4);
+ g_assert_cmpuint (g_hash_table_size (test->am->create_properties), ==, 5);
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);
+ g_assert_cmpint (tp_asv_get_boolean (test->am->create_properties,
+ "ConnectAutomatically", 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