From f9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Thu, 21 Nov 2013 22:16:57 +0100 Subject: Boost/C++11 shared pointers. --- src/net/imap/IMAPStore.cpp | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) (limited to 'src/net/imap/IMAPStore.cpp') diff --git a/src/net/imap/IMAPStore.cpp b/src/net/imap/IMAPStore.cpp index eca58ea7..a1a8c9ca 100644 --- a/src/net/imap/IMAPStore.cpp +++ b/src/net/imap/IMAPStore.cpp @@ -43,8 +43,8 @@ namespace net { namespace imap { -IMAPStore::IMAPStore(ref sess, ref auth, const bool secured) - : store(sess, getInfosInstance(), auth), m_connection(NULL), m_isIMAPS(secured) +IMAPStore::IMAPStore(shared_ptr sess, shared_ptr auth, const bool secured) + : store(sess, getInfosInstance(), auth), m_connection(null), m_isIMAPS(secured) { } @@ -69,32 +69,35 @@ const string IMAPStore::getProtocolName() const } -ref IMAPStore::getRootFolder() +shared_ptr IMAPStore::getRootFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); - return vmime::create (folder::path(), - thisRef().dynamicCast ()); + return make_shared + (folder::path(), + dynamicCast (shared_from_this())); } -ref IMAPStore::getDefaultFolder() +shared_ptr IMAPStore::getDefaultFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); - return vmime::create (folder::path::component("INBOX"), - thisRef().dynamicCast ()); + return make_shared + (folder::path::component("INBOX"), + dynamicCast (shared_from_this())); } -ref IMAPStore::getFolder(const folder::path& path) +shared_ptr IMAPStore::getFolder(const folder::path& path) { if (!isConnected()) throw exceptions::illegal_state("Not connected"); - return vmime::create (path, thisRef().dynamicCast ()); + return make_shared + (path, dynamicCast (shared_from_this())); } @@ -109,8 +112,8 @@ void IMAPStore::connect() if (isConnected()) throw exceptions::already_connected(); - m_connection = vmime::create - (thisRef().dynamicCast (), getAuthenticator()); + m_connection = make_shared + (dynamicCast (shared_from_this()), getAuthenticator()); try { @@ -118,7 +121,7 @@ void IMAPStore::connect() } catch (std::exception&) { - m_connection = NULL; + m_connection = null; throw; } } @@ -145,16 +148,16 @@ bool IMAPStore::isSecuredConnection() const } -ref IMAPStore::getConnectionInfos() const +shared_ptr IMAPStore::getConnectionInfos() const { if (m_connection == NULL) - return NULL; + return null; return m_connection->getConnectionInfos(); } -ref IMAPStore::getConnection() +shared_ptr IMAPStore::getConnection() { return m_connection; } @@ -176,7 +179,7 @@ void IMAPStore::disconnect() m_connection->disconnect(); - m_connection = NULL; + m_connection = null; } @@ -187,7 +190,7 @@ void IMAPStore::noop() m_connection->send(true, "NOOP", true); - utility::auto_ptr resp(m_connection->readResponse()); + std::auto_ptr resp(m_connection->readResponse()); if (resp->isBad() || resp->response_done()->response_tagged()-> resp_cond_state()->status() != IMAPParser::resp_cond_state::OK) @@ -205,7 +208,7 @@ void IMAPStore::noop() } -ref IMAPStore::connection() +shared_ptr IMAPStore::connection() { return (m_connection); } -- cgit v1.2.3