aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/pop3
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/net/pop3/POP3Folder.cpp25
-rw-r--r--src/net/pop3/POP3FolderStatus.cpp67
-rw-r--r--src/net/pop3/POP3Message.cpp2
3 files changed, 90 insertions, 4 deletions
diff --git a/src/net/pop3/POP3Folder.cpp b/src/net/pop3/POP3Folder.cpp
index 7aa850b1..1b7b3df6 100644
--- a/src/net/pop3/POP3Folder.cpp
+++ b/src/net/pop3/POP3Folder.cpp
@@ -33,6 +33,7 @@
#include "vmime/net/pop3/POP3Message.hpp"
#include "vmime/net/pop3/POP3Command.hpp"
#include "vmime/net/pop3/POP3Response.hpp"
+#include "vmime/net/pop3/POP3FolderStatus.hpp"
#include "vmime/net/pop3/POP3Utils.hpp"
@@ -752,12 +753,22 @@ void POP3Folder::copyMessages(const folder::path& /* dest */, const std::vector
void POP3Folder::status(int& count, int& unseen)
{
+ count = 0;
+ unseen = 0;
+
+ ref <folderStatus> status = getStatus();
+
+ count = status->getMessageCount();
+ unseen = status->getUnseenCount();
+}
+
+
+ref <folderStatus> POP3Folder::getStatus()
+{
ref <POP3Store> store = m_store.acquire();
if (!store)
throw exceptions::illegal_state("Store disconnected");
- else if (!isOpen())
- throw exceptions::illegal_state("Folder not open");
POP3Command::STAT()->send(store->getConnection());
@@ -767,10 +778,16 @@ void POP3Folder::status(int& count, int& unseen)
if (!response->isSuccess())
throw exceptions::command_error("STAT", response->getFirstLine());
+
+ unsigned int count = 0;
+
std::istringstream iss(response->getText());
iss >> count;
- unseen = count;
+ ref <POP3FolderStatus> status = vmime::create <POP3FolderStatus>();
+
+ status->setMessageCount(count);
+ status->setUnseenCount(count);
// Update local message count
if (m_messageCount != count)
@@ -811,6 +828,8 @@ void POP3Folder::status(int& count, int& unseen)
}
}
}
+
+ return status;
}
diff --git a/src/net/pop3/POP3FolderStatus.cpp b/src/net/pop3/POP3FolderStatus.cpp
new file mode 100644
index 00000000..e8c5face
--- /dev/null
+++ b/src/net/pop3/POP3FolderStatus.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_POP3
+
+
+#include "vmime/net/pop3/POP3FolderStatus.hpp"
+
+
+namespace vmime {
+namespace net {
+namespace pop3 {
+
+
+unsigned int POP3FolderStatus::getMessageCount() const
+{
+ return m_count;
+}
+
+
+unsigned int POP3FolderStatus::getUnseenCount() const
+{
+ return m_unseen;
+}
+
+
+void POP3FolderStatus::setMessageCount(const unsigned int count)
+{
+ m_count = count;
+}
+
+
+void POP3FolderStatus::setUnseenCount(const unsigned int unseen)
+{
+ m_unseen = unseen;
+}
+
+
+} // pop3
+} // net
+} // vmime
+
+
+#endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_POP3
diff --git a/src/net/pop3/POP3Message.cpp b/src/net/pop3/POP3Message.cpp
index d2bb9881..659e3d79 100644
--- a/src/net/pop3/POP3Message.cpp
+++ b/src/net/pop3/POP3Message.cpp
@@ -72,7 +72,7 @@ int POP3Message::getNumber() const
}
-const message::uid POP3Message::getUniqueId() const
+const message::uid POP3Message::getUID() const
{
return (m_uid);
}