aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorguidog <guidog@517b70f8-ed25-0410-8bf6-f5db08f7b76e>2009-01-10 13:25:30 +0000
committerguidog <guidog@517b70f8-ed25-0410-8bf6-f5db08f7b76e>2009-01-10 13:25:30 +0000
commitc6d317a94d1857eb17617d4f85874f5139c8c8bf (patch)
tree300e5a874c932c7026f8df084a4cc0aa095a589d /src
parentaf9d2e62e392533987d17ada803bb6327c54afee (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/krb5-auth-applet.c21
-rw-r--r--src/krb5-auth-dialog.c2
2 files changed, 16 insertions, 7 deletions
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 {