Re: [evolution-patches] Exchange: Patch for bug #311324



Hi,

I have incorporated all the changes and sending a new patch. Please
review it.

Thanks,
Shakti


On Mon, 2005-08-01 at 12:02 +0530, Sarfraaz Ahmed wrote:
> Looks good. A few styling/naming/error-check issues. Please correct them
> and commit.

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/ChangeLog,v
retrieving revision 1.37
diff -u -p -r1.37 ChangeLog
--- ChangeLog	1 Aug 2005 06:46:30 -0000	1.37
+++ ChangeLog	1 Aug 2005 11:08:29 -0000
@@ -1,3 +1,19 @@
+2005-07-29  Shakti Sen <shprasad novell com>
+
+	* exchange-folder.c (org_gnome_exchange_folder_ab_unsubscribe)
+	(org_gnome_exchange_folder_unsubscribe)
+	(org_gnome_exchange_folder_subscription): Added offline/online support
+	and removed some warning messages.
+	* exchange-operations.c: Added a new function exchange_is_offline().
+	* exchange-operations.h: Included a prototype.
+	* exchange-config-listener.c
+	(exchange_config_listener_get_offline_status): Added newly to get the
+	online/offline status.
+	* exchange-config-listener.h: Added the prototype for
+	exchange_config_listener_get_offline_status().
+
+	Fixes bug #311324.
+
 2005-08-01  Praveen Kumar  <kpraveen novell com>
 	* exchnage-config-listener.c 
 	(exchange_add_autocompletion_folders) : Added new
Index: exchange-config-listener.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-config-listener.c,v
retrieving revision 1.9
diff -u -p -r1.9 exchange-config-listener.c
--- exchange-config-listener.c	1 Aug 2005 06:46:30 -0000	1.9
+++ exchange-config-listener.c	1 Aug 2005 11:08:29 -0000
@@ -839,6 +839,36 @@ idle_construct (gpointer data)
 	return FALSE;
 }
 
+ExchangeConfigListenerStatus
+exchange_config_listener_get_offline_status (ExchangeConfigListener *excl,
+					     gint *mode)
+{
+	ExchangeConfigListenerPrivate *priv;
+	GConfValue *value;
+	ExchangeConfigListenerStatus status;
+	gboolean offline = FALSE;
+
+	if (!excl)
+		return CONFIG_LISTENER_ACCOUNT_NOT_CREATED; 
+	
+	priv = excl->priv;
+	value = gconf_client_get (priv->gconf,
+					"/apps/evolution/shell/start_offline", NULL);
+	if (value)
+		offline = gconf_value_get_bool (value);
+
+	if (!offline) {
+		*mode = IS_OFFLINE;
+		status = CONFIG_LISTENER_STATUS_OK;
+	}
+	else {
+		*mode = IS_ONLINE;
+		status = CONFIG_LISTENER_STATUS_OK;
+	}		
+
+	return status;
+
+}	
 /**
  * exchange_config_listener_new:
  *
Index: exchange-config-listener.h
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-config-listener.h,v
retrieving revision 1.1
diff -u -p -r1.1 exchange-config-listener.h
--- exchange-config-listener.h	13 Jun 2005 12:39:20 -0000	1.1
+++ exchange-config-listener.h	1 Aug 2005 11:08:29 -0000
@@ -16,6 +16,16 @@ extern "C" {
 #pragma }
 #endif /* __cplusplus */
 
+typedef enum {
+	CONFIG_LISTENER_STATUS_OK,
+	CONFIG_LISTENER_ACCOUNT_NOT_CREATED
+} ExchangeConfigListenerStatus;
+
+enum {
+	IS_OFFLINE,
+	IS_ONLINE
+};
+
 #define EXCHANGE_TYPE_CONFIG_LISTENER            (exchange_config_listener_get_type ())
 #define EXCHANGE_CONFIG_LISTENER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), EXCHANGE_TYPE_CONFIG_LISTENER, ExchangeConfigListener))
 #define EXCHANGE_CONFIG_LISTENER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), EXCHANGE_TYPE_CONFIG_LISTENER, ExchangeConfigListenerClass))
@@ -50,6 +60,7 @@ GSList                 *exchange_config_
 
 void 			add_folder_esource (ExchangeAccount *account, FolderType folder_type, const char *folder_name, const char *physical_uri);
 void 			remove_folder_esource (ExchangeAccount *account, FolderType folder_type, const char *physical_uri);
+ExchangeConfigListenerStatus exchange_config_listener_get_offline_status (ExchangeConfigListener *excl, gint *mode);
 
 #ifdef __cplusplus
 }
Index: exchange-folder.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-folder.c,v
retrieving revision 1.6
diff -u -p -r1.6 exchange-folder.c
--- exchange-folder.c	28 Jul 2005 18:05:12 -0000	1.6
+++ exchange-folder.c	1 Aug 2005 11:08:29 -0000
@@ -301,12 +301,31 @@ org_gnome_exchange_folder_ab_unsubscribe
 	gchar *title = NULL;
 	gchar *displayed_folder_name = NULL;
 	gint response;
