aboutsummaryrefslogtreecommitdiffstats
path: root/vmime
diff options
context:
space:
mode:
Diffstat (limited to 'vmime')
-rw-r--r--vmime/net/folder.hpp101
-rw-r--r--vmime/net/imap/IMAPFolder.hpp17
-rw-r--r--vmime/net/imap/IMAPUtils.hpp54
-rw-r--r--vmime/net/maildir/maildirFolder.hpp17
-rw-r--r--vmime/net/maildir/maildirUtils.hpp9
-rw-r--r--vmime/net/messageSet.hpp335
-rw-r--r--vmime/net/pop3/POP3Folder.hpp17
-rw-r--r--vmime/net/pop3/POP3Utils.hpp9
8 files changed, 411 insertions, 148 deletions
diff --git a/vmime/net/folder.hpp b/vmime/net/folder.hpp
index 4cb6bb1a..fc878fbf 100644
--- a/vmime/net/folder.hpp
+++ b/vmime/net/folder.hpp
@@ -38,6 +38,7 @@
#include "vmime/message.hpp"
#include "vmime/net/message.hpp"
+#include "vmime/net/messageSet.hpp"
#include "vmime/net/events.hpp"
#include "vmime/net/folderStatus.hpp"
@@ -186,38 +187,34 @@ public:
*/
virtual ref <message> getMessage(const int num) = 0;
- /** Get new references to messages in this folder, given their numbers.
+ /** Get new references to messages in this folder, given either their
+ * sequence numbers or UIDs.
*
- * @param from sequence number of the first message to get
- * @param to sequence number of the last message to get
- * @return new objects referencing the specified messages
- * @throw exceptions::net_exception if an error occurs
- */
- virtual std::vector <ref <message> > getMessages(const int from = 1, const int to = -1) = 0;
-
- /** Get new references to messages in this folder, given their numbers.
+ * To retrieve messages by their number, use:
+ * \code{.cpp}
+ * // Get messages from sequence number 5 to sequence number 8 (including)
+ * folder->getMessage(vmime::net::messageSet::byNumber(5, 8));
*
- * @param nums sequence numbers of the messages to retrieve
- * @return new objects referencing the specified messages
- * @throw exceptions::net_exception if an error occurs
- */
- virtual std::vector <ref <message> > getMessages(const std::vector <int>& nums) = 0;
-
- /** Get message in this folder, given its UID.
+ * // Get all messages in the folder, starting from number 42
+ * folder->getMessage(vmime::net::messageSet::byNumber(42, -1));
+ * \endcode
+ * Or, to retrieve messages by their UID, use:
+ * \code{.cpp}
+ * // Get messages from UID 1000 to UID 1042 (including)
+ * folder->getMessage(vmime::net::messageSet::byUID(1000, 1042));
*
- * @param uid UID of message to retrieve
- * @return a new object referencing the specified message
- * @throw exceptions::net_exception if an error occurs
- */
- virtual ref <message> getMessageByUID(const message::uid& uid) = 0;
-
- /** Get messages in this folder, given their UIDs.
+ * // Get message with UID 1042
+ * folder->getMessage(vmime::net::messageSet::byUID(1042));
+ *
+ * // Get all messages in the folder, starting from UID 1000
+ * folder->getMessage(vmime::net::messageSet::byUID(1000, "*"));
+ * \endcode
*
- * @param uids UIDs of messages to retrieve
+ * @param msgs index set of messages to retrieve
* @return new objects referencing the specified messages
* @throw exceptions::net_exception if an error occurs
*/
- virtual std::vector <ref <message> > getMessagesByUID(const std::vector <message::uid>& uids) = 0;
+ virtual std::vector <ref <message> > getMessages(const messageSet& msgs) = 0;
/** Return the number of messages in this folder.
*
@@ -249,46 +246,21 @@ public:
*/
virtual void rename(const folder::path& newPath) = 0;
- /** Remove a message in this folder.
- *
- * @param num sequence number of the message to delete
- * @throw exceptions::net_exception if an error occurs
- */
- virtual void deleteMessage(const int num) = 0;
-
- /** Remove one or more messages from this folder.
- *
- * @param from sequence number of the first message to delete
- * @param to sequence number of the last message to delete
- * @throw exceptions::net_exception if an error occurs
- */
- virtual void deleteMessages(const int from = 1, const int to = -1) = 0;
-
/** Remove one or more messages from this folder.
*
- * @param nums sequence numbers of the messages to delete
- * @throw exceptions::net_exception if an error occurs
- */
- virtual void deleteMessages(const std::vector <int>& nums) = 0;
-
- /** Change the flags for one or more messages in this folder.
- *
- * @param from sequence number of the first message to modify
- * @param to sequence number of the last message to modify
- * @param flags set of flags (see message::Flags)
- * @param mode indicate how to treat old and new flags (see message::FlagsModes)
+ * @param msgs index set of messages to delete
* @throw exceptions::net_exception if an error occurs
*/
- virtual void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET) = 0;
+ virtual void deleteMessages(const messageSet& msgs) = 0;
/** Change the flags for one or more messages in this folder.
*
- * @param nums sequence numbers of the messages to modify
+ * @param msgs index set of messages on which to set the flags
* @param flags set of flags (see message::Flags)
* @param mode indicate how to treat old and new flags (see message::FlagsModes)
* @throw exceptions::net_exception if an error occurs
*/
- virtual void setMessageFlags(const std::vector <int>& nums, const int flags, const int mode = message::FLAG_MODE_SET) = 0;
+ virtual void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET) = 0;
/** Add a message to this folder.
*
@@ -311,30 +283,13 @@ public:
*/
virtual void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0;
- /** Copy a message from this folder to another folder.
- *
- * @param dest destination folder path
- * @param num sequence number of the message to copy
- * @throw exceptions::net_exception if an error occurs
- */
- virtual void copyMessage(const folder::path& dest, const int num) = 0;
-
- /** Copy messages from this folder to another folder.
- *
- * @param dest destination folder path
- * @param from sequence number of the first message to copy
- * @param to sequence number of the last message to copy
- * @throw exceptions::net_exception if an error occurs
- */
- virtual void copyMessages(const folder::path& dest, const int from = 1, const int to = -1) = 0;
-
/** Copy messages from this folder to another folder.
*
* @param dest destination folder path
- * @param nums sequence numbers of the messages to copy
+ * @param msgs index set of messages to copy
* @throw exceptions::net_exception if an error occurs
*/
- virtual void copyMessages(const folder::path& dest, const std::vector <int>& nums) = 0;
+ virtual void copyMessages(const folder::path& dest, const messageSet& msgs) = 0;
/** Request folder status without opening it.
*
diff --git a/vmime/net/imap/IMAPFolder.hpp b/vmime/net/imap/IMAPFolder.hpp
index c1d2d34a..b7fc46a1 100644
--- a/vmime/net/imap/IMAPFolder.hpp
+++ b/vmime/net/imap/IMAPFolder.hpp
@@ -91,11 +91,7 @@ public:
bool isOpen() const;
ref <message> getMessage(const int num);
- std::vector <ref <message> > getMessages(const int from = 1, const int to = -1);
- std::vector <ref <message> > getMessages(const std::vector <int>& nums);
-
- ref <message> getMessageByUID(const message::uid& uid);
- std::vector <ref <message> > getMessagesByUID(const std::vector <message::uid>& uids);
+ std::vector <ref <message> > getMessages(const messageSet& msgs);
std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
@@ -106,19 +102,14 @@ public:
void rename(const folder::path& newPath);
- void deleteMessage(const int num);
- void deleteMessages(const int from = 1, const int to = -1);
- void deleteMessages(const std::vector <int>& nums);
+ void deleteMessages(const messageSet& msgs);
- void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET);
- void setMessageFlags(const std::vector <int>& nums, const int flags, const int mode = message::FLAG_MODE_SET);
+ void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET);
void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
- void copyMessage(const folder::path& dest, const int num);
- void copyMessages(const folder::path& dest, const int from = 1, const int to = -1);
- void copyMessages(const folder::path& dest, const std::vector <int>& nums);
+ void copyMessages(const folder::path& dest, const messageSet& msgs);
void status(int& count, int& unseen);
ref <folderStatus> getStatus();
diff --git a/vmime/net/imap/IMAPUtils.hpp b/vmime/net/imap/IMAPUtils.hpp
index 7a03fcac..1dfde7a9 100644
--- a/vmime/net/imap/IMAPUtils.hpp
+++ b/vmime/net/imap/IMAPUtils.hpp
@@ -73,29 +73,6 @@ public:
static const string messageFlagList(const int flags);
- /** Build an "IMAP set" given a list of message numbers. The function tries
- * to group consecutive message numbers to reduce the list.
- *
- * Example:
- * IN = "1,2,3,4,5,7,8,13,15,16,17"
- * OUT = "1:5,7:8,13,15:*" for a mailbox with a total of 17 messages (max = 17)
- *
- * @param list list of message numbers
- * @param max number of messages in the mailbox (or -1 if not known)
- * @param alreadySorted set to true if the list of message numbers is
- * already sorted in ascending order
- * @return a set corresponding to the message list
- */
- static const string listToSet(const std::vector <int>& list,
- const int max = -1, const bool alreadySorted = false);
-
- /** Build an "IMAP set" set given a list of message UIDs.
- *
- * @param list list of message UIDs
- * @return a set corresponding to the list
- */
- static const string listToSet(const std::vector <message::uid>& list);
-
/** Format a date/time to IMAP date/time format.
*
* @param date date/time to format
@@ -103,25 +80,16 @@ public:
*/
static const string dateTime(const vmime::datetime& date);
- /** Construct a fetch request for the specified messages, designated by their sequence numbers.
- *
- * @param cnt connection
- * @param list list of message numbers
- * @param options fetch options
- * @return fetch request
- */
- static const string buildFetchRequest
- (ref <IMAPConnection> cnt, const std::vector <int>& list, const int options);
-
- /** Construct a fetch request for the specified messages, designated by their UIDs.
+ /** Construct a fetch request for the specified messages, designated
+ * either by their sequence numbers or their UIDs.
*
* @param cnt connection
- * @param list list of message UIDs
+ * @param msgs message set
* @param options fetch options
* @return fetch request
*/
static const string buildFetchRequest
- (ref <IMAPConnection> cnt, const std::vector <message::uid>& list, const int options);
+ (ref <IMAPConnection> cnt, const messageSet& msgs, const int options);
/** Convert a parser-style address list to a mailbox list.
*
@@ -130,6 +98,20 @@ public:
*/
static void convertAddressList(const IMAPParser::address_list& src, mailboxList& dest);
+ /** Returns an IMAP-formatted sequence set given a message set.
+ *
+ * @param msgs message set
+ * @return IMAP sequence set (eg. "1:5,7,15:*")
+ */
+ static const string messageSetToSequenceSet(const messageSet& msgs);
+
+ /** Returns a list of message sequence numbers given a message set.
+ *
+ * @param msgs message set
+ * @return list of message numbers
+ */
+ static const std::vector <int> messageSetToNumberList(const messageSet& msgs);
+
private:
static const string buildFetchRequestImpl
diff --git a/vmime/net/maildir/maildirFolder.hpp b/vmime/net/maildir/maildirFolder.hpp
index 940fcaae..2b6f8b4d 100644
--- a/vmime/net/maildir/maildirFolder.hpp
+++ b/vmime/net/maildir/maildirFolder.hpp
@@ -89,11 +89,7 @@ public:
bool isOpen() const;
ref <message> getMessage(const int num);
- std::vector <ref <message> > getMessages(const int from = 1, const int to = -1);
- std::vector <ref <message> > getMessages(const std::vector <int>& nums);
-
- ref <message> getMessageByUID(const message::uid& uid);
- std::vector <ref <message> > getMessagesByUID(const std::vector <message::uid>& uids);
+ std::vector <ref <message> > getMessages(const messageSet& msgs);
int getMessageCount();
@@ -102,19 +98,14 @@ public:
void rename(const folder::path& newPath);
- void deleteMessage(const int num);
- void deleteMessages(const int from = 1, const int to = -1);
- void deleteMessages(const std::vector <int>& nums);
+ void deleteMessages(const messageSet& msgs);
- void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET);
- void setMessageFlags(const std::vector <int>& nums, const int flags, const int mode = message::FLAG_MODE_SET);
+ void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET);
void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
- void copyMessage(const folder::path& dest, const int num);
- void copyMessages(const folder::path& dest, const int from = 1, const int to = -1);
- void copyMessages(const folder::path& dest, const std::vector <int>& nums);
+ void copyMessages(const folder::path& dest, const messageSet& msgs);
void status(int& count, int& unseen);
ref <folderStatus> getStatus();
diff --git a/vmime/net/maildir/maildirUtils.hpp b/vmime/net/maildir/maildirUtils.hpp
index 22246fb7..072a2648 100644
--- a/vmime/net/maildir/maildirUtils.hpp
+++ b/vmime/net/maildir/maildirUtils.hpp
@@ -34,6 +34,8 @@
#include "vmime/utility/file.hpp"
#include "vmime/utility/path.hpp"
+#include "vmime/net/messageSet.hpp"
+
namespace vmime {
namespace net {
@@ -129,6 +131,13 @@ public:
* @param dir directory to delete
*/
static void recursiveFSDelete(ref <utility::file> dir);
+
+ /** Returns a list of message numbers given a message set.
+ *
+ * @param msgs message set
+ * @return list of message numbers
+ */
+ static const std::vector <int> messageSetToNumberList(const messageSet& msgs);
};
diff --git a/vmime/net/messageSet.hpp b/vmime/net/messageSet.hpp
new file mode 100644
index 00000000..2535ac25
--- /dev/null
+++ b/vmime/net/messageSet.hpp
@@ -0,0 +1,335 @@
+//
+// VMime library (http://www.vmime.org)
+// Copyright (C) 2002-2013 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_MESSAGESET_HPP_INCLUDED
+#define VMIME_NET_MESSAGESET_HPP_INCLUDED
+
+
+#include "vmime/net/message.hpp"
+
+
+namespace vmime {
+namespace net {
+
+
+// Forward references
+class numberMessageRange;
+class UIDMessageRange;
+
+
+/** Enumerator used to retrieve the message number/UID ranges contained
+ * in a messageSet object.
+ */
+
+class VMIME_EXPORT messageSetEnumerator
+{
+public:
+
+ virtual void enumerateNumberMessageRange(const numberMessageRange& range) = 0;
+ virtual void enumerateUIDMessageRange(const UIDMessageRange& range) = 0;
+};
+
+
+/** A range of (continuous) messages, designated either by their
+ * sequence number, or by their UID.
+ */
+
+class messageRange : public object
+{
+public:
+
+ virtual ~messageRange();
+
+ /** Enumerates this range with the specified enumerator.
+ *
+ * @param en enumerator that will receive the method calls while
+ * enumerating this range
+ */
+ virtual void enumerate(messageSetEnumerator& en) const = 0;
+
+ /** Clones this message range.
+ */
+ virtual messageRange* clone() const = 0;
+
+protected:
+
+ messageRange();
+ messageRange(const messageRange&);
+};
+
+
+/** A range of (continuous) messages designated by their sequence number.
+ */
+
+class numberMessageRange : public messageRange
+{
+public:
+
+ /** Constructs a message range containing a single message.
+ *
+ * @param number message number (numbering starts at 1, not 0)
+ */
+ numberMessageRange(const int number);
+
+ /** Constructs a message range for multiple messages.
+ *
+ * @param first number of the first message in the range (numbering
+ * starts at 1, not 0)
+ * @param last number of the last message in the range, or use the
+ * special value -1 to designate the last message in the folder
+ */
+ numberMessageRange(const int first, const int last);
+
+ /** Constructs a message range by copying from another range.
+ *
+ * @param other range to copy
+ */
+ numberMessageRange(const numberMessageRange& other);
+
+ /** Returns the number of the first message in the range.
+ *
+ * @return number of the first message
+ */
+ int getFirst() const;
+
+ /** Returns the number of the last message in the range, or -1
+ * to designate the last message in the folder
+ *
+ * @return number of the last message
+ */
+ int getLast() const;
+
+ void enumerate(messageSetEnumerator& en) const;
+
+ messageRange* clone() const;
+
+private:
+
+ int m_first, m_last;
+};
+
+
+/** A range of (continuous) messages represented by their UID.
+ */
+
+class UIDMessageRange : public messageRange
+{
+public:
+
+ /** Constructs a message range containing a single message.
+ *
+ * @param uid message UID
+ */
+ UIDMessageRange(const message::uid& uid);
+
+ /** Constructs a message range for multiple messages.
+ *
+ * @param first UID of the first message in the range
+ * @param last UID of the last message in the range, or use the
+ * special value '*' to designate the last message in the folder
+ */
+ UIDMessageRange(const message::uid& first, const message::uid& last);
+
+ /** Constructs a message range by copying from another range.
+ *
+ * @param other range to copy
+ */
+ UIDMessageRange(const UIDMessageRange& other);
+
+ /** Returns the UID of the first message in the range.
+ *
+ * @return UID of the first message
+ */
+ const message::uid getFirst() const;
+
+ /** Returns the UID of the last message in the range, or '*'
+ * to designate the last message in the folder
+ *
+ * @return UID of the last message
+ */
+ const message::uid getLast() const;
+
+ void enumerate(messageSetEnumerator& en) const;
+
+ messageRange* clone() const;
+
+private:
+
+ message::uid m_first, m_last;
+};
+
+
+/** Represents a set of messages, designated either by their sequence
+ * number, or by their UID (but not both).
+ *
+ * Following is example code to designate messages by their number:
+ * \code{.cpp}
+ * // Designate a single message with sequence number 42
+ * vmime::net::messageSet::byNumber(42)
+ *
+ * // Designate messages from sequence number 5 to sequence number 8 (including)
+ * vmime::net::messageSet::byNumber(5, 8)
+ *
+ * // Designate all messages in the folder, starting from number 42
+ * vmime::net::messageSet::byNumber(42, -1)
+ * \endcode
+ * Or, to designate messages by their UID, use:
+ * \code{.cpp}
+ * // Designate a single message with UID 1042
+ * vmime::net::messageSet::byUID(1042)
+ *
+ * // Designate messages from UID 1000 to UID 1042 (including)
+ * vmime::net::messageSet::byUID(1000, 1042)
+ *
+ * // Designate all messages in the folder, starting from UID 1000
+ * vmime::net::messageSet::byUID(1000, "*")
+ * \endcode
+ */
+
+class VMIME_EXPORT messageSet : public object
+{
+public:
+
+ ~messageSet();
+
+ messageSet(const messageSet& other);
+
+ /** Constructs a new message set and initializes it with a single
+ * message represented by its sequence number.
+ *
+ * @param number message number (numbering starts at 1, not 0)
+ * @return new message set
+ */
+ static messageSet byNumber(const int number);
+
+ /** Constructs a new message set and initializes it with a range
+ * of messages represented by their sequence number.
+ *
+ * @param first number of the first message in the range (numbering
+ * starts at 1, not 0)
+ * @param last number of the last message in the range, or use the
+ * special value -1 to designate the last message in the folder
+ * @return new message set
+ */
+ static messageSet byNumber(const int first, const int last);
+
+ /** Constructs a new message set and initializes it with a possibly
+ * unsorted list of messages represented by their sequence number.
+ * Please note that numbering starts at 1, not 0.
+ *
+ * The function tries to group consecutive message numbers into
+ * ranges to reduce the size of the resulting set.
+ *
+ * For example, given the list "1,2,3,4,5,7,8,13,15,16,17" it will
+ * result in the following ranges: "1:5,7:8,13,15:17".
+ *
+ * @param numbers a vector containing numbers of the messages
+ * @return new message set
+ */
+ static messageSet byNumber(const std::vector <int>& numbers);
+
+ /** Constructs a new message set and initializes it with a single
+ * message represented by its UID.
+ *
+ * @param uid message UID
+ * @return new message set
+ */
+ static messageSet byUID(const message::uid& uid);
+
+ /** Constructs a new message set and initializes it with a range
+ * of messages represented by their sequence number.
+ *
+ * @param first UID of the first message in the range
+ * @param last UID of the last message in the range, or use the
+ * special value '*' to designate the last message in the folder
+ * @return new message set
+ */
+ static messageSet byUID(const message::uid& first, const message::uid& last);
+
+ /** Constructs a new message set and initializes it with a possibly
+ * unsorted list of messages represented by their UID.
+ *
+ * For UIDs that actually are numbers (this is the case for IMAP), the
+ * function tries to group consecutive UIDs into ranges to reduce the
+ * size of the resulting set.
+ *
+ * For example, given the list "1,2,3,4,5,7,8,13,15,16,17" it will
+ * result in the following ranges: "1:5,7:8,13,15:17".
+ *
+ * @param uids a vector containing UIDs of the messages
+ * @return new message set
+ */
+ static messageSet byUID(const std::vector <message::uid>& uids);
+
+ /** Adds the specified range to this set. The type of message range
+ * (either number or UID) must match the type of the ranges already
+ * contained in this set (ie. it's not possible to have a message
+ * set which contains both number ranges and UID ranges).
+ *
+ * @param range range to add
+ * @throw std::invalid_argument exception if the range type does
+ * not match the type of the ranges in this set
+ */
+ void addRange(const messageRange& range);
+
+ /** Enumerates this set with the specified enumerator.
+ *
+ * @param en enumerator that will receive the method calls while
+ * enumerating the ranges in this set
+ */
+ void enumerate(messageSetEnumerator& en) const;
+
+ /** Returns whether this set is empty (contains no range).
+ *
+ * @return true if this set is empty, or false otherwise
+ */
+ bool isEmpty() const;
+
+ /** Returns whether this set references messages by their sequence
+ * number.
+ *
+ * @return true if this set references messages by their sequence
+ * number, or false otherwise
+ */
+ bool isNumberSet() const;
+
+ /** Returns whether this set references messages by their UID.
+ *
+ * @return true if this set references messages by their UID,
+ * or false otherwise
+ */
+ bool isUIDSet() const;
+
+private:
+
+ messageSet();
+
+ std::vector <messageRange*> m_ranges;
+};
+
+
+} // net
+} // vmime
+
+
+#endif // VMIME_NET_MESSAGESET_HPP_INCLUDED
diff --git a/vmime/net/pop3/POP3Folder.hpp b/vmime/net/pop3/POP3Folder.hpp
index 8a97213c..93c1d257 100644
--- a/vmime/net/pop3/POP3Folder.hpp
+++ b/vmime/net/pop3/POP3Folder.hpp
@@ -86,11 +86,7 @@ public:
bool isOpen() const;
ref <message> getMessage(const int num);
- std::vector <ref <message> > getMessages(const int from = 1, const int to = -1);
- std::vector <ref <message> > getMessages(const std::vector <int>& nums);
-
- ref <message> getMessageByUID(const message::uid& uid);
- std::vector <ref <message> > getMessagesByUID(const std::vector <message::uid>& uids);
+ std::vector <ref <message> > getMessages(const messageSet& msgs);
int getMessageCount();
@@ -99,19 +95,14 @@ public:
void rename(const folder::path& newPath);
- void deleteMessage(const int num);
- void deleteMessages(const int from = 1, const int to = -1);
- void deleteMessages(const std::vector <int>& nums);
+ void deleteMessages(const messageSet& msgs);
- void setMessageFlags(const int from, const int to, const int flags, const int mode = message::FLAG_MODE_SET);
- void setMessageFlags(const std::vector <int>& nums, const int flags, const int mode = message::FLAG_MODE_SET);
+ void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET);
void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
- void copyMessage(const folder::path& dest, const int num);
- void copyMessages(const folder::path& dest, const int from = 1, const int to = -1);
- void copyMessages(const folder::path& dest, const std::vector <int>& nums);
+ void copyMessages(const folder::path& dest, const messageSet& msgs);
void status(int& count, int& unseen);
ref <folderStatus> getStatus();
diff --git a/vmime/net/pop3/POP3Utils.hpp b/vmime/net/pop3/POP3Utils.hpp
index 7a2376a1..9d20431c 100644
--- a/vmime/net/pop3/POP3Utils.hpp
+++ b/vmime/net/pop3/POP3Utils.hpp
@@ -35,6 +35,8 @@
#include "vmime/types.hpp"
+#include "vmime/net/messageSet.hpp"
+
namespace vmime {
namespace net {
@@ -63,6 +65,13 @@ public:
*/
static void parseMultiListOrUidlResponse
(ref <POP3Response> response, std::map <int, string>& result);
+
+ /** Returns a list of message numbers given a message set.
+ *
+ * @param msgs message set
+ * @return list of message numbers
+ */
+ static const std::vector <int> messageSetToNumberList(const messageSet& msgs);
};