[evolution-patches] Exchange: Fix for bug 273272
- From: Praveen Kumar <kpraveen novell com>
- To: evolution-patches lists ximian com
- Subject: [evolution-patches] Exchange: Fix for bug 273272
- Date: Fri, 12 Aug 2005 21:42:23 +0530
Hello -
The attached patch fixes the bug 273272 which thrown multiple error
dialogs when Evolution is launched in offline mode in calendar or tasks
component. Please review. Patch is spread across e-d-s, evo, and evo-ex.
Thanks -
Praveen.
Index: servers/exchange/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/exchange/ChangeLog,v
retrieving revision 1.23
diff -u -p -r1.23 ChangeLog
--- servers/exchange/ChangeLog 2 Aug 2005 13:09:54 -0000 1.23
+++ servers/exchange/ChangeLog 12 Aug 2005 15:25:41 -0000
@@ -1,3 +1,11 @@
+2005-08-12 Praveen Kumar <kpraveen novell com>
+
+ * storage/exchange-esource.c
+ (is_offline): Added new
+ (add_folder_esource): Modified to add the calendar and tasks to
+ the selected list only if the account is online. This is a part
+ of the fix to the bug 237272.
+
2005-08-02 Sarfraaz Ahmed <asarfraaz novell com>
* storage/exchange-hierarchy-favorites.c (remove_folder) : Remove
Index: servers/exchange/storage/exchange-esource.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/servers/exchange/storage/exchange-esource.c,v
retrieving revision 1.3
diff -u -p -r1.3 exchange-esource.c
--- servers/exchange/storage/exchange-esource.c 2 Aug 2005 13:09:54 -0000 1.3
+++ servers/exchange/storage/exchange-esource.c 12 Aug 2005 15:25:41 -0000
@@ -30,6 +30,8 @@
#include <stdlib.h>
#include <string.h>
+static gboolean is_offline ();
+
void
add_folder_esource (ExchangeAccount *account,
FolderType folder_type,
@@ -45,8 +47,10 @@ add_folder_esource (ExchangeAccount *acc
const char *offline = NULL;
int mode;
ESourceList *source_list = NULL;
+ gboolean offline_flag;
client = gconf_client_get_default ();
+ offline_flag = is_offline ();
if (folder_type == EXCHANGE_CONTACTS_FOLDER) {
source_list = e_source_list_new_for_gconf ( client,
@@ -129,7 +133,7 @@ add_folder_esource (ExchangeAccount *acc
if (source && !is_contacts_folder) {
/* Select the folder created */
- if (folder_type == EXCHANGE_CALENDAR_FOLDER) {
+ if (folder_type == EXCHANGE_CALENDAR_FOLDER && !offline_flag) {
ids = gconf_client_get_list (client,
CONF_KEY_SELECTED_CAL_SOURCES,
GCONF_VALUE_STRING, NULL);
@@ -141,8 +145,7 @@ add_folder_esource (ExchangeAccount *acc
g_slist_foreach (ids, (GFunc) g_free, NULL);
g_slist_free (ids);
}
- else if (folder_type == EXCHANGE_TASKS_FOLDER) {
-
+ else if (folder_type == EXCHANGE_TASKS_FOLDER && !offline_flag) {
ids = gconf_client_get_list (client,
CONF_KEY_SELECTED_TASKS_SOURCES,
GCONF_VALUE_STRING, NULL);
@@ -282,4 +285,21 @@ remove_folder_esource (ExchangeAccount *
}
g_object_unref (source_list);
g_object_unref (client);
+}
+
+static gboolean
+is_offline ()
+{
+ GConfClient *client;
+ GConfValue *value;
+ gboolean offline = FALSE;
+
+ client = gconf_client_get_default ();
+ value = gconf_client_get (client,
+ "/apps/evolution/shell/start_offline", NULL);
+ if (value)
+ offline = gconf_value_get_bool (value);
+
+ g_object_unref (client);
+ return offline;
}
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-exchange/ChangeLog,v
retrieving revision 1.369
diff -u -p -r1.369 ChangeLog
--- ChangeLog 9 Aug 2005 08:15:40 -0000 1.369
+++ ChangeLog 12 Aug 2005 16:02:16 -0000
@@ -1,3 +1,21 @@
+2005-08-12 Praveen Kumar <kpraveen novell com>
+
+ * calendar/e-cal-backend-exchange.c:
+ (open_calendar): Remove the warning dialog as all UI stuff will
+ be handled by the plugin. Fix for the bug 273272.
+
+
2005-08-08 Sarfraaz Ahmed <asarfraaz novell com>
* configure.in : Bumped the version to 2.3.7
Index: calendar/e-cal-backend-exchange.c
===================================================================
RCS file: /cvs/gnome/evolution-exchange/calendar/e-cal-backend-exchange.c,v
retrieving revision 1.37
diff -u -p -r1.37 e-cal-backend-exchange.c
--- calendar/e-cal-backend-exchange.c 28 Jul 2005 06:00:01 -0000 1.37
+++ calendar/e-cal-backend-exchange.c 12 Aug 2005 16:02:16 -0000
@@ -307,7 +307,6 @@ open_calendar (ECalBackendSync *backend,
display_contents = e_source_get_property (source, "offline_sync");
if (!display_contents || !g_str_equal (display_contents, "1")) {
- e_cal_backend_notify_error (E_CAL_BACKEND (cbex), _("Folder not marked for offline support"));
return GNOME_Evolution_Calendar_RepositoryOffline;
}
Index: plugins/exchange-operations/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/ChangeLog,v
retrieving revision 1.43
diff -u -p -r1.43 ChangeLog
--- plugins/exchange-operations/ChangeLog 8 Aug 2005 05:54:26 -0000 1.43
+++ plugins/exchange-operations/ChangeLog 12 Aug 2005 16:05:35 -0000
@@ -1,3 +1,26 @@
+2005-09-12 Praveen Kumar <kpraveen novell com>
+
+ * exchange-config-listener.c
+ (remove_selected_non_offline_esources): Added new
+ (add_account_esources): Don't add the calendars and tasks in the
+ selected list
+ (account_added): If starting in offline mode remove the non-offline
+ calendars and tasks from the selected list so that it doesn't
+ throws an error
+
+ Fixes the bug 273272.
+
+2005-08-11 Praveen Kumar <kpraveen novell com>
+
+ * exchange-config-listener.c
+ (exchange_camel_urls_is_equal): Added new
+ (exchange_modify_esource_group_name): Added new
+ (account_changed): Handle most of the account parameter changes
+ without restart. This fixes bug 272784 and partially bug 220168
+ (account_removed): Removed the message dialog that says that the
+ changes will be reflected after restart. This partially fixes the
+ bug 220168
+
2005-08-08 Arunprakash <arunp novell com>
* exchange-folder-size-display.c: Included glib/gi18n.h file for
Index: plugins/exchange-operations/exchange-config-listener.c
===================================================================
RCS file: /cvs/gnome/evolution/plugins/exchange-operations/exchange-config-listener.c,v
retrieving revision 1.10
diff -u -p -r1.10 exchange-config-listener.c
--- plugins/exchange-operations/exchange-config-listener.c 3 Aug 2005 09:58:28 -0000 1.10
+++ plugins/exchange-operations/exchange-config-listener.c 12 Aug 2005 16:05:36 -0000
@@ -35,6 +35,7 @@
#include <e-folder-exchange.h>
#include <e2k-marshal.h>
#include <e2k-uri.h>
+#include <camel/camel-url.h>
#include <e-util/e-error.h>
@@ -85,9 +86,13 @@ static void account_changed (EAccountLis
EAccount *account);
static void account_removed (EAccountList *account_listener,
EAccount *account);
-
static void exchange_add_autocompletion_folders (GConfClient *gc_client,
ExchangeAccount *account);
+static gboolean exchange_camel_urls_is_equal (const gchar *url1,
+ const gchar *url2);
+static void exchange_modify_esource_group_name (const char *old_name,
+ const char *new_name);
+static void remove_selected_non_offline_esources (ExchangeAccount *account);
static void
class_init (GObjectClass *object_class)
@@ -299,42 +304,45 @@ add_account_esources (ExchangeAccount *a
e_source_group_add_source (cal_source_group,
source, -1);
- ids = gconf_client_get_list (client,
- CONF_KEY_SELECTED_CAL_SOURCES,
- GCONF_VALUE_STRING, NULL);
- ids = g_slist_append (ids,
- g_strdup (e_source_peek_uid (source)));
- gconf_client_set_list (client,
- CONF_KEY_SELECTED_CAL_SOURCES,
- GCONF_VALUE_STRING, ids, NULL);
- g_slist_foreach (ids, (GFunc) g_free, NULL);
- g_slist_free (ids);
+/* g_print ("!!!Selecting C EP\n"); */
+
+/* ids = gconf_client_get_list (client, */
+/* CONF_KEY_SELECTED_CAL_SOURCES, */
+/* GCONF_VALUE_STRING, NULL); */
+/* ids = g_slist_append (ids, */
+/* g_strdup (e_source_peek_uid (source))); */
+/* gconf_client_set_list (client, */
+/* CONF_KEY_SELECTED_CAL_SOURCES, */
+/* GCONF_VALUE_STRING, ids, NULL); */
+/* g_slist_foreach (ids, (GFunc) g_free, NULL); */
+/* g_slist_free (ids); */
g_object_unref (source);
g_free (relative_uri);
+
}
else if (folder->type == EXCHANGE_TASKS_FOLDER){
relative_uri = g_strdup (folder->uri +
strlen (EXCHANGE_URI_PREFIX));
source = e_source_new (folder->name, relative_uri);
- if (offline_mode)
+ if (offline_mode == ONLINE_MODE)
e_source_set_property (source, "offline_sync", "1");
if (username)
e_source_set_property (source, "username", username);
e_source_group_add_source (tasks_source_group,
source, -1);
- ids = gconf_client_get_list (client,
- CONF_KEY_SELECTED_TASKS_SOURCES,
- GCONF_VALUE_STRING, NULL);
-
- ids = g_slist_append (ids,
- g_strdup (e_source_peek_uid (source)));
- gconf_client_set_list (client,
- CONF_KEY_SELECTED_TASKS_SOURCES,
- GCONF_VALUE_STRING, ids, NULL);
- g_slist_foreach (ids, (GFunc) g_free, NULL);
- g_slist_free (ids);
+/* g_print ("!!!Selecting T EP\n"); */
+/* ids = gconf_client_get_list (client, */
+/* CONF_KEY_SELECTED_TASKS_SOURCES, */
+/* GCONF_VALUE_STRING, NULL); */
+/* ids = g_slist_append (ids, */
+/* g_strdup (e_source_peek_uid (source))); */
+/* gconf_client_set_list (client, */
+/* CONF_KEY_SELECTED_TASKS_SOURCES, */
+/* GCONF_VALUE_STRING, ids, NULL); */
+/* g_slist_foreach (ids, (GFunc) g_free, NULL); */
+/* g_slist_free (ids); */
g_object_unref (source);
g_free (relative_uri);
}
@@ -546,11 +554,10 @@ remove_account_esource (ExchangeAccount
g_slist_free (ids);
}
}
- e_source_list_remove_group (source_list, group);
- e_source_list_sync (source_list, NULL);
- found_group = TRUE;
- break;
}
+ e_source_list_remove_group (source_list, group);
+ e_source_list_sync (source_list, NULL);
+ found_group = TRUE;
}
}
g_object_unref (source_list);
@@ -571,8 +578,10 @@ static void
account_added (EAccountList *account_list, EAccount *account)
{
ExchangeConfigListener *config_listener;
+ ExchangeConfigListenerStatus cl_status;
ExchangeAccount *exchange_account;
ExchangeAccountResult result;
+ gint is_offline;
if (!is_active_exchange_account (account))
return;
@@ -609,7 +618,13 @@ account_added (EAccountList *account_lis
g_signal_emit (config_listener, signals[EXCHANGE_ACCOUNT_CREATED], 0,
exchange_account);
- add_sources (exchange_account);
+/* add_sources (exchange_account); */
+
+ exchange_config_listener_get_offline_status (config_listener, &is_offline);
+ if (is_offline == OFFLINE_MODE) {
+ remove_selected_non_offline_esources (exchange_account);
+ }
+
exchange_account_connect (exchange_account, NULL, &result);
if (result != EXCHANGE_ACCOUNT_CONNECT_SUCCESS)
exchange_operations_report_error (exchange_account, result);
@@ -716,7 +731,12 @@ account_changed (EAccountList *account_l
return;
}
- if (!strcmp (config_listener->priv->configured_uri, account->source->url) &&
+ /* FIXME: The order of the parameters in the Camel URL string is not in
+ * order for the two given strings. So, we will not be able to use
+ * plain string comparison. Instead compare the parameters one by one.
+ */
+ if (exchange_camel_urls_is_equal (config_listener->priv->configured_uri,
+ account->source->url) &&
!strcmp (config_listener->priv->configured_name, account->name)) {
/* The user changed something we don't care about. */
return;
@@ -750,30 +770,22 @@ account_changed (EAccountList *account_l
* could be due to change in hostname or some parameter value,
* remove old e-sources
*/
- if (strcmp (config_listener->priv->configured_uri, account->source->url)) {
- /* This condition will be true always as order of parameters in
- * configured_uri and source->url will not match
- */
+ if (requires_relogin (config_listener->priv->configured_uri,
+ account->source->url)) {
remove_account_esources (priv->exchange_account);
-
- /* Ask user to authenticate at next login if username, hostname,
- * OWA URL or GC server values are changed.
- */
- if (requires_relogin (config_listener->priv->configured_uri,
- account->source->url)) {
- exchange_account_forget_password (priv->exchange_account);
- }
- else {
- /* FIXME: modify esources and don't ask for re-login */
- /* modify_esource (priv->exchange_account,
- * account->source->url);
- * return;
- */
- }
+ exchange_account_forget_password (priv->exchange_account);
+ } else if (strcmp (config_listener->priv->configured_name, account->name)) {
+/* remove_account_esources (priv->exchange_account); */
+ exchange_modify_esource_group_name (config_listener->priv->configured_name,
+ account->name);
+ g_free (config_listener->priv->configured_name);
+ config_listener->priv->configured_name = g_strdup (account->name);
+ return;
+ } else {
+ /* FIXME: Do ESources need to be modified? */
+ return;
}
- else if (strcmp (config_listener->priv->configured_name, account->name))
- remove_account_esources (priv->exchange_account);
-
+
/* Nope. Let the user know we're ignoring him. */
e_error_run (NULL, "org-gnome-exchange-operations:apply-restart", NULL);
@@ -782,8 +794,6 @@ account_changed (EAccountList *account_l
*/
g_free (config_listener->priv->configured_uri);
config_listener->priv->configured_uri = g_strdup (account->source->url);
- g_free (config_listener->priv->configured_name);
- config_listener->priv->configured_name = g_strdup (account->name);
}
static void
@@ -817,15 +827,7 @@ account_removed (EAccountList *account_l
priv->configured_uri = NULL;
g_free (priv->configured_name);
priv->configured_name = NULL;
- } else {
- if (account->enabled) {
- e_error_run (NULL, "org-gnome-exchange-operations:remove-quit", NULL);
- }
- else {
- /* The account is in use. We can't remove it. */
- e_error_run (NULL, "org-gnome-exchange-operations:disable-quit", NULL);
- }
- }
+ }
}
static gboolean
@@ -947,4 +949,253 @@ exchange_add_autocompletion_folders (GCo
found_group = TRUE;
}
}
+
+ g_object_unref (sl);
+}
+
+
+/**
+ * exchange_camel_urls_is_equal
+ *
+ * @url1: CAMEL URL string 1
+ * @url2: CAMEL URL string 2
+ *
+ * This function checks if the parameters present in two given CAMEL URLS are
+ * identical and returns the result.
+ *
+ * Return Value: Boolean result of the comparision.
+ *
+ **/
+static gboolean
+exchange_camel_urls_is_equal (const gchar *url1, const gchar *url2)
+{
+ CamelURL *curl1, *curl2;
+ gchar *param1, *param2;
+ const char *params[] = {
+ "auth",
+ "owa_url",
+ "owa_path",
+ "mailbox",
+ "ad_server",
+ };
+ const int n_params = 5;
+ int i;
+
+ curl1 = camel_url_new (url1, NULL);
+ curl2 = camel_url_new (url2, NULL);
+
+ for (i = 0; i < n_params; ++i) {
+ param1 = (gchar*) camel_url_get_param (curl1, params[i]);
+ param2 = (gchar*) camel_url_get_param (curl2, params[i]);
+ if ((param1 && !param2) || (!param1 && param2) || /* Missing */
+ (param1 && param2 && strcmp (param1, param2))) { /* Differing */
+ g_free (param1);
+ g_free (param2);
+ g_free (curl1);
+ g_free (curl2);
+ return FALSE;
+ }
+ g_free (param1);
+ g_free (param2);
+ }
+ g_free (curl1);
+ g_free (curl2);
+ return TRUE;
+}
+
+/**
+ * exchange_modify_esource_group_name
+ *
+ * @old_name: Old name of the ESourceGroup
+ * @new_name: New name of the ESourceGroup
+ *
+ * This function modifies the old source group name to the specified new
+ * source group name
+ **/
+static void
+exchange_modify_esource_group_name (const char *old_name, const char *new_name)
+{
+ GConfClient *client;
+ ESourceGroup *group;
+ GSList *groups;
+ ESourceList *c_source_list = NULL, *t_source_list = NULL,
+ *a_source_list = NULL;
+
+ client = gconf_client_get_default ();
+
+ c_source_list = e_source_list_new_for_gconf ( client, CONF_KEY_CAL);
+ t_source_list = e_source_list_new_for_gconf ( client, CONF_KEY_TASKS);
+ a_source_list = e_source_list_new_for_gconf ( client, CONF_KEY_CONTACTS);
+
+ groups = e_source_list_peek_groups (c_source_list);
+
+ for ( ; groups != NULL; groups = g_slist_next (groups)) {
+ group = E_SOURCE_GROUP (groups->data);
+ if (!strcmp (e_source_group_peek_name (group), old_name)) {
+ e_source_group_set_name (group, new_name);
+ break;
+ }
+ }
+
+ groups = e_source_list_peek_groups (t_source_list);
+
+ for ( ; groups != NULL; groups = g_slist_next (groups)) {
+ group = E_SOURCE_GROUP (groups->data);
+ if (!strcmp (e_source_group_peek_name (group), old_name)) {
+ e_source_group_set_name (group, new_name);
+ break;
+ }
+ }
+
+ groups = e_source_list_peek_groups (a_source_list);
+
+ for ( ; groups != NULL; groups = g_slist_next (groups)) {
+ group = E_SOURCE_GROUP (groups->data);
+ if (!strcmp (e_source_group_peek_name (group), old_name)) {
+ e_source_group_set_name (group, new_name);
+ break;
+ }
+ }
+
+ e_source_list_sync (c_source_list, NULL);
+ e_source_list_sync (t_source_list, NULL);
+ e_source_list_sync (a_source_list, NULL);
+
+ g_object_unref (c_source_list);
+ g_object_unref (t_source_list);
+ g_object_unref (a_source_list);
+ g_object_unref (client);
+
+}
+
+static void
+remove_selected_non_offline_esources (ExchangeAccount *account)
+{
+ ESourceGroup *group;
+ ESource *source = NULL;
+ GSList *groups;
+ GSList *sources;
+ GSList *ids, *node_to_be_deleted;
+ gboolean found_group;
+ const char *source_uid;
+ GConfClient *client;
+ ESourceList *c_source_list = NULL, *t_source_list=NULL;
+ char *offline_mode=NULL;
+
+ client = gconf_client_get_default ();
+
+ c_source_list = e_source_list_new_for_gconf ( client, CONF_KEY_CAL);
+ t_source_list = e_source_list_new_for_gconf ( client, CONF_KEY_TASKS);
+
+ groups = e_source_list_peek_groups (c_source_list);
+ found_group = FALSE;
+
+ g_print ("Delete selected sources.\n");
+
+ for ( ; groups != NULL && !found_group; groups = g_slist_next (groups)) {
+ group = E_SOURCE_GROUP (groups->data);
+
+ if (strcmp (e_source_group_peek_name (group), account->account_name) == 0
+ &&
+ strcmp (e_source_group_peek_base_uri (group), EXCHANGE_URI_PREFIX) == 0) {
+ sources = e_source_group_peek_sources (group);
+
+ for( ; sources != NULL; sources = g_slist_next (sources)) {
+ source = E_SOURCE (sources->data);
+ source_uid = e_source_peek_uid (source);
+
+ /* Remove from the selected folders */
+ ids = gconf_client_get_list (client,
+ CONF_KEY_SELECTED_CAL_SOURCES ,
+ GCONF_VALUE_STRING, NULL);
+ if (ids) {
+ offline_mode = (gchar*) e_source_get_property (source,
+ "offline_sync");
+ while (1) {
+
+ node_to_be_deleted =
+ g_slist_find_custom (ids,
+ source_uid,
+ (GCompareFunc) strcmp);
+ if (!node_to_be_deleted) {
+ break;
+ }
+ if (!offline_mode ||
+ (offline_mode && strcmp (offline_mode, "1"))) {
+ g_print ("Deleting a selected calendar.\n");
+ g_free (node_to_be_deleted->data);
+ ids = g_slist_delete_link (ids,
+ node_to_be_deleted);
+ gconf_client_set_list (client,
+ CONF_KEY_SELECTED_CAL_SOURCES,
+ GCONF_VALUE_STRING, ids, NULL);
+ }
+ }
+ g_slist_foreach (ids, (GFunc) g_free, NULL);
+ g_slist_free (ids);
+ g_free (offline_mode);
+
+ }
+ }
+ found_group = TRUE;
+ e_source_list_sync (c_source_list, NULL);
+ }
+ }
+
+ groups = e_source_list_peek_groups (t_source_list);
+ found_group = FALSE;
+
+ for ( ; groups != NULL && !found_group; groups = g_slist_next (groups)) {
+ group = E_SOURCE_GROUP (groups->data);
+
+ if (strcmp (e_source_group_peek_name (group), account->account_name) == 0
+ &&
+ strcmp (e_source_group_peek_base_uri (group), EXCHANGE_URI_PREFIX) == 0) {
+ sources = e_source_group_peek_sources (group);
+
+ for( ; sources != NULL; sources = g_slist_next (sources)) {
+ source = E_SOURCE (sources->data);
+ source_uid = e_source_peek_uid (source);
+
+ /* Remove from the selected folders */
+ ids = gconf_client_get_list (client,
+ CONF_KEY_SELECTED_TASKS_SOURCES,
+ GCONF_VALUE_STRING, NULL);
+ if (ids) {
+ offline_mode = (gchar*) e_source_get_property (source,
+ "offline_sync");
+ while (1) {
+
+ node_to_be_deleted =
+ g_slist_find_custom (ids,
+ source_uid,
+ (GCompareFunc) strcmp);
+ if (!node_to_be_deleted) {
+ break;
+ }
+ if (!offline_mode ||
+ (offline_mode && strcmp (offline_mode, "1"))) {
+ g_print ("Deleting a selected tasklist.\n");
+ g_free (node_to_be_deleted->data);
+ ids = g_slist_delete_link (ids,
+ node_to_be_deleted);
+ gconf_client_set_list (client,
+ CONF_KEY_SELECTED_TASKS_SOURCES,
+ GCONF_VALUE_STRING, ids, NULL);
+ }
+ }
+ g_slist_foreach (ids, (GFunc) g_free, NULL);
+ g_slist_free (ids);
+ g_free (offline_mode);
+ }
+ }
+ found_group = TRUE;
+ e_source_list_sync (t_source_list, NULL);
+ }
+ }
+
+ g_object_unref (c_source_list);
+ g_object_unref (t_source_list);
+ g_object_unref (client);
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]