aboutsummaryrefslogtreecommitdiffstats
path: root/vmime
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--vmime/bodyPart.hpp1
-rw-r--r--vmime/contentHandler.hpp3
-rw-r--r--vmime/net/imap/IMAPMessage.hpp19
-rw-r--r--vmime/net/imap/IMAPMessagePartContentHandler.hpp73
-rw-r--r--vmime/net/imap/IMAPPart.hpp88
-rw-r--r--vmime/net/imap/IMAPStructure.hpp67
-rw-r--r--vmime/net/maildir/maildirMessage.hpp2
-rw-r--r--vmime/net/message.hpp12
-rw-r--r--vmime/net/pop3/POP3Message.hpp2
9 files changed, 266 insertions, 1 deletions
diff --git a/vmime/bodyPart.hpp b/vmime/bodyPart.hpp
index 47c11cb1..aa0f0408 100644
--- a/vmime/bodyPart.hpp
+++ b/vmime/bodyPart.hpp
@@ -46,6 +46,7 @@ class bodyPart : public component
public:
bodyPart();
+ bodyPart(weak_ref <vmime::bodyPart> parentPart);
/** Return the header section of this part.
*
diff --git a/vmime/contentHandler.hpp b/vmime/contentHandler.hpp
index aa485f5c..38e4e245 100644
--- a/vmime/contentHandler.hpp
+++ b/vmime/contentHandler.hpp
@@ -87,7 +87,8 @@ public:
virtual void extractRaw(utility::outputStream& os, utility::progressListener* progress = NULL) const = 0;
/** Returns the actual length of data. WARNING: this can return 0 if no
- * length was specified when setting data of this object.
+ * length was specified when setting data of this object, or if the
+ * length is not known).
*
* @return length of data
*/
diff --git a/vmime/net/imap/IMAPMessage.hpp b/vmime/net/imap/IMAPMessage.hpp
index 690e5e2a..edbf69ff 100644
--- a/vmime/net/imap/IMAPMessage.hpp
+++ b/vmime/net/imap/IMAPMessage.hpp
@@ -28,6 +28,8 @@
#include "vmime/net/message.hpp"
#include "vmime/net/folder.hpp"
+#include "vmime/net/imap/IMAPParser.hpp"
+
namespace vmime {
namespace net {
@@ -75,12 +77,29 @@ public:
void fetchPartHeader(ref <part> p);
+ ref <vmime::message> getParsedMessage();
+
private:
void fetch(ref <IMAPFolder> folder, const int options);
void processFetchResponse(const int options, const IMAPParser::msg_att* msgAtt);
+ /** Recursively fetch part header for all parts in the structure.
+ *
+ * @param str structure for which to fetch parts headers
+ */
+ void fetchPartHeaderForStructure(ref <structure> str);
+
+ /** Recursively contruct parsed message from structure.
+ * Called by getParsedMessage().
+ *
+ * @param parentPart root body part (the message)
+ * @param str structure for which to construct part
+ * @param level current nesting level (0 is root)
+ */
+ void constructParsedMessage(ref <bodyPart> parentPart, ref <structure> str, int level = 0);
+
void extract(ref <const part> p, utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool headerOnly, const bool peek) const;
diff --git a/vmime/net/imap/IMAPMessagePartContentHandler.hpp b/vmime/net/imap/IMAPMessagePartContentHandler.hpp
new file mode 100644
index 00000000..0c4641e9
--- /dev/null
+++ b/vmime/net/imap/IMAPMessagePartContentHandler.hpp
@@ -0,0 +1,73 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2009 Vincent Richard <[email protected]>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 3 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// Linking this library statically or dynamically with other modules is making
+// a combined work based on this library. Thus, the terms and conditions of
+// the GNU General Public License cover the whole combination.
+//
+
+#ifndef VMIME_NET_IMAP_IMAPMESSAGEPARTCONTENTHANDLER_HPP_INCLUDED
+#define VMIME_NET_IMAP_IMAPMESSAGEPARTCONTENTHANDLER_HPP_INCLUDED
+
+
+#include "vmime/contentHandler.hpp"
+#include "vmime/net/imap/IMAPMessage.hpp"
+
+
+namespace vmime {
+namespace net {
+namespace imap {
+
+
+class IMAPMessagePartContentHandler : public contentHandler
+{
+public:
+
+ IMAPMessagePartContentHandler(ref <IMAPMessage> msg, ref <class part> part, const vmime::encoding& encoding);
+
+ ref <contentHandler> clone() const;
+
+ void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const;
+
+ void extract(utility::outputStream& os, utility::progressListener* progress = NULL) const;
+ void extractRaw(utility::outputStream& os, utility::progressListener* progress = NULL) const;
+
+ string::size_type getLength() const;
+
+ bool isEncoded() const;
+
+ const vmime::encoding& getEncoding() const;
+
+ bool isEmpty() const;
+
+private:
+
+ weak_ref <IMAPMessage> m_message;
+ weak_ref <part> m_part;
+
+ vmime::encoding m_encoding;
+};
+
+
+} // imap
+} // net
+} // vmime
+
+
+#endif // VMIME_NET_IMAP_IMAPMESSAGEPARTCONTENTHANDLER_HPP_INCLUDED
+
diff --git a/vmime/net/imap/IMAPPart.hpp b/vmime/net/imap/IMAPPart.hpp
new file mode 100644
index 00000000..d84db1bd
--- /dev/null
+++ b/vmime/net/imap/IMAPPart.hpp
@@ -0,0 +1,88 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2009 Vincent Richard <[email protected]>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 3 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// Linking this library statically or dynamically with other modules is making
+// a combined work based on this library. Thus, the terms and conditions of
+// the GNU General Public License cover the whole combination.
+//
+
+#ifndef VMIME_NET_IMAP_IMAPPART_HPP_INCLUDED
+#define VMIME_NET_IMAP_IMAPPART_HPP_INCLUDED
+
+
+#include "vmime/net/message.hpp"
+
+#include "vmime/net/imap/IMAPParser.hpp"
+
+
+namespace vmime {
+namespace net {
+namespace imap {
+
+
+class IMAPStructure;
+
+
+class IMAPPart : public part
+{
+private:
+
+ friend class vmime::creator;
+
+ IMAPPart(ref <IMAPPart> parent, const int number, const IMAPParser::body_type_mpart* mpart);
+ IMAPPart(ref <IMAPPart> parent, const int number, const IMAPParser::body_type_1part* part);
+
+public:
+
+ ref <const structure> getStructure() const;
+ ref <structure> getStructure();
+
+ ref <const IMAPPart> getParent() const;
+
+ const mediaType& getType() const;
+ int getSize() const;
+ int getNumber() const;
+
+ ref <const header> getHeader() const;
+
+
+ static ref <IMAPPart> create
+ (ref <IMAPPart> parent, const int number, const IMAPParser::body* body);
+
+
+ header& getOrCreateHeader();
+
+private:
+
+ ref <IMAPStructure> m_structure;
+ weak_ref <IMAPPart> m_parent;
+ ref <header> m_header;
+
+ int m_number;
+ int m_size;
+ mediaType m_mediaType;
+};
+
+
+} // imap
+} // net
+} // vmime
+
+
+#endif // VMIME_NET_IMAP_IMAPPART_HPP_INCLUDED
+
diff --git a/vmime/net/imap/IMAPStructure.hpp b/vmime/net/imap/IMAPStructure.hpp
new file mode 100644
index 00000000..e43676c8
--- /dev/null
+++ b/vmime/net/imap/IMAPStructure.hpp
@@ -0,0 +1,67 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2009 Vincent Richard <[email protected]>
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License as
+// published by the Free Software Foundation; either version 3 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+//
+// Linking this library statically or dynamically with other modules is making
+// a combined work based on this library. Thus, the terms and conditions of
+// the GNU General Public License cover the whole combination.
+//
+
+#ifndef VMIME_NET_IMAP_IMAPSTRUCTURE_HPP_INCLUDED
+#define VMIME_NET_IMAP_IMAPSTRUCTURE_HPP_INCLUDED
+
+
+#include "vmime/net/message.hpp"
+
+#include "vmime/net/imap/IMAPParser.hpp"
+
+
+namespace vmime {
+namespace net {
+namespace imap {
+
+
+class IMAPPart;
+
+
+class IMAPStructure : public structure
+{
+public:
+
+ IMAPStructure();
+ IMAPStructure(const IMAPParser::body* body);
+ IMAPStructure(ref <IMAPPart> parent, const std::vector <IMAPParser::body*>& list);
+
+ ref <const part> getPartAt(const int x) const;
+ ref <part> getPartAt(const int x);
+ int getPartCount() const;
+
+ static ref <IMAPStructure> emptyStructure();
+
+private:
+
+ std::vector <ref <IMAPPart> > m_parts;
+};
+
+
+} // imap
+} // net
+} // vmime
+
+
+#endif // VMIME_NET_IMAP_IMAPSTRUCTURE_HPP_INCLUDED
+
diff --git a/vmime/net/maildir/maildirMessage.hpp b/vmime/net/maildir/maildirMessage.hpp
index ba3c88e1..cd66d43c 100644
--- a/vmime/net/maildir/maildirMessage.hpp
+++ b/vmime/net/maildir/maildirMessage.hpp
@@ -75,6 +75,8 @@ public:
void fetchPartHeader(ref <part> p);
+ ref <vmime::message> getParsedMessage();
+
private:
void fetch(ref <maildirFolder> folder, const int options);
diff --git a/vmime/net/message.hpp b/vmime/net/message.hpp
index a0cc1daa..b6ebef83 100644
--- a/vmime/net/message.hpp
+++ b/vmime/net/message.hpp
@@ -31,6 +31,8 @@
#include "vmime/utility/progressListener.hpp"
#include "vmime/utility/stream.hpp"
+#include "vmime/message.hpp"
+
namespace vmime {
namespace net {
@@ -286,6 +288,16 @@ public:
* @param p the part for which to fetch the header
*/
virtual void fetchPartHeader(ref <part> p) = 0;
+
+ /** Get the RFC-822 message for this abstract message.
+ * Warning: This may require getting some data (ie: structure and headers) from
+ * the server, which is done automatically. Actual message contents (ie: body)
+ * will not be fetched if possible (IMAP allows it, whereas POP3 will require
+ * to fetch the whole message).
+ *
+ * @return a RFC-822-parsed message
+ */
+ virtual ref <vmime::message> getParsedMessage() = 0;
};
diff --git a/vmime/net/pop3/POP3Message.hpp b/vmime/net/pop3/POP3Message.hpp
index 5dbea3fe..337cc5d5 100644
--- a/vmime/net/pop3/POP3Message.hpp
+++ b/vmime/net/pop3/POP3Message.hpp
@@ -77,6 +77,8 @@ public:
void fetchPartHeader(ref <part> p);
+ ref <vmime::message> getParsedMessage();
+
private:
void fetch(ref <POP3Folder> folder, const int options);