aboutsummaryrefslogtreecommitdiffstats
path: root/vmime
diff options
context:
space:
mode:
Diffstat (limited to 'vmime')
-rw-r--r--vmime/net/pop3/POP3Command.hpp13
-rw-r--r--vmime/net/pop3/POP3Connection.hpp122
-rw-r--r--vmime/net/pop3/POP3Response.hpp27
-rw-r--r--vmime/net/pop3/POP3Store.hpp32
4 files changed, 144 insertions, 50 deletions
diff --git a/vmime/net/pop3/POP3Command.hpp b/vmime/net/pop3/POP3Command.hpp
index 68731661..ef2b3ac4 100644
--- a/vmime/net/pop3/POP3Command.hpp
+++ b/vmime/net/pop3/POP3Command.hpp
@@ -42,13 +42,10 @@ class mailbox;
namespace net {
+namespace pop3 {
-class socket;
-class timeoutHandler;
-
-
-namespace pop3 {
+class POP3Connection;
/** A POP3 command that will be sent to the server.
@@ -84,11 +81,11 @@ public:
*/
static ref <POP3Command> createCommand(const string& text);
- /** Sends this command to the specified socket.
+ /** Sends this command over the specified connection.
*
- * @param sok socket to which the command will be written
+ * @param conn connection onto which the command will be sent
*/
- virtual void writeToSocket(ref <socket> sok);
+ virtual void send(ref <POP3Connection> conn);
/** Returns the full text of the command, including command name
* and parameters (if any).
diff --git a/vmime/net/pop3/POP3Connection.hpp b/vmime/net/pop3/POP3Connection.hpp
new file mode 100644
index 00000000..8a900cb2
--- /dev/null
+++ b/vmime/net/pop3/POP3Connection.hpp
@@ -0,0 +1,122 @@
+//
+// 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.
+//
+
+#ifndef VMIME_NET_POP3_POP3CONNECTION_HPP_INCLUDED
+#define VMIME_NET_POP3_POP3CONNECTION_HPP_INCLUDED
+
+
+#include "vmime/config.hpp"
+
+
+#if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_POP3
+
+
+#include "vmime/messageId.hpp"
+
+#include "vmime/net/socket.hpp"
+#include "vmime/net/timeoutHandler.hpp"
+#include "vmime/net/session.hpp"
+#include "vmime/net/connectionInfos.hpp"
+
+#include "vmime/net/pop3/POP3Command.hpp"
+#include "vmime/net/pop3/POP3Response.hpp"
+
+#include "vmime/security/authenticator.hpp"
+
+
+namespace vmime {
+namespace net {
+
+
+class socket;
+class timeoutHandler;
+
+
+namespace pop3 {
+
+
+class POP3Store;
+
+
+/** Manage connection to a POP3 server.
+ */
+class VMIME_EXPORT POP3Connection : public object
+{
+ friend class vmime::creator;
+
+public:
+
+ POP3Connection(ref <POP3Store> store, ref <security::authenticator> auth);
+ virtual ~POP3Connection();
+
+
+ virtual void connect();
+ virtual bool isConnected() const;
+ virtual void disconnect();
+
+ bool isSecuredConnection() const;
+ ref <connectionInfos> getConnectionInfos() const;
+
+ virtual ref <POP3Store> getStore();
+ virtual ref <socket> getSocket();
+ virtual ref <timeoutHandler> getTimeoutHandler();
+ virtual ref <security::authenticator> getAuthenticator();
+ virtual ref <session> getSession();
+
+private:
+
+ void authenticate(const messageId& randomMID);
+#if VMIME_HAVE_SASL_SUPPORT
+ void authenticateSASL();
+#endif // VMIME_HAVE_SASL_SUPPORT
+
+#if VMIME_HAVE_TLS_SUPPORT
+ void startTLS();
+#endif // VMIME_HAVE_TLS_SUPPORT
+
+ const std::vector <string> getCapabilities();
+
+ void internalDisconnect();
+
+
+ weak_ref <POP3Store> m_store;
+
+ ref <security::authenticator> m_auth;
+ ref <socket> m_socket;
+ ref <timeoutHandler> m_timeoutHandler;
+
+ bool m_authenticated;
+ bool m_secured;
+
+ ref <connectionInfos> m_cntInfos;
+};
+
+
+} // pop3
+} // net
+} // vmime
+
+
+#endif // VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_POP3
+
+#endif // VMIME_NET_POP3_POP3CONNECTION_HPP_INCLUDED
diff --git a/vmime/net/pop3/POP3Response.hpp b/vmime/net/pop3/POP3Response.hpp
index c2997a27..efe72d05 100644
--- a/vmime/net/pop3/POP3Response.hpp
+++ b/vmime/net/pop3/POP3Response.hpp
@@ -50,6 +50,9 @@ class timeoutHandler;
namespace pop3 {
+class POP3Connection;
+
+
/** A POP3 response, as sent by the server.
*/
class VMIME_EXPORT POP3Response : public object
@@ -68,34 +71,29 @@ public:
/** Receive and parse a POP3 response from the
- * specified socket.
+ * specified connection.
*
- * @param sok socket from which to read
- * @param toh time-out handler (can be NULL)
+ * @param conn connection from which to read
* @return POP3 response
* @throws exceptions::operation_timed_out if no data
* has been received within the granted time
*/
- static ref <POP3Response> readResponse
- (ref <socket> sok, ref <timeoutHandler> toh);
+ static ref <POP3Response> readResponse(ref <POP3Connection> conn);
/** Receive and parse a multiline POP3 response from
- * the specified socket.
+ * the specified connection.
*
- * @param sok socket from which to read
- * @param toh time-out handler (can be NULL)
+ * @param conn connection from which to read
* @return POP3 response
* @throws exceptions::operation_timed_out if no data
* has been received within the granted time
*/
- static ref <POP3Response> readMultilineResponse
- (ref <socket> sok, ref <timeoutHandler> toh);
+ static ref <POP3Response> readMultilineResponse(ref <POP3Connection> conn);
/** Receive and parse a large POP3 response (eg. message data)
- * from the specified socket.
+ * from the specified connection.
*
- * @param sok socket from which to read
- * @param toh time-out handler (can be NULL)
+ * @param conn connection from which to read
* @param os output stream to which response data will be written
* @param progress progress listener (can be NULL)
* @param predictedSize estimated size of response data (in bytes)
@@ -104,8 +102,7 @@ public:
* has been received within the granted time
*/
static ref <POP3Response> readLargeResponse
- (ref <socket> sok, ref <timeoutHandler> toh,
- utility::outputStream& os,
+ (ref <POP3Connection> conn, utility::outputStream& os,
utility::progressListener* progress, const long predictedSize);
diff --git a/vmime/net/pop3/POP3Store.hpp b/vmime/net/pop3/POP3Store.hpp
index 681a295e..17dfdbb0 100644
--- a/vmime/net/pop3/POP3Store.hpp
+++ b/vmime/net/pop3/POP3Store.hpp
@@ -31,13 +31,10 @@
#if VMIME_HAVE_MESSAGING_FEATURES && VMIME_HAVE_MESSAGING_PROTO_POP3
-#include "vmime/messageId.hpp"
-
#include "vmime/net/store.hpp"
-#include "vmime/net/socket.hpp"
-#include "vmime/net/timeoutHandler.hpp"
#include "vmime/net/pop3/POP3ServiceInfos.hpp"
+#include "vmime/net/pop3/POP3Connection.hpp"
#include "vmime/utility/stream.hpp"
@@ -86,24 +83,13 @@ public:
bool isSecuredConnection() const;
ref <connectionInfos> getConnectionInfos() const;
+ ref <POP3Connection> getConnection();
-private:
-
- void authenticate(const messageId& randomMID);
-#if VMIME_HAVE_SASL_SUPPORT
- void authenticateSASL();
-#endif // VMIME_HAVE_SASL_SUPPORT
-
-#if VMIME_HAVE_TLS_SUPPORT
- void startTLS();
-#endif // VMIME_HAVE_TLS_SUPPORT
-
- const std::vector <string> getCapabilities();
+ bool isPOP3S() const;
- void sendRequest(ref <POP3Command> cmd);
- ref <POP3Response> readResponse();
+private:
- void internalDisconnect();
+ ref <POP3Connection> m_connection;
void registerFolder(POP3Folder* folder);
@@ -112,16 +98,8 @@ private:
std::list <POP3Folder*> m_folders;
- ref <socket> m_socket;
- bool m_authentified;
-
- ref <timeoutHandler> m_timeoutHandler;
-
const bool m_isPOP3S;
- bool m_secured;
- ref <connectionInfos> m_cntInfos;
-
// Service infos
static POP3ServiceInfos sm_infos;