aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2010-08-18 22:55:03 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2010-08-19 01:18:59 +0800
commit526dbcddf5a3969a8714b49441e4dd62927837f3 (patch)
tree8c11f87fbd4a77f030ab6037867df3e469a76810
parent5286587e932047f9b32001429a395d8caf193b26 (diff)
downloadgsoc2013-empathy-526dbcddf5a3969a8714b49441e4dd62927837f3.tar
gsoc2013-empathy-526dbcddf5a3969a8714b49441e4dd62927837f3.tar.gz
gsoc2013-empathy-526dbcddf5a3969a8714b49441e4dd62927837f3.tar.bz2
gsoc2013-empathy-526dbcddf5a3969a8714b49441e4dd62927837f3.tar.lz
gsoc2013-empathy-526dbcddf5a3969a8714b49441e4dd62927837f3.tar.xz
gsoc2013-empathy-526dbcddf5a3969a8714b49441e4dd62927837f3.tar.zst
gsoc2013-empathy-526dbcddf5a3969a8714b49441e4dd62927837f3.zip
Implement a timeout machinery for the auth client
Similar to the one used in empathy-av.c
-rw-r--r--src/empathy-auth-client.c64
1 files changed, 63 insertions, 1 deletions
diff --git a/src/empathy-auth-client.c b/src/empathy-auth-client.c
index 45812e8e9..7546164d3 100644
--- a/src/empathy-auth-client.c
+++ b/src/empathy-auth-client.c
@@ -39,6 +39,47 @@
#include <extensions/extensions.h>
+#define TIMEOUT 60
+
+static gboolean use_timer = TRUE;
+static guint timeout_id = 0;
+static guint num_windows = 0;
+
+static gboolean
+timeout_cb (gpointer p)
+{
+ DEBUG ("Timeout reached; exiting...");
+
+ gtk_main_quit ();
+ return FALSE;
+}
+
+static void
+start_timer (void)
+{
+ if (!use_timer)
+ return;
+
+ if (timeout_id != 0)
+ return;
+
+ DEBUG ("Start timer");
+
+ timeout_id = g_timeout_add_seconds (TIMEOUT, timeout_cb, NULL);
+}
+
+static void
+stop_timer (void)
+{
+ if (timeout_id == 0)
+ return;
+
+ DEBUG ("Stop timer");
+
+ g_source_remove (timeout_id);
+ timeout_id = 0;
+}
+
static void
tls_dialog_response_cb (GtkDialog *dialog,
gint response_id,
@@ -69,6 +110,14 @@ tls_dialog_response_cb (GtkDialog *dialog,
empathy_tls_certificate_store_ca (certificate);
g_object_unref (certificate);
+
+ /* restart the timeout */
+ num_windows--;
+
+ if (num_windows > 0)
+ return;
+
+ start_timer ();
}
static void
@@ -78,6 +127,10 @@ display_interactive_dialog (EmpathyTLSCertificate *certificate,
{
GtkWidget *tls_dialog;
+ /* stop the timeout */
+ num_windows++;
+ stop_timer ();
+
tls_dialog = empathy_tls_dialog_new (certificate, reason, details);
g_signal_connect (tls_dialog, "response",
G_CALLBACK (tls_dialog_response_cb), NULL);
@@ -188,7 +241,16 @@ main (int argc,
return EXIT_FAILURE;
}
- DEBUG ("Empathy auth client started.");
+ DEBUG ("Empathy auth client started.");
+
+ if (g_getenv ("EMPATHY_PERSIST") != NULL)
+ {
+ DEBUG ("Timed-exit disabled");
+
+ use_timer = FALSE;
+ }
+
+ start_timer ();
gtk_main ();