[telepathy-mission-control/master] McdDispatchOperation: change _mcd_dispatch_operation_handle_with to _mcd_dispatch_operation_approve

Simon McVittie simon.mcvittie at collabora.co.uk
Tue Sep 8 11:07:06 PDT 2009


It's only called from outside McdDispatchOperation in order to say
"handling with any handler is acceptable" (because a request constitutes
approval), never to say "handle with this specific handler".

It also doesn't need to return the error, because the only possible error
is NotYours, which the caller ignores anyway.
---
 src/mcd-dispatch-operation-priv.h |    5 +--
 src/mcd-dispatch-operation.c      |   45 +++++++++++++++++++------------------
 src/mcd-dispatcher.c              |    3 +-
 3 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/src/mcd-dispatch-operation-priv.h b/src/mcd-dispatch-operation-priv.h
index 4e8df70..a485a8c 100644
--- a/src/mcd-dispatch-operation-priv.h
+++ b/src/mcd-dispatch-operation-priv.h
@@ -59,9 +59,8 @@ G_GNUC_INTERNAL gboolean _mcd_dispatch_operation_is_claimed
     (McdDispatchOperation *operation);
 G_GNUC_INTERNAL const gchar *_mcd_dispatch_operation_get_handler
     (McdDispatchOperation *operation);
-G_GNUC_INTERNAL void _mcd_dispatch_operation_handle_with
-    (McdDispatchOperation *operation, const gchar *handler_path,
-     GError **error);
+G_GNUC_INTERNAL void _mcd_dispatch_operation_approve
+    (McdDispatchOperation *self);
 
 #define MCD_TYPE_DISPATCH_OPERATION         (_mcd_dispatch_operation_get_type ())
 #define MCD_DISPATCH_OPERATION(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), MCD_TYPE_DISPATCH_OPERATION, McdDispatchOperation))
diff --git a/src/mcd-dispatch-operation.c b/src/mcd-dispatch-operation.c
index b035247..c14e649 100644
--- a/src/mcd-dispatch-operation.c
+++ b/src/mcd-dispatch-operation.c
@@ -255,22 +255,34 @@ _mcd_dispatch_operation_finish (McdDispatchOperation *operation)
     return TRUE;
 }
 
+static gboolean mcd_dispatch_operation_check_handle_with (
+    McdDispatchOperation *self, const gchar *handler_name, GError **error);
+
 static void
-dispatch_operation_handle_with (TpSvcChannelDispatchOperation *self,
+dispatch_operation_handle_with (TpSvcChannelDispatchOperation *cdo,
                                 const gchar *handler_name,
                                 DBusGMethodInvocation *context)
 {
     GError *error = NULL;
+    McdDispatchOperation *self = MCD_DISPATCH_OPERATION (cdo);
+
+    DEBUG ("%s/%p", self->priv->unique_name, self);
 
-    _mcd_dispatch_operation_handle_with (MCD_DISPATCH_OPERATION (self),
-                                        handler_name, &error);
-    if (error)
+    if (!mcd_dispatch_operation_check_handle_with (self, handler_name, &error))
     {
         dbus_g_method_return_error (context, error);
         g_error_free (error);
+        return;
     }
-    else
-        tp_svc_channel_dispatch_operation_return_from_handle_with (context);
+
+    if (handler_name != NULL && handler_name[0] != '\0')
+    {
+        self->priv->handler = g_strdup (handler_name +
+                                        MCD_CLIENT_BASE_NAME_LEN);
+    }
+
+    _mcd_dispatch_operation_finish (self);
+    tp_svc_channel_dispatch_operation_return_from_handle_with (context);
 }
 
 static void
@@ -696,29 +708,18 @@ mcd_dispatch_operation_check_handle_with (McdDispatchOperation *self,
 }
 
 void
-_mcd_dispatch_operation_handle_with (McdDispatchOperation *operation,
-                                     const gchar *handler_name,
-                                     GError **error)
+_mcd_dispatch_operation_approve (McdDispatchOperation *self)
 {
-    McdDispatchOperationPrivate *priv;
-
-    g_return_if_fail (MCD_IS_DISPATCH_OPERATION (operation));
-    priv = operation->priv;
+    g_return_if_fail (MCD_IS_DISPATCH_OPERATION (self));
 
-    DEBUG ("%s/%p", priv->unique_name, operation);
+    DEBUG ("%s/%p", self->priv->unique_name, self);
 
-    if (!mcd_dispatch_operation_check_handle_with (operation, handler_name,
-                                                   error))
+    if (!mcd_dispatch_operation_check_handle_with (self, NULL, NULL))
     {
         return;
     }
 
-    if (handler_name != NULL && handler_name[0] != '\0')
-    {
-        priv->handler = g_strdup (handler_name + MCD_CLIENT_BASE_NAME_LEN);
-    }
-
-    _mcd_dispatch_operation_finish (operation);
+    _mcd_dispatch_operation_finish (self);
 }
 
 void
diff --git a/src/mcd-dispatcher.c b/src/mcd-dispatcher.c
index 58497d9..b6e5826 100644
--- a/src/mcd-dispatcher.c
+++ b/src/mcd-dispatcher.c
@@ -3658,8 +3658,7 @@ _mcd_dispatcher_add_channel_request (McdDispatcher *dispatcher,
                  * same channel has been requested, the approval operation must
                  * terminate */
                 if (G_LIKELY (context->operation))
-                    _mcd_dispatch_operation_handle_with (context->operation,
-                                                        NULL, NULL);
+                    _mcd_dispatch_operation_approve (context->operation);
             }
             else
                 context->skip_approval = TRUE;
-- 
1.5.6.5




More information about the telepathy-commits mailing list