summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2012-07-06 17:01:50 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-07-06 17:01:50 +0100
commit528770ed041b494a23dc00b4e0b1f5b4ee5c75f9 (patch)
treeb6c931eee0a86e7bbcc731658879c0b09ead30a9
parent8e509049846753db229d49465a85442d9dc7a009 (diff)
parentec9a04f139900957a59630a7f74015f55dffe100 (diff)
downloadtelepathy-glib-528770ed041b494a23dc00b4e0b1f5b4ee5c75f9.tar.gz
Merge branch '51441-get-interfaces'
Conflicts: telepathy-glib/base-connection-manager.c Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--docs/reference/telepathy-glib-sections.txt3
-rw-r--r--examples/cm/call/conn.c17
-rw-r--r--examples/cm/call/protocol.c7
-rw-r--r--examples/cm/channelspecific/conn.c17
-rw-r--r--examples/cm/channelspecific/protocol.c7
-rw-r--r--examples/cm/contactlist/conn.c18
-rw-r--r--examples/cm/contactlist/protocol.c7
-rw-r--r--examples/cm/echo-message-parts/conn.c17
-rw-r--r--examples/cm/echo-message-parts/protocol.c21
-rw-r--r--examples/cm/extended/conn.c17
-rw-r--r--examples/cm/extended/protocol.c7
-rw-r--r--telepathy-glib/base-connection-manager.c74
-rw-r--r--telepathy-glib/base-connection-manager.h9
-rw-r--r--telepathy-glib/base-connection.c156
-rw-r--r--telepathy-glib/base-connection.h9
-rw-r--r--telepathy-glib/base-contact-list.c7
-rw-r--r--telepathy-glib/base-protocol.c76
-rw-r--r--telepathy-glib/base-protocol.h10
-rw-r--r--telepathy-glib/base-room-config.c4
-rw-r--r--tests/dbus/connection-balance.c20
-rw-r--r--tests/dbus/protocol-objects.c8
-rw-r--r--tests/lib/bug16307-conn.c24
-rw-r--r--tests/lib/contacts-conn.c78
-rw-r--r--tests/lib/echo-cm.c14
-rw-r--r--tests/lib/echo-conn.c18
-rw-r--r--tests/lib/simple-conn.c17
26 files changed, 484 insertions, 178 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 75fa60718..d225152cc 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -61,6 +61,7 @@ TpBaseConnectionCreateChannelFactoriesImpl
TpBaseConnectionCreateChannelManagersImpl
TpBaseConnectionCreateHandleReposImpl
TpBaseConnectionGetUniqueConnectionNameImpl
+TpBaseConnectionGetInterfacesImpl
TpBaseConnectionProc
TpBaseConnectionStartConnectingImpl
tp_base_connection_get_bus_name
@@ -112,6 +113,7 @@ TpCMProtocolSpec
TpBaseConnectionManager
TpBaseConnectionManagerClass
TpBaseConnectionManagerNewConnFunc
+TpBaseConnectionManagerGetInterfacesFunc
tp_base_connection_manager_get_dbus_daemon
tp_base_connection_manager_register
tp_base_connection_manager_add_protocol
@@ -5941,6 +5943,7 @@ TpBaseProtocolIdentifyAccountFunc
TpBaseProtocolGetInterfacesFunc
TpBaseProtocolGetConnectionDetailsFunc
TpBaseProtocolGetAvatarDetailsFunc
+TpBaseProtocolGetInterfacesArrayFunc
<SUBSECTION Standard>
tp_base_protocol_get_type
TP_BASE_PROTOCOL
diff --git a/examples/cm/call/conn.c b/examples/cm/call/conn.c
index 720cbf13f..187e34b08 100644
--- a/examples/cm/call/conn.c
+++ b/examples/cm/call/conn.c
@@ -377,6 +377,21 @@ example_call_connection_get_possible_interfaces (void)
return interfaces_always_present;
}
+static GPtrArray *
+get_interfaces_always_present (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
+ guint i;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ example_call_connection_parent_class)->get_interfaces_always_present (base);
+
+ for (i = 0; interfaces_always_present[i] != NULL; i++)
+ g_ptr_array_add (interfaces, (gchar *) interfaces_always_present[i]);
+
+ return interfaces;
+}
+
static void
example_call_connection_class_init (
ExampleCallConnectionClass *klass)
@@ -397,7 +412,7 @@ example_call_connection_class_init (
base_class->create_channel_managers = create_channel_managers;
base_class->start_connecting = start_connecting;
base_class->shut_down = shut_down;
- base_class->interfaces_always_present = interfaces_always_present;
+ 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,
diff --git a/examples/cm/call/protocol.c b/examples/cm/call/protocol.c
index 4233fdefc..f65c99f75 100644
--- a/examples/cm/call/protocol.c
+++ b/examples/cm/call/protocol.c
@@ -134,12 +134,6 @@ identify_account (TpBaseProtocol *self G_GNUC_UNUSED,
return NULL;
}
-static GStrv
-get_interfaces (TpBaseProtocol *self)
-{
- return NULL;
-}
-
static void
get_connection_details (TpBaseProtocol *self G_GNUC_UNUSED,
GStrv *connection_interfaces,
@@ -183,6 +177,5 @@ example_call_protocol_class_init (
base_class->normalize_contact = normalize_contact;
base_class->identify_account = identify_account;
- base_class->get_interfaces = get_interfaces;
base_class->get_connection_details = get_connection_details;
}
diff --git a/examples/cm/channelspecific/conn.c b/examples/cm/channelspecific/conn.c
index 59dba2707..c14b368fb 100644
--- a/examples/cm/channelspecific/conn.c
+++ b/examples/cm/channelspecific/conn.c
@@ -246,6 +246,21 @@ example_csh_connection_get_possible_interfaces (void)
return interfaces_always_present;
}
+static GPtrArray *
+get_interfaces_always_present (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
+ guint i;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ example_csh_connection_parent_class)->get_interfaces_always_present (base);
+
+ for (i = 0; interfaces_always_present[i] != NULL; i++)
+ g_ptr_array_add (interfaces, (gchar *) interfaces_always_present[i]);
+
+ return interfaces;
+}
+
static void
example_csh_connection_class_init (ExampleCSHConnectionClass *klass)
{
@@ -265,7 +280,7 @@ example_csh_connection_class_init (ExampleCSHConnectionClass *klass)
base_class->create_channel_managers = create_channel_managers;
base_class->start_connecting = start_connecting;
base_class->shut_down = shut_down;
- base_class->interfaces_always_present = interfaces_always_present;
+ 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,
diff --git a/examples/cm/channelspecific/protocol.c b/examples/cm/channelspecific/protocol.c
index 112f7cef0..6874689c0 100644
--- a/examples/cm/channelspecific/protocol.c
+++ b/examples/cm/channelspecific/protocol.c
@@ -174,12 +174,6 @@ identify_account (TpBaseProtocol *self G_GNUC_UNUSED,
return NULL;
}
-static GStrv
-get_interfaces (TpBaseProtocol *self)
-{
- return NULL;
-}
-
static void
get_connection_details (TpBaseProtocol *self G_GNUC_UNUSED,
GStrv *connection_interfaces,
@@ -223,6 +217,5 @@ example_csh_protocol_class_init (
base_class->normalize_contact = normalize_contact;
base_class->identify_account = identify_account;
- base_class->get_interfaces = get_interfaces;
base_class->get_connection_details = get_connection_details;
}
diff --git a/examples/cm/contactlist/conn.c b/examples/cm/contactlist/conn.c
index ab4507740..a28ae8547 100644
--- a/examples/cm/contactlist/conn.c
+++ b/examples/cm/contactlist/conn.c
@@ -410,6 +410,22 @@ example_contact_list_connection_get_possible_interfaces (void)
return interfaces_always_present;
}
+static GPtrArray *
+get_interfaces_always_present (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
+ guint i;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ example_contact_list_connection_parent_class)->get_interfaces_always_present (
+ base);
+
+ for (i = 0; interfaces_always_present[i] != NULL; i++)
+ g_ptr_array_add (interfaces, (gchar *) interfaces_always_present[i]);
+
+ return interfaces;
+}
+
static void
example_contact_list_connection_class_init (
ExampleContactListConnectionClass *klass)
@@ -430,7 +446,7 @@ example_contact_list_connection_class_init (
base_class->create_channel_managers = create_channel_managers;
base_class->start_connecting = start_connecting;
base_class->shut_down = shut_down;
- base_class->interfaces_always_present = interfaces_always_present;
+ 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,
diff --git a/examples/cm/contactlist/protocol.c b/examples/cm/contactlist/protocol.c
index fcc05ebed..3f76e1785 100644
--- a/examples/cm/contactlist/protocol.c
+++ b/examples/cm/contactlist/protocol.c
@@ -134,12 +134,6 @@ identify_account (TpBaseProtocol *self G_GNUC_UNUSED,
return NULL;
}
-static GStrv
-get_interfaces (TpBaseProtocol *self)
-{
- return NULL;
-}
-
static void
get_connection_details (TpBaseProtocol *self G_GNUC_UNUSED,
GStrv *connection_interfaces,
@@ -183,6 +177,5 @@ example_contact_list_protocol_class_init (
base_class->normalize_contact = normalize_contact;
base_class->identify_account = identify_account;
- base_class->get_interfaces = get_interfaces;
base_class->get_connection_details = get_connection_details;
}
diff --git a/examples/cm/echo-message-parts/conn.c b/examples/cm/echo-message-parts/conn.c
index d93229f15..115622bd1 100644
--- a/examples/cm/echo-message-parts/conn.c
+++ b/examples/cm/echo-message-parts/conn.c
@@ -172,6 +172,21 @@ example_echo_2_connection_get_possible_interfaces (void)
return interfaces_always_present;
}
+static GPtrArray *
+get_interfaces_always_present (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
+ guint i;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ example_echo_2_connection_parent_class)->get_interfaces_always_present (base);
+
+ for (i = 0; interfaces_always_present[i] != NULL; i++)
+ g_ptr_array_add (interfaces, (gchar *) interfaces_always_present[i]);
+
+ return interfaces;
+}
+
static void
constructed (GObject *object)
{
@@ -206,7 +221,7 @@ example_echo_2_connection_class_init (ExampleEcho2ConnectionClass *klass)
base_class->create_channel_managers = create_channel_managers;
base_class->start_connecting = start_connecting;
base_class->shut_down = shut_down;
- base_class->interfaces_always_present = interfaces_always_present;
+ 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,
diff --git a/examples/cm/echo-message-parts/protocol.c b/examples/cm/echo-message-parts/protocol.c
index 7981fedaa..4512216b9 100644
--- a/examples/cm/echo-message-parts/protocol.c
+++ b/examples/cm/echo-message-parts/protocol.c
@@ -21,11 +21,6 @@ G_DEFINE_TYPE_WITH_CODE (ExampleEcho2Protocol, example_echo_2_protocol,
TP_TYPE_BASE_PROTOCOL,
G_IMPLEMENT_INTERFACE (TP_TYPE_PROTOCOL_ADDRESSING, addressing_iface_init))
-const gchar * const protocol_interfaces[] = {
- TP_IFACE_PROTOCOL_INTERFACE_AVATARS,
- TP_IFACE_PROTOCOL_INTERFACE_ADDRESSING,
- NULL };
-
const gchar * const supported_avatar_mime_types[] = {
"image/png",
"image/jpeg",
@@ -127,10 +122,18 @@ identify_account (TpBaseProtocol *self G_GNUC_UNUSED,
return NULL;
}
-static GStrv
-get_interfaces (TpBaseProtocol *self)
+static GPtrArray *
+get_interfaces_array (TpBaseProtocol *self)
{
- return g_strdupv ((GStrv) protocol_interfaces);
+ GPtrArray *interfaces;
+
+ interfaces = TP_BASE_PROTOCOL_CLASS (
+ example_echo_2_protocol_parent_class)->get_interfaces_array (self);
+
+ g_ptr_array_add (interfaces, TP_IFACE_PROTOCOL_INTERFACE_AVATARS);
+ g_ptr_array_add (interfaces, TP_IFACE_PROTOCOL_INTERFACE_ADDRESSING);
+
+ return interfaces;
}
static void
@@ -235,7 +238,7 @@ example_echo_2_protocol_class_init (
base_class->normalize_contact = normalize_contact;
base_class->identify_account = identify_account;
- base_class->get_interfaces = get_interfaces;
+ base_class->get_interfaces_array = get_interfaces_array;
base_class->get_connection_details = get_connection_details;
base_class->get_avatar_details = get_avatar_details;
}
diff --git a/examples/cm/extended/conn.c b/examples/cm/extended/conn.c
index 8b2560564..873fcf2b0 100644
--- a/examples/cm/extended/conn.c
+++ b/examples/cm/extended/conn.c
@@ -203,6 +203,21 @@ example_extended_connection_get_possible_interfaces (void)
return interfaces_always_present;
}
+static GPtrArray *
+get_interfaces_always_present (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
+ guint i;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ example_extended_connection_parent_class)->get_interfaces_always_present (base);
+
+ for (i = 0; interfaces_always_present[i] != NULL; i++)
+ g_ptr_array_add (interfaces, (gchar *) interfaces_always_present[i]);
+
+ return interfaces;
+}
+
static void
example_extended_connection_class_init (ExampleExtendedConnectionClass *klass)
{
@@ -223,7 +238,7 @@ example_extended_connection_class_init (ExampleExtendedConnectionClass *klass)
base_class->start_connecting = start_connecting;
base_class->shut_down = shut_down;
- base_class->interfaces_always_present = interfaces_always_present;
+ 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,
diff --git a/examples/cm/extended/protocol.c b/examples/cm/extended/protocol.c
index 0a85a504c..0b20659bd 100644
--- a/examples/cm/extended/protocol.c
+++ b/examples/cm/extended/protocol.c
@@ -106,12 +106,6 @@ identify_account (TpBaseProtocol *self G_GNUC_UNUSED,
return NULL;
}
-static GStrv
-get_interfaces (TpBaseProtocol *self)
-{
- return NULL;
-}
-
static void
get_connection_details (TpBaseProtocol *self G_GNUC_UNUSED,
GStrv *connection_interfaces,
@@ -167,6 +161,5 @@ example_extended_protocol_class_init (
base_class->normalize_contact = normalize_contact;
base_class->identify_account = identify_account;
- base_class->get_interfaces = get_interfaces;
base_class->get_connection_details = get_connection_details;
}
diff --git a/telepathy-glib/base-connection-manager.c b/telepathy-glib/base-connection-manager.c
index e7b1a6090..a9562be92 100644
--- a/telepathy-glib/base-connection-manager.c
+++ b/telepathy-glib/base-connection-manager.c
@@ -209,9 +209,17 @@ _tp_legacy_protocol_new (TpBaseConnectionManager *cm,
* D-Bus object paths and bus names. Must contain only letters, digits
* and underscores, and may not start with a digit. Must be filled in by
* subclasses in their class_init function.
- * @interfaces: A #GStrv of extra D-Bus interfaces implemented
- * by instances of this class, which may be filled in by subclasses. The
- * default is to list no additional interfaces. Since: 0.11.11
+ * @protocol_params: An array of #TpCMProtocolSpec structures representing
+ * the protocols this connection manager supports, terminated by a structure
+ * whose name member is %NULL; or %NULL if this CM uses Protocol objects.
+ * @new_connection: A #TpBaseConnectionManagerNewConnFunc used to construct
+ * new connections, or %NULL if this CM uses Protocol objects.
+ * @get_interfaces: Returns a #GPtrArray of static strings of extra
+ * D-Bus interfaces implemented by instances of this class, which may be
+ * filled in by subclasses. The default is to list no additional interfaces.
+ * Implementations must first chainup on parent class implementation and then
+ * add extra interfaces to the #GPtrArray. Replaces @interfaces. Since:
+ * 0.UNRELEASED
*
* The class structure for #TpBaseConnectionManager.
*
@@ -250,6 +258,37 @@ _tp_legacy_protocol_new (TpBaseConnectionManager *cm,
* Returns: the new connection object, or %NULL on error.
*/
+/**
+ * TpBaseConnectionManagerGetInterfacesFunc:
+ * @self: a #TpBaseConnectionManager
+ *
+ * Signature of an implementation of
+ * #TpBaseConnectionManagerClass.get_interfaces virtual function.
+ *
+ * Implementation must first chainup on parent class implementation and then
+ * add extra interfaces into the #GPtrArray.
+ *
+ * |[
+ * static GPtrArray *
+ * my_connection_manager_get_interfaces (TpBaseConnectionManager *self)
+ * {
+ * GPtrArray *interfaces;
+ *
+ * interfaces = TP_BASE_CONNECTION_MANAGER_CLASS (
+ * my_connection_manager_parent_class)->get_interfaces (self);
+ *
+ * g_ptr_array_add (interfaces, TP_IFACE_BADGERS);
+ *
+ * return interfaces;
+ * }
+ * ]|
+ *
+ * Returns: (transfer container): a #GPtrArray of static strings for D-Bus
+ * interfaces implemented by this client.
+ *
+ * Since: 0.UNRELEASED
+ */
+
static void service_iface_init (gpointer, gpointer);
G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TpBaseConnectionManager,
@@ -391,7 +430,15 @@ tp_base_connection_manager_get_property (GObject *object,
break;
case PROP_INTERFACES:
- g_value_set_boxed (value, cls->interfaces);
+ {
+ GPtrArray *interfaces = cls->get_interfaces (self);
+
+ /* make sure there's a terminating NULL */
+ g_ptr_array_add (interfaces, NULL);
+ g_value_set_boxed (value, interfaces->pdata);
+
+ g_ptr_array_unref (interfaces);
+ }
break;
case PROP_PROTOCOLS:
@@ -451,6 +498,23 @@ tp_base_connection_manager_set_property (GObject *object,
}
}
+static GPtrArray *
+tp_base_connection_manager_get_interfaces (TpBaseConnectionManager *self)
+{
+ GPtrArray *interfaces = g_ptr_array_new ();
+ const char * const *ptr;
+
+ /* copy the klass->interfaces property for backwards compatibility */
+ for (ptr = TP_BASE_CONNECTION_MANAGER_GET_CLASS (self)->interfaces;
+ ptr != NULL && *ptr != NULL;
+ ptr++)
+ {
+ g_ptr_array_add (interfaces, (char *) *ptr);
+ }
+
+ return interfaces;
+}
+
static void
tp_base_connection_manager_class_init (TpBaseConnectionManagerClass *klass)
{
@@ -468,6 +532,8 @@ tp_base_connection_manager_class_init (TpBaseConnectionManagerClass *klass)
object_class->dispose = tp_base_connection_manager_dispose;
object_class->finalize = tp_base_connection_manager_finalize;
+ klass->get_interfaces = tp_base_connection_manager_get_interfaces;
+
/**
* TpBaseConnectionManager:dbus-daemon:
*
diff --git a/telepathy-glib/base-connection-manager.h b/telepathy-glib/base-connection-manager.h
index 07652ef66..fe15b70b1 100644
--- a/telepathy-glib/base-connection-manager.h
+++ b/telepathy-glib/base-connection-manager.h
@@ -63,6 +63,9 @@ typedef TpBaseConnection *(*TpBaseConnectionManagerNewConnFunc)(
TpBaseConnectionManager *self, const gchar *proto,
TpIntset *params_present, void *parsed_params, GError **error);
+typedef GPtrArray * (*TpBaseConnectionManagerGetInterfacesFunc) (
+ TpBaseConnectionManager *self);
+
struct _TpBaseConnectionManagerClass {
GObjectClass parent_class;
@@ -72,10 +75,12 @@ struct _TpBaseConnectionManagerClass {
TpBaseConnectionManagerNewConnFunc _TP_SEAL (new_connection);
/*< public >*/
- const gchar * const *interfaces;
+ /*<private>*/
+ const gchar * const *_TP_SEAL (interfaces);
+ /*<public>*/
+ TpBaseConnectionManagerGetInterfacesFunc get_interfaces;
/*<private>*/
- gpointer _future2;
gpointer _future3;
gpointer _future4;
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c
index f8b6137b5..1983e94be 100644
--- a/telepathy-glib/base-connection.c
+++ b/telepathy-glib/base-connection.c
@@ -122,6 +122,38 @@
*/
/**
+ * TpBaseChannelGetInterfacesImpl:
+ * @chan: a channel
+ *
+ * Signature of an implementation of
+ * #TpBaseConnectionClass.get_interfaces_always_present virtual
+ * function.
+ *
+ * Implementation must first chainup on parent class implementation and then
+ * add extra interfaces into the #GPtrArray.
+ *
+ * |[
+ * static GPtrArray *
+ * my_channel_get_interfaces_always_present (TpBaseConnection *self)
+ * {
+ * GPtrArray *interfaces;
+ *
+ * interfaces = TP_BASE_CONNECTION_CLASS (
+ * my_connection_parent_class)->get_interfaces_always_present (self);
+ *
+ * g_ptr_array_add (interfaces, TP_IFACE_BADGERS);
+ *
+ * return interfaces;
+ * }
+ * ]|
+ *
+ * Returns: (transfer container): a #GPtrArray of static strings for D-Bus
+ * interfaces implemented by this client.
+ *
+ * Since: 0.UNRELEASED
+ */
+
+/**
* TpBaseConnectionClass:
* @parent_class: The superclass' structure
* @create_handle_repos: Fill in suitable handle repositories in the
@@ -151,12 +183,12 @@
* @start_connecting: Asynchronously start connecting - called to implement
* the Connect D-Bus method. See #TpBaseConnectionStartConnectingImpl for
* details. May not be left as %NULL.
- * @interfaces_always_present: A strv of extra D-Bus interfaces which are
- * always implemented by instances of this class, which may be filled in
- * by subclasses. The default is to list no additional interfaces.
- * Individual instances may detect which additional interfaces they support
- * and signal them before going to state CONNECTED by calling
- * tp_base_connection_add_interfaces().
+ * @get_interfaces_always_present: Returns a #GPtrArray of extra D-Bus
+ * interfaces which are always implemented by instances of this class,
+ * which may be filled in by subclasses. The default is to list no
+ * additional interfaces. Individual instances may detect which
+ * additional interfaces they support and signal them before going
+ * to state CONNECTED by calling tp_base_connection_add_interfaces().
* @create_channel_managers: Create an array of channel managers for this
* Connection. At least one of this or @create_channel_factories must be set
* by subclasses to a non-%NULL value. Since: 0.7.15
@@ -371,9 +403,8 @@ struct _TpBaseConnectionPrivate
TpHandleRepoIface *handles[TP_NUM_HANDLE_TYPES];
- /* If not %NULL, contains strings representing our interfaces.
- * If %NULL, we have no interfaces except those in
- * klass->interfaces_always_present (i.e. this is lazily allocated).
+ /* Created in constructed, this is an array of static strings which
+ * represent the interfaces on this connection.
*
* Note that this is a GArray of gchar*, not a GPtrArray,
* so that we can use GArray's convenient auto-null-termination. */
@@ -1249,6 +1280,29 @@ _tp_base_connection_set_handle_repo (TpBaseConnection *self,
self->priv->handles[handle_type] = g_object_ref (handle_repo);
}
+static void
+tp_base_connection_create_interfaces_array (TpBaseConnection *self)
+{
+ TpBaseConnectionPrivate *priv = self->priv;
+ TpBaseConnectionClass *klass = TP_BASE_CONNECTION_GET_CLASS (self);
+ GPtrArray *always;
+ guint i;
+
+ g_assert (priv->interfaces == NULL);
+
+ always = klass->get_interfaces_always_present (self);
+
+ priv->interfaces = g_array_sized_new (TRUE, FALSE, sizeof (gchar *),
+ always->len);
+ for (i = 0; i < always->len; i++)
+ {
+ g_array_append_val (priv->interfaces,
+ g_ptr_array_index (always, i));
+ }
+
+ g_ptr_array_unref (always);
+}
+
static GObject *
tp_base_connection_constructor (GType type, guint n_construct_properties,
GObjectConstructParam *construct_params)
@@ -1309,6 +1363,8 @@ tp_base_connection_constructor (GType type, guint n_construct_properties,
(GCallback) manager_channel_closed_cb, self);
}
+ tp_base_connection_create_interfaces_array (self);
+
priv->been_constructed = TRUE;
return (GObject *) self;
@@ -1469,6 +1525,23 @@ conn_requests_get_dbus_property (GObject *object,
}
}
+static GPtrArray *
+tp_base_connection_get_interfaces_always_present (TpBaseConnection *self)
+{
+ GPtrArray *interfaces = g_ptr_array_new ();
+ const gchar **ptr;
+
+ /* copy the klass->interfaces_always_present property for backwards
+ * compatibility */
+ for (ptr = TP_BASE_CONNECTION_GET_CLASS (self)->interfaces_always_present;
+ ptr != NULL && *ptr != NULL;
+ ptr++)
+ {
+ g_ptr_array_add (interfaces, (gchar *) *ptr);
+ }
+
+ return interfaces;
+}
static void
tp_base_connection_class_init (TpBaseConnectionClass *klass)
@@ -1495,6 +1568,9 @@ tp_base_connection_class_init (TpBaseConnectionClass *klass)
object_class->get_property = tp_base_connection_get_property;
object_class->set_property = tp_base_connection_set_property;
+ klass->get_interfaces_always_present =
+ tp_base_connection_get_interfaces_always_present;
+
/**
* TpBaseConnection:protocol: (skip)
*
@@ -1977,20 +2053,7 @@ tp_base_connection_get_interfaces (TpBaseConnection *self)
{
g_return_val_if_fail (TP_IS_BASE_CONNECTION (self), NULL);
- if (self->priv->interfaces != NULL)
- {
- /* There are some extra interfaces for this connection */
- return (const gchar * const *)(self->priv->interfaces->data);
- }
- else
- {
- TpBaseConnectionClass *klass = TP_BASE_CONNECTION_GET_CLASS (self);
-
- /* We only have the interfaces that are always present.
- * Instead of bothering to duplicate the static
- * array into the GArray, we just use it directly */
- return (const gchar * const *)klass->interfaces_always_present;
- }
+ return (const gchar * const *)(self->priv->interfaces->data);
}
static void
@@ -3123,62 +3186,21 @@ tp_base_connection_change_status (TpBaseConnection *self,
* Add some interfaces to the list supported by this Connection. If you're
* going to call this function at all, you must do so before moving to state
* CONNECTED (or DISCONNECTED); if you don't call it, only the set of
- * interfaces always present (@interfaces_always_present in
+ * interfaces always present (@get_interfaces_always_present in
* #TpBaseConnectionClass) will be supported.
*/
void
tp_base_connection_add_interfaces (TpBaseConnection *self,
const gchar **interfaces)
{
- guint i, n_new;
TpBaseConnectionPrivate *priv = self->priv;
- TpBaseConnectionClass *klass = TP_BASE_CONNECTION_GET_CLASS (self);
g_return_if_fail (TP_IS_BASE_CONNECTION (self));
g_return_if_fail (self->status != TP_CONNECTION_STATUS_CONNECTED);
g_return_if_fail (self->status != TP_CONNECTION_STATUS_DISCONNECTED);
- if (interfaces == NULL || interfaces[0] == NULL)
- {
- /* If user tries to add no new interfaces, ignore it */
- return;
- }
-
- n_new = g_strv_length ((gchar **) interfaces);
-
- if (priv->interfaces)
- {
- guint size = priv->interfaces->len;
-
- g_array_set_size (priv->interfaces, size + n_new);
- for (i = 0; i < n_new; i++)
- {
- g_array_index (priv->interfaces, const gchar *, size + i) =
- interfaces[i];
- }
- }
- else
- {
- /* It's the first time anyone has added interfaces - create the array */
- guint n_static = 0;
-
- if (klass->interfaces_always_present)
- {
- n_static = g_strv_length (
- (gchar **) klass->interfaces_always_present);
- }
- priv->interfaces = g_array_sized_new (TRUE, FALSE, sizeof (gchar *),
- n_static + n_new);
- for (i = 0; i < n_static; i++)
- {
- g_array_append_val (priv->interfaces,
- klass->interfaces_always_present[i]);
- }
- for (i = 0; i < n_new; i++)
- {
- g_array_append_val (priv->interfaces, interfaces[i]);
- }
- }
+ for (; interfaces != NULL && *interfaces != NULL; interfaces++)
+ g_array_append_val (priv->interfaces, *interfaces);
}
static void
diff --git a/telepathy-glib/base-connection.h b/telepathy-glib/base-connection.h
index cd8c70e75..41504e423 100644
--- a/telepathy-glib/base-connection.h
+++ b/telepathy-glib/base-connection.h
@@ -60,6 +60,9 @@ typedef GPtrArray *(*TpBaseConnectionCreateChannelManagersImpl) (
typedef gchar *(*TpBaseConnectionGetUniqueConnectionNameImpl) (
TpBaseConnection *self);
+typedef GPtrArray *(*TpBaseConnectionGetInterfacesImpl) (
+ TpBaseConnection *self);
+
struct _TpBaseConnection {
/*<private>*/
GObject parent;
@@ -103,12 +106,14 @@ struct _TpBaseConnectionClass {
TpBaseConnectionStartConnectingImpl start_connecting;
- const gchar **interfaces_always_present;
+ /*<private>*/
+ const gchar **_TP_SEAL (interfaces_always_present);
+ /*<public>*/
+ TpBaseConnectionGetInterfacesImpl get_interfaces_always_present;
TpBaseConnectionCreateChannelManagersImpl create_channel_managers;
/*<private>*/
- gpointer _future2;
gpointer _future3;
gpointer _future4;
diff --git a/telepathy-glib/base-contact-list.c b/telepathy-glib/base-contact-list.c
index 107b4c11c..7e6275308 100644
--- a/telepathy-glib/base-contact-list.c
+++ b/telepathy-glib/base-contact-list.c
@@ -75,7 +75,8 @@
* // ...
* ]|
* <para>and include %TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST in
- * #TpBaseConnectionClass.interfaces_always_present;</para>
+ * the output of
+ * #TpBaseConnectionClass.get_interfaces_always_present;</para>
* </listitem>
* <listitem>
* <para>in the #TpBaseConnectionClass.create_channel_managers
@@ -91,8 +92,8 @@
*
* To support user-defined contact groups too, additionally implement
* %TP_TYPE_CONTACT_GROUP_LIST in the #TpBaseContactList subclass, add the
- * %TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS interface to
- * #TpBaseConnectionClass.interfaces_always_present, and implement the
+ * %TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS interface to the output of
+ * #TpBaseConnectionClass.get interfaces_always_present, and implement the
* %TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_GROUPS in the #TpBaseConnection
* subclass using tp_base_contact_list_mixin_groups_iface_init().
*
diff --git a/telepathy-glib/base-protocol.c b/telepathy-glib/base-protocol.c
index 3732c5bda..6621bd65e 100644
--- a/telepathy-glib/base-protocol.c
+++ b/telepathy-glib/base-protocol.c
@@ -414,6 +414,37 @@ tp_cm_param_filter_string_nonempty (const TpCMParamSpec *paramspec,
*/
/**
+ * TpBaseProtocolGetInterfacesArrayFunc:
+ * @self: a #TpBaseProtocol
+ *
+ * Signature of an implementation of
+ * #TpBaseProtocolClass.get_interfaces_array virtual function.
+ *
+ * Implementation must first chainup on parent class implementation and then
+ * add extra interfaces into the #GPtrArray.
+ *
+ * |[
+ * static GPtrArray *
+ * my_protocol_get_interfaces_array (TpBaseProtocol *self)
+ * {
+ * GPtrArray *interfaces;
+ *
+ * interfaces = TP_BASE_PROTOCOL_CLASS (
+ * my_protocol_parent_class)->get_interfaces_array (self);
+ *
+ * g_ptr_array_add (interfaces, TP_IFACE_BADGERS);
+ *
+ * return interfaces;
+ * }
+ * ]|
+ *
+ * Returns: (transfer container): a #GPtrArray of static strings for D-Bus
+ * interfaces implemented by this client.
+ *
+ * Since: 0.UNRELEASED
+ */
+
+/**
* TP_TYPE_PROTOCOL_ADDRESSING:
*
* Interface representing a #TpBaseProtocol that implements
@@ -517,8 +548,10 @@ tp_cm_param_filter_string_nonempty (const TpCMParamSpec *paramspec,
* and must either return a newly allocated string that represents the
* "identity" of the parameters in @asv (usually the "account" parameter),
* or %NULL with an error raised via @error
- * @get_interfaces: a callback used to implement the Interfaces D-Bus property;
- * it must return a newly allocated #GStrv containing D-Bus interface names
+ * @get_interfaces_array: a callback used to implement the Interfaces
+ * D-Bus property; The implementation must first chainup to parent
+ * class implementation and then add extra interfaces to the
+ * #GPtrArray. Replaces @get_interfaces
* @get_connection_details: a callback used to implement the Protocol D-Bus
* properties that represent details of the connections provided by this
* protocol
@@ -633,14 +666,17 @@ tp_base_protocol_constructed (GObject *object)
TpBaseProtocolClass *cls = TP_BASE_PROTOCOL_GET_CLASS (self);
void (*chain_up) (GObject *) =
((GObjectClass *) tp_base_protocol_parent_class)->constructed;
+ GPtrArray *ifaces;
if (chain_up != NULL)
chain_up (object);
- if (cls->get_interfaces != NULL)
- {
- self->priv->interfaces = (cls->get_interfaces) (self);
- }
+ /* TODO: when we don't have to deal with
+ * TpBaseProtocolClass.get_interfaces, we won't have to do any of this */
+ ifaces = (cls->get_interfaces_array) (self);
+ g_ptr_array_add (ifaces, NULL);
+ self->priv->interfaces = g_strdupv ((GStrv) ifaces->pdata);
+ g_ptr_array_unref (ifaces);
if (cls->get_connection_details != NULL)
{
@@ -1112,6 +1148,32 @@ protocol_properties_getter (GObject *object,
}
}
+static GPtrArray *
+tp_base_protocol_get_interfaces_array (TpBaseProtocol *self)
+{
+ TpBaseProtocolClass *klass = TP_BASE_PROTOCOL_GET_CLASS (self);
+ GPtrArray *interfaces = g_ptr_array_new ();
+ gchar **old_ifaces = NULL, **ptr;
+
+ /* copy the klass->get_interfaces property value for backwards
+ * compatibility */
+ if (klass->get_interfaces != NULL)
+ old_ifaces = klass->get_interfaces (self);
+
+ for (ptr = old_ifaces;
+ ptr != NULL && *ptr != NULL;
+ ptr++)
+ {
+ g_ptr_array_add (interfaces, (char *) *ptr);
+ }
+
+ /* TODO: old_ifaces is leaked because get_interfaces returns a new
+ * GStrv, but we want static strings nowadays. leaking is better
+ * than crashing though. this'll be fixed soon */
+
+ return interfaces;
+}
+
static void
tp_base_protocol_class_init (TpBaseProtocolClass *klass)
{
@@ -1178,6 +1240,8 @@ tp_base_protocol_class_init (TpBaseProtocolClass *klass)
object_class->set_property = tp_base_protocol_set_property;
object_class->finalize = tp_base_protocol_finalize;
+ klass->get_interfaces_array = tp_base_protocol_get_interfaces_array;
+
g_object_class_install_property (object_class, PROP_NAME,
g_param_spec_string ("name",
"Name of this protocol",
diff --git a/telepathy-glib/base-protocol.h b/telepathy-glib/base-protocol.h
index 6fd863c90..20fbf0ee2 100644
--- a/telepathy-glib/base-protocol.h
+++ b/telepathy-glib/base-protocol.h
@@ -139,6 +139,8 @@ typedef void (*TpBaseProtocolGetAvatarDetailsFunc) (TpBaseProtocol *self,
guint *max_width,
guint *max_bytes);
+typedef GPtrArray * (*TpBaseProtocolGetInterfacesArrayFunc) (TpBaseProtocol *self);
+
struct _TpBaseProtocolClass
{
GObjectClass parent_class;
@@ -157,7 +159,11 @@ struct _TpBaseProtocolClass
GHashTable *asv,
GError **error);
- GStrv (*get_interfaces) (TpBaseProtocol *self);
+ /*<private>*/
+ GStrv (*_TP_SEAL (get_interfaces)) (TpBaseProtocol *self);
+ /*<public>*/
+
+ TpBaseProtocolGetInterfacesArrayFunc get_interfaces_array;
void (*get_connection_details) (TpBaseProtocol *self,
GStrv *connection_interfaces,
@@ -173,7 +179,7 @@ struct _TpBaseProtocolClass
GStrv (*dup_authentication_types) (TpBaseProtocol *self);
/*<private>*/
- GCallback padding[5];
+ GCallback padding[4];
TpBaseProtocolClassPrivate *priv;
};
diff --git a/telepathy-glib/base-room-config.c b/telepathy-glib/base-room-config.c
index 8d40e727e..d37e62d6b 100644
--- a/telepathy-glib/base-room-config.c
+++ b/telepathy-glib/base-room-config.c
@@ -71,8 +71,8 @@
* ]|
* </listitem>
* <listitem>
- * <para>include %TP_IFACE_CHANNEL_INTERFACE_ROOM_CONFIG in
- * #TpBaseChannelClass.interfaces.</para>
+ * <para>include %TP_IFACE_CHANNEL_INTERFACE_ROOM_CONFIG in the return of
+ * #TpBaseChannelClass.get_interfaces.</para>
* </listitem>
* </itemizedlist>
*
diff --git a/tests/dbus/connection-balance.c b/tests/dbus/connection-balance.c
index 3140e404f..4d022aba3 100644
--- a/tests/dbus/connection-balance.c
+++ b/tests/dbus/connection-balance.c
@@ -79,6 +79,19 @@ balanced_connection_init (BalancedConnection *self G_GNUC_UNUSED)
{
}
+static GPtrArray *
+get_interfaces (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ balanced_connection_parent_class)->get_interfaces_always_present (base);
+
+ g_ptr_array_add (interfaces, TP_IFACE_CONNECTION_INTERFACE_BALANCE);
+
+ return interfaces;
+}
+
static void
balanced_connection_class_init (BalancedConnectionClass *cls)
{
@@ -91,14 +104,9 @@ balanced_connection_class_init (BalancedConnectionClass *cls)
{ NULL }
};
- static const gchar *interfaces[] = {
- TP_IFACE_CONNECTION_INTERFACE_BALANCE,
- NULL
- };
-
object_class->get_property = balanced_connection_get_property;
- base_class->interfaces_always_present = interfaces;
+ base_class->get_interfaces_always_present = get_interfaces;
g_object_class_install_property (object_class, PROP_ACCOUNT_BALANCE,
g_param_spec_boxed ("account-balance", "", "",
diff --git a/tests/dbus/protocol-objects.c b/tests/dbus/protocol-objects.c
index 1645751d5..dcaea52f2 100644
--- a/tests/dbus/protocol-objects.c
+++ b/tests/dbus/protocol-objects.c
@@ -119,6 +119,10 @@ const gchar * const expected_protocol_interfaces[] = {
TP_IFACE_PROTOCOL_INTERFACE_ADDRESSING,
NULL };
+const gchar * const expected_cm_interfaces[] = {
+ "im.telepathy.Tests.Example",
+ NULL };
+
const gchar * const expected_supported_avatar_mime_types[] = {
"image/png",
"image/jpeg",
@@ -333,8 +337,8 @@ test_protocols_property_old (Test *test,
g_assert_no_error (test->error);
g_assert (tp_asv_lookup (properties, "Interfaces") != NULL);
- test_assert_empty_strv (tp_asv_get_boxed (properties, "Interfaces",
- G_TYPE_STRV));
+ tp_tests_assert_strv_equals (tp_asv_get_boxed (properties,
+ "Interfaces", G_TYPE_STRV), expected_cm_interfaces);
protocols = tp_asv_get_boxed (properties, "Protocols",
TP_HASH_TYPE_PROTOCOL_PROPERTIES_MAP);
diff --git a/tests/lib/bug16307-conn.c b/tests/lib/bug16307-conn.c
index cbabf7393..414d931a0 100644
--- a/tests/lib/bug16307-conn.c
+++ b/tests/lib/bug16307-conn.c
@@ -135,18 +135,28 @@ start_connecting (TpBaseConnection *conn,
return TRUE;
}
+static GPtrArray *
+get_interfaces_always_present (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ tp_tests_bug16307_connection_parent_class)->get_interfaces_always_present (base);
+
+ g_ptr_array_add (interfaces, TP_IFACE_CONNECTION_INTERFACE_ALIASING);
+ g_ptr_array_add (interfaces, TP_IFACE_CONNECTION_INTERFACE_CAPABILITIES);
+ g_ptr_array_add (interfaces, TP_IFACE_CONNECTION_INTERFACE_PRESENCE);
+ g_ptr_array_add (interfaces, TP_IFACE_CONNECTION_INTERFACE_AVATARS);
+
+ return interfaces;
+}
+
static void
tp_tests_bug16307_connection_class_init (TpTestsBug16307ConnectionClass *klass)
{
TpBaseConnectionClass *base_class =
(TpBaseConnectionClass *) klass;
GObjectClass *object_class = (GObjectClass *) klass;
- static const gchar *interfaces_always_present[] = {
- TP_IFACE_CONNECTION_INTERFACE_ALIASING,
- TP_IFACE_CONNECTION_INTERFACE_CAPABILITIES,
- TP_IFACE_CONNECTION_INTERFACE_PRESENCE,
- TP_IFACE_CONNECTION_INTERFACE_AVATARS,
- NULL };
static TpDBusPropertiesMixinPropImpl connection_properties[] = {
{ "Status", "dbus-status-except-i-broke-it", NULL },
{ NULL }
@@ -157,7 +167,7 @@ tp_tests_bug16307_connection_class_init (TpTestsBug16307ConnectionClass *klass)
base_class->start_connecting = start_connecting;
- base_class->interfaces_always_present = interfaces_always_present;
+ base_class->get_interfaces_always_present = get_interfaces_always_present;
signals[SIGNAL_GET_STATUS_RECEIVED] = g_signal_new ("get-status-received",
G_OBJECT_CLASS_TYPE (klass),
diff --git a/tests/lib/contacts-conn.c b/tests/lib/contacts-conn.c
index 6f3088093..5b0dcbba2 100644
--- a/tests/lib/contacts-conn.c
+++ b/tests/lib/contacts-conn.c
@@ -540,13 +540,10 @@ create_channel_managers (TpBaseConnection *conn)
return ret;
}
-static void
-tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass)
+static GPtrArray *
+tp_tests_contacts_get_interfaces_always_present (TpBaseConnection *base)
{
- TpBaseConnectionClass *base_class =
- (TpBaseConnectionClass *) klass;
- GObjectClass *object_class = (GObjectClass *) klass;
- TpPresenceMixinClass *mixin_class;
+ GPtrArray *interfaces;
static const gchar *interfaces_always_present[] = {
TP_IFACE_CONNECTION_INTERFACE_ALIASING,
TP_IFACE_CONNECTION_INTERFACE_AVATARS,
@@ -559,8 +556,25 @@ tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass)
TP_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES,
TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES,
TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO,
- TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
NULL };
+ guint i;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ tp_tests_contacts_connection_parent_class)->get_interfaces_always_present (base);
+
+ for (i = 0; interfaces_always_present[i] != NULL; i++)
+ g_ptr_array_add (interfaces, (gchar *) interfaces_always_present[i]);
+
+ return interfaces;
+}
+
+static void
+tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass)
+{
+ TpBaseConnectionClass *base_class =
+ (TpBaseConnectionClass *) klass;
+ GObjectClass *object_class = (GObjectClass *) klass;
+ TpPresenceMixinClass *mixin_class;
static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
{ TP_IFACE_CONNECTION_INTERFACE_AVATARS,
conn_avatars_properties_getter,
@@ -579,7 +593,7 @@ tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass)
object_class->finalize = finalize;
g_type_class_add_private (klass, sizeof (TpTestsContactsConnectionPrivate));
- base_class->interfaces_always_present = interfaces_always_present;
+ base_class->get_interfaces_always_present = tp_tests_contacts_get_interfaces_always_present;
base_class->create_channel_managers = create_channel_managers;
tp_contacts_mixin_class_init (object_class,
@@ -1386,27 +1400,33 @@ tp_tests_legacy_contacts_connection_init (TpTestsLegacyContactsConnection *self)
{
}
+static GPtrArray *
+tp_tests_legacy_contacts_get_interfaces_always_present (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ tp_tests_legacy_contacts_connection_parent_class)->get_interfaces_always_present (base);
+
+ g_ptr_array_remove (interfaces, TP_IFACE_CONNECTION_INTERFACE_CONTACTS);
+ g_ptr_array_remove (interfaces, TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES);
+
+ return interfaces;
+}
+
static void
tp_tests_legacy_contacts_connection_class_init (
TpTestsLegacyContactsConnectionClass *klass)
{
/* Leave Contacts out of the interfaces we say are present, so clients
* won't use it */
- static const gchar *interfaces_always_present[] = {
- TP_IFACE_CONNECTION_INTERFACE_ALIASING,
- TP_IFACE_CONNECTION_INTERFACE_AVATARS,
- TP_IFACE_CONNECTION_INTERFACE_PRESENCE,
- TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE,
- TP_IFACE_CONNECTION_INTERFACE_LOCATION,
- TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
- NULL };
TpBaseConnectionClass *base_class =
(TpBaseConnectionClass *) klass;
GObjectClass *object_class = (GObjectClass *) klass;
object_class->get_property = legacy_contacts_connection_get_property;
- base_class->interfaces_always_present = interfaces_always_present;
+ base_class->get_interfaces_always_present = tp_tests_legacy_contacts_get_interfaces_always_present;
g_object_class_override_property (object_class,
LEGACY_PROP_HAS_IMMORTAL_HANDLES, "has-immortal-handles");
@@ -1422,21 +1442,27 @@ tp_tests_no_requests_connection_init (TpTestsNoRequestsConnection *self)
{
}
+static GPtrArray *
+tp_tests_no_requests_get_interfaces_always_present (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ tp_tests_no_requests_connection_parent_class)->get_interfaces_always_present (base);
+
+ g_ptr_array_remove (interfaces, TP_IFACE_CONNECTION_INTERFACE_REQUESTS);
+ g_ptr_array_remove (interfaces, TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES);
+
+ return interfaces;
+}
+
static void
tp_tests_no_requests_connection_class_init (
TpTestsNoRequestsConnectionClass *klass)
{
- static const gchar *interfaces_always_present[] = {
- TP_IFACE_CONNECTION_INTERFACE_ALIASING,
- TP_IFACE_CONNECTION_INTERFACE_AVATARS,
- TP_IFACE_CONNECTION_INTERFACE_CONTACTS,
- TP_IFACE_CONNECTION_INTERFACE_PRESENCE,
- TP_IFACE_CONNECTION_INTERFACE_SIMPLE_PRESENCE,
- TP_IFACE_CONNECTION_INTERFACE_LOCATION,
- NULL };
TpBaseConnectionClass *base_class =
(TpBaseConnectionClass *) klass;
- base_class->interfaces_always_present = interfaces_always_present;
+ base_class->get_interfaces_always_present = tp_tests_no_requests_get_interfaces_always_present;
base_class->create_channel_managers = NULL;
}
diff --git a/tests/lib/echo-cm.c b/tests/lib/echo-cm.c
index ed18e6b01..300a0adc0 100644
--- a/tests/lib/echo-cm.c
+++ b/tests/lib/echo-cm.c
@@ -85,6 +85,19 @@ new_connection (TpBaseConnectionManager *self,
return (TpBaseConnection *) conn;
}
+static GPtrArray *
+get_interfaces (TpBaseConnectionManager *self)
+{
+ GPtrArray *interfaces;
+
+ interfaces = TP_BASE_CONNECTION_MANAGER_CLASS (
+ tp_tests_echo_connection_manager_parent_class)->get_interfaces (self);
+
+ g_ptr_array_add (interfaces, "im.telepathy.Tests.Example");
+
+ return interfaces;
+}
+
static void
tp_tests_echo_connection_manager_class_init (
TpTestsEchoConnectionManagerClass *klass)
@@ -95,4 +108,5 @@ tp_tests_echo_connection_manager_class_init (
base_class->new_connection = new_connection;
base_class->cm_dbus_name = "example_echo";
base_class->protocol_params = example_protocols;
+ base_class->get_interfaces = get_interfaces;
}
diff --git a/tests/lib/echo-conn.c b/tests/lib/echo-conn.c
index 3c63582e9..2ce06a21e 100644
--- a/tests/lib/echo-conn.c
+++ b/tests/lib/echo-conn.c
@@ -175,12 +175,22 @@ shut_down (TpBaseConnection *conn)
tp_base_connection_finish_shutdown (conn);
}
+static GPtrArray *
+get_interfaces_always_present (TpBaseConnection *base)
+{
+ GPtrArray *interfaces;
+
+ interfaces = TP_BASE_CONNECTION_CLASS (
+ tp_tests_echo_connection_parent_class)->get_interfaces_always_present (base);
+
+ g_ptr_array_add (interfaces, TP_IFACE_CONNECTION_INTERFACE_REQUESTS);
+
+ return interfaces;
+}
+
static void
tp_tests_echo_connection_class_init (TpTestsEchoConnectionClass *klass)
{
- static const gchar *interfaces_always_present[] = {
- TP_IFACE_CONNECTION_INTERFACE_REQUESTS,
- NULL };
TpBaseConnectionClass *base_class =
(TpBaseConnectionClass *) klass;
GObjectClass *object_class = (GObjectClass *) klass;
@@ -196,7 +206,7 @@ tp_tests_echo_connection_class_init (TpTestsEchoConnectionClass *klass)
base_class->create_channel_managers = create_channel_managers;
base_class->start_connecting = start_connecting;
base_class->shut_down = shut_down;
- base_class->interfaces_always_present = interfaces_always_present;
+ 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,
diff --git a/tests/lib/simple-conn.c b/tests/lib/simple-conn.c
index e6ee214ef..b57e607a9 100644
--- a/tests/lib/simple-conn.c
+++ b/tests/lib/simple-conn.c
@@ -284,6 +284,19 @@ 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)
{
@@ -291,8 +304,6 @@ tp_tests_simple_connection_class_init (TpTestsSimpleConnectionClass *klass)
(TpBaseConnectionClass *) klass;
GObjectClass *object_class = (GObjectClass *) klass;
GParamSpec *param_spec;
- static const gchar *interfaces_always_present[] = {
- TP_IFACE_CONNECTION_INTERFACE_REQUESTS, NULL };
object_class->get_property = get_property;
object_class->set_property = set_property;
@@ -306,7 +317,7 @@ tp_tests_simple_connection_class_init (TpTestsSimpleConnectionClass *klass)
base_class->start_connecting = start_connecting;
base_class->shut_down = shut_down;
- base_class->interfaces_always_present = interfaces_always_present;
+ 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,