summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2009-09-08 18:31:34 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2009-09-08 18:31:34 +0100
commit811a58d941410c0ede9409d35f2eb7f34feddfc7 (patch)
treeda0b756201b984c7e93acb73762c5f4468de1db3
parentf88f4422e3d8570d09bcebad7a88b24821101fe3 (diff)
downloadtelepathy-mission-control-811a58d941410c0ede9409d35f2eb7f34feddfc7.tar.gz
McdDispatchOperation: factor out mcd_dispatch_operation_check_handle_with (the checks that can be done synchronously)
-rw-r--r--src/mcd-dispatch-operation.c49
1 files changed, 36 insertions, 13 deletions
diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index c6bfe47b..6ffbb429 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -661,6 +661,40 @@ mcd_dispatch_operation_get_handler (McdDispatchOperation *operation)
return operation->priv->handler;
}
+static gboolean
+mcd_dispatch_operation_check_handle_with (McdDispatchOperation *self,
+ const gchar *handler_name,
+ GError **error)
+{
+ g_return_val_if_fail (MCD_IS_DISPATCH_OPERATION (self), FALSE);
+
+ if (self->priv->finished)
+ {
+ DEBUG ("NotYours: already finished");
+ g_set_error (error, TP_ERRORS, TP_ERROR_NOT_YOURS,
+ "CDO already finished");
+ return FALSE;
+ }
+
+ if (handler_name == NULL || handler_name[0] == '\0')
+ {
+ /* no handler name given */
+ return TRUE;
+ }
+
+ if (!g_str_has_prefix (handler_name, MCD_CLIENT_BASE_NAME) ||
+ !tp_dbus_check_valid_bus_name (handler_name,
+ TP_DBUS_NAME_TYPE_WELL_KNOWN, NULL))
+ {
+ DEBUG ("InvalidArgument: handler name %s is bad", handler_name);
+ g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
+ "Invalid handler name");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
void
mcd_dispatch_operation_handle_with (McdDispatchOperation *operation,
const gchar *handler_name,
@@ -673,25 +707,14 @@ mcd_dispatch_operation_handle_with (McdDispatchOperation *operation,
DEBUG ("%s/%p", priv->unique_name, operation);
- if (priv->finished)
+ if (!mcd_dispatch_operation_check_handle_with (operation, handler_name,
+ error))
{
- DEBUG ("NotYours: already finished");
- g_set_error (error, TP_ERRORS, TP_ERROR_NOT_YOURS,
- "CDO already finished");
return;
}
if (handler_name != NULL && handler_name[0] != '\0')
{
- if (!g_str_has_prefix (handler_name, MCD_CLIENT_BASE_NAME) ||
- !tp_dbus_check_valid_bus_name (handler_name,
- TP_DBUS_NAME_TYPE_WELL_KNOWN, NULL))
- {
- DEBUG ("InvalidArgument: handler name %s is bad", handler_name);
- g_set_error (error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT,
- "Invalid handler name");
- return;
- }
priv->handler = g_strdup (handler_name + MCD_CLIENT_BASE_NAME_LEN);
}