Skip to content
Snippets Groups Projects
Commit 5d26995a authored by Stephan Bosch's avatar Stephan Bosch
Browse files

Added :flags tag to the imapflags extension and fixed bug in the result execution.

parent 90bfc52b
No related branches found
No related tags found
No related merge requests found
......@@ -57,7 +57,7 @@ static bool tag_copy_validate
return TRUE;
}
/* Command registration */
/* Tag */
static const struct sieve_argument copy_tag = {
"copy", NULL,
......
......@@ -15,10 +15,14 @@ cmds = \
tsts = \
tst-hasflag.c
tags = \
tag-flags.c
libsieve_ext_imapflags_la_SOURCES = \
ext-imapflags-common.c \
$(cmds) \
$(tsts) \
$(tags) \
ext-imapflags.c
noinst_HEADERS = \
......
......@@ -39,6 +39,10 @@ extern const struct sieve_command cmd_removeflag;
extern const struct sieve_command tst_hasflag;
/* Tagged arguments */
extern const struct sieve_argument tag_flags;
/* Opcodes */
extern const struct sieve_opcode setflag_opcode;
......@@ -75,11 +79,18 @@ static bool ext_imapflags_load(int ext_id)
static bool ext_imapflags_validator_load
(struct sieve_validator *validator)
{
/* Register new command */
/* Register commands */
sieve_validator_register_command(validator, &cmd_setflag);
sieve_validator_register_command(validator, &cmd_addflag);
sieve_validator_register_command(validator, &cmd_removeflag);
sieve_validator_register_command(validator, &tst_hasflag);
/* Register :flags tag with keep and fileinto commands and we don't care
* whether these commands are registered or even whether they will be
* registered at all. The validator handles either situation gracefully
*/
sieve_validator_register_external_tag(validator, &tag_flags, "keep", 0);
sieve_validator_register_external_tag(validator, &tag_flags, "fileinto", 0);
return TRUE;
}
......
......@@ -24,3 +24,5 @@ if header :contains "from" "imap@cac.washington.example.edu" {
if hasflag :count "ge" :comparator "i;ascii-numeric" "2" {
fileinto "INBOX.imap-twoflags";
}
fileinto :flags "\\Seen" "INBOX";
#include "lib.h"
#include "sieve-commands.h"
#include "sieve-validator.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
#include "ext-imapflags-common.h"
static bool tag_flags_validate
(struct sieve_validator *validator, struct sieve_ast_argument **arg,
struct sieve_command_context *cmd);
/* Tag */
const struct sieve_argument tag_flags = {
"flags", NULL,
tag_flags_validate,
NULL, NULL
};
/* Tag validation */
static bool tag_flags_validate
(struct sieve_validator *validator, struct sieve_ast_argument **arg,
struct sieve_command_context *cmd)
{
struct sieve_ast_argument *tag = *arg;
/* Detach the tag itself */
*arg = sieve_ast_arguments_detach(*arg,1);
/* Check syntax:
* :flags <list-of-flags: string-list>
*/
if ( !sieve_validate_tag_parameter
(validator, cmd, tag, *arg, SAAT_STRING_LIST) ) {
return FALSE;
}
/* Detach parameter */
*arg = sieve_ast_arguments_detach(*arg,1);
return TRUE;
}
......@@ -192,7 +192,8 @@ static bool act_store_commit
act_store_log_status(trans, aenv->msgdata, FALSE, status);
mailbox_close(&trans->box);
if ( trans->box != NULL )
mailbox_close(&trans->box);
return status;
}
......@@ -208,8 +209,9 @@ static void act_store_rollback
mailbox_transaction_rollback(&trans->mail_trans);
act_store_log_status(trans, aenv->msgdata, TRUE, success);
mailbox_close(&trans->box);
if ( trans->box != NULL )
mailbox_close(&trans->box);
}
......
......@@ -178,9 +178,8 @@ bool sieve_result_execute
printf("\nTransaction execute:\n");
if ( success )
rac = result->first_action;
last_attempted = rac;
rac = result->first_action;
while ( success && rac != NULL ) {
const struct sieve_action *act = rac->action;
......@@ -201,7 +200,6 @@ bool sieve_result_execute
printf("\nTransaction rollback:\n");
commit_ok = success;
last_attempted = rac;
rac = result->first_action;
while ( rac != NULL && rac != last_attempted ) {
const struct sieve_action *act = rac->action;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.