[evolution-patches] Exchange: Remove usage of e_notice in exchange-operations plugin



Hi all,

In exchange-operations plugin, this patch
removes the usage of e_notice function.

Please review it.

Thanks,
Arunprakash.

Index: plugins/exchange-operations/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/ChangeLog,v
retrieving revision 1.13
diff -u -p -r1.13 ChangeLog
--- plugins/exchange-operations/ChangeLog	8 Jul 2005 13:43:53 -0000	1.13
+++ plugins/exchange-operations/ChangeLog	9 Jul 2005 13:07:00 -0000
@@ -1,3 +1,17 @@
+2005-07-09  Arunprakash <arunp novell com>
+
+	* exchange-operations.c (exchange_report_error) : New added, to report
+	errors using e_error_run. Also a list of error-ids is added.
+	* exchange-config-listener.c (account_added) (account_removed) :
+	Modified the usage of e_notice to e_error_run. Also the error from
+	exchange_account_connect is reported using exchange_report_error.
+	* exchange-account-setup.c (btn_chpass_clicked) (org_gnome_exchange_settings)
+	(print_error) (set_oof_info): Changed to use exchange_report_error
+	and e_error_run functions.
+	* org-gnome-exchange-operations.error.xml : Newly added, defines
+	the list of error messages used in the plugin.
+	* Makefile.am : Modified for org-gnome-exchange-operations.error.xml
+
 2005-07-08  Praveen Kumar <kpraveen novell com>
 
 	* Makefile.am : Added entries for the files providing the delegation
Index: plugins/exchange-operations/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/Makefile.am,v
retrieving revision 1.6
diff -u -p -r1.6 Makefile.am
--- plugins/exchange-operations/Makefile.am	8 Jul 2005 13:43:53 -0000	1.6
+++ plugins/exchange-operations/Makefile.am	9 Jul 2005 13:07:00 -0000
@@ -51,8 +51,14 @@ glade_DATA =							\
 	exchange-folder-tree.glade				\
 	exchange-permissions-dialog.glade			
 
+error_DATA = org-gnome-exchange-operations.error
+errordir = $(privdatadir)/errors
+
 EXTRA_DIST = 							\
 	org-gnome-exchange-operations.eplug.in			\
 	org-gnome-folder-permissions.xml			\
-	$(glade_DATA)
+	org-gnome-exchange-operations.error.xml
+	$(glade_DATA)						\
+
+BUILT_SOURCES = $(error_DATA)
 
Index: plugins/exchange-operations/exchange-account-setup.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-account-setup.c,v
retrieving revision 1.9
diff -u -p -r1.9 exchange-account-setup.c
--- plugins/exchange-operations/exchange-account-setup.c	8 Jul 2005 13:43:53 -0000	1.9
+++ plugins/exchange-operations/exchange-account-setup.c	9 Jul 2005 13:07:00 -0000
@@ -48,6 +48,7 @@
 #include "mail/em-config.h"
 #include "exchange-delegates.h"
 
+#define ERROR_DOMAIN	"org-gnome-exchange-operations"
 
 GtkWidget* org_gnome_exchange_settings(EPlugin *epl, EConfigHookItemFactoryData *data);
 GtkWidget *org_gnome_exchange_owa_url(EPlugin *epl, EConfigHookItemFactoryData *data);
