[Telepathy-commits] [telepathy-glib/master] TpBaseConnection: in RequestChannel, ensure that handles are valid
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Sep 25 10:11:10 PDT 2008
In the brave new channel-manager world, channel managers are no longer
responsible for this check (although to be honest, channel factories
never should have been) so the Connection has to do it.
---
telepathy-glib/base-connection.c | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/telepathy-glib/base-connection.c b/telepathy-glib/base-connection.c
index c77a8c0..b6c9ee7 100644
--- a/telepathy-glib/base-connection.c
+++ b/telepathy-glib/base-connection.c
@@ -2010,6 +2010,39 @@ tp_base_connection_request_channel (TpSvcConnection *iface,
TP_BASE_CONNECTION_ERROR_IF_NOT_CONNECTED (self, context);
+ if (handle_type == TP_HANDLE_TYPE_NONE)
+ {
+ if (handle != 0)
+ {
+ GError e = { TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ "When handle type is NONE, handle must be 0" };
+
+ dbus_g_method_return_error (context, &e);
+ return;
+ }
+ }
+ else
+ {
+ TpHandleRepoIface *handle_repo = tp_base_connection_get_handles (self,
+ handle_type);
+
+ if (handle_repo == NULL)
+ {
+ GError e = { TP_ERRORS, TP_ERROR_NOT_AVAILABLE,
+ "Handle type not supported by this connection manager" };
+
+ dbus_g_method_return_error (context, &e);
+ return;
+ }
+
+ if (!tp_handle_is_valid (handle_repo, handle, &error))
+ {
+ dbus_g_method_return_error (context, error);
+ g_error_free (error);
+ return;
+ }
+ }
+
request = channel_request_new (context, METHOD_REQUEST_CHANNEL,
type, handle_type, handle, suppress_handler);
g_ptr_array_add (priv->channel_requests, request);
--
1.5.6.5
More information about the Telepathy-commits
mailing list