* add ical and vcard rendering
authorWilfried Göesgens <willi@citadel.org>
Sat, 8 Nov 2008 23:17:37 +0000 (23:17 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sat, 8 Nov 2008 23:17:37 +0000 (23:17 +0000)
webcit/calendar.c
webcit/messages.c
webcit/static/t/view_message.html
webcit/static/t/view_message_inline_attach.html [new file with mode: 0644]
webcit/webcit.c
webcit/webcit.h

index 9013ad3b11750dbd6c6b8849728dc3e95c234027..8f465c629a75175728a3506c5b8affba77f7a370 100644 (file)
  * 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;
@@ -38,7 +39,7 @@ void cal_process_object(icalcomponent *cal,
 
        /* 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 */
@@ -49,9 +50,9 @@ void cal_process_object(icalcomponent *cal,
                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");
@@ -66,29 +67,29 @@ void cal_process_object(icalcomponent *cal,
                        title = _("This is an unknown type of calendar item.");
                        break;
                }
-               wprintf("</span>");
+               StrBufAppendPrintf(Target, "</span>");
 
-               wprintf("&nbsp;&nbsp;%s",title);
-               wprintf("</div>");
+               StrBufAppendPrintf(Target, "&nbsp;&nbsp;%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");
        }
 
        /*
@@ -109,16 +110,16 @@ void cal_process_object(icalcomponent *cal,
                                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);
                        }
                }
        
@@ -127,43 +128,43 @@ void cal_process_object(icalcomponent *cal,
                        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. */
@@ -171,7 +172,7 @@ void cal_process_object(icalcomponent *cal,
             (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 */
@@ -195,23 +196,23 @@ void cal_process_object(icalcomponent *cal,
                                                 _("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 "
                        "&nbsp;&nbsp;&nbsp;<span class=\"button_link\"> "
                        "<a href=\"javascript:RespondToInvitation('%s_question','%s_title','%ld','%s','Accept');\">%s</a>"
@@ -240,7 +241,7 @@ void cal_process_object(icalcomponent *cal,
                ***********/
 
                /* Display the update buttons */
-               wprintf("<p id=\"%s_question\" >"
+               StrBufAppendPrintf(Target, "<p id=\"%s_question\" >"
                        "%s "
                        "&nbsp;&nbsp;&nbsp;<span class=\"button_link\"> "
                        "<a href=\"javascript:HandleRSVP('%s_question','%s_title','%ld','%s','Update');\">%s</a>"
@@ -257,7 +258,7 @@ void cal_process_object(icalcomponent *cal,
        
        /* Trailing HTML for the display of this object */
        if (recursion_level == 0) {
-               wprintf("<p>&nbsp;</p></div>\n");
+               StrBufAppendPrintf(Target, "<p>&nbsp;</p></div>\n");
        }
 }
 
@@ -270,20 +271,20 @@ void cal_process_object(icalcomponent *cal,
  * \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);
index 64b0c51898426dc7d6e44d56fd6af21ea87e8bc9..093a123e1c9d4a197f7b72b24fe4b5cfb865c75e 100644 (file)
@@ -17,6 +17,9 @@ HashList *MimeRenderHandler = NULL;
 #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);
@@ -500,13 +503,52 @@ void tmplput_MAIL_SUMM_DATE_NO(StrBuf *Target, int nArgs, WCTemplateToken *Token
 
 
 
+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();
@@ -538,7 +580,11 @@ void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundChars
                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);
@@ -553,8 +599,7 @@ void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundChars
                  ( (!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);
@@ -566,20 +611,9 @@ void examine_mime_part(message_summary *Msg, StrBuf *HdrLine, StrBuf *FoundChars
                }
        }
 
-       /** 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;
@@ -907,6 +941,8 @@ void tmplput_MIME_Charset(StrBuf *Target, int nArgs, WCTemplateToken *Token, voi
 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?
 }
 
@@ -1134,7 +1170,7 @@ void fetchname_parsed_vcard(struct vCard *v, char *storename) {
  * \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;
@@ -1157,24 +1193,24 @@ void display_parsed_vcard(struct vCard *v, int full, long msgnum) {
        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("&nbsp;");
+                       StrBufAppendPrintf(Target, "&nbsp;");
                }
-               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) {
 
@@ -1289,27 +1325,27 @@ void display_parsed_vcard(struct vCard *v, int full, long msgnum) {
                        }
                        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 */
@@ -1324,11 +1360,11 @@ void display_parsed_vcard(struct vCard *v, int full, long msgnum) {
 
                                /*** 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");
                                }
                                ***/
                        }
@@ -1338,39 +1374,39 @@ void display_parsed_vcard(struct vCard *v, int full, long msgnum) {
                }
        
                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");
 }
 
 
@@ -1387,14 +1423,15 @@ void display_parsed_vcard(struct vCard *v, int full, long msgnum) {
  * \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);
@@ -1411,7 +1448,7 @@ void display_vcard(char *vcard_source, char alpha, int full, char *storename,
                        || ((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);
@@ -1655,16 +1692,12 @@ void read_message(long msgnum, int printable_view, char *section) {
                        }
 
                        /* 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) {
@@ -2192,7 +2225,7 @@ void display_addressbook(long msgnum, char alpha) {
                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))
@@ -2283,7 +2316,7 @@ void fetch_ab_name(message_summary *Msg, char *namebuf) {
                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);
                }
@@ -4011,6 +4044,12 @@ InitModule_MSG
 
 
 
+       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);
index 16a2b22bf01f37ab6622bbcc901b27cbffd3af4a..c5264eeb94f4f9587ee9f7480b41edd736c01b32 100644 (file)
@@ -31,4 +31,8 @@ onMouseOut=document.getElementById("msg<?MAIL:SUMM:N>").style.visibility="hidden
 <?ITERATE("MAIL:MIME:ATTACH:LINKS", "view_message_list_attach")>
 <?!("X", 2)>
 
+<?!("COND:MAIL:MIME:ATTACH:SUBMESSAGES", 3)>
+<?ITERATE("MAIL:MIME:ATTACH:SUBMESSAGES", "view_message_inline_attach")>
+<?!("X", 3)>
+
 </div>
diff --git a/webcit/static/t/view_message_inline_attach.html b/webcit/static/t/view_message_inline_attach.html
new file mode 100644 (file)
index 0000000..9c02dcb
--- /dev/null
@@ -0,0 +1,5 @@
+<?MAIL:MIME:DATA>
+<img src="display_mime_icon?type=<?MAIL:MIME:CONTENTTYPE("U")>" border=0 align=middle>
+<?MAIL:MIME:FILENAME("X")>  (<?MAIL:MIME:CONTENTTYPE>, <?MAIL:MIME:LENGTH> bytes) 
+[ <a href="mimepart/<?MAIL:MIME:MSGNUM>/<?MAIL:MIME:PARTNUM>/<?MAIL:MIME:FILENAME("U")>" target="wc.<?MAIL:MIME:MSGNUM>.<?MAIL:MIME:PARTNUM>"><?_("View")></a> | 
+ <a href="mimepart_download/<?MAIL:MIME:MSGNUM>/<?MAIL:MIME:PARTNUM>/<?MAIL:MIME:FILENAME("U")>"><?_("Download")></a> ]<br />
index 9c738b1f53f51bc80037afaeb160f8d2bd0fb357..5856fce8a0523ffef72c6d5e455534811219c1f3 100644 (file)
@@ -1054,6 +1054,30 @@ char *load_mimepart(long msgnum, char *partnum)
        }
 }
 
+/*
+ * Read any MIME part of a message, from the server, into memory.
+ */
+void MimeLoadData(wc_mime_attachment *Mime)
+{
+       char buf[SIZ];
+       off_t bytes;
+//// TODO: is there a chance the contenttype is different  to the one we know? 
+       serv_printf("DLAT %ld|%s", Mime->msgnum, ChrPtr(Mime->PartNum));
+       serv_getln(buf, sizeof buf);
+       if (buf[0] == '6') {
+               bytes = extract_long(&buf[4], 0);
+
+               if (Mime->Data == NULL)
+                       Mime->Data = NewStrBufPlain(NULL, bytes);
+               StrBuf_ServGetBLOB(Mime->Data, bytes);
+
+       }
+       else {
+               FlushStrBuf(Mime->Data);
+               /// TODO XImportant message
+       }
+}
+
 
 /*
  * Convenience functions to display a page containing only a string
index bbc026ebaed7b1bdb8e9114f8ea4a15de0201c34..033262460a4d8471d74271ff02be5e438075f92a 100644 (file)
@@ -394,7 +394,10 @@ struct wc_attachment {
        long lvalue;               /* if we put a long... */
 };
 
-typedef struct _wc_mime_attachment {
+
+typedef struct wc_mime_attachment wc_mime_attachment;
+typedef void (*RenderMimeFunc)(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset);
+struct wc_mime_attachment {
        StrBuf *Name;
        StrBuf *FileName;
        StrBuf *PartNum;
@@ -409,10 +412,9 @@ typedef struct _wc_mime_attachment {
        char *data;                /* the data pool; aka this content */
        long lvalue;               /* if we put a long... */
        long msgnum;            /**< the message number on the citadel server derived from message_summary */
-}wc_mime_attachment;
-
+       RenderMimeFunc Renderer;
+};
 
-typedef void (*RenderMimeFunc)(wc_mime_attachment *Mime, StrBuf *RawData, StrBuf *FoundCharset);
 
 /*
  * \brief message summary structure. ???
@@ -792,6 +794,7 @@ char *memreadlinelen(char *start, char *buf, int maxlen, int *retlen);
 long extract_token(char *dest, const char *source, int parmnum, char separator, int maxlen);
 void remove_token(char *source, int parmnum, char separator);
 char *load_mimepart(long msgnum, char *partnum);
+void MimeLoadData(wc_mime_attachment *Mime);
 int pattern2(char *search, char *patn);
 void do_edit_vcard(long, char *, char *, char *);
 void striplt(char *);
@@ -835,7 +838,7 @@ void output_html(const char *, int, int, StrBuf *, StrBuf *);
 void do_listsub(void);
 void toggle_self_service(void);
 ssize_t write(int fd, const void *buf, size_t count);
-void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum);
+void cal_process_attachment(wc_mime_attachment *Mime);
 void load_calendar_item(message_summary *Msg, int unread, struct calview *c);
 void display_calendar(message_summary *Msg, int unread);
 void display_task(message_summary *Msg, int unread);