Expose Content-Disposition on net message parts.

This commit is contained in:
vincent-richard 2020-05-10 10:34:48 +02:00
parent fe5492ceb3
commit 16912a5ed7
5 changed files with 35 additions and 0 deletions

View File

@ -95,6 +95,13 @@ IMAPMessagePart::IMAPMessagePart(
}
}
}
if (part->body_ext_1part && part->body_ext_1part->body_fld_dsp) {
auto *cdisp = part->body_ext_1part->body_fld_dsp->str();
if (cdisp) {
m_dispType = contentDisposition(cdisp->value);
}
}
}
m_structure = null;
@ -133,6 +140,12 @@ const mediaType& IMAPMessagePart::getType() const {
}
const contentDisposition &IMAPMessagePart::getDisposition() const {
return m_dispType;
}
size_t IMAPMessagePart::getSize() const {
return m_size;

View File

@ -66,6 +66,7 @@ public:
shared_ptr <const IMAPMessagePart> getParent() const;
const mediaType& getType() const;
const contentDisposition &getDisposition() const;
size_t getSize() const;
size_t getNumber() const;
string getName() const;
@ -92,6 +93,7 @@ private:
size_t m_size;
string m_name;
mediaType m_mediaType;
contentDisposition m_dispType;
};

View File

@ -54,6 +54,11 @@ maildirMessagePart::maildirMessagePart(
m_size = part.getBody()->getContents()->getLength();
m_mediaType = part.getBody()->getContentType();
auto cdispField = part.getHeader()->ContentDisposition();
if (cdispField) {
m_dispType = dynamic_cast <const contentDisposition&>(*cdispField->getValue());
}
}
@ -103,6 +108,12 @@ const mediaType& maildirMessagePart::getType() const {
}
const contentDisposition &maildirMessagePart::getDisposition() const {
return m_dispType;
}
size_t maildirMessagePart::getSize() const {
return m_size;

View File

@ -61,6 +61,7 @@ public:
weak_ptr <const maildirMessagePart> getParent() const { return (m_parent); }
const mediaType& getType() const;
const contentDisposition &getDisposition() const;
size_t getSize() const;
size_t getNumber() const;
@ -85,6 +86,7 @@ private:
size_t m_number;
size_t m_size;
mediaType m_mediaType;
contentDisposition m_dispType;
size_t m_headerParsedOffset;
size_t m_headerParsedLength;

View File

@ -33,6 +33,7 @@
#include "vmime/header.hpp"
#include "vmime/mediaType.hpp"
#include "vmime/contentDisposition.hpp"
#include "vmime/utility/progressListener.hpp"
#include "vmime/utility/stream.hpp"
@ -85,6 +86,12 @@ public:
*/
virtual const mediaType& getType() const = 0;
/** Return the disposition type of the content in this part.
*
* @return content disposition type
*/
virtual const contentDisposition &getDisposition() const = 0;
/** Return the size of this part.
*
* @return size of the part (in bytes)