From 83cb1d34039f77035a682c3068fd9ab930f95162 Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Sat, 30 Oct 2004 17:43:01 +0000 Subject: [PATCH] Finished fixing forward with attachments. There had been some UI issues when forwarding HTML e-mail. Only one more bug to go. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9664 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/bemail/Enclosures.cpp | 23 +++++++++-------------- src/kits/mail/MailComponent.cpp | 6 ++++-- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/apps/bemail/Enclosures.cpp b/src/apps/bemail/Enclosures.cpp index 10fd2f9f56..ab80668dd8 100644 --- a/src/apps/bemail/Enclosures.cpp +++ b/src/apps/bemail/Enclosures.cpp @@ -352,18 +352,17 @@ TEnclosuresView::Focus(bool focus) } -static void recursive_attachment_search(TEnclosuresView *us,BMailContainer *mail) { +static void recursive_attachment_search(TEnclosuresView *us,BMailContainer *mail,BMailComponent *body) { if (mail == NULL) return; for (int32 i = 0; i < mail->CountComponents(); i++) { BMailComponent *component = mail->GetComponent(i); - if (component->ComponentType() == B_MAIL_MULTIPART_CONTAINER) - recursive_attachment_search(us,dynamic_cast(component)); - - BMailAttachment *attachment = dynamic_cast(component); - if (attachment == NULL) + if (component == body) continue; + + if (component->ComponentType() == B_MAIL_MULTIPART_CONTAINER) + recursive_attachment_search(us,dynamic_cast(component),body); us->fList->AddItem(new TListItem(component)); } @@ -379,11 +378,7 @@ TEnclosuresView::AddEnclosuresFromMail(BEmailMessage *mail) continue; if (component->ComponentType() == B_MAIL_MULTIPART_CONTAINER) - recursive_attachment_search(this,dynamic_cast(component)); - - BMailAttachment *attachment = dynamic_cast(component); - if (attachment == NULL) - continue; + recursive_attachment_search(this,dynamic_cast(component),mail->Body()); fList->AddItem(new TListItem(component)); } @@ -526,14 +521,14 @@ TListItem::DrawItem(BView *owner, BRect r, bool /* complete */) if (fComponent) { // if it's already a mail component, we don't have an icon to // draw, and the entry_ref is invalid - BMailAttachment *attachment = static_cast(fComponent); + BMailAttachment *attachment = dynamic_cast(fComponent); char name[B_FILE_NAME_LENGTH * 2]; - if (attachment->FileName(name) < B_OK) + if ((attachment == NULL) || (attachment->FileName(name) < B_OK)) strcpy(name, "unnamed"); BMimeType type; - if (attachment->MIMEType(&type) == B_OK) + if (fComponent->MIMEType(&type) == B_OK) sprintf(name + strlen(name), ", Type: %s", type.Type()); owner->DrawString(name); diff --git a/src/kits/mail/MailComponent.cpp b/src/kits/mail/MailComponent.cpp index 4a068faeb8..c5f2c22723 100644 --- a/src/kits/mail/MailComponent.cpp +++ b/src/kits/mail/MailComponent.cpp @@ -562,9 +562,11 @@ BTextMailComponent::RenderToRFC822(BPositionIO *render_to) status_t status = ParseRaw(); if (status < B_OK) return status; - + + BMimeType type; + MIMEType(&type); BString content_type; - content_type << "text/plain"; + content_type << type.Type(); // Preserve MIME type (e.g. text/html for (uint32 i = 0; mail_charsets[i].charset != NULL; i++) { if (mail_charsets[i].flavor == charset) {