HUGE PATCH. This moves all of mime_parser.c and all
[citadel.git] / webcit / sieve.c
index 929faafc598eb3f01981d492b2311fe0d7a056cb..831151045c0a9ddd4e8c224fd49e5fc26d65ba57 100644 (file)
@@ -73,13 +73,13 @@ void display_sieve(void)
        );
 
        wprintf("<div id=\"banner\">\n");
-       wprintf("<TABLE class=\"sieve_banner\"><TR><TD>");
-       wprintf("<SPAN CLASS=\"titlebar\">"
-               "<img src=\"static/advanpage2_48x.gif\">");
+       wprintf("<img src=\"static/advanpage2_48x.gif\">");
+       wprintf("<h1>");
        wprintf(_("View/edit server-side mail filters"));
-       wprintf("</SPAN>\n");
-       wprintf("</TD></TR></TABLE>\n");
-       wprintf("</div>\n<div id=\"content\">\n");
+       wprintf("</h1>\n");
+       wprintf("</div>\n");
+
+       wprintf("<div id=\"content\" class=\"service\">\n");
 
        wprintf("<div class=\"fix_scrollbar_bug\">"
                "<table class=\"sieve_background\">"
@@ -197,10 +197,11 @@ void display_sieve(void)
  * \brief      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; i<strlen(str); ++i) {
+       len = strlen(str);
+       for (i=0; i<len; ++i) {
                if (str[i]=='\"') {
                        str[i] = '\'' ;
                }
@@ -215,7 +216,8 @@ void osr_sanitize(char *str) {
  * \brief      Output parseable Sieve script code based on rules input
  */
 void output_sieve_rule(char *hfield, char *compare, char *htext, char *sizecomp, int sizeval,
-                       char *action, char *fileinto, char *redirect, char *automsg, char *final)
+                       char *action, char *fileinto, char *redirect, char *automsg, char *final,
+                       char *my_addresses)
 {
        char *comp1 = "";
        char *comp2 = "";
@@ -380,7 +382,7 @@ void output_sieve_rule(char *hfield, char *compare, char *htext, char *sizecomp,
        }
 
        else if (!strcasecmp(action, "vacation")) {
-               serv_printf("vacation \"%s\";", automsg);
+               serv_printf("vacation :addresses [%s]\n\"%s\";", my_addresses, automsg);
        }
 
 
@@ -419,13 +421,27 @@ 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, "\"");
+       }
 
+       /* Now generate the script and write it to the Citadel server */
        serv_printf("MSIV putscript|%s|", RULES_SCRIPT);
        serv_getln(buf, sizeof buf);
        if (buf[0] != '4') {
@@ -493,7 +509,7 @@ void parse_fields_from_rule_editor(void) {
                        CtdlEncodeBase64(encoded_rule, rule, strlen(rule)+1, 0);
                        serv_printf("# WEBCIT_RULE|%d|%s|", i, encoded_rule);
                        output_sieve_rule(hfield, compare, htext, sizecomp, sizeval,
-                                       action, fileinto, redirect, automsg, final);
+                                       action, fileinto, redirect, automsg, final, my_addresses);
                        serv_printf("");
                }
 
@@ -502,7 +518,6 @@ void parse_fields_from_rule_editor(void) {
 
        serv_puts("stop;");
        serv_puts("000");
-
 }
 
 
@@ -519,7 +534,7 @@ void save_sieve(void) {
        char this_name[64];
        char buf[256];
 
-       if (strlen(bstr("save_button")) == 0) {
+       if (IsEmptyStr(bstr("save_button"))) {
                strcpy(WC->ImportantMessage,
                        _("Cancelled.  Changes were not saved."));
                display_main_menu();
@@ -593,14 +608,12 @@ void display_add_remove_scripts(char *message)
 
        output_headers(1, 1, 2, 0, 0, 0);
        wprintf("<div id=\"banner\">\n");
-       wprintf("<table class=\"sieve_banner\"><tr>"
-               "<td>"
-               "<span class=\"titlebar\">"
-               "<img src=\"static/advanpage2_48x.gif\">");
+       wprintf("<img src=\"static/advanpage2_48x.gif\">");
        wprintf(_("Add or delete scripts"));
-       wprintf("</span></td></tr></table>\n"
-               "</div>\n<div id=\"content\">\n"
-       );
+       wprintf("</h1>\n");
+       wprintf("</div>\n");
+       
+       wprintf("<div id=\"content\" class=\"service\">\n");
 
        if (message != NULL) wprintf(message);