[evolution-patches] Exchange: Fix for bug 312849



Hello -

I am attaching the fix for the bug 312849, which is allowing to create
calendars, task lists and addressbooks when Evolution is in offline
mode. Seperate patches for 2.4.1 and 2.5 are attached. Please review.

Thanks -
Praveen.

Index: plugins/exchange-operations/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/ChangeLog,v
retrieving revision 1.51.2.2
diff -u -p -r1.51.2.2 ChangeLog
--- plugins/exchange-operations/ChangeLog	15 Sep 2005 13:16:07 -0000	1.51.2.2
+++ plugins/exchange-operations/ChangeLog	22 Sep 2005 10:14:44 -0000
@@ -1,3 +1,23 @@
+2005-09-22  Praveen Kumar  <kpraveen novell com>
+
+	** Fixes bug 312849
+
+	* exchange-calendar.c
+	(e_exchange_calendar_pcalendar): Populate the folder hierarchy only 
+	if Evolution is online.
+	(e_exchange_calendar_check): Disable the "OK" button if Evolution 
+	is offline.
+	(e_exchange_calendar_commit): Don't do anything if Evolution is 
+	offline.
+
+	* exchange-contacts.c
+	(e_exchange_contacts_pcontacts): Populate the folder hierarchy only 
+	if Evolution is online.
+	(e_exchange_contacts_check): Disable the "OK" button if Evolution 
+	is offline.
+	(e_exchange_contacts_commit): Don't do anything if Evolution is 
+	offline.
+
 2005-09-15  Arunprakash  <arunp novell com>
 
 	* exchange-account-setup.c
