From 7cbf16046eceda56d1c9b8c58411be7b3469a4e0 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 13 Sep 2013 15:48:50 +0200 Subject: [PATCH 2/2] connection: stop implementing old Capabilities interface --- src/connection-capabilities.c | 146 ------------------------------------------ src/connection-capabilities.h | 2 - src/connection.c | 3 - 3 files changed, 151 deletions(-) diff --git a/src/connection-capabilities.c b/src/connection-capabilities.c index 1e33ad6..93d14e5 100644 --- a/src/connection-capabilities.c +++ b/src/connection-capabilities.c @@ -39,17 +39,6 @@ free_rcc_list (GPtrArray *rccs) } #ifdef ENABLE_MEDIA -static PurpleMediaCaps -tp_flags_to_purple_caps (guint flags) -{ - PurpleMediaCaps caps = PURPLE_MEDIA_CAPS_NONE; - if (flags & TP_CHANNEL_MEDIA_CAPABILITY_AUDIO) - caps |= PURPLE_MEDIA_CAPS_AUDIO; - if (flags & TP_CHANNEL_MEDIA_CAPABILITY_VIDEO) - caps |= PURPLE_MEDIA_CAPS_VIDEO; - return caps; -} - static guint purple_caps_to_tp_flags (PurpleMediaCaps caps) { @@ -108,10 +97,6 @@ _emit_capabilities_changed (HazeConnection *conn, } } - if (caps_arr->len) - tp_svc_connection_interface_capabilities_emit_capabilities_changed ( - conn, caps_arr); - if (caps_arr->len > 0) { GHashTable *ret = g_hash_table_new_full (g_direct_hash, g_direct_equal, @@ -137,75 +122,6 @@ _emit_capabilities_changed (HazeConnection *conn, } #endif -/** - * haze_connection_advertise_capabilities - * - * Implements D-Bus method AdvertiseCapabilities - * on interface org.freedesktop.Telepathy.Connection.Interface.Capabilities - */ -static void -haze_connection_advertise_capabilities (TpSvcConnectionInterfaceCapabilities *iface, - const GPtrArray *add, - const gchar **del, - DBusGMethodInvocation *context) -{ - HazeConnection *self = HAZE_CONNECTION (iface); - TpBaseConnection *base = (TpBaseConnection *) self; -#ifdef ENABLE_MEDIA - guint i; - PurpleMediaCaps old_caps, caps; -#endif - GPtrArray *ret; - - TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (base, context); - -#ifdef ENABLE_MEDIA - caps = old_caps = purple_media_manager_get_ui_caps ( - purple_media_manager_get ()); - for (i = 0; i < add->len; i++) - { - GValue iface_flags_pair = {0, }; - gchar *channel_type; - guint flags; - - g_value_init (&iface_flags_pair, TP_STRUCT_TYPE_CAPABILITY_PAIR); - g_value_set_static_boxed (&iface_flags_pair, g_ptr_array_index (add, i)); - - dbus_g_type_struct_get (&iface_flags_pair, - 0, &channel_type, - 1, &flags, - G_MAXUINT); - - if (g_str_equal (channel_type, TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA)) - caps |= tp_flags_to_purple_caps(flags); - - g_free (channel_type); - } - - for (i = 0; NULL != del[i]; i++) - { - if (g_str_equal (del[i], TP_IFACE_CHANNEL_TYPE_STREAMED_MEDIA)) - { - caps = PURPLE_MEDIA_CAPS_NONE; - break; - } - } - - purple_media_manager_set_ui_caps (purple_media_manager_get(), caps); - - _emit_capabilities_changed (self, tp_base_connection_get_self_handle (base), - old_caps, caps); -#endif - - ret = g_ptr_array_new (); - -/* TODO: store caps and return them properly */ - - tp_svc_connection_interface_capabilities_return_from_advertise_capabilities ( - context, ret); - g_ptr_array_free (ret, TRUE); -} - typedef enum { CAPS_FLAGS_AUDIO = 1 << 0, CAPS_FLAGS_VIDEO = 1 << 1, @@ -495,54 +411,6 @@ haze_connection_get_handle_contact_capabilities (HazeConnection *self, return arr; } -/** - * haze_connection_get_capabilities - * - * Implements D-Bus method GetCapabilities - * on interface org.freedesktop.Telepathy.Connection.Interface.Capabilities - */ -static void -haze_connection_get_capabilities (TpSvcConnectionInterfaceCapabilities *iface, - const GArray *handles, - DBusGMethodInvocation *context) -{ - HazeConnection *self = HAZE_CONNECTION (iface); - TpBaseConnection *conn = TP_BASE_CONNECTION (self); - TpHandleRepoIface *contact_handles = tp_base_connection_get_handles (conn, - TP_HANDLE_TYPE_CONTACT); - guint i; - GPtrArray *ret; - GError *error = NULL; - - TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (conn, context); - - if (!tp_handles_are_valid (contact_handles, handles, TRUE, &error)) - { - dbus_g_method_return_error (context, error); - g_error_free (error); - return; - } - - ret = g_ptr_array_new (); - - for (i = 0; i < handles->len; i++) - { - TpHandle handle = g_array_index (handles, TpHandle, i); - - haze_connection_get_handle_capabilities (self, handle, ret); - } - - tp_svc_connection_interface_capabilities_return_from_get_capabilities ( - context, ret); - - for (i = 0; i < ret->len; i++) - { - g_value_array_free (g_ptr_array_index (ret, i)); - } - - g_ptr_array_free (ret, TRUE); -} - static void conn_capabilities_fill_contact_attributes (GObject *obj, const GArray *contacts, @@ -610,20 +478,6 @@ conn_capabilities_fill_contact_attributes_contact_caps ( } } -void -haze_connection_capabilities_iface_init (gpointer g_iface, - gpointer iface_data) -{ - TpSvcConnectionInterfaceCapabilitiesClass *klass = g_iface; - -#define IMPLEMENT(x) \ - tp_svc_connection_interface_capabilities_implement_##x (\ - klass, haze_connection_##x) - IMPLEMENT(advertise_capabilities); - IMPLEMENT(get_capabilities); -#undef IMPLEMENT -} - static void haze_connection_get_contact_capabilities ( TpSvcConnectionInterfaceContactCapabilities *svc, diff --git a/src/connection-capabilities.h b/src/connection-capabilities.h index 7764a31..791581b 100644 --- a/src/connection-capabilities.h +++ b/src/connection-capabilities.h @@ -23,8 +23,6 @@ #include -void haze_connection_capabilities_iface_init (gpointer g_iface, - gpointer iface_data); void haze_connection_contact_capabilities_iface_init (gpointer g_iface, gpointer iface_data); void haze_connection_capabilities_class_init (GObjectClass *object_class); diff --git a/src/connection.c b/src/connection.c index 79fe6b2..67da039 100644 --- a/src/connection.c +++ b/src/connection.c @@ -71,8 +71,6 @@ G_DEFINE_TYPE_WITH_CODE(HazeConnection, haze_connection_avatars_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_CAPABILITIES, haze_connection_contact_capabilities_iface_init); - G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CAPABILITIES, - haze_connection_capabilities_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACTS, tp_contacts_mixin_iface_init); G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_LIST, @@ -99,7 +97,6 @@ static const gchar * implemented_interfaces[] = { TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS, TP_IFACE_CONNECTION_INTERFACE_REQUESTS, TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE, - TP_IFACE_CONNECTION_INTERFACE_CAPABILITIES, TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES, TP_IFACE_CONNECTION_INTERFACE_CONTACTS, /* TODO: This is a lie. Not all protocols supported by libpurple -- 1.8.3.1