]> code.citadel.org Git - citadel.git/blobdiff - webcit/notes.c
mkinstalldirs needs to be executable
[citadel.git] / webcit / notes.c
index 11412484097d26ed352d45092b4d8ead3cfde49b..079bb960b687d7b49e463e3bd5a2138841e4805c 100644 (file)
@@ -3,6 +3,8 @@
 #include "dav.h"
 #include "webserver.h"
 
+CtxType CTX_VNOTE = CTX_NONE;
+
 int pastel_palette[9][3] = {
        { 0x80, 0x80, 0x80 },
        { 0xff, 0x80, 0x80 },
@@ -433,11 +435,50 @@ int notes_Cleanup(void **ViewSpecific)
        return 0;
 }
 
+void render_MIME_VNote(StrBuf *Target, WCTemplputParams *TP, StrBuf *FoundCharset)
+{
+       wc_mime_attachment *Mime = CTX(CTX_MIME_ATACH);
+
+       if (StrLength(Mime->Data) == 0)
+               MimeLoadData(Mime);
+       if (StrLength(Mime->Data) > 0) {
+               struct vnote *v;
+               StrBuf *Buf;
+               char *vcard;
+
+               Buf = NewStrBuf();
+               vcard = SmashStrBuf(&Mime->Data);
+               v = vnote_new_from_str(vcard);
+               free (vcard);
+               if (v) {
+                       WCTemplputParams TP;
+                       
+                       memset(&TP, 0, sizeof(WCTemplputParams));
+                       TP.Filter.ContextType = CTX_VNOTE;
+                       TP.Context = v;
+                       DoTemplate(HKEY("mail_vnoteitem"),
+                                  Buf, &TP);
+                       
+                       vnote_free(v);
+                       Mime->Data = Buf;
+               }
+               else {
+                       if (Mime->Data == NULL)
+                               Mime->Data = NewStrBuf();
+                       else
+                               FlushStrBuf(Mime->Data);
+               }
+       }
+}
+
+
 
 void 
 InitModule_NOTES
 (void)
 {
+       RegisterCTX(CTX_VNOTE);
+
        RegisterReadLoopHandlerset(
                VIEW_NOTES,
                notes_GetParamsGetServerCall,
@@ -446,7 +487,8 @@ InitModule_NOTES
                NULL,
                notes_LoadMsgFromServer,
                NULL,
-               notes_Cleanup);
+               notes_Cleanup,
+               NULL);
 
        WebcitAddUrlHandler(HKEY("add_new_note"), "", 0, add_new_note, 0);
        WebcitAddUrlHandler(HKEY("ajax_update_note"), "", 0, ajax_update_note, 0);
@@ -461,4 +503,6 @@ InitModule_NOTES
        RegisterNamespace("VNOTE:BGCOLOR", 0, 0,tmpl_vcard_put_bgcolor, NULL, CTX_VNOTE);
        RegisterNamespace("VNOTE:MSG", 0, 1, tmpl_vcard_put_message, NULL, CTX_VNOTE);
        RegisterNamespace("VNOTE:UID", 0, 0, tmpl_vcard_put_uid, NULL, CTX_VNOTE);
+
+       RegisterMimeRenderer(HKEY("text/vnote"), render_MIME_VNote, 1, 300);
 }