[empathy/next] Approver high level API: now singular



commit 16ebeaa417f86927ca42637abf11fa2f5197f8a3
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Mon Jan 27 14:10:35 2014 +0100

    Approver high level API: now singular

 src/empathy-call-factory.c  |   43 +++++-------------------------------
 src/empathy-event-manager.c |   51 +++---------------------------------------
 2 files changed, 10 insertions(+), 84 deletions(-)
---
diff --git a/src/empathy-call-factory.c b/src/empathy-call-factory.c
index 08f2222..4e5d03d 100644
--- a/src/empathy-call-factory.c
+++ b/src/empathy-call-factory.c
@@ -40,10 +40,10 @@ static void handle_channel (TpBaseClient *client,
     gint64 user_action_time,
     TpHandleChannelContext *context);
 
-static void approve_channels (TpBaseClient *client,
+static void approve_channel (TpBaseClient *client,
     TpAccount *account,
     TpConnection *connection,
-    GList *channels,
+    TpChannel *channel,
     TpChannelDispatchOperation *dispatch_operation,
     TpAddDispatchOperationContext *context);
 
@@ -125,7 +125,7 @@ empathy_call_factory_class_init (EmpathyCallFactoryClass *klass)
   object_class->constructor = empathy_call_factory_constructor;
 
   base_clt_cls->handle_channel = handle_channel;
-  base_clt_cls->add_dispatch_operation = approve_channels;
+  base_clt_cls->add_dispatch_operation = approve_channel;
 
   signals[NEW_CALL_HANDLER] =
     g_signal_new ("new-call-handler",
@@ -204,52 +204,21 @@ handle_channel (TpBaseClient *client,
   tp_handle_channel_context_accept (context);
 }
 
-static TpCallChannel *
-find_call_channel (GList *channels)
-{
-  GList *l;
-
-  for (l = channels; l != NULL; l = g_list_next (l))
-    {
-      TpChannel *channel = l->data;
-      GQuark channel_type;
-
-      if (tp_proxy_get_invalidated (channel) != NULL)
-        continue;
-
-      channel_type = tp_channel_get_channel_type_id (channel);
-
-      if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_CALL1)
-        return TP_CALL_CHANNEL (channel);
-    }
-
-  return NULL;
-}
-
 static void
-approve_channels (TpBaseClient *client,
+approve_channel (TpBaseClient *client,
     TpAccount *account,
     TpConnection *connection,
-    GList *channels,
+    TpChannel *channel,
     TpChannelDispatchOperation *dispatch_operation,
     TpAddDispatchOperationContext *context)
 {
   EmpathyCallFactory *self = EMPATHY_CALL_FACTORY (client);
-  TpCallChannel *channel;
   guint handle;
   GError error = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT, "" };
   gboolean handled = FALSE;
 
-  channel = find_call_channel (channels);
-
-  if (channel == NULL)
-    {
-      DEBUG ("Failed to find the main channel; ignoring");
-      error.message = "Unknown channel";
-      goto out;
-    }
 
-  handle = tp_channel_get_handle (TP_CHANNEL (channel), NULL);
+  handle = tp_channel_get_handle (channel, NULL);
 
   if (handle == 0)
     {
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 57d2693..6de3c2a 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -749,36 +749,6 @@ event_manager_auth_process_func (EventPriv *event)
   empathy_event_approve ((EmpathyEvent *) event);
 }
 
-/* If there is a file-transfer, media, or auth channel consider it as
- * the main one. */
-static TpChannel *
-find_main_channel (GList *channels)
-{
-  GList *l;
-  TpChannel *text = NULL;
-
-  for (l = channels; l != NULL; l = g_list_next (l))
-    {
-      TpChannel *channel = l->data;
-      GQuark channel_type;
-
-      if (tp_proxy_get_invalidated (channel) != NULL)
-        continue;
-
-      channel_type = tp_channel_get_channel_type_id (channel);
-
-      if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_CALL1 ||
-          channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_FILE_TRANSFER1 ||
-          channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION1)
-        return channel;
-
-      else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_TEXT)
-        text = channel;
-    }
-
-  return text;
-}
-
 static void
 approve_text_channel (EmpathyEventManager *self,
     EventManagerApproval *approval,
@@ -961,32 +931,19 @@ approve_sasl_channel (EmpathyEventManager *self,
 }
 
 static void
-approve_channels (TpSimpleApprover *approver,
+approve_channel (TpSimpleApprover *approver,
     TpAccount *account,
     TpConnection *connection,
-    GList *channels,
+    TpChannel *channel,
     TpChannelDispatchOperation *dispatch_operation,
     TpAddDispatchOperationContext *context,
     gpointer user_data)
 {
   EmpathyEventManager *self = user_data;
   EmpathyEventManagerPriv *priv = GET_PRIV (self);
-  TpChannel *channel;
   EventManagerApproval *approval;
   GQuark channel_type;
 
-  channel = find_main_channel (channels);
-  if (channel == NULL)
-    {
-      GError error = { TP_ERROR, TP_ERROR_INVALID_ARGUMENT,
-          "Unknown channel type" };
-
-      DEBUG ("Failed to find the main channel; ignoring");
-
-      tp_add_dispatch_operation_context_fail (context, &error);
-      return;
-    }
-
   approval = event_manager_approval_new (self, dispatch_operation, channel);
   priv->approvals = g_slist_prepend (priv->approvals, approval);
 
@@ -1349,7 +1306,7 @@ empathy_event_manager_init (EmpathyEventManager *manager)
   am = tp_account_manager_dup ();
 
   priv->approver = tp_simple_approver_new_with_am (am, "Empathy.EventManager",
-      FALSE, approve_channels, manager, NULL);
+      FALSE, approve_channel, manager, NULL);
 
   /* Private text channels */
   tp_base_client_take_approver_filter (priv->approver,
@@ -1391,7 +1348,7 @@ empathy_event_manager_init (EmpathyEventManager *manager)
    * prepared with capabilities. I chose the former, obviously. :-) */
 
   priv->auth_approver = tp_simple_approver_new_with_am (am,
-      "Empathy.AuthEventManager", FALSE, approve_channels, manager,
+      "Empathy.AuthEventManager", FALSE, approve_channel, manager,
       NULL);
 
   /* SASL auth channels */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]