summaryrefslogtreecommitdiff
path: root/telepathy-glib/base-call-stream.c
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.co.uk>2012-01-16 11:54:49 +0100
committerXavier Claessens <xavier.claessens@collabora.co.uk>2012-01-16 11:54:49 +0100
commit9dc1689db37fd71f5232529172584d87671a7caf (patch)
treecaf0302e68e5adff371daf9ee606fdca344bf181 /telepathy-glib/base-call-stream.c
parentacf6d62027a58460313773da6aa7bf2f8979622a (diff)
downloadtelepathy-glib-9dc1689db37fd71f5232529172584d87671a7caf.tar.gz
TpBaseCallContent/Stream: add get_interfaces virtual method
This is more flexible for subclasses to define the interfaces they implement. Especially in the case of sub-subclasse.
Diffstat (limited to 'telepathy-glib/base-call-stream.c')
-rw-r--r--telepathy-glib/base-call-stream.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/telepathy-glib/base-call-stream.c b/telepathy-glib/base-call-stream.c
index e26225397..6c170d845 100644
--- a/telepathy-glib/base-call-stream.c
+++ b/telepathy-glib/base-call-stream.c
@@ -29,7 +29,7 @@
* This base class makes it easier to write #TpSvcCallStream
* implementations by implementing its properties, and some of its methods.
*
- * Subclasses should fill in #TpBaseCallStreamClass.extra_interfaces,
+ * Subclasses should fill in #TpBaseCallStreamClass.get_interfaces,
* #TpBaseCallStreamClass.request_receiving and
* #TpBaseCallStreamClass.set_sending virtual function.
*
@@ -46,8 +46,9 @@
/**
* TpBaseCallStreamClass:
- * @extra_interfaces: extra interfaces provided by this stream (this SHOULD NOT
- * include %TP_IFACE_CALL_STREAM itself)
+ * @get_interfaces: extra interfaces provided by this stream (this SHOULD NOT
+ * include %TP_IFACE_CALL_STREAM itself). Implementation must first chainup on
+ * parent class implementation then add extra interfaces into the #GPtrArray.
* @request_receiving: optional (see #TpBaseCallStream:can-request-receiving);
* virtual method called when user requested receiving from the given remote
* contact.
@@ -60,6 +61,16 @@
*/
/**
+ * TpBaseCallStreamGetInterfacesFunc:
+ * @self: a #TpBaseCallStream
+ *
+ * Signature of an implementation of #TpBaseCallStreamClass.get_interfaces.
+ *
+ * Returns: a #GPtrArray containing static strings.
+ * Since: 0.UNRELEASED
+ */
+
+/**
* TpBaseCallStreamSetSendingFunc:
* @self: a #TpBaseCallStream
* @sending: whether or not user would like to be sending
@@ -161,6 +172,12 @@ tp_base_call_stream_constructed (GObject *obj)
tp_dbus_daemon_register_object (bus, self->priv->object_path, obj);
}
+static GPtrArray *
+tp_base_call_stream_get_interfaces (TpBaseCallStream *self)
+{
+ return g_ptr_array_new ();
+}
+
static void
tp_base_call_stream_dispose (GObject *object)
{
@@ -197,6 +214,7 @@ tp_base_call_stream_get_property (
GParamSpec *pspec)
{
TpBaseCallStream *self = TP_BASE_CALL_STREAM (object);
+ TpBaseCallStreamClass *klass = TP_BASE_CALL_STREAM_GET_CLASS (self);
switch (property_id)
{
@@ -225,27 +243,16 @@ tp_base_call_stream_get_property (
break;
case PROP_CAN_REQUEST_RECEIVING:
{
- TpBaseCallStreamClass *klass =
- TP_BASE_CALL_STREAM_GET_CLASS (self);
-
g_value_set_boolean (value, klass->request_receiving != NULL);
break;
}
case PROP_INTERFACES:
{
- TpBaseCallStreamClass *klass =
- TP_BASE_CALL_STREAM_GET_CLASS (self);
-
- if (klass->extra_interfaces != NULL)
- {
- g_value_set_boxed (value, klass->extra_interfaces);
- }
- else
- {
- gchar *empty[] = { NULL };
-
- g_value_set_boxed (value, empty);
- }
+ GPtrArray *interfaces = klass->get_interfaces (self);
+
+ g_ptr_array_add (interfaces, NULL);
+ g_value_set_boxed (value, interfaces->pdata);
+ g_ptr_array_unref (interfaces);
break;
}
default:
@@ -283,9 +290,9 @@ tp_base_call_stream_set_property (
}
static void
-tp_base_call_stream_class_init (TpBaseCallStreamClass *bsc_class)
+tp_base_call_stream_class_init (TpBaseCallStreamClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (bsc_class);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GParamSpec *param_spec;
static TpDBusPropertiesMixinPropImpl stream_props[] = {
{ "Interfaces", "interfaces", NULL },
@@ -304,7 +311,7 @@ tp_base_call_stream_class_init (TpBaseCallStreamClass *bsc_class)
{ NULL }
};
- g_type_class_add_private (bsc_class, sizeof (TpBaseCallStreamPrivate));
+ g_type_class_add_private (klass, sizeof (TpBaseCallStreamPrivate));
object_class->constructed = tp_base_call_stream_constructed;
object_class->dispose = tp_base_call_stream_dispose;
@@ -312,6 +319,8 @@ tp_base_call_stream_class_init (TpBaseCallStreamClass *bsc_class)
object_class->set_property = tp_base_call_stream_set_property;
object_class->get_property = tp_base_call_stream_get_property;
+ klass->get_interfaces = tp_base_call_stream_get_interfaces;
+
/**
* TpBaseCallStream:connection:
*
@@ -412,7 +421,7 @@ tp_base_call_stream_class_init (TpBaseCallStreamClass *bsc_class)
g_object_class_install_property (object_class, PROP_CAN_REQUEST_RECEIVING,
param_spec);
- bsc_class->dbus_props_class.interfaces = prop_interfaces;
+ klass->dbus_props_class.interfaces = prop_interfaces;
tp_dbus_properties_mixin_class_init (object_class,
G_STRUCT_OFFSET (TpBaseCallStreamClass, dbus_props_class));
}