[empathy: 50/65] Implement a timeout machinery for the auth client
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy: 50/65] Implement a timeout machinery for the auth client
- Date: Tue, 24 Aug 2010 13:30:40 +0000 (UTC)
commit 526dbcddf5a3969a8714b49441e4dd62927837f3
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Wed Aug 18 16:55:03 2010 +0200
Implement a timeout machinery for the auth client
Similar to the one used in empathy-av.c
src/empathy-auth-client.c | 64 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 63 insertions(+), 1 deletions(-)
---
diff --git a/src/empathy-auth-client.c b/src/empathy-auth-client.c
index 45812e8..7546164 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 ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]