summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2009-09-07 18:06:43 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2009-09-07 18:06:43 +0100
commit6dfcc019d5bf2e28545e526c996ef4b81731495c (patch)
treeaef65d481ea565b6095a37ed3c81d330901f1d37
parent7cc10f837f3e5d18fac9c6bd12b0a54dd80c7485 (diff)
-rw-r--r--src/mcd-connection.c44
-rw-r--r--test/twisted/account-manager/nickname.py15
2 files changed, 55 insertions, 4 deletions
diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index 9612e70a..c7de3220 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -917,15 +917,59 @@ _mcd_connection_set_nickname (McdConnection *connection,
}
static void
+_mcd_connection_get_aliases_cb (TpConnection *proxy,
+ GHashTable *aliases,
+ const GError *error,
+ gpointer user_data,
+ GObject *weak_object)
+{
+ McdConnectionPrivate *priv = user_data;
+ guint self_handle;
+ const gchar *alias;
+
+ DEBUG ("called");
+
+ if (error != NULL)
+ {
+ DEBUG ("GetAliases([SelfHandle]) failed: %s", error->message);
+ return;
+ }
+
+ self_handle = tp_connection_get_self_handle (proxy);
+
+ alias = g_hash_table_lookup (aliases,GUINT_TO_POINTER (self_handle));
+
+ if (alias != NULL &&
+ (priv->alias == NULL || tp_strdiff (priv->alias, alias)))
+ {
+ g_free (priv->alias);
+ priv->alias = g_strdup (alias);
+ g_signal_emit (weak_object, signals[SELF_NICKNAME_CHANGED], 0,
+ alias);
+ }
+}
+
+static void
_mcd_connection_setup_alias (McdConnection *connection)
{
McdConnectionPrivate *priv = connection->priv;
+ GArray *self_handle_array;
+ guint self_handle;
+
+ self_handle_array = g_array_sized_new (FALSE, FALSE, sizeof (guint), 1);
+ self_handle = tp_connection_get_self_handle (priv->tp_conn);
+ g_array_append_val (self_handle_array, self_handle);
tp_cli_connection_interface_aliasing_connect_to_aliases_changed (priv->tp_conn,
on_aliases_changed,
priv, NULL,
(GObject *)connection,
NULL);
+
+ tp_cli_connection_interface_aliasing_call_get_aliases (priv->tp_conn, -1,
+ self_handle_array, _mcd_connection_get_aliases_cb, priv, NULL,
+ (GObject *) connection);
+ g_array_free (self_handle_array, TRUE);
}
static gboolean
diff --git a/test/twisted/account-manager/nickname.py b/test/twisted/account-manager/nickname.py
index 112cb141..c2865078 100644
--- a/test/twisted/account-manager/nickname.py
+++ b/test/twisted/account-manager/nickname.py
@@ -49,16 +49,23 @@ def test(q, bus, mc):
assert account_props.Get(cs.ACCOUNT, 'Nickname') == 'resiak'
# OK, let's go online
- conn, e = enable_fakecm_account(q, bus, mc, account, params,
- has_aliasing=True,
+ conn, get_aliases, set_aliases = enable_fakecm_account(q, bus, mc,
+ account, params, has_aliasing=True,
expect_after_connect=[
EventPattern('dbus-method-call',
+ interface=cs.CONN_IFACE_ALIASING, method='GetAliases',
+ handled=False),
+ EventPattern('dbus-method-call',
interface=cs.CONN_IFACE_ALIASING, method='SetAliases',
handled=False),
])
- assert e.args[0] == { conn.self_handle: 'resiak' }
- q.dbus_return(e.message, signature='')
+ assert get_aliases.args[0] == [ conn.self_handle ]
+ q.dbus_return(get_aliases.message, { conn.self_handle: 'wjt@example.com' },
+ signature='a{us}')
+
+ assert set_aliases.args[0] == { conn.self_handle: 'resiak' }
+ q.dbus_return(set_aliases.message, signature='')
# Change alias after going online
call_async(q, account_props, 'Set', cs.ACCOUNT, 'Nickname',