From 368a776689311fce995865c52399cf72551d14ec Mon Sep 17 00:00:00 2001 From: Sushma Rai Date: Thu, 12 Jan 2006 09:31:05 +0000 Subject: Cheking for password expired error code, displaying the error message and allowing the user to reset password. Also showing password expiry warning message in advance. Fixes #326060. Also, Checking for the quota related error codes and displaying the corresponding error/warning messages to the user. Fixes #326087. svn path=/trunk/; revision=31143 --- plugins/exchange-operations/ChangeLog | 20 ++++ plugins/exchange-operations/Makefile.am | 3 +- .../exchange-operations/exchange-config-listener.c | 133 ++++++++++++++++++++- .../exchange-passwd-expiry.glade | 91 ++++++++++++++ .../org-gnome-exchange-operations.error.xml | 6 +- 5 files changed, 244 insertions(+), 9 deletions(-) create mode 100644 plugins/exchange-operations/exchange-passwd-expiry.glade (limited to 'plugins') diff --git a/plugins/exchange-operations/ChangeLog b/plugins/exchange-operations/ChangeLog index 74d38601a1..d4bcc4af29 100644 --- a/plugins/exchange-operations/ChangeLog +++ b/plugins/exchange-operations/ChangeLog @@ -1,3 +1,23 @@ +2006-01-12 Sushma Rai + + * exchange-config-listener.c (exchange_config_listener_authenticate): + Checking for the password expired error code during connect and if the + password is expired, showing the error message, prompting for resetting + the password and trying to connect again with the new password. + Checking if the password will expire in next a few days, which is + specified by the user during account creation, and if yes, showing + the corresponding error message to the user, which allows him to change + his password. + Fixes #326060. + Also, Checking for the quota related error codes and displaying the + corresponding error/warning messages to the user. Fixes #326087. + + * org-gnome-exchange-operations.error.xml: Added a space. + + * exchange-passwd-expiry.glade: Added new. + + * Makefile.am: Added exchange-passwd-expiry.glade. + 2006-01-11 Srinivasa Ragavan ** Fixes bug #316100 diff --git a/plugins/exchange-operations/Makefile.am b/plugins/exchange-operations/Makefile.am index 0696a6735b..3efa32d475 100644 --- a/plugins/exchange-operations/Makefile.am +++ b/plugins/exchange-operations/Makefile.am @@ -58,7 +58,8 @@ glade_DATA = \ exchange-delegates.glade \ exchange-folder-tree.glade \ exchange-permissions-dialog.glade \ - e-foreign-folder-dialog.glade + e-foreign-folder-dialog.glade \ + exchange-passwd-expiry.glade error_DATA = org-gnome-exchange-operations.error errordir = $(privdatadir)/errors diff --git a/plugins/exchange-operations/exchange-config-listener.c b/plugins/exchange-operations/exchange-config-listener.c index d83458ef24..20a9d33c11 100644 --- a/plugins/exchange-operations/exchange-config-listener.c +++ b/plugins/exchange-operations/exchange-config-listener.c @@ -28,8 +28,8 @@ #include "exchange-config-listener.h" #include "exchange-operations.h" +#include "exchange-change-password.h" -#include #include #include #include @@ -43,10 +43,14 @@ #include #include #include +#include #include #include +#define FILENAME CONNECTOR_GLADEDIR "/exchange-passwd-expiry.glade" +#define ROOTNODE "passwd_exp_dialog" + struct _ExchangeConfigListenerPrivate { GConfClient *gconf; guint idle_id; @@ -582,19 +586,87 @@ remove_account_esources (ExchangeAccount *account) remove_account_esource (account, EXCHANGE_CONTACTS_FOLDER); } +#ifdef HAVE_KRB5 +static char * +get_new_exchange_password (ExchangeAccount *account) +{ + char *old_password, *new_password; + + old_password = exchange_account_get_password (account); + new_password = exchange_get_new_password (old_password, 0); + + if (new_password) { + exchange_account_set_password (account, + old_password, + new_password); + g_free (old_password); + return new_password; + } + g_free (old_password); + return NULL; +} +#endif + +#ifdef HAVE_KRB5 +static void +change_passwd_cb (GtkWidget *button, ExchangeAccount *account) +{ + char *current_passwd, *new_passwd; + + gtk_widget_hide (gtk_widget_get_toplevel(button)); + current_passwd = exchange_account_get_password (account); + new_passwd = exchange_get_new_password (current_passwd, TRUE); + exchange_account_set_password (account, current_passwd, new_passwd); + g_free (current_passwd); + g_free (new_passwd); +} +#endif + +static void +display_passwd_expiry_message (int max_passwd_age, ExchangeAccount *account) +{ + GladeXML *xml; + GtkWidget *top_widget, *change_passwd_button; + GtkResponseType response; + GtkLabel *warning_msg_label; + char *passwd_expiry_msg = + g_strdup_printf (_("Your password will expire in next %d days"), max_passwd_age); + + xml = glade_xml_new (FILENAME, ROOTNODE, NULL); + g_return_if_fail (xml != NULL); + top_widget = glade_xml_get_widget (xml, ROOTNODE); + g_return_if_fail (top_widget != NULL); + + warning_msg_label = GTK_LABEL (glade_xml_get_widget (xml, + "passwd_exp_label")); + gtk_label_set_text (warning_msg_label, passwd_expiry_msg); + change_passwd_button = glade_xml_get_widget (xml, + "change_passwd_button"); + gtk_widget_set_sensitive (change_passwd_button, TRUE); + g_signal_connect (change_passwd_button, + "clicked", + G_CALLBACK (change_passwd_cb), + account); + response = gtk_dialog_run (GTK_DIALOG (top_widget)); + + gtk_widget_destroy (top_widget); + g_object_unref (xml); + g_free (passwd_expiry_msg); +} + ExchangeAccountResult exchange_config_listener_authenticate (ExchangeConfigListener *ex_conf_listener, ExchangeAccount *account) { ExchangeConfigListenerPrivate *priv; ExchangeAccountResult result; - char *key, *password, *title; + char *key, *password, *title, *new_password; gboolean oldremember, remember = FALSE; CamelURL *camel_url; const char *remember_password; g_return_val_if_fail (EXCHANGE_IS_CONFIG_LISTENER (ex_conf_listener), EXCHANGE_ACCOUNT_CONFIG_ERROR); priv = ex_conf_listener->priv; - + camel_url = camel_url_new (priv->configured_uri, NULL); key = camel_url_to_string (camel_url, CAMEL_URL_HIDE_PASSWORD | CAMEL_URL_HIDE_PARAMS); remember_password = camel_url_get_param (camel_url, "save-passwd"); @@ -610,7 +682,7 @@ exchange_config_listener_authenticate (ExchangeConfigListener *ex_conf_listener, } g_free (title); } - else if (remember_password && !g_strcasecmp (remember_password, "fasle")) { + else if (remember_password && !g_strcasecmp (remember_password, "false")) { /* get_password returns the password cached but user has not * selected remember password option, forget this password * whis is stored temporarily by e2k_validate_user(), to avoid @@ -619,6 +691,57 @@ exchange_config_listener_authenticate (ExchangeConfigListener *ex_conf_listener, e_passwords_forget_password ("Exchange", key); } exchange_account_connect (account, password, &result); + g_free (password); + if (result == EXCHANGE_ACCOUNT_PASSWORD_EXPIRED) { + new_password = get_new_exchange_password (account); + if (new_password) { + /* try connecting with new password */ + exchange_account_connect (account, new_password, &result); + g_free (new_password); + } + } + else if (result == EXCHANGE_ACCOUNT_QUOTA_RECIEVE_ERROR || + result == EXCHANGE_ACCOUNT_QUOTA_SEND_ERROR || + result == EXCHANGE_ACCOUNT_QUOTA_WARN) { + gchar *current_quota_usage; + + switch (result) { + case EXCHANGE_ACCOUNT_QUOTA_RECIEVE_ERROR: + current_quota_usage = g_strdup_printf ("%.2f", + account->mbox_size); + e_error_run (NULL, "org-gnome-exchange-operations:account-quota-error", current_quota_usage); + g_free (current_quota_usage); + break; + case EXCHANGE_ACCOUNT_QUOTA_SEND_ERROR: + current_quota_usage = g_strdup_printf ("%.2f", + account->mbox_size); + e_error_run (NULL, "org-gnome-exchange-operations:account-quota-send-error", current_quota_usage); + g_free (current_quota_usage); + break; + case EXCHANGE_ACCOUNT_QUOTA_WARN: + current_quota_usage = g_strdup_printf ("%.2f", + account->mbox_size); + e_error_run (NULL, "org-gnome-exchange-operations:account-quota-warn", current_quota_usage); + g_free (current_quota_usage); + break; + default: + break; + } + /* reset result, so that we check if the password + * expiry warning period + */ + result = EXCHANGE_ACCOUNT_CONNECT_SUCCESS; + + } + if (result == EXCHANGE_ACCOUNT_CONNECT_SUCCESS) { + int max_pwd_age_days; + + /* check for password expiry warning */ + max_pwd_age_days = exchange_account_check_password_expiry (account); + if (max_pwd_age_days >= 0) { + display_passwd_expiry_message (max_pwd_age_days, account); + } + } g_free (key); camel_url_free (camel_url); return result; @@ -675,7 +798,7 @@ account_added (EAccountList *account_list, EAccount *account) remove_selected_non_offline_esources (exchange_account, CONF_KEY_TASKS); return; } - + exchange_account_set_online (exchange_account); exchange_config_listener_authenticate (config_listener, exchange_account); exchange_account_set_online (exchange_account); } diff --git a/plugins/exchange-operations/exchange-passwd-expiry.glade b/plugins/exchange-operations/exchange-passwd-expiry.glade new file mode 100644 index 0000000000..6ea4005c33 --- /dev/null +++ b/plugins/exchange-operations/exchange-passwd-expiry.glade @@ -0,0 +1,91 @@ + + + + + + + + True + Password Expiry Warning... + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + True + True + _Change Password + True + GTK_RELIEF_NORMAL + 0 + + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + ok_button + + + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + Your password will expire in 7 days... + False + False + GTK_JUSTIFY_CENTER + False + False + 0.5 + 0.5 + 0 + 20 + + + 0 + False + False + + + + + + + diff --git a/plugins/exchange-operations/org-gnome-exchange-operations.error.xml b/plugins/exchange-operations/org-gnome-exchange-operations.error.xml index 1edd1dd8f5..3e22e3ccbb 100644 --- a/plugins/exchange-operations/org-gnome-exchange-operations.error.xml +++ b/plugins/exchange-operations/org-gnome-exchange-operations.error.xml @@ -102,17 +102,17 @@ supports Microsoft Exchange 2000 and 2003 only. <_primary>You have exceeded your quota for storing mails on this server. - <_secondary>Your current usage is: {0}KB. You will not be able to either send or recieve mails now. + <_secondary>Your current usage is: {0} KB. You will not be able to either send or recieve mails now. <_primary>You are nearing your quota available for storing mails on this server. - <_secondary>Your current usage is: {0}KB. You will not be able to send mails till you clear up some space by deleting some mails. + <_secondary>Your current usage is: {0} KB. You will not be able to send mails till you clear up some space by deleting some mails. <_primary>You are nearing your quota available for storing mails on this server. - <_secondary>Your current usage is: {0}KB. Try to clear up some space by deleting some mails. + <_secondary>Your current usage is: {0} KB. Try to clear up some space by deleting some mails. -- cgit v1.2.3