@@ -116,6 +117,7 @@ btn_chpass_clicked (GtkButton *button, g
 {
 	ExchangeAccount *account;
 	char *old_password, *new_password;
+ 	ExchangeAccountResult result;
 
 	account = exchange_operations_get_exchange_account ();
 					
@@ -126,7 +128,8 @@ btn_chpass_clicked (GtkButton *button, g
 	}
 	new_password = exchange_get_new_password (old_password, TRUE);
 	g_print ("Current password is \"%s\"\n", old_password);
-	exchange_account_set_password (account, old_password, new_password);
+ 	result = exchange_account_set_password (account, old_password, new_password);
+ 	exchange_report_error (account, result);
 	
 	g_free (old_password);
 	g_free (new_password);	
@@ -226,8 +229,9 @@ org_gnome_exchange_settings(EPlugin *epl
 	/* See if oof info found already */
 	
 	if (!exchange_oof_get (account, &oof_state, &message)) {
-                /* SURF : e_notice (NULL, GTK_MESSAGE_ERROR,
-                          _("Could not read out-of-office state")); */
+
+		e_error_run (NULL, ERROR_DOMAIN ":state-read-error", NULL);
+
                 return NULL;
         }
 	
@@ -365,90 +369,48 @@ print_error (const char *owa_url, E2kAut
 	switch (result) {
 
 		case E2K_AUTOCONFIG_CANT_CONNECT:
-		if (!strncmp (owa_url, "http:", 5)) {
-			old = "http";
-			new = "https";
-		} else {
-			old = "https";
-			new = "http";
-		}
+			if (!strncmp (owa_url, "http:", 5)) {
+				old = "http";
+				new = "https";
+			} else {
+				old = "https";
+				new = "http";
+			}
 
-		/* SURF : e_notice (NULL, GTK_MESSAGE_ERROR,
-			  _("Could not connect to the Exchange "
-			    "server.\nMake sure the URL is correct "
-			    "(try \"%s\" instead of \"%s\"?) "
-			    "and try again."), new, old);
-		*/
-		break;
+			e_error_run (NULL, ERROR_DOMAIN ":account-connect-error", "", NULL);
+			
+			break;
 
 		case E2K_AUTOCONFIG_CANT_RESOLVE:
-		/* SURF :	e_notice (NULL, GTK_MESSAGE_ERROR,
-			  	_("Could not locate Exchange server.\n"
-			    	  "Make sure the server name is spelled correctly "
-			    	  "and try again."));
-		*/
-			break;
+
+			e_error_run (NULL, ERROR_DOMAIN ":account-resolve-error", "", NULL);
+				break;
 
 		case E2K_AUTOCONFIG_AUTH_ERROR:
 		case E2K_AUTOCONFIG_AUTH_ERROR_TRY_NTLM:
 		case E2K_AUTOCONFIG_AUTH_ERROR_TRY_BASIC:
-		/* SURF :	e_notice (NULL, GTK_MESSAGE_ERROR,
-			  	_("Could not authenticate to the Exchange "
-			    	  "server.\nMake sure the username and "
-			    	  "password are correct and try again."));
-		*/
+			e_error_run (NULL, ERROR_DOMAIN ":password-incorrect", NULL);
 			break;
 
 		case E2K_AUTOCONFIG_AUTH_ERROR_TRY_DOMAIN:
-		/* SURF : 		e_notice (NULL, GTK_MESSAGE_ERROR,
-			  	_("Could not authenticate to the Exchange "
-			    	  "server.\nMake sure the username and "
-			    	  "password are correct and try again.\n\n"
-			    	  "You may need to specify the Windows "
-			    	  "domain name as part of your username "
-			    	  "(eg, \"MY-DOMAIN\\%s\")."),
-			  	  ac->username);
-		*/
+			e_error_run (NULL, ERROR_DOMAIN ":account-domain-error", NULL);
 			break;
 
 		case E2K_AUTOCONFIG_NO_OWA:
 		case E2K_AUTOCONFIG_NOT_EXCHANGE:
-		/* SURF :	e_notice (NULL, GTK_MESSAGE_ERROR,
-			  	_("Could not find OWA data at the indicated URL.\n"
-			    	  "Make sure the URL is correct and try again."));
-		*/
+			e_error_run (NULL, ERROR_DOMAIN ":account-wss-error", NULL);
 			break;
 
 		case E2K_AUTOCONFIG_CANT_BPROPFIND:
-		/* SURF :	e_notice (
-				NULL, GTK_MESSAGE_ERROR,
-				_("Ximian Connector requires access to certain "
-			  	"functionality on the Exchange Server that appears "
-			  	"to be disabled or blocked.  (This is usually "
-			  	"unintentional.)  Your Exchange Administrator will "
-			  	"need to enable this functionality in order for "
-			  	"you to be able to use Ximian Connector.\n\n"
-			  	"For information to provide to your Exchange "
-			  	"administrator, please follow the link below:\n"
-				"http://support.novell.com/cgi-bin/search/searchtid.cgi?/ximian/ximian328.html "));
-		*/
+			e_error_run (NULL, ERROR_DOMAIN ":connect-exchange-error", NULL);
 			break;
 
 		case E2K_AUTOCONFIG_EXCHANGE_5_5:
-		/* SURF :	e_notice (
-				NULL, GTK_MESSAGE_ERROR,
-				_("The Exchange server URL you provided is for an "
-			  	"Exchange 5.5 Server. Ximian Connector supports "
-			  	"Microsoft Exchange 2000 and 2003 only."));
-		*/
+			e_error_run (NULL, ERROR_DOMAIN ":account-version-error", NULL);
 			break;
 
 		default:
-		/* SURF :	e_notice (NULL, GTK_MESSAGE_ERROR,
-			  	_("Could not configure Exchange account because "
-			    	  "an unknown error occurred. Check the URL, "
-			    	  "username, and password, and try again."));
-		*/
+			e_error_run (NULL, ERROR_DOMAIN ":configure-error", NULL);
 			break;
 
 	}
@@ -732,8 +694,8 @@ set_oof_info ()
         }
 
 	if (!exchange_oof_set (account, oof_data->state, oof_data->message)) {
-		/* SURF : e_notice (NULL, GTK_MESSAGE_ERROR,
-				_("Could not update out-of-office state")); */
+
+		e_error_run (NULL, ERROR_DOMAIN ":state-update-error", NULL);
 	}
 
 }
Index: plugins/exchange-operations/exchange-config-listener.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-config-listener.c,v
retrieving revision 1.4
diff -u -p -r1.4 exchange-config-listener.c
--- plugins/exchange-operations/exchange-config-listener.c	5 Jul 2005 09:19:10 -0000	1.4
+++ plugins/exchange-operations/exchange-config-listener.c	9 Jul 2005 13:07:01 -0000
@@ -27,6 +27,7 @@
 #endif
 
 #include "exchange-config-listener.h"
+#include "exchange-operations.h"
 
 #include <exchange-account.h>
 #include <exchange-constants.h>
@@ -38,6 +39,8 @@
 
 // SURF : #include <libedataserver/e-dialog-utils.h>
 
+#include <e-util/e-error.h>
+
 #include <libedataserver/e-source.h>
 #include <libedataserver/e-source-list.h>
 #include <libedataserver/e-source-group.h>
@@ -833,6 +836,7 @@ account_added (EAccountList *account_lis
 {
 	ExchangeConfigListener *config_listener;
 	ExchangeAccount *exchange_account;
+	ExchangeAccountResult result;
 
 	if (!is_active_exchange_account (account))
 		return;
@@ -840,9 +844,7 @@ account_added (EAccountList *account_lis
 	config_listener = EXCHANGE_CONFIG_LISTENER (account_list);
 	if (config_listener->priv->configured_account) {
 		/* Multiple accounts configured. */
-		/* SURF : e_notice (NULL, GTK_MESSAGE_ERROR,
-			  _("You may only configure a single Exchange account"));
-		*/
+		e_error_run (NULL, "org-gnome-exchange-operations:single-account-error", NULL);
 		return;
 	}
 
@@ -872,7 +874,8 @@ account_added (EAccountList *account_lis
 	g_signal_emit (config_listener, signals[EXCHANGE_ACCOUNT_CREATED], 0,
 		       exchange_account);
 	add_sources (exchange_account);
-	exchange_account_connect (exchange_account);
+ 	exchange_account_connect (exchange_account, &result);
+ 	exchange_report_error (exchange_account, result);
 	add_new_sources (exchange_account);
 }
 
@@ -1036,10 +1039,8 @@ account_changed (EAccountList *account_l
 		remove_account_esources (priv->exchange_account);
 
 	/* Nope. Let the user know we're ignoring him. */
-	/* SURF : e_notice (NULL, GTK_MESSAGE_WARNING,
-		  _("Changes to Exchange account configuration will "
-		    "take\nplace after you quit and restart Evolution."));
-	*/
+
+	e_error_run (NULL, "org-gnome-exchange-operations:apply-restart", NULL);
 
 	/* But note the new URI so if he changes something else, we
 	 * only warn again if he changes again.
@@ -1083,15 +1084,13 @@ account_removed (EAccountList *account_l
 		priv->configured_name = NULL;
 	} else {
 		if (account->enabled) {
-			/* SURF : e_notice (NULL, GTK_MESSAGE_INFO,
-				_("The Exchange account will be removed when you quit Evolution"));
-			*/
+
+			e_error_run (NULL, "org-gnome-exchange-operations:remove-quit", NULL);
 		}
 		else {
 			/* The account is in use. We can't remove it. */
-			/* SURF : e_notice (NULL, GTK_MESSAGE_INFO,
-			  	_("The Exchange account will be disabled when you quit Evolution"));
-			*/
+
+			e_error_run (NULL, "org-gnome-exchange-operations:disable-quit", NULL);
 		}
 	}
 }
Index: plugins/exchange-operations/exchange-operations.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-operations.c,v
retrieving revision 1.2
diff -u -p -r1.2 exchange-operations.c
--- plugins/exchange-operations/exchange-operations.c	1 Jul 2005 10:06:24 -0000	1.2
+++ plugins/exchange-operations/exchange-operations.c	9 Jul 2005 13:07:01 -0000
@@ -22,9 +22,29 @@
 #include <string.h>
 
 #include "exchange-operations.h"
+#include <e-util/e-error.h>
 
 ExchangeConfigListener *exchange_global_config_listener=NULL;
 
+static char *error_ids[] = { "config-error",
+			     "password-weak-error",
+			     "password-change-error",
+			     "password-change-success",
+			     "account-offline",
+			     "password-incorrect",
+			     "account-domain-error",
+			     "account-mailbox-na",
+			     "account-version-error",
+			     "account-wss-error",
+			     "account-no-mailbox",
+			     "account-resolve-error",
+			     "account-connect-error",
+			     "password-expired",
+			     "account-unknown-error",
+			     "account-quota-error",
+			     "account-quota-send-error",
+			     "account-quota-warn" };
+
 static void
 free_exchange_listener (void)
 {
@@ -166,3 +186,31 @@ exchange_operations_get_exchange_account
 	return account;
 }
 
+void
+exchange_report_error (ExchangeAccount *account, ExchangeAccountResult result)
+{
+	gchar *error_string;
+
+	g_return_if_fail (account != NULL);
+	
+	error_string = g_strconcat ("org-gnome-exchange-operations:", error_ids[result], NULL);
+	
+	switch (result) {
+		case EXCHANGE_ACCOUNT_MAILBOX_NA:
+			e_error_run (NULL, error_string, exchange_account_get_username (account), NULL);
+			break;
+		case EXCHANGE_ACCOUNT_NO_MAILBOX:
+			e_error_run (NULL, error_string, exchange_account_get_username (account),
+				     account->exchange_server, NULL);
+			break;
+		case EXCHANGE_ACCOUNT_RESOLVE_ERROR:
+		case EXCHANGE_ACCOUNT_CONNECT_ERROR:
+		case EXCHANGE_ACCOUNT_UNKNOWN_ERROR:
+			e_error_run (NULL, error_string, account->exchange_server, NULL);
+			break;
+		default:
+			e_error_run (NULL, error_string, NULL);
+	}
+	g_free (error_string);
+}
+
Index: plugins/exchange-operations/exchange-operations.h
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-operations.h,v
retrieving revision 1.2
diff -u -p -r1.2 exchange-operations.h
--- plugins/exchange-operations/exchange-operations.h	1 Jul 2005 10:06:24 -0000	1.2
+++ plugins/exchange-operations/exchange-operations.h	9 Jul 2005 13:07:01 -0000
@@ -26,6 +26,7 @@
 
 #include "e-util/e-plugin.h"
 #include "exchange-config-listener.h"
+#include <exchange/exchange-account.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -43,6 +44,8 @@ gboolean exchange_operations_tokenize_st
 gboolean exchange_operations_cta_add_node_to_tree (GtkTreeStore *store, GtkTreeIter *parent, const char *nuri);
 void exchange_operations_cta_select_node_from_tree (GtkTreeStore *store, GtkTreeIter *parent, const char *nuri, const char *ruri, GtkTreeSelection *selection) ;
 
+void exchange_report_error (ExchangeAccount *account, ExchangeAccountResult result);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
--- /dev/null	2005-03-20 01:06:14.000000000 +0530
+++ plugins/exchange-operations/org-gnome-exchange-operations.error.xml	2005-07-09 16:53:30.000000000 +0530
@@ -0,0 +1,142 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<error-list domain="org-gnome-exchange-operations">
+
+ <error id="single-account-error" type="error">
+  <_primary>You may only configure a single Exchange account.</_primary>
+ </error>
+
+ <error id="apply-restart" type="info">
+  <_primary>Please restart Evolution</_primary>
+  <_secondary>Changes to Exchange account configuration will take place after you quit and restart Evolution.</_secondary>
+ </error>
+
+ <error id="remove-quit" type="info">
+  <_primary>The Exchange account will be removed when you quit Evolution</_primary>
+ </error>
+
+ <error id="disable-quit" type="info">
+  <_primary>The Exchange account will be disabled when you quit Evolution</_primary>
+ </error>
+
+ <error id="state-read-error" type="error">
+  <_primary>Could not read out-of-office state</_primary>
+ </error>
+
+ <error id="state-update-error" type="error">
+  <_primary>Could not update out-of-office state</_primary>
+ </error>
+
+ <error id="config-error" type="error">
+  <_primary>Cannot change password due to configuration problems.</_primary>
+ </error>
+ 
+ <error id="password-weak-error" type="error">
+  <_primary>Server rejected password because it is too weak.</_primary>
+  <_secondary>Try again with a different password.</_secondary>
+ </error>
+
+ <error id="password-change-error" type="error">
+  <_primary>Could not change password.</_primary>
+ </error>
+
+ <error id="password-change-success" type="info">
+  <_primary>Password successfully changed.</_primary>
+ </error>
+
+ <error id="account-offline" type="info">
+  <_primary>Exchange Account is offline.</_primary>
+  <_secondary>Cannot display folders.</_secondary>
+ </error>
+
+ <error id="password-incorrect" type="error">
+  <_primary>Could not authenticate to server.</_primary>
+  <_secondary>Make sure the username and password are correct and try again.</_secondary>
+ </error>
+
+ <error id="account-domain-error" type="error">
+  <_primary>Could not authenticate to server.</_primary>
+  <_secondary xml:space="preserve">This probably means that your server requires 
+you to specify the Windows domain name 
+as part of your username (eg, &quot;DOMAIN\user&quot;).
+
+Or you might have just typed your password wrong.</_secondary>
+ </error>
+
+ <error id="account-mailbox-na" type="error">
+  <_primary>Mailbox for {0} is not on this server.</_primary>
+ </error>
+
+ <error id="account-version-error" type="error">
+  <_primary>The Exchange server is not compatible with Exchange Connector.</_primary>
+  <_secondary xml:space="preserve">The server is runinng Exchange 5.5. Exchange Connector 
+supports Microsoft Exchange 2000 and 2003 only.</_secondary>
+ </error>
+
+ <error id="account-wss-error" type="error">
+  <_primary>Could not find Exchange Web Storage System.</_primary>
+  <_secondary>If OWA is running on a different path, you must specify that in the account configuration dialog.</_secondary>
+ </error>
+
+ <error id="account-no-mailbox" type="info">
+  <_primary>No mailbox for user {0} on {1}.</_primary>
+ </error>
+
+ <error id="account-resolve-error" type="error">
+  <_primary>Could not locate server {0}.</_primary>
+  <_secondary>Make sure the server name is spelled correctly and try again.</_secondary>
+ </error>
+
+ <error id="account-connect-error" type="error">
+  <_primary>Could not connect to server {0}.</_primary>
+  <_secondary>Make sure the URL is correct and try again.</_secondary>
+ </error>
+
+ <error id="password-expired" type="error">
+  <_primary>Your password has expired.</_primary>
+ </error>
+
+ <error id="account-unknown-error" type="error">
+  <_primary>Could not connect to server {0}.</_primary>
+  <_secondary>Unknown error.</_secondary>
+ </error>
+
+ <error id="account-quota-error" type="error">
+  <_primary>You have exceeded your quota for storing mails on this server.</_primary>
+  <_secondary>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>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>Try to clear up some space by deleting some mails.</_secondary>
+ </error>
+
+ <error id="connector-exchange-error" type="error">
+  <_primary>Exchange Connector access error.</_primary>
+  <_secondary xml:space="preserve">Exchange Connector requires access to certain
+functionality on the Exchange Server that appears
+to be disabled or blocked.  (This is usually 
+unintentional.)  Your Exchange Administrator will 
+need to enable this functionality in order for 
+you to be able to use Ximian Connector.
+
+For information to provide to your Exchange 
+administrator, please follow the link below:
+
+http://support.novell.com/cgi-bin/search/searchtid.cgi?/ximian/ximian328.html
+  </_secondary>
+ </error>
+
+ <error id="configure-error" type="error">
+  <_secondary xml:space="preserve">Could not configure Exchange account because 
+an unknown error occurred. Check the URL, 
+username, and password, and try again.</_secondary>
+ </error>
+
+</error-list>
+
+


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]