diff options
Diffstat (limited to '')
-rw-r--r-- | src/net/maildir/maildirFolder.cpp | 27 | ||||
-rw-r--r-- | src/net/maildir/maildirFolderStatus.cpp | 67 | ||||
-rw-r--r-- | src/net/maildir/maildirMessage.cpp | 2 |
3 files changed, 90 insertions, 6 deletions
diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp index aa886ff3..3ea1093e 100644 --- a/src/net/maildir/maildirFolder.cpp +++ b/src/net/maildir/maildirFolder.cpp @@ -33,6 +33,7 @@ #include "vmime/net/maildir/maildirMessage.hpp" #include "vmime/net/maildir/maildirUtils.hpp" #include "vmime/net/maildir/maildirFormat.hpp" +#include "vmime/net/maildir/maildirFolderStatus.hpp" #include "vmime/utility/smartPtr.hpp" @@ -1163,22 +1164,36 @@ void maildirFolder::notifyMessagesCopied(const folder::path& dest) void maildirFolder::status(int& count, int& unseen) { + count = 0; + unseen = 0; + + ref <folderStatus> status = getStatus(); + + count = status->getMessageCount(); + unseen = status->getUnseenCount(); +} + + +ref <folderStatus> maildirFolder::getStatus() +{ ref <maildirStore> store = m_store.acquire(); const int oldCount = m_messageCount; scanFolder(); - count = m_messageCount; - unseen = m_unreadMessageCount; + ref <maildirFolderStatus> status = vmime::create <maildirFolderStatus>(); + + status->setMessageCount(m_messageCount); + status->setUnseenCount(m_unreadMessageCount); // Notify message count changed (new messages) - if (count > oldCount) + if (m_messageCount > oldCount) { std::vector <int> nums; - nums.reserve(count - oldCount); + nums.reserve(m_messageCount - oldCount); - for (int i = oldCount + 1, j = 0 ; i <= count ; ++i, ++j) + for (int i = oldCount + 1, j = 0 ; i <= m_messageCount ; ++i, ++j) nums[j] = i; events::messageCountEvent event @@ -1207,6 +1222,8 @@ void maildirFolder::status(int& count, int& unseen) } } } + + return status; } diff --git a/src/net/maildir/maildirFolderStatus.cpp b/src/net/maildir/maildirFolderStatus.cpp new file mode 100644 index 00000000..49425e59 --- /dev/null +++ b/src/net/maildir/maildirFolderStatus.cpp @@ -0,0 +1,67 @@ +// +// VMime library (http://www.vmime.org) +// Copyright (C) 2002-2013 Vincent Richard <[email protected]> +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License as +// published by the Free Software Foundation; either version 3 of +// the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program; if not, write to the Free Software Foundation, Inc., +// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +// +// Linking this library statically or dynamically with other modules is making +// a combined work based on this library. Thus, the terms and conditions of +// the GNU General Public License cover the whole combination. +// + +#include "vmime/config.hpp" + + +#if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_MAILDIR + + +#include "vmime/net/maildir/maildirFolderStatus.hpp" + + +namespace vmime { +namespace net { +namespace maildir { + + +unsigned int maildirFolderStatus::getMessageCount() const +{ + return m_count; +} + + +unsigned int maildirFolderStatus::getUnseenCount() const +{ + return m_unseen; +} + + +void maildirFolderStatus::setMessageCount(const unsigned int count) +{ + m_count = count; +} + + +void maildirFolderStatus::setUnseenCount(const unsigned int unseen) +{ + m_unseen = unseen; +} + + +} // maildir +} // net +} // vmime + + +#endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_MAILDIR diff --git a/src/net/maildir/maildirMessage.cpp b/src/net/maildir/maildirMessage.cpp index 9b14ad78..b6c12053 100644 --- a/src/net/maildir/maildirMessage.cpp +++ b/src/net/maildir/maildirMessage.cpp @@ -261,7 +261,7 @@ int maildirMessage::getNumber() const } -const message::uid maildirMessage::getUniqueId() const +const message::uid maildirMessage::getUID() const { return (m_uid); } |