Hi, This patch fixes password expiry, and implements quota usage and password expiry warning during login. This feature was available in 2.2.x and was not handled in 2.4.x. This changes the quota warning strings, and adds password expiry warning string and password expiry warning dialog. This fixes #326060 and #326087 Please review. Thanks, Sushma.
Attachment:
exchange-passwd-expiry.glade
Description: application/glade
Index: evolution/plugins/exchange-operations/exchange-config-listener.c =================================================================== RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-config-listener.c,v retrieving revision 1.17 diff -u -p -r1.17 exchange-config-listener.c --- evolution/plugins/exchange-operations/exchange-config-listener.c 5 Jan 2006 13:01:57 -0000 1.17 +++ evolution/plugins/exchange-operations/exchange-config-listener.c 9 Jan 2006 13:39:35 -0000 @@ -28,8 +28,8 @@ #include "exchange-config-listener.h" #include "exchange-operations.h" +#include "exchange-change-password.h" -#include <exchange-account.h> #include <exchange-constants.h> #include <exchange-hierarchy.h> #include <e-folder-exchange.h> @@ -43,10 +43,18 @@ #include <libedataserver/e-source-list.h> #include <libedataserver/e-source-group.h> #include <libedataserverui/e-passwords.h> +#include <glade/glade-xml.h> #include <stdlib.h> #include <string.h> +#define ADS_UF_DONT_EXPIRE_PASSWORD 0x10000 +#define ONE_HUNDRED_NANOSECOND 0.000000100 +#define SECONDS_IN_DAY 86400 +#define PASSWD_EXPIRY_NOTIFICATION_PERIOD 7 +#define FILENAME CONNECTOR_GLADEDIR "/exchange-passwd-expiry.glade" +#define ROOTNODE "passwd_exp_dialog" + struct _ExchangeConfigListenerPrivate { GConfClient *gconf; guint idle_id; @@ -582,12 +590,80 @@ remove_account_esources (ExchangeAccount 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; @@ -619,6 +695,57 @@ exchange_config_listener_authenticate (E 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 +802,7 @@ account_added (EAccountList *account_lis 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); } Index: evolution/plugins/exchange-operations/org-gnome-exchange-operations.error.xml =================================================================== RCS file: /cvs/gnome/evolution/plugins/exchange-operations/org-gnome-exchange-operations.error.xml,v retrieving revision 1.6 diff -u -p -r1.6 org-gnome-exchange-operations.error.xml --- evolution/plugins/exchange-operations/org-gnome-exchange-operations.error.xml 1 Jan 2006 13:56:31 -0000 1.6 +++ evolution/plugins/exchange-operations/org-gnome-exchange-operations.error.xml 9 Jan 2006 13:40:49 -0000 @@ -102,17 +102,17 @@ supports Microsoft Exchange 2000 and 200 <error id="account-quota-error" type="error"> <_primary>You have exceeded your quota for storing mails on this server.</_primary> - <_secondary>Your current usage is: {0}KB. You will not be able to either send or recieve mails now.</_secondary> + <_secondary>Your current usage is: {0} KB. You will not be able to either send or recieve mails now.</_secondary> </error> <error id="account-quota-send-error" type="warning"> <_primary>You are nearing your quota available for storing mails on this server.</_primary> - <_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> + <_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> </error> <error id="account-quota-warn" type="warning"> <_primary>You are nearing your quota available for storing mails on this server.</_primary> - <_secondary>Your current usage is: {0}KB. Try to clear up some space by deleting some mails.</_secondary> + <_secondary>Your current usage is: {0} KB. Try to clear up some space by deleting some mails.</_secondary> </error> <error id="connect-exchange-error" type="error"> Index: evolution/plugins/exchange-operations/Makefile.am =================================================================== RCS file: /cvs/gnome/evolution/plugins/exchange-operations/Makefile.am,v retrieving revision 1.16 diff -u -p -r1.16 Makefile.am --- evolution/plugins/exchange-operations/Makefile.am 25 Dec 2005 04:14:50 -0000 1.16 +++ evolution/plugins/exchange-operations/Makefile.am 9 Jan 2006 13:41:51 -0000 @@ -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 Index: evolution-data-server/servers/exchange/lib/e2k-autoconfig.c =================================================================== RCS file: /cvs/gnome/evolution-data-server/servers/exchange/lib/e2k-autoconfig.c,v retrieving revision 1.10 diff -u -p -r1.10 e2k-autoconfig.c --- evolution-data-server/servers/exchange/lib/e2k-autoconfig.c 19 Dec 2005 13:27:49 -0000 1.10 +++ evolution-data-server/servers/exchange/lib/e2k-autoconfig.c 9 Jan 2006 13:44:21 -0000 @@ -1663,5 +1663,6 @@ e2k_validate_user (const char *owa_url, } g_free (key); + g_free (password); return valid; } Index: evolution-data-server/servers/exchange/storage/exchange-account.c =================================================================== RCS file: /cvs/gnome/evolution-data-server/servers/exchange/storage/exchange-account.c,v retrieving revision 1.25 diff -u -p -r1.25 exchange-account.c --- evolution-data-server/servers/exchange/storage/exchange-account.c 19 Dec 2005 13:51:56 -0000 1.25 +++ evolution-data-server/servers/exchange/storage/exchange-account.c 9 Jan 2006 13:54:21 -0000 @@ -58,9 +58,6 @@ #define ADS_UF_DONT_EXPIRE_PASSWORD 0x10000 #define ONE_HUNDRED_NANOSECOND 0.000000100 #define SECONDS_IN_DAY 86400 -#define PASSWD_EXPIRY_NOTIFICATION_PERIOD 7 -#define FILENAME CONNECTOR_GLADEDIR "/exchange-passwd-expiry.glade" -#define ROOTNODE "passwd_exp_dialog" struct _ExchangeAccountPrivate { E2kContext *ctx; @@ -536,7 +533,7 @@ exchange_account_remove_folder (Exchange if (!get_folder (account, path, &folder, &hier)) return EXCHANGE_ACCOUNT_FOLDER_DOES_NOT_EXIST; - + int_uri = e_folder_exchange_get_internal_uri (folder); if (g_hash_table_find (account->priv->standard_uris, @@ -1020,58 +1017,8 @@ is_password_expired (ExchangeAccount *ac return (result == E2K_KERBEROS_PASSWORD_EXPIRED); } #endif -#if 0 -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\n", - 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); -} - -static void +static int find_passwd_exp_period (ExchangeAccount *account, E2kGlobalCatalogEntry *entry) { double max_pwd_age = 0; @@ -1081,7 +1028,7 @@ find_passwd_exp_period (ExchangeAccount /* If user has not selected password expiry warning option, return */ if (account->priv->passwd_exp_warn_period == -1) - return; + return -1; /* Check for password expiry period */ /* This needs to be invoked after is_password_expired(), i.e., @@ -1098,10 +1045,11 @@ find_passwd_exp_period (ExchangeAccount &entry); e2k_operation_free (&gcop); if (gcstatus != E2K_GLOBAL_CATALOG_OK) - return; + return -1; - if (entry->user_account_control & ADS_UF_DONT_EXPIRE_PASSWORD) - return; /* Password is not set to expire */ + if (entry->user_account_control & ADS_UF_DONT_EXPIRE_PASSWORD) { + return -1; /* Password is not set to expire */ + } /* Here we don't check not setting the password and expired password */ /* Check for the maximum password age set */ @@ -1116,10 +1064,10 @@ find_passwd_exp_period (ExchangeAccount ( max_pwd_age * ONE_HUNDRED_NANOSECOND ) / SECONDS_IN_DAY; if (max_pwd_age_days <= account->priv->passwd_exp_warn_period) { - display_passwd_expiry_message (max_pwd_age_days, - account); + return max_pwd_age_days; } } + return -1; } char * @@ -1462,6 +1410,7 @@ exchange_account_connect (ExchangeAccoun account->priv->connecting = FALSE; g_mutex_unlock (account->priv->connect_lock); *info_result = EXCHANGE_ACCOUNT_PASSWORD_INCORRECT; + e2k_autoconfig_free (ac); return NULL; } @@ -1481,6 +1430,7 @@ exchange_account_connect (ExchangeAccoun *info_result = EXCHANGE_ACCOUNT_PASSWORD_EXPIRED; account->priv->connecting = FALSE; g_mutex_unlock (account->priv->connect_lock); + e2k_autoconfig_free (ac); return NULL; } #endif @@ -1590,20 +1540,17 @@ exchange_account_connect (ExchangeAccoun account->default_timezone = g_strdup (timezone); } - account->priv->connected = TRUE; - account->priv->account_online = ONLINE_MODE; - account->priv->connecting = FALSE; - if (!setup_account_hierarchies (account)) { *info_result = EXCHANGE_ACCOUNT_UNKNOWN_ERROR; g_mutex_unlock (account->priv->connect_lock); return NULL; /* FIXME: what error has happened? */ } - /* Find the password expiery peripod and display warning */ - find_passwd_exp_period(account, entry); - - /* Check for quota warnings */ + account->priv->account_online = ONLINE_MODE; + account->priv->connecting = FALSE; + account->priv->connected = TRUE; + + /* Check for quota usage */ e2k_operation_init (&gcop); gcstatus = e2k_global_catalog_lookup (account->priv->gc, &gcop, E2K_GLOBAL_CATALOG_LOOKUP_BY_EMAIL, @@ -1612,9 +1559,7 @@ exchange_account_connect (ExchangeAccoun &entry); e2k_operation_free (&gcop); - /* FIXME: quota warnings are not yet marked for translation!! */ - /* FIXME: warning message should have quota limit value and optionally current - * usage + /* FIXME: warning message should have quota limit value */ if (gcstatus == E2K_GLOBAL_CATALOG_OK) { @@ -1632,7 +1577,7 @@ exchange_account_connect (ExchangeAccoun account->priv->quota_limit = entry->quota_warn; } } - + g_signal_connect (account->priv->ctx, "redirect", G_CALLBACK (context_redirect), account); @@ -1712,6 +1657,7 @@ exchange_account_get_standard_uri (Excha if (!account->priv->standard_uris) return NULL; + return g_hash_table_lookup (account->priv->standard_uris, item); } @@ -1818,7 +1764,6 @@ exchange_account_get_folder (ExchangeAcc if (!path_or_uri) return NULL; - return g_hash_table_lookup (account->priv->folders, path_or_uri); } @@ -1895,8 +1840,13 @@ exchange_account_get_quota_limit (Exchan int exchange_account_check_password_expiry (ExchangeAccount *account) { + E2kGlobalCatalogEntry *entry; + int max_pwd_age_days = -1; + g_return_val_if_fail (EXCHANGE_IS_ACCOUNT (account), 0); - return -1; + + max_pwd_age_days = find_passwd_exp_period (account, entry); + return max_pwd_age_days; } char * Index: evolution/plugins/exchange-operations/ChangeLog =================================================================== RCS file: /cvs/gnome/evolution/plugins/exchange-operations/ChangeLog,v retrieving revision 1.78 diff -u -p -r1.78 ChangeLog --- evolution/plugins/exchange-operations/ChangeLog 9 Jan 2006 13:29:27 -0000 1.78 +++ evolution/plugins/exchange-operations/ChangeLog 10 Jan 2006 05:35:03 -0000 @@ -1,3 +1,21 @@ +2006-01-10 Sushma Rai <rsushma novell com> + + * 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. + 2006-01-09 Sushma Rai <rsushma novell com> * exchange-folder-subscription.c (create_folder_subscription_dialog): Index: evolution-data-server/servers/exchange/ChangeLog =================================================================== RCS file: /cvs/gnome/evolution-data-server/servers/exchange/ChangeLog,v retrieving revision 1.48 diff -u -p -r1.48 ChangeLog --- evolution-data-server/servers/exchange/ChangeLog 21 Dec 2005 06:43:57 -0000 1.48 +++ evolution-data-server/servers/exchange/ChangeLog 10 Jan 2006 07:39:49 -0000 @@ -1,3 +1,15 @@ +2006-01-10 Sushma Rai <rsushma novell com> + + * lib/e2k-autoconfig.c (e2k_validate_user): Freeing password string. + + * storage/exchange-account.c (display_passwd_expiry_message) + (change_passwd_cb): Removed these unused functions. + (find_passwd_exp_period): Retruning max_pwd_age_days or error instead of + invoking display_passwd_expiry_message(). + (exchange_account_connect): Freeing E2KAutoconfig structure. + (exchange_account_get_quota_limit): Implemeted. Returns password validity + period. Fixes #326060. + 2005-12-21 Sushma Rai <rsushma novell com> * storage/exchange-esource.c (add_folder_esource): Calling