summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-11 14:47:29 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-04-11 14:47:29 +0100
commit3c8b6fa413df0fb46a678397df63fb4135eb0e8a (patch)
treea464c88ff28492a5816b41db9f16a663a6818376
parent35222424e0af3f3c98b29402c03399e1d7029447 (diff)
TpBaseConnection: be a GDBusObjectSkeleton
-rw-r--r--docs/reference/telepathy-glib/telepathy-glib-sections.txt2
-rw-r--r--examples/cm/call/conn.c23
-rw-r--r--examples/cm/channelspecific/conn.c16
-rw-r--r--examples/cm/contactlist/conn.c44
-rw-r--r--examples/cm/echo-message-parts/conn.c16
-rw-r--r--examples/cm/extended/conn.c29
-rw-r--r--telepathy-glib/base-connection.c200
-rw-r--r--telepathy-glib/base-connection.h15
-rw-r--r--telepathy-glib/versions/main-1.0.abi1
-rw-r--r--tests/dbus/connection-balance.c29
-rw-r--r--tests/dbus/proxy-preparation.c9
-rw-r--r--tests/lib/contacts-conn.c81
-rw-r--r--tests/lib/my-conn-proxy.c1
-rw-r--r--tests/lib/my-conn-proxy.h6
14 files changed, 205 insertions, 267 deletions
diff --git a/docs/reference/telepathy-glib/telepathy-glib-sections.txt b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
index f07d33db8..4a43f601b 100644
--- a/docs/reference/telepathy-glib/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib/telepathy-glib-sections.txt
@@ -42,7 +42,6 @@ TpBaseConnectionClass
TpBaseConnectionCreateChannelManagersImpl
TpBaseConnectionCreateHandleReposImpl
TpBaseConnectionGetUniqueConnectionNameImpl
-TpBaseConnectionGetInterfacesImpl
TpBaseConnectionProc
TpBaseConnectionStartConnectingImpl
tp_base_connection_get_bus_name
@@ -58,7 +57,6 @@ tp_base_connection_check_connected
tp_base_connection_change_status
tp_base_connection_disconnect_with_dbus_error
tp_base_connection_finish_shutdown
-tp_base_connection_add_interfaces
TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED
tp_base_connection_add_possible_client_interest
tp_base_connection_add_client_interest
diff --git a/examples/cm/call/conn.c b/examples/cm/call/conn.c
index d64dcacfd..e1d74de35 100644
--- a/examples/cm/call/conn.c
+++ b/examples/cm/call/conn.c
@@ -214,10 +214,17 @@ constructed (GObject *object)
{
void (*chain_up) (GObject *) =
G_OBJECT_CLASS (example_call_connection_parent_class)->constructed;
+ GDBusObjectSkeleton *skel = G_DBUS_OBJECT_SKELETON (object);
+ GDBusInterfaceSkeleton *iface;
if (chain_up != NULL)
chain_up (object);
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_PRESENCE1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
tp_presence_mixin_init (object,
G_STRUCT_OFFSET (ExampleCallConnection, presence_mixin));
}
@@ -326,21 +333,6 @@ 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_fill_contact_attributes (TpBaseConnection *conn,
const gchar *dbus_interface,
@@ -375,7 +367,6 @@ 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->get_interfaces_always_present = get_interfaces_always_present;
base_class->fill_contact_attributes =
example_call_connection_fill_contact_attributes;
diff --git a/examples/cm/channelspecific/conn.c b/examples/cm/channelspecific/conn.c
index c3da5ecdc..4cb7a5958 100644
--- a/examples/cm/channelspecific/conn.c
+++ b/examples/cm/channelspecific/conn.c
@@ -227,21 +227,6 @@ 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)
{
@@ -260,7 +245,6 @@ 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->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/conn.c b/examples/cm/contactlist/conn.c
index 4b1a9f301..266a0b2fc 100644
--- a/examples/cm/contactlist/conn.c
+++ b/examples/cm/contactlist/conn.c
@@ -265,6 +265,8 @@ static void
constructed (GObject *object)
{
ExampleContactListConnection *self = EXAMPLE_CONTACT_LIST_CONNECTION (object);
+ GDBusObjectSkeleton *skel = G_DBUS_OBJECT_SKELETON (object);
+ GDBusInterfaceSkeleton *iface;
void (*chain_up) (GObject *) =
G_OBJECT_CLASS (example_contact_list_connection_parent_class)->constructed;
@@ -284,6 +286,31 @@ constructed (GObject *object)
tp_presence_mixin_init (object,
G_STRUCT_OFFSET (ExampleContactListConnection, presence_mixin));
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_ALIASING1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_BLOCKING1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_GROUPS1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_LIST1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_PRESENCE1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
}
static gboolean
@@ -371,22 +398,6 @@ 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;
-}
-
enum
{
ALIASING_DP_ALIAS_FLAGS,
@@ -442,7 +453,6 @@ 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->get_interfaces_always_present = get_interfaces_always_present;
base_class->fill_contact_attributes =
example_contact_list_connection_fill_contact_attributes;
diff --git a/examples/cm/echo-message-parts/conn.c b/examples/cm/echo-message-parts/conn.c
index f8bb68986..b0aaa4271 100644
--- a/examples/cm/echo-message-parts/conn.c
+++ b/examples/cm/echo-message-parts/conn.c
@@ -168,21 +168,6 @@ 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
example_echo_2_connection_class_init (ExampleEcho2ConnectionClass *klass)
{
@@ -201,7 +186,6 @@ 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->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/conn.c b/examples/cm/extended/conn.c
index cb7846fd7..792952dcb 100644
--- a/examples/cm/extended/conn.c
+++ b/examples/cm/extended/conn.c
@@ -184,19 +184,21 @@ example_extended_connection_get_possible_interfaces (void)
return interfaces_always_present;
}
-static GPtrArray *
-get_interfaces_always_present (TpBaseConnection *base)
+static void
+constructed (GObject *object)
{
- 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;
+ void (*chain_up) (GObject *) =
+ G_OBJECT_CLASS (example_extended_connection_parent_class)->constructed;
+ GDBusObjectSkeleton *skel = G_DBUS_OBJECT_SKELETON (object);
+ GDBusInterfaceSkeleton *iface;
+
+ if (chain_up != NULL)
+ chain_up (object);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ EXAMPLE_TYPE_SVC_CONNECTION_INTERFACE_HATS);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
}
static void
@@ -209,6 +211,7 @@ example_extended_connection_class_init (ExampleExtendedConnectionClass *klass)
object_class->get_property = get_property;
object_class->set_property = set_property;
+ object_class->constructed = constructed;
object_class->finalize = finalize;
g_type_class_add_private (klass, sizeof (ExampleExtendedConnectionPrivate));
@@ -218,8 +221,6 @@ example_extended_connection_class_init (ExampleExtendedConnectionClass *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);
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c
index ce8480813..c9521fcf6 100644
--- a/telepathy-glib/base-connection.c
+++ b/telepathy-glib/base-connection.c
@@ -72,6 +72,10 @@
* asynchronously, returning %TRUE in most cases and changing the status
* to CONNECTED or DISCONNECTED later.
*
+ * Subclasses may call g_dbus_object_skeleton_add_interface()
+ * at any time before the status reaches CONNECTED. It is considered
+ * to be an error to do so after CONNECTED status has been reached.
+ *
* Returns: %FALSE if failure has already occurred, else %TRUE.
*/
@@ -110,38 +114,6 @@
*/
/**
- * TpBaseConnectionGetInterfacesImpl:
- * @self: a #TpBaseConnection
- *
- * 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_connection_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.19.4
- */
-
-/**
* TpBaseConnectionClass:
* @parent_class: The superclass' structure
* @create_handle_repos: Fill in suitable handle repositories in the
@@ -167,12 +139,6 @@
* @start_connecting: Asynchronously start connecting - called to implement
* the Connect D-Bus method. See #TpBaseConnectionStartConnectingImpl for
* details. May not be left as %NULL.
- * @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. This must be set by subclasses to a non-%NULL
* value. Since: 0.7.15
@@ -264,7 +230,7 @@ static void requests_iface_init (gpointer, gpointer);
G_DEFINE_ABSTRACT_TYPE_WITH_CODE(TpBaseConnection,
tp_base_connection,
- G_TYPE_OBJECT,
+ G_TYPE_DBUS_OBJECT_SKELETON,
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION,
conn_iface_init);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_REQUESTS,
@@ -324,13 +290,6 @@ struct _TpBaseConnectionPrivate
TpHandleRepoIface *handles[TP_NUM_ENTITY_TYPES];
- /* 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. */
- GArray *interfaces;
-
/* Array of GDBusMethodInvocation * representing Disconnect calls.
* If NULL and we are in a state != DISCONNECTED, then we have not started
* shutting down yet.
@@ -362,8 +321,6 @@ typedef struct
} ClientData;
static void client_data_free (ClientData *client);
-static const gchar * const *tp_base_connection_get_interfaces (
- TpBaseConnection *self);
static gboolean
tp_base_connection_ensure_dbus (TpBaseConnection *self,
@@ -407,7 +364,9 @@ tp_base_connection_get_property (GObject *object,
break;
case PROP_INTERFACES:
- g_value_set_boxed (value, tp_base_connection_get_interfaces (self));
+ g_value_take_boxed (value,
+ _tp_g_dbus_object_dup_interface_names (G_DBUS_OBJECT (self),
+ TP_IFACE_CONNECTION, TP_IFACE_CONNECTION_INTERFACE_REQUESTS));
break;
case PROP_DBUS_CONNECTION:
@@ -523,11 +482,6 @@ tp_base_connection_dispose (GObject *object)
for (i = 0; i < TP_NUM_ENTITY_TYPES; i++)
tp_clear_object (priv->handles + i);
- if (priv->interfaces)
- {
- g_array_unref (priv->interfaces);
- }
-
if (G_OBJECT_CLASS (tp_base_connection_parent_class)->dispose)
G_OBJECT_CLASS (tp_base_connection_parent_class)->dispose (object);
}
@@ -769,24 +723,47 @@ _tp_base_connection_set_handle_repo (TpBaseConnection *self,
}
static void
-tp_base_connection_create_interfaces_array (TpBaseConnection *self)
+tp_base_connection_interface_changed_cb (TpBaseConnection *self,
+ GDBusInterface *interface,
+ gpointer user_data)
{
- TpBaseConnectionPrivate *priv = self->priv;
- TpBaseConnectionClass *klass = TP_BASE_CONNECTION_GET_CLASS (self);
- GPtrArray *always;
- guint i;
-
- g_assert (priv->interfaces == NULL);
+ GDBusInterfaceInfo *info = g_dbus_interface_get_info (interface);
+ gint what_happened = GPOINTER_TO_INT (user_data);
+ const gchar *verb = (what_happened == 1 ? "add" : "remove");
- always = klass->get_interfaces_always_present (self);
+ g_assert (what_happened == 1 || what_happened == -1);
- priv->interfaces = g_array_sized_new (TRUE, FALSE, sizeof (gchar *),
- always->len);
+ if (self->priv->status == TP_CONNECTION_STATUS_CONNECTED)
+ {
+ WARNING ("Adding or removing Connection interfaces after CONNECTED "
+ "status has been reached is not supported. "
+ "(Tried to %s %s %p, \"%s\")",
+ verb, G_OBJECT_TYPE_NAME (interface), interface, info->name);
+ }
+ else
+ {
+ /* We'd ideally like to detect attempts to remove interfaces
+ * and diagnose those as invalid, too, but we can't do that because
+ * replacement by a subclass is represented as remove + add. */
+ DEBUG ("%s %s %p \"%s\"",
+ verb, G_OBJECT_TYPE_NAME (interface), interface, info->name);
+ }
+}
- for (i = 0; i < always->len; i++)
- g_array_append_val (priv->interfaces, g_ptr_array_index (always, i));
+static void
+object_skeleton_take_interface (GDBusObjectSkeleton *skel,
+ GDBusInterfaceSkeleton *iface)
+{
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+}
- g_ptr_array_unref (always);
+static void
+object_skeleton_take_svc_interface (GDBusObjectSkeleton *skel,
+ GType type)
+{
+ object_skeleton_take_interface (skel,
+ tp_svc_interface_skeleton_new (skel, type));
}
static GObject *
@@ -834,13 +811,34 @@ 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;
}
+static void
+tp_base_connection_constructed (GObject *object)
+{
+ TpBaseConnection *self = TP_BASE_CONNECTION (object);
+ GDBusObjectSkeleton *skel = G_DBUS_OBJECT_SKELETON (self);
+ void (*chain_up) (GObject *) =
+ ((GObjectClass *) tp_base_connection_parent_class)->constructed;
+
+ if (chain_up != NULL)
+ chain_up (object);
+
+ object_skeleton_take_svc_interface (skel, TP_TYPE_SVC_CONNECTION);
+ object_skeleton_take_svc_interface (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_REQUESTS);
+
+ g_signal_connect (self, "interface-added",
+ G_CALLBACK (tp_base_connection_interface_changed_cb),
+ GINT_TO_POINTER (+1));
+ g_signal_connect (self, "interface-removed",
+ G_CALLBACK (tp_base_connection_interface_changed_cb),
+ GINT_TO_POINTER (-1));
+}
+
/**
* tp_base_connection_add_possible_client_interest:
* @self: a connection
@@ -959,24 +957,6 @@ 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;
-}
-
/* this is not really gtk-doc - it's for gobject-introspection */
/**
* TpBaseConnectionClass::fill_contact_attributes:
@@ -1052,7 +1032,9 @@ tp_base_connection_get_connection_property (GObject *object,
break;
case DBUSPROP_INTERFACES:
- g_value_set_boxed (value, tp_base_connection_get_interfaces (self));
+ g_value_take_boxed (value,
+ _tp_g_dbus_object_dup_interface_names (G_DBUS_OBJECT (self),
+ TP_IFACE_CONNECTION, TP_IFACE_CONNECTION_INTERFACE_REQUESTS));
break;
case DBUSPROP_RCCS:
@@ -1083,14 +1065,13 @@ tp_base_connection_class_init (TpBaseConnectionClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (TpBaseConnectionPrivate));
+ object_class->constructed = tp_base_connection_constructed;
object_class->dispose = tp_base_connection_dispose;
object_class->finalize = tp_base_connection_finalize;
object_class->constructor = tp_base_connection_constructor;
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;
klass->fill_contact_attributes = _tp_base_connection_fill_contact_attributes;
/**
@@ -1552,14 +1533,6 @@ tp_base_connection_disconnect (TpSvcConnection *iface,
TP_CONNECTION_STATUS_REASON_REQUESTED);
}
-static const gchar * const *
-tp_base_connection_get_interfaces (TpBaseConnection *self)
-{
- g_return_val_if_fail (TP_IS_BASE_CONNECTION (self), NULL);
-
- return (const gchar * const *)(self->priv->interfaces->data);
-}
-
/**
* tp_base_connection_get_status:
* @self: the connection
@@ -1997,37 +1970,6 @@ tp_base_connection_change_status (TpBaseConnection *self,
g_object_unref (self);
}
-
-/**
- * tp_base_connection_add_interfaces: (skip)
- * @self: A TpBaseConnection in state #TP_INTERNAL_CONNECTION_STATUS_NEW
- * or #TP_CONNECTION_STATUS_CONNECTING
- * @interfaces: A %NULL-terminated array of D-Bus interface names, which
- * must remain valid at least until the connection enters state
- * #TP_CONNECTION_STATUS_DISCONNECTED (in practice, you should either
- * use static strings, or use strdup'd strings and free them in the dispose
- * callback).
- *
- * 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 (@get_interfaces_always_present in
- * #TpBaseConnectionClass) will be supported.
- */
-void
-tp_base_connection_add_interfaces (TpBaseConnection *self,
- const gchar **interfaces)
-{
- TpBaseConnectionPrivate *priv = self->priv;
-
- g_return_if_fail (TP_IS_BASE_CONNECTION (self));
- g_return_if_fail (priv->status != TP_CONNECTION_STATUS_CONNECTED);
- g_return_if_fail (priv->status != TP_CONNECTION_STATUS_DISCONNECTED);
-
- for (; interfaces != NULL && *interfaces != NULL; interfaces++)
- g_array_append_val (priv->interfaces, *interfaces);
-}
-
static guint
get_interest_count (GHashTable *table,
GQuark q)
diff --git a/telepathy-glib/base-connection.h b/telepathy-glib/base-connection.h
index d97203250..b3a8b9481 100644
--- a/telepathy-glib/base-connection.h
+++ b/telepathy-glib/base-connection.h
@@ -56,18 +56,15 @@ typedef GPtrArray *(*TpBaseConnectionCreateChannelManagersImpl) (
typedef gchar *(*TpBaseConnectionGetUniqueConnectionNameImpl) (
TpBaseConnection *self);
-typedef GPtrArray *(*TpBaseConnectionGetInterfacesImpl) (
- TpBaseConnection *self);
-
struct _TpBaseConnection {
/*<private>*/
- GObject parent;
+ GDBusObjectSkeleton parent;
TpBaseConnectionPrivate *priv;
};
struct _TpBaseConnectionClass {
- GObjectClass parent_class;
+ GDBusObjectSkeletonClass parent_class;
#ifdef __GI_SCANNER__
/*<private>*/
@@ -87,13 +84,8 @@ struct _TpBaseConnectionClass {
TpBaseConnectionStartConnectingImpl start_connecting;
- /*<private>*/
- const gchar **_TP_SEAL (interfaces_always_present);
- /*<public>*/
TpBaseConnectionCreateChannelManagersImpl create_channel_managers;
- TpBaseConnectionGetInterfacesImpl get_interfaces_always_present;
-
void (*fill_contact_attributes) (TpBaseConnection *self,
const gchar *dbus_interface,
TpHandle contact,
@@ -154,9 +146,6 @@ void tp_base_connection_set_self_handle (TpBaseConnection *self,
void tp_base_connection_finish_shutdown (TpBaseConnection *self);
-void tp_base_connection_add_interfaces (TpBaseConnection *self,
- const gchar **interfaces);
-
typedef struct _TpChannelManagerIter TpChannelManagerIter;
struct _TpChannelManagerIter {
diff --git a/telepathy-glib/versions/main-1.0.abi b/telepathy-glib/versions/main-1.0.abi
index f404e2d71..a5f714758 100644
--- a/telepathy-glib/versions/main-1.0.abi
+++ b/telepathy-glib/versions/main-1.0.abi
@@ -218,7 +218,6 @@ tp_base_client_take_handler_filter
tp_base_client_take_observer_filter
tp_base_client_unregister
tp_base_connection_add_client_interest
-tp_base_connection_add_interfaces
tp_base_connection_add_possible_client_interest
tp_base_connection_change_status
tp_base_connection_channel_manager_iter_init
diff --git a/tests/dbus/connection-balance.c b/tests/dbus/connection-balance.c
index d5502b211..da274fa8c 100644
--- a/tests/dbus/connection-balance.c
+++ b/tests/dbus/connection-balance.c
@@ -18,6 +18,7 @@
#include <telepathy-glib/interfaces.h>
#include <telepathy-glib/proxy-subclass.h>
#include <telepathy-glib/svc-connection.h>
+#include <telepathy-glib/svc-interface.h>
#include <telepathy-glib/value-array.h>
#include <dbus/dbus-glib.h>
@@ -83,24 +84,27 @@ balanced_connection_init (BalancedConnection *self)
{
}
-static GPtrArray *
-get_interfaces (TpBaseConnection *base)
+static void
+balanced_connection_constructed (GObject *object)
{
- 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_BALANCE1);
-
- return interfaces;
+ GDBusObjectSkeleton *skel = G_DBUS_OBJECT_SKELETON (object);
+ GDBusInterfaceSkeleton *iface;
+ void (*parent_impl) (GObject *) =
+ G_OBJECT_CLASS (balanced_connection_parent_class)->constructed;
+
+ if (parent_impl != NULL)
+ parent_impl (object);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_BALANCE1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
}
static void
balanced_connection_class_init (BalancedConnectionClass *cls)
{
GObjectClass *object_class = (GObjectClass *) cls;
- TpBaseConnectionClass *base_class = TP_BASE_CONNECTION_CLASS (cls);
static TpDBusPropertiesMixinPropImpl balance_props[] = {
{ "AccountBalance", "account-balance", NULL },
@@ -108,10 +112,9 @@ balanced_connection_class_init (BalancedConnectionClass *cls)
{ NULL }
};
+ object_class->constructed = balanced_connection_constructed;
object_class->get_property = balanced_connection_get_property;
- base_class->get_interfaces_always_present = get_interfaces;
-
g_object_class_install_property (object_class, PROP_ACCOUNT_BALANCE,
g_param_spec_boxed ("account-balance", "", "",
TP_STRUCT_TYPE_CURRENCY_AMOUNT,
diff --git a/tests/dbus/proxy-preparation.c b/tests/dbus/proxy-preparation.c
index db969ba4f..6fccfbb43 100644
--- a/tests/dbus/proxy-preparation.c
+++ b/tests/dbus/proxy-preparation.c
@@ -11,6 +11,7 @@
#include <telepathy-glib/cli-connection.h>
#include <telepathy-glib/telepathy-glib.h>
+#include <telepathy-glib/telepathy-glib-dbus.h>
#include "tests/lib/util.h"
#include "tests/lib/simple-account.h"
@@ -386,7 +387,7 @@ test_interface_later (Test *test,
{
GQuark features[] = { TP_TESTS_MY_CONN_PROXY_FEATURE_INTERFACE_LATER, 0 };
GQuark connected[] = { TP_CONNECTION_FEATURE_CONNECTED, 0 };
- const gchar *interfaces[] = { TP_TESTS_MY_CONN_PROXY_IFACE_LATER, NULL };
+ GDBusInterfaceSkeleton *iface;
/* We need a not yet connected connection */
recreate_connection (test);
@@ -404,7 +405,11 @@ test_interface_later (Test *test,
tp_cli_connection_call_connect (test->connection, -1, NULL, NULL, NULL, NULL);
/* While connecting the interface is added */
- tp_base_connection_add_interfaces (test->base_connection, interfaces);
+ iface = tp_svc_interface_skeleton_new (test->base_connection,
+ TP_TESTS_TYPE_SVC_CONNECTION_INTERFACE_LATER);
+ g_dbus_object_skeleton_add_interface (
+ G_DBUS_OBJECT_SKELETON (test->base_connection), iface);
+ g_object_unref (iface);
/* Wait that CONNECTED is announced */
tp_proxy_prepare_async (test->my_conn, connected, prepare_cb, test);
diff --git a/tests/lib/contacts-conn.c b/tests/lib/contacts-conn.c
index 79a5c4b82..092ae975d 100644
--- a/tests/lib/contacts-conn.c
+++ b/tests/lib/contacts-conn.c
@@ -19,6 +19,7 @@
#include <telepathy-glib/telepathy-glib-dbus.h>
#include "debug.h"
+#include "my-conn-proxy.h"
static void init_aliasing (gpointer, gpointer);
static void init_avatars (gpointer, gpointer);
@@ -46,6 +47,12 @@ G_DEFINE_TYPE_WITH_CODE (TpTestsContactsConnection,
tp_base_contact_list_mixin_groups_iface_init);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CONNECTION_INTERFACE_CLIENT_TYPES1,
NULL);
+ /* We don't really implement this one, but the proxy-preparation test
+ * wants to be able to add interfaces at runtime like Gabble does.
+ * It can be any interface we don't really need (implementation detail:
+ * it's PowerSaving1). */
+ G_IMPLEMENT_INTERFACE (TP_TESTS_TYPE_SVC_CONNECTION_INTERFACE_LATER,
+ NULL);
);
/* type definition stuff */
@@ -360,12 +367,59 @@ static void
constructed (GObject *object)
{
TpTestsContactsConnection *self = TP_TESTS_CONTACTS_CONNECTION (object);
+ GDBusObjectSkeleton *skel = G_DBUS_OBJECT_SKELETON (object);
+ GDBusInterfaceSkeleton *iface;
void (*parent_impl) (GObject *) =
G_OBJECT_CLASS (tp_tests_contacts_connection_parent_class)->constructed;
if (parent_impl != NULL)
parent_impl (object);
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_ALIASING1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_AVATARS1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_CLIENT_TYPES1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_GROUPS1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_LIST1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_CONTACT_INFO1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_LOCATION1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
+ iface = tp_svc_interface_skeleton_new (skel,
+ TP_TYPE_SVC_CONNECTION_INTERFACE_PRESENCE1);
+ g_dbus_object_skeleton_add_interface (skel, iface);
+ g_object_unref (iface);
+
self->priv->list_manager = g_object_new (TP_TESTS_TYPE_CONTACT_LIST_MANAGER,
"connection", self, NULL);
@@ -439,32 +493,6 @@ create_channel_managers (TpBaseConnection *conn)
return g_ptr_array_new ();
}
-static GPtrArray *
-tp_tests_contacts_get_interfaces_always_present (TpBaseConnection *base)
-{
- GPtrArray *interfaces;
- static const gchar *interfaces_always_present[] = {
- TP_IFACE_CONNECTION_INTERFACE_ALIASING1,
- TP_IFACE_CONNECTION_INTERFACE_AVATARS1,
- TP_IFACE_CONNECTION_INTERFACE_CONTACT_LIST1,
- TP_IFACE_CONNECTION_INTERFACE_CONTACT_GROUPS1,
- TP_IFACE_CONNECTION_INTERFACE_PRESENCE1,
- TP_IFACE_CONNECTION_INTERFACE_LOCATION1,
- TP_IFACE_CONNECTION_INTERFACE_CLIENT_TYPES1,
- TP_IFACE_CONNECTION_INTERFACE_CONTACT_CAPABILITIES1,
- TP_IFACE_CONNECTION_INTERFACE_CONTACT_INFO1,
- 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;
-}
-
enum
{
ALIASING_DP_ALIAS_FLAGS,
@@ -523,7 +551,6 @@ tp_tests_contacts_connection_class_init (TpTestsContactsConnectionClass *klass)
object_class->finalize = finalize;
g_type_class_add_private (klass, sizeof (TpTestsContactsConnectionPrivate));
- base_class->get_interfaces_always_present = tp_tests_contacts_get_interfaces_always_present;
base_class->create_channel_managers = create_channel_managers;
base_class->fill_contact_attributes =
tp_tests_contacts_connection_fill_contact_attributes;
diff --git a/tests/lib/my-conn-proxy.c b/tests/lib/my-conn-proxy.c
index 0d7723c43..4df30a1e1 100644
--- a/tests/lib/my-conn-proxy.c
+++ b/tests/lib/my-conn-proxy.c
@@ -13,6 +13,7 @@
#include "my-conn-proxy.h"
#include <telepathy-glib/telepathy-glib.h>
+#include <telepathy-glib/telepathy-glib-dbus.h>
G_DEFINE_TYPE (TpTestsMyConnProxy, tp_tests_my_conn_proxy,
TP_TYPE_CONNECTION)
diff --git a/tests/lib/my-conn-proxy.h b/tests/lib/my-conn-proxy.h
index 64a6ebe09..e667c72de 100644
--- a/tests/lib/my-conn-proxy.h
+++ b/tests/lib/my-conn-proxy.h
@@ -110,7 +110,11 @@ GQuark tp_tests_my_conn_proxy_get_feature_quark_retry_dep (void) G_GNUC_CONST;
(tp_tests_my_conn_proxy_get_feature_quark_before_connected ())
GQuark tp_tests_my_conn_proxy_get_feature_quark_before_connected (void) G_GNUC_CONST;
-#define TP_TESTS_MY_CONN_PROXY_IFACE_LATER "im.telepathy.v1.Tests.Connection.Interface.Later"
+#define TP_TESTS_MY_CONN_PROXY_IFACE_LATER \
+ TP_IFACE_CONNECTION_INTERFACE_POWER_SAVING1
+
+#define TP_TESTS_TYPE_SVC_CONNECTION_INTERFACE_LATER \
+ TP_TYPE_SVC_CONNECTION_INTERFACE_POWER_SAVING1
/* Need the interface TP_TESTS_MY_CONN_PROXY_IFACE_LATER to be prepared but
* this interface is not in the initial set of interfaces of the connection.