aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/messaging/imap/IMAPFolder.cpp7
-rw-r--r--src/messaging/maildir/maildirFolder.cpp6
-rw-r--r--src/messaging/pop3/POP3Folder.cpp6
3 files changed, 15 insertions, 4 deletions
diff --git a/src/messaging/imap/IMAPFolder.cpp b/src/messaging/imap/IMAPFolder.cpp
index c567c590..a63e8aa6 100644
--- a/src/messaging/imap/IMAPFolder.cpp
+++ b/src/messaging/imap/IMAPFolder.cpp
@@ -464,12 +464,17 @@ ref <message> IMAPFolder::getMessage(const int num)
std::vector <ref <message> > IMAPFolder::getMessages(const int from, const int to)
{
+ const int messageCount = getMessageCount();
+ const int to2 = (to == -1 ? messageCount : to);
+
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
+ else if (to2 < from || from < 1 || to2 < 1 || from > messageCount || to2 > messageCount)
+ throw exceptions::message_not_found();
std::vector <ref <message> > v;
- for (int i = from ; i <= to ; ++i)
+ for (int i = from ; i <= to2 ; ++i)
v.push_back(vmime::create <IMAPMessage>(this, i));
return (v);
diff --git a/src/messaging/maildir/maildirFolder.cpp b/src/messaging/maildir/maildirFolder.cpp
index d24ab5e5..ebb0dd29 100644
--- a/src/messaging/maildir/maildirFolder.cpp
+++ b/src/messaging/maildir/maildirFolder.cpp
@@ -405,12 +405,16 @@ ref <message> maildirFolder::getMessage(const int num)
std::vector <ref <message> > maildirFolder::getMessages(const int from, const int to)
{
+ const int to2 = (to == -1 ? m_messageCount : to);
+
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
+ else if (to2 < from || from < 1 || to2 < 1 || from > m_messageCount || to2 > m_messageCount)
+ throw exceptions::message_not_found();
std::vector <ref <message> > v;
- for (int i = from ; i <= to ; ++i)
+ for (int i = from ; i <= to2 ; ++i)
{
v.push_back(vmime::create <maildirMessage>
(thisWeakRef().dynamicCast <maildirFolder>(), i));
diff --git a/src/messaging/pop3/POP3Folder.cpp b/src/messaging/pop3/POP3Folder.cpp
index 0f0a5369..0afd3589 100644
--- a/src/messaging/pop3/POP3Folder.cpp
+++ b/src/messaging/pop3/POP3Folder.cpp
@@ -206,16 +206,18 @@ ref <message> POP3Folder::getMessage(const int num)
std::vector <ref <message> > POP3Folder::getMessages(const int from, const int to)
{
+ const int to2 = (to == -1 ? m_messageCount : to);
+
if (!m_store)
throw exceptions::illegal_state("Store disconnected");
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
- else if (to < from || from < 1 || to < 1 || from > m_messageCount || to > m_messageCount)
+ else if (to2 < from || from < 1 || to2 < 1 || from > m_messageCount || to2 > m_messageCount)
throw exceptions::message_not_found();
std::vector <ref <message> > v;
- for (int i = from ; i <= to ; ++i)
+ for (int i = from ; i <= to2 ; ++i)
v.push_back(vmime::create <POP3Message>(this, i));
return (v);