Added function to retrieve sequence numbers of messages whose UID is greater or equal than a specified UID (thanks to Zahi Mashael).
This commit is contained in:
parent
cb16e25619
commit
92c445dd63
@ -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
|
||||
|
@ -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
|
||||
|
@ -843,6 +843,12 @@ void POP3Folder::expunge()
|
||||
}
|
||||
|
||||
|
||||
std::vector <int> POP3Folder::getMessageNumbersStartingOnUID(const message::uid& /* uid */)
|
||||
{
|
||||
throw exceptions::operation_not_supported();
|
||||
}
|
||||
|
||||
|
||||
} // pop3
|
||||
} // net
|
||||
} // vmime
|
||||
|
@ -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);
|
||||
|
@ -120,6 +120,8 @@ public:
|
||||
|
||||
int getFetchCapabilities() const;
|
||||
|
||||
std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
|
||||
|
||||
private:
|
||||
|
||||
void registerMessage(IMAPMessage* msg);
|
||||
|
@ -121,6 +121,8 @@ public:
|
||||
|
||||
int getFetchCapabilities() const;
|
||||
|
||||
std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
|
||||
|
||||
private:
|
||||
|
||||
void scanFolder();
|
||||
|
@ -119,6 +119,8 @@ public:
|
||||
|
||||
int getFetchCapabilities() const;
|
||||
|
||||
std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
|
||||
|
||||
private:
|
||||
|
||||
void registerMessage(POP3Message* msg);
|
||||
|
Loading…
Reference in New Issue
Block a user