aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author0xd34df00d <[email protected]>2018-07-04 20:03:49 +0000
committer0xd34df00d <[email protected]>2018-07-04 20:03:49 +0000
commit52042b2b5b8682eab93786e4337bd0cff6e0ab10 (patch)
tree265d69d07601e0a94ddeb6beea76ef4e9d73f7c0
parent#196 Allow overriding CMAKE_CXX_FLAGS (diff)
downloadvmime-52042b2b5b8682eab93786e4337bd0cff6e0ab10.tar.gz
vmime-52042b2b5b8682eab93786e4337bd0cff6e0ab10.zip
Added net::message::getName() + the IMAP implementation.
-rw-r--r--src/vmime/net/imap/IMAPMessagePart.cpp10
-rw-r--r--src/vmime/net/imap/IMAPMessagePart.hpp2
-rw-r--r--src/vmime/net/message.cpp5
-rw-r--r--src/vmime/net/message.hpp10
4 files changed, 27 insertions, 0 deletions
diff --git a/src/vmime/net/imap/IMAPMessagePart.cpp b/src/vmime/net/imap/IMAPMessagePart.cpp
index 1539f2ca..54c29a9e 100644
--- a/src/vmime/net/imap/IMAPMessagePart.cpp
+++ b/src/vmime/net/imap/IMAPMessagePart.cpp
@@ -68,6 +68,11 @@ IMAPMessagePart::IMAPMessagePart(shared_ptr <IMAPMessagePart> parent, const size
part->body_type_basic()->media_basic()->media_subtype()->value());
m_size = part->body_type_basic()->body_fields()->body_fld_octets()->value();
+
+ if (const auto pparam = part->body_type_basic()->body_fields()->body_fld_param())
+ for (const auto& param : pparam->items())
+ if (param->string1()->value() == "NAME")
+ m_name = param->string2()->value();
}
m_structure = null;
@@ -115,6 +120,11 @@ size_t IMAPMessagePart::getNumber() const
return m_number;
}
+string IMAPMessagePart::getName() const
+{
+ return m_name;
+}
+
shared_ptr <const header> IMAPMessagePart::getHeader() const
{
diff --git a/src/vmime/net/imap/IMAPMessagePart.hpp b/src/vmime/net/imap/IMAPMessagePart.hpp
index 3b00887b..2e19f551 100644
--- a/src/vmime/net/imap/IMAPMessagePart.hpp
+++ b/src/vmime/net/imap/IMAPMessagePart.hpp
@@ -59,6 +59,7 @@ public:
const mediaType& getType() const;
size_t getSize() const;
size_t getNumber() const;
+ string getName() const;
shared_ptr <const header> getHeader() const;
@@ -77,6 +78,7 @@ private:
size_t m_number;
size_t m_size;
+ string m_name;
mediaType m_mediaType;
};
diff --git a/src/vmime/net/message.cpp b/src/vmime/net/message.cpp
index 6765e73c..1a0c8c2c 100644
--- a/src/vmime/net/message.cpp
+++ b/src/vmime/net/message.cpp
@@ -36,6 +36,11 @@ namespace vmime {
namespace net {
+string messagePart::getName() const
+{
+ return {};
+}
+
shared_ptr <const messagePart> messagePart::getPartAt(const size_t pos) const
{
return getStructure()->getPartAt(pos);
diff --git a/src/vmime/net/message.hpp b/src/vmime/net/message.hpp
index 4c64a1cf..ae21f2dd 100644
--- a/src/vmime/net/message.hpp
+++ b/src/vmime/net/message.hpp
@@ -99,6 +99,16 @@ public:
*/
virtual size_t getNumber() const = 0;
+ /** Return the name of this part. In particular, this corresponds to
+ * the attachment file name for attachment parts.
+ *
+ * The part name may be empty if the part does not advertise it or
+ * if the underlying protocol does not support it.
+ *
+ * @return part name
+ */
+ virtual string getName() const;
+
/** Return the sub-part at the specified position (zero is the
* first part).
*