Merge branch 'master' of ssh://git.citadel.org/appl/gitroot/citadel
authorWilfried Goesgens <dothebart@citadel.org>
Thu, 8 Mar 2012 22:37:00 +0000 (23:37 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Thu, 8 Mar 2012 22:37:00 +0000 (23:37 +0100)
citadel/textclient/messages.c
webcit/sieve.c
webcit/static/t/sieve/add.html

index 14c4fd9d7fe85df388ea022215e72d4e3d233ef5..e20888f29097636081056310e7231ad5efafb93f 100644 (file)
@@ -387,6 +387,50 @@ void free_parts(struct parts *p)
 }
 
 
+/*
+ * This is a mini RFC2047 decoder.
+ * It only handles strings encoded from UTF-8 as Quoted-printable.
+ */
+void mini_2047_decode(char *s) {
+       if (!s) return;
+
+       char *qstart = strstr(s, "=?UTF-8?Q?");
+       if (!qstart) return;
+
+       char *qend = strstr(s, "?=");
+       if (!qend) return;
+
+       if (qend <= qstart) return;
+
+       strcpy(qstart, &qstart[10]);
+       qend -= 10;
+
+       char *p = qstart;
+       while (p < qend) {
+
+               if (p[0] == '=') {
+
+                       char ch[3];
+                       ch[0] = p[1];
+                       ch[1] = p[2];
+                       ch[2] = p[3];
+                       int c;
+                       sscanf(ch, "%02x", &c);
+                       p[0] = c;
+                       strcpy(&p[1], &p[3]);
+                       qend -= 2;
+               }
+
+               if (p[0] == '_') {
+                       p[0] = ' ';
+               }
+               
+               ++p;
+       }
+
+       strcpy(qend, &qend[2]);
+}
+
 /*
  * Read a message from the server
  */
@@ -468,7 +512,8 @@ int read_message(CtdlIPC *ipc,
                                scr_printf("part=%s|%s|%s|%s|%s|%ld\n",
                                        ptr->name, ptr->filename, ptr->number,
                                        ptr->disposition, ptr->mimetype,
-                                       ptr->length);
+                                       ptr->length
+                               );
                        }
                }
                scr_printf("\n");
