summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-01-08 13:04:41 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-01-13 12:27:33 +0000
commit60f16c664d45295a7127ce6e3d483123158ba864 (patch)
treea6df0e67809fdd212a6e0bdd8e0bd2b868294ca7
parent85efbaa60a1a6598554216296791bac201c024aa (diff)
presence mixin: switch to singular API
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=50093 Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
-rw-r--r--src/connection.c57
1 files changed, 26 insertions, 31 deletions
diff --git a/src/connection.c b/src/connection.c
index 9152c716..59fdc673 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -571,51 +571,46 @@ make_presence_opt_args (SalutPresenceId presence, const gchar *message)
return ret;
}
-static GHashTable *
-get_contact_statuses (GObject *obj,
- const GArray *handles)
+static TpPresenceStatus *
+get_contact_status (GObject *obj,
+ TpHandle handle)
{
SalutConnection *self = SALUT_CONNECTION (obj);
SalutConnectionPrivate *priv = self->priv;
TpBaseConnection *base = (TpBaseConnection *) self;
TpHandle self_handle = tp_base_connection_get_self_handle (base);
- GHashTable *ret;
- guint i;
-
- ret = g_hash_table_new_full (g_direct_hash, g_direct_equal,
- NULL, (GDestroyNotify) tp_presence_status_free);
+ TpPresenceStatus *ps;
+ SalutPresenceId presence;
+ const gchar *message = NULL;
+ GHashTable *optional_arguments;
- for (i = 0; i < handles->len; i++)
+ if (handle == self_handle)
{
- TpHandle handle = g_array_index (handles, TpHandle, i);
- TpPresenceStatus *ps = tp_presence_status_new
- (SALUT_PRESENCE_OFFLINE, NULL);
- const gchar *message = NULL;
+ presence = priv->self->status;
+ message = priv->self->status_message;
+ }
+ else
+ {
+ SalutContact *contact = salut_contact_manager_get_contact
+ (priv->contact_manager, handle);
- if (handle == self_handle)
+ if (contact == NULL)
{
- ps->index = priv->self->status;
- message = priv->self->status_message;
+ presence = SALUT_PRESENCE_OFFLINE;
+ message = "";
}
else
{
- SalutContact *contact = salut_contact_manager_get_contact
- (priv->contact_manager, handle);
-
- if (contact != NULL)
- {
- ps->index = contact->status;
- message = contact->status_message;
- g_object_unref (contact);
- }
+ presence = contact->status;
+ message = contact->status_message;
+ g_object_unref (contact);
}
-
- ps->optional_arguments = make_presence_opt_args (ps->index, message);
-
- g_hash_table_insert (ret, GUINT_TO_POINTER (handle), ps);
}
- return ret;
+ optional_arguments = make_presence_opt_args (presence, message);
+ ps = tp_presence_status_new (presence, optional_arguments);
+ g_hash_table_unref (optional_arguments);
+ return ps;
}
static void
@@ -787,7 +782,7 @@ salut_connection_class_init (SalutConnectionClass *salut_connection_class)
tp_presence_mixin_class_init (object_class,
G_STRUCT_OFFSET (SalutConnectionClass, presence_mixin),
- is_presence_status_available, get_contact_statuses, set_own_status,
+ is_presence_status_available, get_contact_status, set_own_status,
presence_statuses);
tp_presence_mixin_init_dbus_properties (object_class);