X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsieve.c;h=0db8f5ae0bca9b1cdc1ec4e0c26bb51ab867d5a5;hb=fd034bea666febed8eff22cf10f2b72b8b009665;hp=45324730bb1c6996aab3997dcce633f4b5242287;hpb=00d5940d52cd837d77cd8ca0a7ac6d6217df76f8;p=citadel.git diff --git a/webcit/sieve.c b/webcit/sieve.c index 45324730b..0db8f5ae0 100644 --- a/webcit/sieve.c +++ b/webcit/sieve.c @@ -1,29 +1,71 @@ -/* - * $Id: $ - */ -/** - * \defgroup Sieve view/edit sieve config - * \ingroup WebcitDisplayItems +/* + * Copyright (c) 1996-2011 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 as + * published by the Free Software Foundation; either version 3 of the + * License, or (at your option) any later version. + * + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/*@{*/ + #include "webcit.h" #define MAX_SCRIPTS 100 -#define MAX_RULES 25 +#define MAX_RULES 50 #define RULES_SCRIPT "__WebCit_Generated_Script__" -/** - * \brief view/edit sieve config + +/* + * dummy panel indicating to the user that the server doesn't support Sieve + */ +void display_no_sieve(void) { + + output_headers(1, 1, 2, 0, 0, 0); + + wc_printf("
\n"); + wc_printf(""); + wc_printf("

"); + wc_printf(_("View/edit server-side mail filters")); + wc_printf("

\n"); + wc_printf("
\n"); + + wc_printf("
\n"); + + wc_printf("" + "
\n"); + + wc_printf(_("This installation of Citadel was built without support for server-side mail filtering." + "
Please contact your system administrator if you require this feature.
")); + + wc_printf("
\n"); + wDumpContent(1); +} + + +/* + * 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]; + char buf[SIZ]; /* Don't make this buffer smaller or it will restrict line length */ int i; int rules_script_is_active = 0; - + + if (!WC->serv_info->serv_supports_sieve) { + display_no_sieve(); + return; + } memset(script_names, 0, sizeof script_names); @@ -44,7 +86,7 @@ void display_sieve(void) output_headers(1, 1, 2, 0, 0, 0); - wprintf(" \n" ); - wprintf("
\n"); - wprintf("
"); - wprintf("" - ""); - wprintf(_("View/edit server-side mail filters")); - wprintf("\n"); - wprintf("
\n"); - wprintf("
\n
\n"); - - wprintf("
" - "" + wc_printf("
\n"); + wc_printf(""); + wc_printf("

"); + wc_printf(_("View/edit server-side mail filters")); + wc_printf("

\n"); + wc_printf("
\n"); + + wc_printf("
\n"); + + wc_printf("
" "
\n"); - wprintf("
\n"); + wc_printf("\n"); + wc_printf("\n", WC->nonce); - wprintf(_("When new mail arrives: ")); - wprintf("\n"); - wprintf("\n"); + wc_printf("\n"); - wprintf("\n"); + wc_printf("\n"); - wprintf("\n"); + wc_printf(_("Filter it through a manually edited script (advanced users only)")); + wc_printf("\n"); - wprintf(""); + wc_printf(""); /* The "no filtering" div */ - wprintf("
\n"); - wprintf("


"); - wprintf(_("Your incoming mail will not be filtered through any scripts.")); - wprintf("

\n"); - wprintf("
\n"); + wc_printf("
\n"); + wc_printf("


"); + wc_printf(_("Your incoming mail will not be filtered through any scripts.")); + wc_printf("

