[next] telepathy-glib: future-account: add set_nickname
Jonny Lamb
jonny at kemper.freedesktop.org
Fri May 11 02:41:33 PDT 2012
Module: telepathy-glib
Branch: next
Commit: 0aa1bbd7d9081a48609e05dd2ab6885e30264919
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=0aa1bbd7d9081a48609e05dd2ab6885e30264919
Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date: Thu Apr 26 13:04:46 2012 +0100
future-account: add set_nickname
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 | 18 +++++++++++++++-
3 files changed, 61 insertions(+), 2 deletions(-)
diff --git a/telepathy-glib/future-account.c b/telepathy-glib/future-account.c
index b724391..ed6917c 100644
--- a/telepathy-glib/future-account.c
+++ b/telepathy-glib/future-account.c
@@ -88,6 +88,7 @@ enum {
PROP_PARAMETERS,
PROP_PROPERTIES,
PROP_ICON_NAME,
+ PROP_NICKNAME,
N_PROPS
};
@@ -144,7 +145,12 @@ tp_future_account_get_property (GObject *object,
g_value_set_boxed (value, self->priv->properties);
break;
case PROP_ICON_NAME:
- g_value_set_string (value, tp_asv_get_string (self->priv->properties, "Icon"));
+ g_value_set_string (value,
+ tp_asv_get_string (self->priv->properties, "Icon"));
+ break;
+ case PROP_NICKNAME:
+ g_value_set_string (value,
+ tp_asv_get_string (self->priv->properties, "Nickname"));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -316,6 +322,19 @@ tp_future_account_class_init (TpFutureAccountClass *klass)
"The account's icon name",
NULL,
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+
+ /**
+ * TpFutureAccount:nickname:
+ *
+ * The account's nickname. To change this property use
+ * tp_future_account_set_nickname().
+ */
+ g_object_class_install_property (object_class, PROP_NICKNAME,
+ g_param_spec_string ("nickname",
+ "Nickname",
+ "The account's nickname",
+ NULL,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}
/**
@@ -389,6 +408,27 @@ tp_future_account_set_icon_name (TpFutureAccount *self,
}
/**
+ * tp_future_account_set_nickname:
+ * @self: a #TpFutureAccount
+ * @nickname: a nickname for the account
+ *
+ * Set the nickname for the new account, @self, to @nickname.
+ */
+void
+tp_future_account_set_nickname (TpFutureAccount *self,
+ const gchar *nickname)
+{
+ TpFutureAccountPrivate *priv;
+
+ g_return_if_fail (TP_IS_FUTURE_ACCOUNT (self));
+ g_return_if_fail (nickname != NULL);
+
+ priv = self->priv;
+
+ tp_asv_set_string (priv->properties, "Nickname", nickname);
+}
+
+/**
* 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 e2266f3..ffd2580 100644
--- a/telepathy-glib/future-account.h
+++ b/telepathy-glib/future-account.h
@@ -68,6 +68,9 @@ void tp_future_account_set_display_name (TpFutureAccount *self,
void tp_future_account_set_icon_name (TpFutureAccount *self,
const gchar *icon);
+void tp_future_account_set_nickname (TpFutureAccount *self,
+ const gchar *nickname);
+
/* 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 9f0db69..5bf59e8 100644
--- a/tests/dbus/future-account.c
+++ b/tests/dbus/future-account.c
@@ -133,7 +133,7 @@ test_properties (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
GHashTable *props;
- gchar *icon_name;
+ gchar *icon_name, *nickname;
test->account = tp_future_account_new (test->account_manager,
"gabble", "jabber");
@@ -160,6 +160,22 @@ test_properties (Test *test,
g_hash_table_unref (props);
g_free (icon_name);
+
+ /* now set the nickname and try again */
+ tp_future_account_set_nickname (test->account, "Walter Jr.");
+
+ g_object_get (test->account,
+ "properties", &props,
+ "nickname", &nickname,
+ NULL);
+
+ g_assert_cmpuint (g_hash_table_size (props), ==, 2);
+ g_assert_cmpstr (tp_asv_get_string (props, "Icon"), ==, "user32.dll");
+ g_assert_cmpstr (tp_asv_get_string (props, "Nickname"), ==, "Walter Jr.");
+ g_assert_cmpstr (nickname, ==, "Walter Jr.");
+
+ g_hash_table_unref (props);
+ g_free (nickname);
}
int
More information about the telepathy-commits
mailing list