[Telepathy-commits] [telepathy-gabble/master] Tubes requestotron: Advertise the right RequestableChannelClasses for tubes, and strongly check properties in CreateChannel/RequestChannel.
Alban Crequy
alban.crequy at collabora.co.uk
Fri Dec 5 09:42:39 PST 2008
---
src/private-tubes-factory.c | 80 ++++++++++++++++++++++++++++++++++++------
src/tubes-channel.c | 4 ++
2 files changed, 72 insertions(+), 12 deletions(-)
diff --git a/src/private-tubes-factory.c b/src/private-tubes-factory.c
index 26cea49..6ad730d 100644
--- a/src/private-tubes-factory.c
+++ b/src/private-tubes-factory.c
@@ -963,10 +963,20 @@ static const gchar * const tubes_channel_fixed_properties[] = {
NULL
};
-static const gchar * const tubes_channel_allowed_properties[] = {
+static const gchar * const old_tubes_channel_allowed_properties[] = {
TP_IFACE_CHANNEL ".TargetHandle",
+ NULL
+};
+static const gchar * const stream_tube_channel_allowed_properties[] = {
+ TP_IFACE_CHANNEL ".TargetHandle",
+ GABBLE_IFACE_CHANNEL_INTERFACE_TUBE ".Parameters",
GABBLE_IFACE_CHANNEL_TYPE_STREAM_TUBE ".Service",
+ NULL
+};
+static const gchar * const dbus_tube_channel_allowed_properties[] = {
+ TP_IFACE_CHANNEL ".TargetHandle",
GABBLE_IFACE_CHANNEL_INTERFACE_TUBE ".Parameters",
+ GABBLE_IFACE_CHANNEL_TYPE_DBUS_TUBE ".ServiceName",
NULL
};
@@ -994,7 +1004,7 @@ gabble_private_tubes_factory_foreach_channel_class (
g_hash_table_insert (table, TP_IFACE_CHANNEL ".TargetHandleType",
value);
- func (manager, table, tubes_channel_allowed_properties, user_data);
+ func (manager, table, old_tubes_channel_allowed_properties, user_data);
g_hash_table_destroy (table);
@@ -1012,7 +1022,7 @@ gabble_private_tubes_factory_foreach_channel_class (
g_hash_table_insert (table, TP_IFACE_CHANNEL ".TargetHandleType",
value);
- func (manager, table, tubes_channel_allowed_properties, user_data);
+ func (manager, table, stream_tube_channel_allowed_properties, user_data);
/* 1-1 Channel.Type.DBusTube */
table = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
@@ -1028,7 +1038,7 @@ gabble_private_tubes_factory_foreach_channel_class (
g_hash_table_insert (table, TP_IFACE_CHANNEL ".TargetHandleType",
value);
- func (manager, table, tubes_channel_allowed_properties, user_data);
+ func (manager, table, dbus_tube_channel_allowed_properties, user_data);
g_hash_table_destroy (table);
}
@@ -1048,6 +1058,10 @@ gabble_private_tubes_factory_requestotron (GabblePrivateTubesFactory *self,
const gchar *channel_type;
GabbleTubesChannel *channel;
+ if (tp_asv_get_uint32 (request_properties,
+ TP_IFACE_CHANNEL ".TargetHandleType", NULL) != TP_HANDLE_TYPE_CONTACT)
+ return FALSE;
+
channel_type = tp_asv_get_string (request_properties,
TP_IFACE_CHANNEL ".ChannelType");
@@ -1056,9 +1070,56 @@ gabble_private_tubes_factory_requestotron (GabblePrivateTubesFactory *self,
tp_strdiff (channel_type, GABBLE_IFACE_CHANNEL_TYPE_DBUS_TUBE))
return FALSE;
- if (tp_asv_get_uint32 (request_properties,
- TP_IFACE_CHANNEL ".TargetHandleType", NULL) != TP_HANDLE_TYPE_CONTACT)
- return FALSE;
+ if (! tp_strdiff (channel_type, TP_IFACE_CHANNEL_TYPE_TUBES))
+ {
+ if (tp_channel_manager_asv_has_unknown_properties (request_properties,
+ tubes_channel_fixed_properties,
+ old_tubes_channel_allowed_properties,
+ &error))
+ goto error;
+ }
+ else if (! tp_strdiff (channel_type, GABBLE_IFACE_CHANNEL_TYPE_STREAM_TUBE))
+ {
+ const gchar *service;
+
+ if (tp_channel_manager_asv_has_unknown_properties (request_properties,
+ tubes_channel_fixed_properties,
+ stream_tube_channel_allowed_properties,
+ &error))
+ goto error;
+
+ /* "Service" is a mandatory, not-fixed property */
+ service = tp_asv_get_string (request_properties,
+ GABBLE_IFACE_CHANNEL_TYPE_STREAM_TUBE ".Service");
+ if (service == NULL)
+ {
+ g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
+ "Request missed a mandatory property '%s'",
+ GABBLE_IFACE_CHANNEL_TYPE_STREAM_TUBE ".Service");
+ goto error;
+ }
+ }
+ else if (! tp_strdiff (channel_type, GABBLE_IFACE_CHANNEL_TYPE_DBUS_TUBE))
+ {
+ const gchar *service;
+
+ if (tp_channel_manager_asv_has_unknown_properties (request_properties,
+ tubes_channel_fixed_properties,
+ dbus_tube_channel_allowed_properties,
+ &error))
+ goto error;
+
+ /* "ServiceName" is a mandatory, not-fixed property */
+ service = tp_asv_get_string (request_properties,
+ GABBLE_IFACE_CHANNEL_TYPE_DBUS_TUBE ".ServiceName");
+ if (service == NULL)
+ {
+ g_set_error (&error, TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
+ "Request missed a mandatory property '%s'",
+ GABBLE_IFACE_CHANNEL_TYPE_DBUS_TUBE ".ServiceName");
+ goto error;
+ }
+ }
handle = tp_asv_get_uint32 (request_properties,
TP_IFACE_CHANNEL ".TargetHandle", NULL);
@@ -1066,11 +1127,6 @@ gabble_private_tubes_factory_requestotron (GabblePrivateTubesFactory *self,
if (!tp_handle_is_valid (contact_repo, handle, &error))
goto error;
- if (tp_channel_manager_asv_has_unknown_properties (request_properties,
- tubes_channel_fixed_properties, tubes_channel_allowed_properties,
- &error))
- goto error;
-
/* Don't support opening a channel to our self handle */
if (handle == base_conn->self_handle)
{
diff --git a/src/tubes-channel.c b/src/tubes-channel.c
index 0b8ec4a..3e2f4d4 100644
--- a/src/tubes-channel.c
+++ b/src/tubes-channel.c
@@ -1626,6 +1626,10 @@ GabbleTubeIface *gabble_tubes_channel_tube_request (GabbleTubesChannel *self,
(GDestroyNotify) tp_g_value_slice_free);
}
+ /* if the service property is missing, the requestotron rejects the request
+ */
+ g_assert (service != NULL);
+
DEBUG ("Request a tube channel with type='%s' and service='%s'",
channel_type, service);
--
1.5.6.5
More information about the Telepathy-commits
mailing list