#include "dav.h"
#include "webserver.h"
+CtxType CTX_VNOTE = CTX_NONE;
+
int pastel_palette[9][3] = {
{ 0x80, 0x80, 0x80 },
{ 0xff, 0x80, 0x80 },
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,
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);
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);
}