* Authors: Cosimo Cecchi <cosimo.cecchi@collabora.co.uk>
*/
-#include <config.h>
+#include "config.h"
-#include <stdlib.h>
-#include <glib.h>
#include <glib/gi18n.h>
-#include <gtk/gtk.h>
+#include <gnutls/gnutls.h>
-#include <telepathy-glib/debug-sender.h>
+#include "empathy-auth-factory.h"
+#include "empathy-bad-password-dialog.h"
+#include "empathy-password-dialog.h"
+#include "empathy-sanity-cleaning.h"
+#include "empathy-server-tls-handler.h"
+#include "empathy-tls-dialog.h"
+#include "empathy-tls-verifier.h"
+#include "empathy-ui-utils.h"
#define DEBUG_FLAG EMPATHY_DEBUG_TLS
-#include <libempathy/empathy-debug.h>
-#include <libempathy/empathy-auth-factory.h>
-#include <libempathy/empathy-server-sasl-handler.h>
-#include <libempathy/empathy-server-tls-handler.h>
-#include <libempathy/empathy-tls-verifier.h>
-#include <libempathy/empathy-utils.h>
-
-#include <libempathy-gtk/empathy-password-dialog.h>
-#include <libempathy-gtk/empathy-tls-dialog.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
-
-#include <gnutls/gnutls.h>
-
-#include <extensions/extensions.h>
+#include "empathy-debug.h"
#define TIMEOUT 60
gint response_id,
gpointer user_data)
{
- EmpathyTLSCertificate *certificate = NULL;
- EmpTLSCertificateRejectReason reason = 0;
+ TpTLSCertificate *certificate = NULL;
+ TpTLSCertificateRejectReason reason = 0;
GHashTable *details = NULL;
EmpathyTLSDialog *tls_dialog = EMPATHY_TLS_DIALOG (dialog);
gboolean remember = FALSE;
EmpathyTLSVerifier *verifier = EMPATHY_TLS_VERIFIER (user_data);
- DEBUG ("Response %d", response_id);
-
g_object_get (tls_dialog,
"certificate", &certificate,
"reason", &reason,
"details", &details,
NULL);
+ DEBUG ("Response %d (remember: %d)", response_id, remember);
+
gtk_widget_destroy (GTK_WIDGET (dialog));
if (response_id == GTK_RESPONSE_YES)
{
- empathy_tls_certificate_accept_async (certificate, NULL, NULL);
+ tp_tls_certificate_accept_async (certificate, NULL, NULL);
}
else
{
tp_asv_set_boolean (details, "user-requested", TRUE);
- empathy_tls_certificate_reject_async (certificate, reason, details,
- NULL, NULL);
+ tp_tls_certificate_add_rejection (certificate, reason, NULL,
+ g_variant_new_parsed ("{ 'user-requested': <%b> }", TRUE));
+
+ tp_tls_certificate_reject_async (certificate, NULL, NULL);
}
if (remember)
}
static void
-display_interactive_dialog (EmpathyTLSCertificate *certificate,
+display_interactive_dialog (TpTLSCertificate *certificate,
EmpathyTLSVerifier *verifier,
- EmpTLSCertificateRejectReason reason,
+ TpTLSCertificateRejectReason reason,
GHashTable *details)
{
GtkWidget *tls_dialog;
GAsyncResult *result,
gpointer user_data)
{
- EmpTLSCertificateRejectReason reason;
+ TpTLSCertificateRejectReason reason;
GError *error = NULL;
- EmpathyTLSCertificate *certificate = NULL;
+ TpTLSCertificate *certificate = NULL;
GHashTable *details = NULL;
gchar *hostname = NULL;
}
else
{
- empathy_tls_certificate_accept_async (certificate, NULL, NULL);
+ tp_tls_certificate_accept_async (certificate, NULL, NULL);
}
g_free (hostname);
EmpathyServerTLSHandler *handler,
gpointer user_data)
{
- EmpathyTLSCertificate *certificate = NULL;
+ TpTLSCertificate *certificate = NULL;
gchar *hostname = NULL;
gchar **reference_identities = NULL;
EmpathyTLSVerifier *verifier;
/* If the handler has the password it will deal with it itself. */
if (!empathy_server_sasl_handler_has_password (handler))
{
+ DEBUG ("SASL handler doesn't have a password, prompt for one");
+
dialog = empathy_password_dialog_new (handler);
gtk_widget_show (dialog);
}
}
+static void
+retry_account_cb (GtkWidget *dialog,
+ TpAccount *account,
+ const gchar *password,
+ EmpathyAuthFactory *factory)
+{
+ DEBUG ("Try reconnecting to %s", tp_account_get_path_suffix (account));
+
+ empathy_auth_factory_save_retry_password (factory, account, password);
+
+ tp_account_reconnect_async (account, NULL, NULL);
+}
+
+static void
+auth_factory_auth_passsword_failed (EmpathyAuthFactory *factory,
+ TpAccount *account,
+ const gchar *password,
+ gpointer user_data)
+{
+ GtkWidget *dialog;
+
+ DEBUG ("Authentication on %s failed, popup password dialog",
+ tp_account_get_path_suffix (account));
+
+ dialog = empathy_bad_password_dialog_new (account, password);
+
+ tp_g_signal_connect_object (dialog, "retry",
+ G_CALLBACK (retry_account_cb), factory, 0);
+
+ gtk_widget_show (dialog);
+}
+
+static void
+sanity_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ start_timer ();
+}
+
int
main (int argc,
char **argv)
GError *error = NULL;
EmpathyAuthFactory *factory;
TpDebugSender *debug_sender;
-
- g_thread_init (NULL);
+ TpSimpleClientFactory *tp_factory;
+ TpDBusDaemon *dbus;
context = g_option_context_new (N_(" - Empathy authentication client"));
g_option_context_add_group (context, gtk_get_option_group (TRUE));
gtk_window_set_default_icon_name ("empathy");
textdomain (GETTEXT_PACKAGE);
+ /* There is no 'main' UI window so just use the default GdkScreen */
+ empathy_set_css_provider (NULL);
+
#ifdef ENABLE_DEBUG
/* Set up debug sender */
debug_sender = tp_debug_sender_dup ();
g_log_set_default_handler (tp_debug_sender_log_handler, G_LOG_DOMAIN);
#endif
- factory = empathy_auth_factory_dup_singleton ();
+ dbus = tp_dbus_daemon_dup (NULL);
+ tp_factory = tp_simple_client_factory_new (dbus);
+ tp_simple_client_factory_add_account_features_varargs (tp_factory,
+ TP_ACCOUNT_FEATURE_STORAGE,
+ 0);
+
+ factory = empathy_auth_factory_new (tp_factory);
+ g_object_unref (tp_factory);
+ g_object_unref (dbus);
g_signal_connect (factory, "new-server-tls-handler",
G_CALLBACK (auth_factory_new_tls_handler_cb), NULL);
g_signal_connect (factory, "new-server-sasl-handler",
G_CALLBACK (auth_factory_new_sasl_handler_cb), NULL);
+ g_signal_connect (factory, "auth-password-failed",
+ G_CALLBACK (auth_factory_auth_passsword_failed), NULL);
+
if (!empathy_auth_factory_register (factory, &error))
{
g_critical ("Failed to register the auth factory: %s\n", error->message);
use_timer = FALSE;
}
- start_timer ();
+ /* Wait for the migration code to be done before starting the timer */
+ empathy_sanity_checking_run_async (sanity_cb, NULL);
gtk_main ();