X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsieve.c;h=cce70574ae927c451f165af0488e47215e27ac8c;hb=HEAD;hp=89c5c56ac372f5489e572e89ba984a63eab829fb;hpb=28a21424f7aa43ef885537b4b705f49a0cc4dc08;p=citadel.git
diff --git a/webcit/sieve.c b/webcit/sieve.c
index 89c5c56ac..2e3d61585 100644
--- a/webcit/sieve.c
+++ b/webcit/sieve.c
@@ -1,199 +1,33 @@
-/*
- * $Id: $
- */
-/**
- * \defgroup Sieve view/edit sieve config
- * \ingroup WebcitDisplayItems
+/*
+ * Copyright (c) 1996-2020 by the citadel.org team
+ *
+ * This program is open source software. You can redistribute it and/or
+ * modify it under the terms of the GNU General Public License version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ *
+ * Implementation note: this was kind of hacked up when we switched from Sieve to custom rules.
+ * As a result there's probably some cruft in here...
+ * ajc 2020jul12
+ *
*/
-/*@{*/
+
#include "webcit.h"
+CtxType CTX_SIEVELIST = CTX_NONE;
+CtxType CTX_SIEVESCRIPT = CTX_NONE;
+
#define MAX_SCRIPTS 100
-#define MAX_RULES 25
+#define MAX_RULES 50
#define RULES_SCRIPT "__WebCit_Generated_Script__"
-/**
- * \brief view/edit sieve config
- */
-void display_sieve(void)
-{
- char script_names[MAX_SCRIPTS][64];
- int num_scripts = 0;
- int active_script = (-1);
- char buf[256];
- int i;
- int rules_script_is_active = 0;
-
-
- memset(script_names, 0, sizeof script_names);
-
- serv_puts("MSIV listscripts");
- serv_getln(buf, sizeof(buf));
- if (buf[0] == '1') while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
- if (num_scripts < MAX_SCRIPTS) {
- extract_token(script_names[num_scripts], buf, 0, '|', 64);
- if (extract_int(buf, 1) > 0) {
- active_script = num_scripts;
- if (!strcasecmp(script_names[num_scripts], RULES_SCRIPT)) {
- rules_script_is_active = 1;
- }
- }
- ++num_scripts;
- }
- }
-
- output_headers(1, 1, 2, 0, 0, 0);
-
- wprintf(" \n"
- );
-
- wprintf("
\n");
-
- wprintf(" \n"
- );
-
- wDumpContent(1);
-
-}
-
-
-/**
- * \brief Translate the fields from the rule editor into something we can save...
+/*
+ * Translate the fields from the rule editor into something we can save...
*/
void parse_fields_from_rule_editor(void) {
@@ -208,686 +42,603 @@ void parse_fields_from_rule_editor(void) {
char redirect[256];
char automsg[1024];
char final[32];
-
int i;
char buf[256];
char fname[256];
char rule[2048];
char encoded_rule[4096];
+ char my_addresses[4096];
+
+ /* Enumerate my email addresses in case they are needed for a vacation rule */
+ my_addresses[0] = 0;
+ serv_puts("GVEA");
+ serv_getln(buf, sizeof buf);
+ if (buf[0] == '1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ if (!IsEmptyStr(my_addresses)) {
+ strcat(my_addresses, ",\n");
+ }
+ strcat(my_addresses, "\"");
+ strcat(my_addresses, buf);
+ strcat(my_addresses, "\"");
+ }
- serv_printf("MSIV putscript|%s|", RULES_SCRIPT);
+ /* Now generate the script and write it to the Citadel server */
+ serv_printf("PIBR");
serv_getln(buf, sizeof buf);
if (buf[0] != '4') {
return;
}
- serv_puts("# THIS SCRIPT WAS AUTOMATICALLY GENERATED BY WEBCIT.");
- serv_puts("# ");
- serv_puts("# Do not attempt to manually edit it. If you do so,");
- serv_puts("# your changes will be overwritten the next time WebCit");
- serv_puts("# saves its mail filtering rule set. If you really want");
- serv_puts("# to use these rules as the basis for another script,");
- serv_puts("# copy them to another script and save that instead.");
- serv_puts("");
-
for (i=0; iImportantMessage,
- _("Cancelled. Changes were not saved."));
+ if (!havebstr("save_button")) {
+ AppendImportantMessage(_("Cancelled. Changes were not saved."), -1);
display_main_menu();
return;
}
parse_fields_from_rule_editor();
- serv_puts("MSIV listscripts");
- serv_getln(buf, sizeof(buf));
- if (buf[0] == '1') while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
- if (num_scripts < MAX_SCRIPTS) {
- extract_token(script_names[num_scripts], buf, 0, '|', 64);
- if (extract_int(buf, 1) > 0) {
- active_script = num_scripts;
- }
- ++num_scripts;
- }
- }
-
- bigaction = atoi(bstr("bigaction"));
-
- if (bigaction == 0) {
- serv_puts("MSIV setactive||");
- serv_getln(buf, sizeof buf);
- }
-
- else if (bigaction == 1) {
- serv_printf("MSIV setactive|%s|", RULES_SCRIPT);
- serv_getln(buf, sizeof buf);
- }
-
- else if (bigaction == 2) {
- serv_printf("MSIV setactive|%s|", bstr("active_script"));
- serv_getln(buf, sizeof buf);
- }
-
- if (num_scripts > 0) {
- for (i=0; iImportantMessage, _("Your changes have been saved."));
+ AppendImportantMessage(_("Your changes have been saved."), -1);
display_main_menu();
return;
}
-/**
- * \brief show a list of available scripts to add/remove them
- */
-void display_add_remove_scripts(char *message)
-{
- char buf[256];
- char script_name[256];
-
+void display_sieve_add_or_delete(void) {
output_headers(1, 1, 2, 0, 0, 0);
- wprintf("
\n");
-
- svprintf("BOXTITLE", WCS_STRING, _("Add a new script"));
- do_template("beginbox");
-
- wprintf(_("To create a new script, enter the desired "
- "script name in the box below and click 'Create'."));
- wprintf("
\n",
- _("Return to the script editing screen")
- );
- do_template("endbox");
-
- wprintf("
");
-
- svprintf("BOXTITLE", WCS_STRING, _("Delete scripts"));
- do_template("beginbox");
-
- wprintf(_("To delete an existing script, select the script "
- "name from the list and click 'Delete'."));
- wprintf("