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.
12 * FIXME: add logic to exclude the webcit-generated script from the manual script selection
17 #define MAX_SCRIPTS 100
19 #define RULES_SCRIPT "__WebCit_Generated_Script__"
23 * Helper function for output_sieve_rule() to output strings with quotes escaped
25 void osr_sanitize(char *str) {
28 if (str == NULL) return;
30 for (i=0; i<len; ++i) {
34 else if (isspace(str[i])) {
42 * Output parseable Sieve script code based on rules input
44 void output_sieve_rule(char *hfield, char *compare, char *htext, char *sizecomp, int sizeval,
45 char *action, char *fileinto, char *redirect, char *automsg, char *final,
52 osr_sanitize(fileinto);
53 osr_sanitize(redirect);
54 osr_sanitize(automsg);
56 /* Prepare negation and match operators that will be used iff we apply a conditional */
58 if (!strcasecmp(compare, "contains")) {
62 else if (!strcasecmp(compare, "notcontains")) {
66 else if (!strcasecmp(compare, "is")) {
70 else if (!strcasecmp(compare, "isnot")) {
74 else if (!strcasecmp(compare, "matches")) {
78 else if (!strcasecmp(compare, "notmatches")) {
83 /* Now do the conditional */
85 if (!strcasecmp(hfield, "from")) {
86 serv_printf("if%s header %s \"From\" \"%s\"",
92 else if (!strcasecmp(hfield, "tocc")) {
93 serv_printf("if%s header %s [\"To\", \"Cc\"] \"%s\"",
99 else if (!strcasecmp(hfield, "subject")) {
100 serv_printf("if%s header %s \"Subject\" \"%s\"",
106 else if (!strcasecmp(hfield, "replyto")) {
107 serv_printf("if%s header %s \"Reply-to\" \"%s\"",
113 else if (!strcasecmp(hfield, "sender")) {
114 serv_printf("if%s header %s \"Sender\" \"%s\"",
120 else if (!strcasecmp(hfield, "resentfrom")) {
121 serv_printf("if%s header %s \"Resent-from\" \"%s\"",
127 else if (!strcasecmp(hfield, "resentto")) {
128 serv_printf("if%s header %s \"Resent-to\" \"%s\"",
134 else if (!strcasecmp(hfield, "xmailer")) {
135 serv_printf("if%s header %s \"X-Mailer\" \"%s\"",
141 else if (!strcasecmp(hfield, "xspamflag")) {
142 serv_printf("if%s header %s \"X-Spam-Flag\" \"%s\"",
148 else if (!strcasecmp(hfield, "xspamstatus")) {
149 serv_printf("if%s header %s \"X-Spam-Status\" \"%s\"",
155 else if (!strcasecmp(hfield, "listid")) {
156 serv_printf("if%s header %s \"List-ID\" \"%s\"",
162 else if (!strcasecmp(hfield, "envfrom")) {
163 serv_printf("if%s envelope %s \"From\" \"%s\"",
169 else if (!strcasecmp(hfield, "envto")) {
170 serv_printf("if%s envelope %s \"To\" \"%s\"",
176 else if (!strcasecmp(hfield, "size")) {
177 if (!strcasecmp(sizecomp, "larger")) {
178 serv_printf("if size :over %d", sizeval);
180 else if (!strcasecmp(sizecomp, "smaller")) {
181 serv_printf("if size :under %d", sizeval);
183 else { /* failsafe - should never get here, but just in case... */
184 serv_printf("if size :over 1");
188 /* Open braces if we're in a conditional loop */
190 if (strcasecmp(hfield, "all")) {
196 if (!strcasecmp(action, "keep")) {
197 serv_printf("keep;");
200 else if (!strcasecmp(action, "discard")) {
201 serv_printf("discard;");
204 else if (!strcasecmp(action, "reject")) {
205 serv_printf("reject \"%s\";", automsg);
208 else if (!strcasecmp(action, "fileinto")) {
209 serv_printf("fileinto \"%s\";", fileinto);
212 else if (!strcasecmp(action, "redirect")) {
213 serv_printf("redirect \"%s\";", redirect);
216 else if (!strcasecmp(action, "vacation")) {
217 serv_printf("vacation :addresses [%s]\n\"%s\";", my_addresses, automsg);
220 /* Do 'final' action */
222 if (!strcasecmp(final, "stop")) {
223 serv_printf("stop;");
226 /* Close the braces if we're in a conditional loop */
228 if (strcasecmp(hfield, "all")) {
237 * Translate the fields from the rule editor into something we can save...
239 void parse_fields_from_rule_editor(void) {
256 char encoded_rule[4096];
257 char my_addresses[4096];
259 /* Enumerate my email addresses in case they are needed for a vacation rule */
262 serv_getln(buf, sizeof buf);
263 if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
264 if (!IsEmptyStr(my_addresses)) {
265 strcat(my_addresses, ",\n");
267 strcat(my_addresses, "\"");
268 strcat(my_addresses, buf);
269 strcat(my_addresses, "\"");
272 /* Now generate the script and write it to the Citadel server */
273 serv_printf("MSIV putscript|%s|", RULES_SCRIPT);
274 serv_getln(buf, sizeof buf);
279 serv_puts("# THIS SCRIPT WAS AUTOMATICALLY GENERATED BY WEBCIT.");
281 serv_puts("# Do not attempt to manually edit it. If you do so,");
282 serv_puts("# your changes will be overwritten the next time WebCit");
283 serv_puts("# saves its mail filtering rule set. If you really want");
284 serv_puts("# to use these rules as the basis for another script,");
285 serv_puts("# copy them to another script and save that instead.");
287 serv_puts("require \"fileinto\";");
288 serv_puts("require \"reject\";");
289 serv_puts("require \"vacation\";");
290 serv_puts("require \"envelope\";");
293 for (i=0; i<MAX_RULES; ++i) {
297 sprintf(fname, "active%d", i);
298 active = !strcasecmp(BSTR(fname), "on") ;
302 sprintf(fname, "hfield%d", i);
303 safestrncpy(hfield, BSTR(fname), sizeof hfield);
305 sprintf(fname, "compare%d", i);
306 safestrncpy(compare, BSTR(fname), sizeof compare);
308 sprintf(fname, "htext%d", i);
309 safestrncpy(htext, BSTR(fname), sizeof htext);
311 sprintf(fname, "sizecomp%d", i);
312 safestrncpy(sizecomp, BSTR(fname), sizeof sizecomp);
314 sprintf(fname, "sizeval%d", i);
315 sizeval = IBSTR(fname);
317 sprintf(fname, "action%d", i);
318 safestrncpy(action, BSTR(fname), sizeof action);
320 sprintf(fname, "fileinto%d", i);
321 safestrncpy(fileinto, BSTR(fname), sizeof fileinto);
323 sprintf(fname, "redirect%d", i);
324 safestrncpy(redirect, BSTR(fname), sizeof redirect);
326 sprintf(fname, "automsg%d", i);
327 safestrncpy(automsg, BSTR(fname), sizeof automsg);
329 sprintf(fname, "final%d", i);
330 safestrncpy(final, BSTR(fname), sizeof final);
332 snprintf(rule, sizeof rule, "%d|%s|%s|%s|%s|%d|%s|%s|%s|%s|%s",
333 active, hfield, compare, htext, sizecomp, sizeval, action, fileinto,
334 redirect, automsg, final
337 CtdlEncodeBase64(encoded_rule, rule, strlen(rule)+1, 0);
338 serv_printf("# WEBCIT_RULE|%d|%s|", i, encoded_rule);
339 output_sieve_rule(hfield, compare, htext, sizecomp, sizeval,
340 action, fileinto, redirect, automsg, final, my_addresses);
355 void save_sieve(void) {
357 char script_names[MAX_SCRIPTS][64];
363 if (!havebstr("save_button")) {
364 AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
369 parse_fields_from_rule_editor();
371 serv_puts("MSIV listscripts");
372 serv_getln(buf, sizeof(buf));
373 if (buf[0] == '1') while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
374 if (num_scripts < MAX_SCRIPTS) {
375 extract_token(script_names[num_scripts], buf, 0, '|', 64);
380 bigaction = ibstr("bigaction");
382 if (bigaction == 0) {
383 serv_puts("MSIV setactive||");
384 serv_getln(buf, sizeof buf);
387 else if (bigaction == 1) {
388 serv_printf("MSIV setactive|%s|", RULES_SCRIPT);
389 serv_getln(buf, sizeof buf);
392 else if (bigaction == 2) {
393 serv_printf("MSIV setactive|%s|", bstr("active_script"));
394 serv_getln(buf, sizeof buf);
397 if (num_scripts > 0) {
398 for (i=0; i<num_scripts; ++i) {
400 * We only want to save the scripts from the "manually edited scripts"
401 * screen. The script that WebCit generates from its ruleset will be
402 * auto-generated by parse_fields_from_rule_editor() and saved there.
404 if (strcasecmp(script_names[i], RULES_SCRIPT)) {
405 serv_printf("MSIV putscript|%s|", script_names[i]);
406 serv_getln(buf, sizeof buf);
408 snprintf(this_name, sizeof this_name, "text_%s", script_names[i]);
409 striplt((char *)BSTR(this_name)); /* TODO: get rid of typecast*/
410 serv_write(BSTR(this_name), strlen(BSTR(this_name)));
417 AppendImportantMessage(_("Your changes have been saved."), -1);
424 * create a new script
425 * take the web environment script name and create it on the citadel server
427 void create_script(void) {
430 serv_printf("MSIV getscript|%s", bstr("script_name"));
431 serv_getln(buf, sizeof buf);
433 while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
439 serv_printf("MSIV putscript|%s", bstr("script_name"));
440 serv_getln(buf, sizeof buf);
444 output_headers(1, 1, 2, 0, 0, 0);
445 do_template("sieve_add");
450 output_headers(1, 1, 2, 0, 0, 0);
451 do_template("sieve_add");
459 void delete_script(void) {
462 serv_printf("MSIV deletescript|%s", bstr("script_name"));
463 serv_getln(buf, sizeof buf);
464 output_headers(1, 1, 2, 0, 0, 0);
465 do_template("sieve_add");
471 * dummy panel indicating to the user that the server doesn't support Sieve
473 void display_no_sieve(void) {
475 output_headers(1, 1, 2, 0, 0, 0);
476 do_template("sieve_none");
481 typedef struct __SieveListing {
488 int ConditionalSieveScriptIsActive(StrBuf *Target, WCTemplputParams *TP)
490 SieveListing *SieveList = (SieveListing *)CTX;
491 return SieveList->IsActive;
493 int ConditionalSieveScriptIsRulesScript(StrBuf *Target, WCTemplputParams *TP)
495 SieveListing *SieveList = (SieveListing *)CTX;
496 return SieveList->IsActive;
498 void tmplput_SieveScriptName(StrBuf *Target, WCTemplputParams *TP)
500 SieveListing *SieveList = (SieveListing *)CTX;
501 StrBufAppendTemplate(Target, TP, SieveList->Name, 0);
503 void tmplput_SieveScriptContent(StrBuf *Target, WCTemplputParams *TP)
505 SieveListing *SieveList = (SieveListing *)CTX;
506 StrBufAppendTemplate(Target, TP, SieveList->Content, 0);
508 void FreeSieveListing(void *vSieveListing)
510 SieveListing *List = (SieveListing*) vSieveListing;
512 FreeStrBuf(&List->Name);
516 HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
521 int rules_script_active = 0;
522 int have_rules_script = 0;
526 SieveListing *Ruleset;
528 if (WCC->KnownSieveScripts != NULL) {
529 return WCC->KnownSieveScripts;
532 serv_puts("MSIV listscripts");
534 StrBuf_ServGetln(Line);
535 if (GetServerStatus(Line, NULL) == 1)
537 WCC->KnownSieveScripts = NewHash(1, Flathash);
539 while(!Done && (StrBuf_ServGetln(Line) >= 0) )
540 if ( (StrLength(Line)==3) &&
541 !strcmp(ChrPtr(Line), "000"))
548 Ruleset = (SieveListing *) malloc(sizeof(SieveListing));
549 Ruleset->Name = NewStrBufPlain(NULL, StrLength(Line));
550 StrBufExtract_NextToken(Ruleset->Name, Line, &pch, '|');
551 Ruleset->IsActive = StrBufExtractNext_int(Line, &pch, '|');
552 Ruleset->Content = NULL;
554 if (!strcasecmp(ChrPtr(Ruleset->Name), RULES_SCRIPT))
556 Ruleset->IsRulesScript = 1;
557 have_rules_script = 1;
558 if (Ruleset->IsActive)
560 rules_script_active = 1;
561 PutBstr(HKEY("__SIEVE:RULESSCRIPT"), NewStrBufPlain(HKEY("1")));
564 Put(WCC->KnownSieveScripts, IKEY(num_scripts), Ruleset, FreeSieveListing);
570 if ((num_scripts > 0) && (rules_script_active == 0)) {
571 PutBstr(HKEY("__SIEVE:EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
574 if (num_scripts > have_rules_script)
582 * ok; we have custom scripts, expose that via bstr, and load the payload.
584 PutBstr(HKEY("__SIEVE:HAVE_EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
586 it = GetNewHashPos(WCC->KnownSieveScripts, 0);
587 while (GetNextHashPos(WCC->KnownSieveScripts, it, &len, &Key, &vRuleset) &&
590 Ruleset = (SieveListing *) vRuleset;
591 serv_printf("MSIV getscript|%s", ChrPtr(Ruleset->Name));
592 StrBuf_ServGetln(Line);
593 if (GetServerStatus(Line, NULL) == 1)
595 Ruleset->Content = NewStrBuf();
597 while(!Done && (rc = StrBuf_ServGetln(Line), rc >= 0) )
598 if ( (StrLength(Line)==3) &&
599 !strcmp(ChrPtr(Line), "000"))
605 if (StrLength(Ruleset->Content)>0)
606 StrBufAppendBufPlain(Ruleset->Content, HKEY("\n"), 0);
607 StrBufAppendBuf(Ruleset->Content, Line, 0);
614 return WCC->KnownSieveScripts;
618 typedef enum __eSieveHfield
637 typedef enum __eSieveCompare {
646 typedef enum __eSieveAction {
656 typedef enum __eSieveSizeComp {
661 typedef enum __eSieveFinal {
667 typedef struct __SieveRule {
671 eSieveCompare compare;
673 eSieveSizeComp sizecomp;
683 int ConditionalSieveRule_hfield(StrBuf *Target, WCTemplputParams *TP)
685 SieveRule *Rule = (SieveRule *)CTX;
687 return GetTemplateTokenNumber(Target,
694 int ConditionalSieveRule_compare(StrBuf *Target, WCTemplputParams *TP)
696 SieveRule *Rule = (SieveRule *)CTX;
697 return GetTemplateTokenNumber(Target,
704 int ConditionalSieveRule_action(StrBuf *Target, WCTemplputParams *TP)
706 SieveRule *Rule = (SieveRule *)CTX;
707 return GetTemplateTokenNumber(Target,
714 int ConditionalSieveRule_sizecomp(StrBuf *Target, WCTemplputParams *TP)
716 SieveRule *Rule = (SieveRule *)CTX;
717 return GetTemplateTokenNumber(Target,
724 int ConditionalSieveRule_final(StrBuf *Target, WCTemplputParams *TP)
726 SieveRule *Rule = (SieveRule *)CTX;
727 return GetTemplateTokenNumber(Target,
734 int ConditionalSieveRule_ThisRoom(StrBuf *Target, WCTemplputParams *TP)
736 SieveRule *Rule = (SieveRule *)CTX;
737 return GetTemplateTokenNumber(Target,
744 int ConditionalSieveRule_Active(StrBuf *Target, WCTemplputParams *TP)
746 SieveRule *Rule = (SieveRule *)CTX;
749 void tmplput_SieveRule_htext(StrBuf *Target, WCTemplputParams *TP)
751 SieveRule *Rule = (SieveRule *)CTX;
752 StrBufAppendTemplate(Target, TP, Rule->htext, 0);
754 void tmplput_SieveRule_fileinto(StrBuf *Target, WCTemplputParams *TP)
756 SieveRule *Rule = (SieveRule *)CTX;
757 StrBufAppendTemplate(Target, TP, Rule->fileinto, 0);
759 void tmplput_SieveRule_redirect(StrBuf *Target, WCTemplputParams *TP)
761 SieveRule *Rule = (SieveRule *)CTX;
762 StrBufAppendTemplate(Target, TP, Rule->redirect, 0);
764 void tmplput_SieveRule_automsg(StrBuf *Target, WCTemplputParams *TP)
766 SieveRule *Rule = (SieveRule *)CTX;
767 StrBufAppendTemplate(Target, TP, Rule->automsg, 0);
769 void tmplput_SieveRule_sizeval(StrBuf *Target, WCTemplputParams *TP)
771 SieveRule *Rule = (SieveRule *)CTX;
772 StrBufAppendPrintf(Target, "%d", Rule->sizeval);
775 void tmplput_SieveRule_lookup_FileIntoRoom(StrBuf *Target, WCTemplputParams *TP)
778 SieveRule *Rule = (SieveRule *)CTX;
780 HashList *Rooms = GetRoomListHashLKRA(Target, TP);
782 GetHash(Rooms, SKEY(Rule->fileinto), &vRoom);
783 WCC->ThisRoom = (folder*) vRoom;
786 void FreeSieveRule(void *vRule)
788 SieveRule *Rule = (SieveRule*) vRule;
790 FreeStrBuf(&Rule->htext);
791 FreeStrBuf(&Rule->fileinto);
792 FreeStrBuf(&Rule->redirect);
793 FreeStrBuf(&Rule->automsg);
798 #define WC_RULE_HEADER "# WEBCIT_RULE|"
799 HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
802 StrBuf *EncodedRule = NULL;
804 const char *pch = NULL;
805 HashList *SieveRules = NULL;
807 SieveRule *Rule = NULL;
809 SieveRules = NewHash(1, Flathash);
810 serv_printf("MSIV getscript|"RULES_SCRIPT);
812 EncodedRule = NewStrBuf();
813 StrBuf_ServGetln(Line);
814 if (GetServerStatus(Line, NULL) == 1)
816 while(!Done && (StrBuf_ServGetln(Line) >= 0) )
817 if ( (StrLength(Line)==3) &&
818 !strcmp(ChrPtr(Line), "000"))
825 /* We just care for our encoded header and skip everything else */
826 if ((StrLength(Line) > sizeof(WC_RULE_HEADER) - 1) &&
827 (!strncasecmp(ChrPtr(Line), HKEY(WC_RULE_HEADER))))
829 StrBufSkip_NTokenS(Line, &pch, '|', 1);
830 n = StrBufExtractNext_int(Line, &pch, '|');
831 StrBufExtract_NextToken(EncodedRule, Line, &pch, '|');
832 StrBufDecodeBase64(EncodedRule);
834 Rule = (SieveRule*) malloc(sizeof(SieveRule));
836 Rule->htext = NewStrBufPlain (NULL, StrLength(EncodedRule));
838 Rule->fileinto = NewStrBufPlain (NULL, StrLength(EncodedRule));
839 Rule->redirect = NewStrBufPlain (NULL, StrLength(EncodedRule));
840 Rule->automsg = NewStrBufPlain (NULL, StrLength(EncodedRule));
842 /* Grab our existing values to populate */
844 Rule->active = StrBufExtractNext_int(EncodedRule, &pch, '|');
845 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
847 Rule->hfield = (eSieveHfield) GetTokenDefine(SKEY(Line), tocc);
848 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
849 Rule->compare = (eSieveCompare) GetTokenDefine(SKEY(Line), contains);
850 StrBufExtract_NextToken(Rule->htext, EncodedRule, &pch, '|');
851 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
852 Rule->sizecomp = (eSieveSizeComp) GetTokenDefine(SKEY(Line), larger);
853 Rule->sizeval = StrBufExtractNext_int(EncodedRule, &pch, '|');
854 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
855 Rule->Action = (eSieveAction) GetTokenDefine(SKEY(Line), keep);
856 StrBufExtract_NextToken(Rule->fileinto, EncodedRule, &pch, '|');
857 StrBufExtract_NextToken(Rule->redirect, EncodedRule, &pch, '|');
858 StrBufExtract_NextToken(Rule->automsg, EncodedRule, &pch, '|');
859 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
860 Rule->final = (eSieveFinal) GetTokenDefine(SKEY(Line), econtinue);
861 Put(SieveRules, IKEY(n), Rule, FreeSieveRule);
867 while (n < MAX_RULES) {
868 Rule = (SieveRule*) malloc(sizeof(SieveRule));
869 memset(Rule, 0, sizeof(SieveRule));
870 Put(SieveRules, IKEY(n), Rule, FreeSieveRule);
876 FreeStrBuf(&EncodedRule);
882 SessionDetachModule_SIEVE
885 DeleteHash(&sess->KnownSieveScripts);
892 REGISTERTokenParamDefine(from);
893 REGISTERTokenParamDefine(tocc);
894 REGISTERTokenParamDefine(subject);
895 REGISTERTokenParamDefine(replyto);
896 REGISTERTokenParamDefine(sender);
897 REGISTERTokenParamDefine(resentfrom);
898 REGISTERTokenParamDefine(resentto);
899 REGISTERTokenParamDefine(envfrom);
900 REGISTERTokenParamDefine(envto);
901 REGISTERTokenParamDefine(xmailer);
902 REGISTERTokenParamDefine(xspamflag);
903 REGISTERTokenParamDefine(xspamstatus);
904 REGISTERTokenParamDefine(listid);
905 REGISTERTokenParamDefine(size);
906 REGISTERTokenParamDefine(all);
908 REGISTERTokenParamDefine(contains);
909 REGISTERTokenParamDefine(notcontains);
910 REGISTERTokenParamDefine(is);
911 REGISTERTokenParamDefine(isnot);
912 REGISTERTokenParamDefine(matches);
913 REGISTERTokenParamDefine(notmatches);
915 REGISTERTokenParamDefine(keep);
916 REGISTERTokenParamDefine(discard);
917 REGISTERTokenParamDefine(reject);
918 REGISTERTokenParamDefine(fileinto);
919 REGISTERTokenParamDefine(redirect);
920 REGISTERTokenParamDefine(vacation);
922 REGISTERTokenParamDefine(larger);
923 REGISTERTokenParamDefine(smaller);
925 /* these are c-keyworads, so do it by hand. */
926 RegisterTokenParamDefine(HKEY("continue"), econtinue);
927 RegisterTokenParamDefine(HKEY("stop"), estop);
929 RegisterIterator("SIEVE:SCRIPTS", 0, NULL, GetSieveScriptListing, NULL, NULL, CTX_SIEVELIST, CTX_NONE, IT_NOFLAG);
931 RegisterConditional(HKEY("COND:SIEVE:SCRIPT:ACTIVE"), 0, ConditionalSieveScriptIsActive, CTX_SIEVELIST);
932 RegisterConditional(HKEY("COND:SIEVE:SCRIPT:ISRULES"), 0, ConditionalSieveScriptIsRulesScript, CTX_SIEVELIST);
933 RegisterNamespace("SIEVE:SCRIPT:NAME", 0, 1, tmplput_SieveScriptName, NULL, CTX_SIEVELIST);
934 RegisterNamespace("SIEVE:SCRIPT:CONTENT", 0, 1, tmplput_SieveScriptContent, NULL, CTX_SIEVELIST);
937 RegisterIterator("SIEVE:RULES", 0, NULL, GetSieveRules, NULL, DeleteHash, CTX_SIEVESCRIPT, CTX_NONE, IT_NOFLAG);
939 RegisterConditional(HKEY("COND:SIEVE:ACTIVE"), 1, ConditionalSieveRule_Active, CTX_SIEVESCRIPT);
940 RegisterConditional(HKEY("COND:SIEVE:HFIELD"), 1, ConditionalSieveRule_hfield, CTX_SIEVESCRIPT);
941 RegisterConditional(HKEY("COND:SIEVE:COMPARE"), 1, ConditionalSieveRule_compare, CTX_SIEVESCRIPT);
942 RegisterConditional(HKEY("COND:SIEVE:ACTION"), 1, ConditionalSieveRule_action, CTX_SIEVESCRIPT);
943 RegisterConditional(HKEY("COND:SIEVE:SIZECOMP"), 1, ConditionalSieveRule_sizecomp, CTX_SIEVESCRIPT);
944 RegisterConditional(HKEY("COND:SIEVE:FINAL"), 1, ConditionalSieveRule_final, CTX_SIEVESCRIPT);
945 RegisterConditional(HKEY("COND:SIEVE:THISROOM"), 1, ConditionalSieveRule_ThisRoom, CTX_SIEVESCRIPT);
947 RegisterNamespace("SIEVE:SCRIPT:HTEXT", 0, 1, tmplput_SieveRule_htext, NULL, CTX_SIEVESCRIPT);
948 RegisterNamespace("SIEVE:SCRIPT:SIZE", 0, 1, tmplput_SieveRule_sizeval, NULL, CTX_SIEVESCRIPT);
949 RegisterNamespace("SIEVE:SCRIPT:FILEINTO", 0, 1, tmplput_SieveRule_fileinto, NULL, CTX_SIEVESCRIPT);
950 RegisterNamespace("SIEVE:SCRIPT:REDIRECT", 0, 1, tmplput_SieveRule_redirect, NULL, CTX_SIEVESCRIPT);
951 RegisterNamespace("SIEVE:SCRIPT:AUTOMSG", 0, 1, tmplput_SieveRule_automsg, NULL, CTX_SIEVESCRIPT);
953 /* fetch our room into WCC->ThisRoom, to evaluate while iterating over rooms with COND:THIS:THAT:ROOM */
954 RegisterNamespace("SIEVE:SCRIPT:LOOKUP_FILEINTO", 0, 1, tmplput_SieveRule_lookup_FileIntoRoom, NULL, CTX_SIEVESCRIPT);
955 WebcitAddUrlHandler(HKEY("save_sieve"), "", 0, save_sieve, 0);
956 WebcitAddUrlHandler(HKEY("create_script"), "", 0, create_script, 0);
957 WebcitAddUrlHandler(HKEY("delete_script"), "", 0, delete_script, 0);