Index: plugins/exchange-operations/exchange-calendar.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-calendar.c,v
retrieving revision 1.9
diff -u -p -r1.9 exchange-calendar.c
--- plugins/exchange-operations/exchange-calendar.c	24 Aug 2005 09:43:41 -0000	1.9
+++ plugins/exchange-operations/exchange-calendar.c	22 Sep 2005 10:14:44 -0000
@@ -152,6 +152,7 @@ e_exchange_calendar_pcalendar (EPlugin *
 	char *folder_size;
 	const char *rel_uri;
 	int row, i;
+	gint offline_status;
 
 
 	if (!hidden)
@@ -176,6 +177,17 @@ e_exchange_calendar_pcalendar (EPlugin *
 	e_uri_free (uri);
 	g_free (uri_text);
 
+	parent = data->parent;
+	row = ((GtkTable*)parent)->nrows;
+
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+								    &offline_status);
+	if (offline_status == OFFLINE_MODE) {
+		/* Evolution is in offline mode; we will not be able to create
+		   new folders or modify existing folders. */
+		return NULL;		
+	}
+
 	rel_uri = e_source_peek_relative_uri (t->source);
 	if (rel_uri && strlen (rel_uri)) {
 		calendar_src_exists = TRUE;
@@ -186,9 +198,6 @@ e_exchange_calendar_pcalendar (EPlugin *
 		calendar_src_exists = FALSE;
 	}
 	
-	parent = data->parent;
-	row = ((GtkTable*)parent)->nrows;
-
 	/* REVIEW: Should this handle be freed? - Attn: surf */
 	account = exchange_operations_get_exchange_account ();
 	account_name = account->account_name;
@@ -280,11 +289,16 @@ e_exchange_calendar_check (EPlugin *epl,
 	ESourceGroup *group;
 	const char *base_uri;
 	const char *rel_uri;
+	gint offline_status;
 
 	rel_uri = e_source_peek_relative_uri (t->source);
 	group = e_source_peek_group (t->source);
 	base_uri = e_source_group_peek_base_uri (group);
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+						     &offline_status);
 	if (base_uri && !strncmp (base_uri, "exchange", 8)) {
+		if (offline_status == OFFLINE_MODE)
+			return FALSE;
 		if (rel_uri && !strlen (rel_uri)) {
 			return FALSE;
 		}
@@ -302,13 +316,20 @@ e_exchange_calendar_commit (EPlugin *epl
 	int prefix_len;
 	ExchangeAccount *account;
 	ExchangeAccountFolderResult result;
-		
+	gint offline_status;
+
 	uri_text = e_source_get_uri (source);
 	if (uri_text && strncmp (uri_text, "exchange", 8)) {
 		g_free (uri_text);
 		return ;
 	}	
-	
+
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+						     &offline_status);
+		
+	if (offline_status == OFFLINE_MODE)
+		return;
+
 	account = exchange_operations_get_exchange_account ();
 	path_prefix = g_strconcat (account->account_filename, "/", NULL);
 	prefix_len = strlen (path_prefix);
Index: plugins/exchange-operations/exchange-contacts.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-contacts.c,v
retrieving revision 1.8
diff -u -p -r1.8 exchange-contacts.c
--- plugins/exchange-operations/exchange-contacts.c	24 Aug 2005 09:43:41 -0000	1.8
+++ plugins/exchange-operations/exchange-contacts.c	22 Sep 2005 10:14:44 -0000
@@ -136,6 +136,8 @@ e_exchange_contacts_pcontacts (EPlugin *
 
 	EABConfigTargetSource *t = (EABConfigTargetSource *) data->target;
 	ESource *source = t->source;
+	gint offline_status;
+	
 
 	if (data->old) {
 		gtk_widget_destroy (vb_pcontacts);
@@ -149,6 +151,14 @@ e_exchange_contacts_pcontacts (EPlugin *
 
 	g_free (uri_text);
 
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+								    &offline_status);
+	if (offline_status == OFFLINE_MODE) {
+		/* Evolution is in offline mode; we will not be able to create
+		   new folders or modify existing folders. */
+		return NULL;		
+	}
+
 	rel_uri = e_source_peek_relative_uri (source);
 	uid = e_source_peek_uid (source);
 	if (rel_uri && uid && (strcmp (rel_uri, uid))) {
@@ -263,14 +273,19 @@ e_exchange_contacts_check (EPlugin *epl,
 	ESourceGroup *group;
 	const char *base_uri;
 	const char *rel_uri;
+	gint offline_status;
 
 	rel_uri = e_source_peek_relative_uri (t->source);
 	group = e_source_peek_group (t->source);
 	base_uri = e_source_group_peek_base_uri (group);
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+								    &offline_status);
 	if (base_uri && !strncmp (base_uri, "exchange", 8)) {
+		if (offline_status == OFFLINE_MODE)
+			return FALSE;
 		if (rel_uri && !strlen (rel_uri)) {
 			return FALSE;
-		}
+		}		
 	}
 
 	return TRUE;
@@ -285,6 +300,7 @@ e_exchange_contacts_commit (EPlugin *epl
 	int prefix_len;
 	ExchangeAccount *account;
 	ExchangeAccountFolderResult result;
+	gint offline_status;
 		
 	uri_text = e_source_get_uri (source);
 	if (uri_text && strncmp (uri_text, "exchange", 8)) {
@@ -292,6 +308,11 @@ e_exchange_contacts_commit (EPlugin *epl
 		return ;
 	}	
 	g_free (uri_text);
+
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+								    &offline_status);
+	if (offline_status == OFFLINE_MODE)
+		return;
 
 	account = exchange_operations_get_exchange_account ();
 	path_prefix = g_strconcat (account->account_filename, "/", NULL);
Index: plugins/exchange-operations/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/ChangeLog,v
retrieving revision 1.53
diff -u -p -r1.53 ChangeLog
--- plugins/exchange-operations/ChangeLog	15 Sep 2005 13:07:10 -0000	1.53
+++ plugins/exchange-operations/ChangeLog	22 Sep 2005 10:01:06 -0000
@@ -1,3 +1,23 @@
+2005-09-22  Praveen Kumar  <kpraveen novell com>
+
+	** Fixes bug 312849
+
+	* exchange-calendar.c
+	(e_exchange_calendar_pcalendar): Populate the folder hierarchy only 
+	if Evolution is online.
+	(e_exchange_calendar_check): Disable the "OK" button if Evolution 
+	is offline.
+	(e_exchange_calendar_commit): Don't do anything if Evolution is 
+	offline.
+
+	* exchange-contacts.c
+	(e_exchange_contacts_pcontacts): Populate the folder hierarchy only 
+	if Evolution is online.
+	(e_exchange_contacts_check): Disable the "OK" button if Evolution 
+	is offline.
+	(e_exchange_contacts_commit): Don't do anything if Evolution is 
+	offline.
+
 2005-09-15  Arunprakash  <arunp novell com>
 
 	* exchange-account-setup.c
Index: plugins/exchange-operations/exchange-calendar.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-calendar.c,v
retrieving revision 1.9
diff -u -p -r1.9 exchange-calendar.c
--- plugins/exchange-operations/exchange-calendar.c	24 Aug 2005 09:43:41 -0000	1.9
+++ plugins/exchange-operations/exchange-calendar.c	22 Sep 2005 10:01:06 -0000
@@ -152,6 +152,9 @@ e_exchange_calendar_pcalendar (EPlugin *
 	char *folder_size;
 	const char *rel_uri;
 	int row, i;
+	gint offline_status;
+	char *offline_msg;
+	GtkWidget *lbl_offline_msg;
 
 
 	if (!hidden)
@@ -176,6 +179,24 @@ e_exchange_calendar_pcalendar (EPlugin *
 	e_uri_free (uri);
 	g_free (uri_text);
 
+	parent = data->parent;
+	row = ((GtkTable*)parent)->nrows;
+
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+								    &offline_status);
+	if (offline_status == OFFLINE_MODE) {
+		/* Evolution is in offline mode; we will not be able to create
+		   new folders or modify existing folders. */
+		offline_msg = g_markup_printf_escaped ("<b>%s</b>", 
+						       _("Evolution is in offline mode. You can't create or modify folders now.\nPlease switch to online mode for such operations."));
+		lbl_offline_msg = gtk_label_new ("");
+		gtk_label_set_markup (GTK_LABEL (lbl_offline_msg), offline_msg);
+		g_free (offline_msg);
+		gtk_widget_show (lbl_offline_msg);
+		gtk_table_attach (GTK_TABLE (parent), lbl_offline_msg, 0, 2, row, row+1, GTK_FILL|GTK_EXPAND, 0, 0, 0);
+		return lbl_offline_msg;		
+	}
+
 	rel_uri = e_source_peek_relative_uri (t->source);
 	if (rel_uri && strlen (rel_uri)) {
 		calendar_src_exists = TRUE;
@@ -186,9 +207,6 @@ e_exchange_calendar_pcalendar (EPlugin *
 		calendar_src_exists = FALSE;
 	}
 	
-	parent = data->parent;
-	row = ((GtkTable*)parent)->nrows;
-
 	/* REVIEW: Should this handle be freed? - Attn: surf */
 	account = exchange_operations_get_exchange_account ();
 	account_name = account->account_name;
@@ -280,11 +298,16 @@ e_exchange_calendar_check (EPlugin *epl,
 	ESourceGroup *group;
 	const char *base_uri;
 	const char *rel_uri;
+	gint offline_status;
 
 	rel_uri = e_source_peek_relative_uri (t->source);
 	group = e_source_peek_group (t->source);
 	base_uri = e_source_group_peek_base_uri (group);
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+						     &offline_status);
 	if (base_uri && !strncmp (base_uri, "exchange", 8)) {
+		if (offline_status == OFFLINE_MODE)
+			return FALSE;
 		if (rel_uri && !strlen (rel_uri)) {
 			return FALSE;
 		}
@@ -302,13 +325,20 @@ e_exchange_calendar_commit (EPlugin *epl
 	int prefix_len;
 	ExchangeAccount *account;
 	ExchangeAccountFolderResult result;
-		
+	gint offline_status;
+
 	uri_text = e_source_get_uri (source);
 	if (uri_text && strncmp (uri_text, "exchange", 8)) {
 		g_free (uri_text);
 		return ;
 	}	
-	
+
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+						     &offline_status);
+		
+	if (offline_status == OFFLINE_MODE)
+		return;
+
 	account = exchange_operations_get_exchange_account ();
 	path_prefix = g_strconcat (account->account_filename, "/", NULL);
 	prefix_len = strlen (path_prefix);
Index: plugins/exchange-operations/exchange-contacts.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-contacts.c,v
retrieving revision 1.8
diff -u -p -r1.8 exchange-contacts.c
--- plugins/exchange-operations/exchange-contacts.c	24 Aug 2005 09:43:41 -0000	1.8
+++ plugins/exchange-operations/exchange-contacts.c	22 Sep 2005 10:01:06 -0000
@@ -136,6 +136,10 @@ e_exchange_contacts_pcontacts (EPlugin *
 
 	EABConfigTargetSource *t = (EABConfigTargetSource *) data->target;
 	ESource *source = t->source;
+	GtkWidget *lbl_offline_msg, *vb_offline_msg;
+	char *offline_msg;
+	gint offline_status;
+	
 
 	if (data->old) {
 		gtk_widget_destroy (vb_pcontacts);
@@ -149,6 +153,23 @@ e_exchange_contacts_pcontacts (EPlugin *
 
 	g_free (uri_text);
 
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+								    &offline_status);
+	if (offline_status == OFFLINE_MODE) {
+		/* Evolution is in offline mode; we will not be able to create
+		   new folders or modify existing folders. */
+		offline_msg = g_markup_printf_escaped ("<b>%s</b>", 
+						       _("Evolution is in offline mode. You can't create or modify folders now.\nPlease switch to online mode for such operations."));
+		vb_offline_msg = gtk_vbox_new (FALSE, 6);		
+		gtk_container_add (GTK_CONTAINER (data->parent), vb_offline_msg);
+		lbl_offline_msg = gtk_label_new ("");
+		gtk_label_set_markup (GTK_LABEL (lbl_offline_msg), offline_msg);
+		g_free (offline_msg);
+		gtk_box_pack_start (GTK_BOX (vb_offline_msg), lbl_offline_msg, FALSE, FALSE, 0);
+		gtk_widget_show_all (vb_offline_msg);
+		return vb_offline_msg;		
+	}
+
 	rel_uri = e_source_peek_relative_uri (source);
 	uid = e_source_peek_uid (source);
 	if (rel_uri && uid && (strcmp (rel_uri, uid))) {
@@ -263,14 +284,19 @@ e_exchange_contacts_check (EPlugin *epl,
 	ESourceGroup *group;
 	const char *base_uri;
 	const char *rel_uri;
+	gint offline_status;
 
 	rel_uri = e_source_peek_relative_uri (t->source);
 	group = e_source_peek_group (t->source);
 	base_uri = e_source_group_peek_base_uri (group);
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+								    &offline_status);
 	if (base_uri && !strncmp (base_uri, "exchange", 8)) {
+		if (offline_status == OFFLINE_MODE)
+			return FALSE;
 		if (rel_uri && !strlen (rel_uri)) {
 			return FALSE;
-		}
+		}		
 	}
 
 	return TRUE;
@@ -285,6 +311,7 @@ e_exchange_contacts_commit (EPlugin *epl
 	int prefix_len;
 	ExchangeAccount *account;
 	ExchangeAccountFolderResult result;
+	gint offline_status;
 		
 	uri_text = e_source_get_uri (source);
 	if (uri_text && strncmp (uri_text, "exchange", 8)) {
@@ -292,6 +319,11 @@ e_exchange_contacts_commit (EPlugin *epl
 		return ;
 	}	
 	g_free (uri_text);
+
+	exchange_config_listener_get_offline_status (exchange_global_config_listener, 
+								    &offline_status);
+	if (offline_status == OFFLINE_MODE)
+		return;
 
 	account = exchange_operations_get_exchange_account ();
 	path_prefix = g_strconcat (account->account_filename, "/", NULL);


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