]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
If user clicks in the empty part of a mailbox view, display a blank pane instead...
[citadel.git] / webcit / messages.c
index 560e031f425022bec7dc0e2251cff59a08d03a7f..207787d67fbcb626f7c51fb62dc28c664b189034 100644 (file)
@@ -362,9 +362,7 @@ void handle_one_message(void)
                        serv_printf("MOVE %ld|_TRASH_|0", msgnum);
                }
                StrBuf_ServGetln(CmdBuf);
-               FlushStrBuf(WCC->ImportantMsg);
-               StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
-               GetServerStatus(CmdBuf, &CitStatus);
+               GetServerStatusMsg(CmdBuf, &CitStatus, 1, 0);
                HttpStatus(CitStatus);
                break;
        case eCOPY:
@@ -375,8 +373,7 @@ void handle_one_message(void)
                        Destination = (StrBuf*) vLine;
                        serv_printf("MOVE %ld|%s|%d", msgnum, ChrPtr(Destination), CopyMessage);
                        StrBuf_ServGetln(CmdBuf);
-                       FlushStrBuf(WCC->ImportantMsg);
-                       StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
+                       GetServerStatusMsg(CmdBuf, NULL, 1, 0);
                        GetServerStatus(CmdBuf, &CitStatus);
                        HttpStatus(CitStatus);
                }
@@ -402,6 +399,8 @@ void embed_message(void) {
        StrBuf *CmdBuf = NULL;
 
        msgnum = StrBufExtract_long(WCC->Hdr->HR.ReqLine, 0, '/');
+       if (msgnum <= 0) return;
+
        switch (WCC->Hdr->HR.eReqType)
        {
        case eGET:
@@ -422,8 +421,7 @@ void embed_message(void) {
                        serv_printf("MOVE %ld|_TRASH_|0", msgnum);
                }
                StrBuf_ServGetln(CmdBuf);
-               FlushStrBuf(WCC->ImportantMsg);
-               StrBufAppendBuf(WCC->ImportantMsg, CmdBuf, 4);
+               GetServerStatusMsg(CmdBuf, NULL, 1, 0);
                break;
        default:
                break;
@@ -1019,12 +1017,10 @@ void post_message(void)
                        /* temporarily change to the drafts room */
                        serv_puts("GOTO _DRAFTS_");
                        StrBuf_ServGetln(Buf);
-                       if (GetServerStatus(Buf, NULL) != 2) {
+                       if (GetServerStatusMsg(Buf, NULL, 1, 2) != 2) {
                                /* You probably don't even have a dumb Drafts folder */
-                               StrBufCutLeft(Buf, 4);
-                               syslog(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
-                               StrBufAppendBufPlain(WCC->ImportantMsg, _("Saved to Drafts failed: "), -1, 0);
-                               StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
+                               syslog(9, "%s:%d: server save to drafts error: %s\n", __FILE__, __LINE__, ChrPtr(Buf) + 4);
+                               AppendImportantMessage(_("Saved to Drafts failed: "), -1);
                                display_enter();
                                FreeStrBuf(&Buf);
                                return;
@@ -1089,7 +1085,7 @@ void post_message(void)
 
                if ((HeaderLen + StrLength(sbstr("msgtext")) < 10) && 
                    (GetCount(WCC->attachments) == 0)){
-                       StrBufAppendBufPlain(WCC->ImportantMsg, _("Refusing to post empty message.\n"), -1, 0);
+                       AppendImportantMessage(_("Refusing to post empty message.\n"), -1);
                        FreeStrBuf(&CmdBuf);
                                
                }
@@ -1115,7 +1111,7 @@ void post_message(void)
                                }
                                post_mime_to_server();
                                if (save_to_drafts) {
-                                       StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been saved to Drafts.\n"), -1, 0);
+                                       AppendImportantMessage(_("Message has been saved to Drafts.\n"), -1);
                                        gotoroom(WCC->CurRoom.name);
                                        display_enter();
                                        FreeStrBuf(&Buf);
@@ -1124,17 +1120,15 @@ void post_message(void)
                                             || (havebstr("cc"  ))
                                             || (havebstr("bcc" ))
                                        ) {
-                                       StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been sent.\n"), -1, 0);
+                                       AppendImportantMessage(_("Message has been sent.\n"), -1);
                                }
                                else {
-                                       StrBufAppendBufPlain(WCC->ImportantMsg, _("Message has been posted.\n"), -1, 0);
+                                       AppendImportantMessage(_("Message has been posted.\n"), -1);
                                }
                                dont_post = lbstr("postseq");
                        } else {
-                               StrBufCutLeft(Buf, 4);
-
-                               syslog(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf));
-                               StrBufAppendBuf(WCC->ImportantMsg, Buf, 0);
+                               syslog(9, "%s:%d: server post error: %s\n", __FILE__, __LINE__, ChrPtr(Buf) + 4);
+                               AppendImportantMessage(ChrPtr(Buf) + 4, StrLength(Buf) - 4);
                                if (save_to_drafts) gotoroom(WCC->CurRoom.name);
                                display_enter();
                                FreeStrBuf(&Buf);
@@ -1405,12 +1399,14 @@ void display_enter(void)
                        {
                                long which = 0;
                                if ((StrLength(Line) > 4) && 
-                                   (ChrPtr(Line)[5] == '='))
+                                   (ChrPtr(Line)[4] == '='))
                                        which = FourHash(ChrPtr(Line), 4);
 
                                if (which == l_subj)
                                {
                                        StrBuf *subj = NewStrBuf();
+                                       StrBuf *FlatSubject;
+
                                        if (!strcasecmp(bstr("replying_mode"), "forward")) {
                                                if (strncasecmp(ChrPtr(Line) + 5, "Fw:", 3)) {
                                                        StrBufAppendBufPlain(subj, HKEY("Fw: "), 0);
@@ -1424,7 +1420,10 @@ void display_enter(void)
                                        StrBufAppendBufPlain(subj, 
                                                             ChrPtr(Line) + 5, 
                                                             StrLength(Line) - 5, 0);
-                                       PutBstr(HKEY("subject"), subj);
+                                       FlatSubject = NewStrBufPlain(NULL, StrLength(subj));
+                                       StrBuf_RFC822_to_Utf8(FlatSubject, subj, NULL, NULL);
+
+                                       PutBstr(HKEY("subject"), FlatSubject);
                                }
 
                                else if (which == l_wefw)
@@ -1449,7 +1448,12 @@ void display_enter(void)
                                }
 
                                else if (which == l_from) {
+                                       StrBuf *FlatFrom;
                                        from = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+                                       FlatFrom = NewStrBufPlain(NULL, StrLength(from));
+                                       StrBuf_RFC822_to_Utf8(FlatFrom, from, NULL, NULL);
+                                       FreeStrBuf(&from);
+                                       from = FlatFrom;
                                        for (i=0; i<StrLength(from); ++i) {
                                                if (ChrPtr(from)[i] == ',')
                                                        StrBufPeek(from, NULL, i, ' ');
@@ -1469,7 +1473,12 @@ void display_enter(void)
                                }
                                
                                else if (which == l_rfca) {
+                                       StrBuf *FlatRFCA;
                                        rfca = NewStrBufPlain(ChrPtr(Line) + 5, StrLength(Line) - 5);
+                                       FlatRFCA = NewStrBufPlain(NULL, StrLength(rfca));
+                                       StrBuf_RFC822_to_Utf8(FlatRFCA, rfca, NULL, NULL);
+                                       FreeStrBuf(&rfca);
+                                       rfca = FlatRFCA;
                                }
                        }