2 * Copyright (c) 1996-2012 by the citadel.org team
4 * This program is open source software. You can redistribute it and/or
5 * modify it under the terms of the GNU General Public License version 3.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
15 #define MAX_SCRIPTS 100
17 #define RULES_SCRIPT "__WebCit_Generated_Script__"
20 * Helper function for output_sieve_rule() to output strings with quotes escaped
22 void osr_sanitize(char *str) {
25 if (str == NULL) return;
27 for (i=0; i<len; ++i) {
31 else if (isspace(str[i])) {
39 * Output parseable Sieve script code based on rules input
41 void output_sieve_rule(char *hfield, char *compare, char *htext, char *sizecomp, int sizeval,
42 char *action, char *fileinto, char *redirect, char *automsg, char *final,
49 osr_sanitize(fileinto);
50 osr_sanitize(redirect);
51 osr_sanitize(automsg);
53 /* Prepare negation and match operators that will be used iff we apply a conditional */
55 if (!strcasecmp(compare, "contains")) {
59 else if (!strcasecmp(compare, "notcontains")) {
63 else if (!strcasecmp(compare, "is")) {
67 else if (!strcasecmp(compare, "isnot")) {
71 else if (!strcasecmp(compare, "matches")) {
75 else if (!strcasecmp(compare, "notmatches")) {
80 /* Now do the conditional */
82 if (!strcasecmp(hfield, "from")) {
83 serv_printf("if%s header %s \"From\" \"%s\"",
89 else if (!strcasecmp(hfield, "tocc")) {
90 serv_printf("if%s header %s [\"To\", \"Cc\"] \"%s\"",
96 else if (!strcasecmp(hfield, "subject")) {
97 serv_printf("if%s header %s \"Subject\" \"%s\"",
103 else if (!strcasecmp(hfield, "replyto")) {
104 serv_printf("if%s header %s \"Reply-to\" \"%s\"",
110 else if (!strcasecmp(hfield, "sender")) {
111 serv_printf("if%s header %s \"Sender\" \"%s\"",
117 else if (!strcasecmp(hfield, "resentfrom")) {
118 serv_printf("if%s header %s \"Resent-from\" \"%s\"",
124 else if (!strcasecmp(hfield, "resentto")) {
125 serv_printf("if%s header %s \"Resent-to\" \"%s\"",
131 else if (!strcasecmp(hfield, "xmailer")) {
132 serv_printf("if%s header %s \"X-Mailer\" \"%s\"",
138 else if (!strcasecmp(hfield, "xspamflag")) {
139 serv_printf("if%s header %s \"X-Spam-Flag\" \"%s\"",
145 else if (!strcasecmp(hfield, "xspamstatus")) {
146 serv_printf("if%s header %s \"X-Spam-Status\" \"%s\"",
152 else if (!strcasecmp(hfield, "listid")) {
153 serv_printf("if%s header %s \"List-ID\" \"%s\"",
159 else if (!strcasecmp(hfield, "envfrom")) {
160 serv_printf("if%s envelope %s \"From\" \"%s\"",
166 else if (!strcasecmp(hfield, "envto")) {
167 serv_printf("if%s envelope %s \"To\" \"%s\"",
173 else if (!strcasecmp(hfield, "size")) {
174 if (!strcasecmp(sizecomp, "larger")) {
175 serv_printf("if size :over %d", sizeval);
177 else if (!strcasecmp(sizecomp, "smaller")) {
178 serv_printf("if size :under %d", sizeval);
180 else { /* failsafe - should never get here, but just in case... */
181 serv_printf("if size :over 1");
185 /* Open braces if we're in a conditional loop */
187 if (strcasecmp(hfield, "all")) {
194 if (!strcasecmp(action, "keep")) {
195 serv_printf("keep;");
198 else if (!strcasecmp(action, "discard")) {
199 serv_printf("discard;");
202 else if (!strcasecmp(action, "reject")) {
203 serv_printf("reject \"%s\";", automsg);
206 else if (!strcasecmp(action, "fileinto")) {
207 serv_printf("fileinto \"%s\";", fileinto);
210 else if (!strcasecmp(action, "redirect")) {
211 serv_printf("redirect \"%s\";", redirect);
214 else if (!strcasecmp(action, "vacation")) {
215 serv_printf("vacation :addresses [%s]\n\"%s\";", my_addresses, automsg);
219 /* Do 'final' action */
221 if (!strcasecmp(final, "stop")) {
222 serv_printf("stop;");
226 /* Close the braces if we're in a conditional loop */
228 if (strcasecmp(hfield, "all")) {
239 * Translate the fields from the rule editor into something we can save...
241 void parse_fields_from_rule_editor(void) {
258 char encoded_rule[4096];
259 char my_addresses[4096];
261 /* Enumerate my email addresses in case they are needed for a vacation rule */
264 serv_getln(buf, sizeof buf);
265 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
266 if (!IsEmptyStr(my_addresses)) {
267 strcat(my_addresses, ",\n");
269 strcat(my_addresses, "\"");
270 strcat(my_addresses, buf);
271 strcat(my_addresses, "\"");
274 /* Now generate the script and write it to the Citadel server */
275 serv_printf("MSIV putscript|%s|", RULES_SCRIPT);
276 serv_getln(buf, sizeof buf);
281 serv_puts("# THIS SCRIPT WAS AUTOMATICALLY GENERATED BY WEBCIT.");
283 serv_puts("# Do not attempt to manually edit it. If you do so,");
284 serv_puts("# your changes will be overwritten the next time WebCit");
285 serv_puts("# saves its mail filtering rule set. If you really want");
286 serv_puts("# to use these rules as the basis for another script,");
287 serv_puts("# copy them to another script and save that instead.");
289 serv_puts("require \"fileinto\";");
290 serv_puts("require \"reject\";");
291 serv_puts("require \"vacation\";");
292 serv_puts("require \"envelope\";");
295 for (i=0; i<MAX_RULES; ++i) {
299 sprintf(fname, "active%d", i);
300 active = !strcasecmp(BSTR(fname), "on") ;
304 sprintf(fname, "hfield%d", i);
305 safestrncpy(hfield, BSTR(fname), sizeof hfield);
307 sprintf(fname, "compare%d", i);
308 safestrncpy(compare, BSTR(fname), sizeof compare);
310 sprintf(fname, "htext%d", i);
311 safestrncpy(htext, BSTR(fname), sizeof htext);
313 sprintf(fname, "sizecomp%d", i);
314 safestrncpy(sizecomp, BSTR(fname), sizeof sizecomp);
316 sprintf(fname, "sizeval%d", i);
317 sizeval = IBSTR(fname);
319 sprintf(fname, "action%d", i);
320 safestrncpy(action, BSTR(fname), sizeof action);
322 sprintf(fname, "fileinto%d", i);
323 safestrncpy(fileinto, BSTR(fname), sizeof fileinto);
325 sprintf(fname, "redirect%d", i);
326 safestrncpy(redirect, BSTR(fname), sizeof redirect);
328 sprintf(fname, "automsg%d", i);
329 safestrncpy(automsg, BSTR(fname), sizeof automsg);
331 sprintf(fname, "final%d", i);
332 safestrncpy(final, BSTR(fname), sizeof final);
334 snprintf(rule, sizeof rule, "%d|%s|%s|%s|%s|%d|%s|%s|%s|%s|%s",
335 active, hfield, compare, htext, sizecomp, sizeval, action, fileinto,
336 redirect, automsg, final
339 CtdlEncodeBase64(encoded_rule, rule, strlen(rule)+1, 0);
340 serv_printf("# WEBCIT_RULE|%d|%s|", i, encoded_rule);
341 output_sieve_rule(hfield, compare, htext, sizecomp, sizeval,
342 action, fileinto, redirect, automsg, final, my_addresses);
358 void save_sieve(void) {
360 char script_names[MAX_SCRIPTS][64];
362 int active_script = (-1); /* this throws a 'set but not used' warning , check this ! */
367 if (!havebstr("save_button")) {
368 AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
373 parse_fields_from_rule_editor();
375 serv_puts("MSIV listscripts");
376 serv_getln(buf, sizeof(buf));
377 if (buf[0] == '1') while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
378 if (num_scripts < MAX_SCRIPTS) {
379 extract_token(script_names[num_scripts], buf, 0, '|', 64);
380 if (extract_int(buf, 1) > 0) {
381 active_script = num_scripts;
387 bigaction = ibstr("bigaction");
389 if (bigaction == 0) {
390 serv_puts("MSIV setactive||");
391 serv_getln(buf, sizeof buf);
394 else if (bigaction == 1) {
395 serv_printf("MSIV setactive|%s|", RULES_SCRIPT);
396 serv_getln(buf, sizeof buf);
399 else if (bigaction == 2) {
400 serv_printf("MSIV setactive|%s|", bstr("active_script"));
401 serv_getln(buf, sizeof buf);
404 if (num_scripts > 0) {
405 for (i=0; i<num_scripts; ++i) {
407 * We only want to save the scripts from the "manually edited scripts"
408 * screen. The script that WebCit generates from its ruleset will be
409 * auto-generated by parse_fields_from_rule_editor() and saved there.
411 if (strcasecmp(script_names[i], RULES_SCRIPT)) {
412 serv_printf("MSIV putscript|%s|", script_names[i]);
413 serv_getln(buf, sizeof buf);
415 snprintf(this_name, sizeof this_name, "text_%s", script_names[i]);
416 striplt((char *)BSTR(this_name)); /* TODO: get rid of typecast*/
417 serv_write(BSTR(this_name), strlen(BSTR(this_name)));
424 AppendImportantMessage(_("Your changes have been saved."), -1);
430 * create a new script
431 * take the web environment script name and create it on the citadel server
433 void create_script(void) {
436 serv_printf("MSIV getscript|%s", bstr("script_name"));
437 serv_getln(buf, sizeof buf);
439 while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
445 serv_printf("MSIV putscript|%s", bstr("script_name"));
446 serv_getln(buf, sizeof buf);
450 output_headers(1, 1, 2, 0, 0, 0);
451 do_template("sieve_add");
456 output_headers(1, 1, 2, 0, 0, 0);
457 do_template("sieve_add");
467 void delete_script(void) {
470 serv_printf("MSIV deletescript|%s", bstr("script_name"));
471 serv_getln(buf, sizeof buf);
472 output_headers(1, 1, 2, 0, 0, 0);
473 do_template("sieve_add");
480 * dummy panel indicating to the user that the server doesn't support Sieve
482 void display_no_sieve(void) {
484 output_headers(1, 1, 2, 0, 0, 0);
485 do_template("sieve_none");
490 typedef struct __SieveListing {
497 int ConditionalSieveScriptIsActive(StrBuf *Target, WCTemplputParams *TP)
499 SieveListing *SieveList = (SieveListing *)CTX;
500 return SieveList->IsActive;
502 int ConditionalSieveScriptIsRulesScript(StrBuf *Target, WCTemplputParams *TP)
504 SieveListing *SieveList = (SieveListing *)CTX;
505 return SieveList->IsActive;
507 void tmplput_SieveScriptName(StrBuf *Target, WCTemplputParams *TP)
509 SieveListing *SieveList = (SieveListing *)CTX;
510 StrBufAppendTemplate(Target, TP, SieveList->Name, 0);
512 void tmplput_SieveScriptContent(StrBuf *Target, WCTemplputParams *TP)
514 SieveListing *SieveList = (SieveListing *)CTX;
515 StrBufAppendTemplate(Target, TP, SieveList->Content, 0);
517 void FreeSieveListing(void *vSieveListing)
519 SieveListing *List = (SieveListing*) vSieveListing;
521 FreeStrBuf(&List->Name);
525 HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
530 int rules_script_active = 0;
531 int have_rules_script = 0;
535 SieveListing *Ruleset;
537 if (WCC->KnownSieveScripts != NULL) {
538 return WCC->KnownSieveScripts;
541 serv_puts("MSIV listscripts");
543 StrBuf_ServGetln(Line);
544 if (GetServerStatus(Line, NULL) == 1)
546 WCC->KnownSieveScripts = NewHash(1, Flathash);
548 while(!Done && (StrBuf_ServGetln(Line) >= 0) )
549 if ( (StrLength(Line)==3) &&
550 !strcmp(ChrPtr(Line), "000"))
557 Ruleset = (SieveListing *) malloc(sizeof(SieveListing));
558 Ruleset->Name = NewStrBufPlain(NULL, StrLength(Line));
559 StrBufExtract_NextToken(Ruleset->Name, Line, &pch, '|');
560 Ruleset->IsActive = StrBufExtractNext_int(Line, &pch, '|');
561 Ruleset->Content = NULL;
563 if (!strcasecmp(ChrPtr(Ruleset->Name), RULES_SCRIPT))
565 Ruleset->IsRulesScript = 1;
566 have_rules_script = 1;
567 if (Ruleset->IsActive)
569 rules_script_active = 1;
570 PutBstr(HKEY("__SIEVE:RULESSCRIPT"), NewStrBufPlain(HKEY("1")));
573 Put(WCC->KnownSieveScripts, IKEY(num_scripts), Ruleset, FreeSieveListing);
578 if ((num_scripts > 0) && (rules_script_active == 0))
579 PutBstr(HKEY("__SIEVE:EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
581 if (num_scripts > have_rules_script)
589 * ok; we have custom scripts, expose that via bstr, and load the payload.
591 PutBstr(HKEY("__SIEVE:HAVE_EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
593 it = GetNewHashPos(WCC->KnownSieveScripts, 0);
594 while (GetNextHashPos(WCC->KnownSieveScripts, it, &len, &Key, &vRuleset) &&
597 Ruleset = (SieveListing *) vRuleset;
600 * its the webcit rule? we don't need to load that here.
602 if (Ruleset->IsRulesScript)
605 if (!serv_printf("MSIV getscript|%s", ChrPtr(Ruleset->Name)))
607 StrBuf_ServGetln(Line);
608 if (GetServerStatus(Line, NULL) == 1)
610 Ruleset->Content = NewStrBuf();
611 while(!Done && (rc = StrBuf_ServGetln(Line), rc >= 0) )
612 if ( (StrLength(Line)==3) &&
613 !strcmp(ChrPtr(Line), "000"))
619 if (StrLength(Ruleset->Content)>0)
620 StrBufAppendBufPlain(Ruleset->Content, HKEY("\n"), 0);
621 StrBufAppendBuf(Ruleset->Content, Line, 0);
628 return WCC->KnownSieveScripts;
632 typedef enum __eSieveHfield
651 typedef enum __eSieveCompare {
660 typedef enum __eSieveAction {
670 typedef enum __eSieveSizeComp {
675 typedef enum __eSieveFinal {
681 typedef struct __SieveRule {
685 eSieveCompare compare;
687 eSieveSizeComp sizecomp;
697 int ConditionalSieveRule_hfield(StrBuf *Target, WCTemplputParams *TP)
699 SieveRule *Rule = (SieveRule *)CTX;
701 return GetTemplateTokenNumber(Target,
708 int ConditionalSieveRule_compare(StrBuf *Target, WCTemplputParams *TP)
710 SieveRule *Rule = (SieveRule *)CTX;
711 return GetTemplateTokenNumber(Target,
718 int ConditionalSieveRule_action(StrBuf *Target, WCTemplputParams *TP)
720 SieveRule *Rule = (SieveRule *)CTX;
721 return GetTemplateTokenNumber(Target,
728 int ConditionalSieveRule_sizecomp(StrBuf *Target, WCTemplputParams *TP)
730 SieveRule *Rule = (SieveRule *)CTX;
731 return GetTemplateTokenNumber(Target,
738 int ConditionalSieveRule_final(StrBuf *Target, WCTemplputParams *TP)
740 SieveRule *Rule = (SieveRule *)CTX;
741 return GetTemplateTokenNumber(Target,
748 int ConditionalSieveRule_ThisRoom(StrBuf *Target, WCTemplputParams *TP)
750 SieveRule *Rule = (SieveRule *)CTX;
751 return GetTemplateTokenNumber(Target,
758 int ConditionalSieveRule_Active(StrBuf *Target, WCTemplputParams *TP)
760 SieveRule *Rule = (SieveRule *)CTX;
763 void tmplput_SieveRule_htext(StrBuf *Target, WCTemplputParams *TP)
765 SieveRule *Rule = (SieveRule *)CTX;
766 StrBufAppendTemplate(Target, TP, Rule->htext, 0);
768 void tmplput_SieveRule_fileinto(StrBuf *Target, WCTemplputParams *TP)
770 SieveRule *Rule = (SieveRule *)CTX;
771 StrBufAppendTemplate(Target, TP, Rule->fileinto, 0);
773 void tmplput_SieveRule_redirect(StrBuf *Target, WCTemplputParams *TP)
775 SieveRule *Rule = (SieveRule *)CTX;
776 StrBufAppendTemplate(Target, TP, Rule->redirect, 0);
778 void tmplput_SieveRule_automsg(StrBuf *Target, WCTemplputParams *TP)
780 SieveRule *Rule = (SieveRule *)CTX;
781 StrBufAppendTemplate(Target, TP, Rule->automsg, 0);
783 void tmplput_SieveRule_sizeval(StrBuf *Target, WCTemplputParams *TP)
785 SieveRule *Rule = (SieveRule *)CTX;
786 StrBufAppendPrintf(Target, "%d", Rule->sizeval);
789 void tmplput_SieveRule_lookup_FileIntoRoom(StrBuf *Target, WCTemplputParams *TP)
792 SieveRule *Rule = (SieveRule *)CTX;
794 HashList *Rooms = GetRoomListHashLKRA(Target, TP);
796 GetHash(Rooms, SKEY(Rule->fileinto), &vRoom);
797 WCC->ThisRoom = (folder*) vRoom;
800 void FreeSieveRule(void *vRule)
802 SieveRule *Rule = (SieveRule*) vRule;
804 FreeStrBuf(&Rule->htext);
805 FreeStrBuf(&Rule->fileinto);
806 FreeStrBuf(&Rule->redirect);
807 FreeStrBuf(&Rule->automsg);
812 #define WC_RULE_HEADER "# WEBCIT_RULE|"
813 HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
816 StrBuf *EncodedRule = NULL;
818 const char *pch = NULL;
819 HashList *SieveRules = NULL;
821 SieveRule *Rule = NULL;
823 SieveRules = NewHash(1, Flathash);
824 serv_printf("MSIV getscript|"RULES_SCRIPT);
826 EncodedRule = NewStrBuf();
827 StrBuf_ServGetln(Line);
828 if (GetServerStatus(Line, NULL) == 1)
830 while(!Done && (StrBuf_ServGetln(Line) >= 0) )
831 if ( (StrLength(Line)==3) &&
832 !strcmp(ChrPtr(Line), "000"))
839 /* We just care for our encoded header and skip everything else */
840 if ((StrLength(Line) > sizeof(WC_RULE_HEADER) - 1) &&
841 (!strncasecmp(ChrPtr(Line), HKEY(WC_RULE_HEADER))))
843 StrBufSkip_NTokenS(Line, &pch, '|', 1);
844 n = StrBufExtractNext_int(Line, &pch, '|');
845 StrBufExtract_NextToken(EncodedRule, Line, &pch, '|');
846 StrBufDecodeBase64(EncodedRule);
848 Rule = (SieveRule*) malloc(sizeof(SieveRule));
850 Rule->htext = NewStrBufPlain (NULL, StrLength(EncodedRule));
852 Rule->fileinto = NewStrBufPlain (NULL, StrLength(EncodedRule));
853 Rule->redirect = NewStrBufPlain (NULL, StrLength(EncodedRule));
854 Rule->automsg = NewStrBufPlain (NULL, StrLength(EncodedRule));
856 /* Grab our existing values to populate */
858 Rule->active = StrBufExtractNext_int(EncodedRule, &pch, '|');
859 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
861 Rule->hfield = (eSieveHfield) GetTokenDefine(SKEY(Line), tocc);
862 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
863 Rule->compare = (eSieveCompare) GetTokenDefine(SKEY(Line), contains);
864 StrBufExtract_NextToken(Rule->htext, EncodedRule, &pch, '|');
865 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
866 Rule->sizecomp = (eSieveSizeComp) GetTokenDefine(SKEY(Line), larger);
867 Rule->sizeval = StrBufExtractNext_int(EncodedRule, &pch, '|');
868 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
869 Rule->Action = (eSieveAction) GetTokenDefine(SKEY(Line), keep);
870 StrBufExtract_NextToken(Rule->fileinto, EncodedRule, &pch, '|');
871 StrBufExtract_NextToken(Rule->redirect, EncodedRule, &pch, '|');
872 StrBufExtract_NextToken(Rule->automsg, EncodedRule, &pch, '|');
873 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
874 Rule->final = (eSieveFinal) GetTokenDefine(SKEY(Line), econtinue);
875 Put(SieveRules, IKEY(n), Rule, FreeSieveRule);
881 while (n < MAX_RULES) {
882 Rule = (SieveRule*) malloc(sizeof(SieveRule));
883 memset(Rule, 0, sizeof(SieveRule));
884 Put(SieveRules, IKEY(n), Rule, FreeSieveRule);
890 FreeStrBuf(&EncodedRule);
896 SessionDetachModule_SIEVE
899 DeleteHash(&sess->KnownSieveScripts);
906 REGISTERTokenParamDefine(from);
907 REGISTERTokenParamDefine(tocc);
908 REGISTERTokenParamDefine(subject);
909 REGISTERTokenParamDefine(replyto);
910 REGISTERTokenParamDefine(sender);
911 REGISTERTokenParamDefine(resentfrom);
912 REGISTERTokenParamDefine(resentto);
913 REGISTERTokenParamDefine(envfrom);
914 REGISTERTokenParamDefine(envto);
915 REGISTERTokenParamDefine(xmailer);
916 REGISTERTokenParamDefine(xspamflag);
917 REGISTERTokenParamDefine(xspamstatus);
918 REGISTERTokenParamDefine(listid);
919 REGISTERTokenParamDefine(size);
920 REGISTERTokenParamDefine(all);
922 REGISTERTokenParamDefine(contains);
923 REGISTERTokenParamDefine(notcontains);
924 REGISTERTokenParamDefine(is);
925 REGISTERTokenParamDefine(isnot);
926 REGISTERTokenParamDefine(matches);
927 REGISTERTokenParamDefine(notmatches);
929 REGISTERTokenParamDefine(keep);
930 REGISTERTokenParamDefine(discard);
931 REGISTERTokenParamDefine(reject);
932 REGISTERTokenParamDefine(fileinto);
933 REGISTERTokenParamDefine(redirect);
934 REGISTERTokenParamDefine(vacation);
936 REGISTERTokenParamDefine(larger);
937 REGISTERTokenParamDefine(smaller);
939 /* these are c-keyworads, so do it by hand. */
940 RegisterTokenParamDefine(HKEY("continue"), econtinue);
941 RegisterTokenParamDefine(HKEY("stop"), estop);
943 RegisterIterator("SIEVE:SCRIPTS", 0, NULL, GetSieveScriptListing, NULL, NULL, CTX_SIEVELIST, CTX_NONE, IT_NOFLAG);
945 RegisterConditional(HKEY("COND:SIEVE:SCRIPT:ACTIVE"), 0, ConditionalSieveScriptIsActive, CTX_SIEVELIST);
946 RegisterConditional(HKEY("COND:SIEVE:SCRIPT:ISRULES"), 0, ConditionalSieveScriptIsRulesScript, CTX_SIEVELIST);
947 RegisterNamespace("SIEVE:SCRIPT:NAME", 0, 1, tmplput_SieveScriptName, NULL, CTX_SIEVELIST);
948 RegisterNamespace("SIEVE:SCRIPT:CONTENT", 0, 1, tmplput_SieveScriptContent, NULL, CTX_SIEVELIST);
951 RegisterIterator("SIEVE:RULES", 0, NULL, GetSieveRules, NULL, DeleteHash, CTX_SIEVESCRIPT, CTX_NONE, IT_NOFLAG);
953 RegisterConditional(HKEY("COND:SIEVE:ACTIVE"), 1, ConditionalSieveRule_Active, CTX_SIEVESCRIPT);
954 RegisterConditional(HKEY("COND:SIEVE:HFIELD"), 1, ConditionalSieveRule_hfield, CTX_SIEVESCRIPT);
955 RegisterConditional(HKEY("COND:SIEVE:COMPARE"), 1, ConditionalSieveRule_compare, CTX_SIEVESCRIPT);
956 RegisterConditional(HKEY("COND:SIEVE:ACTION"), 1, ConditionalSieveRule_action, CTX_SIEVESCRIPT);
957 RegisterConditional(HKEY("COND:SIEVE:SIZECOMP"), 1, ConditionalSieveRule_sizecomp, CTX_SIEVESCRIPT);
958 RegisterConditional(HKEY("COND:SIEVE:FINAL"), 1, ConditionalSieveRule_final, CTX_SIEVESCRIPT);
959 RegisterConditional(HKEY("COND:SIEVE:THISROOM"), 1, ConditionalSieveRule_ThisRoom, CTX_SIEVESCRIPT);
961 RegisterNamespace("SIEVE:SCRIPT:HTEXT", 0, 1, tmplput_SieveRule_htext, NULL, CTX_SIEVESCRIPT);
962 RegisterNamespace("SIEVE:SCRIPT:SIZE", 0, 1, tmplput_SieveRule_sizeval, NULL, CTX_SIEVESCRIPT);
963 RegisterNamespace("SIEVE:SCRIPT:FILEINTO", 0, 1, tmplput_SieveRule_fileinto, NULL, CTX_SIEVESCRIPT);
964 RegisterNamespace("SIEVE:SCRIPT:REDIRECT", 0, 1, tmplput_SieveRule_redirect, NULL, CTX_SIEVESCRIPT);
965 RegisterNamespace("SIEVE:SCRIPT:AUTOMSG", 0, 1, tmplput_SieveRule_automsg, NULL, CTX_SIEVESCRIPT);
967 /* fetch our room into WCC->ThisRoom, to evaluate while iterating over rooms with COND:THIS:THAT:ROOM */
968 RegisterNamespace("SIEVE:SCRIPT:LOOKUP_FILEINTO", 0, 1, tmplput_SieveRule_lookup_FileIntoRoom, NULL, CTX_SIEVESCRIPT);
969 WebcitAddUrlHandler(HKEY("save_sieve"), "", 0, save_sieve, 0);
970 WebcitAddUrlHandler(HKEY("create_script"), "", 0, create_script, 0);
971 WebcitAddUrlHandler(HKEY("delete_script"), "", 0, delete_script, 0);