From fc1c52175d824161b80938872b20b436e5b5a115 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 29 Jul 2002 05:24:22 +0000 Subject: New filter action to unset a system flag. The exact opposite of set_flag. 2002-07-29 Jeffrey Stedfast * camel-filter-driver.c (unset_flag): New filter action to unset a system flag. The exact opposite of set_flag. svn path=/trunk/; revision=17625 --- camel/ChangeLog | 5 +++++ camel/camel-filter-driver.c | 55 ++++++++++++++++++++++++++++++++------------- 2 files changed, 44 insertions(+), 16 deletions(-) (limited to 'camel') diff --git a/camel/ChangeLog b/camel/ChangeLog index 9242a0f964..93e7d05792 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,8 @@ +2002-07-29 Jeffrey Stedfast + + * camel-filter-driver.c (unset_flag): New filter action to unset a + system flag. The exact opposite of set_flag. + 2002-07-26 Jeffrey Stedfast * providers/local/camel-local-store.c (get_folder): If the path diff --git a/camel/camel-filter-driver.c b/camel/camel-filter-driver.c index 09b138f99b..eef5c2fa9e 100644 --- a/camel/camel-filter-driver.c +++ b/camel/camel-filter-driver.c @@ -134,7 +134,8 @@ static ESExpResult *do_move (struct _ESExp *f, int argc, struct _ESExpResult **a static ESExpResult *do_stop (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *); static ESExpResult *do_colour (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *); static ESExpResult *do_score (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *); -static ESExpResult *do_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *); +static ESExpResult *set_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *); +static ESExpResult *unset_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *); static ESExpResult *do_shell (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *); static ESExpResult *do_beep (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *); static ESExpResult *play_sound (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *); @@ -147,18 +148,19 @@ static struct { int type; /* set to 1 if a function can perform shortcut evaluation, or doesn't execute everything, 0 otherwise */ } symbols[] = { - { "delete", (ESExpFunc *) do_delete, 0 }, - { "forward-to", (ESExpFunc *) mark_forward, 0 }, - { "copy-to", (ESExpFunc *) do_copy, 0 }, - { "move-to", (ESExpFunc *) do_move, 0 }, - { "stop", (ESExpFunc *) do_stop, 0 }, - { "set-colour", (ESExpFunc *) do_colour, 0 }, - { "set-score", (ESExpFunc *) do_score, 0 }, - { "set-system-flag", (ESExpFunc *) do_flag, 0 }, - { "shell", (ESExpFunc *) do_shell, 0 }, - { "beep", (ESExpFunc *) do_beep, 0 }, - { "play-sound", (ESExpFunc *) play_sound, 0 }, - { "only-once", (ESExpFunc *) do_only_once, 0 } + { "delete", (ESExpFunc *) do_delete, 0 }, + { "forward-to", (ESExpFunc *) mark_forward, 0 }, + { "copy-to", (ESExpFunc *) do_copy, 0 }, + { "move-to", (ESExpFunc *) do_move, 0 }, + { "stop", (ESExpFunc *) do_stop, 0 }, + { "set-colour", (ESExpFunc *) do_colour, 0 }, + { "set-score", (ESExpFunc *) do_score, 0 }, + { "set-system-flag", (ESExpFunc *) set_flag, 0 }, + { "unset-system-flag", (ESExpFunc *) unset_flag, 0 }, + { "shell", (ESExpFunc *) do_shell, 0 }, + { "beep", (ESExpFunc *) do_beep, 0 }, + { "play-sound", (ESExpFunc *) play_sound, 0 }, + { "only-once", (ESExpFunc *) do_only_once, 0 } }; static CamelObjectClass *camel_filter_driver_parent; @@ -590,22 +592,43 @@ do_score (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDri } static ESExpResult * -do_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver) +set_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver) { struct _CamelFilterDriverPrivate *p = _PRIVATE (driver); + guint32 flags; d(fprintf (stderr, "setting flag\n")); if (argc == 1 && argv[0]->type == ESEXP_RES_STRING) { + flags = camel_system_flag (argv[0]->value.string); if (p->source && p->uid && camel_folder_has_summary_capability (p->source)) - camel_folder_set_message_flags(p->source, p->uid, camel_system_flag(argv[0]->value.string), ~0); + camel_folder_set_message_flags (p->source, p->uid, flags, ~0); else - p->info->flags |= camel_system_flag (argv[0]->value.string)|CAMEL_MESSAGE_FOLDER_FLAGGED; + p->info->flags |= flags | CAMEL_MESSAGE_FOLDER_FLAGGED; camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Set %s flag", argv[0]->value.string); } return NULL; } +static ESExpResult * +unset_flag (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver) +{ + struct _CamelFilterDriverPrivate *p = _PRIVATE (driver); + guint32 flags; + + d(fprintf (stderr, "unsetting flag\n")); + if (argc == 1 && argv[0]->type == ESEXP_RES_STRING) { + flags = camel_system_flag (argv[0]->value.string); + if (p->source && p->uid && camel_folder_has_summary_capability (p->source)) + camel_folder_set_message_flags (p->source, p->uid, flags, 0); + else + p->info->flags = (p->info->flags & ~flags) | CAMEL_MESSAGE_FOLDER_FLAGGED; + camel_filter_driver_log (driver, FILTER_LOG_ACTION, "Unset %s flag", argv[0]->value.string); + } + + return NULL; +} + static ESExpResult * do_shell (struct _ESExp *f, int argc, struct _ESExpResult **argv, CamelFilterDriver *driver) { -- cgit v1.2.3