Added POP3 notifications.
This commit is contained in:
parent
4409698208
commit
b2df9c842b
@ -11,6 +11,8 @@ VERSION 0.6.4cvs
|
||||
* SConstruct: fixed compilation/linking problem with g++ and X86-64 on
|
||||
static library: added -fPIC/-fpic in compiler flags.
|
||||
|
||||
* messaging/POP3*: added notifications.
|
||||
|
||||
2005-03-17 Vincent Richard <vincent@vincent-richard.net>
|
||||
|
||||
* base.{cpp|hpp}: renamed 'MIME_VERSION' to 'SUPPORTED_MIME_VERSION'.
|
||||
|
@ -540,6 +540,24 @@ void POP3Folder::deleteMessage(const int num)
|
||||
|
||||
if (!m_store->isSuccessResponse(response))
|
||||
throw exceptions::command_error("DELE", response);
|
||||
|
||||
// Update local flags
|
||||
for (std::map <POP3Message*, int>::iterator it =
|
||||
m_messages.begin() ; it != m_messages.end() ; ++it)
|
||||
{
|
||||
POP3Message* msg = (*it).first;
|
||||
|
||||
if (msg->getNumber() == num)
|
||||
msg->m_deleted = true;
|
||||
}
|
||||
|
||||
// Notify message flags changed
|
||||
std::vector <int> nums;
|
||||
nums.push_back(num);
|
||||
|
||||
events::messageChangedEvent event(this, events::messageChangedEvent::TYPE_FLAGS, nums);
|
||||
|
||||
notifyMessageChanged(event);
|
||||
}
|
||||
|
||||
|
||||
@ -568,6 +586,26 @@ void POP3Folder::deleteMessages(const int from, const int to)
|
||||
if (!m_store->isSuccessResponse(response))
|
||||
throw exceptions::command_error("DELE", response);
|
||||
}
|
||||
|
||||
// Update local flags
|
||||
for (std::map <POP3Message*, int>::iterator it =
|
||||
m_messages.begin() ; it != m_messages.end() ; ++it)
|
||||
{
|
||||
POP3Message* msg = (*it).first;
|
||||
|
||||
if (msg->getNumber() >= from && msg->getNumber() <= to2)
|
||||
msg->m_deleted = true;
|
||||
}
|
||||
|
||||
// Notify message flags changed
|
||||
std::vector <int> nums;
|
||||
|
||||
for (int i = from ; i <= to2 ; ++i)
|
||||
nums.push_back(i);
|
||||
|
||||
events::messageChangedEvent event(this, events::messageChangedEvent::TYPE_FLAGS, nums);
|
||||
|
||||
notifyMessageChanged(event);
|
||||
}
|
||||
|
||||
|
||||
@ -595,6 +633,29 @@ void POP3Folder::deleteMessages(const std::vector <int>& nums)
|
||||
if (!m_store->isSuccessResponse(response))
|
||||
throw exceptions::command_error("DELE", response);
|
||||
}
|
||||
|
||||
// Sort message list
|
||||
std::vector <int> list;
|
||||
|
||||
list.resize(nums.size());
|
||||
std::copy(nums.begin(), nums.end(), list.begin());
|
||||
|
||||
std::sort(list.begin(), list.end());
|
||||
|
||||
// Update local flags
|
||||
for (std::map <POP3Message*, int>::iterator it =
|
||||
m_messages.begin() ; it != m_messages.end() ; ++it)
|
||||
{
|
||||
POP3Message* msg = (*it).first;
|
||||
|
||||
if (std::binary_search(list.begin(), list.end(), msg->getNumber()))
|
||||
msg->m_deleted = true;
|
||||
}
|
||||
|
||||
// Notify message flags changed
|
||||
events::messageChangedEvent event(this, events::messageChangedEvent::TYPE_FLAGS, list);
|
||||
|
||||
notifyMessageChanged(event);
|
||||
}
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace messaging {
|
||||
|
||||
|
||||
POP3Message::POP3Message(POP3Folder* folder, const int num)
|
||||
: m_folder(folder), m_num(num), m_size(-1), m_header(NULL)
|
||||
: m_folder(folder), m_num(num), m_size(-1), m_deleted(false), m_header(NULL)
|
||||
{
|
||||
m_folder->registerMessage(this);
|
||||
}
|
||||
@ -79,7 +79,12 @@ const bool POP3Message::isExpunged() const
|
||||
|
||||
const int POP3Message::getFlags() const
|
||||
{
|
||||
return (FLAG_RECENT);
|
||||
int flags = FLAG_RECENT;
|
||||
|
||||
if (m_deleted)
|
||||
flags |= FLAG_DELETED;
|
||||
|
||||
return (flags);
|
||||
}
|
||||
|
||||
|
||||
|
@ -79,6 +79,8 @@ private:
|
||||
uid m_uid;
|
||||
int m_size;
|
||||
|
||||
bool m_deleted;
|
||||
|
||||
header* m_header;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user