[telepathy-mission-control/master] McdAccount: call a method on the McdConnection to request presence, rather than emitting a signal
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Apr 16 08:34:16 PDT 2009
---
src/mcd-account.c | 35 ++++++++++++++++-------------------
src/mcd-connection-priv.h | 3 +++
src/mcd-connection.c | 37 +++++++++++++++----------------------
3 files changed, 34 insertions(+), 41 deletions(-)
diff --git a/src/mcd-account.c b/src/mcd-account.c
index d23a7e2..a46de4a 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -160,7 +160,6 @@ enum
enum
{
CONNECTION_STATUS_CHANGED,
- REQUESTED_PRESENCE_CHANGED,
VALIDITY_CHANGED,
AVATAR_CHANGED,
ALIAS_CHANGED,
@@ -480,14 +479,18 @@ mcd_account_request_presence_int (McdAccount *account,
if (!(changed || priv->temporary_presence))
return FALSE;
- if (type >= TP_CONNECTION_PRESENCE_TYPE_AVAILABLE && !priv->connection)
+ if (priv->connection == NULL)
{
- _mcd_account_connection_begin (account);
+ if (type >= TP_CONNECTION_PRESENCE_TYPE_AVAILABLE)
+ {
+ _mcd_account_connection_begin (account);
+ }
+ }
+ else
+ {
+ _mcd_connection_request_presence (priv->connection,
+ type, status, message);
}
-
- g_signal_emit (account,
- _mcd_account_signals[REQUESTED_PRESENCE_CHANGED], 0,
- type, status, message);
return TRUE;
}
@@ -1671,14 +1674,6 @@ mcd_account_class_init (McdAccountClass * klass)
NULL, NULL, _mcd_marshal_VOID__UINT_UINT,
G_TYPE_NONE,
2, G_TYPE_UINT, G_TYPE_UINT);
- _mcd_account_signals[REQUESTED_PRESENCE_CHANGED] =
- g_signal_new ("requested-presence-changed",
- G_OBJECT_CLASS_TYPE (klass),
- G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
- 0,
- NULL, NULL, _mcd_marshal_VOID__UINT_STRING_STRING,
- G_TYPE_NONE,
- 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
_mcd_account_signals[VALIDITY_CHANGED] =
g_signal_new ("validity-changed",
G_OBJECT_CLASS_TYPE (klass),
@@ -2481,10 +2476,12 @@ _mcd_account_request_temporary_presence (McdAccount *self,
TpConnectionPresenceType type,
const gchar *status)
{
- /* tell the McdConnection (if it exists) to update our presence, but don't
- * alter RequestedPresence (so we can go back to the old value later) */
- g_signal_emit (self, _mcd_account_signals[REQUESTED_PRESENCE_CHANGED],
- 0, type, status, "");
+ if (self->priv->connection != NULL)
+ {
+ _mcd_connection_request_presence (self->priv->connection,
+ type, status, "");
+ }
+
self->priv->temporary_presence = TRUE;
}
diff --git a/src/mcd-connection-priv.h b/src/mcd-connection-priv.h
index 3e407e4..8e453a6 100644
--- a/src/mcd-connection-priv.h
+++ b/src/mcd-connection-priv.h
@@ -30,6 +30,9 @@
G_BEGIN_DECLS
+G_GNUC_INTERNAL void _mcd_connection_request_presence (McdConnection *self,
+ TpConnectionPresenceType type, const gchar *status, const gchar *message);
+
G_GNUC_INTERNAL void _mcd_connection_connect (McdConnection *connection,
GHashTable *params);
G_GNUC_INTERNAL
diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index a8ca93d..72ab677 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -437,7 +437,8 @@ _mcd_connection_call_disconnect (McdConnection *connection)
}
-/* This handler should update the presence of the tp_connection.
+/* Update the presence of the tp_connection.
+ *
* Note, that the only presence transition not served by this function
* is getting to non-offline state since when presence is offline this object
* does not exist.
@@ -445,35 +446,33 @@ _mcd_connection_call_disconnect (McdConnection *connection)
* So, here we just submit the request to the tp_connection object. The return off
* the operation is handled by (yet to be written) handler
*/
-static void
-on_presence_requested (McdAccount *account,
- TpConnectionPresenceType presence,
- const gchar *status, const gchar *message,
- gpointer user_data)
+void
+_mcd_connection_request_presence (McdConnection *self,
+ TpConnectionPresenceType presence,
+ const gchar *status, const gchar *message)
{
- McdConnection *connection = MCD_CONNECTION (user_data);
- McdConnectionPrivate *priv = connection->priv;
+ g_return_if_fail (MCD_IS_CONNECTION (self));
DEBUG ("Presence requested: %d", presence);
if (presence == TP_CONNECTION_PRESENCE_TYPE_UNSET) return;
if (presence == TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
{
- /* Connection Proxy */
- priv->abort_reason = TP_CONNECTION_STATUS_REASON_REQUESTED;
- mcd_mission_disconnect (MCD_MISSION (connection));
- _mcd_connection_call_disconnect (connection);
+ /* Connection Proxy */
+ self->priv->abort_reason = TP_CONNECTION_STATUS_REASON_REQUESTED;
+ mcd_mission_disconnect (MCD_MISSION (self));
+ _mcd_connection_call_disconnect (self);
/* if a reconnection attempt is scheduled, cancel it */
- if (priv->reconnect_timer)
+ if (self->priv->reconnect_timer)
{
- g_source_remove (priv->reconnect_timer);
- priv->reconnect_timer = 0;
+ g_source_remove (self->priv->reconnect_timer);
+ self->priv->reconnect_timer = 0;
}
}
else
{
- _mcd_connection_set_presence (connection, presence, status, message);
+ _mcd_connection_set_presence (self, presence, status, message);
}
}
@@ -1709,9 +1708,6 @@ _mcd_connection_dispose (GObject * object)
if (priv->account)
{
g_signal_handlers_disconnect_by_func (priv->account,
- G_CALLBACK
- (on_presence_requested), object);
- g_signal_handlers_disconnect_by_func (priv->account,
G_CALLBACK (on_account_avatar_changed),
object);
g_signal_handlers_disconnect_by_func (priv->account,
@@ -1787,9 +1783,6 @@ _mcd_connection_set_property (GObject * obj, guint prop_id,
g_object_ref (account);
priv->account = account;
g_signal_connect (priv->account,
- "requested-presence-changed",
- G_CALLBACK (on_presence_requested), obj);
- g_signal_connect (priv->account,
"mcd-avatar-changed",
G_CALLBACK (on_account_avatar_changed), obj);
g_signal_connect (priv->account,
--
1.5.6.5
More information about the telepathy-commits
mailing list