X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=webcit%2Fnotes.c;fp=webcit%2Fnotes.c;h=df39e36a3e3c777b11f285a4cd0b924eb96a4714;hp=11412484097d26ed352d45092b4d8ead3cfde49b;hb=5d38a76f8f06640e3a3f097d584ac52336110f7c;hpb=3326831584e637a75ba7bb33c4a8e9d0427e89d4 diff --git a/webcit/notes.c b/webcit/notes.c index 114124840..df39e36a3 100644 --- a/webcit/notes.c +++ b/webcit/notes.c @@ -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,48 @@ int notes_Cleanup(void **ViewSpecific) return 0; } +void render_MIME_VNote(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset) +{ + 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, @@ -461,4 +500,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); }