]> code.citadel.org Git - citadel.git/blobdiff - webcit/messages.c
* load_mimepart() was including protocol chatter in its data buffer. Fixed.
[citadel.git] / webcit / messages.c
index 99759b788dd5b0d199f7ae76a1b7475c72600441..97d7f02fb404ccff6305882e528a8b9b93bfaac8 100644 (file)
@@ -50,7 +50,11 @@ int load_message(message_summary *Msg,
        
        Buf = NewStrBuf();
        lprintf(1, "-------------------MSG4 %ld|%s--------------\n", Msg->msgnum, ChrPtr(Msg->PartNum));
-       serv_printf("MSG4 %ld|%s", Msg->msgnum, ChrPtr(Msg->PartNum));
+       if (Msg->PartNum != NULL)
+               serv_printf("MSG4 %ld|%s", Msg->msgnum, ChrPtr(Msg->PartNum));
+       else
+               serv_printf("MSG4 %ld", Msg->msgnum);
+
        StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 1) {
                *Error = NewStrBuf();
@@ -63,14 +67,15 @@ int load_message(message_summary *Msg,
 
        /** begin everythingamundo table */
        HdrToken = NewStrBuf();
-       while ((StrBuf_ServGetlnBuffered(Buf)>=0) && !Done) {
+       while ((StrBuf_ServGetln(Buf)>=0) && !Done) {
                if ( (StrLength(Buf)==3) && 
                    !strcmp(ChrPtr(Buf), "000")) 
                {
                        Done = 1;
                        if (state < 2) {
                                lprintf(1, _("unexpected end of message"));
-                               
+                               if (Msg->MsgBody->Data == NULL)
+                                       Msg->MsgBody->Data = NewStrBuf();
                                Msg->MsgBody->ContentType = NewStrBufPlain(HKEY("text/html"));
                                StrBufAppendPrintf(Msg->MsgBody->Data, "<div><i>");
                                StrBufAppendPrintf(Msg->MsgBody->Data, _("unexpected end of message"));
@@ -376,7 +381,7 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu
 
        serv_printf("MSG0 %ld|1", MsgNum);      /* ask for headers only */
        
-       StrBuf_ServGetlnBuffered(Buf);
+       StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 1) {
                FreeStrBuf(&Buf);
                return NULL;
@@ -384,7 +389,7 @@ message_summary *ReadOneMessageSummary(StrBuf *RawMessage, const char *DefaultSu
 
        Msg = (message_summary*)malloc(sizeof(message_summary));
        memset(Msg, 0, sizeof(message_summary));
-       while (len = StrBuf_ServGetlnBuffered(Buf),
+       while (len = StrBuf_ServGetln(Buf),
               ((len != 3)  ||
                strcmp(ChrPtr(Buf), "000")== 0)){
                buf = ChrPtr(Buf);
@@ -421,7 +426,7 @@ int load_msg_ptrs(const char *servcmd, int with_headers)
        long len;
        int n;
        int skipit;
-       const char *Ptr;
+       const char *Ptr = NULL;
 
        if (WCC->summ != NULL) {
                DeleteHash(&WCC->summ);
@@ -431,13 +436,13 @@ int load_msg_ptrs(const char *servcmd, int with_headers)
        
        Buf = NewStrBuf();
        serv_puts(servcmd);
-       StrBuf_ServGetlnBuffered(Buf);
+       StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) != 1) {
                FreeStrBuf(&Buf);
                return (nummsgs);
        }
        Buf2 = NewStrBuf();
-       while (len = StrBuf_ServGetlnBuffered(Buf),
+       while (len = StrBuf_ServGetln(Buf),
               ((len != 3)  ||
                strcmp(ChrPtr(Buf), "000")!= 0))
        {
@@ -879,6 +884,8 @@ void readloop(long oper)
                        case VIEW_ADDRESSBOOK:
                                ab_name = NULL;
                                fetch_ab_name(Msg, &ab_name);
+                               if (ab_name == NULL) 
+                                       break;
                                ++num_ab;
                                addrbook = realloc(addrbook,
                                                   (sizeof(addrbookent) * num_ab) );
@@ -1327,7 +1334,7 @@ void display_enter(void)
         * message" command really means "add new entry."
         */
        if (WCC->wc_default_view == VIEW_ADDRESSBOOK) {
-               do_edit_vcard(-1, "", "", ChrPtr(WCC->wc_roomname));
+               do_edit_vcard(-1, "", NULL, NULL, "",  ChrPtr(WCC->wc_roomname));
                return;
        }
 
@@ -1569,7 +1576,7 @@ void mimepart(int force_download)
 
        Buf = NewStrBuf();
        serv_printf("OPNA %s|%s", ChrPtr(WCC->UrlFragment2), ChrPtr(WCC->UrlFragment3));
-       StrBuf_ServGetlnBuffered(Buf);
+       StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 2) {
                StrBufCutLeft(Buf, 4);
                bytes = StrBufExtract_long(Buf, 0, '|');
@@ -1579,7 +1586,7 @@ void mimepart(int force_download)
 
                read_server_binary(WCC->WBuf, bytes, Buf);
                serv_puts("CLOS");
-               StrBuf_ServGetlnBuffered(Buf);
+               StrBuf_ServGetln(Buf);
                CT = ChrPtr(ContentType);
 
                if (!force_download) {
@@ -1615,11 +1622,12 @@ StrBuf *load_mimepart(long msgnum, char *partnum)
        
        Buf = NewStrBuf();
        serv_printf("DLAT %ld|%s", msgnum, partnum);
-       StrBuf_ServGetlnBuffered(Buf);
+       StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 6) {
                StrBufCutLeft(Buf, 4);
                bytes = StrBufExtract_long(Buf, 0, '|');
-
+               FreeStrBuf(&Buf);
+               Buf = NewStrBuf();
                StrBuf_ServGetBLOBBuffered(Buf, bytes);
                return(Buf);
        }
@@ -1639,7 +1647,7 @@ void MimeLoadData(wc_mime_attachment *Mime)
 /* TODO: is there a chance the contenttype is different  to the one we know?    */
        serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum));
        Buf = NewStrBuf();
-       StrBuf_ServGetlnBuffered(Buf);
+       StrBuf_ServGetln(Buf);
        if (GetServerStatus(Buf, NULL) == 6) {
                bytes = extract_long(&(ChrPtr(Buf)[4]), 0);
                                     
@@ -1758,3 +1766,10 @@ InitModule_MSG
        WebcitAddUrlHandler(HKEY("roommsgs"), jsonMessageList,0);
        return ;
 }
+
+void
+SessionDetachModule_MSG
+(wcsession *sess)
+{
+       DeleteHash(&sess->summ);
+}