[next] telepathy-glib: future-account: add add_supersedes function and : supersedes property
Jonny Lamb
jonny at kemper.freedesktop.org
Fri May 11 02:41:35 PDT 2012
Module: telepathy-glib
Branch: next
Commit: c2b25d7ed22d154d983dc9cb997b303ce7083354
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=c2b25d7ed22d154d983dc9cb997b303ce7083354
Author: Jonny Lamb <jonny.lamb at collabora.co.uk>
Date: Fri Apr 27 14:14:29 2012 +0100
future-account: add add_supersedes function and :supersedes property
Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
docs/reference/telepathy-glib-sections.txt | 1 +
telepathy-glib/future-account.c | 75 ++++++++++++++++++++++++++++
telepathy-glib/future-account.h | 3 +
tests/dbus/future-account.c | 29 ++++++++++-
4 files changed, 107 insertions(+), 1 deletions(-)
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 3ee87a4..0936fec 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -5242,6 +5242,7 @@ tp_future_account_set_requested_presence
tp_future_account_set_automatic_presence
tp_future_account_set_enabled
tp_future_account_set_connect_automatically
+tp_future_account_add_supersedes
<SUBSECTION>
tp_future_account_set_parameter
tp_future_account_set_parameter_string
diff --git a/telepathy-glib/future-account.c b/telepathy-glib/future-account.c
index c12af23..f246b4c 100644
--- a/telepathy-glib/future-account.c
+++ b/telepathy-glib/future-account.c
@@ -141,6 +141,7 @@ enum {
PROP_AUTOMATIC_STATUS_MESSAGE,
PROP_ENABLED,
PROP_CONNECT_AUTOMATICALLY,
+ PROP_SUPERSEDES,
N_PROPS
};
@@ -245,6 +246,25 @@ tp_future_account_get_property (GObject *object,
TP_PROP_ACCOUNT_CONNECT_AUTOMATICALLY,
NULL));
break;
+ case PROP_SUPERSEDES:
+ {
+ GPtrArray *array = tp_asv_get_boxed (self->priv->properties,
+ TP_PROP_ACCOUNT_SUPERSEDES,
+ TP_ARRAY_TYPE_OBJECT_PATH_LIST);
+
+ if (array != NULL)
+ {
+ /* add the NULL-termination to make it a real GStrv */
+ g_ptr_array_add (array, NULL);
+ g_value_set_boxed (value, array->pdata);
+ g_ptr_array_remove_index (array, (array->len - 1));
+ }
+ else
+ {
+ g_value_set_boxed (value, NULL);
+ }
+ }
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -549,6 +569,22 @@ tp_future_account_class_init (TpFutureAccountClass *klass)
"Whether this account should connect automatically or not",
FALSE,
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
+
+ /**
+ * TpFutureAccount:supersedes:
+ *
+ * The object paths of previously-active accounts superseded by this one.
+ * For instance, this can be used in a logger to read old logs for an
+ * account that has been migrated from one connection manager to another.
+ *
+ * To add to this property use tp_future_account_add_supersedes().
+ */
+ g_object_class_install_property (object_class, PROP_SUPERSEDES,
+ g_param_spec_boxed ("supersedes",
+ "Supersedes",
+ "Accounts superseded by this one",
+ G_TYPE_STRV,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}
/**
@@ -777,6 +813,45 @@ tp_future_account_set_connect_automatically (TpFutureAccount *self,
}
/**
+ * tp_future_account_add_supersedes:
+ * @self: a #TpFutureAccount
+ * @superseded_path: an account object path to add to the supersedes
+ * list
+ *
+ * Add an account object path to the list of superseded accounts which
+ * this new account will supersede. Use the
+ * #TpFutureAccount:supersedes property to read the current list of
+ * superseded accounts.
+ */
+void
+tp_future_account_add_supersedes (TpFutureAccount *self,
+ const gchar *superseded_path)
+{
+ TpFutureAccountPrivate *priv;
+ GPtrArray *array;
+
+ g_return_if_fail (TP_IS_FUTURE_ACCOUNT (self));
+ g_return_if_fail (g_variant_is_object_path (superseded_path));
+
+ priv = self->priv;
+
+ array = tp_asv_get_boxed (priv->properties,
+ TP_PROP_ACCOUNT_SUPERSEDES,
+ TP_ARRAY_TYPE_OBJECT_PATH_LIST);
+
+ if (array == NULL)
+ {
+ array = g_ptr_array_new ();
+
+ tp_asv_take_boxed (priv->properties,
+ TP_PROP_ACCOUNT_SUPERSEDES,
+ TP_ARRAY_TYPE_OBJECT_PATH_LIST, array);
+ }
+
+ g_ptr_array_add (array, g_strdup (superseded_path));
+}
+
+/**
* 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 57fcc8a..2b2d05f 100644
--- a/telepathy-glib/future-account.h
+++ b/telepathy-glib/future-account.h
@@ -85,6 +85,9 @@ void tp_future_account_set_enabled (TpFutureAccount *self,
void tp_future_account_set_connect_automatically (TpFutureAccount *self,
gboolean connect_automatically);
+void tp_future_account_add_supersedes (TpFutureAccount *self,
+ const gchar *superseded_path);
+
/* 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 839d5f3..ce3ce75 100644
--- a/tests/dbus/future-account.c
+++ b/tests/dbus/future-account.c
@@ -179,6 +179,7 @@ test_properties (Test *test,
TpConnectionPresenceType presence_type;
gchar *presence_status, *presence_message;
gboolean enabled, connect_automatically;
+ gchar **supersedes;
test->account = tp_future_account_new (test->account_manager,
"gabble", "jabber");
@@ -272,6 +273,21 @@ test_properties (Test *test,
g_assert_cmpint (enabled, ==, FALSE);
g_assert_cmpint (connect_automatically, ==, TRUE);
+
+ /* supersedes */
+ tp_future_account_add_supersedes (test->account,
+ "/science/yeah/woo");
+
+ g_object_get (test->account,
+ "supersedes", &supersedes,
+ NULL);
+
+ g_assert_cmpuint (g_strv_length (supersedes), ==, 1);
+ g_assert_cmpstr (supersedes[0], ==,
+ "/science/yeah/woo");
+ g_assert (supersedes[1] == NULL);
+
+ g_strfreev (supersedes);
}
static void
@@ -280,6 +296,7 @@ test_create_succeed (Test *test,
{
TpAccount *account;
GValueArray *array;
+ GPtrArray *supersedes;
test->account = tp_future_account_new (test->account_manager,
"gabble", "jabber");
@@ -301,6 +318,9 @@ test_create_succeed (Test *test,
tp_future_account_set_parameter_string (test->account,
"password", "holly");
+ tp_future_account_add_supersedes (test->account,
+ "/some/silly/account");
+
tp_future_account_create_account_async (test->account,
tp_tests_result_ready_cb, &test->result);
tp_tests_run_until_result (&test->result);
@@ -318,7 +338,7 @@ 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), ==, 6);
+ g_assert_cmpuint (g_hash_table_size (test->am->create_properties), ==, 7);
g_assert_cmpstr (tp_asv_get_string (test->am->create_properties,
TP_PROP_ACCOUNT_ICON),
==, "gasmask");
@@ -352,6 +372,13 @@ test_create_succeed (Test *test,
g_assert_cmpstr (g_value_get_string (array->values + 2), ==,
"Cooking");
+ supersedes = tp_asv_get_boxed (test->am->create_properties,
+ TP_PROP_ACCOUNT_SUPERSEDES,
+ TP_ARRAY_TYPE_OBJECT_PATH_LIST);
+ g_assert_cmpuint (supersedes->len, ==, 1);
+ g_assert_cmpstr (g_ptr_array_index (supersedes, 0), ==,
+ "/some/silly/account");
+
g_object_unref (account);
}
More information about the telepathy-commits
mailing list