From 72e999bbfd8e1eb4d6a450aebe138f2940772d2b Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 4 Oct 2013 15:03:39 +0200 Subject: [PATCH 4/4] Stop using TpTubeType enum It has been removed in Telepathy 1.0 so redefine it ourself. --- src/muc-channel.c | 24 ++++++++++++------------ src/private-tubes-factory.c | 30 +++++++++++++++--------------- src/private-tubes-factory.h | 3 ++- src/tube-dbus.c | 2 +- src/tube-iface.c | 8 ++++---- src/tube-iface.h | 6 ++++++ src/tube-stream.c | 2 +- 7 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/muc-channel.c b/src/muc-channel.c index 15c337b..78f79c7 100644 --- a/src/muc-channel.c +++ b/src/muc-channel.c @@ -815,7 +815,7 @@ tube_pre_presence (GabbleMucChannel *gmuc, GabbleTubeIface *tube = value; TpTubeChannelState state; WockyNode *tube_node; - TpTubeType type; + TubeType type; TpHandle initiator; g_object_get (tube, @@ -827,7 +827,7 @@ tube_pre_presence (GabbleMucChannel *gmuc, if (state != TP_TUBE_CHANNEL_STATE_OPEN) continue; - if (type == TP_TUBE_TYPE_STREAM + if (type == TUBE_TYPE_STREAM && initiator != TP_GROUP_MIXIN (gmuc)->self_handle) /* We only announce stream tubes we initiated */ continue; @@ -1971,7 +1971,7 @@ tube_closed_cb (GabbleTubeIface *tube, static GabbleTubeIface * create_new_tube (GabbleMucChannel *gmuc, - TpTubeType type, + TubeType type, TpHandle initiator, const gchar *service, GHashTable *parameters, @@ -1990,13 +1990,13 @@ create_new_tube (GabbleMucChannel *gmuc, switch (type) { - case TP_TUBE_TYPE_DBUS: + case TUBE_TYPE_DBUS: tube = GABBLE_TUBE_IFACE (gabble_tube_dbus_new (conn, handle, TP_HANDLE_TYPE_ROOM, self_handle, initiator, service, parameters, stream_id, tube_id, bytestream, gmuc, requested)); break; - case TP_TUBE_TYPE_STREAM: + case TUBE_TYPE_STREAM: tube = GABBLE_TUBE_IFACE (gabble_tube_stream_new (conn, handle, TP_HANDLE_TYPE_ROOM, self_handle, initiator, service, parameters, tube_id, gmuc, requested)); @@ -2044,7 +2044,7 @@ gabble_muc_channel_tube_request (GabbleMucChannel *self, GHashTable *parameters = NULL; guint64 tube_id; gchar *stream_id; - TpTubeType type; + TubeType type; tube_id = generate_tube_id (self); @@ -2053,14 +2053,14 @@ gabble_muc_channel_tube_request (GabbleMucChannel *self, if (!tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE)) { - type = TP_TUBE_TYPE_STREAM; + type = TUBE_TYPE_STREAM; service = tp_asv_get_string (request_properties, TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE); } else if (! tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_DBUS_TUBE)) { - type = TP_TUBE_TYPE_DBUS; + type = TUBE_TYPE_DBUS; service = tp_asv_get_string (request_properties, TP_PROP_CHANNEL_TYPE_DBUS_TUBE_SERVICE_NAME); } @@ -2231,7 +2231,7 @@ tubes_presence_update (GabbleMucChannel *gmuc, const gchar *stream_id; GabbleTubeIface *tube; guint64 tube_id; - TpTubeType type; + TubeType type; stream_id = wocky_node_get_attribute (tube_node, "stream-id"); @@ -2255,13 +2255,13 @@ tubes_presence_update (GabbleMucChannel *gmuc, contact_repo, tube_node, &type, &initiator_handle, &service, ¶meters, NULL)) { - if (type == TP_TUBE_TYPE_DBUS && initiator_handle == 0) + if (type == TUBE_TYPE_DBUS && initiator_handle == 0) { DEBUG ("D-Bus tube initiator missing"); /* skip to the next child of */ continue; } - else if (type == TP_TUBE_TYPE_STREAM) + else if (type == TUBE_TYPE_STREAM) { initiator_handle = contact; } @@ -2287,7 +2287,7 @@ tubes_presence_update (GabbleMucChannel *gmuc, g_object_get (tube, "type", &type, NULL); - if (type == TP_TUBE_TYPE_DBUS) + if (type == TUBE_TYPE_DBUS) { /* Update mapping of handle -> D-Bus name. */ if (!gabble_tube_dbus_handle_in_names (GABBLE_TUBE_DBUS (tube), diff --git a/src/private-tubes-factory.c b/src/private-tubes-factory.c index b8e2a80..b2d8d35 100644 --- a/src/private-tubes-factory.c +++ b/src/private-tubes-factory.c @@ -105,7 +105,7 @@ gboolean gabble_private_tubes_factory_extract_tube_information ( TpHandleRepoIface *contact_repo, WockyNode *tube_node, - TpTubeType *type, + TubeType *type, TpHandle *initiator_handle, const gchar **service, GHashTable **parameters, @@ -119,11 +119,11 @@ gabble_private_tubes_factory_extract_tube_information ( if (!tp_strdiff (_type, "stream")) { - *type = TP_TUBE_TYPE_STREAM; + *type = TUBE_TYPE_STREAM; } else if (!tp_strdiff (_type, "dbus")) { - *type = TP_TUBE_TYPE_DBUS; + *type = TUBE_TYPE_DBUS; } else { @@ -382,7 +382,7 @@ gabble_private_tubes_factory_close_all (GabblePrivateTubesFactory *self) static void add_service_to_array (const gchar *service, GPtrArray *arr, - TpTubeType type, + TubeType type, TpHandle handle) { GValue monster = {0, }; @@ -396,7 +396,7 @@ add_service_to_array (const gchar *service, NULL }; - g_assert (type == TP_TUBE_TYPE_STREAM || type == TP_TUBE_TYPE_DBUS); + g_assert (type == TUBE_TYPE_STREAM || type == TUBE_TYPE_DBUS); g_value_init (&monster, TP_STRUCT_TYPE_REQUESTABLE_CHANNEL_CLASS); g_value_take_boxed (&monster, @@ -407,7 +407,7 @@ add_service_to_array (const gchar *service, (GDestroyNotify) tp_g_value_slice_free); channel_type_value = tp_g_value_slice_new (G_TYPE_STRING); - if (type == TP_TUBE_TYPE_STREAM) + if (type == TUBE_TYPE_STREAM) g_value_set_static_string (channel_type_value, TP_IFACE_CHANNEL_TYPE_STREAM_TUBE); else @@ -423,7 +423,7 @@ add_service_to_array (const gchar *service, target_handle_type_value = tp_g_value_slice_new (G_TYPE_STRING); g_value_set_string (target_handle_type_value, service); - if (type == TP_TUBE_TYPE_STREAM) + if (type == TUBE_TYPE_STREAM) g_hash_table_insert (fixed_properties, TP_PROP_CHANNEL_TYPE_STREAM_TUBE_SERVICE, target_handle_type_value); @@ -532,10 +532,10 @@ get_contact_caps_foreach (gpointer data, if (g_str_has_prefix (ns, STREAM_CAP_PREFIX)) add_service_to_array (ns + strlen (STREAM_CAP_PREFIX), closure->arr, - TP_TUBE_TYPE_STREAM, closure->handle); + TUBE_TYPE_STREAM, closure->handle); else if (g_str_has_prefix (ns, DBUS_CAP_PREFIX)) add_service_to_array (ns + strlen (DBUS_CAP_PREFIX), closure->arr, - TP_TUBE_TYPE_DBUS, closure->handle); + TUBE_TYPE_DBUS, closure->handle); } static void @@ -894,7 +894,7 @@ private_tubes_factory_tube_close_cb ( WockyNode *node; guint64 tube_id; GabbleTubeIface *channel; - TpTubeType type; + TubeType type; node = wocky_node_get_child_ns ( wocky_stanza_get_top_node (msg), "close", NS_TUBES); @@ -912,7 +912,7 @@ private_tubes_factory_tube_close_cb ( } g_object_get (channel, "type", &type, NULL); - if (type != TP_TUBE_TYPE_STREAM) + if (type != TUBE_TYPE_STREAM) { DEBUG ("Only stream tubes can be closed using a close message"); return TRUE; @@ -1113,7 +1113,7 @@ new_channel_from_stanza (GabblePrivateTubesFactory *self, TpHandleRepoIface *contact_repo = tp_base_connection_get_handles ( (TpBaseConnection *) self->priv->conn, TP_HANDLE_TYPE_CONTACT); - TpTubeType type; + TubeType type; TpHandle handle; const gchar *service; GHashTable *parameters; @@ -1132,13 +1132,13 @@ new_channel_from_stanza (GabblePrivateTubesFactory *self, return NULL; } - if (bytestream == NULL && type != TP_TUBE_TYPE_STREAM) + if (bytestream == NULL && type != TUBE_TYPE_STREAM) { DEBUG ("Only stream tubes are allowed to be created using messages"); send_tube_close_msg (self, wocky_stanza_get_from (stanza), tube_id); return NULL; } - else if (bytestream != NULL && type != TP_TUBE_TYPE_DBUS) + else if (bytestream != NULL && type != TUBE_TYPE_DBUS) { GError e = { WOCKY_XMPP_ERROR, WOCKY_XMPP_ERROR_FORBIDDEN, "Only D-Bus tubes are allowed to be created using SI" }; @@ -1148,7 +1148,7 @@ new_channel_from_stanza (GabblePrivateTubesFactory *self, return NULL; } - if (type == TP_TUBE_TYPE_STREAM) + if (type == TUBE_TYPE_STREAM) { tube = GABBLE_TUBE_IFACE (gabble_tube_stream_new (self->priv->conn, handle, TP_HANDLE_TYPE_CONTACT, diff --git a/src/private-tubes-factory.h b/src/private-tubes-factory.h index d9e01f1..025f9bc 100644 --- a/src/private-tubes-factory.h +++ b/src/private-tubes-factory.h @@ -26,6 +26,7 @@ #include "connection.h" #include "bytestream-iface.h" +#include "tube-iface.h" G_BEGIN_DECLS @@ -77,7 +78,7 @@ void gabble_private_tubes_factory_handle_si_stream_request ( gboolean gabble_private_tubes_factory_extract_tube_information ( TpHandleRepoIface *contact_repo, WockyNode *tube_node, - TpTubeType *type, TpHandle *initiator_handle, + TubeType *type, TpHandle *initiator_handle, const gchar **service, GHashTable **parameters, guint64 *tube_id); diff --git a/src/tube-dbus.c b/src/tube-dbus.c index d982e79..3b6197e 100644 --- a/src/tube-dbus.c +++ b/src/tube-dbus.c @@ -611,7 +611,7 @@ gabble_tube_dbus_get_property (GObject *object, g_value_set_string (value, priv->stream_id); break; case PROP_TYPE: - g_value_set_uint (value, TP_TUBE_TYPE_DBUS); + g_value_set_uint (value, TUBE_TYPE_DBUS); break; case PROP_SERVICE: g_value_set_string (value, priv->service); diff --git a/src/tube-iface.c b/src/tube-iface.c index 7faf514..aef131e 100644 --- a/src/tube-iface.c +++ b/src/tube-iface.c @@ -84,7 +84,7 @@ gabble_tube_iface_base_init (gpointer klass) param_spec = g_param_spec_uint ( "type", "Tube type", - "The TpTubeType this tube object.", + "The TubeType this tube object.", 0, G_MAXUINT32, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); g_object_interface_install_property (klass, param_spec); @@ -150,7 +150,7 @@ gabble_tube_iface_publish_in_node (GabbleTubeIface *tube, { WockyNode *parameters_node; GHashTable *parameters; - TpTubeType type; + TubeType type; gchar *service, *id_str; guint64 tube_id; TpHandleRepoIface *contact_repo = tp_base_connection_get_handles ( @@ -176,7 +176,7 @@ gabble_tube_iface_publish_in_node (GabbleTubeIface *tube, switch (type) { - case TP_TUBE_TYPE_DBUS: + case TUBE_TYPE_DBUS: { gchar *name, *stream_id; @@ -198,7 +198,7 @@ gabble_tube_iface_publish_in_node (GabbleTubeIface *tube, g_free (stream_id); } break; - case TP_TUBE_TYPE_STREAM: + case TUBE_TYPE_STREAM: { wocky_node_set_attribute (node, "type", "stream"); } diff --git a/src/tube-iface.h b/src/tube-iface.h index b727f39..6cfa8ca 100644 --- a/src/tube-iface.h +++ b/src/tube-iface.h @@ -27,6 +27,12 @@ G_BEGIN_DECLS +typedef enum +{ + TUBE_TYPE_DBUS = 0, + TUBE_TYPE_STREAM +} TubeType; + typedef struct _GabbleTubeIface GabbleTubeIface; typedef struct _GabbleTubeIfaceClass GabbleTubeIfaceClass; diff --git a/src/tube-stream.c b/src/tube-stream.c index 8bce156..c623813 100644 --- a/src/tube-stream.c +++ b/src/tube-stream.c @@ -1234,7 +1234,7 @@ gabble_tube_stream_get_property (GObject *object, g_value_set_uint64 (value, priv->id); break; case PROP_TYPE: - g_value_set_uint (value, TP_TUBE_TYPE_STREAM); + g_value_set_uint (value, TUBE_TYPE_STREAM); break; case PROP_SERVICE: g_value_set_string (value, priv->service); -- 1.8.3.1