aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorSushma Rai <rsushma@src.gnome.org>2006-04-07 00:36:22 +0800
committerSushma Rai <rsushma@src.gnome.org>2006-04-07 00:36:22 +0800
commit9d82014a943e687782d046a4276a0cb6d2a8503c (patch)
tree64f66949758fdd16801a57187a72f28e938a7069 /plugins
parentd9756961e7535fbb00fa9349a27183e9975a2f04 (diff)
downloadgsoc2013-evolution-9d82014a943e687782d046a4276a0cb6d2a8503c.tar.gz
gsoc2013-evolution-9d82014a943e687782d046a4276a0cb6d2a8503c.tar.zst
gsoc2013-evolution-9d82014a943e687782d046a4276a0cb6d2a8503c.zip
Corrected the rename folder operation and also not allowing the rename
of standard folders. Fixes #310433. svn path=/trunk/; revision=31780
Diffstat (limited to 'plugins')
-rw-r--r--plugins/exchange-operations/ChangeLog27
-rw-r--r--plugins/exchange-operations/exchange-calendar.c80
-rw-r--r--plugins/exchange-operations/exchange-contacts.c129
-rw-r--r--plugins/exchange-operations/exchange-folder.c1
-rw-r--r--plugins/exchange-operations/exchange-operations.c2
5 files changed, 190 insertions, 49 deletions
diff --git a/plugins/exchange-operations/ChangeLog b/plugins/exchange-operations/ChangeLog
index 434a4c929d..b67f343aa8 100644
--- a/plugins/exchange-operations/ChangeLog
+++ b/plugins/exchange-operations/ChangeLog
@@ -1,3 +1,30 @@
+2006-04-06 Sushma Rai <rsushma@novell.com>
+
+ * exchange-operations.c (exchange_operations_update_child_esources):
+ Checking for ruri NULL.
+
+ * exchange-folder.c (org_gnome_exchange_check_address_book_subscribed):
+ Freeing uri.
+
+ * exchange-contacts.c (e_exchange_contacts_get_contacts): Defined as
+ static.
+ (e_exchange_contacts_pcontacts): Setting contacts_src_exists for GAL
+ folder.
+ (e_exchange_contacts_check): Checking for new folder creation and also
+ not allowing rename of GAL and Contacts folders.
+ (e_exchange_contacts_commit): Corrected the way relative URI was being
+ constructed during rename operation. Handling the return value of the
+ rename operation.
+
+ * exchange-calendar.c (e_exchange_calendar_get_calendars): Defined as a
+ static function.
+ (e_exchange_calendar_check): Not allowing the rename of standard
+ calendar and tasks folders.
+ (e_exchange_calendar_commit): Corrected the way relative URI was being
+ formed during rename operation. Also, handling the return value of the
+ rename folder operation.
+ Fixes #310433.
+
2006-03-06 Sushma Rai <rsushma@novell.com>
* exchange-config-listener.c
diff --git a/plugins/exchange-operations/exchange-calendar.c b/plugins/exchange-operations/exchange-calendar.c
index 26d0dc8001..a1ae07018b 100644
--- a/plugins/exchange-operations/exchange-calendar.c
+++ b/plugins/exchange-operations/exchange-calendar.c
@@ -47,20 +47,19 @@ enum {
gboolean calendar_src_exists = FALSE;
gchar *calendar_old_source_uri = NULL;
-GPtrArray *e_exchange_calendar_get_calendars (ECalSourceType ftype);
+static GPtrArray *e_exchange_calendar_get_calendars (ECalSourceType ftype);
void e_exchange_calendar_pcalendar_on_change (GtkTreeView *treeview, ESource *source);
GtkWidget *e_exchange_calendar_pcalendar (EPlugin *epl, EConfigHookItemFactoryData *data);
gboolean e_exchange_calendar_check (EPlugin *epl, EConfigHookPageCheckData *data);
void e_exchange_calendar_commit (EPlugin *epl, EConfigTarget *target);
/* FIXME: Reconsider the prototype of this function */
-GPtrArray *
+static GPtrArray *
e_exchange_calendar_get_calendars (ECalSourceType ftype)
{
ExchangeAccount *account;
GPtrArray *folder_array;
GPtrArray *calendar_list;
-
EFolder *folder;
int i, prefix_len;
gchar *type;
@@ -98,9 +97,8 @@ e_exchange_calendar_get_calendars (ECalSourceType ftype)
if (!strcmp (type, tstring)) {
tmp = (gchar *)e_folder_get_physical_uri (folder);
if (g_str_has_prefix (tmp, uri_prefix)) {
- ruri = g_strdup (tmp+prefix_len); /* ATTN: Shouldn't free this explictly */
- printf ("adding ruri : %s\n", ruri);
- g_ptr_array_add (calendar_list, (gpointer)ruri);
+ ruri = g_strdup (tmp+prefix_len);
+ g_ptr_array_add (calendar_list, ruri);
}
}
}
@@ -120,7 +118,7 @@ e_exchange_calendar_pcalendar_on_change (GtkTreeView *treeview, ESource *source)
GtkTreeIter iter;
ExchangeAccount *account;
gchar *es_ruri, *ruri;
-
+
account = exchange_operations_get_exchange_account ();
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
@@ -236,6 +234,7 @@ e_exchange_calendar_pcalendar (EPlugin *epl, EConfigHookItemFactoryData *data)
gtk_table_attach (GTK_TABLE (parent), lbl_size_val, 1, 3, row, row+1, GTK_FILL|GTK_EXPAND, 0, 0, 0);
g_free (folder_size);
}
+
lbl_pcalendar = gtk_label_new_with_mnemonic (_("_Location:"));
gtk_widget_show (lbl_pcalendar);
gtk_misc_set_alignment (GTK_MISC (lbl_pcalendar), 0.0, 0.5);
@@ -314,11 +313,40 @@ e_exchange_calendar_check (EPlugin *epl, EConfigHookPageCheckData *data)
if (base_uri && !strncmp (base_uri, "exchange", 8)) {
if (offline_status == OFFLINE_MODE)
return FALSE;
- if (rel_uri && !strlen (rel_uri)) {
+ if (rel_uri && !strlen (rel_uri))
return FALSE;
- }
}
+ if (!calendar_src_exists) {
+ /* new folder */
+ return TRUE;
+ }
+
+ ExchangeAccount *account;
+ EUri *euri;
+ int uri_len;
+ gchar *uri_text, *uri_string, *path, *folder_name;
+
+ account = exchange_operations_get_exchange_account ();
+ uri_text = e_source_get_uri (t->source);
+ euri = e_uri_new (uri_text);
+ uri_string = e_uri_to_string (euri, FALSE);
+ e_uri_free (euri);
+ uri_len = strlen (uri_string) + 1;
+ g_free (uri_string);
+ path = g_build_filename ("/", uri_text + uri_len, NULL);
+ g_free (uri_text);
+ folder_name = g_strdup (g_strrstr (path, "/") +1);
+ g_free (path);
+
+ if (strcmp (folder_name, e_source_peek_name (t->source)) &&
+ exchange_account_get_standard_uri (account, folder_name)) {
+ /* rename of standard folder */
+ g_free (folder_name);
+ return FALSE;
+ }
+ g_free (folder_name);
+
return TRUE;
}
@@ -372,7 +400,7 @@ e_exchange_calendar_commit (EPlugin *epl, EConfigTarget *target)
gruri = (gchar*) e_source_peek_relative_uri (source);
if (calendar_src_exists) {
- gchar *tmpruri, *uri_string;
+ gchar *tmpruri, *uri_string, *temp_path, *prefix;
EUri *euri;
int uri_len;
@@ -389,35 +417,43 @@ e_exchange_calendar_commit (EPlugin *epl, EConfigTarget *target)
uri_len = strlen (uri_string) + 1;
tmpruri = g_strdup (uri_string + strlen ("exchange://"));
- ruri = g_strconcat (tmpruri, uri_text + uri_len, NULL);
- path = g_build_filename ("/", uri_text + uri_len, NULL);
+ temp_path = g_build_filename ("/", uri_text + uri_len, NULL);
+ prefix = g_strndup (temp_path, strlen (temp_path) - strlen (g_strrstr (temp_path, "/")));
+ g_free (temp_path);
+ path = g_build_filename (prefix, "/", gname, NULL);
+ ruri = g_strconcat (tmpruri, ";", path+1, NULL);
oldpath = g_build_filename ("/", calendar_old_source_uri + prefix_len, NULL);
+ g_free (prefix);
g_free (uri_string);
g_free (tmpruri);
}
else {
+ /* new folder */
ruri = g_strconcat (gruri, "/", gname, NULL);
path = g_build_filename ("/", ruri+prefix_len, NULL);
}
- e_source_set_relative_uri (source, ruri);
- e_source_set_property (source, "username", username);
- e_source_set_property (source, "auth-domain", "Exchange");
- if (authtype) {
- e_source_set_property (source, "auth-type", authtype);
- g_free (authtype);
- }
- e_source_set_property (source, "auth", "1");
if (!calendar_src_exists) {
/* Create the new folder */
result = exchange_account_create_folder (account, path, ftype);
}
- else if (gruri && strcmp (gruri, calendar_old_source_uri) && strcmp (path, oldpath)) {
+ else if (gruri && strcmp (path, oldpath)) {
/* Rename the folder */
result = exchange_account_xfer_folder (account, oldpath, path, TRUE);
- exchange_operations_update_child_esources (source,
+ if (result == EXCHANGE_ACCOUNT_FOLDER_OK) {
+ e_source_set_name (source, gname);
+ e_source_set_relative_uri (source, ruri);
+ e_source_set_property (source, "username", username);
+ e_source_set_property (source, "auth-domain", "Exchange");
+ if (authtype) {
+ e_source_set_property (source, "auth-type", authtype);
+ g_free (authtype);
+ }
+ e_source_set_property (source, "auth", "1");
+ exchange_operations_update_child_esources (source,
calendar_old_source_uri,
ruri);
+ }
}
else {
/* Nothing happened specific to exchange; just return */
diff --git a/plugins/exchange-operations/exchange-contacts.c b/plugins/exchange-operations/exchange-contacts.c
index 506522038d..96ab3793e2 100644
--- a/plugins/exchange-operations/exchange-contacts.c
+++ b/plugins/exchange-operations/exchange-contacts.c
@@ -50,14 +50,14 @@ gboolean contacts_src_exists = FALSE;
gchar *contacts_old_src_uri = NULL;
-GPtrArray *e_exchange_contacts_get_contacts (void);
+static GPtrArray *e_exchange_contacts_get_contacts (void);
void e_exchange_contacts_pcontacts_on_change (GtkTreeView *treeview, ESource *source);
GtkWidget *e_exchange_contacts_pcontacts (EPlugin *epl, EConfigHookItemFactoryData *data);
gboolean e_exchange_contacts_check (EPlugin *epl, EConfigHookPageCheckData *data);
void e_exchange_contacts_commit (EPlugin *epl, EConfigTarget *target);
/* FIXME: Reconsider the prototype of this function */
-GPtrArray *
+static GPtrArray *
e_exchange_contacts_get_contacts (void)
{
ExchangeAccount *account;
@@ -84,8 +84,8 @@ e_exchange_contacts_get_contacts (void)
if (!strcmp (type, "contacts")) {
tmp = (gchar*) e_folder_get_physical_uri (folder);
if (g_str_has_prefix (tmp, uri_prefix)) {
- ruri = g_strdup (tmp+prefix_len); /* ATTN: Should not free this explicitly */
- g_ptr_array_add (contacts_list, (gpointer)ruri);
+ ruri = g_strdup (tmp+prefix_len);
+ g_ptr_array_add (contacts_list, ruri);
}
}
}
@@ -104,7 +104,7 @@ e_exchange_contacts_pcontacts_on_change (GtkTreeView *treeview, ESource *source)
GtkTreeIter iter;
ExchangeAccount *account;
gchar *es_ruri;
-
+
account = exchange_operations_get_exchange_account ();
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
@@ -140,7 +140,7 @@ e_exchange_contacts_pcontacts (EPlugin *epl, EConfigHookItemFactoryData *data)
char *offline_msg;
gint offline_status;
gboolean gal_folder = FALSE;
-
+
if (data->old) {
gtk_widget_destroy (vb_pcontacts);
}
@@ -175,8 +175,10 @@ e_exchange_contacts_pcontacts (EPlugin *epl, EConfigHookItemFactoryData *data)
return vb_offline_msg;
}
- if (gal_folder)
+ if (gal_folder) {
+ contacts_src_exists = TRUE;
return NULL;
+ }
rel_uri = e_source_peek_relative_uri (source);
uid = e_source_peek_uid (source);
@@ -306,14 +308,82 @@ e_exchange_contacts_check (EPlugin *epl, EConfigHookPageCheckData *data)
exchange_config_listener_get_offline_status (exchange_global_config_listener,
&offline_status);
if (base_uri) {
- if (!g_ascii_strncasecmp (base_uri, "exchange", 8) ||
- !g_ascii_strncasecmp (base_uri, "gal", 3)) {
+ if (!g_ascii_strncasecmp (base_uri, "exchange", 8)) {
if (offline_status == OFFLINE_MODE)
return FALSE;
if (rel_uri && !strlen (rel_uri)) {
return FALSE;
}
}
+ else
+ return FALSE;
+ }
+ else {
+ return FALSE;
+ }
+
+ if (!contacts_src_exists) {
+ return TRUE;
+ }
+
+ ExchangeAccount *account;
+ account = exchange_operations_get_exchange_account ();
+
+ if (!rel_uri) {
+ GConfClient *client;
+ ESourceList *source_list = NULL;
+ ESourceGroup *source_group = NULL;
+ GSList *groups;
+ ESource *source;
+
+ /* GAL folder */
+ client = gconf_client_get_default ();
+ source_list = e_source_list_new_for_gconf ( client, CONF_KEY_CONTACTS);
+ g_object_unref (client);
+ groups = e_source_list_peek_groups (source_list);
+
+ if ((source_group = e_source_list_peek_group_by_name (source_list,
+ account->account_name))) {
+ source = e_source_group_peek_source_by_name (source_group, e_source_peek_name (t->source));
+ if (e_source_group_peek_source_by_name (source_group,
+ e_source_peek_name (t->source))) {
+ /* not a rename of GAL */
+ g_object_unref (source_list);
+ return TRUE;
+ }
+ else {
+ g_object_unref (source_list);
+ return FALSE;
+ }
+ }
+ else {
+ g_object_unref (source_list);
+ return FALSE;
+ }
+ }
+ else {
+ EUri *euri;
+ int uri_len;
+ gchar *uri_text, *uri_string, *path, *folder_name;
+
+ uri_text = e_source_get_uri (t->source);
+ euri = e_uri_new (uri_text);
+ uri_string = e_uri_to_string (euri, FALSE);
+ e_uri_free (euri);
+ uri_len = strlen (uri_string) + 1;
+ g_free (uri_string);
+ path = g_build_filename ("/", uri_text + uri_len, NULL);
+ g_free (uri_text);
+ folder_name = g_strdup (g_strrstr (path, "/") +1);
+ g_free (path);
+
+ if (strcmp (folder_name, e_source_peek_name (t->source)) &&
+ exchange_account_get_standard_uri (account, folder_name)) {
+ /* rename of standard folder */
+ g_free (folder_name);
+ return FALSE;
+ }
+ g_free (folder_name);
}
return TRUE;
@@ -335,7 +405,7 @@ e_exchange_contacts_commit (EPlugin *epl, EConfigTarget *target)
if (uri_text && strncmp (uri_text, "exchange", 8)) {
/* here no need of checking for gal */
g_free (uri_text);
- return ;
+ return;
}
exchange_config_listener_get_offline_status (exchange_global_config_listener,
@@ -357,7 +427,7 @@ e_exchange_contacts_commit (EPlugin *epl, EConfigTarget *target)
gruri = (gchar*) e_source_peek_relative_uri (source);
if (contacts_src_exists) {
- gchar *tmpruri, *uri_string;
+ gchar *tmpruri, *uri_string, *temp_path, *prefix;
EUri *euri;
int uri_len;
@@ -367,36 +437,43 @@ e_exchange_contacts_commit (EPlugin *epl, EConfigTarget *target)
uri_len = strlen (uri_string) + 1;
tmpruri = g_strdup (uri_string + strlen ("exchange://"));
- ruri = g_strconcat (tmpruri, uri_text + uri_len, NULL);
- path = g_build_filename ("/", uri_text + uri_len, NULL);
+ temp_path = g_build_filename ("/", uri_text + uri_len, NULL);
+ prefix = g_strndup (temp_path, strlen (temp_path) - strlen (g_strrstr (temp_path, "/")));
+ g_free (temp_path);
+ path = g_build_filename (prefix, "/", gname, NULL);
+ ruri = g_strconcat (tmpruri, ";", path+1, NULL);
oldpath = g_build_filename ("/", contacts_old_src_uri + prefix_len, NULL);
+ g_free (prefix);
g_free (uri_string);
g_free (tmpruri);
}
else {
+ /* new folder */
ruri = g_strconcat (gruri, "/", gname, NULL);
path = g_build_filename ("/", ruri+prefix_len, NULL);
}
- e_source_set_relative_uri (source, ruri);
- e_source_set_property (source, "username", username);
- e_source_set_property (source, "auth-domain", "Exchange");
- if (authtype) {
- e_source_set_property (source, "auth-type", authtype);
- g_free (authtype);
- }
- e_source_set_property (source, "auth", "plain/password");
-
if (!contacts_src_exists) {
/* Create the new folder */
result = exchange_account_create_folder (account, path, "contacts");
}
- else if (gruri && strcmp (gruri, contacts_old_src_uri) && strcmp (path, oldpath)) {
+ else if (gruri && strcmp (path, oldpath )) {
/* Rename the folder */
result = exchange_account_xfer_folder (account, oldpath, path, TRUE);
- exchange_operations_update_child_esources (source,
- contacts_old_src_uri,
- ruri);
+ if (result == EXCHANGE_ACCOUNT_FOLDER_OK) {
+ e_source_set_name (source, gname);
+ e_source_set_relative_uri (source, ruri);
+ e_source_set_property (source, "username", username);
+ e_source_set_property (source, "auth-domain", "Exchange");
+ if (authtype) {
+ e_source_set_property (source, "auth-type", authtype);
+ g_free (authtype);
+ }
+ e_source_set_property (source, "auth", "plain/password");
+ exchange_operations_update_child_esources (source,
+ contacts_old_src_uri,
+ ruri);
+ }
}
else {
/* Nothing happened specific to exchange; just return */
diff --git a/plugins/exchange-operations/exchange-folder.c b/plugins/exchange-operations/exchange-folder.c
index a7669e7d6b..5ff5a2ba42 100644
--- a/plugins/exchange-operations/exchange-folder.c
+++ b/plugins/exchange-operations/exchange-folder.c
@@ -271,6 +271,7 @@ org_gnome_exchange_check_address_book_subscribed (EPlugin *ep, EABPopupTargetSou
uri = e_source_get_uri (source);
path = g_strdup (uri + strlen ("exchange://") + strlen (account->account_filename) + strlen ("/;"));
+ g_free (uri);
sub_folder = strchr (path, '@');
if (!sub_folder) {
diff --git a/plugins/exchange-operations/exchange-operations.c b/plugins/exchange-operations/exchange-operations.c
index 166fba4b11..86d1830388 100644
--- a/plugins/exchange-operations/exchange-operations.c
+++ b/plugins/exchange-operations/exchange-operations.c
@@ -269,7 +269,7 @@ void exchange_operations_update_child_esources (ESource *source, const gchar *ol
for (tsource = sources; tsource != NULL; tsource = tsource->next) {
gchar *ruri;
ruri = (gchar*) e_source_peek_relative_uri (tsource->data);
- if (g_strrstr (ruri, old_path)) {
+ if (ruri && g_strrstr (ruri, old_path)) {
/* This ESource points to one of the child folders */
gchar **tmpv, *truri;
/* A nasty search and replace */