[empathy] Do not should "password required" if X-TELEPATHY-PASSWORD is not supported



commit c7fe998d565bd37ed066e1fee0e7281c7f6117ce
Author: Xavier Claessens <xclaesse gmail com>
Date:   Sat Oct 1 13:08:11 2011 +0200

    Do not should "password required" if X-TELEPATHY-PASSWORD is not supported
    
    Messenger XMPP only supports auth via an access token, no password

 src/empathy-event-manager.c |   29 +++++++++++++++++++++++++----
 1 files changed, 25 insertions(+), 4 deletions(-)
---
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 79b1f60..da677d4 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -1128,10 +1128,31 @@ approve_channels (TpSimpleApprover *approver,
     }
   else if (channel_type == TP_IFACE_QUARK_CHANNEL_TYPE_SERVER_AUTHENTICATION)
     {
-      event_manager_add (approval->manager, account, NULL, EMPATHY_EVENT_TYPE_AUTH,
-          GTK_STOCK_DIALOG_AUTHENTICATION, tp_account_get_display_name (account),
-          _("Password required"), approval,
-          event_manager_auth_process_func, NULL);
+      GHashTable *props;
+      const gchar * const *available_mechanisms;
+
+      props = tp_channel_borrow_immutable_properties (channel);
+      available_mechanisms = tp_asv_get_boxed (props,
+          TP_PROP_CHANNEL_INTERFACE_SASL_AUTHENTICATION_AVAILABLE_MECHANISMS,
+          G_TYPE_STRV);
+
+      if (tp_strv_contains (available_mechanisms, "X-TELEPATHY-PASSWORD"))
+        {
+          event_manager_add (approval->manager, account, NULL,
+              EMPATHY_EVENT_TYPE_AUTH,
+              GTK_STOCK_DIALOG_AUTHENTICATION,
+              tp_account_get_display_name (account),
+              _("Password required"), approval,
+              event_manager_auth_process_func, NULL);
+        }
+      else
+        {
+          GError error = { TP_ERRORS, TP_ERROR_NOT_IMPLEMENTED,
+              "Support only X-TELEPATHY-PASSWORD auth method" };
+
+          tp_add_dispatch_operation_context_fail (context, &error);
+          return;
+        }
     }
   else
     {



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