aboutsummaryrefslogtreecommitdiffstats
path: root/src/net/pop3
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/pop3')
-rw-r--r--src/net/pop3/POP3Command.cpp40
-rw-r--r--src/net/pop3/POP3Connection.cpp104
-rw-r--r--src/net/pop3/POP3Folder.cpp134
-rw-r--r--src/net/pop3/POP3FolderStatus.cpp4
-rw-r--r--src/net/pop3/POP3Message.cpp32
-rw-r--r--src/net/pop3/POP3Response.cpp22
-rw-r--r--src/net/pop3/POP3SStore.cpp2
-rw-r--r--src/net/pop3/POP3Store.cpp37
-rw-r--r--src/net/pop3/POP3Utils.cpp2
9 files changed, 189 insertions, 188 deletions
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> POP3Command::CAPA()
+shared_ptr <POP3Command> POP3Command::CAPA()
{
return createCommand("CAPA");
}
// static
-ref <POP3Command> POP3Command::NOOP()
+shared_ptr <POP3Command> POP3Command::NOOP()
{
return createCommand("NOOP");
}
// static
-ref <POP3Command> POP3Command::AUTH(const string& mechName)
+shared_ptr <POP3Command> POP3Command::AUTH(const string& mechName)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -74,14 +74,14 @@ ref <POP3Command> POP3Command::AUTH(const string& mechName)
// static
-ref <POP3Command> POP3Command::STLS()
+shared_ptr <POP3Command> POP3Command::STLS()
{
return createCommand("STLS");
}
// static
-ref <POP3Command> POP3Command::APOP(const string& username, const string& digest)
+shared_ptr <POP3Command> POP3Command::APOP(const string& username, const string& digest)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -92,7 +92,7 @@ ref <POP3Command> POP3Command::APOP(const string& username, const string& digest
// static
-ref <POP3Command> POP3Command::USER(const string& username)
+shared_ptr <POP3Command> POP3Command::USER(const string& username)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -103,7 +103,7 @@ ref <POP3Command> POP3Command::USER(const string& username)
// static
-ref <POP3Command> POP3Command::PASS(const string& password)
+shared_ptr <POP3Command> POP3Command::PASS(const string& password)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -114,21 +114,21 @@ ref <POP3Command> POP3Command::PASS(const string& password)
// static
-ref <POP3Command> POP3Command::STAT()
+shared_ptr <POP3Command> POP3Command::STAT()
{
return createCommand("STAT");
}
// static
-ref <POP3Command> POP3Command::LIST()
+shared_ptr <POP3Command> POP3Command::LIST()
{
return createCommand("LIST");
}
// static
-ref <POP3Command> POP3Command::LIST(const unsigned long msg)
+shared_ptr <POP3Command> POP3Command::LIST(const unsigned long msg)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -139,14 +139,14 @@ ref <POP3Command> POP3Command::LIST(const unsigned long msg)
// static
-ref <POP3Command> POP3Command::UIDL()
+shared_ptr <POP3Command> POP3Command::UIDL()
{
return createCommand("UIDL");
}
// static
-ref <POP3Command> POP3Command::UIDL(const unsigned long msg)
+shared_ptr <POP3Command> POP3Command::UIDL(const unsigned long msg)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -157,7 +157,7 @@ ref <POP3Command> POP3Command::UIDL(const unsigned long msg)
// static
-ref <POP3Command> POP3Command::DELE(const unsigned long msg)
+shared_ptr <POP3Command> POP3Command::DELE(const unsigned long msg)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -168,7 +168,7 @@ ref <POP3Command> POP3Command::DELE(const unsigned long msg)
// static
-ref <POP3Command> POP3Command::RETR(const unsigned long msg)
+shared_ptr <POP3Command> POP3Command::RETR(const unsigned long msg)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -179,7 +179,7 @@ ref <POP3Command> POP3Command::RETR(const unsigned long msg)
// static
-ref <POP3Command> POP3Command::TOP(const unsigned long msg, const unsigned long lines)
+shared_ptr <POP3Command> POP3Command::TOP(const unsigned long msg, const unsigned long lines)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -190,23 +190,23 @@ ref <POP3Command> POP3Command::TOP(const unsigned long msg, const unsigned long
// static
-ref <POP3Command> POP3Command::RSET()
+shared_ptr <POP3Command> POP3Command::RSET()
{
return createCommand("RSET");
}
// static
-ref <POP3Command> POP3Command::QUIT()
+shared_ptr <POP3Command> POP3Command::QUIT()
{
return createCommand("QUIT");
}
// static
-ref <POP3Command> POP3Command::createCommand(const string& text)
+shared_ptr <POP3Command> POP3Command::createCommand(const string& text)
{
- return vmime::create <POP3Command>(text);
+ return shared_ptr <POP3Command>(new POP3Command(text));
}
@@ -216,7 +216,7 @@ const string POP3Command::getText() const
}
-void POP3Command::send(ref <POP3Connection> conn)
+void POP3Command::send(shared_ptr <POP3Connection> 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 <type>(getSession(), \
- dynamic_cast <const POP3ServiceInfos&>(m_store.acquire()->getInfos()).getProperties().prop))
+ (m_store.lock()->getInfos().getPropertyValue <type>(getSession(), \
+ dynamic_cast <const POP3ServiceInfos&>(m_store.lock()->getInfos()).getProperties().prop))
#define HAS_PROPERTY(prop) \
- (m_store.acquire()->getInfos().hasProperty(getSession(), \
- dynamic_cast <const POP3ServiceInfos&>(m_store.acquire()->getInfos()).getProperties().prop))
+ (m_store.lock()->getInfos().hasProperty(getSession(), \
+ dynamic_cast <const POP3ServiceInfos&>(m_store.lock()->getInfos()).getProperties().prop))
namespace vmime {
@@ -63,8 +63,8 @@ namespace pop3 {
-POP3Connection::POP3Connection(ref <POP3Store> store, ref <security::authenticator> auth)
- : m_store(store), m_auth(auth), m_socket(NULL), m_timeoutHandler(NULL),
+POP3Connection::POP3Connection(shared_ptr <POP3Store> store, shared_ptr <security::authenticator> 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 <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> 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 <tls::TLSSession> tlsSession = tls::TLSSession::create
+ shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
(store->getCertificateVerifier(),
store->getSession()->getTLSProperties());
- ref <tls::TLSSocket> tlsSocket =
+ shared_ptr <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
m_socket = tlsSocket;
m_secured = true;
- m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
+ m_cntInfos = make_shared <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
}
else
#endif // VMIME_HAVE_TLS_SUPPORT
{
- m_cntInfos = vmime::create <defaultConnectionInfos>(address, port);
+ m_cntInfos = make_shared <defaultConnectionInfos>(address, port);
}
m_socket->connect(address, port);
@@ -131,8 +131,8 @@ void POP3Connection::connect()
// eg: C: <connection to server>
// --- S: +OK MailSite POP3 Server 5.3.4.0 Ready <[email protected]>
- ref <POP3Response> response = POP3Response::readResponse
- (thisRef().dynamicCast <POP3Connection>());
+ shared_ptr <POP3Response> response = POP3Response::readResponse
+ (dynamicCast <POP3Connection>(shared_from_this()));
if (!response->isSuccess())
{
@@ -195,8 +195,8 @@ void POP3Connection::internalDisconnect()
{
try
{
- POP3Command::QUIT()->send(thisRef().dynamicCast <POP3Connection>());
- POP3Response::readResponse(thisRef().dynamicCast <POP3Connection>());
+ POP3Command::QUIT()->send(dynamicCast <POP3Connection>(shared_from_this()));
+ POP3Response::readResponse(dynamicCast <POP3Connection>(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 <POP3Connection> conn = thisRef().dynamicCast <POP3Connection>();
- ref <POP3Response> response;
+ shared_ptr <POP3Connection> conn = dynamicCast <POP3Connection>(shared_from_this());
+ shared_ptr <POP3Response> response;
if (GET_PROPERTY(bool, PROPERTY_OPTIONS_APOP))
{
@@ -271,7 +271,7 @@ void POP3Connection::authenticate(const messageId& randomMID)
randomMID.getRight().length() != 0)
{
// <digest> is the result of MD5 applied to "<message-id>password"
- ref <security::digest::messageDigest> md5 =
+ shared_ptr <security::digest::messageDigest> 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 <security::sasl::SASLAuthenticator>())
+ if (!dynamicCast <security::sasl::SASLAuthenticator>(getAuthenticator()))
throw exceptions::authentication_error("No SASL authenticator available.");
std::vector <string> capa = getCapabilities();
@@ -401,10 +401,10 @@ void POP3Connection::authenticateSASL()
if (saslMechs.empty())
throw exceptions::authentication_error("No SASL mechanism available.");
- std::vector <ref <security::sasl::SASLMechanism> > mechList;
+ std::vector <shared_ptr <security::sasl::SASLMechanism> > mechList;
- ref <security::sasl::SASLContext> saslContext =
- vmime::create <security::sasl::SASLContext>();
+ shared_ptr <security::sasl::SASLContext> saslContext =
+ make_shared <security::sasl::SASLContext>();
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 <security::sasl::SASLMechanism> suggestedMech =
+ shared_ptr <security::sasl::SASLMechanism> 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 <security::sasl::SASLAuthenticator>()->
+ mechList = dynamicCast <security::sasl::SASLAuthenticator>(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 <security::sasl::SASLMechanism> mech = mechList[i];
+ shared_ptr <security::sasl::SASLMechanism> mech = mechList[i];
- ref <security::sasl::SASLSession> saslSession =
+ shared_ptr <security::sasl::SASLSession> saslSession =
saslContext->createSession("pop3", getAuthenticator(), mech);
saslSession->init();
- POP3Command::AUTH(mech->getName())->send(thisRef().dynamicCast <POP3Connection>());
+ POP3Command::AUTH(mech->getName())->send(dynamicCast <POP3Connection>(shared_from_this()));
for (bool cont = true ; cont ; )
{
- ref <POP3Response> response =
- POP3Response::readResponse(thisRef().dynamicCast <POP3Connection>());
+ shared_ptr <POP3Response> response =
+ POP3Response::readResponse(dynamicCast <POP3Connection>(shared_from_this()));
switch (response->getCode())
{
@@ -537,19 +537,19 @@ void POP3Connection::startTLS()
{
try
{
- POP3Command::STLS()->send(thisRef().dynamicCast <POP3Connection>());
+ POP3Command::STLS()->send(dynamicCast <POP3Connection>(shared_from_this()));
- ref <POP3Response> response =
- POP3Response::readResponse(thisRef().dynamicCast <POP3Connection>());
+ shared_ptr <POP3Response> response =
+ POP3Response::readResponse(dynamicCast <POP3Connection>(shared_from_this()));
if (!response->isSuccess())
throw exceptions::command_error("STLS", response->getFirstLine());
- ref <tls::TLSSession> tlsSession = tls::TLSSession::create
- (m_store.acquire()->getCertificateVerifier(),
- m_store.acquire()->getSession()->getTLSProperties());
+ shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
+ (m_store.lock()->getCertificateVerifier(),
+ m_store.lock()->getSession()->getTLSProperties());
- ref <tls::TLSSocket> tlsSocket =
+ shared_ptr <tls::TLSSocket> 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 <tls::TLSSecuredConnectionInfos>
+ m_cntInfos = make_shared <tls::TLSSecuredConnectionInfos>
(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 <POP3Connection>());
+ POP3Command::CAPA()->send(dynamicCast <POP3Connection>(shared_from_this()));
- ref <POP3Response> response =
- POP3Response::readMultilineResponse(thisRef().dynamicCast <POP3Connection>());
+ shared_ptr <POP3Response> response =
+ POP3Response::readMultilineResponse(dynamicCast <POP3Connection>(shared_from_this()));
std::vector <string> res;
@@ -631,37 +631,37 @@ bool POP3Connection::isSecuredConnection() const
}
-ref <connectionInfos> POP3Connection::getConnectionInfos() const
+shared_ptr <connectionInfos> POP3Connection::getConnectionInfos() const
{
return m_cntInfos;
}
-ref <POP3Store> POP3Connection::getStore()
+shared_ptr <POP3Store> POP3Connection::getStore()
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <session> POP3Connection::getSession()
+shared_ptr <session> POP3Connection::getSession()
{
- return m_store.acquire()->getSession();
+ return m_store.lock()->getSession();
}
-ref <socket> POP3Connection::getSocket()
+shared_ptr <socket> POP3Connection::getSocket()
{
return m_socket;
}
-ref <timeoutHandler> POP3Connection::getTimeoutHandler()
+shared_ptr <timeoutHandler> POP3Connection::getTimeoutHandler()
{
return m_timeoutHandler;
}
-ref <security::authenticator> POP3Connection::getAuthenticator()
+shared_ptr <security::authenticator> 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 <POP3Store> store)
+POP3Folder::POP3Folder(const folder::path& path, shared_ptr <POP3Store> 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 <POP3Store> store)
POP3Folder::~POP3Folder()
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> 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 <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> 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 <POP3Response> response = POP3Response::readResponse(store->getConnection());
+ shared_ptr <POP3Response> 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 <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -200,7 +200,7 @@ void POP3Folder::destroy()
bool POP3Folder::exists()
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -215,9 +215,9 @@ bool POP3Folder::isOpen() const
}
-ref <message> POP3Folder::getMessage(const int num)
+shared_ptr <message> POP3Folder::getMessage(const int num)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -226,13 +226,13 @@ ref <message> POP3Folder::getMessage(const int num)
else if (num < 1 || num > m_messageCount)
throw exceptions::message_not_found();
- return vmime::create <POP3Message>(thisRef().dynamicCast <POP3Folder>(), num);
+ return make_shared <POP3Message>(dynamicCast <POP3Folder>(shared_from_this()), num);
}
-std::vector <ref <message> > POP3Folder::getMessages(const messageSet& msgs)
+std::vector <shared_ptr <message> > POP3Folder::getMessages(const messageSet& msgs)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -243,15 +243,15 @@ std::vector <ref <message> > POP3Folder::getMessages(const messageSet& msgs)
{
const std::vector <int> numbers = POP3Utils::messageSetToNumberList(msgs);
- std::vector <ref <message> > messages;
- ref <POP3Folder> thisFolder = thisRef().dynamicCast <POP3Folder>();
+ std::vector <shared_ptr <message> > messages;
+ shared_ptr <POP3Folder> thisFolder(dynamicCast <POP3Folder>(shared_from_this()));
for (std::vector <int>::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 <POP3Message>(thisFolder, *it));
+ messages.push_back(make_shared <POP3Message>(thisFolder, *it));
}
return messages;
@@ -265,7 +265,7 @@ std::vector <ref <message> > POP3Folder::getMessages(const messageSet& msgs)
int POP3Folder::getMessageCount()
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -276,42 +276,42 @@ int POP3Folder::getMessageCount()
}
-ref <folder> POP3Folder::getFolder(const folder::path::component& name)
+shared_ptr <folder> POP3Folder::getFolder(const folder::path::component& name)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
- return vmime::create <POP3Folder>(m_path / name, store);
+ return make_shared <POP3Folder>(m_path / name, store);
}
-std::vector <ref <folder> > POP3Folder::getFolders(const bool /* recursive */)
+std::vector <shared_ptr <folder> > POP3Folder::getFolders(const bool /* recursive */)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
if (m_path.isEmpty())
{
- std::vector <ref <folder> > v;
- v.push_back(vmime::create <POP3Folder>(folder::path::component("INBOX"), store));
+ std::vector <shared_ptr <folder> > v;
+ v.push_back(make_shared <POP3Folder>(folder::path::component("INBOX"), store));
return (v);
}
else
{
- std::vector <ref <folder> > v;
+ std::vector <shared_ptr <folder> > v;
return (v);
}
}
-void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAttributes& options,
+void POP3Folder::fetchMessages(std::vector <shared_ptr <message> >& msg, const fetchAttributes& options,
utility::progressListener* progress)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -324,11 +324,11 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
if (progress)
progress->start(total);
- for (std::vector <ref <message> >::iterator it = msg.begin() ;
+ for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ;
it != msg.end() ; ++it)
{
- (*it).dynamicCast <POP3Message>()->fetch
- (thisRef().dynamicCast <POP3Folder>(), options);
+ dynamicCast <POP3Message>(*it)->fetch
+ (dynamicCast <POP3Folder>(shared_from_this()), options);
if (progress)
progress->progress(++current, total);
@@ -340,7 +340,7 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
POP3Command::LIST()->send(store->getConnection());
// Get the response
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readMultilineResponse(store->getConnection());
if (response->isSuccess())
@@ -353,10 +353,10 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
std::map <int, string> result;
POP3Utils::parseMultiListOrUidlResponse(response, result);
- for (std::vector <ref <message> >::iterator it = msg.begin() ;
+ for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ;
it != msg.end() ; ++it)
{
- ref <POP3Message> m = (*it).dynamicCast <POP3Message>();
+ shared_ptr <POP3Message> m = dynamicCast <POP3Message>(*it);
std::map <int, string>::const_iterator x = result.find(m->m_num);
@@ -380,7 +380,7 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
POP3Command::UIDL()->send(store->getConnection());
// Get the response
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readMultilineResponse(store->getConnection());
if (response->isSuccess())
@@ -393,10 +393,10 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
std::map <int, string> result;
POP3Utils::parseMultiListOrUidlResponse(response, result);
- for (std::vector <ref <message> >::iterator it = msg.begin() ;
+ for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ;
it != msg.end() ; ++it)
{
- ref <POP3Message> m = (*it).dynamicCast <POP3Message>();
+ shared_ptr <POP3Message> m = dynamicCast <POP3Message>(*it);
std::map <int, string>::const_iterator x = result.find(m->m_num);
@@ -411,17 +411,17 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
}
-void POP3Folder::fetchMessage(ref <message> msg, const fetchAttributes& options)
+void POP3Folder::fetchMessage(shared_ptr <message> msg, const fetchAttributes& options)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
- msg.dynamicCast <POP3Message>()->fetch
- (thisRef().dynamicCast <POP3Folder>(), options);
+ dynamicCast <POP3Message>(msg)->fetch
+ (dynamicCast <POP3Folder>(shared_from_this()), options);
if (options.has(fetchAttributes::SIZE))
{
@@ -429,7 +429,7 @@ void POP3Folder::fetchMessage(ref <message> msg, const fetchAttributes& options)
POP3Command::LIST(msg->getNumber())->send(store->getConnection());
// Get the response
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readResponse(store->getConnection());
if (response->isSuccess())
@@ -451,7 +451,7 @@ void POP3Folder::fetchMessage(ref <message> msg, const fetchAttributes& options)
std::istringstream iss(string(it, responseText.end()));
iss >> size;
- msg.dynamicCast <POP3Message>()->m_size = size;
+ dynamicCast <POP3Message>(msg)->m_size = size;
}
}
}
@@ -462,7 +462,7 @@ void POP3Folder::fetchMessage(ref <message> msg, const fetchAttributes& options)
POP3Command::UIDL(msg->getNumber())->send(store->getConnection());
// Get the response
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readResponse(store->getConnection());
if (response->isSuccess())
@@ -479,7 +479,7 @@ void POP3Folder::fetchMessage(ref <message> msg, const fetchAttributes& options)
if (it != responseText.end())
{
- msg.dynamicCast <POP3Message>()->m_uid =
+ dynamicCast <POP3Message>(msg)->m_uid =
string(it, responseText.end());
}
}
@@ -495,24 +495,24 @@ int POP3Folder::getFetchCapabilities() const
}
-ref <folder> POP3Folder::getParent()
+shared_ptr <folder> POP3Folder::getParent()
{
if (m_path.isEmpty())
- return NULL;
+ return null;
else
- return vmime::create <POP3Folder>(m_path.getParent(), m_store.acquire());
+ return make_shared <POP3Folder>(m_path.getParent(), m_store.lock());
}
-ref <const store> POP3Folder::getStore() const
+shared_ptr <const store> POP3Folder::getStore() const
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <store> POP3Folder::getStore()
+shared_ptr <store> 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 <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
const std::vector <int> nums = POP3Utils::messageSetToNumberList(msgs);
@@ -553,7 +553,7 @@ void POP3Folder::deleteMessages(const messageSet& msgs)
{
POP3Command::DELE(*it)->send(store->getConnection());
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readResponse(store->getConnection());
if (!response->isSuccess())
@@ -579,9 +579,9 @@ void POP3Folder::deleteMessages(const messageSet& msgs)
}
// Notify message flags changed
- ref <events::messageChangedEvent> event =
- vmime::create <events::messageChangedEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageChangedEvent> event =
+ make_shared <events::messageChangedEvent>
+ (dynamicCast <folder>(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 <vmime::message> /* msg */, const int /* flags */,
+void POP3Folder::addMessage(shared_ptr <vmime::message> /* 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 <folderStatus> status = getStatus();
+ shared_ptr <folderStatus> status = getStatus();
count = status->getMessageCount();
unseen = status->getUnseenCount();
}
-ref <folderStatus> POP3Folder::getStatus()
+shared_ptr <folderStatus> POP3Folder::getStatus()
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
POP3Command::STAT()->send(store->getConnection());
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readResponse(store->getConnection());
if (!response->isSuccess())
@@ -654,7 +654,7 @@ ref <folderStatus> POP3Folder::getStatus()
std::istringstream iss(response->getText());
iss >> count;
- ref <POP3FolderStatus> status = vmime::create <POP3FolderStatus>();
+ shared_ptr <POP3FolderStatus> status = make_shared <POP3FolderStatus>();
status->setMessageCount(count);
status->setUnseenCount(count);
@@ -675,9 +675,9 @@ ref <folderStatus> POP3Folder::getStatus()
nums[j] = i;
// Notify message count changed
- ref <events::messageCountEvent> event =
- vmime::create <events::messageCountEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageCountEvent> event =
+ make_shared <events::messageCountEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageCountEvent::TYPE_ADDED, nums);
notifyMessageCount(event);
@@ -690,9 +690,9 @@ ref <folderStatus> POP3Folder::getStatus()
{
(*it)->m_messageCount = count;
- ref <events::messageCountEvent> event =
- vmime::create <events::messageCountEvent>
- ((*it)->thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageCountEvent> event =
+ make_shared <events::messageCountEvent>
+ (dynamicCast <folder>((*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 <folderStatus> POP3FolderStatus::clone() const
+shared_ptr <folderStatus> POP3FolderStatus::clone() const
{
- return vmime::create <POP3FolderStatus>(*this);
+ return make_shared <POP3FolderStatus>(*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 <POP3Folder> folder, const int num)
+POP3Message::POP3Message(shared_ptr <POP3Folder> 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 <POP3Folder> folder, const int num)
POP3Message::~POP3Message()
{
- ref <POP3Folder> folder = m_folder.acquire();
+ shared_ptr <POP3Folder> 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 <const messageStructure> POP3Message::getStructure() const
+shared_ptr <const messageStructure> POP3Message::getStructure() const
{
throw exceptions::operation_not_supported();
}
-ref <messageStructure> POP3Message::getStructure()
+shared_ptr <messageStructure> POP3Message::getStructure()
{
throw exceptions::operation_not_supported();
}
-ref <const header> POP3Message::getHeader() const
+shared_ptr <const header> 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 <const POP3Folder> folder = m_folder.acquire();
+ shared_ptr <const POP3Folder> 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 <POP3Store> store = folder.constCast <POP3Folder>()->m_store.acquire();
+ shared_ptr <POP3Store> store = constCast <POP3Folder>(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 <const messagePart> /* p */, utility::outputStream& /* os */,
+ (shared_ptr <const messagePart> /* 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 <messagePart> /* p */)
+void POP3Message::fetchPartHeader(shared_ptr <messagePart> /* p */)
{
throw exceptions::operation_not_supported();
}
-void POP3Message::fetch(ref <POP3Folder> msgFolder, const fetchAttributes& options)
+void POP3Message::fetch(shared_ptr <POP3Folder> msgFolder, const fetchAttributes& options)
{
- ref <POP3Folder> folder = m_folder.acquire();
+ shared_ptr <POP3Folder> folder = m_folder.lock();
if (folder != msgFolder)
throw exceptions::folder_not_found();
@@ -196,7 +196,7 @@ void POP3Message::fetch(ref <POP3Folder> msgFolder, const fetchAttributes& optio
// fields in particular.
// Emit the "TOP" command
- ref <POP3Store> store = folder->m_store.acquire();
+ shared_ptr <POP3Store> store = folder->m_store.lock();
POP3Command::TOP(m_num, 0)->send(store->getConnection());
@@ -208,7 +208,7 @@ void POP3Message::fetch(ref <POP3Folder> msgFolder, const fetchAttributes& optio
POP3Response::readLargeResponse(store->getConnection(),
bufferStream, /* progress */ NULL, /* predictedSize */ 0);
- m_header = vmime::create <header>();
+ m_header = make_shared <header>();
m_header->parse(buffer);
}
catch (exceptions::command_error& e)
@@ -224,14 +224,14 @@ void POP3Message::setFlags(const int /* flags */, const int /* mode */)
}
-ref <vmime::message> POP3Message::getParsedMessage()
+shared_ptr <vmime::message> POP3Message::getParsedMessage()
{
std::ostringstream oss;
utility::outputStreamAdapter os(oss);
extract(os);
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ shared_ptr <vmime::message> msg = make_shared <vmime::message>();
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 <socket> sok, ref <timeoutHandler> toh)
+POP3Response::POP3Response(shared_ptr <socket> sok, shared_ptr <timeoutHandler> toh)
: m_socket(sok), m_timeoutHandler(toh)
{
}
// static
-ref <POP3Response> POP3Response::readResponse(ref <POP3Connection> conn)
+shared_ptr <POP3Response> POP3Response::readResponse(shared_ptr <POP3Connection> conn)
{
- ref <POP3Response> resp = vmime::create <POP3Response>
- (conn->getSocket(), conn->getTimeoutHandler());
+ shared_ptr <POP3Response> resp = shared_ptr <POP3Response>
+ (new POP3Response(conn->getSocket(), conn->getTimeoutHandler()));
string buffer;
resp->readResponseImpl(buffer, /* multiLine */ false);
@@ -70,10 +70,10 @@ ref <POP3Response> POP3Response::readResponse(ref <POP3Connection> conn)
// static
-ref <POP3Response> POP3Response::readMultilineResponse(ref <POP3Connection> conn)
+shared_ptr <POP3Response> POP3Response::readMultilineResponse(shared_ptr <POP3Connection> conn)
{
- ref <POP3Response> resp = vmime::create <POP3Response>
- (conn->getSocket(), conn->getTimeoutHandler());
+ shared_ptr <POP3Response> resp = shared_ptr <POP3Response>
+ (new POP3Response(conn->getSocket(), conn->getTimeoutHandler()));
string buffer;
resp->readResponseImpl(buffer, /* multiLine */ true);
@@ -96,12 +96,12 @@ ref <POP3Response> POP3Response::readMultilineResponse(ref <POP3Connection> conn
// static
-ref <POP3Response> POP3Response::readLargeResponse
- (ref <POP3Connection> conn, utility::outputStream& os,
+shared_ptr <POP3Response> POP3Response::readLargeResponse
+ (shared_ptr <POP3Connection> conn, utility::outputStream& os,
utility::progressListener* progress, const long predictedSize)
{
- ref <POP3Response> resp = vmime::create <POP3Response>
- (conn->getSocket(), conn->getTimeoutHandler());
+ shared_ptr <POP3Response> resp = shared_ptr <POP3Response>
+ (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 <session> sess, ref <security::authenticator> auth)
+POP3SStore::POP3SStore(shared_ptr <session> sess, shared_ptr <security::authenticator> 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 <session> sess, ref <security::authenticator> auth, const bool secured)
+POP3Store::POP3Store(shared_ptr <session> sess, shared_ptr <security::authenticator> auth, const bool secured)
: store(sess, getInfosInstance(), auth), m_isPOP3S(secured)
{
}
@@ -68,33 +68,34 @@ const string POP3Store::getProtocolName() const
}
-ref <folder> POP3Store::getDefaultFolder()
+shared_ptr <folder> POP3Store::getDefaultFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <POP3Folder>(folder::path(folder::path::component("INBOX")),
- thisRef().dynamicCast <POP3Store>());
+ return make_shared <POP3Folder>
+ (folder::path(folder::path::component("INBOX")),
+ dynamicCast <POP3Store>(shared_from_this()));
}
-ref <folder> POP3Store::getRootFolder()
+shared_ptr <folder> POP3Store::getRootFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <POP3Folder>(folder::path(),
- thisRef().dynamicCast <POP3Store>());
+ return make_shared <POP3Folder>
+ (folder::path(), dynamicCast <POP3Store>(shared_from_this()));
}
-ref <folder> POP3Store::getFolder(const folder::path& path)
+shared_ptr <folder> POP3Store::getFolder(const folder::path& path)
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <POP3Folder>(path,
- thisRef().dynamicCast <POP3Store>());
+ return make_shared <POP3Folder>
+ (path, dynamicCast <POP3Store>(shared_from_this()));
}
@@ -109,8 +110,8 @@ void POP3Store::connect()
if (isConnected())
throw exceptions::already_connected();
- m_connection = vmime::create <POP3Connection>
- (thisRef().dynamicCast <POP3Store>(), getAuthenticator());
+ m_connection = make_shared <POP3Connection>
+ (dynamicCast <POP3Store>(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 <connectionInfos> POP3Store::getConnectionInfos() const
+shared_ptr <connectionInfos> POP3Store::getConnectionInfos() const
{
if (m_connection == NULL)
- return NULL;
+ return null;
return m_connection->getConnectionInfos();
}
-ref <POP3Connection> POP3Store::getConnection()
+shared_ptr <POP3Connection> 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 <POP3Response> response = POP3Response::readResponse(m_connection);
+ shared_ptr <POP3Response> 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 <POP3Response> response, std::map <int, string>& result)
+void POP3Utils::parseMultiListOrUidlResponse(shared_ptr <POP3Response> response, std::map <int, string>& result)
{
std::map <int, string> ids;