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

Created skeletons for the commands introduced by the imapflags extension.

parent 91669a17
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,15 @@ AM_CPPFLAGS = \
-I$(dovecot_incdir)/src/lib-mail \
-I$(dovecot_incdir)/src/lib-storage
cmds = \
cmd-setflag.c \
cmd-addflag.c \
cmd-removeflag.c
libsieve_ext_imapflags_la_SOURCES = \
ext-imapflags-common.c \
$(cmds) \
ext-imapflags.c
noinst_HEADERS = \
ext-imapflags-common.h
#include "lib.h"
#include "sieve-commands.h"
#include "sieve-commands-private.h"
#include "sieve-validator.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
#include "ext-imapflags-common.h"
/* Forward declarations */
static bool cmd_addflag_generate
(struct sieve_generator *generator, struct sieve_command_context *ctx);
/* Addflag command
*
* Syntax:
* addflag [<variablename: string>] <list-of-flags: string-list>
*/
const struct sieve_command cmd_addflag = {
"addflag",
SCT_COMMAND,
-1, /* We check positional arguments ourselves */
0, FALSE, FALSE,
NULL, NULL,
ext_imapflags_command_validate,
cmd_addflag_generate,
NULL
};
/* Code generation */
static bool cmd_addflag_generate
(struct sieve_generator *generator, struct sieve_command_context *ctx)
{
return TRUE;
}
#include "lib.h"
#include "sieve-commands.h"
#include "sieve-commands-private.h"
#include "sieve-validator.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
#include "ext-imapflags-common.h"
/* Forward declarations */
static bool cmd_removeflag_generate
(struct sieve_generator *generator, struct sieve_command_context *ctx);
/* Removeflag command
*
* Syntax:
* removeflag [<variablename: string>] <list-of-flags: string-list>
*/
const struct sieve_command cmd_removeflag = {
"removeflag",
SCT_COMMAND,
-1, /* We check positional arguments ourselves */
0, FALSE, FALSE,
NULL, NULL,
ext_imapflags_command_validate,
cmd_removeflag_generate,
NULL
};
/* Code generation */
static bool cmd_removeflag_generate
(struct sieve_generator *generator, struct sieve_command_context *ctx)
{
return TRUE;
}
#include "lib.h"
#include "sieve-commands.h"
#include "sieve-commands-private.h"
#include "sieve-validator.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
#include "ext-imapflags-common.h"
/* Forward declarations */
static bool cmd_setflag_generate
(struct sieve_generator *generator, struct sieve_command_context *ctx);
/* Setflag command
*
* Syntax:
* setflag [<variablename: string>] <list-of-flags: string-list>
*/
const struct sieve_command cmd_setflag = {
"setflag",
SCT_COMMAND,
-1, /* We check positional arguments ourselves */
0, FALSE, FALSE,
NULL, NULL,
ext_imapflags_command_validate,
cmd_setflag_generate,
NULL
};
/* Code generation */
static bool cmd_setflag_generate
(struct sieve_generator *generator, struct sieve_command_context *ctx)
{
return TRUE;
}
#include "lib.h"
#include "sieve-commands.h"
#include "sieve-commands-private.h"
#include "sieve-validator.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
#include "ext-imapflags-common.h"
bool ext_imapflags_command_validate
(struct sieve_validator *validator, struct sieve_command_context *cmd)
{
return TRUE;
}
#ifndef __EXT_IMAPFLAGS_COMMON_H
#define __EXT_IMAPFLAGS_COMMON_H
bool ext_imapflags_command_validate
(struct sieve_validator *validator, struct sieve_command_context *cmd);
#endif /* __EXT_IMAPFLAGS_COMMON_H */
......@@ -24,6 +24,12 @@
static bool ext_imapflags_load(int ext_id);
static bool ext_imapflags_validator_load(struct sieve_validator *validator);
/* Commands */
extern const struct sieve_command cmd_setflag;
extern const struct sieve_command cmd_addflag;
extern const struct sieve_command cmd_removeflag;
/* Extension definitions */
int ext_my_id;
......@@ -48,10 +54,12 @@ static bool ext_imapflags_load(int ext_id)
/* Load extension into validator */
static bool ext_imapflags_validator_load
(struct sieve_validator *validator ATTR_UNUSED)
(struct sieve_validator *validator)
{
/* Register new command */
//sieve_validator_register_command(validator, &imapflags_command);
sieve_validator_register_command(validator, &cmd_setflag);
sieve_validator_register_command(validator, &cmd_addflag);
sieve_validator_register_command(validator, &cmd_removeflag);
return TRUE;
}
......
require "imapflags";
require "fileinto";
if header :contains "from" "boss@frobnitzm.example.edu" {
setflag "flagvar" "\\Flagged";
# fileinto :flags "${flagvar}" "INBOX.From Boss";
}
if header :contains "Disposition-Notification-To" "mel@example.com" {
addflag "flagvar" "$MDNRequired";
}
if header :contains "from" "imap@cac.washington.example.edu" {
removeflag "flagvar" "$MDNRequired";
# fileinto :flags "${flagvar}" "INBOX.imap-list";
}
......@@ -43,8 +43,8 @@ struct sieve_command {
enum sieve_command_type type;
/* High-level command syntax */
unsigned int positional_arguments;
unsigned int subtests;
int positional_arguments;
int subtests;
bool block_allowed;
bool block_required;
......
......@@ -48,6 +48,7 @@ extern const struct sieve_extension subaddress_extension;
extern const struct sieve_extension comparator_i_ascii_numeric_extension;
extern const struct sieve_extension relational_extension;
extern const struct sieve_extension regex_extension;
extern const struct sieve_extension imapflags_extension;
const struct sieve_extension *sieve_core_extensions[] = {
&comparator_extension, &match_type_extension, &address_part_extension,
......@@ -57,7 +58,7 @@ const struct sieve_extension *sieve_core_extensions[] = {
/* 'Plugins' */
&vacation_extension, &subaddress_extension,
&comparator_i_ascii_numeric_extension,
&relational_extension, &regex_extension
&relational_extension, &regex_extension, &imapflags_extension
};
const unsigned int sieve_core_extensions_count =
......
......@@ -655,8 +655,9 @@ static bool sieve_validate_command
/* Check syntax */
if (
!sieve_validate_command_arguments
(validator, ctx, command->positional_arguments) ||
( command->positional_arguments >= 0 &&
!sieve_validate_command_arguments
(validator, ctx, command->positional_arguments) ) ||
!sieve_validate_command_subtests
(validator, ctx, command->subtests) ||
(ast_type == SAT_COMMAND && !sieve_validate_command_block
......
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.