@@ -607,12 +652,12 @@ int read_message(CtdlIPC *ipc,
                safestrncpy(reply_subject, message->subject, sizeof reply_subject);
                if (!IsEmptyStr(message->subject)) {
                        if (dest) {
-                               fprintf(dest, "Subject: %s\n",
-                                                       message->subject);
+                               fprintf(dest, "Subject: %s\n", message->subject);
                        } else {
                                color(DIM_WHITE);
                                scr_printf("Subject: ");
                                color(BRIGHT_CYAN);
+                               mini_2047_decode(message->subject);
                                scr_printf("%s\n", message->subject);
                        }
                }
@@ -1002,7 +1047,6 @@ MECR:     if (mode >= 2) {
                fp = fopen(filename, "r");
                if (fp != NULL) {
                        fmout(screenwidth, fp, NULL, NULL, 0);
-                       /* TODO: why ftell if we ignore the result? */
                        beg = ftell(fp);
                        if (beg < 0)
                                scr_printf("failed to get stream position %s\n", 
index 0c4613bcac0d53d7e30a5aa3f0dfbe2354fe8c6a..3761b11319efc22a03ef82f3beb1bc3ea2bcd42b 100644 (file)
@@ -8,6 +8,8 @@
  * 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"
@@ -16,6 +18,7 @@
 #define MAX_RULES      50
 #define RULES_SCRIPT   "__WebCit_Generated_Script__"
 
+
 /*
  * Helper function for output_sieve_rule() to output strings with quotes escaped
  */
@@ -188,7 +191,6 @@ void output_sieve_rule(char *hfield, char *compare, char *htext, char *sizecomp,
                serv_printf("{");
        }
 
-
        /* Do action */
 
        if (!strcasecmp(action, "keep")) {
@@ -215,26 +217,22 @@ void output_sieve_rule(char *hfield, char *compare, char *htext, char *sizecomp,
                serv_printf("vacation :addresses [%s]\n\"%s\";", my_addresses, automsg);
        }
 
-
        /* Do 'final' action */
 
        if (!strcasecmp(final, "stop")) {
                serv_printf("stop;");
        }
 
-
        /* Close the braces if we're in a conditional loop */
 
        if (strcasecmp(hfield, "all")) {
                serv_printf("}");
        }
 
-
        /* End of rule. */
 }
 
 
-
 /*
  * Translate the fields from the rule editor into something we can save...
  */
@@ -351,7 +349,6 @@ void parse_fields_from_rule_editor(void) {
 }
 
 
-
 /*
  * save sieve config
  */
@@ -359,7 +356,6 @@ void save_sieve(void) {
        int bigaction;
        char script_names[MAX_SCRIPTS][64];
        int num_scripts = 0;
-       int active_script = (-1);       /* this throws a 'set but not used' warning , check this ! */
        int i;
        char this_name[64];
        char buf[256];
@@ -377,9 +373,6 @@ void save_sieve(void) {
        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;
                }
        }
@@ -426,6 +419,7 @@ void save_sieve(void) {
        return;
 }
 
+
 /*
  * create a new script
  * take the web environment script name and create it on the citadel server
@@ -459,8 +453,6 @@ void create_script(void) {
 }
 
 
-
-
 /*
  * delete a script
  */
@@ -473,7 +465,6 @@ void delete_script(void) {
        do_template("sieve_add");
        wDumpContent(1);
 }
-               
 
 
 /*
@@ -534,8 +525,9 @@ HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
        int Done = 0;
        SieveListing *Ruleset;
 
-       if (WCC->KnownSieveScripts != NULL)
+       if (WCC->KnownSieveScripts != NULL) {
                return WCC->KnownSieveScripts;
+       }
 
        serv_puts("MSIV listscripts");
        Line = NewStrBuf();
@@ -574,8 +566,10 @@ HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
                                ++num_scripts;
                        }
        }
-       if ((num_scripts > 0) && (rules_script_active == 0))
+
+       if ((num_scripts > 0) && (rules_script_active == 0)) {
                PutBstr(HKEY("__SIEVE:EXTERNAL_SCRIPT"), NewStrBufPlain(HKEY("1")));
+       }
 
        if (num_scripts > have_rules_script)
        {
@@ -594,19 +588,12 @@ HashList *GetSieveScriptListing(StrBuf *Target, WCTemplputParams *TP)
                       (vRuleset != NULL))
                {
                        Ruleset = (SieveListing *) vRuleset;
-
-                       /*
-                        * its the webcit rule? we don't need to load that here.
-                        */
-                       if (Ruleset->IsRulesScript)
-                               continue;
-
-                       if (!serv_printf("MSIV getscript|%s", ChrPtr(Ruleset->Name)))
-                               break;
+                       serv_printf("MSIV getscript|%s", ChrPtr(Ruleset->Name));
                        StrBuf_ServGetln(Line);
                        if (GetServerStatus(Line, NULL) == 1) 
                        {
                                Ruleset->Content = NewStrBuf();
+                               Done = 0;
                                while(!Done && (rc = StrBuf_ServGetln(Line), rc >= 0) )
                                        if ( (StrLength(Line)==3) && 
                                             !strcmp(ChrPtr(Line), "000")) 
index b0c4bad48f05f0d4e438deb68b68d73237888a36..783a8360d33a2ed670d89abcd66bfbdcb7f0fe3a 100644 (file)
@@ -37,9 +37,6 @@
        <td>
        </tr>
        </table>
-
-there is all sorts of stuff missing here, wtf ?
-
 </div> <!-- end of 'content' div -->
 <?=("trailing")>