From 1539754d5357df5eed7a88cc3f2955c87af9faae Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Sun, 29 Jan 2006 17:36:34 +0000 Subject: Added service::isSecuredConnection() and service::getConnectionInfos() to retrieve information about the connection. --- src/net/pop3/POP3Store.cpp | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'src/net/pop3/POP3Store.cpp') diff --git a/src/net/pop3/POP3Store.cpp b/src/net/pop3/POP3Store.cpp index 29a22dcf..5340e50d 100644 --- a/src/net/pop3/POP3Store.cpp +++ b/src/net/pop3/POP3Store.cpp @@ -27,12 +27,15 @@ #include "vmime/utility/filteredStream.hpp" #include "vmime/utility/stringUtils.hpp" +#include "vmime/net/defaultConnectionInfos.hpp" + #if VMIME_HAVE_SASL_SUPPORT #include "vmime/security/sasl/SASLContext.hpp" #endif // VMIME_HAVE_SASL_SUPPORT #if VMIME_HAVE_TLS_SUPPORT #include "vmime/net/tls/TLSSession.hpp" + #include "vmime/net/tls/TLSSecuredConnectionInfos.hpp" #endif // VMIME_HAVE_TLS_SUPPORT #include @@ -54,7 +57,8 @@ namespace pop3 { POP3Store::POP3Store(ref sess, ref auth, const bool secured) : store(sess, getInfosInstance(), auth), m_socket(NULL), - m_authentified(false), m_timeoutHandler(NULL), m_secured(secured) + m_authentified(false), m_timeoutHandler(NULL), + m_isPOP3S(secured), m_secured(false) { } @@ -130,7 +134,7 @@ void POP3Store::connect() m_socket = getSocketFactory()->create(); #if VMIME_HAVE_TLS_SUPPORT - if (m_secured) // dedicated port/POP3S + if (m_isPOP3S) // dedicated port/POP3S { ref tlsSession = vmime::create (getCertificateVerifier()); @@ -139,8 +143,15 @@ void POP3Store::connect() tlsSession->getSocket(m_socket); m_socket = tlsSocket; + + m_secured = true; + m_cntInfos = vmime::create (address, port, tlsSession, tlsSocket); } #endif // VMIME_HAVE_TLS_SUPPORT + else + { + m_cntInfos = vmime::create (address, port); + } m_socket->connect(address, port); @@ -165,7 +176,7 @@ void POP3Store::connect() const bool tlsRequired = HAS_PROPERTY(PROPERTY_CONNECTION_TLS_REQUIRED) && GET_PROPERTY(bool, PROPERTY_CONNECTION_TLS_REQUIRED); - if (!m_secured && tls) // only if not POP3S + if (!m_isPOP3S && tls) // only if not POP3S { try { @@ -533,6 +544,10 @@ void POP3Store::startTLS() tlsSocket->handshake(m_timeoutHandler); m_socket = tlsSocket; + + m_secured = true; + m_cntInfos = vmime::create + (m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket); } catch (exceptions::command_error&) { @@ -556,6 +571,18 @@ const bool POP3Store::isConnected() const } +const bool POP3Store::isSecuredConnection() const +{ + return m_secured; +} + + +ref POP3Store::getConnectionInfos() const +{ + return m_cntInfos; +} + + void POP3Store::disconnect() { if (!isConnected()) @@ -590,6 +617,9 @@ void POP3Store::internalDisconnect() m_timeoutHandler = NULL; m_authentified = false; + + m_secured = false; + m_cntInfos = NULL; } -- cgit v1.2.3