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;
540 serv_puts("MSIV listscripts");
542 StrBuf_ServGetln(Line);
543 if (GetServerStatus(Line, NULL) == 1)
545 WCC->KnownSieveScripts = NewHash(1, Flathash);
547 while(!Done && (StrBuf_ServGetln(Line) >= 0) )
548 if ( (StrLength(Line)==3) &&
549 !strcmp(ChrPtr(Line), "000"))
556 Ruleset = (SieveListing *) malloc(sizeof(SieveListing));
557 Ruleset->Name = NewStrBufPlain(NULL, StrLength(Line));
558 StrBufExtract_NextToken(Ruleset->Name, Line, &pch, '|');
559 Ruleset->IsActive = StrBufExtractNext_int(Line, &pch, '|');
560 Ruleset->Content = NULL;
562 if (!strcasecmp(ChrPtr(Ruleset->Name), RULES_SCRIPT))
564 Ruleset->IsRulesScript = 1;
565 have_rules_script = 1;
566 if (Ruleset->IsActive)
568 rules_script_active = 1;
569 PutBstr(HKEY("__SIEVE:RULESSCRIPT"), NewStrBufPlain(HKEY("1")));
572 Put(WCC->KnownSieveScripts, IKEY(num_scripts), Ruleset, FreeSieveListing);
577 if ((num_scripts > 0) && (rules_script_active == 0))
578 PutBstr(HKEY("__SIEVE:EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
580 if (num_scripts > have_rules_script)
588 * ok; we have custom scripts, expose that via bstr, and load the payload.
590 PutBstr(HKEY("__SIEVE:HAVE_EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
592 it = GetNewHashPos(WCC->KnownSieveScripts, 0);
593 while (GetNextHashPos(WCC->KnownSieveScripts, it, &len, &Key, &vRuleset) &&
596 Ruleset = (SieveListing *) vRuleset;
599 * its the webcit rule? we don't need to load that here.
601 if (Ruleset->IsRulesScript)
604 if (!serv_printf("MSIV getscript|%s", ChrPtr(Ruleset->Name)))
606 StrBuf_ServGetln(Line);
607 if (GetServerStatus(Line, NULL) == 1)
609 Ruleset->Content = NewStrBuf();
610 while(!Done && (rc = StrBuf_ServGetln(Line), rc >= 0) )
611 if ( (StrLength(Line)==3) &&
612 !strcmp(ChrPtr(Line), "000"))
618 if (StrLength(Ruleset->Content)>0)
619 StrBufAppendBufPlain(Ruleset->Content, HKEY("\n"), 0);
620 StrBufAppendBuf(Ruleset->Content, Line, 0);
627 return WCC->KnownSieveScripts;
631 typedef enum __eSieveHfield
650 typedef enum __eSieveCompare {
659 typedef enum __eSieveAction {
669 typedef enum __eSieveSizeComp {
674 typedef enum __eSieveFinal {
680 typedef struct __SieveRule {
684 eSieveCompare compare;
686 eSieveSizeComp sizecomp;
696 int ConditionalSieveRule_hfield(StrBuf *Target, WCTemplputParams *TP)
698 SieveRule *Rule = (SieveRule *)CTX;
700 return GetTemplateTokenNumber(Target,
707 int ConditionalSieveRule_compare(StrBuf *Target, WCTemplputParams *TP)
709 SieveRule *Rule = (SieveRule *)CTX;
710 return GetTemplateTokenNumber(Target,
717 int ConditionalSieveRule_action(StrBuf *Target, WCTemplputParams *TP)
719 SieveRule *Rule = (SieveRule *)CTX;
720 return GetTemplateTokenNumber(Target,
727 int ConditionalSieveRule_sizecomp(StrBuf *Target, WCTemplputParams *TP)
729 SieveRule *Rule = (SieveRule *)CTX;
730 return GetTemplateTokenNumber(Target,
737 int ConditionalSieveRule_final(StrBuf *Target, WCTemplputParams *TP)
739 SieveRule *Rule = (SieveRule *)CTX;
740 return GetTemplateTokenNumber(Target,
747 int ConditionalSieveRule_ThisRoom(StrBuf *Target, WCTemplputParams *TP)
749 SieveRule *Rule = (SieveRule *)CTX;
750 return GetTemplateTokenNumber(Target,
757 int ConditionalSieveRule_Active(StrBuf *Target, WCTemplputParams *TP)
759 SieveRule *Rule = (SieveRule *)CTX;
762 void tmplput_SieveRule_htext(StrBuf *Target, WCTemplputParams *TP)
764 SieveRule *Rule = (SieveRule *)CTX;
765 StrBufAppendTemplate(Target, TP, Rule->htext, 0);
767 void tmplput_SieveRule_fileinto(StrBuf *Target, WCTemplputParams *TP)
769 SieveRule *Rule = (SieveRule *)CTX;
770 StrBufAppendTemplate(Target, TP, Rule->fileinto, 0);
772 void tmplput_SieveRule_redirect(StrBuf *Target, WCTemplputParams *TP)
774 SieveRule *Rule = (SieveRule *)CTX;
775 StrBufAppendTemplate(Target, TP, Rule->redirect, 0);
777 void tmplput_SieveRule_automsg(StrBuf *Target, WCTemplputParams *TP)
779 SieveRule *Rule = (SieveRule *)CTX;
780 StrBufAppendTemplate(Target, TP, Rule->automsg, 0);
782 void tmplput_SieveRule_sizeval(StrBuf *Target, WCTemplputParams *TP)
784 SieveRule *Rule = (SieveRule *)CTX;
785 StrBufAppendPrintf(Target, "%d", Rule->sizeval);
788 void tmplput_SieveRule_lookup_FileIntoRoom(StrBuf *Target, WCTemplputParams *TP)
791 SieveRule *Rule = (SieveRule *)CTX;
793 HashList *Rooms = GetRoomListHashLKRA(Target, TP);
795 GetHash(Rooms, SKEY(Rule->fileinto), &vRoom);
796 WCC->ThisRoom = (folder*) vRoom;
799 void FreeSieveRule(void *vRule)
801 SieveRule *Rule = (SieveRule*) vRule;
803 FreeStrBuf(&Rule->htext);
804 FreeStrBuf(&Rule->fileinto);
805 FreeStrBuf(&Rule->redirect);
806 FreeStrBuf(&Rule->automsg);
811 #define WC_RULE_HEADER "# WEBCIT_RULE|"
812 HashList *GetSieveRules(StrBuf *Target, WCTemplputParams *TP)
815 StrBuf *EncodedRule = NULL;
817 const char *pch = NULL;
818 HashList *SieveRules = NULL;
820 SieveRule *Rule = NULL;
822 SieveRules = NewHash(1, Flathash);
823 serv_printf("MSIV getscript|"RULES_SCRIPT);
825 EncodedRule = NewStrBuf();
826 StrBuf_ServGetln(Line);
827 if (GetServerStatus(Line, NULL) == 1)
829 while(!Done && (StrBuf_ServGetln(Line) >= 0) )
830 if ( (StrLength(Line)==3) &&
831 !strcmp(ChrPtr(Line), "000"))
838 /* We just care for our encoded header and skip everything else */
839 if ((StrLength(Line) > sizeof(WC_RULE_HEADER) - 1) &&
840 (!strncasecmp(ChrPtr(Line), HKEY(WC_RULE_HEADER))))
842 StrBufSkip_NTokenS(Line, &pch, '|', 1);
843 n = StrBufExtractNext_int(Line, &pch, '|');
844 StrBufExtract_NextToken(EncodedRule, Line, &pch, '|');
845 StrBufDecodeBase64(EncodedRule);
847 Rule = (SieveRule*) malloc(sizeof(SieveRule));
849 Rule->htext = NewStrBufPlain (NULL, StrLength(EncodedRule));
851 Rule->fileinto = NewStrBufPlain (NULL, StrLength(EncodedRule));
852 Rule->redirect = NewStrBufPlain (NULL, StrLength(EncodedRule));
853 Rule->automsg = NewStrBufPlain (NULL, StrLength(EncodedRule));
855 /* Grab our existing values to populate */
857 Rule->active = StrBufExtractNext_int(EncodedRule, &pch, '|');
858 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
860 Rule->hfield = (eSieveHfield) GetTokenDefine(SKEY(Line), tocc);
861 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
862 Rule->compare = (eSieveCompare) GetTokenDefine(SKEY(Line), contains);
863 StrBufExtract_NextToken(Rule->htext, EncodedRule, &pch, '|');
864 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
865 Rule->sizecomp = (eSieveSizeComp) GetTokenDefine(SKEY(Line), larger);
866 Rule->sizeval = StrBufExtractNext_int(EncodedRule, &pch, '|');
867 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
868 Rule->Action = (eSieveAction) GetTokenDefine(SKEY(Line), keep);
869 StrBufExtract_NextToken(Rule->fileinto, EncodedRule, &pch, '|');
870 StrBufExtract_NextToken(Rule->redirect, EncodedRule, &pch, '|');
871 StrBufExtract_NextToken(Rule->automsg, EncodedRule, &pch, '|');
872 StrBufExtract_NextToken(Line, EncodedRule, &pch, '|');
873 Rule->final = (eSieveFinal) GetTokenDefine(SKEY(Line), econtinue);
874 Put(SieveRules, IKEY(n), Rule, FreeSieveRule);
880 while (n < MAX_RULES) {
881 Rule = (SieveRule*) malloc(sizeof(SieveRule));
882 memset(Rule, 0, sizeof(SieveRule));
883 Put(SieveRules, IKEY(n), Rule, FreeSieveRule);
889 FreeStrBuf(&EncodedRule);
895 SessionDetachModule_SIEVE
898 DeleteHash(&sess->KnownSieveScripts);
905 REGISTERTokenParamDefine(from);
906 REGISTERTokenParamDefine(tocc);
907 REGISTERTokenParamDefine(subject);
908 REGISTERTokenParamDefine(replyto);
909 REGISTERTokenParamDefine(sender);
910 REGISTERTokenParamDefine(resentfrom);
911 REGISTERTokenParamDefine(resentto);
912 REGISTERTokenParamDefine(envfrom);
913 REGISTERTokenParamDefine(envto);
914 REGISTERTokenParamDefine(xmailer);
915 REGISTERTokenParamDefine(xspamflag);
916 REGISTERTokenParamDefine(xspamstatus);
917 REGISTERTokenParamDefine(listid);
918 REGISTERTokenParamDefine(size);
919 REGISTERTokenParamDefine(all);
921 REGISTERTokenParamDefine(contains);
922 REGISTERTokenParamDefine(notcontains);
923 REGISTERTokenParamDefine(is);
924 REGISTERTokenParamDefine(isnot);
925 REGISTERTokenParamDefine(matches);
926 REGISTERTokenParamDefine(notmatches);
928 REGISTERTokenParamDefine(keep);
929 REGISTERTokenParamDefine(discard);
930 REGISTERTokenParamDefine(reject);
931 REGISTERTokenParamDefine(fileinto);
932 REGISTERTokenParamDefine(redirect);
933 REGISTERTokenParamDefine(vacation);
935 REGISTERTokenParamDefine(larger);
936 REGISTERTokenParamDefine(smaller);
938 /* these are c-keyworads, so do it by hand. */
939 RegisterTokenParamDefine(HKEY("continue"), econtinue);
940 RegisterTokenParamDefine(HKEY("stop"), estop);
942 RegisterIterator("SIEVE:SCRIPTS", 0, NULL, GetSieveScriptListing, NULL, NULL, CTX_SIEVELIST, CTX_NONE, IT_NOFLAG);
944 RegisterConditional(HKEY("COND:SIEVE:SCRIPT:ACTIVE"), 0, ConditionalSieveScriptIsActive, CTX_SIEVELIST);
945 RegisterConditional(HKEY("COND:SIEVE:SCRIPT:ISRULES"), 0, ConditionalSieveScriptIsRulesScript, CTX_SIEVELIST);
946 RegisterNamespace("SIEVE:SCRIPT:NAME", 0, 1, tmplput_SieveScriptName, NULL, CTX_SIEVELIST);
947 RegisterNamespace("SIEVE:SCRIPT:CONTENT", 0, 1, tmplput_SieveScriptContent, NULL, CTX_SIEVELIST);
950 RegisterIterator("SIEVE:RULES", 0, NULL, GetSieveRules, NULL, DeleteHash, CTX_SIEVESCRIPT, CTX_NONE, IT_NOFLAG);
952 RegisterConditional(HKEY("COND:SIEVE:ACTIVE"), 1, ConditionalSieveRule_Active, CTX_SIEVESCRIPT);
953 RegisterConditional(HKEY("COND:SIEVE:HFIELD"), 1, ConditionalSieveRule_hfield, CTX_SIEVESCRIPT);
954 RegisterConditional(HKEY("COND:SIEVE:COMPARE"), 1, ConditionalSieveRule_compare, CTX_SIEVESCRIPT);
955 RegisterConditional(HKEY("COND:SIEVE:ACTION"), 1, ConditionalSieveRule_action, CTX_SIEVESCRIPT);
956 RegisterConditional(HKEY("COND:SIEVE:SIZECOMP"), 1, ConditionalSieveRule_sizecomp, CTX_SIEVESCRIPT);
957 RegisterConditional(HKEY("COND:SIEVE:FINAL"), 1, ConditionalSieveRule_final, CTX_SIEVESCRIPT);
958 RegisterConditional(HKEY("COND:SIEVE:THISROOM"), 1, ConditionalSieveRule_ThisRoom, CTX_SIEVESCRIPT);
960 RegisterNamespace("SIEVE:SCRIPT:HTEXT", 0, 1, tmplput_SieveRule_htext, NULL, CTX_SIEVESCRIPT);
961 RegisterNamespace("SIEVE:SCRIPT:SIZE", 0, 1, tmplput_SieveRule_sizeval, NULL, CTX_SIEVESCRIPT);
962 RegisterNamespace("SIEVE:SCRIPT:FILEINTO", 0, 1, tmplput_SieveRule_fileinto, NULL, CTX_SIEVESCRIPT);
963 RegisterNamespace("SIEVE:SCRIPT:REDIRECT", 0, 1, tmplput_SieveRule_redirect, NULL, CTX_SIEVESCRIPT);
964 RegisterNamespace("SIEVE:SCRIPT:AUTOMSG", 0, 1, tmplput_SieveRule_automsg, NULL, CTX_SIEVESCRIPT);
966 /* fetch our room into WCC->ThisRoom, to evaluate while iterating over rooms with COND:THIS:THAT:ROOM */
967 RegisterNamespace("SIEVE:SCRIPT:LOOKUP_FILEINTO", 0, 1, tmplput_SieveRule_lookup_FileIntoRoom, NULL, CTX_SIEVESCRIPT);
968 WebcitAddUrlHandler(HKEY("save_sieve"), "", 0, save_sieve, 0);
969 WebcitAddUrlHandler(HKEY("create_script"), "", 0, create_script, 0);
970 WebcitAddUrlHandler(HKEY("delete_script"), "", 0, delete_script, 0);