X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fsieve.c;h=ae08f608a21e5b059506877ac65cd975c2d2d4cd;hb=f5c1330914acc193f96892efc191a32ee537dfb5;hp=944057eac784622d01443050dc263dbaeea6b84c;hpb=75b650b277116624d37e059a9adf16930424c645;p=citadel.git diff --git a/webcit/sieve.c b/webcit/sieve.c index 944057eac..ae08f608a 100644 --- a/webcit/sieve.c +++ b/webcit/sieve.c @@ -1,29 +1,54 @@ -/* - * $Id: $ - */ -/** - * \defgroup Sieve view/edit sieve config - * \ingroup WebcitDisplayItems - */ -/*@{*/ #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 +69,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 +218,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(); @@ -413,7 +587,7 @@ void save_sieve(void) { } } - bigaction = atoi(bstr("bigaction")); + bigaction = ibstr("bigaction"); if (bigaction == 0) { serv_puts("MSIV setactive||"); @@ -442,9 +616,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"); } } } @@ -456,8 +630,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) { @@ -465,54 +639,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", NULL); + StrBufAppendBufPlain(WC->WBuf, _("Add a new script"), -1, 0); + do_template("beginbox_2", NULL); - 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"); + do_template("endbox", NULL); - svprintf("BOXTITLE", WCS_STRING, _("Edit scripts")); - do_template("beginbox"); - wprintf("
%s

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

\n", _("Return to the script editing screen") ); - do_template("endbox"); + do_template("endbox", NULL); - wprintf("
"); + wc_printf(""); - svprintf("BOXTITLE", WCS_STRING, _("Delete scripts")); - do_template("beginbox"); + do_template("beginbox_1", NULL); + StrBufAppendBufPlain(WC->WBuf, _("Delete scripts"), -1, 0); + do_template("beginbox_2", NULL); - 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"); - do_template("endbox"); + wc_printf("
\n"); + do_template("endbox", NULL); - wprintf("
\n"); + wc_printf("
\n"); wDumpContent(1); } -/** - * \brief delete a script +/* + * delete a script */ void delete_script(void) { char buf[256]; @@ -553,8 +732,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) { @@ -640,13 +819,29 @@ 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); +}