\n"); + wc_printf("
\n"); /* The "webcit managed scripts" div */ - wprintf("
\n"); + wc_printf("
\n"); display_rules_editor_inner_div(); - wprintf("
\n"); + wc_printf("
\n"); /* The "I'm smart and can write my own Sieve scripts" div */ - wprintf("
\n"); + wc_printf("
\n"); if (num_scripts > 0) { - wprintf(_("The currently active script is: ")); - wprintf("\n"); for (i=0; i%s\n", + wc_printf("\n", ((active_script == i) ? "selected" : ""), script_names[i], script_names[i] ); } } - wprintf("\n"); + wc_printf("\n"); } - wprintf("   "); - wprintf("%s\n", _("Add or delete scripts")); + wc_printf("   "); + wc_printf("%s\n", _("Add or delete scripts")); - wprintf("
\n"); + wc_printf("
\n"); if (num_scripts > 0) { for (i=0; i\n", script_names[i]); - wprintf("\n"); - wprintf("
\n"); + wc_printf("\n"); + wc_printf("
\n"); } } } - wprintf(" \n" ); - wprintf("\n"); + wc_printf("\n"); /* The rest of this is common for all panels... */ - wprintf("

"); - wprintf("", _("Save changes")); - wprintf(" "); - wprintf("\n", _("Cancel")); - wprintf("
\n"); + wc_printf("

"); + wc_printf("", _("Save changes")); + wc_printf(" "); + wc_printf("\n", _("Cancel")); + wc_printf("
\n"); - wprintf("
\n"); + wc_printf("\n"); - wprintf(" \n" ); @@ -192,14 +234,15 @@ void display_sieve(void) -/** - * \brief Helper function for output_sieve_rule() to output strings with quotes escaped +/* + * Helper function for output_sieve_rule() to output strings with quotes escaped */ void osr_sanitize(char *str) { - int i; + int i, len; if (str == NULL) return; - for (i=0; iImportantMessage, _("Cancelled. Changes were not saved.")); display_main_menu(); @@ -539,7 +603,7 @@ void save_sieve(void) { } } - bigaction = atoi(bstr("bigaction")); + bigaction = ibstr("bigaction"); if (bigaction == 0) { serv_puts("MSIV setactive||"); @@ -568,9 +632,9 @@ void save_sieve(void) { serv_getln(buf, sizeof buf); if (buf[0] == '4') { snprintf(this_name, sizeof this_name, "text_%s", script_names[i]); - striplt(bstr(this_name)); - serv_printf("%s", bstr(this_name)); - serv_puts("000"); + striplt((char *)BSTR(this_name)); /* TODO: get rid of typecast*/ + serv_write(BSTR(this_name), strlen(BSTR(this_name))); + serv_puts("\n000"); } } } @@ -582,8 +646,8 @@ void save_sieve(void) { } -/** - * \brief show a list of available scripts to add/remove them +/* + * show a list of available scripts to add/remove them */ void display_add_remove_scripts(char *message) { @@ -591,54 +655,59 @@ void display_add_remove_scripts(char *message) char script_name[256]; output_headers(1, 1, 2, 0, 0, 0); - wprintf("
\n"); - wprintf("" - "
" - "" - ""); - wprintf(_("Add or delete scripts")); - wprintf("
\n" - "
\n
\n" - ); + wc_printf("
\n"); + wc_printf(""); + wc_printf(_("Add or delete scripts")); + wc_printf("\n"); + wc_printf("
\n"); + + wc_printf("
\n"); - if (message != NULL) wprintf(message); + if (message != NULL) { + wc_printf("%s", message); + } - wprintf("
\n"); + wc_printf("
\n"); - svprintf("BOXTITLE", WCS_STRING, _("Add a new script")); - do_template("beginbox"); + do_template("beginbox_1"); + StrBufAppendBufPlain(WC->WBuf, _("Add a new script"), -1, 0); + do_template("beginbox_2"); - wprintf(_("To create a new script, enter the desired " + wc_printf(_("To create a new script, enter the desired " "script name in the box below and click 'Create'.")); - wprintf("

"); + wc_printf("

"); - wprintf("
\n"); - wprintf(_("Script name: ")); - wprintf("
\n" + wc_printf("
\n"); + wc_printf("\n", WC->nonce); + wc_printf(_("Script name: ")); + wc_printf("
\n" "" "
\n", _("Create")); do_template("endbox"); - svprintf("BOXTITLE", WCS_STRING, _("Edit scripts")); - do_template("beginbox"); - wprintf("
%s

\n", + do_template("beginbox_1"); + StrBufAppendBufPlain(WC->WBuf, _("Edit scripts"), -1, 0); + do_template("beginbox_2"); + wc_printf("
%s

\n", _("Return to the script editing screen") ); do_template("endbox"); - wprintf("
"); + wc_printf(""); - svprintf("BOXTITLE", WCS_STRING, _("Delete scripts")); - do_template("beginbox"); + do_template("beginbox_1"); + StrBufAppendBufPlain(WC->WBuf, _("Delete scripts"), -1, 0); + do_template("beginbox_2"); - wprintf(_("To delete an existing script, select the script " + wc_printf(_("To delete an existing script, select the script " "name from the list and click 'Delete'.")); - wprintf("

"); + wc_printf("

"); - wprintf("
" + wc_printf("
" "
\n"); - wprintf("\n", WC->nonce); + wc_printf("
\n"); + wc_printf("
\n"); - wprintf("", _("Delete script"), _("Delete this script?")); - wprintf("
\n"); + wc_printf("
\n"); do_template("endbox"); - wprintf("
\n"); + wc_printf("
\n"); wDumpContent(1); } -/** - * \brief delete a script +/* + * delete a script */ void delete_script(void) { char buf[256]; @@ -679,8 +748,8 @@ void delete_script(void) { -/** - * \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) { @@ -766,7 +835,7 @@ void display_rules_editor_inner_div(void) { * This script should get called by every onChange event... * */ - wprintf(" \n"); + wc_printf(" \n"); free(rooms); } +void _display_add_remove_scripts(void) {display_add_remove_scripts(NULL);} - - - -/*@}*/ +void +InitModule_SIEVE +(void) +{ + WebcitAddUrlHandler(HKEY("display_sieve"), "", 0, display_sieve, 0); + WebcitAddUrlHandler(HKEY("save_sieve"), "", 0, save_sieve, 0); + WebcitAddUrlHandler(HKEY("display_add_remove_scripts"), "", 0, _display_add_remove_scripts, 0); + WebcitAddUrlHandler(HKEY("create_script"), "", 0, create_script, 0); + WebcitAddUrlHandler(HKEY("delete_script"), "", 0, delete_script, 0); +}