aboutsummaryrefslogtreecommitdiffstats
path: root/src/empathy-auth-client.c
diff options
context:
space:
mode:
authorJonny Lamb <jonnylamb@gnome.org>2010-12-01 22:48:13 +0800
committerJonny Lamb <jonnylamb@gnome.org>2010-12-01 22:48:13 +0800
commit1994d674ad7b35e8b4a5db7f431c31414d1230f3 (patch)
tree69ba13b57dff87e088719dadd5754645237795cd /src/empathy-auth-client.c
parent81d9ab0e356681fb49c43c7bd7bf75bdf84122bc (diff)
downloadgsoc2013-empathy-1994d674ad7b35e8b4a5db7f431c31414d1230f3.tar
gsoc2013-empathy-1994d674ad7b35e8b4a5db7f431c31414d1230f3.tar.gz
gsoc2013-empathy-1994d674ad7b35e8b4a5db7f431c31414d1230f3.tar.bz2
gsoc2013-empathy-1994d674ad7b35e8b4a5db7f431c31414d1230f3.tar.lz
gsoc2013-empathy-1994d674ad7b35e8b4a5db7f431c31414d1230f3.tar.xz
gsoc2013-empathy-1994d674ad7b35e8b4a5db7f431c31414d1230f3.tar.zst
gsoc2013-empathy-1994d674ad7b35e8b4a5db7f431c31414d1230f3.zip
auth-client: listen for new sasl handlers and pop up a password dialog
Signed-off-by: Jonny Lamb <jonnylamb@gnome.org>
Diffstat (limited to 'src/empathy-auth-client.c')
-rw-r--r--src/empathy-auth-client.c71
1 files changed, 69 insertions, 2 deletions
diff --git a/src/empathy-auth-client.c b/src/empathy-auth-client.c
index 17b66a57d..864253bbf 100644
--- a/src/empathy-auth-client.c
+++ b/src/empathy-auth-client.c
@@ -29,6 +29,7 @@
#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>
@@ -180,7 +181,7 @@ verifier_verify_cb (GObject *source,
}
static void
-auth_factory_new_handler_cb (EmpathyAuthFactory *factory,
+auth_factory_new_tls_handler_cb (EmpathyAuthFactory *factory,
EmpathyServerTLSHandler *handler,
gpointer user_data)
{
@@ -204,6 +205,69 @@ auth_factory_new_handler_cb (EmpathyAuthFactory *factory,
g_free (hostname);
}
+typedef struct
+{
+ EmpathyServerSASLHandler *handler;
+ GtkWidget *entry;
+} PasswordDialogData;
+
+static void
+password_dialog_response_cb (GtkDialog *dialog,
+ gint response,
+ gpointer user_data)
+{
+ PasswordDialogData *data = user_data;
+
+ if (response == GTK_RESPONSE_ACCEPT)
+ {
+ empathy_server_sasl_handler_provide_password (data->handler,
+ gtk_entry_get_text (GTK_ENTRY (data->entry)));
+ }
+ else
+ {
+ empathy_server_sasl_handler_cancel (data->handler);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+
+ g_object_unref (data->handler);
+ g_slice_free (PasswordDialogData, data);
+}
+
+static void
+auth_factory_new_sasl_handler_cb (EmpathyAuthFactory *factory,
+ EmpathyServerSASLHandler *handler,
+ gpointer user_data)
+{
+ GtkWidget *dialog, *entry;
+ PasswordDialogData *data;
+
+ DEBUG ("New SASL server handler received from the factory");
+
+ dialog = gtk_dialog_new_with_buttons (_("Enter password"), NULL,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+ NULL);
+
+ entry = gtk_entry_new ();
+ gtk_entry_set_visibility (GTK_ENTRY (entry), FALSE);
+
+ gtk_box_pack_start (GTK_BOX (
+ gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
+ entry, FALSE, FALSE, 10);
+ gtk_widget_show (entry);
+
+ data = g_slice_new0 (PasswordDialogData);
+ data->handler = g_object_ref (handler);
+ data->entry = entry;
+
+ g_signal_connect (dialog, "response",
+ G_CALLBACK (password_dialog_response_cb), data);
+
+ gtk_widget_show (dialog);
+}
+
int
main (int argc,
char **argv)
@@ -238,7 +302,10 @@ main (int argc,
factory = empathy_auth_factory_dup_singleton ();
g_signal_connect (factory, "new-server-tls-handler",
- G_CALLBACK (auth_factory_new_handler_cb), NULL);
+ 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);
if (!empathy_auth_factory_register (factory, &error))
{