From c6d317a94d1857eb17617d4f85874f5139c8c8bf Mon Sep 17 00:00:00 2001 From: guidog Date: Sat, 10 Jan 2009 13:25:30 +0000 Subject: don't popup the dialog if we have a tray icon The user can happily refresh the credentials by left clicking on the tray icon. When using libnotify we also remind him to do so every NOTIFY_SECONDS (300). git-svn-id: http://svn.gnome.org/svn/krb5-auth-dialog/trunk@104 517b70f8-ed25-0410-8bf6-f5db08f7b76e --- src/krb5-auth-applet.c | 21 +++++++++++++++------ src/krb5-auth-dialog.c | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/krb5-auth-applet.c b/src/krb5-auth-applet.c index 5dc9145..4a11d09 100644 --- a/src/krb5-auth-applet.c +++ b/src/krb5-auth-applet.c @@ -28,23 +28,26 @@ #include "krb5-auth-notify.h" #endif +#define NOTIFY_SECONDS 300 /* update the tray icon's tooltip and icon */ int ka_update_status(Krb5AuthApplet* applet, krb5_timestamp expiry) { gchar* expiry_text; - int interval = expiry - time (0); + int now = time(0); + int remaining = expiry - now; + static int last_warn = 0; static gboolean expiry_notified = FALSE; - if (interval > 0) { + if (remaining > 0) { int hours, minutes; - if (interval >= 3600) { - hours = interval / 3600; - minutes = (interval % 3600) / 60; + if (remaining >= 3600) { + hours = remaining / 3600; + minutes = (remaining % 3600) / 60; expiry_text = g_strdup_printf (_("Your credentials expire in %.2d:%.2dh"), hours, minutes); } else { - minutes = interval / 60; + minutes = remaining / 60; expiry_text = g_strdup_printf (ngettext( "Your credentials expire in %d minute", "Your credentials expire in %d minutes", @@ -57,6 +60,11 @@ ka_update_status(Krb5AuthApplet* applet, krb5_timestamp expiry) _("Network credentials valid"), _("Your Kerberos credentials have been refreshed."), NULL); expiry_notified = FALSE; + } else if (remaining < applet->pw_prompt_secs && (now - last_warn) > NOTIFY_SECONDS) { + ka_send_event_notification (applet, NOTIFY_URGENCY_NORMAL, + _("Network credentials expiring"), + expiry_text, NULL); + last_warn = now; } #endif } else { @@ -68,6 +76,7 @@ ka_update_status(Krb5AuthApplet* applet, krb5_timestamp expiry) _("Network credentials expired"), _("Your Kerberos credentails have expired."), NULL); expiry_notified = TRUE; + last_warn = 0; } #endif } diff --git a/src/krb5-auth-dialog.c b/src/krb5-auth-dialog.c index 1974465..1875598 100644 --- a/src/krb5-auth-dialog.c +++ b/src/krb5-auth-dialog.c @@ -404,7 +404,7 @@ credentials_expiring (gpointer *data) Krb5AuthApplet* applet = (Krb5AuthApplet*) data; KA_DEBUG("Checking expiry: %d", applet->pw_prompt_secs); - if (credentials_expiring_real (applet, &renewable) && is_online) { + if (credentials_expiring_real (applet, &renewable) && is_online && !applet->show_trayicon) { give_up = canceled && (creds_expiry == canceled_creds_expiry); if (!give_up) { do { -- cgit v1.2.3