diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2009-06-01 17:52:35 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2009-06-01 17:57:30 +0100 |
commit | e32080c5ef1a1bdd337024ba694a85b8af3f9cd9 (patch) | |
tree | 265b2c05e9b211d27b8053d3662454eae7ba180c /src/mcd-account.c | |
parent | 63fb36de9e7223d7bb7a367ea14fdfe2333a86b9 (diff) |
McdAccount: push nickname into McdConnection via a method call rather than a signal
The "larger" object should be calling methods on the "smaller", and the
"smaller" should be receiving signals from the "larger" (McdAccount is
"larger" than McdConnection and should depend on it, and the converse
is false).
Diffstat (limited to 'src/mcd-account.c')
-rw-r--r-- | src/mcd-account.c | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/src/mcd-account.c b/src/mcd-account.c index 23bb7ab2..2089d6d7 100644 --- a/src/mcd-account.c +++ b/src/mcd-account.c @@ -161,7 +161,6 @@ enum CONNECTION_STATUS_CHANGED, VALIDITY_CHANGED, AVATAR_CHANGED, - ALIAS_CHANGED, LAST_SIGNAL }; @@ -816,10 +815,11 @@ set_nickname (TpSvcDBusProperties *self, const gchar *name, DEBUG ("called for %s", priv->unique_name); ret = mcd_account_set_string_val (account, name, value, error); - if (ret == SET_RESULT_CHANGED) + if (ret == SET_RESULT_CHANGED && priv->connection != NULL) { - g_signal_emit (account, _mcd_account_signals[ALIAS_CHANGED], 0, - g_value_get_string (value)); + /* this is a no-op if the connection doesn't support it */ + _mcd_connection_set_nickname (priv->connection, + g_value_get_string (value)); } return (ret != SET_RESULT_ERROR); @@ -1897,13 +1897,6 @@ mcd_account_class_init (McdAccountClass * klass) G_TYPE_NONE, 2, dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), G_TYPE_STRING); - _mcd_account_signals[ALIAS_CHANGED] = - g_signal_new ("alias-changed", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED, - 0, - NULL, NULL, g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); _mcd_account_compat_class_init (klass); _mcd_account_connection_class_init (klass); @@ -2622,6 +2615,27 @@ _mcd_account_load (McdAccount *account, McdAccountLoadCb callback, MCD_ACCOUNT_GET_CLASS (account)->load (account, callback, user_data); } +static void +mcd_account_connection_ready_cb (McdAccount *account, + McdConnection *connection) +{ + McdAccountPrivate *priv = account->priv; + gchar *nickname; + + g_return_if_fail (MCD_IS_ACCOUNT (account)); + g_return_if_fail (connection == priv->connection); + + nickname = mcd_account_get_alias (account); + + if (nickname != NULL) + { + /* this is a no-op if the connection doesn't support it */ + _mcd_connection_set_nickname (connection, nickname); + } + + g_free (nickname); +} + void _mcd_account_set_connection (McdAccount *account, McdConnection *connection) { @@ -2641,13 +2655,29 @@ _mcd_account_set_connection (McdAccount *account, McdConnection *connection) g_signal_handlers_disconnect_by_func (priv->connection, on_conn_status_changed, account); + g_signal_handlers_disconnect_by_func (priv->connection, + mcd_account_connection_ready_cb, + account); g_object_unref (priv->connection); } + priv->connection = connection; + if (connection) { g_return_if_fail (MCD_IS_CONNECTION (connection)); g_object_ref (connection); + + if (_mcd_connection_is_ready (connection)) + { + mcd_account_connection_ready_cb (account, connection); + } + else + { + g_signal_connect_swapped (connection, "ready", + G_CALLBACK (mcd_account_connection_ready_cb), account); + } + g_signal_connect (connection, "self-presence-changed", G_CALLBACK (on_conn_self_presence_changed), account); g_signal_connect (connection, "connection-status-changed", |