X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsieve.c;h=ee6bcec9e4afa0240ca803485592501d987e09c6;hb=e14009d3009ea58a433e15e51e9c57a255677a01;hp=d7642a1324b12ed4a84d7c9a0d81ea01984c5a3d;hpb=91a299f6f81db844d5480ccb3aaf62ff30955e49;p=citadel.git
diff --git a/webcit/sieve.c b/webcit/sieve.c
index d7642a132..ee6bcec9e 100644
--- a/webcit/sieve.c
+++ b/webcit/sieve.c
@@ -1,205 +1,36 @@
-/*
- * $Id: $
- */
-/**
- * \defgroup Sieve view/edit sieve config
- * \ingroup WebcitDisplayItems
+/*
+ * Copyright (c) 1996-2012 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.
+ *
+ * FIXME: add logic to exclude the webcit-generated script from the manual script selection
*/
-/*@{*/
+
#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");
-
- 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("
");
-
- wprintf("
"
- "
\n");
- do_template("endbox");
-
- wprintf("
\n");
-
+ do_template("sieve_add");
wDumpContent(1);
}
-/**
- * \brief delete a script
- */
-void delete_script(void) {
- char buf[256];
-
- serv_printf("MSIV deletescript|%s", bstr("script_name"));
- serv_getln(buf, sizeof buf);
- display_add_remove_scripts(&buf[4]);
-}
-
-
-
-/**
- * \brief create a new script
+/*
+ * create a new script
* take the web environment script name and create it on the citadel server
*/
void create_script(void) {
@@ -688,427 +440,526 @@ void create_script(void) {
serv_printf("MSIV getscript|%s", bstr("script_name"));
serv_getln(buf, sizeof buf);
- if (buf[0] == '1') {
+ if (buf[0] == '1') { // does script exist already?
while (serv_getln(buf, sizeof(buf)), strcmp(buf, "000")) {
- /* flush */
+ // yes -- flush the output
}
- display_add_remove_scripts(_("A script by that name already exists."));
- return;
}
-
- serv_printf("MSIV putscript|%s", bstr("script_name"));
- serv_getln(buf, sizeof buf);
- if (buf[0] == '4') {
- serv_puts("keep;");
- serv_puts("000");
- display_add_remove_scripts(_("A new script has been created. Return to the script editing screen to edit and activate it."));
- return;
+ else {
+ // no -- safe to create a new one by this name
+ serv_printf("MSIV putscript|%s", bstr("script_name"));
+ serv_getln(buf, sizeof buf);
+ if (buf[0] == '4') {
+ serv_puts("keep;");
+ serv_puts("000");
+ }
}
- display_add_remove_scripts(&buf[4]);
+ display_sieve_add_or_delete();
}
+/*
+ * delete a script
+ */
+void delete_script(void) {
+ char buf[256];
-
-void display_rules_editor_inner_div(void) {
- int i, j;
- char buf[4096];
- char rules[MAX_RULES][2048];
-
- struct {
- char name[128];
- } *rooms = NULL;
- int num_roomnames = 0;
- int num_roomnames_alloc = 0;
-
- int active;
- char hfield[256];
- char compare[32];
- char htext[256];
- char sizecomp[32];
- int sizeval;
- char action[32];
- char fileinto[128];
- char redirect[256];
- char automsg[1024];
- char final[32];
-
- /* load the rules */
- memset(rules, 0, sizeof rules);
- serv_printf("MSIV getscript|%s", RULES_SCRIPT);
- serv_getln(buf, sizeof buf);
- if (buf[0] == '1') while(serv_getln(buf, sizeof (buf)), strcmp(buf, "000")) {
- if (!strncasecmp(buf, "# WEBCIT_RULE|", 14)) {
- j = extract_int(buf, 1);
- remove_token(buf, 0, '|');
- remove_token(buf, 0, '|');
- CtdlDecodeBase64(rules[j], buf, strlen(buf));
- }
- }
-
- /* load the roomnames */
- serv_puts("LKRA");
+ serv_printf("MSIV deletescript|%s", bstr("script_name"));
serv_getln(buf, sizeof buf);
- if (buf[0] == '1') {
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
- ++num_roomnames;
- if (num_roomnames > num_roomnames_alloc) {
- num_roomnames_alloc += 250;
- rooms = realloc(rooms, (num_roomnames_alloc * 128));
- }
- extract_token(rooms[num_roomnames-1].name, buf, 0, '|', 128);
- }
- }
+ display_sieve_add_or_delete();
+}
/*
- * This script should get called by every onChange event...
- *
- */
- wprintf(" \n"
- );
+void display_no_sieve(void) {
+ output_headers(1, 1, 1, 0, 0, 0);
+ do_template("sieve_none");
+ wDumpContent(1);
+}
- wprintf(" ");
- wprintf("