+	gboolean mode;
+	ExchangeConfigListenerStatus status;
 
 	account = exchange_operations_get_exchange_account ();
 
 	if (!account)
 		return;
 
+	status = exchange_is_offline (&mode);
+
+	if (status == CONFIG_LISTENER_ACCOUNT_NOT_CREATED) {
+		g_warning ("Exchange account is not created");
+		return;
+	}	
+
+	if (status == CONFIG_LISTENER_STATUS_OK && mode == OFFLINE_MODE) {
+		g_warning ("Unsubscribe to Other User's Folder is not allowed in Offline mode\n");
+		/* FIXME:
+		   I think throwing an error dialog is not allowed
+		   because of UI freeze.
+		   e_error_run (NULL, ERROR_DOMAIN ":folder-offline-error", NULL);
+		*/
+		return;
+	}	
+
 	source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (target->selector));
 	displayed_folder_name = (gchar *) e_source_peek_name (source);
 	dialog = gtk_message_dialog_new (NULL,
@@ -344,12 +363,31 @@ org_gnome_exchange_folder_unsubscribe (E
 	gchar *title = NULL;
 	gchar *displayed_folder_name = NULL;
 	gint response;
+	gboolean mode;
+	ExchangeConfigListenerStatus status;
 
 	account = exchange_operations_get_exchange_account ();
 
 	if (!account)
 		return;
 
+	status = exchange_is_offline (&mode);
+
+	if (status == CONFIG_LISTENER_ACCOUNT_NOT_CREATED) {
+		g_warning ("Exchange account is not created");
+		return;
+	}	
+
+	if (status == CONFIG_LISTENER_STATUS_OK && mode == OFFLINE_MODE) {
+		g_warning ("Unsubscribe to Other User's Folder is not allowed in Offline mode\n");
+		/* FIXME:
+		   I think throwing an error dialog is not allowed 
+		   because of UI freeze.
+		   e_error_run (NULL, ERROR_DOMAIN ":folder-offline-error", NULL);
+		*/
+		return;
+	}	
+
 	source = e_source_selector_peek_primary_selection (E_SOURCE_SELECTOR (target->selector));
 	displayed_folder_name = (gchar *) e_source_peek_name (source);
 	dialog = gtk_message_dialog_new (NULL,
@@ -390,11 +428,30 @@ org_gnome_exchange_folder_subscription (
 	gchar *folder_type = NULL;
 	gchar *physical_uri = NULL;
 	gchar *user_email_address = NULL, *folder_name = NULL;
+	gboolean mode;
+	ExchangeConfigListenerStatus status;
 
 	account = exchange_operations_get_exchange_account ();
 
 	if (!account)
 		return;
+
+	status = exchange_is_offline (&mode);
+
+	if (status == CONFIG_LISTENER_ACCOUNT_NOT_CREATED) {
+		g_warning ("Exchange account is not created");
+		return;
+	}	
+
+	if (status == CONFIG_LISTENER_STATUS_OK && mode == OFFLINE_MODE) {
+		g_warning ("Subscribe to Other User's Folder is not allowed in Offline mode\n");
+		/* FIXME:
+		   I think throwing an error dialog is not allowed 
+		   because of UI freeze.
+		   e_error_run (NULL, ERROR_DOMAIN ":folder-offline-error", NULL);
+		*/
+		return;
+	}	
 
 	create_folder_subscription_dialog (account->account_name, &user_email_address, &folder_name);
 
Index: exchange-operations.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-operations.c,v
retrieving revision 1.7
diff -u -p -r1.7 exchange-operations.c
--- exchange-operations.c	25 Jul 2005 06:12:03 -0000	1.7
+++ exchange-operations.c	1 Aug 2005 11:08:29 -0000
@@ -61,6 +61,12 @@ e_plugin_lib_enable (EPluginLib *eplib, 
 	return 0;
 }
 
+ExchangeConfigListenerStatus
+exchange_is_offline (gint *mode)
+{	
+	return exchange_config_listener_get_offline_status (exchange_global_config_listener, mode);
+}	
+
 /* FIXME: See if a GLib variant of this function available */
 gboolean
 exchange_operations_tokenize_string (char **string, char *token, char delimit)
Index: exchange-operations.h
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-operations.h,v
retrieving revision 1.5
diff -u -p -r1.5 exchange-operations.h
--- exchange-operations.h	25 Jul 2005 06:12:03 -0000	1.5
+++ exchange-operations.h	1 Aug 2005 11:08:29 -0000
@@ -40,6 +40,7 @@ extern ExchangeConfigListener *exchange_
 int e_plugin_lib_enable (EPluginLib *eplib, int enable);
 
 ExchangeAccount *exchange_operations_get_exchange_account (void);
+ExchangeConfigListenerStatus exchange_is_offline (gint *mode);
 
 gboolean exchange_operations_tokenize_string (char **string, char *token, char delimit);
 


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