From a18d1c8f9ab20539f4f5a34172d0adeec29c8475 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 6 Nov 2013 19:11:28 +0000 Subject: [PATCH 09/11] Assume that Conn.I.Requests is supported, and don't put it in Interfaces --- examples/cm/call/conn.c | 1 - examples/cm/channelspecific/conn.c | 1 - examples/cm/contactlist/conn.c | 1 - examples/cm/echo-message-parts/conn.c | 1 - examples/cm/extended/conn.c | 1 - telepathy-glib/base-connection.c | 20 ++------------------ telepathy-glib/connection.c | 23 +++++++++-------------- tests/dbus/protocol-objects.c | 1 - tests/lib/simple-conn.c | 15 --------------- 9 files changed, 11 insertions(+), 53 deletions(-) diff --git a/examples/cm/call/conn.c b/examples/cm/call/conn.c index 9f20b4d..e4d69eb 100644 --- a/examples/cm/call/conn.c +++ b/examples/cm/call/conn.c @@ -353,7 +353,6 @@ static const TpPresenceStatusSpec presence_statuses[] = { static const gchar *interfaces_always_present[] = { TP_IFACE_CONNECTION_INTERFACE_PRESENCE1, - TP_IFACE_CONNECTION_INTERFACE_REQUESTS, NULL }; const gchar * const * diff --git a/examples/cm/channelspecific/conn.c b/examples/cm/channelspecific/conn.c index 5904d36..b49e0cb 100644 --- a/examples/cm/channelspecific/conn.c +++ b/examples/cm/channelspecific/conn.c @@ -217,7 +217,6 @@ shut_down (TpBaseConnection *conn) } static const gchar *interfaces_always_present[] = { - TP_IFACE_CONNECTION_INTERFACE_REQUESTS, NULL }; const gchar * const * diff --git a/examples/cm/contactlist/conn.c b/examples/cm/contactlist/conn.c index 10a8e67..2e79406 100644 --- a/examples/cm/contactlist/conn.c +++ b/examples/cm/contactlist/conn.c @@ -378,7 +378,6 @@ static const gchar *interfaces_always_present[] = { TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS1, TP_IFACE_CONNECTION_INTERFACE_CONTACT_BLOCKING1, TP_IFACE_CONNECTION_INTERFACE_PRESENCE1, - TP_IFACE_CONNECTION_INTERFACE_REQUESTS, NULL }; const gchar * const * diff --git a/examples/cm/echo-message-parts/conn.c b/examples/cm/echo-message-parts/conn.c index 2f164eb..c846f0a 100644 --- a/examples/cm/echo-message-parts/conn.c +++ b/examples/cm/echo-message-parts/conn.c @@ -158,7 +158,6 @@ shut_down (TpBaseConnection *conn) } static const gchar *interfaces_always_present[] = { - TP_IFACE_CONNECTION_INTERFACE_REQUESTS, NULL }; const gchar * const * diff --git a/examples/cm/extended/conn.c b/examples/cm/extended/conn.c index 8a40c20..84c0474 100644 --- a/examples/cm/extended/conn.c +++ b/examples/cm/extended/conn.c @@ -173,7 +173,6 @@ shut_down (TpBaseConnection *conn) } static const gchar *interfaces_always_present[] = { - TP_IFACE_CONNECTION_INTERFACE_REQUESTS, EXAMPLE_IFACE_CONNECTION_INTERFACE_HATS, NULL }; diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c index a847936..97a720e 100644 --- a/telepathy-glib/base-connection.c +++ b/telepathy-glib/base-connection.c @@ -894,7 +894,6 @@ tp_base_connection_create_interfaces_array (TpBaseConnection *self) TpBaseConnectionPrivate *priv = self->priv; TpBaseConnectionClass *klass = TP_BASE_CONNECTION_GET_CLASS (self); GPtrArray *always; - gboolean has_requests = FALSE; guint i; g_assert (priv->interfaces == NULL); @@ -903,18 +902,9 @@ tp_base_connection_create_interfaces_array (TpBaseConnection *self) priv->interfaces = g_array_sized_new (TRUE, FALSE, sizeof (gchar *), always->len); - for (i = 0; i < always->len; i++) - { - const gchar *iface = g_ptr_array_index (always, i); - - if (!tp_strdiff (iface, TP_IFACE_CONNECTION_INTERFACE_REQUESTS)) - has_requests = TRUE; - - g_array_append_val (priv->interfaces, iface); - } - if (!has_requests) - g_critical ("Requests interface must always be present"); + for (i = 0; i < always->len; i++) + g_array_append_val (priv->interfaces, g_ptr_array_index (always, i)); g_ptr_array_unref (always); } @@ -935,12 +925,6 @@ tp_base_connection_constructor (GType type, guint n_construct_properties, g_assert (cls->shut_down != NULL); g_assert (cls->start_connecting != NULL); - if (!TP_IS_SVC_CONNECTION_INTERFACE_REQUESTS (self)) - { - g_critical ("Connection must always implement " - "TpSvcConnectionInterfaceRequests"); - } - /* if we fail to connect to D-Bus here, we'll return an error from * register */ tp_base_connection_ensure_dbus (self, NULL); diff --git a/telepathy-glib/connection.c b/telepathy-glib/connection.c index bbdfd64..723e6ab 100644 --- a/telepathy-glib/connection.c +++ b/telepathy-glib/connection.c @@ -567,11 +567,8 @@ _tp_connection_do_get_capabilities_async (TpConnection *self, DEBUG ("%s: Retrieving capabilities", tp_proxy_get_object_path (self)); - /* We don't check whether we actually have this interface here. The - * quark is dbus properties quark is guaranteed to be on every - * TpProxy and only very very old CMs won't have Requests, in case - * someone still has such a relic we'll we'll just handle it when - * they reply to us with an error */ + /* We don't check whether we actually have this interface here. + * The Requests interface is mandatory, and we assume we have it. */ tp_cli_dbus_properties_call_get (self, -1, TP_IFACE_CONNECTION_INTERFACE_REQUESTS, "RequestableChannelClasses", @@ -1091,12 +1088,6 @@ _tp_connection_got_properties (TpProxy *proxy, if (interfaces == NULL) goto error; - if (!tp_strv_contains (interfaces, TP_IFACE_CONNECTION_INTERFACE_REQUESTS)) - { - DEBUG ("Connection does not have Requests/Contacts interface - Broken CM"); - goto error; - } - tp_proxy_add_interfaces (proxy, interfaces); self->priv->ready_enough_for_contacts = TRUE; @@ -1188,6 +1179,13 @@ tp_connection_init (TpConnection *self) self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, TP_TYPE_CONNECTION, TpConnectionPrivate); + /* This is conceptually part of Connection core now. The only reason + * it's kept separate is to reduce D-Bus traffic, since the + * ChannelDispatcher implementation is normally the only thing + * that needs to see its properties or signals. */ + tp_proxy_add_interface_by_id ((TpProxy *) self, + TP_IFACE_QUARK_CONNECTION_INTERFACE_REQUESTS); + self->priv->status = TP_UNKNOWN_CONNECTION_STATUS; self->priv->status_reason = TP_CONNECTION_STATUS_REASON_NONE_SPECIFIED; self->priv->contacts = g_hash_table_new (g_direct_hash, g_direct_equal); @@ -1358,7 +1356,6 @@ static const TpProxyFeature * tp_connection_list_features (TpProxyClass *cls G_GNUC_UNUSED) { static TpProxyFeature features[N_FEAT + 1] = { { 0 } }; - static GQuark need_requests[2] = {0, 0}; static GQuark need_avatars[2] = {0, 0}; static GQuark need_contact_info[2] = {0, 0}; static GQuark need_balance[2] = {0, 0}; @@ -1379,8 +1376,6 @@ tp_connection_list_features (TpProxyClass *cls G_GNUC_UNUSED) features[FEAT_CAPABILITIES].name = TP_CONNECTION_FEATURE_CAPABILITIES; features[FEAT_CAPABILITIES].prepare_async = tp_connection_prepare_capabilities_async; - need_requests[0] = TP_IFACE_QUARK_CONNECTION_INTERFACE_REQUESTS; - features[FEAT_CAPABILITIES].interfaces_needed = need_requests; features[FEAT_AVATAR_REQUIREMENTS].name = TP_CONNECTION_FEATURE_AVATAR_REQUIREMENTS; features[FEAT_AVATAR_REQUIREMENTS].prepare_async = diff --git a/tests/dbus/protocol-objects.c b/tests/dbus/protocol-objects.c index 441cc8d..2a884cc 100644 --- a/tests/dbus/protocol-objects.c +++ b/tests/dbus/protocol-objects.c @@ -90,7 +90,6 @@ teardown (Test *test, } const gchar * const expected_interfaces[] = { - TP_IFACE_CONNECTION_INTERFACE_REQUESTS, NULL }; const gchar * const expected_protocol_interfaces[] = { diff --git a/tests/lib/simple-conn.c b/tests/lib/simple-conn.c index fa7bfda..0f3a090 100644 --- a/tests/lib/simple-conn.c +++ b/tests/lib/simple-conn.c @@ -264,19 +264,6 @@ shut_down (TpBaseConnection *conn) conn); } -static GPtrArray * -get_interfaces_always_present (TpBaseConnection *base) -{ - GPtrArray *interfaces; - - interfaces = TP_BASE_CONNECTION_CLASS ( - tp_tests_simple_connection_parent_class)->get_interfaces_always_present (base); - - g_ptr_array_add (interfaces, TP_IFACE_CONNECTION_INTERFACE_REQUESTS); - - return interfaces; -} - static void tp_tests_simple_connection_class_init (TpTestsSimpleConnectionClass *klass) { @@ -297,8 +284,6 @@ tp_tests_simple_connection_class_init (TpTestsSimpleConnectionClass *klass) base_class->start_connecting = start_connecting; base_class->shut_down = shut_down; - base_class->get_interfaces_always_present = get_interfaces_always_present; - param_spec = g_param_spec_string ("account", "Account name", "The username of this user", NULL, G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); -- 1.8.4.2