diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-22 14:21:22 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-04-22 14:30:08 +0100 |
commit | 572cad9efae480c84bff9ed26057b78f4dcc247a (patch) | |
tree | c6c6d239d77828ac6d72e02342075efe785a2e8b | |
parent | 4ab5af50a901d4421fe23f0aaf14863a04a4dcb3 (diff) |
Update to GInterface-based TpPresenceMixin API
-rw-r--r-- | src/connection-presence.c | 35 | ||||
-rw-r--r-- | src/connection-presence.h | 3 | ||||
-rw-r--r-- | src/connection.c | 10 | ||||
-rw-r--r-- | src/connection.h | 3 |
4 files changed, 22 insertions, 29 deletions
diff --git a/src/connection-presence.c b/src/connection-presence.c index 2b1ea2b..071ed21 100644 --- a/src/connection-presence.c +++ b/src/connection-presence.c @@ -135,10 +135,10 @@ _get_purple_status_id (HazeConnection *self, } static gboolean -_status_available (GObject *obj, +_status_available (TpPresenceMixin *mixin, guint index) { - HazeConnection *self = HAZE_CONNECTION (obj); + HazeConnection *self = HAZE_CONNECTION (mixin); /* FIXME: (a) should we be able to set offline on ourselves; * (b) deal with some protocols not having status messages. */ @@ -147,11 +147,11 @@ _status_available (GObject *obj, static TpPresenceStatus * -_get_contact_status (GObject *obj, +_get_contact_status (TpPresenceMixin *mixin, TpHandle handle) { - HazeConnection *conn = HAZE_CONNECTION (obj); - TpBaseConnection *base_conn = TP_BASE_CONNECTION (obj); + HazeConnection *conn = HAZE_CONNECTION (mixin); + TpBaseConnection *base_conn = TP_BASE_CONNECTION (mixin); TpHandleRepoIface *handle_repo = tp_base_connection_get_handles (base_conn, TP_ENTITY_TYPE_CONTACT); PurpleStatus *p_status; @@ -203,7 +203,8 @@ haze_connection_presence_account_status_changed (PurpleAccount *account, base_conn = ACCOUNT_GET_TP_BASE_CONNECTION (account); tp_status = _get_tp_status (status); - tp_presence_mixin_emit_one_presence_update (G_OBJECT (base_conn), + tp_presence_mixin_emit_one_presence_update ( + TP_PRESENCE_MIXIN (base_conn), tp_base_connection_get_self_handle (base_conn), tp_status); } } @@ -227,8 +228,8 @@ update_status (PurpleBuddy *buddy, tp_status = _get_tp_status (status); - tp_presence_mixin_emit_one_presence_update (G_OBJECT (conn), handle, - tp_status); + tp_presence_mixin_emit_one_presence_update (TP_PRESENCE_MIXIN (conn), + handle, tp_status); } static void @@ -252,11 +253,11 @@ signed_on_off_cb (PurpleBuddy *buddy, } static gboolean -_set_own_status (GObject *obj, +_set_own_status (TpPresenceMixin *mixin, const TpPresenceStatus *status, GError **error) { - HazeConnection *self = HAZE_CONNECTION (obj); + HazeConnection *self = HAZE_CONNECTION (mixin); const char *status_id = NULL; const gchar *message = NULL; GList *attrs = NULL; @@ -298,17 +299,13 @@ haze_connection_presence_class_init (GObjectClass *object_class) PURPLE_CALLBACK (signed_on_off_cb), GINT_TO_POINTER (TRUE)); purple_signal_connect (blist_handle, "buddy-signed-off", object_class, PURPLE_CALLBACK (signed_on_off_cb), GINT_TO_POINTER (FALSE)); - - tp_presence_mixin_class_init (object_class, - G_STRUCT_OFFSET (HazeConnectionClass, presence_class), - _status_available, _get_contact_status, _set_own_status, statuses); - - tp_presence_mixin_init_dbus_properties (object_class); } void -haze_connection_presence_init (GObject *object) +haze_connection_presence_iface_init (TpPresenceMixinInterface *iface) { - tp_presence_mixin_init (object, G_STRUCT_OFFSET (HazeConnection, - presence)); + iface->status_available = _status_available; + iface->get_contact_status = _get_contact_status; + iface->set_own_status = _set_own_status; + iface->statuses = statuses; } diff --git a/src/connection-presence.h b/src/connection-presence.h index 9f248c0..111b741 100644 --- a/src/connection-presence.h +++ b/src/connection-presence.h @@ -25,10 +25,11 @@ #include "connection.h" void haze_connection_presence_class_init (GObjectClass *object_class); -void haze_connection_presence_init (GObject *object); void haze_connection_presence_account_status_changed (PurpleAccount *account, PurpleStatus *status); +void haze_connection_presence_iface_init (TpPresenceMixinInterface *iface); + #endif diff --git a/src/connection.c b/src/connection.c index af95f52..f7f7a93 100644 --- a/src/connection.c +++ b/src/connection.c @@ -61,8 +61,8 @@ enum G_DEFINE_TYPE_WITH_CODE(HazeConnection, haze_connection, TP_TYPE_BASE_CONNECTION, - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_PRESENCE1, - tp_presence_mixin_iface_init); + G_IMPLEMENT_INTERFACE (TP_TYPE_PRESENCE_MIXIN, + haze_connection_presence_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_ALIASING1, haze_connection_aliasing_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_AVATARS1, @@ -756,7 +756,7 @@ haze_connection_constructor (GType type, self->contact_list = HAZE_CONTACT_LIST ( g_object_new (HAZE_TYPE_CONTACT_LIST, "connection", self, NULL)); - haze_connection_presence_init (object); + tp_presence_mixin_init (TP_PRESENCE_MIXIN (self)); haze_connection_mail_init (object); return (GObject *)self; @@ -787,8 +787,6 @@ haze_connection_finalize (GObject *object) HazeConnection *self = HAZE_CONNECTION (object); HazeConnectionPrivate *priv = self->priv; - tp_presence_mixin_finalize (object); - g_strfreev (self->acceptable_avatar_mime_types); g_free (priv->username); g_free (priv->password); @@ -827,7 +825,7 @@ haze_connection_fill_contact_attributes (TpBaseConnection *base, dbus_interface, handle, 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 1b097fa..879380b 100644 --- a/src/connection.h +++ b/src/connection.h @@ -38,7 +38,6 @@ typedef struct _HazeConnectionClass HazeConnectionClass; struct _HazeConnectionClass { TpBaseConnectionClass parent_class; - TpPresenceMixinClass presence_class; }; struct _HazeConnection { @@ -50,8 +49,6 @@ struct _HazeConnection { HazeImChannelFactory *im_factory; TpSimplePasswordManager *password_manager; - TpPresenceMixin presence; - gchar **acceptable_avatar_mime_types; HazeConnectionPrivate *priv; |