summaryrefslogtreecommitdiff
path: root/src/mcd-account.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mcd-account.c')
-rw-r--r--src/mcd-account.c62
1 files changed, 46 insertions, 16 deletions
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 0a7f3efc..f113f267 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -2977,6 +2977,10 @@ mcd_account_init (McdAccount *account)
priv->min_presence_status = NULL;
priv->min_presence_message = NULL;
+ priv->curr_presence_type = TP_CONNECTION_PRESENCE_TYPE_OFFLINE;
+ priv->curr_presence_status = g_strdup ("offline");
+ priv->curr_presence_status = g_strdup ("");
+
combine_presences (account);
priv->always_on = FALSE;
@@ -3208,18 +3212,14 @@ mcd_account_request_presence (McdAccount *account,
}
static void
-on_conn_self_presence_changed (McdConnection *connection,
- TpConnectionPresenceType presence,
- const gchar *status,
- const gchar *message,
- gpointer user_data)
+mcd_account_update_self_presence (McdAccount *account,
+ TpConnectionPresenceType presence,
+ const gchar *status,
+ const gchar *message)
{
- McdAccount *account = MCD_ACCOUNT (user_data);
McdAccountPrivate *priv = account->priv;
gboolean changed = FALSE;
GValue value = { 0 };
- GType type;
- GValueArray *va;
if (priv->curr_presence_type != presence)
{
@@ -3239,24 +3239,39 @@ on_conn_self_presence_changed (McdConnection *connection,
changed = TRUE;
}
- if (_mcd_connection_presence_info_is_ready (connection))
+ if (_mcd_connection_presence_info_is_ready (priv->connection))
{
_mcd_account_set_changing_presence (account, FALSE);
}
if (!changed) return;
- type = TP_STRUCT_TYPE_SIMPLE_PRESENCE;
- g_value_init (&value, type);
- g_value_take_boxed (&value, dbus_g_type_specialized_construct (type));
- va = (GValueArray *) g_value_get_boxed (&value);
- g_value_set_uint (va->values, presence);
- g_value_set_static_string (va->values + 1, status);
- g_value_set_static_string (va->values + 2, message);
+ g_value_init (&value, TP_STRUCT_TYPE_SIMPLE_PRESENCE);
+ g_value_take_boxed (&value,
+ tp_value_array_build (3,
+ G_TYPE_UINT, presence,
+ G_TYPE_STRING, status,
+ G_TYPE_STRING, message,
+ G_TYPE_INVALID));
mcd_account_changed_property (account, "CurrentPresence", &value);
g_value_unset (&value);
}
+
+static void
+on_conn_self_presence_changed (McdConnection *connection,
+ TpConnectionPresenceType presence,
+ const gchar *status,
+ const gchar *message,
+ gpointer user_data)
+{
+ McdAccount *account = MCD_ACCOUNT (user_data);
+ McdAccountPrivate *priv = account->priv;
+
+ g_assert (priv->connection == connection);
+ mcd_account_update_self_presence (account, presence, status, message);
+}
+
/* TODO: remove when the relative members will become public */
void
mcd_account_get_requested_presence (McdAccount *account,
@@ -4080,6 +4095,21 @@ mcd_account_connection_ready_cb (McdAccount *account,
}
g_free (nickname);
+
+ if (!tp_proxy_has_interface_by_id (tp_connection,
+ TP_IFACE_QUARK_CONNECTION_INTERFACE_SIMPLE_PRESENCE))
+ {
+ /* This connection doesn't have SimplePresence, but it's online.
+ * TpConnection only emits connection-ready when the account is online
+ * and we've introspected it, so we know that if this interface isn't
+ * present now, it's not going to appear.
+ *
+ * So, the spec says that we should set CurrentPresence to Unset.
+ */
+ mcd_account_update_self_presence (account,
+ TP_CONNECTION_PRESENCE_TYPE_UNSET, "", "");
+ }
+
}
void