From 81b7b009e9562323efb277d8fd4cc48675b35dc7 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sat, 23 Jul 2005 13:14:21 +0000 Subject: [PATCH] Fixed getMessages(). --- ChangeLog | 5 +++++ src/messaging/imap/IMAPFolder.cpp | 7 ++++++- src/messaging/maildir/maildirFolder.cpp | 6 +++++- src/messaging/pop3/POP3Folder.cpp | 6 ++++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b43f7af7..4f1c452b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ VERSION 0.7.2cvs ================ +2005-07-23 Vincent Richard + + * POP3, IMAP, maildir: fixed getMessages() when default arguments are given: + no message were returned, instead of the real message count. + 2005-07-15 Vincent Richard * *attachment, messageParser: added a getName() parameter to retrieve 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 IMAPFolder::getMessage(const int num) std::vector > 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 > v; - for (int i = from ; i <= to ; ++i) + for (int i = from ; i <= to2 ; ++i) v.push_back(vmime::create (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 maildirFolder::getMessage(const int num) std::vector > 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 > v; - for (int i = from ; i <= to ; ++i) + for (int i = from ; i <= to2 ; ++i) { v.push_back(vmime::create (thisWeakRef().dynamicCast (), 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 POP3Folder::getMessage(const int num) std::vector > 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 > v; - for (int i = from ; i <= to ; ++i) + for (int i = from ; i <= to2 ; ++i) v.push_back(vmime::create (this, i)); return (v);