diff options
author | Not Zed <NotZed@Ximian.com> | 2002-05-08 14:36:28 +0800 |
---|---|---|
committer | Michael Zucci <zucchi@src.gnome.org> | 2002-05-08 14:36:28 +0800 |
commit | d616d97a3ef8a1202933ba2000b363d0dcb69d3d (patch) | |
tree | b6c946427a68bf9f5733fc1f6f32a2cb1aff00bf /filter/filter-context.c | |
parent | 8accbe54edf3b9f2b1d6ebcaf8b06d796fef1ec6 (diff) | |
download | gsoc2013-evolution-d616d97a3ef8a1202933ba2000b363d0dcb69d3d.tar gsoc2013-evolution-d616d97a3ef8a1202933ba2000b363d0dcb69d3d.tar.gz gsoc2013-evolution-d616d97a3ef8a1202933ba2000b363d0dcb69d3d.tar.bz2 gsoc2013-evolution-d616d97a3ef8a1202933ba2000b363d0dcb69d3d.tar.lz gsoc2013-evolution-d616d97a3ef8a1202933ba2000b363d0dcb69d3d.tar.xz gsoc2013-evolution-d616d97a3ef8a1202933ba2000b363d0dcb69d3d.tar.zst gsoc2013-evolution-d616d97a3ef8a1202933ba2000b363d0dcb69d3d.zip |
Changed to return a GList *, a list of the names of the rules affected by
2002-05-08 Not Zed <NotZed@Ximian.com>
* rule-context.c (rule_context_delete_uri): Changed to return a
GList *, a list of the names of the rules affected by the delete,
fixed all implementors.
(rule_context_rename_uri): Similarly for delete_uri, for
api consistency.
(rule_context_free_uri_list): Util function to free the return
from above.
* filter-context.c (filter_delete_uri): Actually implement it, fix
for #18826, and some related bugs.
svn path=/trunk/; revision=16718
Diffstat (limited to 'filter/filter-context.c')
-rw-r--r-- | filter/filter-context.c | 78 |
1 files changed, 66 insertions, 12 deletions
diff --git a/filter/filter-context.c b/filter/filter-context.c index 2f77fbe2f5..cb049d6093 100644 --- a/filter/filter-context.c +++ b/filter/filter-context.c @@ -33,14 +33,14 @@ /* For poking into filter-folder guts */ #include "filter-folder.h" -#define d(x) +#define d(x) static void filter_context_class_init (FilterContextClass *class); static void filter_context_init (FilterContext *gspaper); static void filter_context_finalise (GtkObject *obj); -static int filter_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); -static int filter_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp); +static GList *filter_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); +static GList *filter_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp); #define _PRIVATE(x) (((FilterContext *)(x))->priv) @@ -165,13 +165,14 @@ FilterPart *filter_context_next_action(FilterContext *f, FilterPart *last) } /* We search for any folders in our actions list that need updating, update them */ -static int filter_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp) +static GList *filter_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp) { FilterRule *rule; GList *l, *el; FilterPart *action; FilterElement *element; int count = 0; + GList *changed = NULL; d(printf("uri '%s' renamed to '%s'\n", olduri, newuri)); @@ -208,23 +209,76 @@ static int filter_rename_uri(RuleContext *f, const char *olduri, const char *new l = l->next; } - if (rulecount) + if (rulecount) { + changed = g_list_append(changed, g_strdup(rule->name)); filter_rule_emit_changed(rule); + } count += rulecount; } - return count + parent_class->rename_uri(f, olduri, newuri, cmp); + /* might need to call parent class, if it did anything ... parent_class->rename_uri(f, olduri, newuri, cmp); */ + + return changed; } -static int filter_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp) +static GList *filter_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp) { - /* We basically should do similar to above, but when we find it, - Remove the action, and if thats the last action, remove the rule? */ + /* We basically do similar to above, but when we find it, + Remove the action, and if thats the last action, this might create an empty rule? remove the rule? */ + + FilterRule *rule; + GList *l, *el; + FilterPart *action; + FilterElement *element; + int count = 0; + GList *deleted = NULL; + + d(printf("uri '%s' deleted\n", uri)); + + /* For all rules, for all actions, for all elements, check deleted folder elements */ + /* Yes we could do this inside each part itself, but not today */ + rule = NULL; + while ( (rule = rule_context_next_rule(f, rule, NULL)) ) { + int recorded = 0; + + d(printf("checking rule '%s'\n", rule->name)); + + l = FILTER_FILTER(rule)->actions; + while (l) { + action = l->data; + + d(printf("checking action '%s'\n", action->name)); + + el = action->elements; + while (el) { + element = el->data; + + d(printf("checking element '%s'\n", element->name)); + if (IS_FILTER_FOLDER(element)) + d(printf(" is folder, existing uri = '%s'\n", FILTER_FOLDER(element)->uri)); + + if (IS_FILTER_FOLDER(element) + && cmp(((FilterFolder *)element)->uri, uri)) { + d(printf(" Deleted!\n")); + /* check if last action, if so, remove rule instead? */ + l = l->next; + filter_filter_remove_action((FilterFilter *)rule, action); + gtk_object_unref((GtkObject *)action); + count++; + if (!recorded) + deleted = g_list_append(deleted, g_strdup(rule->name)); + goto next_action; + } + el = el->next; + } + l = l->next; + next_action: + } + } - /* But i'm not confident the rest of the mailer wont accidentlly delete - something which was just temporarily not available. */ + /* TODO: could call parent and merge lists */ - return parent_class->delete_uri(f, uri, cmp); + return deleted; } |