[next] telepathy-gabble: Update presence mixin API
Simon McVittie
smcv at kemper.freedesktop.org
Wed May 7 02:18:41 PDT 2014
Module: telepathy-gabble
Branch: next
Commit: ba614f1df8016198d5d62edf755a4fd4f17c6758
URL: http://cgit.freedesktop.org/telepathy/telepathy-gabble/commit/?id=ba614f1df8016198d5d62edf755a4fd4f17c6758
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Thu Apr 17 18:03:20 2014 +0100
Update presence mixin API
---
src/conn-presence.c | 43 +++++++++++++++++++------------------------
src/conn-presence.h | 2 +-
src/connection.c | 10 +++-------
src/connection.h | 2 --
4 files changed, 23 insertions(+), 34 deletions(-)
diff --git a/src/conn-presence.c b/src/conn-presence.c
index 90cc868..f20b616 100644
--- a/src/conn-presence.c
+++ b/src/conn-presence.c
@@ -150,10 +150,10 @@ conn_presence_error_quark (void)
return quark;
}
-static TpPresenceStatus *construct_contact_status (GObject *obj,
+static TpPresenceStatus *construct_contact_status (TpPresenceMixin *mixin,
TpHandle handle)
{
- GabbleConnection *self = GABBLE_CONNECTION (obj);
+ GabbleConnection *self = GABBLE_CONNECTION (mixin);
TpBaseConnection *base = (TpBaseConnection *) self;
GabblePresence *presence;
GabblePresenceId status;
@@ -187,6 +187,7 @@ construct_contact_statuses (GabbleConnection *self,
const GArray *contact_handles)
{
TpBaseConnection *base = (TpBaseConnection *) self;
+ TpPresenceMixin *mixin = TP_PRESENCE_MIXIN (self);
guint i;
TpHandle handle;
GHashTable *contact_statuses;
@@ -204,7 +205,7 @@ construct_contact_statuses (GabbleConnection *self,
handle = g_array_index (contact_handles, TpHandle, i);
g_hash_table_insert (contact_statuses, GUINT_TO_POINTER (handle),
- construct_contact_status ((GObject *) self, handle));
+ construct_contact_status (mixin, handle));
}
return contact_statuses;
@@ -228,7 +229,8 @@ conn_presence_emit_presence_update (
contact_statuses = construct_contact_statuses (self,
contact_handles);
- tp_presence_mixin_emit_presence_update ((GObject *) self, contact_statuses);
+ tp_presence_mixin_emit_presence_update (TP_PRESENCE_MIXIN (self),
+ contact_statuses);
g_hash_table_unref (contact_statuses);
}
@@ -1502,9 +1504,9 @@ conn_presence_statuses (void)
}
static guint
-get_maximum_status_message_length_cb (GObject *obj)
+get_maximum_status_message_length_cb (TpPresenceMixin *mixin)
{
- GabbleConnection *conn = GABBLE_CONNECTION (obj);
+ GabbleConnection *conn = GABBLE_CONNECTION (mixin);
GabbleConnectionPresencePrivate *priv = conn->presence_priv;
return priv->max_status_message_length;
@@ -1692,11 +1694,11 @@ toggle_presence_visibility_cb (GObject *source_object,
}
static gboolean
-set_own_status_cb (GObject *obj,
+set_own_status_cb (TpPresenceMixin *mixin,
const TpPresenceStatus *status,
GError **error)
{
- GabbleConnection *conn = GABBLE_CONNECTION (obj);
+ GabbleConnection *conn = GABBLE_CONNECTION (mixin);
GabbleConnectionPresencePrivate *priv = conn->presence_priv;
TpBaseConnection *base = (TpBaseConnection *) conn;
GabblePresenceId i = GABBLE_PRESENCE_AVAILABLE;
@@ -1804,9 +1806,10 @@ connection_status_changed_cb (
static gboolean
-status_available_cb (GObject *obj, guint status)
+status_available_cb (TpPresenceMixin *mixin,
+ guint status)
{
- GabbleConnection *conn = GABBLE_CONNECTION (obj);
+ GabbleConnection *conn = GABBLE_CONNECTION (mixin);
TpBaseConnection *base = (TpBaseConnection *) conn;
GabbleConnectionPresencePrivate *priv = conn->presence_priv;
TpConnectionPresenceType presence_type =
@@ -1870,20 +1873,15 @@ conn_presence_get_type (GabblePresence *presence)
* Until then, gabble_statuses is leaked.
*/
void
-conn_presence_class_init (GabbleConnectionClass *klass)
+conn_presence_mixin_init (TpPresenceMixinInterface *mixin_cls)
{
- TpPresenceMixinClass *mixin_cls;
-
- tp_presence_mixin_class_init ((GObjectClass *) klass,
- G_STRUCT_OFFSET (GabbleConnectionClass, presence_class),
- status_available_cb, construct_contact_status,
- set_own_status_cb, conn_presence_statuses ());
- mixin_cls = TP_PRESENCE_MIXIN_CLASS (klass);
+ mixin_cls->status_available = status_available_cb;
+ mixin_cls->get_contact_status = construct_contact_status;
+ mixin_cls->set_own_status = set_own_status_cb;
mixin_cls->get_maximum_status_message_length =
get_maximum_status_message_length_cb;
- tp_presence_mixin_init_dbus_properties (
- (GObjectClass *) klass);
+ mixin_cls->statuses = conn_presence_statuses ();
}
void
@@ -1902,8 +1900,7 @@ conn_presence_init (GabbleConnection *conn)
conn->presence_priv->privacy_statuses = NULL;
- tp_presence_mixin_init ((GObject *) conn,
- G_STRUCT_OFFSET (GabbleConnection, presence));
+ tp_presence_mixin_init (TP_PRESENCE_MIXIN (conn));
}
void
@@ -1944,6 +1941,4 @@ conn_presence_finalize (GabbleConnection *conn)
g_hash_table_unref (priv->shared_statuses);
g_slice_free (GabbleConnectionPresencePrivate, priv);
-
- tp_presence_mixin_finalize ((GObject *) conn);
}
diff --git a/src/conn-presence.h b/src/conn-presence.h
index 4b060c6..e737607 100644
--- a/src/conn-presence.h
+++ b/src/conn-presence.h
@@ -40,7 +40,7 @@ typedef enum {
GQuark conn_presence_error_quark (void);
#define CONN_PRESENCE_ERROR (conn_presence_error_quark ())
-void conn_presence_class_init (GabbleConnectionClass *klass);
+void conn_presence_mixin_init (TpPresenceMixinInterface *mixin_cls);
void conn_presence_init (GabbleConnection *conn);
void conn_presence_finalize (GabbleConnection *conn);
void conn_presence_dispose (GabbleConnection *self);
diff --git a/src/connection.c b/src/connection.c
index fa882cb..5bc70b4 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -93,6 +93,8 @@ static TpBaseContactList *_gabble_plugin_connection_get_contact_list (
G_DEFINE_TYPE_WITH_CODE(GabbleConnection,
gabble_connection,
TP_TYPE_BASE_CONNECTION,
+ G_IMPLEMENT_INTERFACE (TP_TYPE_PRESENCE_MIXIN,
+ conn_presence_mixin_init);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_ALIASING1,
conn_aliasing_iface_init);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_AVATARS1,
@@ -105,8 +107,6 @@ G_DEFINE_TYPE_WITH_CODE(GabbleConnection,
tp_base_contact_list_mixin_groups_iface_init);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_BLOCKING1,
tp_base_contact_list_mixin_blocking_iface_init);
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_PRESENCE1,
- tp_presence_mixin_iface_init);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_LOCATION1,
location_iface_init);
G_IMPLEMENT_INTERFACE
@@ -530,8 +530,6 @@ gabble_connection_constructed (GObject *object)
object_skeleton_take_svc_interface (skel,
TP_TYPE_SVC_CONNECTION_INTERFACE_POWER_SAVING1);
object_skeleton_take_svc_interface (skel,
- TP_TYPE_SVC_CONNECTION_INTERFACE_PRESENCE1);
- object_skeleton_take_svc_interface (skel,
TP_TYPE_SVC_CONNECTION_INTERFACE_SIDECARS1);
if (priv->resource == NULL)
@@ -1232,8 +1230,6 @@ gabble_connection_class_init (GabbleConnectionClass *gabble_connection_class)
TP_IFACE_QUARK_CONNECTION_INTERFACE_ALIASING1,
conn_aliasing_properties_getter, NULL, conn_aliasing_properties);
- conn_presence_class_init (gabble_connection_class);
-
conn_contact_info_class_init (gabble_connection_class);
tp_base_contact_list_mixin_class_init (parent_class);
@@ -3393,7 +3389,7 @@ gabble_connection_fill_contact_attributes (TpBaseConnection *base,
attributes))
return;
- if (tp_presence_mixin_fill_contact_attributes ((GObject *) self,
+ if (tp_presence_mixin_fill_contact_attributes (TP_PRESENCE_MIXIN (self),
dbus_interface, handle, attributes))
return;
diff --git a/src/connection.h b/src/connection.h
index c3b8837..2fd1f85 100644
--- a/src/connection.h
+++ b/src/connection.h
@@ -166,12 +166,10 @@ typedef enum {
struct _GabbleConnectionClass {
TpBaseConnectionClass parent_class;
- TpPresenceMixinClass presence_class;
};
struct _GabbleConnection {
TpBaseConnection parent;
- TpPresenceMixin presence;
WockySession *session;
More information about the telepathy-commits
mailing list