summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2012-04-26 17:18:31 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-05-04 12:34:01 +0100
commit81d3a71c8043bf7892a7ebaa048c0297bfbec745 (patch)
tree3846ce5c4f22ad05dbfef0fad9c527ed31296d4f
parent7955221c201193e7e1a6e41966009121c5424b2a (diff)
future-account: add set_enabled function and :enabled property
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--telepathy-glib/future-account.c38
-rw-r--r--telepathy-glib/future-account.h3
-rw-r--r--tests/dbus/future-account.c15
3 files changed, 55 insertions, 1 deletions
diff --git a/telepathy-glib/future-account.c b/telepathy-glib/future-account.c
index 3cb708fa2..3f26ead0d 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 353ca3804..15a20228d 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 21c9f5669..dc8135e38 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@white.us");
@@ -278,11 +289,13 @@ test_create_succeed (Test *test,
==, "walter@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);