aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcaillon <caillon@517b70f8-ed25-0410-8bf6-f5db08f7b76e>2005-10-31 07:05:30 +0000
committercaillon <caillon@517b70f8-ed25-0410-8bf6-f5db08f7b76e>2005-10-31 07:05:30 +0000
commitadae85b3eb15ed70aeaebe85a525750af3d2a926 (patch)
treec3722f40f03e7164141b9bdddd7d1e9274077187
parent9102d470bcc916ea2e2539881b58995c7b97a030 (diff)
2005-10-31 Christopher Aillon <caillon@redhat.com>
* src/krb5-auth-dialog.c: Update the credentials expiry time git-svn-id: http://svn.gnome.org/svn/krb5-auth-dialog/trunk@30 517b70f8-ed25-0410-8bf6-f5db08f7b76e
-rw-r--r--ChangeLog4
-rw-r--r--src/krb5-auth-dialog.c62
2 files changed, 54 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index b63f52e..e0b1f13 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2005-10-31 Christopher Aillon <caillon@redhat.com>
+ * src/krb5-auth-dialog.c: Update the credentials expiry time
+
+2005-10-31 Christopher Aillon <caillon@redhat.com>
+
* src/krb5-auth-dialog.c: No need to pass around our GladeXML
since its a static global
diff --git a/src/krb5-auth-dialog.c b/src/krb5-auth-dialog.c
index db432bc..90eb0e3 100644
--- a/src/krb5-auth-dialog.c
+++ b/src/krb5-auth-dialog.c
@@ -46,6 +46,31 @@ static gint creds_expiry;
static int renew_credentials ();
+static gboolean
+krb5_auth_dialog_wrong_label_update_expiry (gpointer data)
+{
+ GtkWidget *label = GTK_WIDGET(data);
+ int minutes_left;
+ gchar *expiry_text;
+ gchar *expiry_markup;
+
+ g_return_val_if_fail (label != NULL, FALSE);
+
+ minutes_left = (creds_expiry - time(0)) / 60;
+
+ if (minutes_left > 0)
+ expiry_text = g_strdup_printf (_("Your credentials expire in %d minutes"), minutes_left);
+ else
+ expiry_text = g_strdup (_("Your credentials have expired"));
+
+ expiry_markup = g_strdup_printf ("<span size=\"smaller\" style=\"italic\">%s</span>", expiry_text);
+ gtk_label_set_markup (GTK_LABEL (label), expiry_markup);
+ g_free (expiry_text);
+ g_free (expiry_markup);
+
+ return TRUE;
+}
+
static void
krb5_auth_dialog_setup (GtkWidget *dialog,
const gchar *krb5prompt)
@@ -87,20 +112,25 @@ krb5_auth_dialog_setup (GtkWidget *dialog,
gtk_label_set_text (GTK_LABEL (label), prompt);
/* Add our extra message hints, if any */
- if (invalid_password)
- wrong_text = g_strdup (_("The password you entered is invalid"));
- else
+ wrong_label = glade_xml_get_widget (xml, "krb5_wrong_label");
+
+ if (wrong_label)
{
- int minutes_left = (creds_expiry - time(0)) / 60;
- if (minutes_left > 0)
- wrong_text = g_strdup_printf (_("Your credentials expire in %d minutes"), minutes_left);
+ if (invalid_password)
+ wrong_text = g_strdup (_("The password you entered is invalid"));
else
- wrong_text = g_strdup (_("Your credentials have expired"));
+ {
+ int minutes_left = (creds_expiry - time(0)) / 60;
+ if (minutes_left > 0)
+ {
+ wrong_text = g_strdup_printf (_("Your credentials expire in %d minutes"), minutes_left);
+ }
+ else
+ wrong_text = g_strdup (_("Your credentials have expired"));
+ }
}
- wrong_label = glade_xml_get_widget (xml, "krb5_wrong_label");
-
- if (wrong_label && wrong_text != NULL)
+ if (wrong_text)
{
wrong_markup = g_strdup_printf ("<span size=\"smaller\" style=\"italic\">%s</span>", wrong_text);
gtk_label_set_markup (GTK_LABEL (wrong_label), wrong_markup);
@@ -122,6 +152,7 @@ krb5_gtk_prompter (krb5_context ctx,
krb5_prompt prompts[])
{
GtkWidget *dialog;
+ GtkWidget *wrong_label;
krb5_error_code errcode;
int i;
@@ -134,6 +165,7 @@ krb5_gtk_prompter (krb5_context ctx,
const gchar *password = NULL;
int password_len = 0;
int response;
+ guint32 source_id = 0;
GtkWidget *entry;
@@ -142,6 +174,10 @@ krb5_gtk_prompter (krb5_context ctx,
entry = glade_xml_get_widget(xml, "krb5_entry");
krb5_auth_dialog_setup (dialog, (gchar *) prompts[i].prompt);
+ wrong_label = glade_xml_get_widget (xml, "krb5_wrong_label");
+ source_id = g_timeout_add (5000, (GSourceFunc)krb5_auth_dialog_wrong_label_update_expiry,
+ wrong_label);
+
response = gtk_dialog_run (GTK_DIALOG (dialog));
switch (response)
{
@@ -157,6 +193,8 @@ krb5_gtk_prompter (krb5_context ctx,
g_assert_not_reached ();
}
+ g_source_remove (source_id);
+
prompts[i].reply->data = (char *) password;
prompts[i].reply->length = password_len;
}
@@ -404,8 +442,8 @@ main (int argc, char *argv[])
xml = glade_xml_new (GLADEDIR "krb5-auth-dialog.glade", NULL, NULL);
dialog = glade_xml_get_widget (xml, "krb5_dialog");
- g_timeout_add (CREDENTIAL_CHECK_INTERVAL, (GSourceFunc)credentials_expiring, NULL);
- credentials_expiring (NULL);
+ if (credentials_expiring (NULL))
+ g_timeout_add (CREDENTIAL_CHECK_INTERVAL, (GSourceFunc)credentials_expiring, NULL);
gtk_main ();
}