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 | |
parent | 8accbe54edf3b9f2b1d6ebcaf8b06d796fef1ec6 (diff) | |
download | gsoc2013-evolution-d616d97a3ef8a1202933ba2000b363d0dcb69d3d.tar.gz 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')
-rw-r--r-- | filter/ChangeLog | 13 | ||||
-rw-r--r-- | filter/filter-context.c | 78 | ||||
-rw-r--r-- | filter/libfilter-i18n.h | 36 | ||||
-rw-r--r-- | filter/rule-context.c | 31 | ||||
-rw-r--r-- | filter/rule-context.h | 10 |
5 files changed, 126 insertions, 42 deletions
diff --git a/filter/ChangeLog b/filter/ChangeLog index 29c408637d..beaecec429 100644 --- a/filter/ChangeLog +++ b/filter/ChangeLog @@ -1,3 +1,16 @@ +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. + 2002-04-26 Jeffrey Stedfast <fejj@ximian.com> * Makefile.am: Get rid of ibex stuff, we no longer use it. 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; } diff --git a/filter/libfilter-i18n.h b/filter/libfilter-i18n.h index 6d9828a52f..864e9644cc 100644 --- a/filter/libfilter-i18n.h +++ b/filter/libfilter-i18n.h @@ -4,34 +4,18 @@ char *s = N_("Assign Color"); char *s = N_("Assign Score"); char *s = N_("Attachments"); char *s = N_("Beep"); -char *s = N_("contains"); char *s = N_("Copy to Folder"); char *s = N_("Date received"); char *s = N_("Date sent"); char *s = N_("Delete"); char *s = N_("Deleted"); -char *s = N_("does not contain"); -char *s = N_("does not end with"); -char *s = N_("does not exist"); -char *s = N_("does not sound like"); -char *s = N_("does not start with"); char *s = N_("Do Not Exist"); char *s = N_("Draft"); -char *s = N_("ends with"); char *s = N_("Execute Shell Command"); char *s = N_("Exist"); -char *s = N_("exists"); char *s = N_("Expression"); char *s = N_("Follow Up"); char *s = N_("Important"); -char *s = N_("is"); -char *s = N_("is after"); -char *s = N_("is before"); -char *s = N_("is Flagged"); -char *s = N_("is greater than"); -char *s = N_("is less than"); -char *s = N_("is not"); -char *s = N_("is not Flagged"); char *s = N_("Mailing list"); char *s = N_("Message Body"); char *s = N_("Message Header"); @@ -45,10 +29,26 @@ char *s = N_("Score"); char *s = N_("Sender"); char *s = N_("Set Status"); char *s = N_("Size (kB)"); -char *s = N_("sounds like"); char *s = N_("Source Account"); char *s = N_("Specific header"); -char *s = N_("starts with"); char *s = N_("Status"); char *s = N_("Stop Processing"); char *s = N_("Subject"); +char *s = N_("contains"); +char *s = N_("does not contain"); +char *s = N_("does not end with"); +char *s = N_("does not exist"); +char *s = N_("does not sound like"); +char *s = N_("does not start with"); +char *s = N_("ends with"); +char *s = N_("exists"); +char *s = N_("is Flagged"); +char *s = N_("is after"); +char *s = N_("is before"); +char *s = N_("is greater than"); +char *s = N_("is less than"); +char *s = N_("is not Flagged"); +char *s = N_("is not"); +char *s = N_("is"); +char *s = N_("sounds like"); +char *s = N_("starts with"); diff --git a/filter/rule-context.c b/filter/rule-context.c index d11e4ec722..18939a0041 100644 --- a/filter/rule-context.c +++ b/filter/rule-context.c @@ -38,8 +38,8 @@ static int load(RuleContext * f, const char *system, const char *user); static int save(RuleContext * f, const char *user); -static int rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); -static int delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp); +static GList *rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); +static GList *delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp); static void rule_context_class_init(RuleContextClass * class); static void rule_context_init(RuleContext * gspaper); @@ -652,28 +652,43 @@ rule_context_find_rank_rule (RuleContext *f, int rank, const char *source) return NULL; } -static int +static GList * delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp) { - return 0; + return NULL; } -int +GList * rule_context_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp) { return ((RuleContextClass *) ((GtkObject *) f)->klass)->delete_uri(f, uri, cmp); } -static int +static GList * rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp) { - return 0; + return NULL; } -int +GList * rule_context_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp) { return ((RuleContextClass *) ((GtkObject *) f)->klass)->rename_uri (f, olduri, newuri, cmp); } +void +rule_context_free_uri_list(RuleContext *f, GList *uris) +{ + GList *l = uris, *n; + + /* TODO: should be virtual */ + + while (l) { + n = l->next; + g_free(l->data); + g_list_free_1(l); + l = n; + } +} + diff --git a/filter/rule-context.h b/filter/rule-context.h index 982129b216..56c1bb491e 100644 --- a/filter/rule-context.h +++ b/filter/rule-context.h @@ -61,8 +61,8 @@ struct _RuleContextClass { int (*load)(RuleContext *f, const char *system, const char *user); int (*save)(RuleContext *f, const char *user); - int (*delete_uri)(RuleContext *f, const char *uri, GCompareFunc cmp); - int (*rename_uri)(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); + GList *(*delete_uri)(RuleContext *f, const char *uri, GCompareFunc cmp); + GList *(*rename_uri)(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); /* signals */ void (*rule_added)(RuleContext *f, FilterRule *rule); @@ -117,8 +117,10 @@ void rule_context_add_part_set(RuleContext *f, const char *setname, int part_ty void rule_context_add_rule_set(RuleContext *f, const char *setname, int rule_type, RCRuleFunc append, RCNextRuleFunc next); /* uri's disappear/renamed externally */ -int rule_context_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp); -int rule_context_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); +GList *rule_context_delete_uri(RuleContext *f, const char *uri, GCompareFunc cmp); +GList *rule_context_rename_uri(RuleContext *f, const char *olduri, const char *newuri, GCompareFunc cmp); + +void rule_context_free_uri_list(RuleContext *f, GList *uris); #endif /* ! _RULE_CONTEXT_H */ |