summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2012-05-25 11:17:09 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2012-05-31 13:39:16 +0100
commita64e1ec6fac7b9c01f9578ddbda49222b53d1784 (patch)
tree273134e3463061822550f4ded8ee95b4dde1a19d
parent3360f5abbe98c28e6a2e6dfd5fe9553c80993e12 (diff)
tube-dbus: subclass TpBaseChannel instead
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--src/Makefile.am2
-rw-r--r--src/muc-tube-dbus.c47
-rw-r--r--src/muc-tube-dbus.h60
-rw-r--r--src/tube-dbus.c432
-rw-r--r--src/tube-dbus.h5
-rw-r--r--src/tube-iface.c2
-rw-r--r--src/tubes-channel.c2
7 files changed, 223 insertions, 327 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8a985abd..8be8d011 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,6 +45,8 @@ CORE_SOURCES = \
file-transfer-channel.c \
file-transfer-channel.h \
muc-channel.h \
+ muc-tube-dbus.c \
+ muc-tube-dbus.h \
presence-cache.c \
presence-cache.h \
tubes-manager.c \
diff --git a/src/muc-tube-dbus.c b/src/muc-tube-dbus.c
new file mode 100644
index 00000000..0fedeaf4
--- /dev/null
+++ b/src/muc-tube-dbus.c
@@ -0,0 +1,47 @@
+/*
+ * muc-tube-dbus.c - Source for SalutMucTubeDBus
+ * Copyright (C) 2012 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include "muc-tube-dbus.h"
+
+G_DEFINE_TYPE (SalutMucTubeDBus, salut_muc_tube_dbus,
+ SALUT_TYPE_TUBE_DBUS)
+
+static const gchar *salut_muc_tube_dbus_interfaces[] = {
+ TP_IFACE_CHANNEL_INTERFACE_GROUP,
+ TP_IFACE_CHANNEL_INTERFACE_TUBE,
+ NULL
+};
+
+static void
+salut_muc_tube_dbus_init (SalutMucTubeDBus *self)
+{
+}
+
+static void
+salut_muc_tube_dbus_class_init (
+ SalutMucTubeDBusClass *salut_muc_tube_dbus_class)
+{
+ TpBaseChannelClass *base_class = TP_BASE_CHANNEL_CLASS (
+ salut_muc_tube_dbus_class);
+
+ base_class->interfaces = salut_muc_tube_dbus_interfaces;
+ base_class->target_handle_type = TP_HANDLE_TYPE_ROOM;
+}
diff --git a/src/muc-tube-dbus.h b/src/muc-tube-dbus.h
new file mode 100644
index 00000000..cdaafab1
--- /dev/null
+++ b/src/muc-tube-dbus.h
@@ -0,0 +1,60 @@
+/*
+ * muc-tube-dbus.h - Header for SalutMucTubeDBus
+ * Copyright (C) 2012 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef __SALUT_MUC_TUBE_DBUS_H__
+#define __SALUT_MUC_TUBE_DBUS_H__
+
+#include <glib-object.h>
+
+#include "tube-dbus.h"
+
+G_BEGIN_DECLS
+
+typedef struct _SalutMucTubeDBus SalutMucTubeDBus;
+typedef struct _SalutMucTubeDBusClass SalutMucTubeDBusClass;
+
+struct _SalutMucTubeDBusClass {
+ SalutTubeDBusClass parent_class;
+};
+
+struct _SalutMucTubeDBus {
+ SalutTubeDBus parent;
+};
+
+GType salut_muc_tube_dbus_get_type (void);
+
+/* TYPE MACROS */
+#define SALUT_TYPE_MUC_TUBE_DBUS \
+ (salut_muc_tube_dbus_get_type ())
+#define SALUT_MUC_TUBE_DBUS(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj), SALUT_TYPE_MUC_TUBE_DBUS, SalutMucTubeDBus))
+#define SALUT_MUC_TUBE_DBUS_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass), SALUT_TYPE_MUC_TUBE_DBUS,\
+ SalutMucTubeDBusClass))
+#define SALUT_IS_MUC_TUBE_DBUS(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj), SALUT_TYPE_MUC_TUBE_DBUS))
+#define SALUT_IS_MUC_TUBE_DBUS_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass), SALUT_TYPE_MUC_TUBE_DBUS))
+#define SALUT_MUC_TUBE_DBUS_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), SALUT_TYPE_MUC_TUBE_DBUS,\
+ SalutMucTubeDBusClass))
+
+G_END_DECLS
+
+#endif /* #ifndef __SALUT_MUC_TUBE_DBUS_H__ */
diff --git a/src/tube-dbus.c b/src/tube-dbus.c
index e92dde9b..aed98c33 100644
--- a/src/tube-dbus.c
+++ b/src/tube-dbus.c
@@ -44,6 +44,7 @@
#define DEBUG_FLAG DEBUG_TUBES
#include "debug.h"
#include "connection.h"
+#include "muc-tube-dbus.h"
#include "tube-iface.h"
#include "sha1/sha1-util.h"
@@ -56,27 +57,17 @@
* arbitrary limit on the queue size set to 4MB. */
#define MAX_QUEUE_SIZE (4096*1024)
-static void channel_iface_init (gpointer, gpointer);
static void tube_iface_init (gpointer g_iface, gpointer iface_data);
static void dbustube_iface_init (gpointer g_iface, gpointer iface_data);
-G_DEFINE_TYPE_WITH_CODE (SalutTubeDBus, salut_tube_dbus, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_DBUS_PROPERTIES,
- tp_dbus_properties_mixin_iface_init);
- G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL, channel_iface_init);
+G_DEFINE_TYPE_WITH_CODE (SalutTubeDBus, salut_tube_dbus, TP_TYPE_BASE_CHANNEL,
G_IMPLEMENT_INTERFACE (SALUT_TYPE_TUBE_IFACE, tube_iface_init);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_TYPE_DBUS_TUBE,
dbustube_iface_init);
G_IMPLEMENT_INTERFACE (TP_TYPE_SVC_CHANNEL_INTERFACE_TUBE,
- NULL);
- G_IMPLEMENT_INTERFACE (TP_TYPE_EXPORTABLE_CHANNEL, NULL);
- G_IMPLEMENT_INTERFACE (TP_TYPE_CHANNEL_IFACE, NULL));
+ NULL))
static const gchar *salut_tube_dbus_interfaces[] = {
- TP_IFACE_CHANNEL_INTERFACE_GROUP,
- /* If more interfaces are added, either keep Group as the first, or change
- * the implementations of salut_tube_dbus_get_interfaces () and
- * salut_tube_dbus_get_property () too */
TP_IFACE_CHANNEL_INTERFACE_TUBE,
NULL
};
@@ -102,31 +93,19 @@ static guint signals[LAST_SIGNAL] = {0};
/* properties */
enum
{
- PROP_OBJECT_PATH = 1,
- PROP_CHANNEL_TYPE,
- PROP_CONNECTION,
- PROP_INTERFACES,
- PROP_TUBES_CHANNEL,
- PROP_HANDLE,
- PROP_HANDLE_TYPE,
+ PROP_TUBES_CHANNEL = 1,
PROP_SELF_HANDLE,
PROP_MUC_CONNECTION,
PROP_ID,
PROP_BYTESTREAM,
PROP_STREAM_ID,
PROP_TYPE,
- PROP_INITIATOR_HANDLE,
PROP_SERVICE,
PROP_PARAMETERS,
PROP_STATE,
PROP_DBUS_ADDRESS,
PROP_DBUS_NAME,
PROP_DBUS_NAMES,
- PROP_CHANNEL_DESTROYED,
- PROP_CHANNEL_PROPERTIES,
- PROP_REQUESTED,
- PROP_TARGET_ID,
- PROP_INITIATOR_ID,
PROP_SUPPORTED_ACCESS_CONTROLS,
LAST_PROPERTY
};
@@ -134,11 +113,7 @@ enum
typedef struct _SalutTubeDBusPrivate SalutTubeDBusPrivate;
struct _SalutTubeDBusPrivate
{
- SalutConnection *conn;
- gchar *object_path;
SalutTubesChannel *tubes_channel;
- TpHandle handle;
- TpHandleType handle_type;
TpHandle self_handle;
GibberMucConnection *muc_connection;
guint id;
@@ -395,6 +370,7 @@ do_close (SalutTubeDBus *self)
else
{
g_signal_emit (G_OBJECT (self), signals[CLOSED], 0);
+ tp_base_channel_destroyed (TP_BASE_CHANNEL (self));
}
}
@@ -546,6 +522,7 @@ bytestream_state_changed_cb (GibberBytestreamIface *bytestream,
priv->closed = TRUE;
g_signal_emit (G_OBJECT (self), signals[CLOSED], 0);
+ tp_base_channel_destroyed (TP_BASE_CHANNEL (self));
}
else if (state == GIBBER_BYTESTREAM_STATE_OPEN)
{
@@ -635,7 +612,6 @@ salut_tube_dbus_finalize (GObject *object)
SalutTubeDBus *self = SALUT_TUBE_DBUS (object);
SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
- g_free (priv->object_path);
g_free (priv->stream_id);
g_free (priv->service);
g_hash_table_unref (priv->parameters);
@@ -652,41 +628,12 @@ salut_tube_dbus_get_property (GObject *object,
{
SalutTubeDBus *self = SALUT_TUBE_DBUS (object);
SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
- TpBaseConnection *base_conn = (TpBaseConnection *) priv->conn;
switch (property_id)
{
- case PROP_OBJECT_PATH:
- g_value_set_string (value, priv->object_path);
- break;
- case PROP_CHANNEL_TYPE:
- g_value_set_static_string (value,
- TP_IFACE_CHANNEL_TYPE_DBUS_TUBE);
- break;
- case PROP_CONNECTION:
- g_value_set_object (value, priv->conn);
- break;
- case PROP_INTERFACES:
- if (priv->handle_type == TP_HANDLE_TYPE_CONTACT)
- {
- /* 1-1 tubes - omit the Group interface */
- g_value_set_boxed (value, salut_tube_dbus_interfaces + 1);
- }
- else
- {
- /* MUC tubes */
- g_value_set_boxed (value, salut_tube_dbus_interfaces);
- }
- break;
case PROP_TUBES_CHANNEL:
g_value_set_object (value, priv->tubes_channel);
break;
- case PROP_HANDLE:
- g_value_set_uint (value, priv->handle);
- break;
- case PROP_HANDLE_TYPE:
- g_value_set_uint (value, priv->handle_type);
- break;
case PROP_SELF_HANDLE:
g_value_set_uint (value, priv->self_handle);
break;
@@ -705,9 +652,6 @@ salut_tube_dbus_get_property (GObject *object,
case PROP_TYPE:
g_value_set_uint (value, TP_TUBE_TYPE_DBUS);
break;
- case PROP_INITIATOR_HANDLE:
- g_value_set_uint (value, priv->initiator);
- break;
case PROP_SERVICE:
g_value_set_string (value, priv->service);
break;
@@ -726,72 +670,6 @@ salut_tube_dbus_get_property (GObject *object,
case PROP_DBUS_NAMES:
g_value_set_boxed (value, priv->dbus_names);
break;
- case PROP_CHANNEL_DESTROYED:
- g_value_set_boolean (value, priv->closed);
- break;
- case PROP_CHANNEL_PROPERTIES:
- {
- GHashTable *properties;
-
- properties = tp_dbus_properties_mixin_make_properties_hash (object,
- TP_IFACE_CHANNEL, "TargetHandle",
- TP_IFACE_CHANNEL, "TargetHandleType",
- TP_IFACE_CHANNEL, "ChannelType",
- TP_IFACE_CHANNEL, "TargetID",
- TP_IFACE_CHANNEL, "InitiatorHandle",
- TP_IFACE_CHANNEL, "InitiatorID",
- TP_IFACE_CHANNEL, "Requested",
- TP_IFACE_CHANNEL, "Interfaces",
- TP_IFACE_CHANNEL_TYPE_DBUS_TUBE, "ServiceName",
- TP_IFACE_CHANNEL_TYPE_DBUS_TUBE, "SupportedAccessControls",
- NULL);
-
- if (priv->initiator != priv->self_handle)
- {
- /* channel has not been requested so Parameters is immutable */
- GValue *prop_value = g_slice_new0 (GValue);
-
- /* FIXME: use tp_dbus_properties_mixin_add_properties once it's
- * added in tp-glib */
- tp_dbus_properties_mixin_get (object,
- TP_IFACE_CHANNEL_INTERFACE_TUBE, "Parameters",
- prop_value, NULL);
- g_assert (G_IS_VALUE (prop_value));
-
- g_hash_table_insert (properties,
- g_strdup_printf ("%s.%s", TP_IFACE_CHANNEL_INTERFACE_TUBE,
- "Parameters"), prop_value);
- }
-
- g_value_take_boxed (value, properties);
- }
- break;
- case PROP_REQUESTED:
- g_value_set_boolean (value,
- (priv->initiator == priv->self_handle));
- break;
- case PROP_INITIATOR_ID:
- {
- TpHandleRepoIface *repo = tp_base_connection_get_handles (
- base_conn, TP_HANDLE_TYPE_CONTACT);
-
- /* some channel can have o.f.T.Channel.InitiatorHandle == 0 but
- * tubes always have an initiator */
- g_assert (priv->initiator != 0);
-
- g_value_set_string (value,
- tp_handle_inspect (repo, priv->initiator));
- }
- break;
- case PROP_TARGET_ID:
- {
- TpHandleRepoIface *repo = tp_base_connection_get_handles (
- base_conn, priv->handle_type);
-
- g_value_set_string (value,
- tp_handle_inspect (repo, priv->handle));
- }
- break;
case PROP_SUPPORTED_ACCESS_CONTROLS:
g_value_set_boxed (value, priv->supported_access_controls);
break;
@@ -812,26 +690,9 @@ salut_tube_dbus_set_property (GObject *object,
switch (property_id)
{
- case PROP_OBJECT_PATH:
- g_free (priv->object_path);
- priv->object_path = g_value_dup_string (value);
- break;
- case PROP_CHANNEL_TYPE:
- /* this property is writable in the interface, but not actually
- * meaningfully changeable on this channel, so we do nothing */
- break;
- case PROP_CONNECTION:
- priv->conn = g_value_get_object (value);
- break;
case PROP_TUBES_CHANNEL:
priv->tubes_channel = g_value_get_object (value);
break;
- case PROP_HANDLE:
- priv->handle = g_value_get_uint (value);
- break;
- case PROP_HANDLE_TYPE:
- priv->handle_type = g_value_get_uint (value);
- break;
case PROP_SELF_HANDLE:
priv->self_handle = g_value_get_uint (value);
break;
@@ -860,9 +721,6 @@ salut_tube_dbus_set_property (GObject *object,
G_CALLBACK (bytestream_state_changed_cb), self);
}
break;
- case PROP_INITIATOR_HANDLE:
- priv->initiator = g_value_get_uint (value);
- break;
case PROP_SERVICE:
g_free (priv->service);
priv->service = g_value_dup_string (value);
@@ -886,7 +744,9 @@ salut_tube_dbus_constructor (GType type,
GObject *obj;
SalutTubeDBus *self;
SalutTubeDBusPrivate *priv;
- TpDBusDaemon *bus;
+ TpBaseChannel *base;
+ TpBaseChannelClass *cls;
+ SalutConnection *conn;
TpBaseConnection *base_conn;
TpHandleRepoIface *handles_repo;
TpSocketAccessControl access_control;
@@ -895,22 +755,18 @@ salut_tube_dbus_constructor (GType type,
constructor (type, n_props, props);
self = SALUT_TUBE_DBUS (obj);
- priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
-
- base_conn = TP_BASE_CONNECTION (priv->conn);
- handles_repo = tp_base_connection_get_handles (base_conn, priv->handle_type);
-
- /* Ref the initiator handle */
- g_assert (priv->conn != NULL);
- g_assert (priv->initiator != 0);
+ base = TP_BASE_CHANNEL (self);
+ cls = TP_BASE_CHANNEL_GET_CLASS (base);
- bus = tp_base_connection_get_dbus_daemon (base_conn);
- tp_dbus_daemon_register_object (bus, priv->object_path, obj);
+ priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
- DEBUG ("Registering at '%s'", priv->object_path);
+ conn = SALUT_CONNECTION (tp_base_channel_get_connection (base));
+ base_conn = TP_BASE_CONNECTION (conn);
+ handles_repo = tp_base_connection_get_handles (base_conn,
+ cls->target_handle_type);
g_assert (priv->self_handle != 0);
- if (priv->handle_type == TP_HANDLE_TYPE_ROOM)
+ if (cls->target_handle_type == TP_HANDLE_TYPE_ROOM)
{
/*
* We have to create an MUC bytestream that will be
@@ -927,15 +783,16 @@ salut_tube_dbus_constructor (GType type,
priv->dbus_names = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, g_free);
- priv->dbus_local_name = generate_dbus_unique_name (priv->conn->name);
+ priv->dbus_local_name = generate_dbus_unique_name (conn->name);
DEBUG ("local name: %s", priv->dbus_local_name);
- peer_id = tp_handle_inspect (handles_repo, priv->handle);
+ peer_id = tp_handle_inspect (handles_repo,
+ tp_base_channel_get_target_handle (base));
bytestream = g_object_new (GIBBER_TYPE_BYTESTREAM_MUC,
"muc-connection", priv->muc_connection,
"state", GIBBER_BYTESTREAM_STATE_LOCAL_PENDING,
- "self-id", priv->conn->name,
+ "self-id", conn->name,
"peer-id", peer_id,
NULL);
@@ -958,7 +815,13 @@ salut_tube_dbus_constructor (GType type,
priv->reassembly_bytes_needed = 0;
}
- if (priv->initiator == priv->self_handle)
+ /* Tube needs to be offered if we initiated and requested it. Being
+ * the initiator is not enough as we could re-join a MUC containing
+ * an old tube we created when we were in this room some time
+ * ago. In that case, we have to accept it if we want to re-join the
+ * tube. */
+ if (tp_base_channel_get_initiator (base) == priv->self_handle
+ && tp_base_channel_is_requested (base))
{
priv->offered = FALSE;
}
@@ -984,19 +847,49 @@ salut_tube_dbus_constructor (GType type,
}
static void
+salut_tube_dbus_fill_immutable_properties (TpBaseChannel *chan,
+ GHashTable *properties)
+{
+ TpBaseChannelClass *cls = TP_BASE_CHANNEL_CLASS (
+ salut_tube_dbus_parent_class);
+
+ cls->fill_immutable_properties (chan, properties);
+
+ tp_dbus_properties_mixin_fill_properties_hash (
+ G_OBJECT (chan), properties,
+ TP_IFACE_CHANNEL_TYPE_DBUS_TUBE, "ServiceName",
+ TP_IFACE_CHANNEL_TYPE_DBUS_TUBE, "SupportedAccessControls",
+ NULL);
+
+ if (!tp_base_channel_is_requested (chan))
+ {
+ tp_dbus_properties_mixin_fill_properties_hash (
+ G_OBJECT (chan), properties,
+ TP_IFACE_CHANNEL_INTERFACE_TUBE, "Parameters",
+ NULL);
+ }
+}
+
+static gchar *
+salut_tube_dbus_get_object_path_suffix (TpBaseChannel *base)
+{
+ SalutTubeDBus *self = SALUT_TUBE_DBUS (base);
+ SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
+
+ return g_strdup_printf ("DBusTubeChannel/%u/%u",
+ tp_base_channel_get_target_handle (base),
+ priv->id);
+}
+
+static void
+salut_tube_dbus_close_dbus (TpBaseChannel *base)
+{
+ do_close ((SalutTubeDBus *) base);
+}
+
+static void
salut_tube_dbus_class_init (SalutTubeDBusClass *salut_tube_dbus_class)
{
- static TpDBusPropertiesMixinPropImpl channel_props[] = {
- { "TargetHandleType", "handle-type", NULL },
- { "TargetHandle", "handle", NULL },
- { "ChannelType", "channel-type", NULL },
- { "TargetID", "target-id", NULL },
- { "Interfaces", "interfaces", NULL },
- { "Requested", "requested", NULL },
- { "InitiatorHandle", "initiator-handle", NULL },
- { "InitiatorID", "initiator-id", NULL },
- { NULL }
- };
static TpDBusPropertiesMixinPropImpl dbus_tube_props[] = {
{ "ServiceName", "service", NULL },
{ "DBusNames", "dbus-names", NULL },
@@ -1009,11 +902,6 @@ salut_tube_dbus_class_init (SalutTubeDBusClass *salut_tube_dbus_class)
{ NULL }
};
static TpDBusPropertiesMixinIfaceImpl prop_interfaces[] = {
- { TP_IFACE_CHANNEL,
- tp_dbus_properties_mixin_getter_gobject_properties,
- NULL,
- channel_props,
- },
{ TP_IFACE_CHANNEL_TYPE_DBUS_TUBE,
tp_dbus_properties_mixin_getter_gobject_properties,
NULL,
@@ -1027,38 +915,36 @@ salut_tube_dbus_class_init (SalutTubeDBusClass *salut_tube_dbus_class)
{ NULL }
};
GObjectClass *object_class = G_OBJECT_CLASS (salut_tube_dbus_class);
+ TpBaseChannelClass *base_class = TP_BASE_CHANNEL_CLASS (salut_tube_dbus_class);
GParamSpec *param_spec;
object_class->get_property = salut_tube_dbus_get_property;
object_class->set_property = salut_tube_dbus_set_property;
object_class->constructor = salut_tube_dbus_constructor;
+ base_class->channel_type = TP_IFACE_CHANNEL_TYPE_DBUS_TUBE;
+ base_class->interfaces = salut_tube_dbus_interfaces;
+ base_class->target_handle_type = TP_HANDLE_TYPE_CONTACT;
+ base_class->close = salut_tube_dbus_close_dbus;
+ base_class->fill_immutable_properties =
+ salut_tube_dbus_fill_immutable_properties;
+ base_class->get_object_path_suffix =
+ salut_tube_dbus_get_object_path_suffix;
+
g_type_class_add_private (salut_tube_dbus_class,
sizeof (SalutTubeDBusPrivate));
object_class->dispose = salut_tube_dbus_dispose;
object_class->finalize = salut_tube_dbus_finalize;
- g_object_class_override_property (object_class, PROP_OBJECT_PATH,
- "object-path");
- g_object_class_override_property (object_class, PROP_CHANNEL_TYPE,
- "channel-type");
- g_object_class_override_property (object_class, PROP_CONNECTION,
- "connection");
g_object_class_override_property (object_class, PROP_TUBES_CHANNEL,
"tubes-channel");
- g_object_class_override_property (object_class, PROP_HANDLE,
- "handle");
- g_object_class_override_property (object_class, PROP_HANDLE_TYPE,
- "handle-type");
g_object_class_override_property (object_class, PROP_SELF_HANDLE,
"self-handle");
g_object_class_override_property (object_class, PROP_ID,
"id");
g_object_class_override_property (object_class, PROP_TYPE,
"type");
- g_object_class_override_property (object_class, PROP_INITIATOR_HANDLE,
- "initiator-handle");
g_object_class_override_property (object_class, PROP_SERVICE,
"service");
g_object_class_override_property (object_class, PROP_PARAMETERS,
@@ -1066,11 +952,6 @@ salut_tube_dbus_class_init (SalutTubeDBusClass *salut_tube_dbus_class)
g_object_class_override_property (object_class, PROP_STATE,
"state");
- g_object_class_override_property (object_class, PROP_CHANNEL_DESTROYED,
- "channel-destroyed");
- g_object_class_override_property (object_class, PROP_CHANNEL_PROPERTIES,
- "channel-properties");
-
param_spec = g_param_spec_object (
"muc-connection",
"GibberMucConnection object",
@@ -1123,31 +1004,6 @@ salut_tube_dbus_class_init (SalutTubeDBusClass *salut_tube_dbus_class)
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_DBUS_NAMES, param_spec);
- param_spec = g_param_spec_boxed ("interfaces", "Extra D-Bus interfaces",
- "Additional Channel.Interface.* interfaces",
- G_TYPE_STRV,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_INTERFACES, param_spec);
-
- param_spec = g_param_spec_string ("target-id", "Target JID",
- "The string obtained by inspecting the target handle",
- NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_TARGET_ID, param_spec);
-
- param_spec = g_param_spec_string ("initiator-id", "Initiator's bare JID",
- "The string obtained by inspecting the initiator-handle",
- NULL,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_INITIATOR_ID,
- param_spec);
-
- param_spec = g_param_spec_boolean ("requested", "Requested?",
- "True if this channel was requested by the local user",
- FALSE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_REQUESTED, param_spec);
-
param_spec = g_param_spec_boxed (
"supported-access-controls",
"Supported access-controls",
@@ -1194,6 +1050,8 @@ salut_tube_dbus_offer (SalutTubeDBus *self,
GError **error)
{
SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
+ TpBaseChannel *base = TP_BASE_CHANNEL (self);
+ TpBaseChannelClass *cls = TP_BASE_CHANNEL_GET_CLASS (base);
if (priv->offered)
{
@@ -1202,7 +1060,7 @@ salut_tube_dbus_offer (SalutTubeDBus *self,
return FALSE;
}
- if (priv->handle_type == TP_HANDLE_TYPE_CONTACT)
+ if (cls->target_handle_type == TP_HANDLE_TYPE_CONTACT)
{
/* TODO: we don't implement 1-1 D-Bus tube atm */
;
@@ -1229,6 +1087,8 @@ message_received (SalutTubeDBus *tube,
const char *data,
size_t len)
{
+ TpBaseChannel *base = TP_BASE_CHANNEL (tube);
+ TpBaseChannelClass *cls = TP_BASE_CHANNEL_GET_CLASS (base);
SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (tube);
DBusMessage *msg;
DBusError error = {0,};
@@ -1245,7 +1105,7 @@ message_received (SalutTubeDBus *tube,
return;
}
- if (priv->handle_type == TP_HANDLE_TYPE_ROOM)
+ if (cls->target_handle_type == TP_HANDLE_TYPE_ROOM)
{
const gchar *destination;
const gchar *sender_name;
@@ -1331,8 +1191,11 @@ data_received_cb (GibberBytestreamIface *stream,
{
SalutTubeDBus *tube = SALUT_TUBE_DBUS (user_data);
SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (tube);
+ TpBaseChannel *base = TP_BASE_CHANNEL (tube);
+ TpBaseChannelClass *cls = TP_BASE_CHANNEL_GET_CLASS (base);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
- (TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
+ tp_base_channel_get_connection (base),
+ TP_HANDLE_TYPE_CONTACT);
TpHandle sender;
sender = tp_handle_lookup (contact_repo, from, NULL, NULL);
@@ -1342,7 +1205,7 @@ data_received_cb (GibberBytestreamIface *stream,
return;
}
- if (priv->handle_type == TP_HANDLE_TYPE_CONTACT)
+ if (cls->target_handle_type == TP_HANDLE_TYPE_CONTACT)
{
GString *buf = priv->reassembly_buffer;
@@ -1459,17 +1322,15 @@ salut_tube_dbus_new (SalutConnection *conn,
gboolean requested)
{
SalutTubeDBus *tube;
- gchar *object_path;
+ GType gtype = SALUT_TYPE_TUBE_DBUS;
- object_path = g_strdup_printf ("%s/DBusTubeChannel_%u_%u",
- conn->parent.object_path, handle, id);
+ if (handle_type == TP_HANDLE_TYPE_ROOM)
+ gtype = SALUT_TYPE_MUC_TUBE_DBUS;
- tube = g_object_new (SALUT_TYPE_TUBE_DBUS,
+ tube = g_object_new (gtype,
"connection", conn,
- "object-path", object_path,
"tubes-channel", tubes_channel,
"handle", handle,
- "handle-type", handle_type,
"self-handle", self_handle,
"muc-connection", muc_connection,
"initiator-handle", initiator,
@@ -1493,6 +1354,8 @@ salut_tube_dbus_accept (SalutTubeIface *tube,
{
SalutTubeDBus *self = SALUT_TUBE_DBUS (tube);
SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
+ TpBaseChannel *base = TP_BASE_CHANNEL (self);
+ TpBaseChannelClass *cls = TP_BASE_CHANNEL_GET_CLASS (base);
GibberBytestreamState state;
g_assert (priv->bytestream != NULL);
@@ -1504,7 +1367,7 @@ salut_tube_dbus_accept (SalutTubeIface *tube,
if (state != GIBBER_BYTESTREAM_STATE_LOCAL_PENDING)
return TRUE;
- if (priv->handle_type == TP_HANDLE_TYPE_CONTACT)
+ if (cls->target_handle_type == TP_HANDLE_TYPE_CONTACT)
{
/* TODO: SI reply */
}
@@ -1553,12 +1416,15 @@ salut_tube_dbus_add_name (SalutTubeDBus *self,
const gchar *name)
{
SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
+ TpBaseChannel *base = TP_BASE_CHANNEL (self);
+ TpBaseChannelClass *cls = TP_BASE_CHANNEL_GET_CLASS (base);
TpHandleRepoIface *contact_repo = tp_base_connection_get_handles (
- (TpBaseConnection *) priv->conn, TP_HANDLE_TYPE_CONTACT);
+ tp_base_channel_get_connection (base),
+ TP_HANDLE_TYPE_CONTACT);
GHashTable *added;
GArray *removed;
- g_assert (priv->handle_type == TP_HANDLE_TYPE_ROOM);
+ g_assert (cls->target_handle_type == TP_HANDLE_TYPE_ROOM);
if (g_hash_table_lookup (priv->dbus_names, GUINT_TO_POINTER (handle))
!= NULL)
@@ -1608,11 +1474,13 @@ salut_tube_dbus_remove_name (SalutTubeDBus *self,
TpHandle handle)
{
SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
+ TpBaseChannel *base = TP_BASE_CHANNEL (self);
+ TpBaseChannelClass *cls = TP_BASE_CHANNEL_GET_CLASS (base);
const gchar *name;
GHashTable *added;
GArray *removed;
- g_assert (priv->handle_type == TP_HANDLE_TYPE_ROOM);
+ g_assert (cls->target_handle_type == TP_HANDLE_TYPE_ROOM);
name = g_hash_table_lookup (priv->dbus_names, GUINT_TO_POINTER (handle));
if (name == NULL)
@@ -1639,8 +1507,10 @@ salut_tube_dbus_handle_in_names (SalutTubeDBus *self,
TpHandle handle)
{
SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
+ TpBaseChannel *base = TP_BASE_CHANNEL (self);
+ TpBaseChannelClass *cls = TP_BASE_CHANNEL_GET_CLASS (base);
- g_assert (priv->handle_type == TP_HANDLE_TYPE_ROOM);
+ g_assert (cls->target_handle_type == TP_HANDLE_TYPE_ROOM);
return (g_hash_table_lookup (priv->dbus_names, GUINT_TO_POINTER (handle))
!= NULL);
@@ -1652,77 +1522,6 @@ salut_tube_dbus_channel_get_allowed_properties (void)
return salut_tube_dbus_channel_allowed_properties;
}
-/**
- * salut_tube_dbus_close_async:
- *
- * Implements D-Bus method Close
- * on interface org.freedesktop.Telepathy.Channel
- */
-static void
-salut_tube_dbus_close_async (TpSvcChannel *iface,
- DBusGMethodInvocation *context)
-{
- salut_tube_dbus_close (SALUT_TUBE_IFACE (iface), FALSE);
- tp_svc_channel_return_from_close (context);
-}
-
-/**
- * salut_tube_dbus_get_channel_type
- *
- * Implements D-Bus method GetChannelType
- * on interface org.freedesktop.Telepathy.Channel
- */
-static void
-salut_tube_dbus_get_channel_type (TpSvcChannel *iface,
- DBusGMethodInvocation *context)
-{
- tp_svc_channel_return_from_get_channel_type (context,
- TP_IFACE_CHANNEL_TYPE_DBUS_TUBE);
-}
-
-/**
- * salut_tube_dbus_get_handle
- *
- * Implements D-Bus method GetHandle
- * on interface org.freedesktop.Telepathy.Channel
- */
-static void
-salut_tube_dbus_get_handle (TpSvcChannel *iface,
- DBusGMethodInvocation *context)
-{
- SalutTubeDBus *self = SALUT_TUBE_DBUS (iface);
- SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
-
- tp_svc_channel_return_from_get_handle (context, priv->handle_type,
- priv->handle);
-}
-
-/**
- * salut_tube_dbus_get_interfaces
- *
- * Implements D-Bus method GetInterfaces
- * on interface org.freedesktop.Telepathy.Channel
- */
-static void
-salut_tube_dbus_get_interfaces (TpSvcChannel *iface,
- DBusGMethodInvocation *context)
-{
- SalutTubeDBus *self = SALUT_TUBE_DBUS (iface);
- SalutTubeDBusPrivate *priv = SALUT_TUBE_DBUS_GET_PRIVATE (self);
-
- if (priv->handle_type == TP_HANDLE_TYPE_CONTACT)
- {
- /* omit the Group interface */
- tp_svc_channel_return_from_get_interfaces (context,
- salut_tube_dbus_interfaces + 1);
- }
- else
- {
- tp_svc_channel_return_from_get_interfaces (context,
- salut_tube_dbus_interfaces);
- }
-}
-
static gboolean
salut_tube_dbus_check_access_control (SalutTubeDBus *self,
guint access_control,
@@ -1819,21 +1618,6 @@ salut_tube_dbus_accept_async (TpSvcChannelTypeDBusTube *self,
}
static void
-channel_iface_init (gpointer g_iface,
- gpointer iface_data)
-{
- TpSvcChannelClass *klass = (TpSvcChannelClass *) g_iface;
-
-#define IMPLEMENT(x, suffix) tp_svc_channel_implement_##x (\
- klass, salut_tube_dbus_##x##suffix)
- IMPLEMENT(close,_async);
- IMPLEMENT(get_channel_type,);
- IMPLEMENT(get_handle,);
- IMPLEMENT(get_interfaces,);
-#undef IMPLEMENT
-}
-
-static void
tube_iface_init (gpointer g_iface,
gpointer iface_data)
{
diff --git a/src/tube-dbus.h b/src/tube-dbus.h
index b90285ac..d3954ad4 100644
--- a/src/tube-dbus.h
+++ b/src/tube-dbus.h
@@ -22,6 +22,7 @@
#include <glib-object.h>
+#include <telepathy-glib/base-channel.h>
#include <telepathy-glib/enums.h>
#include <telepathy-glib/interfaces.h>
@@ -36,13 +37,13 @@ typedef struct _SalutTubeDBus SalutTubeDBus;
typedef struct _SalutTubeDBusClass SalutTubeDBusClass;
struct _SalutTubeDBusClass {
- GObjectClass parent_class;
+ TpBaseChannelClass parent_class;
TpDBusPropertiesMixinClass dbus_props_class;
};
struct _SalutTubeDBus {
- GObject parent;
+ TpBaseChannel parent;
gpointer priv;
};
diff --git a/src/tube-iface.c b/src/tube-iface.c
index 18d39877..fa866442 100644
--- a/src/tube-iface.c
+++ b/src/tube-iface.c
@@ -96,7 +96,7 @@ salut_tube_iface_base_init (gpointer klass)
"connection",
"SalutConnection object",
"Salut connection object that owns this D-Bus tube object.",
- SALUT_TYPE_CONNECTION,
+ TP_TYPE_BASE_CONNECTION,
G_PARAM_CONSTRUCT_ONLY |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_interface_install_property (klass, param_spec);
diff --git a/src/tubes-channel.c b/src/tubes-channel.c
index 1d7a1968..77b5c7cd 100644
--- a/src/tubes-channel.c
+++ b/src/tubes-channel.c
@@ -1150,6 +1150,8 @@ create_new_tube (SalutTubesChannel *self,
tube = SALUT_TUBE_IFACE (salut_tube_dbus_new (priv->conn, self,
priv->handle, priv->handle_type, priv->self_handle, muc_connection,
initiator, service, parameters, tube_id, requested));
+
+ tp_base_channel_register ((TpBaseChannel *) tube);
break;
case TP_TUBE_TYPE_STREAM:
tube = SALUT_TUBE_IFACE (salut_tube_stream_new (priv->conn, self,