diff options
-rw-r--r-- | src/core/abstract/MCAbstractPart.cpp | 33 | ||||
-rw-r--r-- | src/core/abstract/MCAbstractPart.h | 4 | ||||
-rw-r--r-- | src/core/renderer/MCHTMLRenderer.cpp | 2 | ||||
-rw-r--r-- | src/core/rfc822/MCAttachment.cpp | 3 | ||||
-rw-r--r-- | src/objc/abstract/MCOAbstractPart.h | 3 | ||||
-rw-r--r-- | src/objc/abstract/MCOAbstractPart.mm | 1 |
6 files changed, 42 insertions, 4 deletions
diff --git a/src/core/abstract/MCAbstractPart.cpp b/src/core/abstract/MCAbstractPart.cpp index e88a5a36..0956368c 100644 --- a/src/core/abstract/MCAbstractPart.cpp +++ b/src/core/abstract/MCAbstractPart.cpp @@ -28,6 +28,7 @@ AbstractPart::AbstractPart(AbstractPart * other) setContentLocation(other->mContentLocation); setContentDescription(other->mContentDescription); setInlineAttachment(other->mInlineAttachment); + setAttachment(other->mAttachment); setPartType(other->mPartType); setContentTypeParameters(other->mContentTypeParameters); } @@ -42,6 +43,7 @@ void AbstractPart::init() mContentLocation = NULL; mContentDescription = NULL; mInlineAttachment = false; + mAttachment = false; mPartType = PartTypeSingle; mContentTypeParameters = NULL; } @@ -81,6 +83,7 @@ String * AbstractPart::description() result->appendUTF8Format("content-description: %s\n", mContentDescription->UTF8Characters()); } result->appendUTF8Format("inline: %i\n", mInlineAttachment); + result->appendUTF8Format("attachment: %i\n", mAttachment); if (mContentTypeParameters != NULL) { mc_foreachhashmapKeyAndValue(String, key, String, value, mContentTypeParameters) { result->appendUTF8Format("%s: %s\n", key->UTF8Characters(), value->UTF8Characters()); @@ -186,6 +189,16 @@ void AbstractPart::setInlineAttachment(bool inlineAttachment) mInlineAttachment = inlineAttachment; } +bool AbstractPart::isAttachment() +{ + return mAttachment; +} + +void AbstractPart::setAttachment(bool attachment) +{ + mAttachment = attachment; +} + void AbstractPart::importIMAPFields(struct mailimap_body_fields * fields, struct mailimap_body_ext_1part * extension) { @@ -233,7 +246,10 @@ void AbstractPart::importIMAPFields(struct mailimap_body_fields * fields, if (strcasecmp(extension->bd_disposition->dsp_type, "inline") == 0) { setInlineAttachment(true); } - + else if (strcasecmp(extension->bd_disposition->dsp_type, "attachment") == 0) { + setAttachment(true); + } + if (extension->bd_disposition->dsp_attributes != NULL) { clistiter * cur; @@ -345,6 +361,9 @@ HashMap * AbstractPart::serializable() if (mInlineAttachment) { result->setObjectForKey(MCSTR("inlineAttachment"), MCSTR("1")); } + if (mAttachment) { + result->setObjectForKey(MCSTR("attachment"), MCSTR("1")); + } String * partTypeStr; switch (mPartType) { default: @@ -387,6 +406,12 @@ void AbstractPart::importSerializable(HashMap * serializable) setInlineAttachment(true); } } + value = (String *) serializable->objectForKey(MCSTR("attachment")); + if (value != NULL) { + if (value->intValue()) { + setAttachment(true); + } + } value = (String *) serializable->objectForKey(MCSTR("partType")); if (value != NULL) { if (value->isEqual(MCSTR("single"))) { @@ -417,8 +442,9 @@ void AbstractPart::setContentTypeParameters(HashMap * parameters) Array * AbstractPart::allContentTypeParametersNames() { - if (mContentTypeParameters == NULL) + if (mContentTypeParameters == NULL) { return Array::array(); + } return mContentTypeParameters->allKeys(); } @@ -433,8 +459,9 @@ void AbstractPart::setContentTypeParameter(String * name, String * object) void AbstractPart::removeContentTypeParameter(String * name) { - if (mContentTypeParameters == NULL) + if (mContentTypeParameters == NULL) { return; + } mc_foreachhashmapKey(String, key, mContentTypeParameters) { if (key->isEqualCaseInsensitive(name)) { mContentTypeParameters->removeObjectForKey(key); diff --git a/src/core/abstract/MCAbstractPart.h b/src/core/abstract/MCAbstractPart.h index 7a743e1d..88b5b331 100644 --- a/src/core/abstract/MCAbstractPart.h +++ b/src/core/abstract/MCAbstractPart.h @@ -43,6 +43,9 @@ namespace mailcore { virtual bool isInlineAttachment(); virtual void setInlineAttachment(bool inlineAttachment); + virtual bool isAttachment(); + virtual void setAttachment(bool attachment); + virtual AbstractPart * partForContentID(String * contentID); virtual AbstractPart * partForUniqueID(String * uniqueID); @@ -75,6 +78,7 @@ namespace mailcore { String * mContentLocation; String * mContentDescription; bool mInlineAttachment; + bool mAttachment; PartType mPartType; HashMap * mContentTypeParameters; void init(); diff --git a/src/core/renderer/MCHTMLRenderer.cpp b/src/core/renderer/MCHTMLRenderer.cpp index 568c939e..60788d57 100644 --- a/src/core/renderer/MCHTMLRenderer.cpp +++ b/src/core/renderer/MCHTMLRenderer.cpp @@ -92,7 +92,7 @@ static bool isTextPart(AbstractPart * part, htmlRendererContext * context) MCAssert(mimeType != NULL); if (!part->isInlineAttachment()) { - if ((part->filename() != NULL) && context->firstRendered) { + if (part->isAttachment() || ((part->filename() != NULL) && context->firstRendered)) { return false; } } diff --git a/src/core/rfc822/MCAttachment.cpp b/src/core/rfc822/MCAttachment.cpp index 99f3caa0..0968ad83 100644 --- a/src/core/rfc822/MCAttachment.cpp +++ b/src/core/rfc822/MCAttachment.cpp @@ -589,6 +589,9 @@ Attachment * Attachment::attachmentWithSingleMIME(struct mailmime * mime) if (single_fields.fld_disposition->dsp_type->dsp_type == MAILMIME_DISPOSITION_TYPE_INLINE) { result->setInlineAttachment(true); } + else if (single_fields.fld_disposition->dsp_type->dsp_type == MAILMIME_DISPOSITION_TYPE_ATTACHMENT) { + result->setAttachment(true); + } } } diff --git a/src/objc/abstract/MCOAbstractPart.h b/src/objc/abstract/MCOAbstractPart.h index 30dd8f5f..72383f9a 100644 --- a/src/objc/abstract/MCOAbstractPart.h +++ b/src/objc/abstract/MCOAbstractPart.h @@ -73,6 +73,9 @@ typedef NS_ENUM(NSInteger, MCOPartType) { /** Returns whether the part is an explicit inline attachment.*/ @property (nonatomic, assign, getter=isInlineAttachment) BOOL inlineAttachment; +/** Returns whether the part is an explicit attachment.*/ +@property (nonatomic, assign, getter=isAttachment) BOOL attachment; + /** Returns the part with the given Content-ID among this part and its subparts.*/ - (MCOAbstractPart *) partForContentID:(NSString *)contentID; diff --git a/src/objc/abstract/MCOAbstractPart.mm b/src/objc/abstract/MCOAbstractPart.mm index 8608ec61..e71c7413 100644 --- a/src/objc/abstract/MCOAbstractPart.mm +++ b/src/objc/abstract/MCOAbstractPart.mm @@ -72,6 +72,7 @@ MCO_OBJC_SYNTHESIZE_STRING(setContentID, contentID) MCO_OBJC_SYNTHESIZE_STRING(setContentLocation, contentLocation) MCO_OBJC_SYNTHESIZE_STRING(setContentDescription, contentDescription) MCO_OBJC_SYNTHESIZE_BOOL(setInlineAttachment, isInlineAttachment) +MCO_OBJC_SYNTHESIZE_BOOL(setAttachment, isAttachment) - (MCOAbstractPart *) partForContentID:(NSString *)contentID { |