[Commits] account.c 1.61.2.103 1.61.2.104 filtering.c 1.60.2.59 1.60.2.60 filtering.h 1.21.2.20 1.21.2.21 imap_gtk.c 1.1.2.67 1.1.2.68 mh_gtk.c 1.2.2.39 1.2.2.40 prefs_actions.c 1.60.2.77 1.60.2.78 prefs_actions.h 1.5.2.7 1.5.2.8
pawel at claws-mail.org
pawel at claws-mail.org
Thu Nov 24 17:50:14 CET 2011
Update of /home/claws-mail/claws/src
In directory claws-mail:/tmp/cvs-serv30628/src
Modified Files:
Tag: gtk2
account.c filtering.c filtering.h imap_gtk.c mh_gtk.c
prefs_actions.c prefs_actions.h
Log Message:
2011-11-24 [pawel] 3.7.10cvs102
* src/account.c
* src/filtering.c
* src/filtering.h
* src/imap_gtk.c
* src/mh_gtk.c
* src/prefs_actions.c
* src/prefs_actions.h
Implement actions updating on folder/account rename
This fixes bug #2543 'filter actions in actionsrc not
updated upon account renaming'
Index: account.c
===================================================================
RCS file: /home/claws-mail/claws/src/account.c,v
retrieving revision 1.61.2.103
retrieving revision 1.61.2.104
diff -u -d -r1.61.2.103 -r1.61.2.104
--- account.c 22 Nov 2011 19:37:32 -0000 1.61.2.103
+++ account.c 24 Nov 2011 16:50:11 -0000 1.61.2.104
@@ -51,6 +51,7 @@
#include "remotefolder.h"
#include "manual.h"
#include "filtering.h"
+#include "prefs_actions.h"
enum {
ACCOUNT_IS_DEFAULT,
@@ -467,6 +468,7 @@
account_rename_path(old_prefix, new_prefix);
prefs_filtering_rename_path(old_prefix, new_prefix);
+ prefs_actions_rename_path(old_prefix, new_prefix);
g_free(old_prefix);
g_free(new_prefix);
Index: imap_gtk.c
===================================================================
RCS file: /home/claws-mail/claws/src/imap_gtk.c,v
retrieving revision 1.1.2.67
retrieving revision 1.1.2.68
diff -u -d -r1.1.2.67 -r1.1.2.68
--- imap_gtk.c 7 Nov 2011 22:11:45 -0000 1.1.2.67
+++ imap_gtk.c 24 Nov 2011 16:50:11 -0000 1.1.2.68
@@ -298,7 +298,7 @@
new_id = folder_item_get_identifier(item);
prefs_filtering_rename_path(old_id, new_id);
account_rename_path(old_id, new_id);
-
+ prefs_actions_rename_path(old_id, new_id);
g_free(old_id);
g_free(new_id);
Index: filtering.c
===================================================================
RCS file: /home/claws-mail/claws/src/filtering.c,v
retrieving revision 1.60.2.59
retrieving revision 1.60.2.60
diff -u -d -r1.60.2.59 -r1.60.2.60
--- filtering.c 20 Nov 2011 21:06:57 -0000 1.60.2.59
+++ filtering.c 24 Nov 2011 16:50:11 -0000 1.60.2.60
@@ -1126,3 +1126,94 @@
return FALSE;
}
+
+gboolean filtering_action_list_rename_path(GSList *action_list, const gchar *old_path,
+ const gchar *new_path)
+{
+ gchar *base;
+ gchar *prefix;
+ gchar *suffix;
+ gchar *dest_path;
+ gchar *old_path_with_sep;
+ gint destlen;
+ gint prefixlen;
+ gint oldpathlen;
+ GSList * action_cur;
+ const gchar *separator=G_DIR_SEPARATOR_S;
+ gboolean matched = FALSE;
+#ifdef G_OS_WIN32
+again:
+#endif
+ oldpathlen = strlen(old_path);
+ old_path_with_sep = g_strconcat(old_path,separator,NULL);
+
+ for(action_cur = action_list ; action_cur != NULL ;
+ action_cur = action_cur->next) {
+
+ FilteringAction *action = action_cur->data;
+
+ if (action->type == MATCHACTION_SET_TAG ||
+ action->type == MATCHACTION_UNSET_TAG)
+ continue;
+ if (!action->destination)
+ continue;
+
+ destlen = strlen(action->destination);
+
+ if (destlen > oldpathlen) {
+ prefixlen = destlen - oldpathlen;
+ suffix = action->destination + prefixlen;
+
+ if (!strncmp(old_path, suffix, oldpathlen)) {
+ prefix = g_malloc0(prefixlen + 1);
+ strncpy2(prefix, action->destination, prefixlen);
+
+ base = suffix + oldpathlen;
+ while (*base == G_DIR_SEPARATOR) base++;
+ if (*base == '\0')
+ dest_path = g_strconcat(prefix, separator,
+ new_path, NULL);
+ else
+ dest_path = g_strconcat(prefix,
+ separator,
+ new_path,
+ separator,
+ base, NULL);
+
+ g_free(prefix);
+ g_free(action->destination);
+ action->destination = dest_path;
+ matched = TRUE;
+ } else { /* for non-leaf folders */
+ /* compare with trailing slash */
+ if (!strncmp(old_path_with_sep, action->destination, oldpathlen+1)) {
+
+ suffix = action->destination + oldpathlen + 1;
+ dest_path = g_strconcat(new_path, separator,
+ suffix, NULL);
+ g_free(action->destination);
+ action->destination = dest_path;
+ matched = TRUE;
+ }
+ }
+ } else {
+ /* folder-moving a leaf */
+ if (!strcmp(old_path, action->destination)) {
+ dest_path = g_strdup(new_path);
+ g_free(action->destination);
+ action->destination = dest_path;
+ matched = TRUE;
+ }
+ }
+ }
+
+ g_free(old_path_with_sep);
+#ifdef G_OS_WIN32
+ if (!strcmp(separator, G_DIR_SEPARATOR_S) && !matched) {
+ separator = "/";
+ goto again;
+ }
+#endif
+
+ return matched;
+}
Index: filtering.h
===================================================================
RCS file: /home/claws-mail/claws/src/filtering.h,v
retrieving revision 1.21.2.20
retrieving revision 1.21.2.21
diff -u -d -r1.21.2.20 -r1.21.2.21
--- filtering.h 20 Nov 2011 21:06:57 -0000 1.21.2.20
+++ filtering.h 24 Nov 2011 16:50:11 -0000 1.21.2.21
@@ -107,5 +107,7 @@
gboolean filtering_peek_per_account_rules(GSList *filtering_list);
GSList *filtering_action_list_sort(GSList *action_list);
+gboolean filtering_action_list_rename_path(GSList *action_list, const gchar *old_path,
+ const gchar *new_path);
#endif
Index: prefs_actions.h
===================================================================
RCS file: /home/claws-mail/claws/src/prefs_actions.h,v
retrieving revision 1.5.2.7
retrieving revision 1.5.2.8
diff -u -d -r1.5.2.7 -r1.5.2.8
--- prefs_actions.h 16 Feb 2011 07:16:12 -0000 1.5.2.7
+++ prefs_actions.h 24 Nov 2011 16:50:11 -0000 1.5.2.8
@@ -25,5 +25,7 @@
void prefs_actions_read_config (void);
void prefs_actions_write_config (void);
void prefs_actions_open (MainWindow *mainwin);
+void prefs_actions_rename_path (const gchar *old_path,
+ const gchar *new_path);
#endif /* __PREFS_ACTIONS_H__ */
Index: mh_gtk.c
===================================================================
RCS file: /home/claws-mail/claws/src/mh_gtk.c,v
retrieving revision 1.2.2.39
retrieving revision 1.2.2.40
diff -u -d -r1.2.2.39 -r1.2.2.40
--- mh_gtk.c 16 Feb 2011 07:16:10 -0000 1.2.2.39
+++ mh_gtk.c 24 Nov 2011 16:50:11 -0000 1.2.2.40
@@ -282,6 +282,7 @@
new_id = folder_item_get_identifier(item);
prefs_filtering_rename_path(old_id, new_id);
account_rename_path(old_id, new_id);
+ prefs_actions_rename_path(old_id, new_id);
g_free(old_id);
g_free(new_id);
Index: prefs_actions.c
===================================================================
RCS file: /home/claws-mail/claws/src/prefs_actions.c,v
retrieving revision 1.60.2.77
retrieving revision 1.60.2.78
diff -u -d -r1.60.2.77 -r1.60.2.78
--- prefs_actions.c 20 Nov 2011 21:06:57 -0000 1.60.2.77
+++ prefs_actions.c 24 Nov 2011 16:50:11 -0000 1.60.2.78
@@ -1336,3 +1336,31 @@
modified = TRUE;
}
}
+
+void prefs_actions_rename_path(const gchar *old_path, const gchar *new_path)
+{
+ gchar **tokens, *action_str;
+ GSList *action, *action_list;
+
+ for (action = prefs_common.actions_list; action != NULL;
+ action = action->next) {
+ action_str = (gchar *)action->data;
+ tokens = g_strsplit_set(action_str, "{}", 5);
+
+ if (tokens[0] && tokens[1] && *tokens[1] != '\0')
+ action_list = matcher_parser_get_action_list(tokens[1]);
+ else
+ action_list = NULL;
+
+ if (action_list &&
+ filtering_action_list_rename_path(action_list,
+ old_path, new_path)) {
+ g_free(action->data);
+ action->data = g_strconcat(tokens[0], "{",
+ filteringaction_list_to_string(action_list),
+ "}", NULL);
+ }
+
+ g_strfreev(tokens);
+ }
+}
More information about the Commits
mailing list