aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2012-04-05 09:46:39 +0000
committerVincent Richard <[email protected]>2012-04-05 09:46:39 +0000
commit92c445dd63d463aaf0ee674dcae1a192e8a50381 (patch)
tree0e9826aa1dc354a05f6fd9aabe70f698166c8216
parentUpdated coding conventions. (diff)
downloadvmime-92c445dd63d463aaf0ee674dcae1a192e8a50381.tar.gz
vmime-92c445dd63d463aaf0ee674dcae1a192e8a50381.zip
Added function to retrieve sequence numbers of messages whose UID is greater or equal than a specified UID (thanks to Zahi Mashael).
-rw-r--r--src/net/imap/IMAPFolder.cpp56
-rw-r--r--src/net/maildir/maildirFolder.cpp6
-rw-r--r--src/net/pop3/POP3Folder.cpp6
-rw-r--r--vmime/net/folder.hpp7
-rw-r--r--vmime/net/imap/IMAPFolder.hpp2
-rw-r--r--vmime/net/maildir/maildirFolder.hpp2
-rw-r--r--vmime/net/pop3/POP3Folder.hpp2
7 files changed, 81 insertions, 0 deletions
diff --git a/src/net/imap/IMAPFolder.cpp b/src/net/imap/IMAPFolder.cpp
index 0122d217..50a2f2ba 100644
--- a/src/net/imap/IMAPFolder.cpp
+++ b/src/net/imap/IMAPFolder.cpp
@@ -1772,6 +1772,62 @@ void IMAPFolder::status(int& count, int& unseen)
}
+std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid& uid)
+{
+ std::vector<int> v;
+
+ std::ostringstream command;
+ command.imbue(std::locale::classic());
+
+ command << "SEARCH UID " << uid;
+
+ // Send the request
+ m_connection->send(true, command.str(), true);
+
+ // Get the response
+ utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+
+ if (resp->isBad() ||
+ resp->response_done()->response_tagged()->resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
+ {
+ throw exceptions::command_error("SEARCH",
+ m_connection->getParser()->lastLine(), "bad response");
+ }
+
+ const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList = resp->continue_req_or_response_data();
+
+ for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
+ it = respDataList.begin() ; it != respDataList.end() ; ++it)
+ {
+ if ((*it)->response_data() == NULL)
+ {
+ throw exceptions::command_error("SEARCH",
+ m_connection->getParser()->lastLine(), "invalid response");
+ }
+
+ const IMAPParser::mailbox_data* mailboxData =
+ (*it)->response_data()->mailbox_data();
+
+ // We are only interested in responses of type "SEARCH"
+ if (mailboxData == NULL ||
+ mailboxData->type() != IMAPParser::mailbox_data::SEARCH)
+ {
+ continue;
+ }
+
+ for (std::vector <IMAPParser::nz_number*>::const_iterator
+ it = mailboxData->search_nz_number_list().begin() ;
+ it != mailboxData->search_nz_number_list().end();
+ ++it)
+ {
+ v.push_back((*it)->value());
+ }
+ }
+
+ return v;
+}
+
+
} // imap
} // net
} // vmime
diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp
index dd680c9c..d11ae3b8 100644
--- a/src/net/maildir/maildirFolder.cpp
+++ b/src/net/maildir/maildirFolder.cpp
@@ -1363,6 +1363,12 @@ const utility::file::path maildirFolder::getMessageFSPath(const int number) cons
}
+std::vector <int> maildirFolder::getMessageNumbersStartingOnUID(const message::uid& /* uid */)
+{
+ throw exceptions::operation_not_supported();
+}
+
+
} // maildir
} // net
} // vmime
diff --git a/src/net/pop3/POP3Folder.cpp b/src/net/pop3/POP3Folder.cpp
index d5fc6874..e0856090 100644
--- a/src/net/pop3/POP3Folder.cpp
+++ b/src/net/pop3/POP3Folder.cpp
@@ -843,6 +843,12 @@ void POP3Folder::expunge()
}
+std::vector <int> POP3Folder::getMessageNumbersStartingOnUID(const message::uid& /* uid */)
+{
+ throw exceptions::operation_not_supported();
+}
+
+
} // pop3
} // net
} // vmime
diff --git a/vmime/net/folder.hpp b/vmime/net/folder.hpp
index b20e9c95..df9cbaf5 100644
--- a/vmime/net/folder.hpp
+++ b/vmime/net/folder.hpp
@@ -383,6 +383,13 @@ public:
*/
virtual int getFetchCapabilities() const = 0;
+ /** Return the sequence numbers of messages whose UID equal or greater than uid
+ *
+ * @param uid the uid of the first message
+ * @throw net_exception if an error occurs
+ */
+ virtual std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid) = 0;
+
// Event listeners
void addMessageChangedListener(events::messageChangedListener* l);
void removeMessageChangedListener(events::messageChangedListener* l);
diff --git a/vmime/net/imap/IMAPFolder.hpp b/vmime/net/imap/IMAPFolder.hpp
index dec3878e..cc52596f 100644
--- a/vmime/net/imap/IMAPFolder.hpp
+++ b/vmime/net/imap/IMAPFolder.hpp
@@ -120,6 +120,8 @@ public:
int getFetchCapabilities() const;
+ std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
+
private:
void registerMessage(IMAPMessage* msg);
diff --git a/vmime/net/maildir/maildirFolder.hpp b/vmime/net/maildir/maildirFolder.hpp
index 7474b1aa..68b5b898 100644
--- a/vmime/net/maildir/maildirFolder.hpp
+++ b/vmime/net/maildir/maildirFolder.hpp
@@ -121,6 +121,8 @@ public:
int getFetchCapabilities() const;
+ std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
+
private:
void scanFolder();
diff --git a/vmime/net/pop3/POP3Folder.hpp b/vmime/net/pop3/POP3Folder.hpp
index abaa8eb1..c4829085 100644
--- a/vmime/net/pop3/POP3Folder.hpp
+++ b/vmime/net/pop3/POP3Folder.hpp
@@ -119,6 +119,8 @@ public:
int getFetchCapabilities() const;
+ std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
+
private:
void registerMessage(POP3Message* msg);