Simplified IMAP parser objects.
This commit is contained in:
parent
523aacb499
commit
182e8f5dd8
@ -176,20 +176,20 @@ void IMAPConnection::connect() {
|
|||||||
scoped_ptr <IMAPParser::greeting> greet(m_parser->readGreeting());
|
scoped_ptr <IMAPParser::greeting> greet(m_parser->readGreeting());
|
||||||
bool needAuth = false;
|
bool needAuth = false;
|
||||||
|
|
||||||
if (greet->resp_cond_bye()) {
|
if (greet->resp_cond_bye) {
|
||||||
|
|
||||||
internalDisconnect();
|
internalDisconnect();
|
||||||
throw exceptions::connection_greeting_error(greet->getErrorLog());
|
throw exceptions::connection_greeting_error(greet->getErrorLog());
|
||||||
|
|
||||||
} else if (greet->resp_cond_auth()->condition() != IMAPParser::resp_cond_auth::PREAUTH) {
|
} else if (greet->resp_cond_auth->condition != IMAPParser::resp_cond_auth::PREAUTH) {
|
||||||
|
|
||||||
needAuth = true;
|
needAuth = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (greet->resp_cond_auth()->resp_text()->resp_text_code() &&
|
if (greet->resp_cond_auth->resp_text->resp_text_code &&
|
||||||
greet->resp_cond_auth()->resp_text()->resp_text_code()->capability_data()) {
|
greet->resp_cond_auth->resp_text->resp_text_code->capability_data) {
|
||||||
|
|
||||||
processCapabilityResponseData(greet->resp_cond_auth()->resp_text()->resp_text_code()->capability_data());
|
processCapabilityResponseData(greet->resp_cond_auth->resp_text->resp_text_code->capability_data.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if VMIME_HAVE_TLS_SUPPORT
|
#if VMIME_HAVE_TLS_SUPPORT
|
||||||
@ -294,8 +294,8 @@ void IMAPConnection::authenticate() {
|
|||||||
internalDisconnect();
|
internalDisconnect();
|
||||||
throw exceptions::command_error("LOGIN", resp->getErrorLog());
|
throw exceptions::command_error("LOGIN", resp->getErrorLog());
|
||||||
|
|
||||||
} else if (resp->response_done()->response_tagged()->
|
} else if (resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
internalDisconnect();
|
internalDisconnect();
|
||||||
throw exceptions::authentication_error(resp->getErrorLog());
|
throw exceptions::authentication_error(resp->getErrorLog());
|
||||||
@ -411,27 +411,24 @@ void IMAPConnection::authenticateSASL() {
|
|||||||
|
|
||||||
scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
|
||||||
|
|
||||||
if (resp->response_done() &&
|
if (resp->response_done &&
|
||||||
resp->response_done()->response_tagged() &&
|
resp->response_done->response_tagged &&
|
||||||
resp->response_done()->response_tagged()->resp_cond_state()->
|
resp->response_done->response_tagged->resp_cond_state->
|
||||||
status() == IMAPParser::resp_cond_state::OK) {
|
status == IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
m_socket = saslSession->getSecuredSocket(m_socket);
|
m_socket = saslSession->getSecuredSocket(m_socket);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
std::vector <IMAPParser::continue_req_or_response_data*>
|
|
||||||
respDataList = resp->continue_req_or_response_data();
|
|
||||||
|
|
||||||
string response;
|
string response;
|
||||||
bool hasResponse = false;
|
bool hasResponse = false;
|
||||||
|
|
||||||
for (unsigned int i = 0 ; i < respDataList.size() ; ++i) {
|
for (auto &respData : resp->continue_req_or_response_data) {
|
||||||
|
|
||||||
if (respDataList[i]->continue_req()) {
|
if (respData->continue_req) {
|
||||||
|
|
||||||
response = respDataList[i]->continue_req()->resp_text()->text();
|
response = respData->continue_req->resp_text->text;
|
||||||
hasResponse = true;
|
hasResponse = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -527,8 +524,8 @@ void IMAPConnection::startTLS() {
|
|||||||
|
|
||||||
scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("STARTTLS", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("STARTTLS", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
@ -629,8 +626,8 @@ void IMAPConnection::fetchCapabilities() {
|
|||||||
|
|
||||||
scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
|
||||||
|
|
||||||
if (resp->response_done()->response_tagged()->
|
if (resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() == IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status == IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
processCapabilityResponseData(resp.get());
|
processCapabilityResponseData(resp.get());
|
||||||
}
|
}
|
||||||
@ -639,23 +636,19 @@ void IMAPConnection::fetchCapabilities() {
|
|||||||
|
|
||||||
bool IMAPConnection::processCapabilityResponseData(const IMAPParser::response* resp) {
|
bool IMAPConnection::processCapabilityResponseData(const IMAPParser::response* resp) {
|
||||||
|
|
||||||
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
|
for (auto &respData : resp->continue_req_or_response_data) {
|
||||||
resp->continue_req_or_response_data();
|
|
||||||
|
|
||||||
for (size_t i = 0 ; i < respDataList.size() ; ++i) {
|
if (respData->response_data == NULL) {
|
||||||
|
|
||||||
if (respDataList[i]->response_data() == NULL) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IMAPParser::capability_data* capaData =
|
auto &capaData = respData->response_data->capability_data;
|
||||||
respDataList[i]->response_data()->capability_data();
|
|
||||||
|
|
||||||
if (capaData == NULL) {
|
if (!capaData) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
processCapabilityResponseData(capaData);
|
processCapabilityResponseData(capaData.get());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,14 +660,12 @@ void IMAPConnection::processCapabilityResponseData(const IMAPParser::capability_
|
|||||||
|
|
||||||
std::vector <string> res;
|
std::vector <string> res;
|
||||||
|
|
||||||
std::vector <IMAPParser::capability*> caps = capaData->capabilities();
|
for (auto &cap : capaData->capabilities) {
|
||||||
|
|
||||||
for (unsigned int j = 0 ; j < caps.size() ; ++j) {
|
if (cap->auth_type) {
|
||||||
|
res.push_back("AUTH=" + cap->auth_type->name);
|
||||||
if (caps[j]->auth_type()) {
|
|
||||||
res.push_back("AUTH=" + caps[j]->auth_type()->name());
|
|
||||||
} else {
|
} else {
|
||||||
res.push_back(utility::stringUtils::toUpper(caps[j]->atom()->value()));
|
res.push_back(utility::stringUtils::toUpper(cap->atom->value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -744,34 +735,31 @@ void IMAPConnection::initHierarchySeparator() {
|
|||||||
|
|
||||||
scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_parser->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
internalDisconnect();
|
internalDisconnect();
|
||||||
throw exceptions::command_error("LIST", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("LIST", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
|
const auto& respDataList = resp->continue_req_or_response_data;
|
||||||
resp->continue_req_or_response_data();
|
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
for (unsigned int i = 0 ; !found && i < respDataList.size() ; ++i) {
|
for (unsigned int i = 0 ; !found && i < respDataList.size() ; ++i) {
|
||||||
|
|
||||||
if (respDataList[i]->response_data() == NULL) {
|
if (!respDataList[i]->response_data) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const IMAPParser::mailbox_data* mailboxData =
|
auto &mailboxData = respDataList[i]->response_data->mailbox_data;
|
||||||
static_cast <const IMAPParser::response_data*>
|
|
||||||
(respDataList[i]->response_data())->mailbox_data();
|
|
||||||
|
|
||||||
if (mailboxData == NULL || mailboxData->type() != IMAPParser::mailbox_data::LIST) {
|
if (!mailboxData || mailboxData->type != IMAPParser::mailbox_data::LIST) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mailboxData->mailbox_list()->quoted_char() != '\0') {
|
if (mailboxData->mailbox_list->quoted_char != '\0') {
|
||||||
m_hierarchySeparator = mailboxData->mailbox_list()->quoted_char();
|
m_hierarchySeparator = mailboxData->mailbox_list->quoted_char;
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,34 +193,30 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable) {
|
|||||||
// Read the response
|
// Read the response
|
||||||
scoped_ptr <IMAPParser::response> resp(connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("SELECT", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("SELECT", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
|
auto &respDataList = resp->continue_req_or_response_data;
|
||||||
resp->continue_req_or_response_data();
|
|
||||||
|
|
||||||
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
|
for (auto it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
||||||
it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
|
||||||
|
|
||||||
if ((*it)->response_data() == NULL) {
|
auto *responseData = (*it)->response_data.get();
|
||||||
|
|
||||||
|
if (!responseData) {
|
||||||
throw exceptions::command_error("SELECT", resp->getErrorLog(), "invalid response");
|
throw exceptions::command_error("SELECT", resp->getErrorLog(), "invalid response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const IMAPParser::response_data* responseData = (*it)->response_data();
|
|
||||||
|
|
||||||
// OK Untagged responses: UNSEEN, PERMANENTFLAGS, UIDVALIDITY (optional)
|
// OK Untagged responses: UNSEEN, PERMANENTFLAGS, UIDVALIDITY (optional)
|
||||||
if (responseData->resp_cond_state()) {
|
if (responseData->resp_cond_state) {
|
||||||
|
|
||||||
const IMAPParser::resp_text_code* code =
|
auto *code = responseData->resp_cond_state->resp_text->resp_text_code.get();
|
||||||
responseData->resp_cond_state()->resp_text()->resp_text_code();
|
|
||||||
|
|
||||||
if (code != NULL) {
|
if (code) {
|
||||||
|
|
||||||
switch (code->type()) {
|
switch (code->type) {
|
||||||
|
|
||||||
case IMAPParser::resp_text_code::NOMODSEQ:
|
case IMAPParser::resp_text_code::NOMODSEQ:
|
||||||
|
|
||||||
@ -234,9 +230,9 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Untagged responses: FLAGS, EXISTS, RECENT (required)
|
// Untagged responses: FLAGS, EXISTS, RECENT (required)
|
||||||
} else if (responseData->mailbox_data()) {
|
} else if (responseData->mailbox_data) {
|
||||||
|
|
||||||
switch (responseData->mailbox_data()->type()) {
|
switch (responseData->mailbox_data->type) {
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
|
|
||||||
@ -248,7 +244,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable) {
|
|||||||
|
|
||||||
IMAPUtils::mailboxFlagsToFolderAttributes(
|
IMAPUtils::mailboxFlagsToFolderAttributes(
|
||||||
connection,
|
connection,
|
||||||
responseData->mailbox_data()->mailbox_flag_list(),
|
*responseData->mailbox_data->mailbox_flag_list,
|
||||||
*m_attribs
|
*m_attribs
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -261,13 +257,12 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable) {
|
|||||||
processStatusUpdate(resp.get());
|
processStatusUpdate(resp.get());
|
||||||
|
|
||||||
// Check for access mode (read-only or read-write)
|
// Check for access mode (read-only or read-write)
|
||||||
const IMAPParser::resp_text_code* respTextCode = resp->response_done()->
|
auto *respTextCode = resp->response_done->response_tagged->resp_cond_state->resp_text->resp_text_code.get();
|
||||||
response_tagged()->resp_cond_state()->resp_text()->resp_text_code();
|
|
||||||
|
|
||||||
if (respTextCode) {
|
if (respTextCode) {
|
||||||
|
|
||||||
const int openMode =
|
const int openMode =
|
||||||
(respTextCode->type() == IMAPParser::resp_text_code::READ_WRITE)
|
(respTextCode->type == IMAPParser::resp_text_code::READ_WRITE)
|
||||||
? MODE_READ_WRITE
|
? MODE_READ_WRITE
|
||||||
: MODE_READ_ONLY;
|
: MODE_READ_ONLY;
|
||||||
|
|
||||||
@ -404,8 +399,8 @@ void IMAPFolder::create(const folderAttributes& attribs) {
|
|||||||
|
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("CREATE", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("CREATE", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
@ -443,8 +438,8 @@ void IMAPFolder::destroy() {
|
|||||||
|
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("DELETE", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("DELETE", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
@ -505,38 +500,34 @@ int IMAPFolder::testExistAndGetType() {
|
|||||||
|
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("LIST", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("LIST", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check whether the result mailbox list contains this folder
|
// Check whether the result mailbox list contains this folder
|
||||||
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
|
auto& respDataList = resp->continue_req_or_response_data;
|
||||||
resp->continue_req_or_response_data();
|
|
||||||
|
|
||||||
folderAttributes attribs;
|
folderAttributes attribs;
|
||||||
attribs.setType(-1);
|
attribs.setType(-1);
|
||||||
|
|
||||||
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
|
for (auto it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
||||||
it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
|
||||||
|
|
||||||
if ((*it)->response_data() == NULL) {
|
|
||||||
|
|
||||||
|
if (!(*it)->response_data) {
|
||||||
throw exceptions::command_error("LIST", resp->getErrorLog(), "invalid response");
|
throw exceptions::command_error("LIST", resp->getErrorLog(), "invalid response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const IMAPParser::mailbox_data* mailboxData =
|
auto *mailboxData = (*it)->response_data->mailbox_data.get();
|
||||||
(*it)->response_data()->mailbox_data();
|
|
||||||
|
|
||||||
// We are only interested in responses of type "LIST"
|
// We are only interested in responses of type "LIST"
|
||||||
if (mailboxData != NULL &&
|
if (mailboxData &&
|
||||||
mailboxData->type() == IMAPParser::mailbox_data::LIST) {
|
mailboxData->type == IMAPParser::mailbox_data::LIST) {
|
||||||
|
|
||||||
// Get the folder type/flags at the same time
|
// Get the folder type/flags at the same time
|
||||||
IMAPUtils::mailboxFlagsToFolderAttributes(
|
IMAPUtils::mailboxFlagsToFolderAttributes(
|
||||||
m_connection,
|
m_connection,
|
||||||
mailboxData->mailbox_list()->mailbox_flag_list(),
|
*mailboxData->mailbox_list->mailbox_flag_list,
|
||||||
attribs
|
attribs
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -602,44 +593,36 @@ std::vector <shared_ptr <message> > IMAPFolder::getMessages(const messageSet& ms
|
|||||||
// Get the response
|
// Get the response
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("UID FETCH ... UID", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("UID FETCH ... UID", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the response
|
// Process the response
|
||||||
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
|
auto &respDataList = resp->continue_req_or_response_data;
|
||||||
resp->continue_req_or_response_data();
|
|
||||||
|
|
||||||
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
|
for (auto it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
||||||
it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
|
||||||
|
|
||||||
if ((*it)->response_data() == NULL) {
|
|
||||||
|
|
||||||
|
if (!(*it)->response_data) {
|
||||||
throw exceptions::command_error("UID FETCH ... UID", resp->getErrorLog(), "invalid response");
|
throw exceptions::command_error("UID FETCH ... UID", resp->getErrorLog(), "invalid response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const IMAPParser::message_data* messageData =
|
auto *messageData = (*it)->response_data->message_data.get();
|
||||||
(*it)->response_data()->message_data();
|
|
||||||
|
|
||||||
// We are only interested in responses of type "FETCH"
|
// We are only interested in responses of type "FETCH"
|
||||||
if (messageData == NULL || messageData->type() != IMAPParser::message_data::FETCH) {
|
if (!messageData || messageData->type != IMAPParser::message_data::FETCH) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Process fetch response for this message
|
// Find UID in message attributes
|
||||||
const size_t msgNum = messageData->number();
|
const size_t msgNum = messageData->number;
|
||||||
message::uid msgUID;
|
message::uid msgUID;
|
||||||
|
|
||||||
// Find UID in message attributes
|
for (auto &att : messageData->msg_att->items) {
|
||||||
const std::vector <IMAPParser::msg_att_item*> atts = messageData->msg_att()->items();
|
|
||||||
|
|
||||||
for (std::vector <IMAPParser::msg_att_item*>::const_iterator
|
if (att->type == IMAPParser::msg_att_item::UID) {
|
||||||
it = atts.begin() ; it != atts.end() ; ++it) {
|
msgUID = att->uniqueid->value;
|
||||||
|
|
||||||
if ((*it)->type() == IMAPParser::msg_att_item::UID) {
|
|
||||||
msgUID = (*it)->unique_id()->value();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -736,49 +719,45 @@ std::vector <shared_ptr <folder> > IMAPFolder::getFolders(const bool recursive)
|
|||||||
|
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("LIST", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("LIST", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
|
auto &respDataList = resp->continue_req_or_response_data;
|
||||||
resp->continue_req_or_response_data();
|
|
||||||
|
|
||||||
|
|
||||||
std::vector <shared_ptr <folder> > v;
|
std::vector <shared_ptr <folder> > v;
|
||||||
|
|
||||||
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
|
for (auto it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
||||||
it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
|
||||||
|
|
||||||
if ((*it)->response_data() == NULL) {
|
|
||||||
|
|
||||||
|
if (!(*it)->response_data) {
|
||||||
throw exceptions::command_error("LIST", resp->getErrorLog(), "invalid response");
|
throw exceptions::command_error("LIST", resp->getErrorLog(), "invalid response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const IMAPParser::mailbox_data* mailboxData =
|
auto *mailboxData = (*it)->response_data->mailbox_data.get();
|
||||||
(*it)->response_data()->mailbox_data();
|
|
||||||
|
|
||||||
if (mailboxData == NULL || mailboxData->type() != IMAPParser::mailbox_data::LIST) {
|
if (!mailboxData || mailboxData->type != IMAPParser::mailbox_data::LIST) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get folder path
|
// Get folder path
|
||||||
const class IMAPParser::mailbox* mailbox =
|
auto &mailbox = mailboxData->mailbox_list->mailbox;
|
||||||
mailboxData->mailbox_list()->mailbox();
|
|
||||||
|
|
||||||
folder::path path = IMAPUtils::stringToPath(
|
folder::path path = IMAPUtils::stringToPath(
|
||||||
mailboxData->mailbox_list()->quoted_char(), mailbox->name()
|
mailboxData->mailbox_list->quoted_char, mailbox->name
|
||||||
);
|
);
|
||||||
|
|
||||||
if (recursive || m_path.isDirectParentOf(path)) {
|
if (recursive || m_path.isDirectParentOf(path)) {
|
||||||
|
|
||||||
// Append folder to list
|
// Append folder to list
|
||||||
const class IMAPParser::mailbox_flag_list* mailbox_flag_list =
|
|
||||||
mailboxData->mailbox_list()->mailbox_flag_list();
|
|
||||||
|
|
||||||
shared_ptr <folderAttributes> attribs = make_shared <folderAttributes>();
|
shared_ptr <folderAttributes> attribs = make_shared <folderAttributes>();
|
||||||
IMAPUtils::mailboxFlagsToFolderAttributes(m_connection, mailbox_flag_list, *attribs);
|
|
||||||
|
IMAPUtils::mailboxFlagsToFolderAttributes(
|
||||||
|
m_connection,
|
||||||
|
*mailboxData->mailbox_list->mailbox_flag_list,
|
||||||
|
*attribs
|
||||||
|
);
|
||||||
|
|
||||||
v.push_back(make_shared <IMAPFolder>(path, store, attribs));
|
v.push_back(make_shared <IMAPFolder>(path, store, attribs));
|
||||||
}
|
}
|
||||||
@ -826,14 +805,13 @@ void IMAPFolder::fetchMessages(
|
|||||||
// Get the response
|
// Get the response
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("FETCH", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("FETCH", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
|
auto &respDataList = resp->continue_req_or_response_data;
|
||||||
resp->continue_req_or_response_data();
|
|
||||||
|
|
||||||
const size_t total = msg.size();
|
const size_t total = msg.size();
|
||||||
size_t current = 0;
|
size_t current = 0;
|
||||||
@ -844,30 +822,27 @@ void IMAPFolder::fetchMessages(
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
|
for (auto it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
||||||
it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
|
||||||
|
|
||||||
if ((*it)->response_data() == NULL) {
|
|
||||||
|
|
||||||
|
if (!(*it)->response_data) {
|
||||||
throw exceptions::command_error("FETCH", resp->getErrorLog(), "invalid response");
|
throw exceptions::command_error("FETCH", resp->getErrorLog(), "invalid response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const IMAPParser::message_data* messageData =
|
auto *messageData = (*it)->response_data->message_data.get();
|
||||||
(*it)->response_data()->message_data();
|
|
||||||
|
|
||||||
// We are only interested in responses of type "FETCH"
|
// We are only interested in responses of type "FETCH"
|
||||||
if (messageData == NULL || messageData->type() != IMAPParser::message_data::FETCH) {
|
if (!messageData || messageData->type != IMAPParser::message_data::FETCH) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process fetch response for this message
|
// Process fetch response for this message
|
||||||
const size_t num = messageData->number();
|
const size_t num = messageData->number;
|
||||||
|
|
||||||
std::map <size_t, shared_ptr <IMAPMessage> >::iterator msg = numberToMsg.find(num);
|
std::map <size_t, shared_ptr <IMAPMessage> >::iterator msg = numberToMsg.find(num);
|
||||||
|
|
||||||
if (msg != numberToMsg.end()) {
|
if (msg != numberToMsg.end()) {
|
||||||
|
|
||||||
(*msg).second->processFetchResponse(options, messageData);
|
(*msg).second->processFetchResponse(options, *messageData);
|
||||||
|
|
||||||
if (progress) {
|
if (progress) {
|
||||||
progress->progress(++current, total);
|
progress->progress(++current, total);
|
||||||
@ -928,45 +903,39 @@ std::vector <shared_ptr <message> > IMAPFolder::getAndFetchMessages(
|
|||||||
// Get the response
|
// Get the response
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("FETCH", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("FETCH", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
|
auto &respDataList = resp->continue_req_or_response_data;
|
||||||
resp->continue_req_or_response_data();
|
|
||||||
|
|
||||||
std::vector <shared_ptr <message> > messages;
|
std::vector <shared_ptr <message> > messages;
|
||||||
|
|
||||||
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
|
for (auto it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
||||||
it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
|
||||||
|
|
||||||
if ((*it)->response_data() == NULL) {
|
|
||||||
|
|
||||||
|
if (!(*it)->response_data) {
|
||||||
throw exceptions::command_error("FETCH", resp->getErrorLog(), "invalid response");
|
throw exceptions::command_error("FETCH", resp->getErrorLog(), "invalid response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const IMAPParser::message_data* messageData =
|
auto *messageData = (*it)->response_data->message_data.get();
|
||||||
(*it)->response_data()->message_data();
|
|
||||||
|
|
||||||
// We are only interested in responses of type "FETCH"
|
// We are only interested in responses of type "FETCH"
|
||||||
if (messageData == NULL || messageData->type() != IMAPParser::message_data::FETCH) {
|
if (!messageData || messageData->type != IMAPParser::message_data::FETCH) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get message number
|
// Get message number
|
||||||
const size_t msgNum = messageData->number();
|
const size_t msgNum = messageData->number;
|
||||||
|
|
||||||
// Get message UID
|
// Get message UID
|
||||||
const std::vector <IMAPParser::msg_att_item*> atts = messageData->msg_att()->items();
|
|
||||||
message::uid msgUID;
|
message::uid msgUID;
|
||||||
|
|
||||||
for (std::vector <IMAPParser::msg_att_item*>::const_iterator
|
for (auto &att : messageData->msg_att->items) {
|
||||||
it = atts.begin() ; it != atts.end() ; ++it) {
|
|
||||||
|
|
||||||
if ((*it)->type() == IMAPParser::msg_att_item::UID) {
|
if (att->type == IMAPParser::msg_att_item::UID) {
|
||||||
msgUID = (*it)->unique_id()->value();
|
msgUID = att->uniqueid->value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -978,7 +947,7 @@ std::vector <shared_ptr <message> > IMAPFolder::getAndFetchMessages(
|
|||||||
messages.push_back(msg);
|
messages.push_back(msg);
|
||||||
|
|
||||||
// Process fetch response for this message
|
// Process fetch response for this message
|
||||||
msg->processFetchResponse(attribsWithUID, messageData);
|
msg->processFetchResponse(attribsWithUID, *messageData);
|
||||||
}
|
}
|
||||||
|
|
||||||
processStatusUpdate(resp.get());
|
processStatusUpdate(resp.get());
|
||||||
@ -1071,8 +1040,8 @@ void IMAPFolder::deleteMessages(const messageSet& msgs) {
|
|||||||
// Get the response
|
// Get the response
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("STORE", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("STORE", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
@ -1097,8 +1066,8 @@ void IMAPFolder::setMessageFlags(
|
|||||||
// Get the response
|
// Get the response
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("STORE", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("STORE", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
@ -1155,13 +1124,11 @@ messageSet IMAPFolder::addMessage(
|
|||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
const std::vector <IMAPParser::continue_req_or_response_data*>& respList
|
auto &respList = resp->continue_req_or_response_data;
|
||||||
= resp->continue_req_or_response_data();
|
|
||||||
|
|
||||||
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
|
for (auto it = respList.begin() ; !ok && (it != respList.end()) ; ++it) {
|
||||||
it = respList.begin() ; !ok && (it != respList.end()) ; ++it) {
|
|
||||||
|
|
||||||
if ((*it)->continue_req()) {
|
if ((*it)->continue_req) {
|
||||||
ok = true;
|
ok = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1216,19 +1183,19 @@ messageSet IMAPFolder::addMessage(
|
|||||||
// Get the response
|
// Get the response
|
||||||
scoped_ptr <IMAPParser::response> finalResp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> finalResp(m_connection->readResponse());
|
||||||
|
|
||||||
if (finalResp->isBad() || finalResp->response_done()->response_tagged()->
|
if (finalResp->isBad() || finalResp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("APPEND", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("APPEND", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
|
|
||||||
processStatusUpdate(finalResp.get());
|
processStatusUpdate(finalResp.get());
|
||||||
|
|
||||||
const IMAPParser::resp_text_code* respTextCode =
|
auto *respTextCode =
|
||||||
finalResp->response_done()->response_tagged()->resp_cond_state()->resp_text()->resp_text_code();
|
finalResp->response_done->response_tagged->resp_cond_state->resp_text->resp_text_code.get();
|
||||||
|
|
||||||
if (respTextCode && respTextCode->type() == IMAPParser::resp_text_code::APPENDUID) {
|
if (respTextCode && respTextCode->type == IMAPParser::resp_text_code::APPENDUID) {
|
||||||
return IMAPUtils::buildMessageSet(respTextCode->uid_set());
|
return IMAPUtils::buildMessageSet(*respTextCode->uid_set);
|
||||||
}
|
}
|
||||||
|
|
||||||
return messageSet::empty();
|
return messageSet::empty();
|
||||||
@ -1253,8 +1220,8 @@ void IMAPFolder::expunge() {
|
|||||||
// Get the response
|
// Get the response
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("EXPUNGE", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("EXPUNGE", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
@ -1286,8 +1253,8 @@ void IMAPFolder::rename(const folder::path& newPath) {
|
|||||||
// Get the response
|
// Get the response
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("RENAME", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("RENAME", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
@ -1352,19 +1319,19 @@ messageSet IMAPFolder::copyMessages(const folder::path& dest, const messageSet&
|
|||||||
// Get the response
|
// Get the response
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("COPY", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("COPY", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
|
|
||||||
processStatusUpdate(resp.get());
|
processStatusUpdate(resp.get());
|
||||||
|
|
||||||
const IMAPParser::resp_text_code* respTextCode =
|
auto *respTextCode =
|
||||||
resp->response_done()->response_tagged()->resp_cond_state()->resp_text()->resp_text_code();
|
resp->response_done->response_tagged->resp_cond_state->resp_text->resp_text_code.get();
|
||||||
|
|
||||||
if (respTextCode && respTextCode->type() == IMAPParser::resp_text_code::COPYUID) {
|
if (respTextCode && respTextCode->type == IMAPParser::resp_text_code::COPYUID) {
|
||||||
return IMAPUtils::buildMessageSet(respTextCode->uid_set2());
|
return IMAPUtils::buildMessageSet(*respTextCode->uid_set2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return messageSet::empty();
|
return messageSet::empty();
|
||||||
@ -1412,29 +1379,27 @@ shared_ptr <folderStatus> IMAPFolder::getStatus() {
|
|||||||
// Get the response
|
// Get the response
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("STATUS", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("STATUS", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList =
|
auto &respDataList = resp->continue_req_or_response_data;
|
||||||
resp->continue_req_or_response_data();
|
|
||||||
|
|
||||||
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
|
for (auto it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
||||||
it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
|
||||||
|
|
||||||
if ((*it)->response_data() != NULL) {
|
if ((*it)->response_data) {
|
||||||
|
|
||||||
const IMAPParser::response_data* responseData = (*it)->response_data();
|
auto &responseData = (*it)->response_data;
|
||||||
|
|
||||||
if (responseData->mailbox_data() &&
|
if (responseData->mailbox_data &&
|
||||||
responseData->mailbox_data()->type() == IMAPParser::mailbox_data::STATUS) {
|
responseData->mailbox_data->type == IMAPParser::mailbox_data::STATUS) {
|
||||||
|
|
||||||
shared_ptr <IMAPFolderStatus> status = make_shared <IMAPFolderStatus>();
|
shared_ptr <IMAPFolderStatus> status = make_shared <IMAPFolderStatus>();
|
||||||
status->updateFromResponse(responseData->mailbox_data());
|
status->updateFromResponse(*responseData->mailbox_data);
|
||||||
|
|
||||||
m_status->updateFromResponse(responseData->mailbox_data());
|
m_status->updateFromResponse(*responseData->mailbox_data);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -1457,8 +1422,8 @@ void IMAPFolder::noop() {
|
|||||||
|
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("NOOP", resp->getErrorLog());
|
throw exceptions::command_error("NOOP", resp->getErrorLog());
|
||||||
}
|
}
|
||||||
@ -1483,38 +1448,32 @@ std::vector <size_t> IMAPFolder::getMessageNumbersStartingOnUID(const message::u
|
|||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() ||
|
if (resp->isBad() ||
|
||||||
resp->response_done()->response_tagged()->resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp->response_done->response_tagged->resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("SEARCH", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("SEARCH", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector <IMAPParser::continue_req_or_response_data*>& respDataList = resp->continue_req_or_response_data();
|
auto& respDataList = resp->continue_req_or_response_data;
|
||||||
|
|
||||||
std::vector <size_t> seqNumbers;
|
std::vector <size_t> seqNumbers;
|
||||||
|
|
||||||
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
|
for (auto it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
||||||
it = respDataList.begin() ; it != respDataList.end() ; ++it) {
|
|
||||||
|
|
||||||
if ((*it)->response_data() == NULL) {
|
if (!(*it)->response_data) {
|
||||||
throw exceptions::command_error("SEARCH", resp->getErrorLog(), "invalid response");
|
throw exceptions::command_error("SEARCH", resp->getErrorLog(), "invalid response");
|
||||||
}
|
}
|
||||||
|
|
||||||
const IMAPParser::mailbox_data* mailboxData =
|
auto *mailboxData = (*it)->response_data->mailbox_data.get();
|
||||||
(*it)->response_data()->mailbox_data();
|
|
||||||
|
|
||||||
// We are only interested in responses of type "SEARCH"
|
// We are only interested in responses of type "SEARCH"
|
||||||
if (mailboxData == NULL ||
|
if (!mailboxData ||
|
||||||
mailboxData->type() != IMAPParser::mailbox_data::SEARCH) {
|
mailboxData->type != IMAPParser::mailbox_data::SEARCH) {
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (std::vector <IMAPParser::nz_number*>::const_iterator
|
for (auto &nzn : mailboxData->search_nz_number_list) {
|
||||||
it = mailboxData->search_nz_number_list().begin() ;
|
seqNumbers.push_back(nzn->value);
|
||||||
it != mailboxData->search_nz_number_list().end();
|
|
||||||
++it) {
|
|
||||||
|
|
||||||
seqNumbers.push_back((*it)->value());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1532,60 +1491,58 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp) {
|
|||||||
int expungedMessageCount = 0;
|
int expungedMessageCount = 0;
|
||||||
|
|
||||||
// Process tagged response
|
// Process tagged response
|
||||||
if (resp->response_done() && resp->response_done()->response_tagged() &&
|
if (resp->response_done &&
|
||||||
resp->response_done()->response_tagged()
|
resp->response_done->response_tagged &&
|
||||||
->resp_cond_state()->resp_text()->resp_text_code()) {
|
resp->response_done->response_tagged->resp_cond_state->resp_text->resp_text_code) {
|
||||||
|
|
||||||
const IMAPParser::resp_text_code* code =
|
m_status->updateFromResponse(
|
||||||
resp->response_done()->response_tagged()
|
*resp->response_done->response_tagged->resp_cond_state->resp_text->resp_text_code
|
||||||
->resp_cond_state()->resp_text()->resp_text_code();
|
);
|
||||||
|
|
||||||
m_status->updateFromResponse(code);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process untagged responses
|
// Process untagged responses
|
||||||
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
|
for (auto it = resp->continue_req_or_response_data.begin() ;
|
||||||
it = resp->continue_req_or_response_data().begin() ;
|
it != resp->continue_req_or_response_data.end() ; ++it) {
|
||||||
it != resp->continue_req_or_response_data().end() ; ++it) {
|
|
||||||
|
|
||||||
if ((*it)->response_data() && (*it)->response_data()->resp_cond_state() &&
|
if ((*it)->response_data &&
|
||||||
(*it)->response_data()->resp_cond_state()->resp_text()->resp_text_code()) {
|
(*it)->response_data->resp_cond_state &&
|
||||||
|
(*it)->response_data->resp_cond_state->resp_text->resp_text_code) {
|
||||||
|
|
||||||
const IMAPParser::resp_text_code* code =
|
m_status->updateFromResponse(
|
||||||
(*it)->response_data()->resp_cond_state()->resp_text()->resp_text_code();
|
*(*it)->response_data->resp_cond_state->resp_text->resp_text_code
|
||||||
|
);
|
||||||
|
|
||||||
m_status->updateFromResponse(code);
|
} else if ((*it)->response_data &&
|
||||||
|
(*it)->response_data->mailbox_data) {
|
||||||
|
|
||||||
} else if ((*it)->response_data() && (*it)->response_data()->mailbox_data()) {
|
m_status->updateFromResponse(*(*it)->response_data->mailbox_data);
|
||||||
|
|
||||||
m_status->updateFromResponse((*it)->response_data()->mailbox_data());
|
|
||||||
|
|
||||||
// Update folder attributes, if available
|
// Update folder attributes, if available
|
||||||
if ((*it)->response_data()->mailbox_data()->type() == IMAPParser::mailbox_data::LIST) {
|
if ((*it)->response_data->mailbox_data->type == IMAPParser::mailbox_data::LIST) {
|
||||||
|
|
||||||
folderAttributes attribs;
|
folderAttributes attribs;
|
||||||
IMAPUtils::mailboxFlagsToFolderAttributes(
|
IMAPUtils::mailboxFlagsToFolderAttributes(
|
||||||
m_connection,
|
m_connection,
|
||||||
(*it)->response_data()->mailbox_data()->mailbox_list()->mailbox_flag_list(),
|
*(*it)->response_data->mailbox_data->mailbox_list->mailbox_flag_list,
|
||||||
attribs
|
attribs
|
||||||
);
|
);
|
||||||
|
|
||||||
m_attribs = make_shared <folderAttributes>(attribs);
|
m_attribs = make_shared <folderAttributes>(attribs);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ((*it)->response_data() && (*it)->response_data()->message_data()) {
|
} else if ((*it)->response_data && (*it)->response_data->message_data) {
|
||||||
|
|
||||||
const IMAPParser::message_data* msgData = (*it)->response_data()->message_data();
|
auto* msgData = (*it)->response_data->message_data.get();
|
||||||
const size_t msgNumber = msgData->number();
|
const size_t msgNumber = msgData->number;
|
||||||
|
|
||||||
if ((*it)->response_data()->message_data()->type() == IMAPParser::message_data::FETCH) {
|
if (msgData->type == IMAPParser::message_data::FETCH) {
|
||||||
|
|
||||||
// Message changed
|
// Message changed
|
||||||
for (std::vector <IMAPMessage*>::iterator mit =
|
for (std::vector <IMAPMessage*>::iterator mit =
|
||||||
m_messages.begin() ; mit != m_messages.end() ; ++mit) {
|
m_messages.begin() ; mit != m_messages.end() ; ++mit) {
|
||||||
|
|
||||||
if ((*mit)->getNumber() == msgNumber) {
|
if ((*mit)->getNumber() == msgNumber) {
|
||||||
(*mit)->processFetchResponse(/* options */ 0, msgData);
|
(*mit)->processFetchResponse(/* options */ 0, *msgData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1597,7 +1554,7 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp) {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
} else if ((*it)->response_data()->message_data()->type() == IMAPParser::message_data::EXPUNGE) {
|
} else if (msgData->type == IMAPParser::message_data::EXPUNGE) {
|
||||||
|
|
||||||
// A message has been expunged, renumber messages
|
// A message has been expunged, renumber messages
|
||||||
for (std::vector <IMAPMessage*>::iterator jt =
|
for (std::vector <IMAPMessage*>::iterator jt =
|
||||||
|
@ -100,23 +100,20 @@ shared_ptr <folderStatus> IMAPFolderStatus::clone() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp) {
|
bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data& resp) {
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
if (resp->type() == IMAPParser::mailbox_data::STATUS) {
|
if (resp.type == IMAPParser::mailbox_data::STATUS) {
|
||||||
|
|
||||||
const IMAPParser::status_att_list* statusAttList = resp->status_att_list();
|
for (auto &attval : resp.status_att_list->values) {
|
||||||
|
|
||||||
for (std::vector <IMAPParser::status_att_val*>::const_iterator
|
switch (attval->type) {
|
||||||
jt = statusAttList->values().begin() ; jt != statusAttList->values().end() ; ++jt) {
|
|
||||||
|
|
||||||
switch ((*jt)->type()) {
|
|
||||||
|
|
||||||
case IMAPParser::status_att_val::MESSAGES: {
|
case IMAPParser::status_att_val::MESSAGES: {
|
||||||
|
|
||||||
const size_t count =
|
const size_t count =
|
||||||
static_cast <size_t>((*jt)->value_as_number()->value());
|
static_cast <size_t>(attval->value_as_number()->value);
|
||||||
|
|
||||||
if (m_count != count) {
|
if (m_count != count) {
|
||||||
m_count = count;
|
m_count = count;
|
||||||
@ -128,7 +125,7 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
|
|||||||
case IMAPParser::status_att_val::UNSEEN: {
|
case IMAPParser::status_att_val::UNSEEN: {
|
||||||
|
|
||||||
const size_t unseen =
|
const size_t unseen =
|
||||||
static_cast <size_t>((*jt)->value_as_number()->value());
|
static_cast <size_t>(attval->value_as_number()->value);
|
||||||
|
|
||||||
if (m_unseen != unseen) {
|
if (m_unseen != unseen) {
|
||||||
m_unseen = unseen;
|
m_unseen = unseen;
|
||||||
@ -140,7 +137,7 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
|
|||||||
case IMAPParser::status_att_val::RECENT: {
|
case IMAPParser::status_att_val::RECENT: {
|
||||||
|
|
||||||
const size_t recent =
|
const size_t recent =
|
||||||
static_cast <size_t>((*jt)->value_as_number()->value());
|
static_cast <size_t>(attval->value_as_number()->value);
|
||||||
|
|
||||||
if (m_recent != recent) {
|
if (m_recent != recent) {
|
||||||
m_recent = recent;
|
m_recent = recent;
|
||||||
@ -152,7 +149,7 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
|
|||||||
case IMAPParser::status_att_val::UIDNEXT: {
|
case IMAPParser::status_att_val::UIDNEXT: {
|
||||||
|
|
||||||
const vmime_uint32 uidNext =
|
const vmime_uint32 uidNext =
|
||||||
static_cast <vmime_uint32>((*jt)->value_as_number()->value());
|
static_cast <vmime_uint32>(attval->value_as_number()->value);
|
||||||
|
|
||||||
if (m_uidNext != uidNext) {
|
if (m_uidNext != uidNext) {
|
||||||
m_uidNext = uidNext;
|
m_uidNext = uidNext;
|
||||||
@ -164,7 +161,7 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
|
|||||||
case IMAPParser::status_att_val::UIDVALIDITY: {
|
case IMAPParser::status_att_val::UIDVALIDITY: {
|
||||||
|
|
||||||
const vmime_uint32 uidValidity =
|
const vmime_uint32 uidValidity =
|
||||||
static_cast <vmime_uint32>((*jt)->value_as_number()->value());
|
static_cast <vmime_uint32>(attval->value_as_number()->value);
|
||||||
|
|
||||||
if (m_uidValidity != uidValidity) {
|
if (m_uidValidity != uidValidity) {
|
||||||
m_uidValidity = uidValidity;
|
m_uidValidity = uidValidity;
|
||||||
@ -176,7 +173,7 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
|
|||||||
case IMAPParser::status_att_val::HIGHESTMODSEQ: {
|
case IMAPParser::status_att_val::HIGHESTMODSEQ: {
|
||||||
|
|
||||||
const vmime_uint64 highestModSeq =
|
const vmime_uint64 highestModSeq =
|
||||||
static_cast <vmime_uint64>((*jt)->value_as_mod_sequence_value()->value());
|
static_cast <vmime_uint64>(attval->value_as_mod_sequence_value()->value);
|
||||||
|
|
||||||
if (m_highestModSeq != highestModSeq) {
|
if (m_highestModSeq != highestModSeq) {
|
||||||
m_highestModSeq = highestModSeq;
|
m_highestModSeq = highestModSeq;
|
||||||
@ -189,20 +186,20 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (resp->type() == IMAPParser::mailbox_data::EXISTS) {
|
} else if (resp.type == IMAPParser::mailbox_data::EXISTS) {
|
||||||
|
|
||||||
const size_t count =
|
const size_t count =
|
||||||
static_cast <size_t>(resp->number()->value());
|
static_cast <size_t>(resp.number->value);
|
||||||
|
|
||||||
if (m_count != count) {
|
if (m_count != count) {
|
||||||
m_count = count;
|
m_count = count;
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (resp->type() == IMAPParser::mailbox_data::RECENT) {
|
} else if (resp.type == IMAPParser::mailbox_data::RECENT) {
|
||||||
|
|
||||||
const size_t recent =
|
const size_t recent =
|
||||||
static_cast <size_t>(resp->number()->value());
|
static_cast <size_t>(resp.number->value);
|
||||||
|
|
||||||
if (m_recent != recent) {
|
if (m_recent != recent) {
|
||||||
m_recent = recent;
|
m_recent = recent;
|
||||||
@ -214,16 +211,16 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::mailbox_data* resp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool IMAPFolderStatus::updateFromResponse(const IMAPParser::resp_text_code* resp) {
|
bool IMAPFolderStatus::updateFromResponse(const IMAPParser::resp_text_code& resp) {
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
switch (resp->type()) {
|
switch (resp.type) {
|
||||||
|
|
||||||
case IMAPParser::resp_text_code::UIDVALIDITY: {
|
case IMAPParser::resp_text_code::UIDVALIDITY: {
|
||||||
|
|
||||||
const vmime_uint32 uidValidity =
|
const vmime_uint32 uidValidity =
|
||||||
static_cast <vmime_uint32>(resp->nz_number()->value());
|
static_cast <vmime_uint32>(resp.nz_number->value);
|
||||||
|
|
||||||
if (m_uidValidity != uidValidity) {
|
if (m_uidValidity != uidValidity) {
|
||||||
m_uidValidity = uidValidity;
|
m_uidValidity = uidValidity;
|
||||||
@ -235,7 +232,7 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::resp_text_code* resp
|
|||||||
case IMAPParser::resp_text_code::UIDNEXT: {
|
case IMAPParser::resp_text_code::UIDNEXT: {
|
||||||
|
|
||||||
const vmime_uint32 uidNext =
|
const vmime_uint32 uidNext =
|
||||||
static_cast <vmime_uint32>(resp->nz_number()->value());
|
static_cast <vmime_uint32>(resp.nz_number->value);
|
||||||
|
|
||||||
if (m_uidNext != uidNext) {
|
if (m_uidNext != uidNext) {
|
||||||
m_uidNext = uidNext;
|
m_uidNext = uidNext;
|
||||||
@ -247,7 +244,7 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::resp_text_code* resp
|
|||||||
case IMAPParser::resp_text_code::UNSEEN: {
|
case IMAPParser::resp_text_code::UNSEEN: {
|
||||||
|
|
||||||
const size_t unseen =
|
const size_t unseen =
|
||||||
static_cast <size_t>(resp->nz_number()->value());
|
static_cast <size_t>(resp.nz_number->value);
|
||||||
|
|
||||||
if (m_unseen != unseen)
|
if (m_unseen != unseen)
|
||||||
{
|
{
|
||||||
@ -260,7 +257,7 @@ bool IMAPFolderStatus::updateFromResponse(const IMAPParser::resp_text_code* resp
|
|||||||
case IMAPParser::resp_text_code::HIGHESTMODSEQ: {
|
case IMAPParser::resp_text_code::HIGHESTMODSEQ: {
|
||||||
|
|
||||||
const vmime_uint64 highestModSeq =
|
const vmime_uint64 highestModSeq =
|
||||||
static_cast <vmime_uint64>(resp->mod_sequence_value()->value());
|
static_cast <vmime_uint64>(resp.mod_sequence_value->value);
|
||||||
|
|
||||||
if (m_highestModSeq != highestModSeq) {
|
if (m_highestModSeq != highestModSeq) {
|
||||||
m_highestModSeq = highestModSeq;
|
m_highestModSeq = highestModSeq;
|
||||||
|
@ -93,14 +93,14 @@ public:
|
|||||||
* @param resp parsed IMAP response
|
* @param resp parsed IMAP response
|
||||||
* @return true if the status changed, or false otherwise
|
* @return true if the status changed, or false otherwise
|
||||||
*/
|
*/
|
||||||
bool updateFromResponse(const IMAPParser::mailbox_data* resp);
|
bool updateFromResponse(const IMAPParser::mailbox_data& resp);
|
||||||
|
|
||||||
/** Reads the folder status from the specified IMAP response.
|
/** Reads the folder status from the specified IMAP response.
|
||||||
*
|
*
|
||||||
* @param resp parsed IMAP response
|
* @param resp parsed IMAP response
|
||||||
* @return true if the status changed, or false otherwise
|
* @return true if the status changed, or false otherwise
|
||||||
*/
|
*/
|
||||||
bool updateFromResponse(const IMAPParser::resp_text_code* resp);
|
bool updateFromResponse(const IMAPParser::resp_text_code& resp);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public:
|
|||||||
if (typeid(comp) == typeid(IMAPParser::msg_att_item)) {
|
if (typeid(comp) == typeid(IMAPParser::msg_att_item)) {
|
||||||
|
|
||||||
const int type = static_cast
|
const int type = static_cast
|
||||||
<const IMAPParser::msg_att_item&>(comp).type();
|
<const IMAPParser::msg_att_item&>(comp).type;
|
||||||
|
|
||||||
if (type == IMAPParser::msg_att_item::BODY_SECTION ||
|
if (type == IMAPParser::msg_att_item::BODY_SECTION ||
|
||||||
type == IMAPParser::msg_att_item::RFC822_TEXT) {
|
type == IMAPParser::msg_att_item::RFC822_TEXT) {
|
||||||
@ -460,8 +460,8 @@ size_t IMAPMessage::extractImpl(
|
|||||||
// Get the response
|
// Get the response
|
||||||
scoped_ptr <IMAPParser::response> resp(folder->m_connection->readResponse(&literalHandler));
|
scoped_ptr <IMAPParser::response> resp(folder->m_connection->readResponse(&literalHandler));
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("FETCH", resp->getErrorLog(), "bad response");
|
throw exceptions::command_error("FETCH", resp->getErrorLog(), "bad response");
|
||||||
}
|
}
|
||||||
@ -477,23 +477,21 @@ size_t IMAPMessage::extractImpl(
|
|||||||
|
|
||||||
int IMAPMessage::processFetchResponse(
|
int IMAPMessage::processFetchResponse(
|
||||||
const fetchAttributes& options,
|
const fetchAttributes& options,
|
||||||
const IMAPParser::message_data* msgData
|
const IMAPParser::message_data& msgData
|
||||||
) {
|
) {
|
||||||
|
|
||||||
shared_ptr <IMAPFolder> folder = m_folder.lock();
|
shared_ptr <IMAPFolder> folder = m_folder.lock();
|
||||||
|
|
||||||
// Get message attributes
|
// Get message attributes
|
||||||
const std::vector <IMAPParser::msg_att_item*> atts = msgData->msg_att()->items();
|
|
||||||
int changes = 0;
|
int changes = 0;
|
||||||
|
|
||||||
for (std::vector <IMAPParser::msg_att_item*>::const_iterator
|
for (auto &att : msgData.msg_att->items) {
|
||||||
it = atts.begin() ; it != atts.end() ; ++it) {
|
|
||||||
|
|
||||||
switch ((*it)->type()) {
|
switch (att->type) {
|
||||||
|
|
||||||
case IMAPParser::msg_att_item::FLAGS: {
|
case IMAPParser::msg_att_item::FLAGS: {
|
||||||
|
|
||||||
int flags = IMAPUtils::messageFlagsFromFlags((*it)->flag_list());
|
int flags = IMAPUtils::messageFlagsFromFlags(*att->flag_list);
|
||||||
|
|
||||||
if (m_flags != flags) {
|
if (m_flags != flags) {
|
||||||
m_flags = flags;
|
m_flags = flags;
|
||||||
@ -504,33 +502,33 @@ int IMAPMessage::processFetchResponse(
|
|||||||
}
|
}
|
||||||
case IMAPParser::msg_att_item::UID: {
|
case IMAPParser::msg_att_item::UID: {
|
||||||
|
|
||||||
m_uid = (*it)->unique_id()->value();
|
m_uid = att->uniqueid->value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IMAPParser::msg_att_item::MODSEQ: {
|
case IMAPParser::msg_att_item::MODSEQ: {
|
||||||
|
|
||||||
m_modseq = (*it)->mod_sequence_value()->value();
|
m_modseq = att->mod_sequence_value->value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IMAPParser::msg_att_item::ENVELOPE: {
|
case IMAPParser::msg_att_item::ENVELOPE: {
|
||||||
|
|
||||||
if (!options.has(fetchAttributes::FULL_HEADER)) {
|
if (!options.has(fetchAttributes::FULL_HEADER)) {
|
||||||
|
|
||||||
const IMAPParser::envelope* env = (*it)->envelope();
|
auto* env = att->envelope.get();
|
||||||
shared_ptr <vmime::header> hdr = getOrCreateHeader();
|
shared_ptr <vmime::header> hdr = getOrCreateHeader();
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
hdr->Date()->setValue(env->env_date()->value());
|
hdr->Date()->setValue(env->env_date->value);
|
||||||
|
|
||||||
// Subject
|
// Subject
|
||||||
text subject;
|
text subject;
|
||||||
text::decodeAndUnfold(env->env_subject()->value(), &subject);
|
text::decodeAndUnfold(env->env_subject->value, &subject);
|
||||||
|
|
||||||
hdr->Subject()->setValue(subject);
|
hdr->Subject()->setValue(subject);
|
||||||
|
|
||||||
// From
|
// From
|
||||||
mailboxList from;
|
mailboxList from;
|
||||||
IMAPUtils::convertAddressList(*(env->env_from()), from);
|
IMAPUtils::convertAddressList(*(env->env_from), from);
|
||||||
|
|
||||||
if (!from.isEmpty()) {
|
if (!from.isEmpty()) {
|
||||||
hdr->From()->setValue(*(from.getMailboxAt(0)));
|
hdr->From()->setValue(*(from.getMailboxAt(0)));
|
||||||
@ -538,13 +536,13 @@ int IMAPMessage::processFetchResponse(
|
|||||||
|
|
||||||
// To
|
// To
|
||||||
mailboxList to;
|
mailboxList to;
|
||||||
IMAPUtils::convertAddressList(*(env->env_to()), to);
|
IMAPUtils::convertAddressList(*(env->env_to), to);
|
||||||
|
|
||||||
hdr->To()->setValue(to.toAddressList());
|
hdr->To()->setValue(to.toAddressList());
|
||||||
|
|
||||||
// Sender
|
// Sender
|
||||||
mailboxList sender;
|
mailboxList sender;
|
||||||
IMAPUtils::convertAddressList(*(env->env_sender()), sender);
|
IMAPUtils::convertAddressList(*(env->env_sender), sender);
|
||||||
|
|
||||||
if (!sender.isEmpty()) {
|
if (!sender.isEmpty()) {
|
||||||
hdr->Sender()->setValue(*(sender.getMailboxAt(0)));
|
hdr->Sender()->setValue(*(sender.getMailboxAt(0)));
|
||||||
@ -552,7 +550,7 @@ int IMAPMessage::processFetchResponse(
|
|||||||
|
|
||||||
// Reply-to
|
// Reply-to
|
||||||
mailboxList replyTo;
|
mailboxList replyTo;
|
||||||
IMAPUtils::convertAddressList(*(env->env_reply_to()), replyTo);
|
IMAPUtils::convertAddressList(*(env->env_reply_to), replyTo);
|
||||||
|
|
||||||
if (!replyTo.isEmpty()) {
|
if (!replyTo.isEmpty()) {
|
||||||
hdr->ReplyTo()->setValue(*(replyTo.getMailboxAt(0)));
|
hdr->ReplyTo()->setValue(*(replyTo.getMailboxAt(0)));
|
||||||
@ -560,7 +558,7 @@ int IMAPMessage::processFetchResponse(
|
|||||||
|
|
||||||
// Cc
|
// Cc
|
||||||
mailboxList cc;
|
mailboxList cc;
|
||||||
IMAPUtils::convertAddressList(*(env->env_cc()), cc);
|
IMAPUtils::convertAddressList(*(env->env_cc), cc);
|
||||||
|
|
||||||
if (!cc.isEmpty()) {
|
if (!cc.isEmpty()) {
|
||||||
hdr->Cc()->setValue(cc.toAddressList());
|
hdr->Cc()->setValue(cc.toAddressList());
|
||||||
@ -568,7 +566,7 @@ int IMAPMessage::processFetchResponse(
|
|||||||
|
|
||||||
// Bcc
|
// Bcc
|
||||||
mailboxList bcc;
|
mailboxList bcc;
|
||||||
IMAPUtils::convertAddressList(*(env->env_bcc()), bcc);
|
IMAPUtils::convertAddressList(*(env->env_bcc), bcc);
|
||||||
|
|
||||||
if (!bcc.isEmpty()) {
|
if (!bcc.isEmpty()) {
|
||||||
hdr->Bcc()->setValue(bcc.toAddressList());
|
hdr->Bcc()->setValue(bcc.toAddressList());
|
||||||
@ -579,37 +577,34 @@ int IMAPMessage::processFetchResponse(
|
|||||||
}
|
}
|
||||||
case IMAPParser::msg_att_item::BODY_STRUCTURE: {
|
case IMAPParser::msg_att_item::BODY_STRUCTURE: {
|
||||||
|
|
||||||
m_structure = make_shared <IMAPMessageStructure>((*it)->body());
|
m_structure = make_shared <IMAPMessageStructure>(att->body.get());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IMAPParser::msg_att_item::RFC822_HEADER: {
|
case IMAPParser::msg_att_item::RFC822_HEADER: {
|
||||||
|
|
||||||
getOrCreateHeader()->parse((*it)->nstring()->value());
|
getOrCreateHeader()->parse(att->nstring->value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IMAPParser::msg_att_item::RFC822_SIZE: {
|
case IMAPParser::msg_att_item::RFC822_SIZE: {
|
||||||
|
|
||||||
m_size = static_cast <size_t>((*it)->number()->value());
|
m_size = static_cast <size_t>(att->number->value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case IMAPParser::msg_att_item::BODY_SECTION: {
|
case IMAPParser::msg_att_item::BODY_SECTION: {
|
||||||
|
|
||||||
if (!options.has(fetchAttributes::FULL_HEADER)) {
|
if (!options.has(fetchAttributes::FULL_HEADER)) {
|
||||||
|
|
||||||
if ((*it)->section()->section_text1() &&
|
if (att->section->section_text1 &&
|
||||||
(*it)->section()->section_text1()->type()
|
att->section->section_text1->type
|
||||||
== IMAPParser::section_text::HEADER_FIELDS) {
|
== IMAPParser::section_text::HEADER_FIELDS) {
|
||||||
|
|
||||||
header tempHeader;
|
header tempHeader;
|
||||||
tempHeader.parse((*it)->nstring()->value());
|
tempHeader.parse(att->nstring->value);
|
||||||
|
|
||||||
vmime::header& hdr = *getOrCreateHeader();
|
vmime::header& hdr = *getOrCreateHeader();
|
||||||
std::vector <shared_ptr <headerField> > fields = tempHeader.getFieldList();
|
|
||||||
|
|
||||||
for (std::vector <shared_ptr <headerField> >::const_iterator jt = fields.begin() ;
|
for (auto& fld : tempHeader.getFieldList()) {
|
||||||
jt != fields.end() ; ++jt) {
|
hdr.appendField(vmime::clone(fld));
|
||||||
|
|
||||||
hdr.appendField(vmime::clone(*jt));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ private:
|
|||||||
* @return a combination of flags that specify what changed exactly on
|
* @return a combination of flags that specify what changed exactly on
|
||||||
* this message (see events::messageChangedEvent::Types)
|
* this message (see events::messageChangedEvent::Types)
|
||||||
*/
|
*/
|
||||||
int processFetchResponse(const fetchAttributes& options, const IMAPParser::message_data* msgData);
|
int processFetchResponse(const fetchAttributes& options, const IMAPParser::message_data& msgData);
|
||||||
|
|
||||||
/** Recursively fetch part header for all parts in the structure.
|
/** Recursively fetch part header for all parts in the structure.
|
||||||
*
|
*
|
||||||
|
@ -48,7 +48,7 @@ IMAPMessagePart::IMAPMessagePart(
|
|||||||
|
|
||||||
m_mediaType = vmime::mediaType(
|
m_mediaType = vmime::mediaType(
|
||||||
"multipart",
|
"multipart",
|
||||||
mpart->media_subtype()->value()
|
mpart->media_subtype->value
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,35 +63,35 @@ IMAPMessagePart::IMAPMessagePart(
|
|||||||
m_number(number),
|
m_number(number),
|
||||||
m_size(0) {
|
m_size(0) {
|
||||||
|
|
||||||
if (part->body_type_text()) {
|
if (part->body_type_text) {
|
||||||
|
|
||||||
m_mediaType = vmime::mediaType(
|
m_mediaType = vmime::mediaType(
|
||||||
"text",
|
"text",
|
||||||
part->body_type_text()->media_text()->media_subtype()->value()
|
part->body_type_text->media_text->media_subtype->value
|
||||||
);
|
);
|
||||||
|
|
||||||
m_size = part->body_type_text()->body_fields()->body_fld_octets()->value();
|
m_size = part->body_type_text->body_fields->body_fld_octets->value;
|
||||||
|
|
||||||
} else if (part->body_type_msg()) {
|
} else if (part->body_type_msg) {
|
||||||
|
|
||||||
m_mediaType = vmime::mediaType(
|
m_mediaType = vmime::mediaType(
|
||||||
"message",
|
"message",
|
||||||
part->body_type_msg()->media_message()->media_subtype()->value()
|
part->body_type_msg->media_message->media_subtype->value
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
m_mediaType = vmime::mediaType(
|
m_mediaType = vmime::mediaType(
|
||||||
part->body_type_basic()->media_basic()->media_type()->value(),
|
part->body_type_basic->media_basic->media_type->value,
|
||||||
part->body_type_basic()->media_basic()->media_subtype()->value()
|
part->body_type_basic->media_basic->media_subtype->value
|
||||||
);
|
);
|
||||||
|
|
||||||
m_size = part->body_type_basic()->body_fields()->body_fld_octets()->value();
|
m_size = part->body_type_basic->body_fields->body_fld_octets->value;
|
||||||
|
|
||||||
if (const auto pparam = part->body_type_basic()->body_fields()->body_fld_param()) {
|
if (const auto* pparam = part->body_type_basic->body_fields->body_fld_param.get()) {
|
||||||
for (const auto& param : pparam->items()) {
|
for (const auto& param : pparam->items) {
|
||||||
if (param->string1()->value() == "NAME") {
|
if (param->string1->value == "NAME") {
|
||||||
m_name = param->string2()->value();
|
m_name = param->string2->value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -168,16 +168,16 @@ shared_ptr <IMAPMessagePart> IMAPMessagePart::create(
|
|||||||
const IMAPParser::body* body
|
const IMAPParser::body* body
|
||||||
) {
|
) {
|
||||||
|
|
||||||
if (body->body_type_mpart()) {
|
if (body->body_type_mpart) {
|
||||||
|
|
||||||
shared_ptr <IMAPMessagePart> part = make_shared <IMAPMessagePart>(parent, number, body->body_type_mpart());
|
auto part = make_shared <IMAPMessagePart>(parent, number, body->body_type_mpart.get());
|
||||||
part->m_structure = make_shared <IMAPMessageStructure>(part, body->body_type_mpart()->list());
|
part->m_structure = make_shared <IMAPMessageStructure>(part, body->body_type_mpart->list);
|
||||||
|
|
||||||
return part;
|
return part;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return make_shared <IMAPMessagePart>(parent, number, body->body_type_1part());
|
return make_shared <IMAPMessagePart>(parent, number, body->body_type_1part.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,15 +48,13 @@ IMAPMessageStructure::IMAPMessageStructure(const IMAPParser::body* body) {
|
|||||||
|
|
||||||
IMAPMessageStructure::IMAPMessageStructure(
|
IMAPMessageStructure::IMAPMessageStructure(
|
||||||
const shared_ptr <IMAPMessagePart>& parent,
|
const shared_ptr <IMAPMessagePart>& parent,
|
||||||
const std::vector <IMAPParser::body*>& list
|
const std::vector <std::unique_ptr <IMAPParser::body>>& list
|
||||||
) {
|
) {
|
||||||
|
|
||||||
size_t number = 0;
|
size_t number = 0;
|
||||||
|
|
||||||
for (std::vector <IMAPParser::body*>::const_iterator
|
for (auto it = list.begin() ; it != list.end() ; ++it, ++number) {
|
||||||
it = list.begin() ; it != list.end() ; ++it, ++number) {
|
m_parts.push_back(IMAPMessagePart::create(parent, number, it->get()));
|
||||||
|
|
||||||
m_parts.push_back(IMAPMessagePart::create(parent, number, *it));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public:
|
|||||||
|
|
||||||
IMAPMessageStructure();
|
IMAPMessageStructure();
|
||||||
IMAPMessageStructure(const IMAPParser::body* body);
|
IMAPMessageStructure(const IMAPParser::body* body);
|
||||||
IMAPMessageStructure(const shared_ptr <IMAPMessagePart>& parent, const std::vector <IMAPParser::body*>& list);
|
IMAPMessageStructure(const shared_ptr <IMAPMessagePart>& parent, const std::vector <std::unique_ptr <IMAPParser::body>>& list);
|
||||||
|
|
||||||
shared_ptr <const messagePart> getPartAt(const size_t x) const;
|
shared_ptr <const messagePart> getPartAt(const size_t x) const;
|
||||||
shared_ptr <messagePart> getPartAt(const size_t x);
|
shared_ptr <messagePart> getPartAt(const size_t x);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -208,8 +208,8 @@ void IMAPStore::noop() {
|
|||||||
|
|
||||||
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
scoped_ptr <IMAPParser::response> resp(m_connection->readResponse());
|
||||||
|
|
||||||
if (resp->isBad() || resp->response_done()->response_tagged()->
|
if (resp->isBad() || resp->response_done->response_tagged->
|
||||||
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) {
|
resp_cond_state->status != IMAPParser::resp_cond_state::OK) {
|
||||||
|
|
||||||
throw exceptions::command_error("NOOP", resp->getErrorLog());
|
throw exceptions::command_error("NOOP", resp->getErrorLog());
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,7 @@ const folder::path::component IMAPUtils::fromModifiedUTF7(const string& text) {
|
|||||||
// static
|
// static
|
||||||
void IMAPUtils::mailboxFlagsToFolderAttributes(
|
void IMAPUtils::mailboxFlagsToFolderAttributes(
|
||||||
const shared_ptr <const IMAPConnection>& cnt,
|
const shared_ptr <const IMAPConnection>& cnt,
|
||||||
const IMAPParser::mailbox_flag_list* list,
|
const IMAPParser::mailbox_flag_list& list,
|
||||||
folderAttributes& attribs
|
folderAttributes& attribs
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@ -404,12 +404,9 @@ void IMAPUtils::mailboxFlagsToFolderAttributes(
|
|||||||
flags |= folderAttributes::FLAG_HAS_CHILDREN;
|
flags |= folderAttributes::FLAG_HAS_CHILDREN;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector <IMAPParser::mailbox_flag*>& mailboxFlags = list->flags();
|
for (auto it = list.flags.begin() ; it != list.flags.end() ; ++it) {
|
||||||
|
|
||||||
for (std::vector <IMAPParser::mailbox_flag*>::const_iterator it = mailboxFlags.begin() ;
|
switch ((*it)->type) {
|
||||||
it != mailboxFlags.end() ; ++it) {
|
|
||||||
|
|
||||||
switch ((*it)->type()) {
|
|
||||||
|
|
||||||
case IMAPParser::mailbox_flag::NOSELECT:
|
case IMAPParser::mailbox_flag::NOSELECT:
|
||||||
|
|
||||||
@ -480,15 +477,13 @@ void IMAPUtils::mailboxFlagsToFolderAttributes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int IMAPUtils::messageFlagsFromFlags(const IMAPParser::flag_list* list) {
|
int IMAPUtils::messageFlagsFromFlags(const IMAPParser::flag_list& list) {
|
||||||
|
|
||||||
const std::vector <IMAPParser::flag*>& flagList = list->flags();
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
|
|
||||||
for (std::vector <IMAPParser::flag*>::const_iterator
|
for (auto &flag : list.flags) {
|
||||||
it = flagList.begin() ; it != flagList.end() ; ++it) {
|
|
||||||
|
|
||||||
switch ((*it)->type()) {
|
switch (flag->type) {
|
||||||
|
|
||||||
case IMAPParser::flag::ANSWERED:
|
case IMAPParser::flag::ANSWERED:
|
||||||
|
|
||||||
@ -705,16 +700,13 @@ void IMAPUtils::convertAddressList(
|
|||||||
mailboxList& dest
|
mailboxList& dest
|
||||||
) {
|
) {
|
||||||
|
|
||||||
for (std::vector <IMAPParser::address*>::const_iterator
|
for (auto& addr : src.addresses) {
|
||||||
it = src.addresses().begin() ; it != src.addresses().end() ; ++it) {
|
|
||||||
|
|
||||||
const IMAPParser::address& addr = **it;
|
|
||||||
|
|
||||||
text name;
|
text name;
|
||||||
text::decodeAndUnfold(addr.addr_name()->value(), &name);
|
text::decodeAndUnfold(addr->addr_name->value, &name);
|
||||||
|
|
||||||
string email = addr.addr_mailbox()->value()
|
string email = addr->addr_mailbox->value
|
||||||
+ "@" + addr.addr_host()->value();
|
+ "@" + addr->addr_host->value;
|
||||||
|
|
||||||
dest.appendMailbox(make_shared <mailbox>(name, email));
|
dest.appendMailbox(make_shared <mailbox>(name, email));
|
||||||
}
|
}
|
||||||
@ -817,18 +809,20 @@ const string IMAPUtils::messageSetToSequenceSet(const messageSet& msgs) {
|
|||||||
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
messageSet IMAPUtils::buildMessageSet(const IMAPParser::uid_set* uidSet) {
|
messageSet IMAPUtils::buildMessageSet(const IMAPParser::uid_set& uidSetRef) {
|
||||||
|
|
||||||
messageSet set = messageSet::empty();
|
messageSet set = messageSet::empty();
|
||||||
|
|
||||||
for ( ; uidSet ; uidSet = uidSet->next_uid_set()) {
|
const IMAPParser::uid_set* uidSet = &uidSetRef;
|
||||||
|
|
||||||
if (uidSet->uid_range()) {
|
for ( ; uidSet ; uidSet = uidSet->next_uid_set.get()) {
|
||||||
|
|
||||||
|
if (uidSet->uid_range) {
|
||||||
|
|
||||||
set.addRange(
|
set.addRange(
|
||||||
UIDMessageRange(
|
UIDMessageRange(
|
||||||
message::uid(uidSet->uid_range()->uniqueid1()->value()),
|
message::uid(uidSet->uid_range->uniqueid1->value),
|
||||||
message::uid(uidSet->uid_range()->uniqueid2()->value())
|
message::uid(uidSet->uid_range->uniqueid2->value)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -836,7 +830,7 @@ messageSet IMAPUtils::buildMessageSet(const IMAPParser::uid_set* uidSet) {
|
|||||||
|
|
||||||
set.addRange(
|
set.addRange(
|
||||||
UIDMessageRange(
|
UIDMessageRange(
|
||||||
message::uid(uidSet->uniqueid()->value())
|
message::uid(uidSet->uniqueid->value)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -73,12 +73,13 @@ public:
|
|||||||
* @param list list of mailbox flags
|
* @param list list of mailbox flags
|
||||||
* @param attribs reference to an object holding folder attributes
|
* @param attribs reference to an object holding folder attributes
|
||||||
*/
|
*/
|
||||||
static void mailboxFlagsToFolderAttributes
|
static void mailboxFlagsToFolderAttributes(
|
||||||
(const shared_ptr <const IMAPConnection>& cnt,
|
const shared_ptr <const IMAPConnection>& cnt,
|
||||||
const IMAPParser::mailbox_flag_list* list,
|
const IMAPParser::mailbox_flag_list& list,
|
||||||
folderAttributes& attribs);
|
folderAttributes& attribs
|
||||||
|
);
|
||||||
|
|
||||||
static int messageFlagsFromFlags(const IMAPParser::flag_list* list);
|
static int messageFlagsFromFlags(const IMAPParser::flag_list& list);
|
||||||
|
|
||||||
static const std::vector <string> messageFlagList(const int flags);
|
static const std::vector <string> messageFlagList(const int flags);
|
||||||
|
|
||||||
@ -97,8 +98,11 @@ public:
|
|||||||
* @param options fetch options
|
* @param options fetch options
|
||||||
* @return fetch request
|
* @return fetch request
|
||||||
*/
|
*/
|
||||||
static shared_ptr <IMAPCommand> buildFetchCommand
|
static shared_ptr <IMAPCommand> buildFetchCommand(
|
||||||
(const shared_ptr <IMAPConnection>& cnt, const messageSet& msgs, const fetchAttributes& options);
|
const shared_ptr <IMAPConnection>& cnt,
|
||||||
|
const messageSet& msgs,
|
||||||
|
const fetchAttributes& options
|
||||||
|
);
|
||||||
|
|
||||||
/** Convert a parser-style address list to a mailbox list.
|
/** Convert a parser-style address list to a mailbox list.
|
||||||
*
|
*
|
||||||
@ -119,7 +123,7 @@ public:
|
|||||||
* @param uidSet UID set, as returned by the parser
|
* @param uidSet UID set, as returned by the parser
|
||||||
* @return message set
|
* @return message set
|
||||||
*/
|
*/
|
||||||
static messageSet buildMessageSet(const IMAPParser::uid_set* uidSet);
|
static messageSet buildMessageSet(const IMAPParser::uid_set& uidSet);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user