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/imap/IMAPConnection.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/net/imap/IMAPConnection.cpp') diff --git a/src/net/imap/IMAPConnection.cpp b/src/net/imap/IMAPConnection.cpp index 76c09316..e4a49041 100644 --- a/src/net/imap/IMAPConnection.cpp +++ b/src/net/imap/IMAPConnection.cpp @@ -25,12 +25,15 @@ #include "vmime/exception.hpp" #include "vmime/platformDependant.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 @@ -52,7 +55,8 @@ namespace imap { IMAPConnection::IMAPConnection(weak_ref store, ref auth) : m_store(store), m_auth(auth), m_socket(NULL), m_parser(NULL), m_tag(NULL), - m_hierarchySeparator('\0'), m_state(STATE_NONE), m_timeoutHandler(NULL) + m_hierarchySeparator('\0'), m_state(STATE_NONE), m_timeoutHandler(NULL), + m_secured(false) { } @@ -92,7 +96,7 @@ void IMAPConnection::connect() m_socket = m_store->getSocketFactory()->create(); #if VMIME_HAVE_TLS_SUPPORT - if (m_store->isSecuredConnection()) // dedicated port/IMAPS + if (m_store->isIMAPS()) // dedicated port/IMAPS { ref tlsSession = vmime::create (m_store->getCertificateVerifier()); @@ -101,8 +105,15 @@ void IMAPConnection::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); @@ -446,6 +457,10 @@ void IMAPConnection::startTLS() m_socket = tlsSocket; m_parser->setSocket(m_socket); + + m_secured = true; + m_cntInfos = vmime::create + (m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket); } catch (exceptions::command_error&) { @@ -517,6 +532,18 @@ const bool IMAPConnection::isConnected() const } +const bool IMAPConnection::isSecuredConnection() const +{ + return m_secured; +} + + +ref IMAPConnection::getConnectionInfos() const +{ + return m_cntInfos; +} + + void IMAPConnection::disconnect() { if (!isConnected()) @@ -539,6 +566,9 @@ void IMAPConnection::internalDisconnect() m_timeoutHandler = NULL; m_state = STATE_LOGOUT; + + m_secured = false; + m_cntInfos = NULL; } -- cgit v1.2.3