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/pop3/POP3Command.cpp | 40 ++++++------ src/net/pop3/POP3Connection.cpp | 104 ++++++++++++++--------------- src/net/pop3/POP3Folder.cpp | 134 +++++++++++++++++++------------------- src/net/pop3/POP3FolderStatus.cpp | 4 +- src/net/pop3/POP3Message.cpp | 32 ++++----- src/net/pop3/POP3Response.cpp | 22 +++---- src/net/pop3/POP3SStore.cpp | 2 +- src/net/pop3/POP3Store.cpp | 37 ++++++----- src/net/pop3/POP3Utils.cpp | 2 +- 9 files changed, 189 insertions(+), 188 deletions(-) (limited to 'src/net/pop3') diff --git a/src/net/pop3/POP3Command.cpp b/src/net/pop3/POP3Command.cpp index 6c178891..6fe301ce 100644 --- a/src/net/pop3/POP3Command.cpp +++ b/src/net/pop3/POP3Command.cpp @@ -49,21 +49,21 @@ POP3Command::POP3Command(const string& text) // static -ref POP3Command::CAPA() +shared_ptr POP3Command::CAPA() { return createCommand("CAPA"); } // static -ref POP3Command::NOOP() +shared_ptr POP3Command::NOOP() { return createCommand("NOOP"); } // static -ref POP3Command::AUTH(const string& mechName) +shared_ptr POP3Command::AUTH(const string& mechName) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -74,14 +74,14 @@ ref POP3Command::AUTH(const string& mechName) // static -ref POP3Command::STLS() +shared_ptr POP3Command::STLS() { return createCommand("STLS"); } // static -ref POP3Command::APOP(const string& username, const string& digest) +shared_ptr POP3Command::APOP(const string& username, const string& digest) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -92,7 +92,7 @@ ref POP3Command::APOP(const string& username, const string& digest // static -ref POP3Command::USER(const string& username) +shared_ptr POP3Command::USER(const string& username) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -103,7 +103,7 @@ ref POP3Command::USER(const string& username) // static -ref POP3Command::PASS(const string& password) +shared_ptr POP3Command::PASS(const string& password) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -114,21 +114,21 @@ ref POP3Command::PASS(const string& password) // static -ref POP3Command::STAT() +shared_ptr POP3Command::STAT() { return createCommand("STAT"); } // static -ref POP3Command::LIST() +shared_ptr POP3Command::LIST() { return createCommand("LIST"); } // static -ref POP3Command::LIST(const unsigned long msg) +shared_ptr POP3Command::LIST(const unsigned long msg) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -139,14 +139,14 @@ ref POP3Command::LIST(const unsigned long msg) // static -ref POP3Command::UIDL() +shared_ptr POP3Command::UIDL() { return createCommand("UIDL"); } // static -ref POP3Command::UIDL(const unsigned long msg) +shared_ptr POP3Command::UIDL(const unsigned long msg) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -157,7 +157,7 @@ ref POP3Command::UIDL(const unsigned long msg) // static -ref POP3Command::DELE(const unsigned long msg) +shared_ptr POP3Command::DELE(const unsigned long msg) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -168,7 +168,7 @@ ref POP3Command::DELE(const unsigned long msg) // static -ref POP3Command::RETR(const unsigned long msg) +shared_ptr POP3Command::RETR(const unsigned long msg) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -179,7 +179,7 @@ ref POP3Command::RETR(const unsigned long msg) // static -ref POP3Command::TOP(const unsigned long msg, const unsigned long lines) +shared_ptr POP3Command::TOP(const unsigned long msg, const unsigned long lines) { std::ostringstream cmd; cmd.imbue(std::locale::classic()); @@ -190,23 +190,23 @@ ref POP3Command::TOP(const unsigned long msg, const unsigned long // static -ref POP3Command::RSET() +shared_ptr POP3Command::RSET() { return createCommand("RSET"); } // static -ref POP3Command::QUIT() +shared_ptr POP3Command::QUIT() { return createCommand("QUIT"); } // static -ref POP3Command::createCommand(const string& text) +shared_ptr POP3Command::createCommand(const string& text) { - return vmime::create (text); + return shared_ptr (new POP3Command(text)); } @@ -216,7 +216,7 @@ const string POP3Command::getText() const } -void POP3Command::send(ref conn) +void POP3Command::send(shared_ptr conn) { conn->getSocket()->send(m_text + "\r\n"); } diff --git a/src/net/pop3/POP3Connection.cpp b/src/net/pop3/POP3Connection.cpp index dd0024e9..547ef5ef 100644 --- a/src/net/pop3/POP3Connection.cpp +++ b/src/net/pop3/POP3Connection.cpp @@ -50,11 +50,11 @@ // Helpers for service properties #define GET_PROPERTY(type, prop) \ - (m_store.acquire()->getInfos().getPropertyValue (getSession(), \ - dynamic_cast (m_store.acquire()->getInfos()).getProperties().prop)) + (m_store.lock()->getInfos().getPropertyValue (getSession(), \ + dynamic_cast (m_store.lock()->getInfos()).getProperties().prop)) #define HAS_PROPERTY(prop) \ - (m_store.acquire()->getInfos().hasProperty(getSession(), \ - dynamic_cast (m_store.acquire()->getInfos()).getProperties().prop)) + (m_store.lock()->getInfos().hasProperty(getSession(), \ + dynamic_cast (m_store.lock()->getInfos()).getProperties().prop)) namespace vmime { @@ -63,8 +63,8 @@ namespace pop3 { -POP3Connection::POP3Connection(ref store, ref auth) - : m_store(store), m_auth(auth), m_socket(NULL), m_timeoutHandler(NULL), +POP3Connection::POP3Connection(shared_ptr store, shared_ptr auth) + : m_store(store), m_auth(auth), m_socket(null), m_timeoutHandler(null), m_authenticated(false), m_secured(false), m_capabilitiesFetched(false) { } @@ -94,7 +94,7 @@ void POP3Connection::connect() const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS); const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT); - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); // Create the time-out handler if (store->getTimeoutHandlerFactory()) @@ -106,22 +106,22 @@ void POP3Connection::connect() #if VMIME_HAVE_TLS_SUPPORT if (store->isPOP3S()) // dedicated port/POP3S { - ref tlsSession = tls::TLSSession::create + shared_ptr tlsSession = tls::TLSSession::create (store->getCertificateVerifier(), store->getSession()->getTLSProperties()); - ref tlsSocket = + shared_ptr tlsSocket = tlsSession->getSocket(m_socket); m_socket = tlsSocket; m_secured = true; - m_cntInfos = vmime::create (address, port, tlsSession, tlsSocket); + m_cntInfos = make_shared (address, port, tlsSession, tlsSocket); } else #endif // VMIME_HAVE_TLS_SUPPORT { - m_cntInfos = vmime::create (address, port); + m_cntInfos = make_shared (address, port); } m_socket->connect(address, port); @@ -131,8 +131,8 @@ void POP3Connection::connect() // eg: C: // --- S: +OK MailSite POP3 Server 5.3.4.0 Ready <36938848.1056800841.634@somewhere.com> - ref response = POP3Response::readResponse - (thisRef().dynamicCast ()); + shared_ptr response = POP3Response::readResponse + (dynamicCast (shared_from_this())); if (!response->isSuccess()) { @@ -195,8 +195,8 @@ void POP3Connection::internalDisconnect() { try { - POP3Command::QUIT()->send(thisRef().dynamicCast ()); - POP3Response::readResponse(thisRef().dynamicCast ()); + POP3Command::QUIT()->send(dynamicCast (shared_from_this())); + POP3Response::readResponse(dynamicCast (shared_from_this())); } catch (exception&) { @@ -206,21 +206,21 @@ void POP3Connection::internalDisconnect() m_socket->disconnect(); } - m_socket = NULL; + m_socket = null; } - m_timeoutHandler = NULL; + m_timeoutHandler = null; m_authenticated = false; m_secured = false; - m_cntInfos = NULL; + m_cntInfos = null; } void POP3Connection::authenticate(const messageId& randomMID) { - getAuthenticator()->setService(m_store.acquire()); + getAuthenticator()->setService(m_store.lock()); #if VMIME_HAVE_SASL_SUPPORT // First, try SASL authentication @@ -262,8 +262,8 @@ void POP3Connection::authenticate(const messageId& randomMID) const string username = getAuthenticator()->getUsername(); const string password = getAuthenticator()->getPassword(); - ref conn = thisRef().dynamicCast (); - ref response; + shared_ptr conn = dynamicCast (shared_from_this()); + shared_ptr response; if (GET_PROPERTY(bool, PROPERTY_OPTIONS_APOP)) { @@ -271,7 +271,7 @@ void POP3Connection::authenticate(const messageId& randomMID) randomMID.getRight().length() != 0) { // is the result of MD5 applied to "password" - ref md5 = + shared_ptr md5 = security::digest::messageDigestFactory::getInstance()->create("md5"); md5->update(randomMID.generate() + password); @@ -361,7 +361,7 @@ void POP3Connection::authenticate(const messageId& randomMID) void POP3Connection::authenticateSASL() { - if (!getAuthenticator().dynamicCast ()) + if (!dynamicCast (getAuthenticator())) throw exceptions::authentication_error("No SASL authenticator available."); std::vector capa = getCapabilities(); @@ -401,10 +401,10 @@ void POP3Connection::authenticateSASL() if (saslMechs.empty()) throw exceptions::authentication_error("No SASL mechanism available."); - std::vector > mechList; + std::vector > mechList; - ref saslContext = - vmime::create (); + shared_ptr saslContext = + make_shared (); for (unsigned int i = 0 ; i < saslMechs.size() ; ++i) { @@ -423,14 +423,14 @@ void POP3Connection::authenticateSASL() throw exceptions::authentication_error("No SASL mechanism available."); // Try to suggest a mechanism among all those supported - ref suggestedMech = + shared_ptr suggestedMech = saslContext->suggestMechanism(mechList); if (!suggestedMech) throw exceptions::authentication_error("Unable to suggest SASL mechanism."); // Allow application to choose which mechanisms to use - mechList = getAuthenticator().dynamicCast ()-> + mechList = dynamicCast (getAuthenticator())-> getAcceptableMechanisms(mechList, suggestedMech); if (mechList.empty()) @@ -439,19 +439,19 @@ void POP3Connection::authenticateSASL() // Try each mechanism in the list in turn for (unsigned int i = 0 ; i < mechList.size() ; ++i) { - ref mech = mechList[i]; + shared_ptr mech = mechList[i]; - ref saslSession = + shared_ptr saslSession = saslContext->createSession("pop3", getAuthenticator(), mech); saslSession->init(); - POP3Command::AUTH(mech->getName())->send(thisRef().dynamicCast ()); + POP3Command::AUTH(mech->getName())->send(dynamicCast (shared_from_this())); for (bool cont = true ; cont ; ) { - ref response = - POP3Response::readResponse(thisRef().dynamicCast ()); + shared_ptr response = + POP3Response::readResponse(dynamicCast (shared_from_this())); switch (response->getCode()) { @@ -537,19 +537,19 @@ void POP3Connection::startTLS() { try { - POP3Command::STLS()->send(thisRef().dynamicCast ()); + POP3Command::STLS()->send(dynamicCast (shared_from_this())); - ref response = - POP3Response::readResponse(thisRef().dynamicCast ()); + shared_ptr response = + POP3Response::readResponse(dynamicCast (shared_from_this())); if (!response->isSuccess()) throw exceptions::command_error("STLS", response->getFirstLine()); - ref tlsSession = tls::TLSSession::create - (m_store.acquire()->getCertificateVerifier(), - m_store.acquire()->getSession()->getTLSProperties()); + shared_ptr tlsSession = tls::TLSSession::create + (m_store.lock()->getCertificateVerifier(), + m_store.lock()->getSession()->getTLSProperties()); - ref tlsSocket = + shared_ptr tlsSocket = tlsSession->getSocket(m_socket); tlsSocket->handshake(m_timeoutHandler); @@ -557,7 +557,7 @@ void POP3Connection::startTLS() m_socket = tlsSocket; m_secured = true; - m_cntInfos = vmime::create + m_cntInfos = make_shared (m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket); // " Once TLS has been started, the client MUST discard cached @@ -601,10 +601,10 @@ void POP3Connection::invalidateCapabilities() void POP3Connection::fetchCapabilities() { - POP3Command::CAPA()->send(thisRef().dynamicCast ()); + POP3Command::CAPA()->send(dynamicCast (shared_from_this())); - ref response = - POP3Response::readMultilineResponse(thisRef().dynamicCast ()); + shared_ptr response = + POP3Response::readMultilineResponse(dynamicCast (shared_from_this())); std::vector res; @@ -631,37 +631,37 @@ bool POP3Connection::isSecuredConnection() const } -ref POP3Connection::getConnectionInfos() const +shared_ptr POP3Connection::getConnectionInfos() const { return m_cntInfos; } -ref POP3Connection::getStore() +shared_ptr POP3Connection::getStore() { - return m_store.acquire(); + return m_store.lock(); } -ref POP3Connection::getSession() +shared_ptr POP3Connection::getSession() { - return m_store.acquire()->getSession(); + return m_store.lock()->getSession(); } -ref POP3Connection::getSocket() +shared_ptr POP3Connection::getSocket() { return m_socket; } -ref POP3Connection::getTimeoutHandler() +shared_ptr POP3Connection::getTimeoutHandler() { return m_timeoutHandler; } -ref POP3Connection::getAuthenticator() +shared_ptr POP3Connection::getAuthenticator() { return m_auth; } diff --git a/src/net/pop3/POP3Folder.cpp b/src/net/pop3/POP3Folder.cpp index ffff121e..66ace31c 100644 --- a/src/net/pop3/POP3Folder.cpp +++ b/src/net/pop3/POP3Folder.cpp @@ -45,7 +45,7 @@ namespace net { namespace pop3 { -POP3Folder::POP3Folder(const folder::path& path, ref store) +POP3Folder::POP3Folder(const folder::path& path, shared_ptr store) : m_store(store), m_path(path), m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()), m_mode(-1), m_open(false) @@ -56,7 +56,7 @@ POP3Folder::POP3Folder(const folder::path& path, ref store) POP3Folder::~POP3Folder() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (store) { @@ -115,7 +115,7 @@ const folder::path POP3Folder::getFullPath() const void POP3Folder::open(const int mode, bool failIfModeIsNotAvailable) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -134,7 +134,7 @@ void POP3Folder::open(const int mode, bool failIfModeIsNotAvailable) { POP3Command::STAT()->send(store->getConnection()); - ref response = POP3Response::readResponse(store->getConnection()); + shared_ptr response = POP3Response::readResponse(store->getConnection()); if (!response->isSuccess()) throw exceptions::command_error("STAT", response->getFirstLine()); @@ -156,7 +156,7 @@ void POP3Folder::open(const int mode, bool failIfModeIsNotAvailable) void POP3Folder::close(const bool expunge) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -200,7 +200,7 @@ void POP3Folder::destroy() bool POP3Folder::exists() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -215,9 +215,9 @@ bool POP3Folder::isOpen() const } -ref POP3Folder::getMessage(const int num) +shared_ptr POP3Folder::getMessage(const int num) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -226,13 +226,13 @@ ref POP3Folder::getMessage(const int num) else if (num < 1 || num > m_messageCount) throw exceptions::message_not_found(); - return vmime::create (thisRef().dynamicCast (), num); + return make_shared (dynamicCast (shared_from_this()), num); } -std::vector > POP3Folder::getMessages(const messageSet& msgs) +std::vector > POP3Folder::getMessages(const messageSet& msgs) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -243,15 +243,15 @@ std::vector > POP3Folder::getMessages(const messageSet& msgs) { const std::vector numbers = POP3Utils::messageSetToNumberList(msgs); - std::vector > messages; - ref thisFolder = thisRef().dynamicCast (); + std::vector > messages; + shared_ptr thisFolder(dynamicCast (shared_from_this())); for (std::vector ::const_iterator it = numbers.begin() ; it != numbers.end() ; ++it) { if (*it < 1|| *it > m_messageCount) throw exceptions::message_not_found(); - messages.push_back(vmime::create (thisFolder, *it)); + messages.push_back(make_shared (thisFolder, *it)); } return messages; @@ -265,7 +265,7 @@ std::vector > POP3Folder::getMessages(const messageSet& msgs) int POP3Folder::getMessageCount() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -276,42 +276,42 @@ int POP3Folder::getMessageCount() } -ref POP3Folder::getFolder(const folder::path::component& name) +shared_ptr POP3Folder::getFolder(const folder::path::component& name) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); - return vmime::create (m_path / name, store); + return make_shared (m_path / name, store); } -std::vector > POP3Folder::getFolders(const bool /* recursive */) +std::vector > POP3Folder::getFolders(const bool /* recursive */) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); if (m_path.isEmpty()) { - std::vector > v; - v.push_back(vmime::create (folder::path::component("INBOX"), store)); + std::vector > v; + v.push_back(make_shared (folder::path::component("INBOX"), store)); return (v); } else { - std::vector > v; + std::vector > v; return (v); } } -void POP3Folder::fetchMessages(std::vector >& msg, const fetchAttributes& options, +void POP3Folder::fetchMessages(std::vector >& msg, const fetchAttributes& options, utility::progressListener* progress) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); @@ -324,11 +324,11 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt if (progress) progress->start(total); - for (std::vector >::iterator it = msg.begin() ; + for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { - (*it).dynamicCast ()->fetch - (thisRef().dynamicCast (), options); + dynamicCast (*it)->fetch + (dynamicCast (shared_from_this()), options); if (progress) progress->progress(++current, total); @@ -340,7 +340,7 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt POP3Command::LIST()->send(store->getConnection()); // Get the response - ref response = + shared_ptr response = POP3Response::readMultilineResponse(store->getConnection()); if (response->isSuccess()) @@ -353,10 +353,10 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt std::map result; POP3Utils::parseMultiListOrUidlResponse(response, result); - for (std::vector >::iterator it = msg.begin() ; + for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { - ref m = (*it).dynamicCast (); + shared_ptr m = dynamicCast (*it); std::map ::const_iterator x = result.find(m->m_num); @@ -380,7 +380,7 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt POP3Command::UIDL()->send(store->getConnection()); // Get the response - ref response = + shared_ptr response = POP3Response::readMultilineResponse(store->getConnection()); if (response->isSuccess()) @@ -393,10 +393,10 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt std::map result; POP3Utils::parseMultiListOrUidlResponse(response, result); - for (std::vector >::iterator it = msg.begin() ; + for (std::vector >::iterator it = msg.begin() ; it != msg.end() ; ++it) { - ref m = (*it).dynamicCast (); + shared_ptr m = dynamicCast (*it); std::map ::const_iterator x = result.find(m->m_num); @@ -411,17 +411,17 @@ void POP3Folder::fetchMessages(std::vector >& msg, const fetchAtt } -void POP3Folder::fetchMessage(ref msg, const fetchAttributes& options) +void POP3Folder::fetchMessage(shared_ptr msg, const fetchAttributes& options) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); else if (!isOpen()) throw exceptions::illegal_state("Folder not open"); - msg.dynamicCast ()->fetch - (thisRef().dynamicCast (), options); + dynamicCast (msg)->fetch + (dynamicCast (shared_from_this()), options); if (options.has(fetchAttributes::SIZE)) { @@ -429,7 +429,7 @@ void POP3Folder::fetchMessage(ref msg, const fetchAttributes& options) POP3Command::LIST(msg->getNumber())->send(store->getConnection()); // Get the response - ref response = + shared_ptr response = POP3Response::readResponse(store->getConnection()); if (response->isSuccess()) @@ -451,7 +451,7 @@ void POP3Folder::fetchMessage(ref msg, const fetchAttributes& options) std::istringstream iss(string(it, responseText.end())); iss >> size; - msg.dynamicCast ()->m_size = size; + dynamicCast (msg)->m_size = size; } } } @@ -462,7 +462,7 @@ void POP3Folder::fetchMessage(ref msg, const fetchAttributes& options) POP3Command::UIDL(msg->getNumber())->send(store->getConnection()); // Get the response - ref response = + shared_ptr response = POP3Response::readResponse(store->getConnection()); if (response->isSuccess()) @@ -479,7 +479,7 @@ void POP3Folder::fetchMessage(ref msg, const fetchAttributes& options) if (it != responseText.end()) { - msg.dynamicCast ()->m_uid = + dynamicCast (msg)->m_uid = string(it, responseText.end()); } } @@ -495,24 +495,24 @@ int POP3Folder::getFetchCapabilities() const } -ref POP3Folder::getParent() +shared_ptr POP3Folder::getParent() { if (m_path.isEmpty()) - return NULL; + return null; else - return vmime::create (m_path.getParent(), m_store.acquire()); + return make_shared (m_path.getParent(), m_store.lock()); } -ref POP3Folder::getStore() const +shared_ptr POP3Folder::getStore() const { - return m_store.acquire(); + return m_store.lock(); } -ref POP3Folder::getStore() +shared_ptr POP3Folder::getStore() { - return m_store.acquire(); + return m_store.lock(); } @@ -530,13 +530,13 @@ void POP3Folder::unregisterMessage(POP3Message* msg) void POP3Folder::onStoreDisconnected() { - m_store = NULL; + m_store.reset(); } void POP3Folder::deleteMessages(const messageSet& msgs) { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); const std::vector nums = POP3Utils::messageSetToNumberList(msgs); @@ -553,7 +553,7 @@ void POP3Folder::deleteMessages(const messageSet& msgs) { POP3Command::DELE(*it)->send(store->getConnection()); - ref response = + shared_ptr response = POP3Response::readResponse(store->getConnection()); if (!response->isSuccess()) @@ -579,9 +579,9 @@ void POP3Folder::deleteMessages(const messageSet& msgs) } // Notify message flags changed - ref event = - vmime::create - (thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast (shared_from_this()), events::messageChangedEvent::TYPE_FLAGS, list); notifyMessageChanged(event); @@ -601,7 +601,7 @@ void POP3Folder::rename(const folder::path& /* newPath */) } -void POP3Folder::addMessage(ref /* msg */, const int /* flags */, +void POP3Folder::addMessage(shared_ptr /* msg */, const int /* flags */, vmime::datetime* /* date */, utility::progressListener* /* progress */) { throw exceptions::operation_not_supported(); @@ -626,23 +626,23 @@ void POP3Folder::status(int& count, int& unseen) count = 0; unseen = 0; - ref status = getStatus(); + shared_ptr status = getStatus(); count = status->getMessageCount(); unseen = status->getUnseenCount(); } -ref POP3Folder::getStatus() +shared_ptr POP3Folder::getStatus() { - ref store = m_store.acquire(); + shared_ptr store = m_store.lock(); if (!store) throw exceptions::illegal_state("Store disconnected"); POP3Command::STAT()->send(store->getConnection()); - ref response = + shared_ptr response = POP3Response::readResponse(store->getConnection()); if (!response->isSuccess()) @@ -654,7 +654,7 @@ ref POP3Folder::getStatus() std::istringstream iss(response->getText()); iss >> count; - ref status = vmime::create (); + shared_ptr status = make_shared (); status->setMessageCount(count); status->setUnseenCount(count); @@ -675,9 +675,9 @@ ref POP3Folder::getStatus() nums[j] = i; // Notify message count changed - ref event = - vmime::create - (thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast (shared_from_this()), events::messageCountEvent::TYPE_ADDED, nums); notifyMessageCount(event); @@ -690,9 +690,9 @@ ref POP3Folder::getStatus() { (*it)->m_messageCount = count; - ref event = - vmime::create - ((*it)->thisRef().dynamicCast (), + shared_ptr event = + make_shared + (dynamicCast ((*it)->shared_from_this()), events::messageCountEvent::TYPE_ADDED, nums); (*it)->notifyMessageCount(event); diff --git a/src/net/pop3/POP3FolderStatus.cpp b/src/net/pop3/POP3FolderStatus.cpp index 64c8d9d1..944379ac 100644 --- a/src/net/pop3/POP3FolderStatus.cpp +++ b/src/net/pop3/POP3FolderStatus.cpp @@ -74,9 +74,9 @@ void POP3FolderStatus::setUnseenCount(const unsigned int unseen) } -ref POP3FolderStatus::clone() const +shared_ptr POP3FolderStatus::clone() const { - return vmime::create (*this); + return make_shared (*this); } diff --git a/src/net/pop3/POP3Message.cpp b/src/net/pop3/POP3Message.cpp index bad25cb9..5f0fb725 100644 --- a/src/net/pop3/POP3Message.cpp +++ b/src/net/pop3/POP3Message.cpp @@ -44,7 +44,7 @@ namespace net { namespace pop3 { -POP3Message::POP3Message(ref folder, const int num) +POP3Message::POP3Message(shared_ptr folder, const int num) : m_folder(folder), m_num(num), m_size(-1), m_deleted(false) { folder->registerMessage(this); @@ -53,7 +53,7 @@ POP3Message::POP3Message(ref folder, const int num) POP3Message::~POP3Message() { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (folder) folder->unregisterMessage(this); @@ -62,7 +62,7 @@ POP3Message::~POP3Message() void POP3Message::onFolderClosed() { - m_folder = NULL; + m_folder.reset(); } @@ -104,19 +104,19 @@ int POP3Message::getFlags() const } -ref POP3Message::getStructure() const +shared_ptr POP3Message::getStructure() const { throw exceptions::operation_not_supported(); } -ref POP3Message::getStructure() +shared_ptr POP3Message::getStructure() { throw exceptions::operation_not_supported(); } -ref POP3Message::getHeader() const +shared_ptr POP3Message::getHeader() const { if (m_header == NULL) throw exceptions::unfetched_object(); @@ -129,7 +129,7 @@ void POP3Message::extract(utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const bool /* peek */) const { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (!folder) throw exceptions::illegal_state("Folder closed"); @@ -140,7 +140,7 @@ void POP3Message::extract(utility::outputStream& os, throw exceptions::partial_fetch_not_supported(); // Emit the "RETR" command - ref store = folder.constCast ()->m_store.acquire(); + shared_ptr store = constCast (folder)->m_store.lock(); POP3Command::RETR(m_num)->send(store->getConnection()); @@ -157,7 +157,7 @@ void POP3Message::extract(utility::outputStream& os, void POP3Message::extractPart - (ref /* p */, utility::outputStream& /* os */, + (shared_ptr /* p */, utility::outputStream& /* os */, utility::progressListener* /* progress */, const int /* start */, const int /* length */, const bool /* peek */) const @@ -166,15 +166,15 @@ void POP3Message::extractPart } -void POP3Message::fetchPartHeader(ref /* p */) +void POP3Message::fetchPartHeader(shared_ptr /* p */) { throw exceptions::operation_not_supported(); } -void POP3Message::fetch(ref msgFolder, const fetchAttributes& options) +void POP3Message::fetch(shared_ptr msgFolder, const fetchAttributes& options) { - ref folder = m_folder.acquire(); + shared_ptr folder = m_folder.lock(); if (folder != msgFolder) throw exceptions::folder_not_found(); @@ -196,7 +196,7 @@ void POP3Message::fetch(ref msgFolder, const fetchAttributes& optio // fields in particular. // Emit the "TOP" command - ref store = folder->m_store.acquire(); + shared_ptr store = folder->m_store.lock(); POP3Command::TOP(m_num, 0)->send(store->getConnection()); @@ -208,7 +208,7 @@ void POP3Message::fetch(ref msgFolder, const fetchAttributes& optio POP3Response::readLargeResponse(store->getConnection(), bufferStream, /* progress */ NULL, /* predictedSize */ 0); - m_header = vmime::create
(); + m_header = make_shared
(); m_header->parse(buffer); } catch (exceptions::command_error& e) @@ -224,14 +224,14 @@ void POP3Message::setFlags(const int /* flags */, const int /* mode */) } -ref POP3Message::getParsedMessage() +shared_ptr POP3Message::getParsedMessage() { std::ostringstream oss; utility::outputStreamAdapter os(oss); extract(os); - vmime::ref msg = vmime::create (); + shared_ptr msg = make_shared (); msg->parse(oss.str()); return msg; diff --git a/src/net/pop3/POP3Response.cpp b/src/net/pop3/POP3Response.cpp index 975cd642..e24634c6 100644 --- a/src/net/pop3/POP3Response.cpp +++ b/src/net/pop3/POP3Response.cpp @@ -46,17 +46,17 @@ namespace net { namespace pop3 { -POP3Response::POP3Response(ref sok, ref toh) +POP3Response::POP3Response(shared_ptr sok, shared_ptr toh) : m_socket(sok), m_timeoutHandler(toh) { } // static -ref POP3Response::readResponse(ref conn) +shared_ptr POP3Response::readResponse(shared_ptr conn) { - ref resp = vmime::create - (conn->getSocket(), conn->getTimeoutHandler()); + shared_ptr resp = shared_ptr + (new POP3Response(conn->getSocket(), conn->getTimeoutHandler())); string buffer; resp->readResponseImpl(buffer, /* multiLine */ false); @@ -70,10 +70,10 @@ ref POP3Response::readResponse(ref conn) // static -ref POP3Response::readMultilineResponse(ref conn) +shared_ptr POP3Response::readMultilineResponse(shared_ptr conn) { - ref resp = vmime::create - (conn->getSocket(), conn->getTimeoutHandler()); + shared_ptr resp = shared_ptr + (new POP3Response(conn->getSocket(), conn->getTimeoutHandler())); string buffer; resp->readResponseImpl(buffer, /* multiLine */ true); @@ -96,12 +96,12 @@ ref POP3Response::readMultilineResponse(ref conn // static -ref POP3Response::readLargeResponse - (ref conn, utility::outputStream& os, +shared_ptr POP3Response::readLargeResponse + (shared_ptr conn, utility::outputStream& os, utility::progressListener* progress, const long predictedSize) { - ref resp = vmime::create - (conn->getSocket(), conn->getTimeoutHandler()); + shared_ptr resp = shared_ptr + (new POP3Response(conn->getSocket(), conn->getTimeoutHandler())); string firstLine; resp->readResponseImpl(firstLine, os, progress, predictedSize); diff --git a/src/net/pop3/POP3SStore.cpp b/src/net/pop3/POP3SStore.cpp index f7d17b38..f1c3da74 100644 --- a/src/net/pop3/POP3SStore.cpp +++ b/src/net/pop3/POP3SStore.cpp @@ -35,7 +35,7 @@ namespace net { namespace pop3 { -POP3SStore::POP3SStore(ref sess, ref auth) +POP3SStore::POP3SStore(shared_ptr sess, shared_ptr auth) : POP3Store(sess, auth, true) { } diff --git a/src/net/pop3/POP3Store.cpp b/src/net/pop3/POP3Store.cpp index 6ff404e2..e6e95b1b 100644 --- a/src/net/pop3/POP3Store.cpp +++ b/src/net/pop3/POP3Store.cpp @@ -42,7 +42,7 @@ namespace net { namespace pop3 { -POP3Store::POP3Store(ref sess, ref auth, const bool secured) +POP3Store::POP3Store(shared_ptr sess, shared_ptr auth, const bool secured) : store(sess, getInfosInstance(), auth), m_isPOP3S(secured) { } @@ -68,33 +68,34 @@ const string POP3Store::getProtocolName() const } -ref POP3Store::getDefaultFolder() +shared_ptr POP3Store::getDefaultFolder() { if (!isConnected()) throw exceptions::illegal_state("Not connected"); - return vmime::create (folder::path(folder::path::component("INBOX")), - thisRef().dynamicCast ()); + return make_shared + (folder::path(folder::path::component("INBOX")), + dynamicCast (shared_from_this())); } -ref POP3Store::getRootFolder() +shared_ptr POP3Store::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 POP3Store::getFolder(const folder::path& path) +shared_ptr POP3Store::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 +110,8 @@ void POP3Store::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 +119,7 @@ void POP3Store::connect() } catch (std::exception&) { - m_connection = NULL; + m_connection = null; throw; } } @@ -145,16 +146,16 @@ bool POP3Store::isSecuredConnection() const } -ref POP3Store::getConnectionInfos() const +shared_ptr POP3Store::getConnectionInfos() const { if (m_connection == NULL) - return NULL; + return null; return m_connection->getConnectionInfos(); } -ref POP3Store::getConnection() +shared_ptr POP3Store::getConnection() { return m_connection; } @@ -175,7 +176,7 @@ void POP3Store::disconnect() m_connection->disconnect(); - m_connection = NULL; + m_connection = null; } @@ -186,7 +187,7 @@ void POP3Store::noop() POP3Command::NOOP()->send(m_connection); - ref response = POP3Response::readResponse(m_connection); + shared_ptr response = POP3Response::readResponse(m_connection); if (!response->isSuccess()) throw exceptions::command_error("NOOP", response->getFirstLine()); diff --git a/src/net/pop3/POP3Utils.cpp b/src/net/pop3/POP3Utils.cpp index e2722104..7ba65fff 100644 --- a/src/net/pop3/POP3Utils.cpp +++ b/src/net/pop3/POP3Utils.cpp @@ -39,7 +39,7 @@ namespace pop3 { // static -void POP3Utils::parseMultiListOrUidlResponse(ref response, std::map & result) +void POP3Utils::parseMultiListOrUidlResponse(shared_ptr response, std::map & result) { std::map ids; -- cgit v1.2.3