[next] telepathy-glib: future-account: add set_display_name
Jonny Lamb
jonny at kemper.freedesktop.org
Fri May 11 02:41:33 PDT 2012
Module: telepathy-glib
Branch: next
Commit: 1231b08bd8720f2bf8e58d3a8c308c1baecc36cb
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=1231b08bd8720f2bf8e58d3a8c308c1baecc36cb
Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date: Wed Apr 25 19:23:35 2012 +0100
future-account: add set_display_name
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
telepathy-glib/future-account.c | 39 +++++++++++++++++++++++++++++++++++++++
telepathy-glib/future-account.h | 3 +++
tests/dbus/future-account.c | 7 ++++++-
3 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/telepathy-glib/future-account.c b/telepathy-glib/future-account.c
index 976d28a..4c5d110 100644
--- a/telepathy-glib/future-account.c
+++ b/telepathy-glib/future-account.c
@@ -60,6 +60,7 @@ struct _TpFutureAccountPrivate {
gchar *cm_name;
gchar *proto_name;
+ gchar *display_name;
};
G_DEFINE_TYPE (TpFutureAccount, tp_future_account, G_TYPE_OBJECT)
@@ -76,6 +77,7 @@ enum {
PROP_ACCOUNT_MANAGER = 1,
PROP_CONNECTION_MANAGER,
PROP_PROTOCOL,
+ PROP_DISPLAY_NAME,
N_PROPS
};
@@ -105,6 +107,9 @@ tp_future_account_get_property (GObject *object,
case PROP_PROTOCOL:
g_value_set_string (value, self->priv->proto_name);
break;
+ case PROP_DISPLAY_NAME:
+ g_value_set_string (value, self->priv->display_name);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -165,6 +170,7 @@ tp_future_account_finalize (GObject *object)
tp_clear_pointer (&priv->cm_name, g_free);
tp_clear_pointer (&priv->proto_name, g_free);
+ tp_clear_pointer (&priv->display_name, g_free);
/* free any data held directly by the object here */
@@ -221,6 +227,18 @@ tp_future_account_class_init (TpFutureAccountClass *klass)
"The account's protocol name",
NULL,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
+ /**
+ * TpFutureAccount:display-name:
+ *
+ * The account's display name.
+ */
+ g_object_class_install_property (object_class, PROP_DISPLAY_NAME,
+ g_param_spec_string ("display-name",
+ "DisplayName",
+ "The account's display name",
+ NULL,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}
/**
@@ -250,3 +268,24 @@ tp_future_account_new (TpAccountManager *account_manager,
NULL);
}
+/**
+ * tp_future_account_set_display_name:
+ * @self: a #TpFutureAccount
+ * @name: a display name for the account
+ *
+ * Set the display name for the new account @self to @name.
+ */
+void
+tp_future_account_set_display_name (TpFutureAccount *self,
+ const gchar *name)
+{
+ TpFutureAccountPrivate *priv;
+
+ g_return_if_fail (TP_IS_FUTURE_ACCOUNT (self));
+ g_return_if_fail (name != NULL);
+
+ priv = self->priv;
+
+ g_free (priv->display_name);
+ priv->display_name = g_strdup (name);
+}
diff --git a/telepathy-glib/future-account.h b/telepathy-glib/future-account.h
index 805aa95..be40e76 100644
--- a/telepathy-glib/future-account.h
+++ b/telepathy-glib/future-account.h
@@ -62,6 +62,9 @@ GType tp_future_account_get_type (void);
TpFutureAccount * tp_future_account_new (TpAccountManager *account_manager,
const gchar *manager, const gchar *protocol) G_GNUC_WARN_UNUSED_RESULT;
+void tp_future_account_set_display_name (TpFutureAccount *self,
+ const gchar *name);
+
G_END_DECLS
#endif
diff --git a/tests/dbus/future-account.c b/tests/dbus/future-account.c
index 7396ebe..5320b0f 100644
--- a/tests/dbus/future-account.c
+++ b/tests/dbus/future-account.c
@@ -68,24 +68,29 @@ test_properties (Test *test,
gconstpointer data G_GNUC_UNUSED)
{
TpAccountManager *am;
- gchar *manager, *protocol;
+ gchar *manager, *protocol, *display_name;
test->account = tp_future_account_new (test->account_manager,
"gabble", "jabber");
+ tp_future_account_set_display_name (test->account, "Charles Dickens");
+
g_object_get (test->account,
"account-manager", &am,
"connection-manager", &manager,
"protocol", &protocol,
+ "display-name", &display_name,
NULL);
g_assert (am == test->account_manager);
g_assert_cmpstr (manager, ==, "gabble");
g_assert_cmpstr (protocol, ==, "jabber");
+ g_assert_cmpstr (display_name, ==, "Charles Dickens");
g_object_unref (am);
g_free (manager);
g_free (protocol);
+ g_free (display_name);
}
int
More information about the telepathy-commits
mailing list