]> code.citadel.org Git - citadel.git/blobdiff - webcit/notes.c
* use SmashStrBuf where apropriate
[citadel.git] / webcit / notes.c
index 4d78d2a9344367d42f103265dce16ef6181216bd..fe75c32b50da145ac2fe9cce759e6278e1d56a12 100644 (file)
@@ -95,10 +95,9 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
                        }
                        else {
                                phase++;
-                               
                                if ((msg4_content_length > 0)
                                    && ( !strcasecmp(msg4_content_encoding, "7bit"))
-                                   && (!strcasecmp(mime_content_type, "text/vnote"))
+                                   && (!strcasecmp(msg4_content_type, "text/vnote"))
                                ) { 
                                        vnote_inline = 1;
                                }
@@ -132,7 +131,7 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
 
        if (StrLength(Data) > 0) {
                if (IsEmptyStr(uid_from_headers)) {
-                       // Convert an old-style note to a vNote
+                       /* Convert an old-style note to a vNote */
                        vnote_from_body = vnote_new();
                        vnote_from_body->uid = strdup(uid_from_headers);
                        vnote_from_body->color_red = pastel_palette[3][0];
@@ -145,8 +144,10 @@ struct vnote *vnote_new_from_msg(long msgnum,int unread)
                        return vnote_from_body;
                }
                else {
-                       struct vnote *v = vnote_new_from_str(ChrPtr(Data));
-                       FreeStrBuf(&Data);
+                       char *Buf = SmashStrBuf(&Data);
+                       
+                       struct vnote *v = vnote_new_from_str(Buf);
+                       free(Buf);
                        return(v);
                }
        }
@@ -188,6 +189,7 @@ void write_vnote_to_server(struct vnote *v)
        
                serv_printf("--%s", boundary);
                serv_puts("Content-type: text/vnote");
+               serv_puts("Content-Transfer-Encoding: 7bit");
                serv_puts("");
                pch = vnote_serialize(v);
                serv_puts(pch);
@@ -216,7 +218,6 @@ void ajax_update_note(void) {
                return;
        }
 
-       // lprintf(9, "Note UID = %s\n", bstr("note_uid"));
        serv_printf("EUID %s", bstr("note_uid"));
        serv_getln(buf, sizeof buf);
        if (buf[0] != '2') {
@@ -226,9 +227,8 @@ void ajax_update_note(void) {
                return;
        }
        msgnum = atol(&buf[4]);
-       // lprintf(9, "Note msg = %ld\n", msgnum);
-
-       // Was this request a delete operation?  If so, nuke it...
+       
+       /* Was this request a delete operation?  If so, nuke it... */
        if (havebstr("deletenote")) {
                if (!strcasecmp(bstr("deletenote"), "yes")) {
                        serv_printf("DELE %d", msgnum);
@@ -240,7 +240,7 @@ void ajax_update_note(void) {
                }
        }
 
-       // If we get to this point it's an update, not a delete
+       /* If we get to this point it's an update, not a delete */
        v = vnote_new_from_msg(msgnum, 0);
        if (!v) {
                begin_ajax_response();
@@ -271,7 +271,7 @@ void ajax_update_note(void) {
         if (havebstr("blue")) {
                v->color_blue = atoi(bstr("blue"));
        }
-        if (havebstr("value")) {       // I would have preferred 'body' but InPlaceEditor hardcodes 'value'
+        if (havebstr("value")) {       /* I would have preferred 'body' but InPlaceEditor hardcodes 'value' */
                if (v->body) free(v->body);
                v->body = strdup(bstr("value"));
        }
@@ -296,13 +296,19 @@ void ajax_update_note(void) {
  *
  * msgnum = Message number on the local server of the note to be displayed
  */
-void display_note(message_summary *Msg, int unread) {
+////TODO: falscher hook
+int notes_LoadMsgFromServer(SharedMessageStatus *Stat, 
+                           void **ViewSpecific, 
+                           message_summary* Msg, 
+                           int is_new, 
+                           int i)
+{
        struct vnote *v;
        WCTemplputParams TP;
 
        memset(&TP, 0, sizeof(WCTemplputParams));
        TP.Filter.ContextType = CTX_VNOTE;
-       v = vnote_new_from_msg(Msg->msgnum, unread);
+       v = vnote_new_from_msg(Msg->msgnum, is_new);
        if (v) {
                TP.Context = v;
                DoTemplate(HKEY("vnoteitem"),
@@ -322,6 +328,7 @@ void display_note(message_summary *Msg, int unread) {
 
                vnote_free(v);
        }
+       return 0;
 }
 
 
@@ -408,10 +415,41 @@ void tmpl_vcard_put_uid(StrBuf *Target, WCTemplputParams *TP)
        StrBufAppendBufPlain(Target, v->uid, -1, 0);
 }
 
+
+
+
+int notes_GetParamsGetServerCall(SharedMessageStatus *Stat, 
+                                void **ViewSpecific, 
+                                long oper, 
+                                char *cmd, 
+                                long len)
+{
+       strcpy(cmd, "MSGS ALL");
+       Stat->maxmsgs = 32767;
+       wprintf("<div id=\"new_notes_here\"></div>\n");
+       return 200;
+
+}
+
+int notes_Cleanup(void **ViewSpecific)
+{
+       end_burst();
+       return 0;
+}
+
+
 void 
 InitModule_NOTES
 (void)
 {
+       RegisterReadLoopHandlerset(
+               VIEW_NOTES,
+               notes_GetParamsGetServerCall,
+               NULL,
+               notes_LoadMsgFromServer,
+               NULL,
+               notes_Cleanup);
+
        WebcitAddUrlHandler(HKEY("add_new_note"), add_new_note, 0);
        WebcitAddUrlHandler(HKEY("ajax_update_note"), ajax_update_note, 0);