* msgnum: Message number on the Citadel server
* cal_partnum: MIME part number within that message containing the calendar object
*/
-void cal_process_object(icalcomponent *cal,
+void cal_process_object(StrBuf *Target,
+ icalcomponent *cal,
int recursion_level,
long msgnum,
- char *cal_partnum)
+ const char *cal_partnum)
{
icalcomponent *c;
icalproperty *method = NULL;
/* Leading HTML for the display of this object */
if (recursion_level == 0) {
- wprintf("<div class=\"mimepart\">\n");
+ StrBufAppendPrintf(Target, "<div class=\"mimepart\">\n");
}
/* Look for a method */
the_method = icalproperty_get_method(method);
char *title;
- wprintf("<div id=\"%s_title\">", divname);
- wprintf("<img src=\"static/calarea_48x.gif\">");
- wprintf("<span>");
+ StrBufAppendPrintf(Target, "<div id=\"%s_title\">", divname);
+ StrBufAppendPrintf(Target, "<img src=\"static/calarea_48x.gif\">");
+ StrBufAppendPrintf(Target, "<span>");
switch(the_method) {
case ICAL_METHOD_REQUEST:
title = _("Meeting invitation");
title = _("This is an unknown type of calendar item.");
break;
}
- wprintf("</span>");
+ StrBufAppendPrintf(Target, "</span>");
- wprintf(" %s",title);
- wprintf("</div>");
+ StrBufAppendPrintf(Target, " %s",title);
+ StrBufAppendPrintf(Target, "</div>");
}
- wprintf("<dl>");
+ StrBufAppendPrintf(Target, "<dl>");
p = icalcomponent_get_first_property(cal, ICAL_SUMMARY_PROPERTY);
if (p != NULL) {
- wprintf("<dt>");
- wprintf(_("Summary:"));
- wprintf("</dt><dd>");
- escputs((char *)icalproperty_get_comment(p));
- wprintf("</dd>\n");
+ StrBufAppendPrintf(Target, "<dt>");
+ StrBufAppendPrintf(Target, _("Summary:"));
+ StrBufAppendPrintf(Target, "</dt><dd>");
+ StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
+ StrBufAppendPrintf(Target, "</dd>\n");
}
p = icalcomponent_get_first_property(cal, ICAL_LOCATION_PROPERTY);
if (p != NULL) {
- wprintf("<dt>");
- wprintf(_("Location:"));
- wprintf("</dt><dd>");
- escputs((char *)icalproperty_get_comment(p));
- wprintf("</dd>\n");
+ StrBufAppendPrintf(Target, "<dt>");
+ StrBufAppendPrintf(Target, _("Location:"));
+ StrBufAppendPrintf(Target, "</dt><dd>");
+ StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
+ StrBufAppendPrintf(Target, "</dd>\n");
}
/*
d_tm.tm_mon = t.month - 1;
d_tm.tm_mday = t.day;
wc_strftime(d_str, sizeof d_str, "%x", &d_tm);
- wprintf("<dt>");
- wprintf(_("Date:"));
- wprintf("</dt><dd>%s</dd>", d_str);
+ StrBufAppendPrintf(Target, "<dt>");
+ StrBufAppendPrintf(Target, _("Date:"));
+ StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", d_str);
}
else {
tt = icaltime_as_timet(t);
webcit_fmt_date(buf, tt, 0);
- wprintf("<dt>");
- wprintf(_("Starting date/time:"));
- wprintf("</dt><dd>%s</dd>", buf);
+ StrBufAppendPrintf(Target, "<dt>");
+ StrBufAppendPrintf(Target, _("Starting date/time:"));
+ StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", buf);
}
}
t = icalproperty_get_dtend(p);
tt = icaltime_as_timet(t);
webcit_fmt_date(buf, tt, 0);
- wprintf("<dt>");
- wprintf(_("Ending date/time:"));
- wprintf("</dt><dd>%s</dd>", buf);
+ StrBufAppendPrintf(Target, "<dt>");
+ StrBufAppendPrintf(Target, _("Ending date/time:"));
+ StrBufAppendPrintf(Target, "</dt><dd>%s</dd>", buf);
}
}
p = icalcomponent_get_first_property(cal, ICAL_DESCRIPTION_PROPERTY);
if (p != NULL) {
- wprintf("<dt>");
- wprintf(_("Description:"));
- wprintf("</dt><dd>");
- escputs((char *)icalproperty_get_comment(p));
- wprintf("</dd>\n");
+ StrBufAppendPrintf(Target, "<dt>");
+ StrBufAppendPrintf(Target, _("Description:"));
+ StrBufAppendPrintf(Target, "</dt><dd>");
+ StrEscAppend(Target, NULL, (char *)icalproperty_get_comment(p), 0, 0);
+ StrBufAppendPrintf(Target, "</dd>\n");
}
/* If the component has attendees, iterate through them. */
for (p = icalcomponent_get_first_property(cal, ICAL_ATTENDEE_PROPERTY);
(p != NULL);
p = icalcomponent_get_next_property(cal, ICAL_ATTENDEE_PROPERTY)) {
- wprintf("<dt>");
- wprintf(_("Attendee:"));
- wprintf("</dt><dd>");
+ StrBufAppendPrintf(Target, "<dt>");
+ StrBufAppendPrintf(Target, _("Attendee:"));
+ StrBufAppendPrintf(Target, "</dt><dd>");
safestrncpy(buf, icalproperty_get_attendee(p), sizeof buf);
if (!strncasecmp(buf, "MAILTO:", 7)) {
/** screen name or email address */
strcpy(buf, &buf[7]);
striplt(buf);
- escputs(buf);
- wprintf(" ");
+ StrEscAppend(Target, NULL, buf, 0, 0);
+ StrBufAppendPrintf(Target, " ");
/** participant status */
partstat_as_string(buf, p);
- escputs(buf);
+ StrEscAppend(Target, NULL, buf, 0, 0);
}
- wprintf("</dd>\n");
+ StrBufAppendPrintf(Target, "</dd>\n");
}
/* If the component has subcomponents, recurse through them. */
(c != 0);
c = icalcomponent_get_next_component(cal, ICAL_ANY_COMPONENT)) {
/* Recursively process subcomponent */
- cal_process_object(c, recursion_level+1, msgnum, cal_partnum);
+ cal_process_object(Target, c, recursion_level+1, msgnum, cal_partnum);
}
/* If this is a REQUEST, display conflicts and buttons */
_("This event would conflict with '%s' which is already in your calendar."), conflict_name);
}
- wprintf("<dt>%s",
+ StrBufAppendPrintf(Target, "<dt>%s",
(is_update ?
_("Update:") :
_("CONFLICT:")
)
);
- wprintf("</dt><dd>");
- escputs(conflict_message);
- wprintf("</dd>\n");
+ StrBufAppendPrintf(Target, "</dt><dd>");
+ StrEscAppend(Target, NULL, conflict_message, 0, 0);
+ StrBufAppendPrintf(Target, "</dd>\n");
}
}
lprintf(9, "...done.\n");
- wprintf("</dl>");
+ StrBufAppendPrintf(Target, "</dl>");
/* Display the Accept/Decline buttons */
- wprintf("<p id=\"%s_question\">"
+ StrBufAppendPrintf(Target, "<p id=\"%s_question\">"
"%s "
" <span class=\"button_link\"> "
"<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Accept');\">%s</a>"
***********/
/* Display the update buttons */
- wprintf("<p id=\"%s_question\" >"
+ StrBufAppendPrintf(Target, "<p id=\"%s_question\" >"
"%s "
" <span class=\"button_link\"> "
"<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Update');\">%s</a>"
/* Trailing HTML for the display of this object */
if (recursion_level == 0) {
- wprintf("<p> </p></div>\n");
+ StrBufAppendPrintf(Target, "<p> </p></div>\n");
}
}
* \param msgnum number of the mesage in our db
* \param cal_partnum the number of the calendar item
*/
-void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum)
+void cal_process_attachment(wc_mime_attachment *Mime)
{
icalcomponent *cal;
-
- cal = icalcomponent_new_from_string(part_source);
-
+
+ cal = icalcomponent_new_from_string(ChrPtr(Mime->Data));
+ FlushStrBuf(Mime->Data);
if (cal == NULL) {
- wprintf(_("There was an error parsing this calendar item."));
- wprintf("<br />\n");
+ StrBufAppendPrintf(Mime->Data, _("There was an error parsing this calendar item."));
+ StrBufAppendPrintf(Mime->Data, "<br />\n");
return;
}
ical_dezonify(cal);
- cal_process_object(cal, 0, msgnum, cal_partnum);
+ cal_process_object(Mime->Data, cal, 0, Mime->msgnum, ChrPtr(Mime->PartNum));
/* Free the memory we obtained from libical's constructor */
icalcomponent_free(cal);
#define SENDER_COL_WIDTH_PCT 30 /**< Mailbox view column width */
#define DATE_PLUS_BUTTONS_WIDTH_PCT 20 /**< Mailbox view column width */
+void display_vcard(StrBuf *Target, const char *vcard_source, char alpha, int full, char *storename, long msgnum);
+
+
void display_enter(void);
int longcmp_r(const void *s1, const void *s2);
int summcmp_subj(const void *s1, const void *s2);
+void render_MAIL(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+{
+}
+
+void render_MIME_VCard(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+{
+ MimeLoadData(Mime);
+ if (StrLength(Mime->Data) > 0) {
+ StrBuf *Buf;
+ Buf = NewStrBuf();
+ /** If it's my vCard I can edit it */
+ if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
+ || (!strcasecmp(&WC->wc_roomname[11], USERCONFIGROOM))
+ || (WC->wc_view == VIEW_ADDRESSBOOK)
+ ) {
+ StrBufAppendPrintf(Buf, "<a href=\"edit_vcard?msgnum=%ld&partnum=%s\">",
+ Mime->msgnum, ChrPtr(Mime->PartNum));
+ StrBufAppendPrintf(Buf, "[%s]</a>", _("edit"));
+ }
+
+ /* In all cases, display the full card */
+ display_vcard(Buf, ChrPtr(Mime->Data), 0, 1, NULL, Mime->msgnum);
+ FreeStrBuf(&Mime->Data);
+ Mime->Data = Buf;
+ }
+
+}
+void render_MIME_ICS(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset)
+{
+ MimeLoadData(Mime);
+ if (StrLength(Mime->Data) > 0) {
+ cal_process_attachment(Mime);
+ }
+}
+
+
+
void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundCharset)
{
wc_mime_attachment *mime;
StrBuf *Buf;
+ void *vMimeRenderer;
mime = (wc_mime_attachment*) malloc(sizeof(wc_mime_attachment));
memset(mime, 0, sizeof(wc_mime_attachment));
+ mime->msgnum = Msg->msgnum;
Buf = NewStrBuf();
mime->Name = NewStrBuf();
Msg->AllAttach = NewHash(1,NULL);
Put(Msg->AllAttach, SKEY(mime->PartNum), mime, DestroyMime);
- if (!strcasecmp(ChrPtr(mime->ContentType), "message/rfc822")) {
+
+ if (GetHash(MimeRenderHandler, SKEY(mime->ContentType), &vMimeRenderer) &&
+ vMimeRenderer != NULL)
+ {
+ mime->Renderer = (RenderMimeFunc) vMimeRenderer;
if (Msg->Submessages == NULL)
Msg->Submessages = NewHash(1,NULL);
Put(Msg->Submessages, SKEY(mime->PartNum), mime, reference_free_handler);
( (!strcasecmp(ChrPtr(mime->Disposition), "attachment"))
|| (!strcasecmp(ChrPtr(mime->Disposition), "inline"))
|| (!strcasecmp(ChrPtr(mime->Disposition), ""))))
- {
-
+ {
if (Msg->AttachLinks == NULL)
Msg->AttachLinks = NewHash(1,NULL);
Put(Msg->AttachLinks, SKEY(mime->PartNum), mime, reference_free_handler);
}
}
- /** begin handler prep ** */
- if ( (!strcasecmp(ChrPtr(mime->ContentType), "text/x-vcard"))
- || (!strcasecmp(ChrPtr(mime->ContentType), "text/vcard")) ) {
- Msg->vcard_partnum_ref = mime;
- }
- else if ( (!strcasecmp(ChrPtr(mime->ContentType), "text/calendar"))
- || (!strcasecmp(ChrPtr(mime->ContentType), "application/ics")) ) {
- Msg->cal_partnum_ref = mime;
- }
- /** end handler prep ***/
-
FreeStrBuf(&Buf);
-
}
+
void tmplput_MAIL_SUMM_NATTACH(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
{
message_summary *Msg = (message_summary*) Context;
void tmplput_MIME_Data(StrBuf *Target, int nArgs, WCTemplateToken *Token, void *Context, int ContextType)
{
wc_mime_attachment *mime = (wc_mime_attachment*) Context;
+ if (mime->Renderer != NULL)
+ mime->Renderer(mime, NULL, NULL);
StrBufAppendBuf(Target, mime->Data, 0); /// TODO: check whether we need to load it now?
}
* \param full display all items of the vcard?
* \param msgnum Citadel message pointer
*/
-void display_parsed_vcard(struct vCard *v, int full, long msgnum) {
+void display_parsed_vcard(StrBuf *Target, struct vCard *v, int full, long msgnum) {
int i, j;
char buf[SIZ];
char *name;
strcpy(org, "");
if (!full) {
- wprintf("<TD>");
+ StrBufAppendPrintf(Target, "<TD>");
name = vcard_get_prop(v, "fn", 1, 0, 0);
if (name != NULL) {
- escputs(name);
+ StrEscAppend(Target, NULL, name, 0, 0);
}
else if (name = vcard_get_prop(v, "n", 1, 0, 0), name != NULL) {
strcpy(fullname, name);
vcard_n_prettyize(fullname);
- escputs(fullname);
+ StrEscAppend(Target, NULL, fullname, 0, 0);
}
else {
- wprintf(" ");
+ StrBufAppendPrintf(Target, " ");
}
- wprintf("</TD>");
+ StrBufAppendPrintf(Target, "</TD>");
return;
}
- wprintf("<div align=center>"
+ StrBufAppendPrintf(Target, "<div align=center>"
"<table bgcolor=#aaaaaa width=50%%>");
for (pass=1; pass<=2; ++pass) {
}
else if (!strcasecmp(firsttoken, "adr")) {
if (pass == 2) {
- wprintf("<TR><TD>");
- wprintf(_("Address:"));
- wprintf("</TD><TD>");
+ StrBufAppendPrintf(Target, "<TR><TD>");
+ StrBufAppendPrintf(Target, _("Address:"));
+ StrBufAppendPrintf(Target, "</TD><TD>");
for (j=0; j<num_tokens(thisvalue, ';'); ++j) {
extract_token(buf, thisvalue, j, ';', sizeof buf);
if (!IsEmptyStr(buf)) {
- escputs(buf);
- if (j<3) wprintf("<br />");
- else wprintf(" ");
+ StrEscAppend(Target, NULL, buf, 0, 0);
+ if (j<3) StrBufAppendPrintf(Target, "<br />");
+ else StrBufAppendPrintf(Target, " ");
}
}
- wprintf("</TD></TR>\n");
+ StrBufAppendPrintf(Target, "</TD></TR>\n");
}
}
/* else if (!strcasecmp(firsttoken, "photo") && full && pass == 2) {
// Only output on second pass
- wprintf("<tr><td>");
- wprintf(_("Photo:"));
- wprintf("</td><td>");
- wprintf("<img src=\"/vcardphoto/%ld/\" alt=\"Contact photo\"/>",msgnum);
- wprintf("</td></tr>\n");
+ StrBufAppendPrintf(Target, "<tr><td>");
+ StrBufAppendPrintf(Target, _("Photo:"));
+ StrBufAppendPrintf(Target, "</td><td>");
+ StrBufAppendPrintf(Target, "<img src=\"/vcardphoto/%ld/\" alt=\"Contact photo\"/>",msgnum);
+ StrBufAppendPrintf(Target, "</td></tr>\n");
} */
else if (!strcasecmp(firsttoken, "version")) {
/* ignore */
/*** Don't show extra fields. They're ugly.
if (pass == 2) {
- wprintf("<TR><TD>");
- escputs(thisname);
- wprintf("</TD><TD>");
- escputs(thisvalue);
- wprintf("</TD></TR>\n");
+ StrBufAppendPrintf(Target, "<TR><TD>");
+ StrEscAppend(Target, NULL, thisname, 0, 0);
+ StrBufAppendPrintf(Target, "</TD><TD>");
+ StrEscAppend(Target, NULL, thisvalue, 0, 0);
+ StrBufAppendPrintf(Target, "</TD></TR>\n");
}
***/
}
}
if (pass == 1) {
- wprintf("<TR BGCOLOR=\"#AAAAAA\">"
+ StrBufAppendPrintf(Target, "<TR BGCOLOR=\"#AAAAAA\">"
"<TD COLSPAN=2 BGCOLOR=\"#FFFFFF\">"
"<IMG ALIGN=CENTER src=\"static/viewcontacts_48x.gif\">"
"<FONT SIZE=+1><B>");
- escputs(fullname);
- wprintf("</B></FONT>");
+ StrEscAppend(Target, NULL, fullname, 0, 0);
+ StrBufAppendPrintf(Target, "</B></FONT>");
if (!IsEmptyStr(title)) {
- wprintf("<div align=right>");
- escputs(title);
- wprintf("</div>");
+ StrBufAppendPrintf(Target, "<div align=right>");
+ StrEscAppend(Target, NULL, title, 0, 0);
+ StrBufAppendPrintf(Target, "</div>");
}
if (!IsEmptyStr(org)) {
- wprintf("<div align=right>");
- escputs(org);
- wprintf("</div>");
+ StrBufAppendPrintf(Target, "<div align=right>");
+ StrEscAppend(Target, NULL, org, 0, 0);
+ StrBufAppendPrintf(Target, "</div>");
}
- wprintf("</TD></TR>\n");
+ StrBufAppendPrintf(Target, "</TD></TR>\n");
if (!IsEmptyStr(phone)) {
- wprintf("<tr><td>");
- wprintf(_("Telephone:"));
- wprintf("</td><td>%s</td></tr>\n", phone);
+ StrBufAppendPrintf(Target, "<tr><td>");
+ StrBufAppendPrintf(Target, _("Telephone:"));
+ StrBufAppendPrintf(Target, "</td><td>%s</td></tr>\n", phone);
}
if (!IsEmptyStr(mailto)) {
- wprintf("<tr><td>");
- wprintf(_("E-mail:"));
- wprintf("</td><td>%s</td></tr>\n", mailto);
+ StrBufAppendPrintf(Target, "<tr><td>");
+ StrBufAppendPrintf(Target, _("E-mail:"));
+ StrBufAppendPrintf(Target, "</td><td>%s</td></tr>\n", mailto);
}
}
}
- wprintf("</table></div>\n");
+ StrBufAppendPrintf(Target, "</table></div>\n");
}
* \param storename where to store???
* \param msgnum Citadel message pointer
*/
-void display_vcard(char *vcard_source, char alpha, int full, char *storename,
+void display_vcard(StrBuf *Target, const char *vcard_source, char alpha, int full, char *storename,
long msgnum) {
struct vCard *v;
char *name;
char buf[SIZ];
char this_alpha = 0;
- v = vcard_load(vcard_source);
+ v = vcard_load((char*)vcard_source); ///TODO
+
if (v == NULL) return;
name = vcard_get_prop(v, "n", 1, 0, 0);
|| ((isalpha(alpha)) && (tolower(alpha) == tolower(this_alpha)) )
|| ((!isalpha(alpha)) && (!isalpha(this_alpha)))
) {
- display_parsed_vcard(v, full,msgnum);
+ display_parsed_vcard(Target, v, full,msgnum);
}
vcard_free(v);
}
/* In all cases, display the full card */
- display_vcard(part_source, 0, 1, NULL,msgnum);
+ display_vcard(WC->WBuf, part_source, 0, 1, NULL,msgnum);
}
}
/* Handler for calendar parts */
if (!IsEmptyStr(cal_partnum)) {
- part_source = load_mimepart(msgnum, cal_partnum);
- if (part_source != NULL) {
- cal_process_attachment(part_source, msgnum, cal_partnum);
- }
}
if (part_source) {
if (vcard_source != NULL) {
/** Display the summary line */
- display_vcard(vcard_source, alpha, 0, NULL,msgnum);
+ display_vcard(WC->WBuf, vcard_source, alpha, 0, NULL,msgnum);
/** If it's my vCard I can edit it */
if ( (!strcasecmp(WC->wc_roomname, USERCONFIGROOM))
if (vcard_source != NULL) {
/* Grab the name off the card */
- display_vcard(vcard_source, 0, 0, namebuf, Msg->msgnum);
+ display_vcard(WC->WBuf, vcard_source, 0, 0, namebuf, Msg->msgnum);
free(vcard_source);
}
+ RegisterMimeRenderer(HKEY("message/rfc822"), render_MAIL);
+ RegisterMimeRenderer(HKEY("text/x-vcard"), render_MIME_VCard);
+ RegisterMimeRenderer(HKEY("text/vcard"), render_MIME_VCard);
+ RegisterMimeRenderer(HKEY("text/calendar"), render_MIME_ICS);
+ RegisterMimeRenderer(HKEY("application/ics"), render_MIME_ICS);
+
RegisterMimeRenderer(HKEY("text/x-citadel-variformat"), render_MAIL_variformat);
RegisterMimeRenderer(HKEY("text/plain"), render_MAIL_text_plain);
RegisterMimeRenderer(HKEY("text"), render_MAIL_text_plain);