aboutsummaryrefslogtreecommitdiffstats
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/events.cpp24
-rw-r--r--src/net/folder.cpp14
-rw-r--r--src/net/imap/IMAPConnection.cpp96
-rw-r--r--src/net/imap/IMAPFolder.cpp211
-rw-r--r--src/net/imap/IMAPFolderStatus.cpp4
-rw-r--r--src/net/imap/IMAPMessage.cpp98
-rw-r--r--src/net/imap/IMAPMessagePart.cpp32
-rw-r--r--src/net/imap/IMAPMessagePartContentHandler.cpp32
-rw-r--r--src/net/imap/IMAPMessageStructure.cpp12
-rw-r--r--src/net/imap/IMAPSStore.cpp2
-rw-r--r--src/net/imap/IMAPStore.cpp41
-rw-r--r--src/net/imap/IMAPUtils.cpp4
-rw-r--r--src/net/maildir/format/courierMaildirFormat.cpp50
-rw-r--r--src/net/maildir/format/kmailMaildirFormat.cpp46
-rw-r--r--src/net/maildir/maildirFolder.cpp238
-rw-r--r--src/net/maildir/maildirFolderStatus.cpp4
-rw-r--r--src/net/maildir/maildirFormat.cpp20
-rw-r--r--src/net/maildir/maildirMessage.cpp66
-rw-r--r--src/net/maildir/maildirMessagePart.cpp18
-rw-r--r--src/net/maildir/maildirMessageStructure.cpp16
-rw-r--r--src/net/maildir/maildirStore.cpp38
-rw-r--r--src/net/maildir/maildirUtils.cpp6
-rw-r--r--src/net/message.cpp4
-rw-r--r--src/net/messageSet.cpp8
-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
-rw-r--r--src/net/sendmail/sendmailTransport.cpp9
-rw-r--r--src/net/service.cpp32
-rw-r--r--src/net/serviceFactory.cpp32
-rw-r--r--src/net/serviceInfos.cpp2
-rw-r--r--src/net/serviceRegistration.inl10
-rw-r--r--src/net/session.cpp57
-rw-r--r--src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp6
-rw-r--r--src/net/smtp/SMTPCommand.cpp30
-rw-r--r--src/net/smtp/SMTPCommandSet.cpp20
-rw-r--r--src/net/smtp/SMTPConnection.cpp82
-rw-r--r--src/net/smtp/SMTPResponse.cpp8
-rw-r--r--src/net/smtp/SMTPSTransport.cpp2
-rw-r--r--src/net/smtp/SMTPTransport.cpp26
-rw-r--r--src/net/tls/TLSSecuredConnectionInfos.cpp4
-rw-r--r--src/net/tls/gnutls/TLSProperties_GnuTLS.cpp10
-rw-r--r--src/net/tls/gnutls/TLSSession_GnuTLS.cpp12
-rw-r--r--src/net/tls/gnutls/TLSSocket_GnuTLS.cpp38
-rw-r--r--src/net/tls/openssl/OpenSSLInitializer.cpp4
-rw-r--r--src/net/tls/openssl/TLSProperties_OpenSSL.cpp10
-rw-r--r--src/net/tls/openssl/TLSSession_OpenSSL.cpp12
-rw-r--r--src/net/tls/openssl/TLSSocket_OpenSSL.cpp32
-rw-r--r--src/net/transport.cpp52
55 files changed, 976 insertions, 975 deletions
diff --git a/src/net/events.cpp b/src/net/events.cpp
index 8cc23706..a19e1738 100644
--- a/src/net/events.cpp
+++ b/src/net/events.cpp
@@ -60,7 +60,7 @@ const char* messageCountEvent::EVENT_CLASS = "messageCountEvent";
messageCountEvent::messageCountEvent
- (ref <folder> folder, const Types type, const std::vector <int>& nums)
+ (shared_ptr <folder> folder, const Types type, const std::vector <int>& nums)
: m_folder(folder), m_type(type)
{
m_nums.resize(nums.size());
@@ -68,7 +68,7 @@ messageCountEvent::messageCountEvent
}
-ref <folder> messageCountEvent::getFolder() const { return (m_folder); }
+shared_ptr <folder> messageCountEvent::getFolder() const { return (m_folder); }
messageCountEvent::Types messageCountEvent::getType() const { return (m_type); }
const std::vector <int>& messageCountEvent::getNumbers() const { return (m_nums); }
@@ -76,9 +76,9 @@ const std::vector <int>& messageCountEvent::getNumbers() const { return (m_nums)
void messageCountEvent::dispatch(messageCountListener* listener)
{
if (m_type == TYPE_ADDED)
- listener->messagesAdded(thisRef().dynamicCast <messageCountEvent>());
+ listener->messagesAdded(dynamicCast <messageCountEvent>(shared_from_this()));
else
- listener->messagesRemoved(thisRef().dynamicCast <messageCountEvent>());
+ listener->messagesRemoved(dynamicCast <messageCountEvent>(shared_from_this()));
}
@@ -96,7 +96,7 @@ const char* messageChangedEvent::EVENT_CLASS = "messageChangedEvent";
messageChangedEvent::messageChangedEvent
- (ref <folder> folder, const Types type, const std::vector <int>& nums)
+ (shared_ptr <folder> folder, const Types type, const std::vector <int>& nums)
: m_folder(folder), m_type(type)
{
m_nums.resize(nums.size());
@@ -104,14 +104,14 @@ messageChangedEvent::messageChangedEvent
}
-ref <folder> messageChangedEvent::getFolder() const { return (m_folder); }
+shared_ptr <folder> messageChangedEvent::getFolder() const { return (m_folder); }
messageChangedEvent::Types messageChangedEvent::getType() const { return (m_type); }
const std::vector <int>& messageChangedEvent::getNumbers() const { return (m_nums); }
void messageChangedEvent::dispatch(messageChangedListener* listener)
{
- listener->messageChanged(thisRef().dynamicCast <messageChangedEvent>());
+ listener->messageChanged(dynamicCast <messageChangedEvent>(shared_from_this()));
}
@@ -129,14 +129,14 @@ const char* folderEvent::EVENT_CLASS = "folderEvent";
folderEvent::folderEvent
- (ref <folder> folder, const Types type,
+ (shared_ptr <folder> folder, const Types type,
const utility::path& oldPath, const utility::path& newPath)
: m_folder(folder), m_type(type), m_oldPath(oldPath), m_newPath(newPath)
{
}
-ref <folder> folderEvent::getFolder() const { return (m_folder); }
+shared_ptr <folder> folderEvent::getFolder() const { return (m_folder); }
folderEvent::Types folderEvent::getType() const { return (m_type); }
@@ -144,9 +144,9 @@ void folderEvent::dispatch(folderListener* listener)
{
switch (m_type)
{
- case TYPE_CREATED: listener->folderCreated(thisRef().dynamicCast <folderEvent>()); break;
- case TYPE_RENAMED: listener->folderRenamed(thisRef().dynamicCast <folderEvent>()); break;
- case TYPE_DELETED: listener->folderDeleted(thisRef().dynamicCast <folderEvent>()); break;
+ case TYPE_CREATED: listener->folderCreated(dynamicCast <folderEvent>(shared_from_this())); break;
+ case TYPE_RENAMED: listener->folderRenamed(dynamicCast <folderEvent>(shared_from_this())); break;
+ case TYPE_DELETED: listener->folderDeleted(dynamicCast <folderEvent>(shared_from_this())); break;
}
}
diff --git a/src/net/folder.cpp b/src/net/folder.cpp
index 1cc618d4..1d6f3140 100644
--- a/src/net/folder.cpp
+++ b/src/net/folder.cpp
@@ -48,7 +48,7 @@ void folder::removeMessageChangedListener(events::messageChangedListener* l)
}
-void folder::notifyMessageChanged(ref <events::messageChangedEvent> event)
+void folder::notifyMessageChanged(shared_ptr <events::messageChangedEvent> event)
{
for (std::list <events::messageChangedListener*>::iterator
it = m_messageChangedListeners.begin() ; it != m_messageChangedListeners.end() ; ++it)
@@ -70,7 +70,7 @@ void folder::removeMessageCountListener(events::messageCountListener* l)
}
-void folder::notifyMessageCount(ref <events::messageCountEvent> event)
+void folder::notifyMessageCount(shared_ptr <events::messageCountEvent> event)
{
for (std::list <events::messageCountListener*>::iterator
it = m_messageCountListeners.begin() ; it != m_messageCountListeners.end() ; ++it)
@@ -92,7 +92,7 @@ void folder::removeFolderListener(events::folderListener* l)
}
-void folder::notifyFolder(ref <events::folderEvent> event)
+void folder::notifyFolder(shared_ptr <events::folderEvent> event)
{
for (std::list <events::folderListener*>::iterator
it = m_folderListeners.begin() ; it != m_folderListeners.end() ; ++it)
@@ -102,19 +102,19 @@ void folder::notifyFolder(ref <events::folderEvent> event)
}
-void folder::notifyEvent(ref <events::event> event)
+void folder::notifyEvent(shared_ptr <events::event> event)
{
if (event->getClass() == events::messageCountEvent::EVENT_CLASS)
{
- notifyMessageCount(event.dynamicCast <events::messageCountEvent>());
+ notifyMessageCount(dynamicCast <events::messageCountEvent>(event));
}
else if (event->getClass() == events::messageChangedEvent::EVENT_CLASS)
{
- notifyMessageChanged(event.dynamicCast <events::messageChangedEvent>());
+ notifyMessageChanged(dynamicCast <events::messageChangedEvent>(event));
}
else if (event->getClass() == events::folderEvent::EVENT_CLASS)
{
- notifyFolder(event.dynamicCast <events::folderEvent>());
+ notifyFolder(dynamicCast <events::folderEvent>(event));
}
}
diff --git a/src/net/imap/IMAPConnection.cpp b/src/net/imap/IMAPConnection.cpp
index 53f8ba9f..0dba1ecc 100644
--- a/src/net/imap/IMAPConnection.cpp
+++ b/src/net/imap/IMAPConnection.cpp
@@ -53,11 +53,11 @@
// Helpers for service properties
#define GET_PROPERTY(type, prop) \
- (m_store.acquire()->getInfos().getPropertyValue <type>(getSession(), \
- dynamic_cast <const IMAPServiceInfos&>(m_store.acquire()->getInfos()).getProperties().prop))
+ (m_store.lock()->getInfos().getPropertyValue <type>(getSession(), \
+ dynamic_cast <const IMAPServiceInfos&>(m_store.lock()->getInfos()).getProperties().prop))
#define HAS_PROPERTY(prop) \
- (m_store.acquire()->getInfos().hasProperty(getSession(), \
- dynamic_cast <const IMAPServiceInfos&>(m_store.acquire()->getInfos()).getProperties().prop))
+ (m_store.lock()->getInfos().hasProperty(getSession(), \
+ dynamic_cast <const IMAPServiceInfos&>(m_store.lock()->getInfos()).getProperties().prop))
namespace vmime {
@@ -65,9 +65,9 @@ namespace net {
namespace imap {
-IMAPConnection::IMAPConnection(ref <IMAPStore> store, ref <security::authenticator> 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),
+IMAPConnection::IMAPConnection(shared_ptr <IMAPStore> store, shared_ptr <security::authenticator> 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_secured(false), m_firstTag(true), m_capabilitiesFetched(false), m_noModSeq(false)
{
}
@@ -100,7 +100,7 @@ void IMAPConnection::connect()
const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS);
const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT);
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
// Create the time-out handler
if (store->getTimeoutHandlerFactory())
@@ -112,29 +112,29 @@ void IMAPConnection::connect()
#if VMIME_HAVE_TLS_SUPPORT
if (store->isIMAPS()) // dedicated port/IMAPS
{
- 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);
- m_tag = vmime::create <IMAPTag>();
- m_parser = vmime::create <IMAPParser>(m_tag, m_socket, m_timeoutHandler);
+ m_tag = make_shared <IMAPTag>();
+ m_parser = make_shared <IMAPParser>(m_tag, m_socket, m_timeoutHandler);
setState(STATE_NON_AUTHENTICATED);
@@ -145,7 +145,7 @@ void IMAPConnection::connect()
// eg: C: <connection to server>
// --- S: * OK mydomain.org IMAP4rev1 v12.256 server ready
- utility::auto_ptr <IMAPParser::greeting> greet(m_parser->readGreeting());
+ std::auto_ptr <IMAPParser::greeting> greet(m_parser->readGreeting());
bool needAuth = false;
if (greet->resp_cond_bye())
@@ -223,7 +223,7 @@ void IMAPConnection::connect()
void IMAPConnection::authenticate()
{
- getAuthenticator()->setService(m_store.acquire());
+ getAuthenticator()->setService(m_store.lock());
#if VMIME_HAVE_SASL_SUPPORT
// First, try SASL authentication
@@ -262,7 +262,7 @@ void IMAPConnection::authenticate()
send(true, "LOGIN " + IMAPUtils::quoteString(username)
+ " " + IMAPUtils::quoteString(password), true);
- utility::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->isBad())
{
@@ -277,7 +277,7 @@ void IMAPConnection::authenticate()
}
// Server capabilities may change when logged in
- if (!processCapabilityResponseData(resp))
+ if (!processCapabilityResponseData(resp.get()))
invalidateCapabilities();
}
@@ -286,7 +286,7 @@ void IMAPConnection::authenticate()
void IMAPConnection::authenticateSASL()
{
- if (!getAuthenticator().dynamicCast <security::sasl::SASLAuthenticator>())
+ if (!dynamicCast <security::sasl::SASLAuthenticator>(getAuthenticator()))
throw exceptions::authentication_error("No SASL authenticator available.");
const std::vector <string> capa = getCapabilities();
@@ -310,10 +310,10 @@ void IMAPConnection::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)
{
@@ -332,14 +332,14 @@ void IMAPConnection::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())
@@ -348,9 +348,9 @@ void IMAPConnection::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("imap", getAuthenticator(), mech);
saslSession->init();
@@ -359,7 +359,7 @@ void IMAPConnection::authenticateSASL()
for (bool cont = true ; cont ; )
{
- utility::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->response_done() &&
resp->response_done()->response_tagged() &&
@@ -466,7 +466,7 @@ void IMAPConnection::startTLS()
{
send(true, "STARTTLS", true);
- utility::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -475,11 +475,11 @@ void IMAPConnection::startTLS()
("STARTTLS", resp->getErrorLog(), "bad response");
}
- 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);
@@ -488,7 +488,7 @@ void IMAPConnection::startTLS()
m_parser->setSocket(m_socket);
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
@@ -551,12 +551,12 @@ void IMAPConnection::fetchCapabilities()
{
send(true, "CAPABILITY", true);
- utility::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->response_done()->response_tagged()->
resp_cond_state()->status() == IMAPParser::resp_cond_state::OK)
{
- processCapabilityResponseData(resp);
+ processCapabilityResponseData(resp.get());
}
}
@@ -604,7 +604,7 @@ void IMAPConnection::processCapabilityResponseData(const IMAPParser::capability_
}
-ref <security::authenticator> IMAPConnection::getAuthenticator()
+shared_ptr <security::authenticator> IMAPConnection::getAuthenticator()
{
return m_auth;
}
@@ -623,7 +623,7 @@ bool IMAPConnection::isSecuredConnection() const
}
-ref <connectionInfos> IMAPConnection::getConnectionInfos() const
+shared_ptr <connectionInfos> IMAPConnection::getConnectionInfos() const
{
return m_cntInfos;
}
@@ -645,15 +645,15 @@ void IMAPConnection::internalDisconnect()
send(true, "LOGOUT", true);
m_socket->disconnect();
- m_socket = NULL;
+ m_socket = null;
}
- m_timeoutHandler = NULL;
+ m_timeoutHandler = null;
m_state = STATE_LOGOUT;
m_secured = false;
- m_cntInfos = NULL;
+ m_cntInfos = null;
}
@@ -661,7 +661,7 @@ void IMAPConnection::initHierarchySeparator()
{
send(true, "LIST \"\" \"\"", true);
- vmime::utility::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -769,25 +769,25 @@ char IMAPConnection::hierarchySeparator() const
}
-ref <const IMAPStore> IMAPConnection::getStore() const
+shared_ptr <const IMAPStore> IMAPConnection::getStore() const
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <IMAPStore> IMAPConnection::getStore()
+shared_ptr <IMAPStore> IMAPConnection::getStore()
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <session> IMAPConnection::getSession()
+shared_ptr <session> IMAPConnection::getSession()
{
- return m_store.acquire()->getSession();
+ return m_store.lock()->getSession();
}
-ref <const socket> IMAPConnection::getSocket() const
+shared_ptr <const socket> IMAPConnection::getSocket() const
{
return m_socket;
}
diff --git a/src/net/imap/IMAPFolder.cpp b/src/net/imap/IMAPFolder.cpp
index 3a3615e6..06d331df 100644
--- a/src/net/imap/IMAPFolder.cpp
+++ b/src/net/imap/IMAPFolder.cpp
@@ -39,7 +39,6 @@
#include "vmime/message.hpp"
#include "vmime/exception.hpp"
-#include "vmime/utility/smartPtr.hpp"
#include "vmime/utility/outputStreamAdapter.hpp"
@@ -52,20 +51,20 @@ namespace net {
namespace imap {
-IMAPFolder::IMAPFolder(const folder::path& path, ref <IMAPStore> store, const int type, const int flags)
+IMAPFolder::IMAPFolder(const folder::path& path, shared_ptr <IMAPStore> store, const int type, const int flags)
: m_store(store), m_connection(store->connection()), m_path(path),
m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()), m_mode(-1),
m_open(false), m_type(type), m_flags(flags)
{
store->registerFolder(this);
- m_status = vmime::create <IMAPFolderStatus>();
+ m_status = make_shared <IMAPFolderStatus>();
}
IMAPFolder::~IMAPFolder()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (store)
{
@@ -76,7 +75,7 @@ IMAPFolder::~IMAPFolder()
}
else if (m_open)
{
- m_connection = NULL;
+ m_connection = null;
onClose();
}
}
@@ -145,7 +144,7 @@ const folder::path IMAPFolder::getFullPath() const
void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -159,8 +158,8 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
}
// Open a connection for this folder
- ref <IMAPConnection> connection =
- vmime::create <IMAPConnection>(store, store->getAuthenticator());
+ shared_ptr <IMAPConnection> connection =
+ make_shared <IMAPConnection>(store, store->getAuthenticator());
try
{
@@ -193,7 +192,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
connection->send(true, oss.str(), true);
// Read the response
- utility::auto_ptr <IMAPParser::response> resp(connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -259,7 +258,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
}
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
// Check for access mode (read-only or read-write)
const IMAPParser::resp_text_code* respTextCode = resp->response_done()->
@@ -292,7 +291,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
void IMAPFolder::close(const bool expunge)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -300,7 +299,7 @@ void IMAPFolder::close(const bool expunge)
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
- ref <IMAPConnection> oldConnection = m_connection;
+ shared_ptr <IMAPConnection> oldConnection = m_connection;
// Emit the "CLOSE" command to expunge messages marked
// as deleted (this is fastest than "EXPUNGE")
@@ -316,12 +315,12 @@ void IMAPFolder::close(const bool expunge)
oldConnection->disconnect();
// Now use default store connection
- m_connection = m_store.acquire()->connection();
+ m_connection = m_store.lock()->connection();
m_open = false;
m_mode = -1;
- m_status = vmime::create <IMAPFolderStatus>();
+ m_status = make_shared <IMAPFolderStatus>();
onClose();
}
@@ -341,7 +340,7 @@ void IMAPFolder::onClose()
void IMAPFolder::create(const int type)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -371,7 +370,7 @@ void IMAPFolder::create(const int type)
m_connection->send(true, oss.str(), true);
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -381,9 +380,9 @@ void IMAPFolder::create(const int type)
}
// Notify folder created
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_CREATED, m_path, m_path);
notifyFolder(event);
@@ -392,7 +391,7 @@ void IMAPFolder::create(const int type)
void IMAPFolder::destroy()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -409,7 +408,7 @@ void IMAPFolder::destroy()
m_connection->send(true, oss.str(), true);
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -419,9 +418,9 @@ void IMAPFolder::destroy()
}
// Notify folder deleted
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_DELETED, m_path, m_path);
notifyFolder(event);
@@ -430,7 +429,7 @@ void IMAPFolder::destroy()
bool IMAPFolder::exists()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!isOpen() && !store)
throw exceptions::illegal_state("Store disconnected");
@@ -470,7 +469,7 @@ int IMAPFolder::testExistAndGetType()
m_connection->send(true, oss.str(), true);
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -517,7 +516,7 @@ bool IMAPFolder::isOpen() const
}
-ref <message> IMAPFolder::getMessage(const int num)
+shared_ptr <message> IMAPFolder::getMessage(const int num)
{
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
@@ -525,28 +524,28 @@ ref <message> IMAPFolder::getMessage(const int num)
if (num < 1 || num > m_status->getMessageCount())
throw exceptions::message_not_found();
- return vmime::create <IMAPMessage>(thisRef().dynamicCast <IMAPFolder>(), num);
+ return make_shared <IMAPMessage>(dynamicCast <IMAPFolder>(shared_from_this()), num);
}
-std::vector <ref <message> > IMAPFolder::getMessages(const messageSet& msgs)
+std::vector <shared_ptr <message> > IMAPFolder::getMessages(const messageSet& msgs)
{
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
if (msgs.isEmpty())
- return std::vector <ref <message> >();
+ return std::vector <shared_ptr <message> >();
- std::vector <ref <message> > messages;
+ std::vector <shared_ptr <message> > messages;
if (msgs.isNumberSet())
{
const std::vector <int> numbers = IMAPUtils::messageSetToNumberList(msgs);
- ref <IMAPFolder> thisFolder = thisRef().dynamicCast <IMAPFolder>();
+ shared_ptr <IMAPFolder> thisFolder = dynamicCast <IMAPFolder>(shared_from_this());
for (std::vector <int>::const_iterator it = numbers.begin() ; it != numbers.end() ; ++it)
- messages.push_back(vmime::create <IMAPMessage>(thisFolder, *it));
+ messages.push_back(make_shared <IMAPMessage>(thisFolder, *it));
}
else if (msgs.isUIDSet())
{
@@ -566,7 +565,7 @@ std::vector <ref <message> > IMAPFolder::getMessages(const messageSet& msgs)
m_connection->send(true, cmd.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -613,8 +612,8 @@ std::vector <ref <message> > IMAPFolder::getMessages(const messageSet& msgs)
if (!msgUID.empty())
{
- ref <IMAPFolder> thisFolder = thisRef().dynamicCast <IMAPFolder>();
- messages.push_back(vmime::create <IMAPMessage>(thisFolder, msgNum, msgUID));
+ shared_ptr <IMAPFolder> thisFolder = dynamicCast <IMAPFolder>(shared_from_this());
+ messages.push_back(make_shared <IMAPMessage>(thisFolder, msgNum, msgUID));
}
}
}
@@ -650,20 +649,20 @@ vmime_uint64 IMAPFolder::getHighestModSequence() const
}
-ref <folder> IMAPFolder::getFolder(const folder::path::component& name)
+shared_ptr <folder> IMAPFolder::getFolder(const folder::path::component& name)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
- return vmime::create <IMAPFolder>(m_path / name, store);
+ return make_shared <IMAPFolder>(m_path / name, store);
}
-std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
+std::vector <shared_ptr <folder> > IMAPFolder::getFolders(const bool recursive)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!isOpen() && !store)
throw exceptions::illegal_state("Store disconnected");
@@ -699,7 +698,7 @@ std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
m_connection->send(true, oss.str(), true);
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -711,7 +710,7 @@ std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
resp->continue_req_or_response_data();
- std::vector <ref <folder> > v;
+ std::vector <shared_ptr <folder> > v;
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
it = respDataList.begin() ; it != respDataList.end() ; ++it)
@@ -741,7 +740,7 @@ std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
const class IMAPParser::mailbox_flag_list* mailbox_flag_list =
mailboxData->mailbox_list()->mailbox_flag_list();
- v.push_back(vmime::create <IMAPFolder>(path, store,
+ v.push_back(make_shared <IMAPFolder>(path, store,
IMAPUtils::folderTypeFromFlags(mailbox_flag_list),
IMAPUtils::folderFlagsFromFlags(mailbox_flag_list)));
}
@@ -751,10 +750,10 @@ std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
}
-void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAttributes& options,
+void IMAPFolder::fetchMessages(std::vector <shared_ptr <message> >& msg, const fetchAttributes& options,
utility::progressListener* progress)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -765,12 +764,12 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
std::vector <int> list;
list.reserve(msg.size());
- std::map <int, ref <IMAPMessage> > numberToMsg;
+ std::map <int, shared_ptr <IMAPMessage> > numberToMsg;
- for (std::vector <ref <message> >::iterator it = msg.begin() ; it != msg.end() ; ++it)
+ for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ; it != msg.end() ; ++it)
{
list.push_back((*it)->getNumber());
- numberToMsg[(*it)->getNumber()] = (*it).dynamicCast <IMAPMessage>();
+ numberToMsg[(*it)->getNumber()] = dynamicCast <IMAPMessage>(*it);
}
// Send the request
@@ -780,7 +779,7 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
m_connection->send(true, command, true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -819,7 +818,7 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
// Process fetch response for this message
const int num = static_cast <int>(messageData->number());
- std::map <int, ref <IMAPMessage> >::iterator msg = numberToMsg.find(num);
+ std::map <int, shared_ptr <IMAPMessage> >::iterator msg = numberToMsg.find(num);
if (msg != numberToMsg.end())
{
@@ -841,13 +840,13 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
if (progress)
progress->stop(total);
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
-void IMAPFolder::fetchMessage(ref <message> msg, const fetchAttributes& options)
+void IMAPFolder::fetchMessage(shared_ptr <message> msg, const fetchAttributes& options)
{
- std::vector <ref <message> > msgs;
+ std::vector <shared_ptr <message> > msgs;
msgs.push_back(msg);
fetchMessages(msgs, options, /* progress */ NULL);
@@ -863,24 +862,24 @@ int IMAPFolder::getFetchCapabilities() const
}
-ref <folder> IMAPFolder::getParent()
+shared_ptr <folder> IMAPFolder::getParent()
{
if (m_path.isEmpty())
- return NULL;
+ return null;
else
- return vmime::create <IMAPFolder>(m_path.getParent(), m_store.acquire());
+ return make_shared <IMAPFolder>(m_path.getParent(), m_store.lock());
}
-ref <const store> IMAPFolder::getStore() const
+shared_ptr <const store> IMAPFolder::getStore() const
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <store> IMAPFolder::getStore()
+shared_ptr <store> IMAPFolder::getStore()
{
- return m_store.acquire();
+ return m_store.lock();
}
@@ -902,13 +901,13 @@ void IMAPFolder::unregisterMessage(IMAPMessage* msg)
void IMAPFolder::onStoreDisconnected()
{
- m_store = NULL;
+ m_store.reset();
}
void IMAPFolder::deleteMessages(const messageSet& msgs)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (msgs.isEmpty())
throw exceptions::invalid_argument();
@@ -935,7 +934,7 @@ void IMAPFolder::deleteMessages(const messageSet& msgs)
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -944,7 +943,7 @@ void IMAPFolder::deleteMessages(const messageSet& msgs)
resp->getErrorLog(), "bad response");
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
@@ -977,7 +976,7 @@ void IMAPFolder::setMessageFlags(const messageSet& msgs, const int flags, const
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -986,12 +985,12 @@ void IMAPFolder::setMessageFlags(const messageSet& msgs, const int flags, const
resp->getErrorLog(), "bad response");
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
}
-void IMAPFolder::addMessage(ref <vmime::message> msg, const int flags,
+void IMAPFolder::addMessage(shared_ptr <vmime::message> msg, const int flags,
vmime::datetime* date, utility::progressListener* progress)
{
std::ostringstream oss;
@@ -1009,7 +1008,7 @@ void IMAPFolder::addMessage(ref <vmime::message> msg, const int flags,
void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int flags,
vmime::datetime* date, utility::progressListener* progress)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1045,7 +1044,7 @@ void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
bool ok = false;
const std::vector <IMAPParser::continue_req_or_response_data*>& respList
@@ -1097,7 +1096,7 @@ void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int
progress->stop(total);
// Get the response
- utility::auto_ptr <IMAPParser::response> finalResp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> finalResp(m_connection->readResponse());
if (finalResp->isBad() || finalResp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1106,13 +1105,13 @@ void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int
resp->getErrorLog(), "bad response");
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
void IMAPFolder::expunge()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1125,7 +1124,7 @@ void IMAPFolder::expunge()
m_connection->send(true, "EXPUNGE", true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1134,13 +1133,13 @@ void IMAPFolder::expunge()
resp->getErrorLog(), "bad response");
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
void IMAPFolder::rename(const folder::path& newPath)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1165,7 +1164,7 @@ void IMAPFolder::rename(const folder::path& newPath)
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1180,9 +1179,9 @@ void IMAPFolder::rename(const folder::path& newPath)
m_path = newPath;
m_name = newPath.getLastComponent();
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_RENAMED, oldPath, newPath);
notifyFolder(event);
@@ -1197,22 +1196,22 @@ void IMAPFolder::rename(const folder::path& newPath)
(*it)->m_path.renameParent(oldPath, newPath);
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- ((*it)->thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>((*it)->shared_from_this()),
events::folderEvent::TYPE_RENAMED, oldPath, (*it)->m_path);
(*it)->notifyFolder(event);
}
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
void IMAPFolder::copyMessages(const folder::path& dest, const messageSet& set)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1231,7 +1230,7 @@ void IMAPFolder::copyMessages(const folder::path& dest, const messageSet& set)
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1240,7 +1239,7 @@ void IMAPFolder::copyMessages(const folder::path& dest, const messageSet& set)
resp->getErrorLog(), "bad response");
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
@@ -1249,16 +1248,16 @@ void IMAPFolder::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> IMAPFolder::getStatus()
+shared_ptr <folderStatus> IMAPFolder::getStatus()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1283,7 +1282,7 @@ ref <folderStatus> IMAPFolder::getStatus()
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1305,7 +1304,7 @@ ref <folderStatus> IMAPFolder::getStatus()
if (responseData->mailbox_data() &&
responseData->mailbox_data()->type() == IMAPParser::mailbox_data::STATUS)
{
- ref <IMAPFolderStatus> status = vmime::create <IMAPFolderStatus>();
+ shared_ptr <IMAPFolderStatus> status = make_shared <IMAPFolderStatus>();
status->updateFromResponse(responseData->mailbox_data());
m_status->updateFromResponse(responseData->mailbox_data());
@@ -1322,14 +1321,14 @@ ref <folderStatus> IMAPFolder::getStatus()
void IMAPFolder::noop()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
m_connection->send(true, "NOOP", true);
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1337,7 +1336,7 @@ void IMAPFolder::noop()
throw exceptions::command_error("NOOP", resp->getErrorLog());
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
@@ -1354,7 +1353,7 @@ std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid&
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() ||
resp->response_done()->response_tagged()->resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1393,7 +1392,7 @@ std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid&
}
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
return v;
}
@@ -1401,9 +1400,9 @@ std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid&
void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp)
{
- std::vector <ref <events::event> > events;
+ std::vector <shared_ptr <events::event> > events;
- ref <IMAPFolderStatus> oldStatus = m_status->clone().dynamicCast <IMAPFolderStatus>();
+ shared_ptr <IMAPFolderStatus> oldStatus = vmime::clone(m_status);
int expungedMessageCount = 0;
// Process tagged response
@@ -1450,8 +1449,8 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp)
(*mit)->processFetchResponse(/* options */ 0, msgData);
}
- events.push_back(vmime::create <events::messageChangedEvent>
- (thisRef().dynamicCast <folder>(),
+ events.push_back(make_shared <events::messageChangedEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageChangedEvent::TYPE_FLAGS,
std::vector <int>(1, msgNumber)));
}
@@ -1467,8 +1466,8 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp)
(*jt)->renumber((*jt)->getNumber() - 1);
}
- events.push_back(vmime::create <events::messageCountEvent>
- (thisRef().dynamicCast <folder>(),
+ events.push_back(make_shared <events::messageCountEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageCountEvent::TYPE_REMOVED,
std::vector <int>(1, msgNumber)));
@@ -1488,14 +1487,14 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp)
newMessageNumbers.push_back(msgNumber);
}
- events.push_back(vmime::create <events::messageCountEvent>
- (thisRef().dynamicCast <folder>(),
+ events.push_back(make_shared <events::messageCountEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageCountEvent::TYPE_ADDED,
newMessageNumbers));
}
// Dispatch notifications
- for (std::vector <ref <events::event> >::iterator evit =
+ for (std::vector <shared_ptr <events::event> >::iterator evit =
events.begin() ; evit != events.end() ; ++evit)
{
notifyEvent(*evit);
diff --git a/src/net/imap/IMAPFolderStatus.cpp b/src/net/imap/IMAPFolderStatus.cpp
index c231cb38..25c88b02 100644
--- a/src/net/imap/IMAPFolderStatus.cpp
+++ b/src/net/imap/IMAPFolderStatus.cpp
@@ -94,9 +94,9 @@ vmime_uint64 IMAPFolderStatus::getHighestModSeq() const
}
-ref <folderStatus> IMAPFolderStatus::clone() const
+shared_ptr <folderStatus> IMAPFolderStatus::clone() const
{
- return vmime::create <IMAPFolderStatus>(*this);
+ return make_shared <IMAPFolderStatus>(*this);
}
diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp
index d512e752..ae51bfe8 100644
--- a/src/net/imap/IMAPMessage.cpp
+++ b/src/net/imap/IMAPMessage.cpp
@@ -97,17 +97,17 @@ private:
//
-IMAPMessage::IMAPMessage(ref <IMAPFolder> folder, const int num)
+IMAPMessage::IMAPMessage(shared_ptr <IMAPFolder> folder, const int num)
: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
- m_expunged(false), m_modseq(0), m_structure(NULL)
+ m_expunged(false), m_modseq(0), m_structure(null)
{
folder->registerMessage(this);
}
-IMAPMessage::IMAPMessage(ref <IMAPFolder> folder, const int num, const uid& uid)
+IMAPMessage::IMAPMessage(shared_ptr <IMAPFolder> folder, const int num, const uid& uid)
: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
- m_expunged(false), m_uid(uid), m_modseq(0), m_structure(NULL)
+ m_expunged(false), m_uid(uid), m_modseq(0), m_structure(null)
{
folder->registerMessage(this);
}
@@ -115,7 +115,7 @@ IMAPMessage::IMAPMessage(ref <IMAPFolder> folder, const int num, const uid& uid)
IMAPMessage::~IMAPMessage()
{
- ref <IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <IMAPFolder> folder = m_folder.lock();
if (folder)
folder->unregisterMessage(this);
@@ -124,7 +124,7 @@ IMAPMessage::~IMAPMessage()
void IMAPMessage::onFolderClosed()
{
- m_folder = NULL;
+ m_folder.reset();
}
@@ -170,7 +170,7 @@ int IMAPMessage::getFlags() const
}
-ref <const messageStructure> IMAPMessage::getStructure() const
+shared_ptr <const messageStructure> IMAPMessage::getStructure() const
{
if (m_structure == NULL)
throw exceptions::unfetched_object();
@@ -179,7 +179,7 @@ ref <const messageStructure> IMAPMessage::getStructure() const
}
-ref <messageStructure> IMAPMessage::getStructure()
+shared_ptr <messageStructure> IMAPMessage::getStructure()
{
if (m_structure == NULL)
throw exceptions::unfetched_object();
@@ -188,7 +188,7 @@ ref <messageStructure> IMAPMessage::getStructure()
}
-ref <const header> IMAPMessage::getHeader() const
+shared_ptr <const header> IMAPMessage::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
@@ -200,20 +200,20 @@ ref <const header> IMAPMessage::getHeader() const
void IMAPMessage::extract(utility::outputStream& os, utility::progressListener* progress,
const int start, const int length, const bool peek) const
{
- ref <const IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <const IMAPFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
- extractImpl(NULL, os, progress, start, length, EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0));
+ extractImpl(null, os, progress, start, length, EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0));
}
void IMAPMessage::extractPart
- (ref <const messagePart> p, utility::outputStream& os, utility::progressListener* progress,
+ (shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress,
const int start, const int length, const bool peek) const
{
- ref <const IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <const IMAPFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
@@ -222,9 +222,9 @@ void IMAPMessage::extractPart
}
-void IMAPMessage::fetchPartHeader(ref <messagePart> p)
+void IMAPMessage::fetchPartHeader(shared_ptr <messagePart> p)
{
- ref <IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <IMAPFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
@@ -234,15 +234,15 @@ void IMAPMessage::fetchPartHeader(ref <messagePart> p)
extractImpl(p, ossAdapter, NULL, 0, -1, EXTRACT_HEADER | EXTRACT_PEEK);
- p.dynamicCast <IMAPMessagePart>()->getOrCreateHeader().parse(oss.str());
+ dynamicCast <IMAPMessagePart>(p)->getOrCreateHeader().parse(oss.str());
}
-void IMAPMessage::fetchPartHeaderForStructure(ref <messageStructure> str)
+void IMAPMessage::fetchPartHeaderForStructure(shared_ptr <messageStructure> str)
{
for (size_t i = 0, n = str->getPartCount() ; i < n ; ++i)
{
- ref <messagePart> part = str->getPartAt(i);
+ shared_ptr <messagePart> part = str->getPartAt(i);
// Fetch header of current part
fetchPartHeader(part);
@@ -253,11 +253,11 @@ void IMAPMessage::fetchPartHeaderForStructure(ref <messageStructure> str)
}
-void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream& os,
+void IMAPMessage::extractImpl(shared_ptr <const messagePart> p, utility::outputStream& os,
utility::progressListener* progress, const int start,
const int length, const int extractFlags) const
{
- ref <const IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <const IMAPFolder> folder = m_folder.lock();
IMAPMessage_literalHandler literalHandler(os, progress);
@@ -267,7 +267,7 @@ void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream&
if (p != NULL)
{
- ref <const IMAPMessagePart> currentPart = p.dynamicCast <const IMAPMessagePart>();
+ shared_ptr <const IMAPMessagePart> currentPart = dynamicCast <const IMAPMessagePart>(p);
std::vector <int> numbers;
numbers.push_back(currentPart->getNumber());
@@ -344,11 +344,11 @@ void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream&
command << "<" << start << "." << length << ">";
// Send the request
- folder.constCast <IMAPFolder>()->m_connection->send(true, command.str(), true);
+ constCast <IMAPFolder>(folder)->m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp
- (folder.constCast <IMAPFolder>()->m_connection->readResponse(&literalHandler));
+ std::auto_ptr <IMAPParser::response> resp
+ (constCast <IMAPFolder>(folder)->m_connection->readResponse(&literalHandler));
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -368,7 +368,7 @@ void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream&
int IMAPMessage::processFetchResponse
(const fetchAttributes& options, const IMAPParser::message_data* msgData)
{
- ref <IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <IMAPFolder> folder = m_folder.lock();
// Get message attributes
const std::vector <IMAPParser::msg_att_item*> atts = msgData->msg_att()->items();
@@ -406,7 +406,7 @@ int IMAPMessage::processFetchResponse
if (!options.has(fetchAttributes::FULL_HEADER))
{
const IMAPParser::envelope* env = (*it)->envelope();
- ref <vmime::header> hdr = getOrCreateHeader();
+ shared_ptr <vmime::header> hdr = getOrCreateHeader();
// Date
hdr->Date()->setValue(env->env_date()->value());
@@ -463,7 +463,7 @@ int IMAPMessage::processFetchResponse
}
case IMAPParser::msg_att_item::BODY_STRUCTURE:
{
- m_structure = vmime::create <IMAPMessageStructure>((*it)->body());
+ m_structure = make_shared <IMAPMessageStructure>((*it)->body());
break;
}
case IMAPParser::msg_att_item::RFC822_HEADER:
@@ -488,12 +488,12 @@ int IMAPMessage::processFetchResponse
tempHeader.parse((*it)->nstring()->value());
vmime::header& hdr = *getOrCreateHeader();
- std::vector <ref <headerField> > fields = tempHeader.getFieldList();
+ std::vector <shared_ptr <headerField> > fields = tempHeader.getFieldList();
- for (std::vector <ref <headerField> >::const_iterator jt = fields.begin() ;
+ for (std::vector <shared_ptr <headerField> >::const_iterator jt = fields.begin() ;
jt != fields.end() ; ++jt)
{
- hdr.appendField((*jt)->clone().dynamicCast <headerField>());
+ hdr.appendField(vmime::clone(*jt));
}
}
}
@@ -515,18 +515,18 @@ int IMAPMessage::processFetchResponse
}
-ref <header> IMAPMessage::getOrCreateHeader()
+shared_ptr <header> IMAPMessage::getOrCreateHeader()
{
if (m_header != NULL)
return (m_header);
else
- return (m_header = vmime::create <header>());
+ return (m_header = make_shared <header>());
}
void IMAPMessage::setFlags(const int flags, const int mode)
{
- ref <IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <IMAPFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
@@ -539,20 +539,20 @@ void IMAPMessage::setFlags(const int flags, const int mode)
void IMAPMessage::constructParsedMessage
- (ref <bodyPart> parentPart, ref <messageStructure> str, int level)
+ (shared_ptr <bodyPart> parentPart, shared_ptr <messageStructure> str, int level)
{
if (level == 0)
{
- ref <messagePart> part = str->getPartAt(0);
+ shared_ptr <messagePart> part = str->getPartAt(0);
// Copy header
- ref <const header> hdr = part->getHeader();
+ shared_ptr <const header> hdr = part->getHeader();
parentPart->getHeader()->copyFrom(*hdr);
// Initialize body
parentPart->getBody()->setContents
- (vmime::create <IMAPMessagePartContentHandler>
- (thisRef().dynamicCast <IMAPMessage>(),
+ (make_shared <IMAPMessagePartContentHandler>
+ (dynamicCast <IMAPMessage>(shared_from_this()),
part, parentPart->getBody()->getEncoding()));
constructParsedMessage(parentPart, part->getStructure(), 1);
@@ -561,18 +561,18 @@ void IMAPMessage::constructParsedMessage
{
for (size_t i = 0, n = str->getPartCount() ; i < n ; ++i)
{
- ref <messagePart> part = str->getPartAt(i);
+ shared_ptr <messagePart> part = str->getPartAt(i);
- ref <bodyPart> childPart = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> childPart = make_shared <bodyPart>();
// Copy header
- ref <const header> hdr = part->getHeader();
+ shared_ptr <const header> hdr = part->getHeader();
childPart->getHeader()->copyFrom(*hdr);
// Initialize body
childPart->getBody()->setContents
- (vmime::create <IMAPMessagePartContentHandler>
- (thisRef().dynamicCast <IMAPMessage>(),
+ (make_shared <IMAPMessagePartContentHandler>
+ (dynamicCast <IMAPMessage>(shared_from_this()),
part, childPart->getBody()->getEncoding()));
// Add child part
@@ -585,10 +585,10 @@ void IMAPMessage::constructParsedMessage
}
-ref <vmime::message> IMAPMessage::getParsedMessage()
+shared_ptr <vmime::message> IMAPMessage::getParsedMessage()
{
// Fetch structure
- ref <messageStructure> structure = NULL;
+ shared_ptr <messageStructure> structure;
try
{
@@ -596,10 +596,10 @@ ref <vmime::message> IMAPMessage::getParsedMessage()
}
catch (exceptions::unfetched_object&)
{
- std::vector <ref <message> > msgs;
- msgs.push_back(thisRef().dynamicCast <IMAPMessage>());
+ std::vector <shared_ptr <message> > msgs;
+ msgs.push_back(dynamicCast <IMAPMessage>(shared_from_this()));
- m_folder.acquire()->fetchMessages
+ m_folder.lock()->fetchMessages
(msgs, fetchAttributes(fetchAttributes::STRUCTURE), /* progress */ NULL);
structure = getStructure();
@@ -609,7 +609,7 @@ ref <vmime::message> IMAPMessage::getParsedMessage()
fetchPartHeaderForStructure(structure);
// Construct message from structure
- ref <vmime::message> msg = vmime::create <vmime::message>();
+ shared_ptr <vmime::message> msg = make_shared <vmime::message>();
constructParsedMessage(msg, structure);
diff --git a/src/net/imap/IMAPMessagePart.cpp b/src/net/imap/IMAPMessagePart.cpp
index 48e063e8..153470cf 100644
--- a/src/net/imap/IMAPMessagePart.cpp
+++ b/src/net/imap/IMAPMessagePart.cpp
@@ -36,16 +36,16 @@ namespace net {
namespace imap {
-IMAPMessagePart::IMAPMessagePart(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_mpart* mpart)
- : m_parent(parent), m_header(NULL), m_number(number), m_size(0)
+IMAPMessagePart::IMAPMessagePart(shared_ptr <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_mpart* mpart)
+ : m_parent(parent), m_header(null), m_number(number), m_size(0)
{
m_mediaType = vmime::mediaType
("multipart", mpart->media_subtype()->value());
}
-IMAPMessagePart::IMAPMessagePart(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_1part* part)
- : m_parent(parent), m_header(NULL), m_number(number), m_size(0)
+IMAPMessagePart::IMAPMessagePart(shared_ptr <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_1part* part)
+ : m_parent(parent), m_header(null), m_number(number), m_size(0)
{
if (part->body_type_text())
{
@@ -70,11 +70,11 @@ IMAPMessagePart::IMAPMessagePart(ref <IMAPMessagePart> parent, const int number,
m_size = part->body_type_basic()->body_fields()->body_fld_octets()->value();
}
- m_structure = NULL;
+ m_structure = null;
}
-ref <const messageStructure> IMAPMessagePart::getStructure() const
+shared_ptr <const messageStructure> IMAPMessagePart::getStructure() const
{
if (m_structure != NULL)
return m_structure;
@@ -83,7 +83,7 @@ ref <const messageStructure> IMAPMessagePart::getStructure() const
}
-ref <messageStructure> IMAPMessagePart::getStructure()
+shared_ptr <messageStructure> IMAPMessagePart::getStructure()
{
if (m_structure != NULL)
return m_structure;
@@ -92,9 +92,9 @@ ref <messageStructure> IMAPMessagePart::getStructure()
}
-ref <const IMAPMessagePart> IMAPMessagePart::getParent() const
+shared_ptr <const IMAPMessagePart> IMAPMessagePart::getParent() const
{
- return m_parent.acquire();
+ return m_parent.lock();
}
@@ -116,7 +116,7 @@ int IMAPMessagePart::getNumber() const
}
-ref <const header> IMAPMessagePart::getHeader() const
+shared_ptr <const header> IMAPMessagePart::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
@@ -126,19 +126,19 @@ ref <const header> IMAPMessagePart::getHeader() const
// static
-ref <IMAPMessagePart> IMAPMessagePart::create
- (ref <IMAPMessagePart> parent, const int number, const IMAPParser::body* body)
+shared_ptr <IMAPMessagePart> IMAPMessagePart::create
+ (shared_ptr <IMAPMessagePart> parent, const int number, const IMAPParser::body* body)
{
if (body->body_type_mpart())
{
- ref <IMAPMessagePart> part = vmime::create <IMAPMessagePart>(parent, number, body->body_type_mpart());
- part->m_structure = vmime::create <IMAPMessageStructure>(part, body->body_type_mpart()->list());
+ shared_ptr <IMAPMessagePart> part = make_shared <IMAPMessagePart>(parent, number, body->body_type_mpart());
+ part->m_structure = make_shared <IMAPMessageStructure>(part, body->body_type_mpart()->list());
return part;
}
else
{
- return vmime::create <IMAPMessagePart>(parent, number, body->body_type_1part());
+ return make_shared <IMAPMessagePart>(parent, number, body->body_type_1part());
}
}
@@ -148,7 +148,7 @@ header& IMAPMessagePart::getOrCreateHeader()
if (m_header != NULL)
return *m_header;
else
- return *(m_header = vmime::create <header>());
+ return *(m_header = make_shared <header>());
}
diff --git a/src/net/imap/IMAPMessagePartContentHandler.cpp b/src/net/imap/IMAPMessagePartContentHandler.cpp
index 10c7a040..7112e3d2 100644
--- a/src/net/imap/IMAPMessagePartContentHandler.cpp
+++ b/src/net/imap/IMAPMessagePartContentHandler.cpp
@@ -43,17 +43,17 @@ namespace imap {
IMAPMessagePartContentHandler::IMAPMessagePartContentHandler
- (ref <IMAPMessage> msg, ref <messagePart> part, const vmime::encoding& encoding)
+ (shared_ptr <IMAPMessage> msg, shared_ptr <messagePart> part, const vmime::encoding& encoding)
: m_message(msg), m_part(part), m_encoding(encoding)
{
}
-ref <contentHandler> IMAPMessagePartContentHandler::clone() const
+shared_ptr <contentHandler> IMAPMessagePartContentHandler::clone() const
{
- return create <IMAPMessagePartContentHandler>
- (m_message.acquire().constCast <IMAPMessage>(),
- m_part.acquire().constCast <messagePart>(),
+ return make_shared <IMAPMessagePartContentHandler>
+ (constCast <IMAPMessage>(m_message.lock()),
+ constCast <messagePart>(m_part.lock()),
m_encoding);
}
@@ -61,8 +61,8 @@ ref <contentHandler> IMAPMessagePartContentHandler::clone() const
void IMAPMessagePartContentHandler::generate
(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength) const
{
- ref <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
- ref <messagePart> part = m_part.acquire().constCast <messagePart>();
+ shared_ptr <IMAPMessage> msg = constCast <IMAPMessage>(m_message.lock());
+ shared_ptr <messagePart> part = constCast <messagePart>(m_part.lock());
// Data is already encoded
if (isEncoded())
@@ -85,14 +85,14 @@ void IMAPMessagePartContentHandler::generate
std::ostringstream oss2;
utility::outputStreamAdapter tmp2(oss2);
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
theDecoder->decode(in, tmp2);
// Reencode to output stream
string str = oss2.str();
utility::inputStreamStringAdapter tempIn(str);
- ref <utility::encoder::encoder> theEncoder = enc.getEncoder();
+ shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder();
theEncoder->getProperties()["maxlinelength"] = maxLineLength;
theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT);
@@ -114,7 +114,7 @@ void IMAPMessagePartContentHandler::generate
msg->extractPart(part, tmp, NULL);
// Encode temporary buffer to output stream
- ref <utility::encoder::encoder> theEncoder = enc.getEncoder();
+ shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder();
theEncoder->getProperties()["maxlinelength"] = maxLineLength;
theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT);
@@ -128,8 +128,8 @@ void IMAPMessagePartContentHandler::generate
void IMAPMessagePartContentHandler::extract
(utility::outputStream& os, utility::progressListener* progress) const
{
- ref <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
- ref <messagePart> part = m_part.acquire().constCast <messagePart>();
+ shared_ptr <IMAPMessage> msg = constCast <IMAPMessage>(m_message.lock());
+ shared_ptr <messagePart> part = constCast <messagePart>(m_part.lock());
// No decoding to perform
if (!isEncoded())
@@ -149,7 +149,7 @@ void IMAPMessagePartContentHandler::extract
utility::inputStreamStringAdapter is(oss.str());
utility::progressListenerSizeAdapter plsa(progress, getLength());
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
theDecoder->decode(is, os, &plsa);
}
}
@@ -158,8 +158,8 @@ void IMAPMessagePartContentHandler::extract
void IMAPMessagePartContentHandler::extractRaw
(utility::outputStream& os, utility::progressListener* progress) const
{
- ref <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
- ref <messagePart> part = m_part.acquire().constCast <messagePart>();
+ shared_ptr <IMAPMessage> msg = constCast <IMAPMessage>(m_message.lock());
+ shared_ptr <messagePart> part = constCast <messagePart>(m_part.lock());
msg->extractPart(part, os, progress);
}
@@ -167,7 +167,7 @@ void IMAPMessagePartContentHandler::extractRaw
string::size_type IMAPMessagePartContentHandler::getLength() const
{
- return m_part.acquire()->getSize();
+ return m_part.lock()->getSize();
}
diff --git a/src/net/imap/IMAPMessageStructure.cpp b/src/net/imap/IMAPMessageStructure.cpp
index 60f26c68..8dc333e9 100644
--- a/src/net/imap/IMAPMessageStructure.cpp
+++ b/src/net/imap/IMAPMessageStructure.cpp
@@ -43,11 +43,11 @@ IMAPMessageStructure::IMAPMessageStructure()
IMAPMessageStructure::IMAPMessageStructure(const IMAPParser::body* body)
{
- m_parts.push_back(IMAPMessagePart::create(NULL, 0, body));
+ m_parts.push_back(IMAPMessagePart::create(null, 0, body));
}
-IMAPMessageStructure::IMAPMessageStructure(ref <IMAPMessagePart> parent, const std::vector <IMAPParser::body*>& list)
+IMAPMessageStructure::IMAPMessageStructure(shared_ptr <IMAPMessagePart> parent, const std::vector <IMAPParser::body*>& list)
{
int number = 0;
@@ -59,13 +59,13 @@ IMAPMessageStructure::IMAPMessageStructure(ref <IMAPMessagePart> parent, const s
}
-ref <const messagePart> IMAPMessageStructure::getPartAt(const size_t x) const
+shared_ptr <const messagePart> IMAPMessageStructure::getPartAt(const size_t x) const
{
return m_parts[x];
}
-ref <messagePart> IMAPMessageStructure::getPartAt(const size_t x)
+shared_ptr <messagePart> IMAPMessageStructure::getPartAt(const size_t x)
{
return m_parts[x];
}
@@ -78,9 +78,9 @@ size_t IMAPMessageStructure::getPartCount() const
// static
-ref <IMAPMessageStructure> IMAPMessageStructure::emptyStructure()
+shared_ptr <IMAPMessageStructure> IMAPMessageStructure::emptyStructure()
{
- static ref <IMAPMessageStructure> emptyStructure = vmime::create <IMAPMessageStructure>();
+ static shared_ptr <IMAPMessageStructure> emptyStructure = make_shared <IMAPMessageStructure>();
return emptyStructure;
}
diff --git a/src/net/imap/IMAPSStore.cpp b/src/net/imap/IMAPSStore.cpp
index b467d13a..c9e64f5b 100644
--- a/src/net/imap/IMAPSStore.cpp
+++ b/src/net/imap/IMAPSStore.cpp
@@ -35,7 +35,7 @@ namespace net {
namespace imap {
-IMAPSStore::IMAPSStore(ref <session> sess, ref <security::authenticator> auth)
+IMAPSStore::IMAPSStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth)
: IMAPStore(sess, auth, true)
{
}
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 <session> sess, ref <security::authenticator> auth, const bool secured)
- : store(sess, getInfosInstance(), auth), m_connection(NULL), m_isIMAPS(secured)
+IMAPStore::IMAPStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth, const bool secured)
+ : store(sess, getInfosInstance(), auth), m_connection(null), m_isIMAPS(secured)
{
}
@@ -69,32 +69,35 @@ const string IMAPStore::getProtocolName() const
}
-ref <folder> IMAPStore::getRootFolder()
+shared_ptr <folder> IMAPStore::getRootFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <IMAPFolder>(folder::path(),
- thisRef().dynamicCast <IMAPStore>());
+ return make_shared <IMAPFolder>
+ (folder::path(),
+ dynamicCast <IMAPStore>(shared_from_this()));
}
-ref <folder> IMAPStore::getDefaultFolder()
+shared_ptr <folder> IMAPStore::getDefaultFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <IMAPFolder>(folder::path::component("INBOX"),
- thisRef().dynamicCast <IMAPStore>());
+ return make_shared <IMAPFolder>
+ (folder::path::component("INBOX"),
+ dynamicCast <IMAPStore>(shared_from_this()));
}
-ref <folder> IMAPStore::getFolder(const folder::path& path)
+shared_ptr <folder> IMAPStore::getFolder(const folder::path& path)
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <IMAPFolder>(path, thisRef().dynamicCast <IMAPStore>());
+ return make_shared <IMAPFolder>
+ (path, dynamicCast <IMAPStore>(shared_from_this()));
}
@@ -109,8 +112,8 @@ void IMAPStore::connect()
if (isConnected())
throw exceptions::already_connected();
- m_connection = vmime::create <IMAPConnection>
- (thisRef().dynamicCast <IMAPStore>(), getAuthenticator());
+ m_connection = make_shared <IMAPConnection>
+ (dynamicCast <IMAPStore>(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 <connectionInfos> IMAPStore::getConnectionInfos() const
+shared_ptr <connectionInfos> IMAPStore::getConnectionInfos() const
{
if (m_connection == NULL)
- return NULL;
+ return null;
return m_connection->getConnectionInfos();
}
-ref <IMAPConnection> IMAPStore::getConnection()
+shared_ptr <IMAPConnection> 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 <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> 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 <IMAPConnection> IMAPStore::connection()
+shared_ptr <IMAPConnection> IMAPStore::connection()
{
return (m_connection);
}
diff --git a/src/net/imap/IMAPUtils.cpp b/src/net/imap/IMAPUtils.cpp
index caaf6575..bf310414 100644
--- a/src/net/imap/IMAPUtils.cpp
+++ b/src/net/imap/IMAPUtils.cpp
@@ -544,7 +544,7 @@ const string IMAPUtils::dateTime(const vmime::datetime& date)
// static
const string IMAPUtils::buildFetchRequest
- (ref <IMAPConnection> cnt, const messageSet& msgs, const fetchAttributes& options)
+ (shared_ptr <IMAPConnection> cnt, const messageSet& msgs, const fetchAttributes& options)
{
// Example:
// C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)])
@@ -649,7 +649,7 @@ void IMAPUtils::convertAddressList
string email = addr.addr_mailbox()->value()
+ "@" + addr.addr_host()->value();
- dest.appendMailbox(vmime::create <mailbox>(name, email));
+ dest.appendMailbox(make_shared <mailbox>(name, email));
}
}
diff --git a/src/net/maildir/format/courierMaildirFormat.cpp b/src/net/maildir/format/courierMaildirFormat.cpp
index 346b9c67..a948de3e 100644
--- a/src/net/maildir/format/courierMaildirFormat.cpp
+++ b/src/net/maildir/format/courierMaildirFormat.cpp
@@ -41,7 +41,7 @@ namespace maildir {
namespace format {
-courierMaildirFormat::courierMaildirFormat(ref <context> ctx)
+courierMaildirFormat::courierMaildirFormat(shared_ptr <context> ctx)
: maildirFormat(ctx)
{
}
@@ -55,19 +55,19 @@ const string courierMaildirFormat::getName() const
void courierMaildirFormat::createFolder(const folder::path& path)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY)))
throw exceptions::invalid_folder_name();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
- ref <utility::file> newDir = fsf->create
+ shared_ptr <utility::file> newDir = fsf->create
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
- ref <utility::file> tmpDir = fsf->create
+ shared_ptr <utility::file> tmpDir = fsf->create
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
- ref <utility::file> curDir = fsf->create
+ shared_ptr <utility::file> curDir = fsf->create
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
rootDir->createDirectory(true);
@@ -76,7 +76,7 @@ void courierMaildirFormat::createFolder(const folder::path& path)
tmpDir->createDirectory(false);
curDir->createDirectory(false);
- ref <utility::file> maildirFile = fsf->create
+ shared_ptr <utility::file> maildirFile = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY)
/ utility::file::path::component("maildirfolder"));
@@ -86,7 +86,7 @@ void courierMaildirFormat::createFolder(const folder::path& path)
void courierMaildirFormat::destroyFolder(const folder::path& path)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
// Recursively delete directories of subfolders
const std::vector <folder::path> folders = listFolders(path, true);
@@ -125,7 +125,7 @@ void courierMaildirFormat::renameFolder
void courierMaildirFormat::renameFolderImpl
(const folder::path& oldPath, const folder::path& newPath)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
const utility::file::path oldFSPath =
folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY);
@@ -133,26 +133,26 @@ void courierMaildirFormat::renameFolderImpl
const utility::file::path newFSPath =
folderPathToFileSystemPath(newPath, ROOT_DIRECTORY);
- ref <utility::file> rootDir = fsf->create(oldFSPath);
+ shared_ptr <utility::file> rootDir = fsf->create(oldFSPath);
rootDir->rename(newFSPath);
}
bool courierMaildirFormat::folderExists(const folder::path& path) const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
- ref <utility::file> newDir = fsf->create
+ shared_ptr <utility::file> newDir = fsf->create
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
- ref <utility::file> tmpDir = fsf->create
+ shared_ptr <utility::file> tmpDir = fsf->create
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
- ref <utility::file> curDir = fsf->create
+ shared_ptr <utility::file> curDir = fsf->create
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
- ref <utility::file> maildirFile = fsf->create
+ shared_ptr <utility::file> maildirFile = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY)
/ utility::file::path::component("maildirfolder"));
@@ -260,9 +260,9 @@ const std::vector <folder::path> courierMaildirFormat::listFolders
bool courierMaildirFormat::listDirectories(const folder::path& root,
std::vector <string>& dirs, const bool onlyTestForExistence) const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(getContext()->getStore()->getFileSystemPath());
if (rootDir->exists())
@@ -278,11 +278,11 @@ bool courierMaildirFormat::listDirectories(const folder::path& root,
}
// Enumerate directories
- ref <utility::fileIterator> it = rootDir->getFiles();
+ shared_ptr <utility::fileIterator> it = rootDir->getFiles();
while (it->hasMoreElements())
{
- ref <utility::file> file = it->nextElement();
+ shared_ptr <utility::file> file = it->nextElement();
if (isSubfolderDirectory(*file))
{
@@ -502,24 +502,24 @@ const folder::path::component courierMaildirFormat::fromModifiedUTF7(const strin
bool courierMaildirFormat::supports() const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(getContext()->getStore()->getFileSystemPath());
if (rootDir->exists())
{
// Try to find a file named "maildirfolder", which indicates
// the Maildir is in Courier format
- ref <utility::fileIterator> it = rootDir->getFiles();
+ shared_ptr <utility::fileIterator> it = rootDir->getFiles();
while (it->hasMoreElements())
{
- ref <utility::file> file = it->nextElement();
+ shared_ptr <utility::file> file = it->nextElement();
if (isSubfolderDirectory(*file))
{
- ref <utility::file> folderFile = fsf->create
+ shared_ptr <utility::file> folderFile = fsf->create
(file->getFullPath() / utility::file::path::component("maildirfolder"));
if (folderFile->exists() && folderFile->isFile())
diff --git a/src/net/maildir/format/kmailMaildirFormat.cpp b/src/net/maildir/format/kmailMaildirFormat.cpp
index 0f81b10a..70c9b909 100644
--- a/src/net/maildir/format/kmailMaildirFormat.cpp
+++ b/src/net/maildir/format/kmailMaildirFormat.cpp
@@ -41,7 +41,7 @@ namespace maildir {
namespace format {
-kmailMaildirFormat::kmailMaildirFormat(ref <context> ctx)
+kmailMaildirFormat::kmailMaildirFormat(shared_ptr <context> ctx)
: maildirFormat(ctx)
{
}
@@ -55,19 +55,19 @@ const string kmailMaildirFormat::getName() const
void kmailMaildirFormat::createFolder(const folder::path& path)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY)))
throw exceptions::invalid_folder_name();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
- ref <utility::file> newDir = fsf->create
+ shared_ptr <utility::file> newDir = fsf->create
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
- ref <utility::file> tmpDir = fsf->create
+ shared_ptr <utility::file> tmpDir = fsf->create
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
- ref <utility::file> curDir = fsf->create
+ shared_ptr <utility::file> curDir = fsf->create
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
rootDir->createDirectory(true);
@@ -81,7 +81,7 @@ void kmailMaildirFormat::createFolder(const folder::path& path)
void kmailMaildirFormat::destroyFolder(const folder::path& path)
{
// Delete 'folder' and '.folder.directory' directories
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
maildirUtils::recursiveFSDelete(fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY))); // root
@@ -93,16 +93,16 @@ void kmailMaildirFormat::destroyFolder(const folder::path& path)
bool kmailMaildirFormat::folderExists(const folder::path& path) const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
- ref <utility::file> newDir = fsf->create
+ shared_ptr <utility::file> newDir = fsf->create
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
- ref <utility::file> tmpDir = fsf->create
+ shared_ptr <utility::file> tmpDir = fsf->create
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
- ref <utility::file> curDir = fsf->create
+ shared_ptr <utility::file> curDir = fsf->create
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
return rootDir->exists() && rootDir->isDirectory() &&
@@ -183,18 +183,18 @@ const std::vector <folder::path> kmailMaildirFormat::listFolders
void kmailMaildirFormat::listFoldersImpl
(std::vector <folder::path>& list, const folder::path& root, const bool recursive) const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create(folderPathToFileSystemPath(root,
+ shared_ptr <utility::file> rootDir = fsf->create(folderPathToFileSystemPath(root,
root.isEmpty() ? ROOT_DIRECTORY : CONTAINER_DIRECTORY));
if (rootDir->exists())
{
- ref <utility::fileIterator> it = rootDir->getFiles();
+ shared_ptr <utility::fileIterator> it = rootDir->getFiles();
while (it->hasMoreElements())
{
- ref <utility::file> file = it->nextElement();
+ shared_ptr <utility::file> file = it->nextElement();
if (isSubfolderDirectory(*file))
{
@@ -232,11 +232,11 @@ bool kmailMaildirFormat::isSubfolderDirectory(const utility::file& file)
void kmailMaildirFormat::renameFolder(const folder::path& oldPath, const folder::path& newPath)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY));
- ref <utility::file> contDir = fsf->create
+ shared_ptr <utility::file> contDir = fsf->create
(folderPathToFileSystemPath(oldPath, CONTAINER_DIRECTORY));
try
@@ -283,16 +283,16 @@ void kmailMaildirFormat::renameFolder(const folder::path& oldPath, const folder:
bool kmailMaildirFormat::folderHasSubfolders(const folder::path& path) const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(path, CONTAINER_DIRECTORY));
- ref <utility::fileIterator> it = rootDir->getFiles();
+ shared_ptr <utility::fileIterator> it = rootDir->getFiles();
while (it->hasMoreElements())
{
- ref <utility::file> file = it->nextElement();
+ shared_ptr <utility::file> file = it->nextElement();
if (isSubfolderDirectory(*file))
return true;
diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp
index ae4c17e0..f476d98a 100644
--- a/src/net/maildir/maildirFolder.cpp
+++ b/src/net/maildir/maildirFolder.cpp
@@ -35,8 +35,6 @@
#include "vmime/net/maildir/maildirFormat.hpp"
#include "vmime/net/maildir/maildirFolderStatus.hpp"
-#include "vmime/utility/smartPtr.hpp"
-
#include "vmime/message.hpp"
#include "vmime/exception.hpp"
@@ -51,7 +49,7 @@ namespace net {
namespace maildir {
-maildirFolder::maildirFolder(const folder::path& path, ref <maildirStore> store)
+maildirFolder::maildirFolder(const folder::path& path, shared_ptr <maildirStore> store)
: m_store(store), m_path(path),
m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()),
m_mode(-1), m_open(false), m_unreadMessageCount(0), m_messageCount(0)
@@ -62,7 +60,7 @@ maildirFolder::maildirFolder(const folder::path& path, ref <maildirStore> store)
maildirFolder::~maildirFolder()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (store)
{
@@ -80,7 +78,7 @@ maildirFolder::~maildirFolder()
void maildirFolder::onStoreDisconnected()
{
- m_store = NULL;
+ m_store.reset();
}
@@ -106,7 +104,7 @@ int maildirFolder::getFlags()
{
int flags = 0;
- if (m_store.acquire()->getFormat()->folderHasSubfolders(m_path))
+ if (m_store.lock()->getFormat()->folderHasSubfolders(m_path))
flags |= FLAG_CHILDREN; // Contains at least one sub-folder
return (flags);
@@ -127,7 +125,7 @@ const folder::path maildirFolder::getFullPath() const
void maildirFolder::open(const int mode, bool /* failIfModeIsNotAvailable */)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -145,7 +143,7 @@ void maildirFolder::open(const int mode, bool /* failIfModeIsNotAvailable */)
void maildirFolder::close(const bool expunge)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -193,7 +191,7 @@ void maildirFolder::unregisterMessage(maildirMessage* msg)
void maildirFolder::create(const int /* type */)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -215,9 +213,9 @@ void maildirFolder::create(const int /* type */)
}
// Notify folder created
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_CREATED, m_path, m_path);
notifyFolder(event);
@@ -226,7 +224,7 @@ void maildirFolder::create(const int /* type */)
void maildirFolder::destroy()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -244,9 +242,9 @@ void maildirFolder::destroy()
}
// Notify folder deleted
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_DELETED, m_path, m_path);
notifyFolder(event);
@@ -255,7 +253,7 @@ void maildirFolder::destroy()
bool maildirFolder::exists()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
return store->getFormat()->folderExists(m_path);
}
@@ -269,42 +267,42 @@ bool maildirFolder::isOpen() const
void maildirFolder::scanFolder()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
try
{
m_messageCount = 0;
m_unreadMessageCount = 0;
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path newDirPath = store->getFormat()->folderPathToFileSystemPath
(m_path, maildirFormat::NEW_DIRECTORY);
- ref <utility::file> newDir = fsf->create(newDirPath);
+ shared_ptr <utility::file> newDir = fsf->create(newDirPath);
utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath
(m_path, maildirFormat::CUR_DIRECTORY);
- ref <utility::file> curDir = fsf->create(curDirPath);
+ shared_ptr <utility::file> curDir = fsf->create(curDirPath);
// New received messages (new/)
- ref <utility::fileIterator> nit = newDir->getFiles();
+ shared_ptr <utility::fileIterator> nit = newDir->getFiles();
std::vector <utility::file::path::component> newMessageFilenames;
while (nit->hasMoreElements())
{
- ref <utility::file> file = nit->nextElement();
+ shared_ptr <utility::file> file = nit->nextElement();
if (maildirUtils::isMessageFile(*file))
newMessageFilenames.push_back(file->getFullPath().getLastComponent());
}
// Current messages (cur/)
- ref <utility::fileIterator> cit = curDir->getFiles();
+ shared_ptr <utility::fileIterator> cit = curDir->getFiles();
std::vector <utility::file::path::component> curMessageFilenames;
while (cit->hasMoreElements())
{
- ref <utility::file> file = cit->nextElement();
+ shared_ptr <utility::file> file = cit->nextElement();
if (maildirUtils::isMessageFile(*file))
curMessageFilenames.push_back(file->getFullPath().getLastComponent());
@@ -354,7 +352,7 @@ void maildirFolder::scanFolder()
maildirUtils::buildFilename(maildirUtils::extractId(*it), 0);
// Move messages from 'new' to 'cur'
- ref <utility::file> file = fsf->create(newDirPath / *it);
+ shared_ptr <utility::file> file = fsf->create(newDirPath / *it);
file->rename(curDirPath / newFilename);
// Append to message list
@@ -406,7 +404,7 @@ void maildirFolder::scanFolder()
}
-ref <message> maildirFolder::getMessage(const int num)
+shared_ptr <message> maildirFolder::getMessage(const int num)
{
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
@@ -414,12 +412,12 @@ ref <message> maildirFolder::getMessage(const int num)
if (num < 1 || num > m_messageCount)
throw exceptions::message_not_found();
- return vmime::create <maildirMessage>
- (thisRef().dynamicCast <maildirFolder>(), num);
+ return make_shared <maildirMessage>
+ (dynamicCast <maildirFolder>(shared_from_this()), num);
}
-std::vector <ref <message> > maildirFolder::getMessages(const messageSet& msgs)
+std::vector <shared_ptr <message> > maildirFolder::getMessages(const messageSet& msgs)
{
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
@@ -428,15 +426,15 @@ std::vector <ref <message> > maildirFolder::getMessages(const messageSet& msgs)
{
const std::vector <int> numbers = maildirUtils::messageSetToNumberList(msgs);
- std::vector <ref <message> > messages;
- ref <maildirFolder> thisFolder = thisRef().dynamicCast <maildirFolder>();
+ std::vector <shared_ptr <message> > messages;
+ shared_ptr <maildirFolder> thisFolder = dynamicCast <maildirFolder>(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 <maildirMessage>(thisFolder, *it));
+ messages.push_back(make_shared <maildirMessage>(thisFolder, *it));
}
return messages;
@@ -454,25 +452,25 @@ int maildirFolder::getMessageCount()
}
-ref <folder> maildirFolder::getFolder(const folder::path::component& name)
+shared_ptr <folder> maildirFolder::getFolder(const folder::path::component& name)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
- return vmime::create <maildirFolder>(m_path / name, store);
+ return make_shared <maildirFolder>(m_path / name, store);
}
-std::vector <ref <folder> > maildirFolder::getFolders(const bool recursive)
+std::vector <shared_ptr <folder> > maildirFolder::getFolders(const bool recursive)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!isOpen() && !store)
throw exceptions::illegal_state("Store disconnected");
- std::vector <ref <folder> > list;
+ std::vector <shared_ptr <folder> > list;
listFolders(list, recursive);
@@ -480,9 +478,9 @@ std::vector <ref <folder> > maildirFolder::getFolders(const bool recursive)
}
-void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool recursive)
+void maildirFolder::listFolders(std::vector <shared_ptr <folder> >& list, const bool recursive)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
try
{
@@ -493,8 +491,8 @@ void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool re
for (std::vector <folder::path>::size_type i = 0, n = pathList.size() ; i < n ; ++i)
{
- ref <maildirFolder> subFolder =
- vmime::create <maildirFolder>(pathList[i], store);
+ shared_ptr <maildirFolder> subFolder =
+ make_shared <maildirFolder>(pathList[i], store);
list.push_back(subFolder);
}
@@ -508,7 +506,7 @@ void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool re
void maildirFolder::rename(const folder::path& newPath)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -533,9 +531,9 @@ void maildirFolder::rename(const folder::path& newPath)
m_path = newPath;
m_name = newPath.getLastComponent();
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_RENAMED, oldPath, newPath);
notifyFolder(event);
@@ -549,9 +547,9 @@ void maildirFolder::rename(const folder::path& newPath)
(*it)->m_path = newPath;
(*it)->m_name = newPath.getLastComponent();
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- ((*it)->thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>((*it)->shared_from_this()),
events::folderEvent::TYPE_RENAMED, oldPath, newPath);
(*it)->notifyFolder(event);
@@ -562,9 +560,9 @@ void maildirFolder::rename(const folder::path& newPath)
(*it)->m_path.renameParent(oldPath, newPath);
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- ((*it)->thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>((*it)->shared_from_this()),
events::folderEvent::TYPE_RENAMED, oldPath, (*it)->m_path);
(*it)->notifyFolder(event);
@@ -583,7 +581,7 @@ void maildirFolder::deleteMessages(const messageSet& msgs)
void maildirFolder::setMessageFlags
(const messageSet& msgs, const int flags, const int mode)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -597,7 +595,7 @@ void maildirFolder::setMessageFlags
const std::vector <int> nums = maildirUtils::messageSetToNumberList(msgs);
// Change message flags
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path curDirPath = store->getFormat()->
folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY);
@@ -610,7 +608,7 @@ void maildirFolder::setMessageFlags
try
{
const utility::file::path::component path = m_messageInfos[num].path;
- ref <utility::file> file = fsf->create(curDirPath / path);
+ shared_ptr <utility::file> file = fsf->create(curDirPath / path);
int newFlags = maildirUtils::extractFlags(path);
@@ -690,9 +688,9 @@ void maildirFolder::setMessageFlags
}
// 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, nums);
notifyMessageChanged(event);
@@ -706,7 +704,7 @@ void maildirFolder::setMessageFlags
}
-void maildirFolder::addMessage(ref <vmime::message> msg, const int flags,
+void maildirFolder::addMessage(shared_ptr <vmime::message> msg, const int flags,
vmime::datetime* date, utility::progressListener* progress)
{
std::ostringstream oss;
@@ -724,7 +722,7 @@ void maildirFolder::addMessage(ref <vmime::message> msg, const int flags,
void maildirFolder::addMessage(utility::inputStream& is, const int size,
const int flags, vmime::datetime* /* date */, utility::progressListener* progress)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -733,7 +731,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
else if (m_mode == MODE_READ_ONLY)
throw exceptions::illegal_state("Folder is read-only");
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path tmpDirPath = store->getFormat()->
folderPathToFileSystemPath(m_path,maildirFormat::TMP_DIRECTORY);
@@ -749,7 +747,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
try
{
- ref <utility::file> tmpDir = fsf->create(tmpDirPath);
+ shared_ptr <utility::file> tmpDir = fsf->create(tmpDirPath);
tmpDir->createDirectory(true);
}
catch (exceptions::filesystem_exception&)
@@ -759,7 +757,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
try
{
- ref <utility::file> curDir = fsf->create(dstDirPath);
+ shared_ptr <utility::file> curDir = fsf->create(dstDirPath);
curDir->createDirectory(true);
}
catch (exceptions::filesystem_exception&)
@@ -785,9 +783,9 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
std::vector <int> nums;
nums.push_back(m_messageCount);
- 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);
@@ -804,9 +802,9 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
(*it)->m_messageInfos.resize(m_messageInfos.size());
std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin());
- 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);
@@ -821,9 +819,9 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
utility::inputStream& is, const utility::stream::size_type size,
utility::progressListener* progress)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> file = fsf->create(tmpDirPath / filename);
+ shared_ptr <utility::file> file = fsf->create(tmpDirPath / filename);
if (progress)
progress->start(size);
@@ -833,8 +831,8 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
{
file->createFile();
- ref <utility::fileWriter> fw = file->getFileWriter();
- ref <utility::outputStream> os = fw->getOutputStream();
+ shared_ptr <utility::fileWriter> fw = file->getFileWriter();
+ shared_ptr <utility::outputStream> os = fw->getOutputStream();
utility::stream::value_type buffer[65536];
utility::stream::size_type total = 0;
@@ -863,7 +861,7 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
// Delete temporary file
try
{
- ref <utility::file> file = fsf->create(tmpDirPath / filename);
+ shared_ptr <utility::file> file = fsf->create(tmpDirPath / filename);
file->remove();
}
catch (exceptions::filesystem_exception&)
@@ -888,7 +886,7 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
try
{
file->remove();
- ref <utility::file> file = fsf->create(dstDirPath / filename);
+ shared_ptr <utility::file> file = fsf->create(dstDirPath / filename);
file->remove();
}
catch (exceptions::filesystem_exception&)
@@ -906,14 +904,14 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msgs)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath
(m_path, maildirFormat::CUR_DIRECTORY);
@@ -926,7 +924,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
// Create destination directories
try
{
- ref <utility::file> destTmpDir = fsf->create(destTmpDirPath);
+ shared_ptr <utility::file> destTmpDir = fsf->create(destTmpDirPath);
destTmpDir->createDirectory(true);
}
catch (exceptions::filesystem_exception&)
@@ -936,7 +934,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
try
{
- ref <utility::file> destCurDir = fsf->create(destCurDirPath);
+ shared_ptr <utility::file> destCurDir = fsf->create(destCurDirPath);
destCurDir->createDirectory(true);
}
catch (exceptions::filesystem_exception&)
@@ -959,9 +957,9 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
const utility::file::path::component filename =
maildirUtils::buildFilename(maildirUtils::generateId(), flags);
- ref <utility::file> file = fsf->create(curDirPath / msg.path);
- ref <utility::fileReader> fr = file->getFileReader();
- ref <utility::inputStream> is = fr->getInputStream();
+ shared_ptr <utility::file> file = fsf->create(curDirPath / msg.path);
+ shared_ptr <utility::fileReader> fr = file->getFileReader();
+ shared_ptr <utility::inputStream> is = fr->getInputStream();
copyMessageImpl(destTmpDirPath, destCurDirPath,
filename, *is, file->getLength(), NULL);
@@ -979,7 +977,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
void maildirFolder::notifyMessagesCopied(const folder::path& dest)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
for (std::list <maildirFolder*>::iterator it = store->m_folders.begin() ;
it != store->m_folders.end() ; ++it)
@@ -1002,22 +1000,22 @@ void maildirFolder::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> maildirFolder::getStatus()
+shared_ptr <folderStatus> maildirFolder::getStatus()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
const int oldCount = m_messageCount;
scanFolder();
- ref <maildirFolderStatus> status = vmime::create <maildirFolderStatus>();
+ shared_ptr <maildirFolderStatus> status = make_shared <maildirFolderStatus>();
status->setMessageCount(m_messageCount);
status->setUnseenCount(m_unreadMessageCount);
@@ -1031,9 +1029,9 @@ ref <folderStatus> maildirFolder::getStatus()
for (int i = oldCount + 1, j = 0 ; i <= m_messageCount ; ++i, ++j)
nums[j] = i;
- 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);
@@ -1050,9 +1048,9 @@ ref <folderStatus> maildirFolder::getStatus()
(*it)->m_messageInfos.resize(m_messageInfos.size());
std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin());
- 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);
@@ -1066,7 +1064,7 @@ ref <folderStatus> maildirFolder::getStatus()
void maildirFolder::expunge()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1075,7 +1073,7 @@ void maildirFolder::expunge()
else if (m_mode == MODE_READ_ONLY)
throw exceptions::illegal_state("Folder is read-only");
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path curDirPath = store->getFormat()->
folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY);
@@ -1106,7 +1104,7 @@ void maildirFolder::expunge()
// Delete file from file system
try
{
- ref <utility::file> file = fsf->create(curDirPath / infos.path);
+ shared_ptr <utility::file> file = fsf->create(curDirPath / infos.path);
file->remove();
}
catch (exceptions::filesystem_exception& e)
@@ -1126,9 +1124,9 @@ void maildirFolder::expunge()
m_unreadMessageCount -= unreadCount;
// Notify message expunged
- 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_REMOVED, nums);
notifyMessageCount(event);
@@ -1145,9 +1143,9 @@ void maildirFolder::expunge()
(*it)->m_messageInfos.resize(m_messageInfos.size());
std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin());
- 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_REMOVED, nums);
(*it)->notifyMessageCount(event);
@@ -1156,31 +1154,31 @@ void maildirFolder::expunge()
}
-ref <folder> maildirFolder::getParent()
+shared_ptr <folder> maildirFolder::getParent()
{
if (m_path.isEmpty())
- return NULL;
+ return null;
else
- return vmime::create <maildirFolder>(m_path.getParent(), m_store.acquire());
+ return make_shared <maildirFolder>(m_path.getParent(), m_store.lock());
}
-ref <const store> maildirFolder::getStore() const
+shared_ptr <const store> maildirFolder::getStore() const
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <store> maildirFolder::getStore()
+shared_ptr <store> maildirFolder::getStore()
{
- return m_store.acquire();
+ return m_store.lock();
}
-void maildirFolder::fetchMessages(std::vector <ref <message> >& msg,
+void maildirFolder::fetchMessages(std::vector <shared_ptr <message> >& msg,
const fetchAttributes& options, utility::progressListener* progress)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1193,12 +1191,12 @@ void maildirFolder::fetchMessages(std::vector <ref <message> >& msg,
if (progress)
progress->start(total);
- ref <maildirFolder> thisFolder = thisRef().dynamicCast <maildirFolder>();
+ shared_ptr <maildirFolder> thisFolder = dynamicCast <maildirFolder>(shared_from_this());
- 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 <maildirMessage>()->fetch(thisFolder, options);
+ dynamicCast <maildirMessage>(*it)->fetch(thisFolder, options);
if (progress)
progress->progress(++current, total);
@@ -1209,17 +1207,17 @@ void maildirFolder::fetchMessages(std::vector <ref <message> >& msg,
}
-void maildirFolder::fetchMessage(ref <message> msg, const fetchAttributes& options)
+void maildirFolder::fetchMessage(shared_ptr <message> msg, const fetchAttributes& options)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
- msg.dynamicCast <maildirMessage>()->fetch
- (thisRef().dynamicCast <maildirFolder>(), options);
+ dynamicCast <maildirMessage>(msg)->fetch
+ (dynamicCast <maildirFolder>(shared_from_this()), options);
}
@@ -1234,7 +1232,7 @@ int maildirFolder::getFetchCapabilities() const
const utility::file::path maildirFolder::getMessageFSPath(const int number) const
{
- utility::file::path curDirPath = m_store.acquire()->getFormat()->
+ utility::file::path curDirPath = m_store.lock()->getFormat()->
folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY);
return (curDirPath / m_messageInfos[number - 1].path);
diff --git a/src/net/maildir/maildirFolderStatus.cpp b/src/net/maildir/maildirFolderStatus.cpp
index bc00ba28..9ee84dba 100644
--- a/src/net/maildir/maildirFolderStatus.cpp
+++ b/src/net/maildir/maildirFolderStatus.cpp
@@ -74,9 +74,9 @@ void maildirFolderStatus::setUnseenCount(const unsigned int unseen)
}
-ref <folderStatus> maildirFolderStatus::clone() const
+shared_ptr <folderStatus> maildirFolderStatus::clone() const
{
- return vmime::create <maildirFolderStatus>(*this);
+ return make_shared <maildirFolderStatus>(*this);
}
diff --git a/src/net/maildir/maildirFormat.cpp b/src/net/maildir/maildirFormat.cpp
index f1e9c66e..f7a3c8fe 100644
--- a/src/net/maildir/maildirFormat.cpp
+++ b/src/net/maildir/maildirFormat.cpp
@@ -50,15 +50,15 @@ const utility::file::path::component maildirFormat::NEW_DIR("new", vmime::charse
// maildirFormat::context
//
-maildirFormat::context::context(ref <maildirStore> store)
+maildirFormat::context::context(shared_ptr <maildirStore> store)
: m_store(store)
{
}
-ref <maildirStore> maildirFormat::context::getStore() const
+shared_ptr <maildirStore> maildirFormat::context::getStore() const
{
- return m_store.acquire().constCast <maildirStore>();
+ return constCast <maildirStore>(m_store.lock());
}
@@ -66,37 +66,37 @@ ref <maildirStore> maildirFormat::context::getStore() const
// maildirFormat
//
-maildirFormat::maildirFormat(ref <context> ctx)
+maildirFormat::maildirFormat(shared_ptr <context> ctx)
: m_context(ctx)
{
}
-ref <maildirFormat::context> maildirFormat::getContext()
+shared_ptr <maildirFormat::context> maildirFormat::getContext()
{
return m_context;
}
-ref <const maildirFormat::context> maildirFormat::getContext() const
+shared_ptr <const maildirFormat::context> maildirFormat::getContext() const
{
return m_context;
}
// static
-ref <maildirFormat> maildirFormat::detect(ref <maildirStore> store)
+shared_ptr <maildirFormat> maildirFormat::detect(shared_ptr <maildirStore> store)
{
- ref <context> ctx = create <context>(store);
+ shared_ptr <context> ctx = make_shared <context>(store);
// Try Courier format
- ref <maildirFormat> fmt = create <format::courierMaildirFormat>(ctx);
+ shared_ptr <maildirFormat> fmt = make_shared <format::courierMaildirFormat>(ctx);
if (fmt->supports())
return fmt;
// Default is KMail format
- return create <format::kmailMaildirFormat>(ctx);
+ return make_shared <format::kmailMaildirFormat>(ctx);
}
diff --git a/src/net/maildir/maildirMessage.cpp b/src/net/maildir/maildirMessage.cpp
index d20481d4..88d743b2 100644
--- a/src/net/maildir/maildirMessage.cpp
+++ b/src/net/maildir/maildirMessage.cpp
@@ -47,9 +47,9 @@ namespace net {
namespace maildir {
-maildirMessage::maildirMessage(ref <maildirFolder> folder, const int num)
+maildirMessage::maildirMessage(shared_ptr <maildirFolder> folder, const int num)
: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
- m_expunged(false), m_structure(NULL)
+ m_expunged(false), m_structure(null)
{
folder->registerMessage(this);
}
@@ -57,7 +57,7 @@ maildirMessage::maildirMessage(ref <maildirFolder> folder, const int num)
maildirMessage::~maildirMessage()
{
- ref <maildirFolder> folder = m_folder.acquire();
+ shared_ptr <maildirFolder> folder = m_folder.lock();
if (folder)
folder->unregisterMessage(this);
@@ -66,7 +66,7 @@ maildirMessage::~maildirMessage()
void maildirMessage::onFolderClosed()
{
- m_folder = NULL;
+ m_folder.reset();
}
@@ -97,7 +97,7 @@ bool maildirMessage::isExpunged() const
}
-ref <const messageStructure> maildirMessage::getStructure() const
+shared_ptr <const messageStructure> maildirMessage::getStructure() const
{
if (m_structure == NULL)
throw exceptions::unfetched_object();
@@ -106,7 +106,7 @@ ref <const messageStructure> maildirMessage::getStructure() const
}
-ref <messageStructure> maildirMessage::getStructure()
+shared_ptr <messageStructure> maildirMessage::getStructure()
{
if (m_structure == NULL)
throw exceptions::unfetched_object();
@@ -115,7 +115,7 @@ ref <messageStructure> maildirMessage::getStructure()
}
-ref <const header> maildirMessage::getHeader() const
+shared_ptr <const header> maildirMessage::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
@@ -135,7 +135,7 @@ int maildirMessage::getFlags() const
void maildirMessage::setFlags(const int flags, const int mode)
{
- ref <maildirFolder> folder = m_folder.acquire();
+ shared_ptr <maildirFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
@@ -152,11 +152,11 @@ void maildirMessage::extract(utility::outputStream& os,
}
-void maildirMessage::extractPart(ref <const messagePart> p, utility::outputStream& os,
+void maildirMessage::extractPart(shared_ptr <const messagePart> p, utility::outputStream& os,
utility::progressListener* progress, const int start,
const int length, const bool peek) const
{
- ref <const maildirMessagePart> mp = p.dynamicCast <const maildirMessagePart>();
+ shared_ptr <const maildirMessagePart> mp = dynamicCast <const maildirMessagePart>(p);
extractImpl(os, progress, mp->getBodyParsedOffset(), mp->getBodyParsedLength(),
start, length, peek);
@@ -167,15 +167,15 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis
const int start, const int length, const int partialStart, const int partialLength,
const bool /* peek */) const
{
- ref <const maildirFolder> folder = m_folder.acquire();
+ shared_ptr <const maildirFolder> folder = m_folder.lock();
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
const utility::file::path path = folder->getMessageFSPath(m_num);
- ref <utility::file> file = fsf->create(path);
+ shared_ptr <utility::file> file = fsf->create(path);
- ref <utility::fileReader> reader = file->getFileReader();
- ref <utility::inputStream> is = reader->getInputStream();
+ shared_ptr <utility::fileReader> reader = file->getFileReader();
+ shared_ptr <utility::inputStream> is = reader->getInputStream();
is->skip(start + partialStart);
@@ -210,19 +210,19 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis
}
-void maildirMessage::fetchPartHeader(ref <messagePart> p)
+void maildirMessage::fetchPartHeader(shared_ptr <messagePart> p)
{
- ref <maildirFolder> folder = m_folder.acquire();
+ shared_ptr <maildirFolder> folder = m_folder.lock();
- ref <maildirMessagePart> mp = p.dynamicCast <maildirMessagePart>();
+ shared_ptr <maildirMessagePart> mp = dynamicCast <maildirMessagePart>(p);
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
const utility::file::path path = folder->getMessageFSPath(m_num);
- ref <utility::file> file = fsf->create(path);
+ shared_ptr <utility::file> file = fsf->create(path);
- ref <utility::fileReader> reader = file->getFileReader();
- ref <utility::inputStream> is = reader->getInputStream();
+ shared_ptr <utility::fileReader> reader = file->getFileReader();
+ shared_ptr <utility::inputStream> is = reader->getInputStream();
is->skip(mp->getHeaderParsedOffset());
@@ -246,17 +246,17 @@ void maildirMessage::fetchPartHeader(ref <messagePart> p)
}
-void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes& options)
+void maildirMessage::fetch(shared_ptr <maildirFolder> msgFolder, const fetchAttributes& options)
{
- ref <maildirFolder> folder = m_folder.acquire();
+ shared_ptr <maildirFolder> folder = m_folder.lock();
if (folder != msgFolder)
throw exceptions::folder_not_found();
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
const utility::file::path path = folder->getMessageFSPath(m_num);
- ref <utility::file> file = fsf->create(path);
+ shared_ptr <utility::file> file = fsf->create(path);
if (options.has(fetchAttributes::FLAGS))
m_flags = maildirUtils::extractFlags(path.getLastComponent());
@@ -273,8 +273,8 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes&
{
string contents;
- ref <utility::fileReader> reader = file->getFileReader();
- ref <utility::inputStream> is = reader->getInputStream();
+ shared_ptr <utility::fileReader> reader = file->getFileReader();
+ shared_ptr <utility::inputStream> is = reader->getInputStream();
// Need whole message contents for structure
if (options.has(fetchAttributes::STRUCTURE))
@@ -323,7 +323,7 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes&
// Extract structure
if (options.has(fetchAttributes::STRUCTURE))
{
- m_structure = vmime::create <maildirMessageStructure>(null, msg);
+ m_structure = make_shared <maildirMessageStructure>(shared_ptr <maildirMessagePart>(), msg);
}
// Extract some header fields or whole header
@@ -338,23 +338,23 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes&
}
-ref <header> maildirMessage::getOrCreateHeader()
+shared_ptr <header> maildirMessage::getOrCreateHeader()
{
if (m_header != NULL)
return (m_header);
else
- return (m_header = vmime::create <header>());
+ return (m_header = make_shared <header>());
}
-ref <vmime::message> maildirMessage::getParsedMessage()
+shared_ptr <vmime::message> maildirMessage::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/maildir/maildirMessagePart.cpp b/src/net/maildir/maildirMessagePart.cpp
index 75086ec3..683e259e 100644
--- a/src/net/maildir/maildirMessagePart.cpp
+++ b/src/net/maildir/maildirMessagePart.cpp
@@ -36,8 +36,8 @@ namespace net {
namespace maildir {
-maildirMessagePart::maildirMessagePart(ref <maildirMessagePart> parent, const int number, const bodyPart& part)
- : m_parent(parent), m_header(NULL), m_number(number)
+maildirMessagePart::maildirMessagePart(shared_ptr <maildirMessagePart> parent, const int number, const bodyPart& part)
+ : m_parent(parent), m_header(null), m_number(number)
{
m_headerParsedOffset = part.getHeader()->getParsedOffset();
m_headerParsedLength = part.getHeader()->getParsedLength();
@@ -59,17 +59,17 @@ maildirMessagePart::~maildirMessagePart()
void maildirMessagePart::initStructure(const bodyPart& part)
{
if (part.getBody()->getPartList().size() == 0)
- m_structure = NULL;
+ m_structure = null;
else
{
- m_structure = vmime::create <maildirMessageStructure>
- (thisRef().dynamicCast <maildirMessagePart>(),
+ m_structure = make_shared <maildirMessageStructure>
+ (dynamicCast <maildirMessagePart>(shared_from_this()),
part.getBody()->getPartList());
}
}
-ref <const messageStructure> maildirMessagePart::getStructure() const
+shared_ptr <const messageStructure> maildirMessagePart::getStructure() const
{
if (m_structure != NULL)
return m_structure;
@@ -78,7 +78,7 @@ ref <const messageStructure> maildirMessagePart::getStructure() const
}
-ref <messageStructure> maildirMessagePart::getStructure()
+shared_ptr <messageStructure> maildirMessagePart::getStructure()
{
if (m_structure != NULL)
return m_structure;
@@ -105,7 +105,7 @@ int maildirMessagePart::getNumber() const
}
-ref <const header> maildirMessagePart::getHeader() const
+shared_ptr <const header> maildirMessagePart::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
@@ -119,7 +119,7 @@ header& maildirMessagePart::getOrCreateHeader()
if (m_header != NULL)
return *m_header;
else
- return *(m_header = vmime::create <header>());
+ return *(m_header = make_shared <header>());
}
diff --git a/src/net/maildir/maildirMessageStructure.cpp b/src/net/maildir/maildirMessageStructure.cpp
index a0473f9e..f3b7cf59 100644
--- a/src/net/maildir/maildirMessageStructure.cpp
+++ b/src/net/maildir/maildirMessageStructure.cpp
@@ -36,7 +36,7 @@ namespace net {
namespace maildir {
-ref <maildirMessageStructure> maildirMessageStructure::m_emptyStructure = vmime::create <maildirMessageStructure>();
+shared_ptr <maildirMessageStructure> maildirMessageStructure::m_emptyStructure = make_shared <maildirMessageStructure>();
maildirMessageStructure::maildirMessageStructure()
@@ -44,20 +44,20 @@ maildirMessageStructure::maildirMessageStructure()
}
-maildirMessageStructure::maildirMessageStructure(ref <maildirMessagePart> parent, const bodyPart& part)
+maildirMessageStructure::maildirMessageStructure(shared_ptr <maildirMessagePart> parent, const bodyPart& part)
{
- vmime::ref <maildirMessagePart> mpart = vmime::create <maildirMessagePart>(parent, 0, part);
+ shared_ptr <maildirMessagePart> mpart = make_shared <maildirMessagePart>(parent, 0, part);
mpart->initStructure(part);
m_parts.push_back(mpart);
}
-maildirMessageStructure::maildirMessageStructure(ref <maildirMessagePart> parent, const std::vector <ref <const vmime::bodyPart> >& list)
+maildirMessageStructure::maildirMessageStructure(shared_ptr <maildirMessagePart> parent, const std::vector <shared_ptr <const vmime::bodyPart> >& list)
{
for (unsigned int i = 0 ; i < list.size() ; ++i)
{
- vmime::ref <maildirMessagePart> mpart = vmime::create <maildirMessagePart>(parent, i, *list[i]);
+ shared_ptr <maildirMessagePart> mpart = make_shared <maildirMessagePart>(parent, i, *list[i]);
mpart->initStructure(*list[i]);
m_parts.push_back(mpart);
@@ -65,13 +65,13 @@ maildirMessageStructure::maildirMessageStructure(ref <maildirMessagePart> parent
}
-ref <const messagePart> maildirMessageStructure::getPartAt(const size_t x) const
+shared_ptr <const messagePart> maildirMessageStructure::getPartAt(const size_t x) const
{
return m_parts[x];
}
-ref <messagePart> maildirMessageStructure::getPartAt(const size_t x)
+shared_ptr <messagePart> maildirMessageStructure::getPartAt(const size_t x)
{
return m_parts[x];
}
@@ -84,7 +84,7 @@ size_t maildirMessageStructure::getPartCount() const
// static
-ref <maildirMessageStructure> maildirMessageStructure::emptyStructure()
+shared_ptr <maildirMessageStructure> maildirMessageStructure::emptyStructure()
{
return m_emptyStructure;
}
diff --git a/src/net/maildir/maildirStore.cpp b/src/net/maildir/maildirStore.cpp
index 0fad6831..c7ceb6fa 100644
--- a/src/net/maildir/maildirStore.cpp
+++ b/src/net/maildir/maildirStore.cpp
@@ -32,8 +32,6 @@
#include "vmime/net/maildir/maildirFolder.hpp"
#include "vmime/net/maildir/maildirFormat.hpp"
-#include "vmime/utility/smartPtr.hpp"
-
#include "vmime/exception.hpp"
#include "vmime/platform.hpp"
@@ -54,7 +52,7 @@ namespace net {
namespace maildir {
-maildirStore::maildirStore(ref <session> sess, ref <security::authenticator> auth)
+maildirStore::maildirStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth)
: store(sess, getInfosInstance(), auth), m_connected(false)
{
}
@@ -80,33 +78,35 @@ const string maildirStore::getProtocolName() const
}
-ref <folder> maildirStore::getRootFolder()
+shared_ptr <folder> maildirStore::getRootFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <maildirFolder>(folder::path(),
- thisRef().dynamicCast <maildirStore>());
+ return make_shared <maildirFolder>
+ (folder::path(),
+ dynamicCast <maildirStore>(shared_from_this()));
}
-ref <folder> maildirStore::getDefaultFolder()
+shared_ptr <folder> maildirStore::getDefaultFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <maildirFolder>(folder::path::component("inbox"),
- thisRef().dynamicCast <maildirStore>());
+ return make_shared <maildirFolder>
+ (folder::path::component("inbox"),
+ dynamicCast <maildirStore>(shared_from_this()));
}
-ref <folder> maildirStore::getFolder(const folder::path& path)
+shared_ptr <folder> maildirStore::getFolder(const folder::path& path)
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <maildirFolder>(path,
- thisRef().dynamicCast <maildirStore>());
+ return make_shared <maildirFolder>
+ (path, dynamicCast <maildirStore>(shared_from_this()));
}
@@ -138,11 +138,11 @@ void maildirStore::connect()
throw exceptions::already_connected();
// Get root directory
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
m_fsPath = fsf->stringToPath(GET_PROPERTY(string, PROPERTY_SERVER_ROOTPATH));
- ref <utility::file> rootDir = fsf->create(m_fsPath);
+ shared_ptr <utility::file> rootDir = fsf->create(m_fsPath);
// Try to create the root directory if it does not exist
if (!(rootDir->exists() && rootDir->isDirectory()))
@@ -157,7 +157,7 @@ void maildirStore::connect()
}
}
- m_format = maildirFormat::detect(thisRef().dynamicCast <maildirStore>());
+ m_format = maildirFormat::detect(dynamicCast <maildirStore>(shared_from_this()));
m_connected = true;
}
@@ -175,9 +175,9 @@ bool maildirStore::isSecuredConnection() const
}
-ref <connectionInfos> maildirStore::getConnectionInfos() const
+shared_ptr <connectionInfos> maildirStore::getConnectionInfos() const
{
- return vmime::create <defaultConnectionInfos>("localhost", static_cast <port_t>(0));
+ return make_shared <defaultConnectionInfos>("localhost", static_cast <port_t>(0));
}
@@ -201,13 +201,13 @@ void maildirStore::noop()
}
-ref <maildirFormat> maildirStore::getFormat()
+shared_ptr <maildirFormat> maildirStore::getFormat()
{
return m_format;
}
-ref <const maildirFormat> maildirStore::getFormat() const
+shared_ptr <const maildirFormat> maildirStore::getFormat() const
{
return m_format;
}
diff --git a/src/net/maildir/maildirUtils.cpp b/src/net/maildir/maildirUtils.cpp
index c4ba2857..5a5ac90f 100644
--- a/src/net/maildir/maildirUtils.cpp
+++ b/src/net/maildir/maildirUtils.cpp
@@ -175,14 +175,14 @@ const utility::file::path::component maildirUtils::generateId()
}
-void maildirUtils::recursiveFSDelete(ref <utility::file> dir)
+void maildirUtils::recursiveFSDelete(shared_ptr <utility::file> dir)
{
- ref <utility::fileIterator> files = dir->getFiles();
+ shared_ptr <utility::fileIterator> files = dir->getFiles();
// First, delete files and subdirectories in this directory
while (files->hasMoreElements())
{
- ref <utility::file> file = files->nextElement();
+ shared_ptr <utility::file> file = files->nextElement();
if (file->isDirectory())
{
diff --git a/src/net/message.cpp b/src/net/message.cpp
index 09fe6321..6765e73c 100644
--- a/src/net/message.cpp
+++ b/src/net/message.cpp
@@ -36,13 +36,13 @@ namespace vmime {
namespace net {
-ref <const messagePart> messagePart::getPartAt(const size_t pos) const
+shared_ptr <const messagePart> messagePart::getPartAt(const size_t pos) const
{
return getStructure()->getPartAt(pos);
}
-ref <messagePart> messagePart::getPartAt(const size_t pos)
+shared_ptr <messagePart> messagePart::getPartAt(const size_t pos)
{
return getStructure()->getPartAt(pos);
}
diff --git a/src/net/messageSet.cpp b/src/net/messageSet.cpp
index 04f1debb..71a8a788 100644
--- a/src/net/messageSet.cpp
+++ b/src/net/messageSet.cpp
@@ -314,8 +314,8 @@ messageSet messageSet::byUID(const std::vector <message::uid>& uids)
else
{
set.m_ranges.push_back(new UIDMessageRange
- (static_cast <std::ostringstream*>(&(std::ostringstream() << rangeStart))->str(),
- static_cast <std::ostringstream*>(&(std::ostringstream() << previous))->str()));
+ (utility::stringUtils::toString(rangeStart),
+ utility::stringUtils::toString(previous)));
previous = current;
rangeStart = current;
@@ -324,8 +324,8 @@ messageSet messageSet::byUID(const std::vector <message::uid>& uids)
}
set.m_ranges.push_back(new UIDMessageRange
- (static_cast <std::ostringstream*>(&(std::ostringstream() << rangeStart))->str(),
- static_cast <std::ostringstream*>(&(std::ostringstream() << previous))->str()));
+ (utility::stringUtils::toString(rangeStart),
+ utility::stringUtils::toString(previous)));
return set;
}
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;
diff --git a/src/net/sendmail/sendmailTransport.cpp b/src/net/sendmail/sendmailTransport.cpp
index 82501575..68c96e51 100644
--- a/src/net/sendmail/sendmailTransport.cpp
+++ b/src/net/sendmail/sendmailTransport.cpp
@@ -36,7 +36,6 @@
#include "vmime/utility/filteredStream.hpp"
#include "vmime/utility/childProcess.hpp"
-#include "vmime/utility/smartPtr.hpp"
#include "vmime/utility/streamUtils.hpp"
@@ -59,7 +58,7 @@ namespace net {
namespace sendmail {
-sendmailTransport::sendmailTransport(ref <session> sess, ref <security::authenticator> auth)
+sendmailTransport::sendmailTransport(shared_ptr <session> sess, shared_ptr <security::authenticator> auth)
: transport(sess, getInfosInstance(), auth), m_connected(false)
{
}
@@ -109,9 +108,9 @@ bool sendmailTransport::isSecuredConnection() const
}
-ref <connectionInfos> sendmailTransport::getConnectionInfos() const
+shared_ptr <connectionInfos> sendmailTransport::getConnectionInfos() const
{
- return vmime::create <defaultConnectionInfos>("localhost", static_cast <port_t>(0));
+ return make_shared <defaultConnectionInfos>("localhost", static_cast <port_t>(0));
}
@@ -182,7 +181,7 @@ void sendmailTransport::internalSend
const utility::file::path path = vmime::platform::getHandler()->
getFileSystemFactory()->stringToPath(m_sendmailPath);
- ref <utility::childProcess> proc =
+ shared_ptr <utility::childProcess> proc =
vmime::platform::getHandler()->
getChildProcessFactory()->create(path);
diff --git a/src/net/service.cpp b/src/net/service.cpp
index 9ff0c394..c52ba592 100644
--- a/src/net/service.cpp
+++ b/src/net/service.cpp
@@ -46,23 +46,23 @@ namespace vmime {
namespace net {
-service::service(ref <session> sess, const serviceInfos& /* infos */,
- ref <security::authenticator> auth)
+service::service(shared_ptr <session> sess, const serviceInfos& /* infos */,
+ shared_ptr <security::authenticator> auth)
: m_session(sess), m_auth(auth)
{
if (!auth)
{
#if VMIME_HAVE_SASL_SUPPORT
- m_auth = vmime::create
+ m_auth = make_shared
<security::sasl::defaultSASLAuthenticator>();
#else
- m_auth = vmime::create
+ m_auth = make_shared
<security::defaultAuthenticator>();
#endif // VMIME_HAVE_SASL_SUPPORT
}
#if VMIME_HAVE_TLS_SUPPORT
- m_certVerifier = vmime::create <security::cert::defaultCertificateVerifier>();
+ m_certVerifier = make_shared <security::cert::defaultCertificateVerifier>();
#endif // VMIME_HAVE_TLS_SUPPORT
m_socketFactory = platform::getHandler()->getSocketFactory();
@@ -74,31 +74,31 @@ service::~service()
}
-ref <const session> service::getSession() const
+shared_ptr <const session> service::getSession() const
{
return (m_session);
}
-ref <session> service::getSession()
+shared_ptr <session> service::getSession()
{
return (m_session);
}
-ref <const security::authenticator> service::getAuthenticator() const
+shared_ptr <const security::authenticator> service::getAuthenticator() const
{
return (m_auth);
}
-ref <security::authenticator> service::getAuthenticator()
+shared_ptr <security::authenticator> service::getAuthenticator()
{
return (m_auth);
}
-void service::setAuthenticator(ref <security::authenticator> auth)
+void service::setAuthenticator(shared_ptr <security::authenticator> auth)
{
m_auth = auth;
}
@@ -106,13 +106,13 @@ void service::setAuthenticator(ref <security::authenticator> auth)
#if VMIME_HAVE_TLS_SUPPORT
-void service::setCertificateVerifier(ref <security::cert::certificateVerifier> cv)
+void service::setCertificateVerifier(shared_ptr <security::cert::certificateVerifier> cv)
{
m_certVerifier = cv;
}
-ref <security::cert::certificateVerifier> service::getCertificateVerifier()
+shared_ptr <security::cert::certificateVerifier> service::getCertificateVerifier()
{
return m_certVerifier;
}
@@ -120,25 +120,25 @@ ref <security::cert::certificateVerifier> service::getCertificateVerifier()
#endif // VMIME_HAVE_TLS_SUPPORT
-void service::setSocketFactory(ref <socketFactory> sf)
+void service::setSocketFactory(shared_ptr <socketFactory> sf)
{
m_socketFactory = sf;
}
-ref <socketFactory> service::getSocketFactory()
+shared_ptr <socketFactory> service::getSocketFactory()
{
return m_socketFactory;
}
-void service::setTimeoutHandlerFactory(ref <timeoutHandlerFactory> thf)
+void service::setTimeoutHandlerFactory(shared_ptr <timeoutHandlerFactory> thf)
{
m_toHandlerFactory = thf;
}
-ref <timeoutHandlerFactory> service::getTimeoutHandlerFactory()
+shared_ptr <timeoutHandlerFactory> service::getTimeoutHandlerFactory()
{
return m_toHandlerFactory;
}
diff --git a/src/net/serviceFactory.cpp b/src/net/serviceFactory.cpp
index c44cbadc..a16098ce 100644
--- a/src/net/serviceFactory.cpp
+++ b/src/net/serviceFactory.cpp
@@ -49,26 +49,26 @@ serviceFactory::~serviceFactory()
}
-serviceFactory* serviceFactory::getInstance()
+shared_ptr <serviceFactory> serviceFactory::getInstance()
{
static serviceFactory instance;
- return (&instance);
+ return shared_ptr <serviceFactory>(&instance, noop_shared_ptr_deleter <serviceFactory>());
}
-ref <service> serviceFactory::create
- (ref <session> sess, const string& protocol,
- ref <security::authenticator> auth)
+shared_ptr <service> serviceFactory::create
+ (shared_ptr <session> sess, const string& protocol,
+ shared_ptr <security::authenticator> auth)
{
return (getServiceByProtocol(protocol)->create(sess, auth));
}
-ref <service> serviceFactory::create
- (ref <session> sess, const utility::url& u,
- ref <security::authenticator> auth)
+shared_ptr <service> serviceFactory::create
+ (shared_ptr <session> sess, const utility::url& u,
+ shared_ptr <security::authenticator> auth)
{
- ref <service> serv = create(sess, u.getProtocol(), auth);
+ shared_ptr <service> serv = create(sess, u.getProtocol(), auth);
sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.address"] = u.getHost();
@@ -90,11 +90,11 @@ ref <service> serviceFactory::create
}
-ref <const serviceFactory::registeredService> serviceFactory::getServiceByProtocol(const string& protocol) const
+shared_ptr <const serviceFactory::registeredService> serviceFactory::getServiceByProtocol(const string& protocol) const
{
const string name(utility::stringUtils::toLower(protocol));
- for (std::vector <ref <registeredService> >::const_iterator it = m_services.begin() ;
+ for (std::vector <shared_ptr <registeredService> >::const_iterator it = m_services.begin() ;
it != m_services.end() ; ++it)
{
if ((*it)->getName() == name)
@@ -111,17 +111,17 @@ size_t serviceFactory::getServiceCount() const
}
-ref <const serviceFactory::registeredService> serviceFactory::getServiceAt(const size_t pos) const
+shared_ptr <const serviceFactory::registeredService> serviceFactory::getServiceAt(const size_t pos) const
{
return (m_services[pos]);
}
-const std::vector <ref <const serviceFactory::registeredService> > serviceFactory::getServiceList() const
+const std::vector <shared_ptr <const serviceFactory::registeredService> > serviceFactory::getServiceList() const
{
- std::vector <ref <const registeredService> > res;
+ std::vector <shared_ptr <const registeredService> > res;
- for (std::vector <ref <registeredService> >::const_iterator it = m_services.begin() ;
+ for (std::vector <shared_ptr <registeredService> >::const_iterator it = m_services.begin() ;
it != m_services.end() ; ++it)
{
res.push_back(*it);
@@ -131,7 +131,7 @@ const std::vector <ref <const serviceFactory::registeredService> > serviceFactor
}
-void serviceFactory::registerService(ref <registeredService> reg)
+void serviceFactory::registerService(shared_ptr <registeredService> reg)
{
m_services.push_back(reg);
}
diff --git a/src/net/serviceInfos.cpp b/src/net/serviceInfos.cpp
index 751bae3f..8de0529e 100644
--- a/src/net/serviceInfos.cpp
+++ b/src/net/serviceInfos.cpp
@@ -85,7 +85,7 @@ serviceInfos::~serviceInfos()
}
-bool serviceInfos::hasProperty(ref <session> s, const property& p) const
+bool serviceInfos::hasProperty(shared_ptr <session> s, const property& p) const
{
return s->getProperties().hasProperty(getPropertyPrefix() + p.getName());
}
diff --git a/src/net/serviceRegistration.inl b/src/net/serviceRegistration.inl
index 084aed9e..2366fe01 100644
--- a/src/net/serviceRegistration.inl
+++ b/src/net/serviceRegistration.inl
@@ -41,11 +41,11 @@ public:
{
}
- ref <service> create
- (ref <session> sess,
- ref <security::authenticator> auth) const
+ shared_ptr <service> create
+ (shared_ptr <session> sess,
+ shared_ptr <security::authenticator> auth) const
{
- return vmime::create <S>(sess, auth);
+ return make_shared <S>(sess, auth);
}
const serviceInfos& getInfos() const
@@ -80,7 +80,7 @@ public:
serviceRegisterer(const string& protocol, const service::Type type)
{
serviceFactory::getInstance()->registerService
- (vmime::create <vmime::net::registeredServiceImpl <S> >(protocol, type));
+ (make_shared <registeredServiceImpl <S> >(protocol, type));
}
};
diff --git a/src/net/session.cpp b/src/net/session.cpp
index a444d000..fcc5dd12 100644
--- a/src/net/session.cpp
+++ b/src/net/session.cpp
@@ -39,19 +39,20 @@ namespace net {
session::session()
- : m_tlsProps(vmime::create <tls::TLSProperties>())
+ : m_tlsProps(make_shared <tls::TLSProperties>())
{
}
session::session(const session& sess)
- : object(), m_props(sess.m_props), m_tlsProps(vmime::create <tls::TLSProperties>(*sess.m_tlsProps))
+ : object(), m_props(sess.m_props),
+ m_tlsProps(make_shared <tls::TLSProperties>(*sess.m_tlsProps))
{
}
session::session(const propertySet& props)
- : m_props(props), m_tlsProps(vmime::create <tls::TLSProperties>())
+ : m_props(props), m_tlsProps(make_shared <tls::TLSProperties>())
{
}
@@ -61,67 +62,67 @@ session::~session()
}
-ref <transport> session::getTransport(ref <security::authenticator> auth)
+shared_ptr <transport> session::getTransport(shared_ptr <security::authenticator> auth)
{
return (getTransport(m_props["transport.protocol"], auth));
}
-ref <transport> session::getTransport
- (const string& protocol, ref <security::authenticator> auth)
+shared_ptr <transport> session::getTransport
+ (const string& protocol, shared_ptr <security::authenticator> auth)
{
- ref <session> sess = thisRef().dynamicCast <session>();
- ref <service> sv = serviceFactory::getInstance()->create(sess, protocol, auth);
+ shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
+ shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, protocol, auth);
if (sv->getType() != service::TYPE_TRANSPORT)
throw exceptions::no_service_available();
- return sv.staticCast <transport>();
+ return dynamicCast <transport>(sv);
}
-ref <transport> session::getTransport
- (const utility::url& url, ref <security::authenticator> auth)
+shared_ptr <transport> session::getTransport
+ (const utility::url& url, shared_ptr <security::authenticator> auth)
{
- ref <session> sess = thisRef().dynamicCast <session>();
- ref <service> sv = serviceFactory::getInstance()->create(sess, url, auth);
+ shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
+ shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, url, auth);
if (sv->getType() != service::TYPE_TRANSPORT)
throw exceptions::no_service_available();
- return sv.staticCast <transport>();
+ return dynamicCast <transport>(sv);
}
-ref <store> session::getStore(ref <security::authenticator> auth)
+shared_ptr <store> session::getStore(shared_ptr <security::authenticator> auth)
{
return (getStore(m_props["store.protocol"], auth));
}
-ref <store> session::getStore
- (const string& protocol, ref <security::authenticator> auth)
+shared_ptr <store> session::getStore
+ (const string& protocol, shared_ptr <security::authenticator> auth)
{
- ref <session> sess = thisRef().dynamicCast <session>();
- ref <service> sv = serviceFactory::getInstance()->create(sess, protocol, auth);
+ shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
+ shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, protocol, auth);
if (sv->getType() != service::TYPE_STORE)
throw exceptions::no_service_available();
- return sv.staticCast <store>();
+ return dynamicCast <store>(sv);
}
-ref <store> session::getStore
- (const utility::url& url, ref <security::authenticator> auth)
+shared_ptr <store> session::getStore
+ (const utility::url& url, shared_ptr <security::authenticator> auth)
{
- ref <session> sess = thisRef().dynamicCast <session>();
- ref <service> sv = serviceFactory::getInstance()->create(sess, url, auth);
+ shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
+ shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, url, auth);
if (sv->getType() != service::TYPE_STORE)
throw exceptions::no_service_available();
- return sv.staticCast <store>();
+ return dynamicCast <store>(sv);
}
@@ -137,13 +138,13 @@ propertySet& session::getProperties()
}
-void session::setTLSProperties(ref <tls::TLSProperties> tlsProps)
+void session::setTLSProperties(shared_ptr <tls::TLSProperties> tlsProps)
{
- m_tlsProps = vmime::create <tls::TLSProperties>(*tlsProps);
+ m_tlsProps = make_shared <tls::TLSProperties>(*tlsProps);
}
-ref <tls::TLSProperties> session::getTLSProperties() const
+shared_ptr <tls::TLSProperties> session::getTLSProperties() const
{
return m_tlsProps;
}
diff --git a/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp b/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp
index 932bd56f..0584f7e6 100644
--- a/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp
+++ b/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp
@@ -40,7 +40,7 @@ namespace net {
namespace smtp {
-SMTPChunkingOutputStreamAdapter::SMTPChunkingOutputStreamAdapter(ref <SMTPConnection> conn)
+SMTPChunkingOutputStreamAdapter::SMTPChunkingOutputStreamAdapter(shared_ptr <SMTPConnection> conn)
: m_connection(conn), m_bufferSize(0), m_chunkCount(0)
{
}
@@ -64,7 +64,7 @@ void SMTPChunkingOutputStreamAdapter::sendChunk
// If PIPELINING is not supported, read one response for this BDAT command
if (!m_connection->hasExtension("PIPELINING"))
{
- ref <SMTPResponse> resp = m_connection->readResponse();
+ shared_ptr <SMTPResponse> resp = m_connection->readResponse();
if (resp->getCode() != 250)
{
@@ -77,7 +77,7 @@ void SMTPChunkingOutputStreamAdapter::sendChunk
else if (last)
{
bool invalidReply = false;
- ref <SMTPResponse> resp;
+ shared_ptr <SMTPResponse> resp;
for (unsigned int i = 0 ; i < m_chunkCount ; ++i)
{
diff --git a/src/net/smtp/SMTPCommand.cpp b/src/net/smtp/SMTPCommand.cpp
index e40797f2..6b3d1d79 100644
--- a/src/net/smtp/SMTPCommand.cpp
+++ b/src/net/smtp/SMTPCommand.cpp
@@ -47,7 +47,7 @@ SMTPCommand::SMTPCommand(const string& text)
// static
-ref <SMTPCommand> SMTPCommand::EHLO(const string& hostname)
+shared_ptr <SMTPCommand> SMTPCommand::EHLO(const string& hostname)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -58,7 +58,7 @@ ref <SMTPCommand> SMTPCommand::EHLO(const string& hostname)
// static
-ref <SMTPCommand> SMTPCommand::HELO(const string& hostname)
+shared_ptr <SMTPCommand> SMTPCommand::HELO(const string& hostname)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -69,7 +69,7 @@ ref <SMTPCommand> SMTPCommand::HELO(const string& hostname)
// static
-ref <SMTPCommand> SMTPCommand::AUTH(const string& mechName)
+shared_ptr <SMTPCommand> SMTPCommand::AUTH(const string& mechName)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -80,21 +80,21 @@ ref <SMTPCommand> SMTPCommand::AUTH(const string& mechName)
// static
-ref <SMTPCommand> SMTPCommand::STARTTLS()
+shared_ptr <SMTPCommand> SMTPCommand::STARTTLS()
{
return createCommand("STARTTLS");
}
// static
-ref <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8)
+shared_ptr <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8)
{
return MAIL(mbox, utf8, 0);
}
// static
-ref <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const unsigned long size)
+shared_ptr <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const unsigned long size)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -123,7 +123,7 @@ ref <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const
// static
-ref <SMTPCommand> SMTPCommand::RCPT(const mailbox& mbox, const bool utf8)
+shared_ptr <SMTPCommand> SMTPCommand::RCPT(const mailbox& mbox, const bool utf8)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -146,21 +146,21 @@ ref <SMTPCommand> SMTPCommand::RCPT(const mailbox& mbox, const bool utf8)
// static
-ref <SMTPCommand> SMTPCommand::RSET()
+shared_ptr <SMTPCommand> SMTPCommand::RSET()
{
return createCommand("RSET");
}
// static
-ref <SMTPCommand> SMTPCommand::DATA()
+shared_ptr <SMTPCommand> SMTPCommand::DATA()
{
return createCommand("DATA");
}
// static
-ref <SMTPCommand> SMTPCommand::BDAT(const unsigned long chunkSize, const bool last)
+shared_ptr <SMTPCommand> SMTPCommand::BDAT(const unsigned long chunkSize, const bool last)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -174,23 +174,23 @@ ref <SMTPCommand> SMTPCommand::BDAT(const unsigned long chunkSize, const bool la
// static
-ref <SMTPCommand> SMTPCommand::NOOP()
+shared_ptr <SMTPCommand> SMTPCommand::NOOP()
{
return createCommand("NOOP");
}
// static
-ref <SMTPCommand> SMTPCommand::QUIT()
+shared_ptr <SMTPCommand> SMTPCommand::QUIT()
{
return createCommand("QUIT");
}
// static
-ref <SMTPCommand> SMTPCommand::createCommand(const string& text)
+shared_ptr <SMTPCommand> SMTPCommand::createCommand(const string& text)
{
- return vmime::create <SMTPCommand>(text);
+ return shared_ptr <SMTPCommand>(new SMTPCommand(text));
}
@@ -200,7 +200,7 @@ const string SMTPCommand::getText() const
}
-void SMTPCommand::writeToSocket(ref <socket> sok)
+void SMTPCommand::writeToSocket(shared_ptr <socket> sok)
{
sok->send(m_text + "\r\n");
}
diff --git a/src/net/smtp/SMTPCommandSet.cpp b/src/net/smtp/SMTPCommandSet.cpp
index a967c3a6..3e03427c 100644
--- a/src/net/smtp/SMTPCommandSet.cpp
+++ b/src/net/smtp/SMTPCommandSet.cpp
@@ -49,13 +49,13 @@ SMTPCommandSet::SMTPCommandSet(const bool pipeline)
// static
-ref <SMTPCommandSet> SMTPCommandSet::create(const bool pipeline)
+shared_ptr <SMTPCommandSet> SMTPCommandSet::create(const bool pipeline)
{
- return vmime::create <SMTPCommandSet>(pipeline);
+ return shared_ptr <SMTPCommandSet>(new SMTPCommandSet(pipeline));
}
-void SMTPCommandSet::addCommand(ref <SMTPCommand> cmd)
+void SMTPCommandSet::addCommand(shared_ptr <SMTPCommand> cmd)
{
if (m_started)
{
@@ -67,17 +67,17 @@ void SMTPCommandSet::addCommand(ref <SMTPCommand> cmd)
}
-void SMTPCommandSet::writeToSocket(ref <socket> sok)
+void SMTPCommandSet::writeToSocket(shared_ptr <socket> sok)
{
if (m_pipeline)
{
if (!m_started)
{
// Send all commands at once
- for (std::list <ref <SMTPCommand> >::const_iterator it = m_commands.begin() ;
+ for (std::list <shared_ptr <SMTPCommand> >::const_iterator it = m_commands.begin() ;
it != m_commands.end() ; ++it)
{
- ref <SMTPCommand> cmd = *it;
+ shared_ptr <SMTPCommand> cmd = *it;
cmd->writeToSocket(sok);
}
}
@@ -85,7 +85,7 @@ void SMTPCommandSet::writeToSocket(ref <socket> sok)
if (!m_commands.empty())
{
// Advance the pointer to last command sent
- ref <SMTPCommand> cmd = m_commands.front();
+ shared_ptr <SMTPCommand> cmd = m_commands.front();
m_commands.pop_front();
m_lastCommandSent = cmd;
@@ -96,7 +96,7 @@ void SMTPCommandSet::writeToSocket(ref <socket> sok)
if (!m_commands.empty())
{
// Send only one command
- ref <SMTPCommand> cmd = m_commands.front();
+ shared_ptr <SMTPCommand> cmd = m_commands.front();
m_commands.pop_front();
cmd->writeToSocket(sok);
@@ -114,7 +114,7 @@ const string SMTPCommandSet::getText() const
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
- for (std::list <ref <SMTPCommand> >::const_iterator it = m_commands.begin() ;
+ for (std::list <shared_ptr <SMTPCommand> >::const_iterator it = m_commands.begin() ;
it != m_commands.end() ; ++it)
{
cmd << (*it)->getText() << "\r\n";
@@ -130,7 +130,7 @@ bool SMTPCommandSet::isFinished() const
}
-ref <SMTPCommand> SMTPCommandSet::getLastCommandSent() const
+shared_ptr <SMTPCommand> SMTPCommandSet::getLastCommandSent() const
{
return m_lastCommandSent;
}
diff --git a/src/net/smtp/SMTPConnection.cpp b/src/net/smtp/SMTPConnection.cpp
index e831ccfc..9fcacbc1 100644
--- a/src/net/smtp/SMTPConnection.cpp
+++ b/src/net/smtp/SMTPConnection.cpp
@@ -51,11 +51,11 @@
// Helpers for service properties
#define GET_PROPERTY(type, prop) \
- (m_transport.acquire()->getInfos().getPropertyValue <type>(getSession(), \
- dynamic_cast <const SMTPServiceInfos&>(m_transport.acquire()->getInfos()).getProperties().prop))
+ (m_transport.lock()->getInfos().getPropertyValue <type>(getSession(), \
+ dynamic_cast <const SMTPServiceInfos&>(m_transport.lock()->getInfos()).getProperties().prop))
#define HAS_PROPERTY(prop) \
- (m_transport.acquire()->getInfos().hasProperty(getSession(), \
- dynamic_cast <const SMTPServiceInfos&>(m_transport.acquire()->getInfos()).getProperties().prop))
+ (m_transport.lock()->getInfos().hasProperty(getSession(), \
+ dynamic_cast <const SMTPServiceInfos&>(m_transport.lock()->getInfos()).getProperties().prop))
namespace vmime {
@@ -64,8 +64,8 @@ namespace smtp {
-SMTPConnection::SMTPConnection(ref <SMTPTransport> transport, ref <security::authenticator> auth)
- : m_transport(transport), m_auth(auth), m_socket(NULL), m_timeoutHandler(NULL),
+SMTPConnection::SMTPConnection(shared_ptr <SMTPTransport> transport, shared_ptr <security::authenticator> auth)
+ : m_transport(transport), m_auth(auth), m_socket(null), m_timeoutHandler(null),
m_authenticated(false), m_secured(false), m_extendedSMTP(false)
{
}
@@ -95,7 +95,7 @@ void SMTPConnection::connect()
const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS);
const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT);
- ref <SMTPTransport> transport = m_transport.acquire();
+ shared_ptr <SMTPTransport> transport = m_transport.lock();
// Create the time-out handler
if (transport->getTimeoutHandlerFactory())
@@ -107,22 +107,22 @@ void SMTPConnection::connect()
#if VMIME_HAVE_TLS_SUPPORT
if (transport->isSMTPS()) // dedicated port/SMTPS
{
- ref <tls::TLSSession> tlsSession = tls::TLSSession::create
+ shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
(transport->getCertificateVerifier(),
transport->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);
@@ -132,7 +132,7 @@ void SMTPConnection::connect()
// eg: C: <connection to server>
// --- S: 220 smtp.domain.com Service ready
- ref <SMTPResponse> resp;
+ shared_ptr <SMTPResponse> resp;
if ((resp = readResponse())->getCode() != 220)
{
@@ -199,7 +199,7 @@ void SMTPConnection::helo()
sendRequest(SMTPCommand::EHLO(platform::getHandler()->getHostName()));
- ref <SMTPResponse> resp;
+ shared_ptr <SMTPResponse> resp;
if ((resp = readResponse())->getCode() != 250)
{
@@ -281,7 +281,7 @@ void SMTPConnection::authenticate()
throw exceptions::command_error("AUTH", "ESMTP not supported.");
}
- getAuthenticator()->setService(m_transport.acquire());
+ getAuthenticator()->setService(m_transport.lock());
#if VMIME_HAVE_SASL_SUPPORT
// First, try SASL authentication
@@ -325,7 +325,7 @@ void SMTPConnection::authenticate()
void SMTPConnection::authenticateSASL()
{
- if (!getAuthenticator().dynamicCast <security::sasl::SASLAuthenticator>())
+ if (!dynamicCast <security::sasl::SASLAuthenticator>(getAuthenticator()))
throw exceptions::authentication_error("No SASL authenticator available.");
// Obtain SASL mechanisms supported by server from ESMTP extensions
@@ -335,10 +335,10 @@ void SMTPConnection::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)
{
@@ -357,14 +357,14 @@ void SMTPConnection::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())
@@ -373,9 +373,9 @@ void SMTPConnection::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("smtp", getAuthenticator(), mech);
saslSession->init();
@@ -384,7 +384,7 @@ void SMTPConnection::authenticateSASL()
for (bool cont = true ; cont ; )
{
- ref <SMTPResponse> response = readResponse();
+ shared_ptr <SMTPResponse> response = readResponse();
switch (response->getCode())
{
@@ -472,7 +472,7 @@ void SMTPConnection::startTLS()
{
sendRequest(SMTPCommand::STARTTLS());
- ref <SMTPResponse> resp = readResponse();
+ shared_ptr <SMTPResponse> resp = readResponse();
if (resp->getCode() != 220)
{
@@ -480,11 +480,11 @@ void SMTPConnection::startTLS()
resp->getCode(), resp->getEnhancedCode());
}
- ref <tls::TLSSession> tlsSession = tls::TLSSession::create
+ shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
(getTransport()->getCertificateVerifier(),
getTransport()->getSession()->getTLSProperties());
- ref <tls::TLSSocket> tlsSocket =
+ shared_ptr <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
tlsSocket->handshake(m_timeoutHandler);
@@ -492,7 +492,7 @@ void SMTPConnection::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);
}
catch (exceptions::command_error&)
@@ -533,27 +533,27 @@ void SMTPConnection::internalDisconnect()
}
m_socket->disconnect();
- m_socket = NULL;
+ m_socket = null;
- m_timeoutHandler = NULL;
+ m_timeoutHandler = null;
m_authenticated = false;
m_extendedSMTP = false;
m_secured = false;
- m_cntInfos = NULL;
+ m_cntInfos = null;
}
-void SMTPConnection::sendRequest(ref <SMTPCommand> cmd)
+void SMTPConnection::sendRequest(shared_ptr <SMTPCommand> cmd)
{
cmd->writeToSocket(m_socket);
}
-ref <SMTPResponse> SMTPConnection::readResponse()
+shared_ptr <SMTPResponse> SMTPConnection::readResponse()
{
- ref <SMTPResponse> resp = SMTPResponse::readResponse
+ shared_ptr <SMTPResponse> resp = SMTPResponse::readResponse
(m_socket, m_timeoutHandler, m_responseState);
m_responseState = resp->getCurrentState();
@@ -574,37 +574,37 @@ bool SMTPConnection::isSecuredConnection() const
}
-ref <connectionInfos> SMTPConnection::getConnectionInfos() const
+shared_ptr <connectionInfos> SMTPConnection::getConnectionInfos() const
{
return m_cntInfos;
}
-ref <SMTPTransport> SMTPConnection::getTransport()
+shared_ptr <SMTPTransport> SMTPConnection::getTransport()
{
- return m_transport.acquire();
+ return m_transport.lock();
}
-ref <session> SMTPConnection::getSession()
+shared_ptr <session> SMTPConnection::getSession()
{
- return m_transport.acquire()->getSession();
+ return m_transport.lock()->getSession();
}
-ref <socket> SMTPConnection::getSocket()
+shared_ptr <socket> SMTPConnection::getSocket()
{
return m_socket;
}
-ref <timeoutHandler> SMTPConnection::getTimeoutHandler()
+shared_ptr <timeoutHandler> SMTPConnection::getTimeoutHandler()
{
return m_timeoutHandler;
}
-ref <security::authenticator> SMTPConnection::getAuthenticator()
+shared_ptr <security::authenticator> SMTPConnection::getAuthenticator()
{
return m_auth;
}
diff --git a/src/net/smtp/SMTPResponse.cpp b/src/net/smtp/SMTPResponse.cpp
index 9367dcd4..baefc38d 100644
--- a/src/net/smtp/SMTPResponse.cpp
+++ b/src/net/smtp/SMTPResponse.cpp
@@ -43,7 +43,7 @@ namespace net {
namespace smtp {
-SMTPResponse::SMTPResponse(ref <socket> sok, ref <timeoutHandler> toh, const state& st)
+SMTPResponse::SMTPResponse(shared_ptr <socket> sok, shared_ptr <timeoutHandler> toh, const state& st)
: m_socket(sok), m_timeoutHandler(toh),
m_responseBuffer(st.responseBuffer), m_responseContinues(false)
{
@@ -94,10 +94,10 @@ const string SMTPResponse::getText() const
// static
-ref <SMTPResponse> SMTPResponse::readResponse
- (ref <socket> sok, ref <timeoutHandler> toh, const state& st)
+shared_ptr <SMTPResponse> SMTPResponse::readResponse
+ (shared_ptr <socket> sok, shared_ptr <timeoutHandler> toh, const state& st)
{
- ref <SMTPResponse> resp = vmime::create <SMTPResponse>(sok, toh, st);
+ shared_ptr <SMTPResponse> resp = shared_ptr <SMTPResponse>(new SMTPResponse(sok, toh, st));
resp->readResponse();
diff --git a/src/net/smtp/SMTPSTransport.cpp b/src/net/smtp/SMTPSTransport.cpp
index 2e594ce7..ab64d49d 100644
--- a/src/net/smtp/SMTPSTransport.cpp
+++ b/src/net/smtp/SMTPSTransport.cpp
@@ -35,7 +35,7 @@ namespace net {
namespace smtp {
-SMTPSTransport::SMTPSTransport(ref <session> sess, ref <security::authenticator> auth)
+SMTPSTransport::SMTPSTransport(shared_ptr <session> sess, shared_ptr <security::authenticator> auth)
: SMTPTransport(sess, auth, true)
{
}
diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp
index 91487ed4..4f409a03 100644
--- a/src/net/smtp/SMTPTransport.cpp
+++ b/src/net/smtp/SMTPTransport.cpp
@@ -51,7 +51,7 @@ namespace net {
namespace smtp {
-SMTPTransport::SMTPTransport(ref <session> sess, ref <security::authenticator> auth, const bool secured)
+SMTPTransport::SMTPTransport(shared_ptr <session> sess, shared_ptr <security::authenticator> auth, const bool secured)
: transport(sess, getInfosInstance(), auth), m_isSMTPS(secured), m_needReset(false)
{
}
@@ -88,8 +88,8 @@ void SMTPTransport::connect()
if (isConnected())
throw exceptions::already_connected();
- m_connection = vmime::create <SMTPConnection>
- (thisRef().dynamicCast <SMTPTransport>(), getAuthenticator());
+ m_connection = make_shared <SMTPConnection>
+ (dynamicCast <SMTPTransport>(shared_from_this()), getAuthenticator());
try
{
@@ -97,7 +97,7 @@ void SMTPTransport::connect()
}
catch (std::exception&)
{
- m_connection = NULL;
+ m_connection = null;
throw;
}
}
@@ -118,16 +118,16 @@ bool SMTPTransport::isSecuredConnection() const
}
-ref <connectionInfos> SMTPTransport::getConnectionInfos() const
+shared_ptr <connectionInfos> SMTPTransport::getConnectionInfos() const
{
if (m_connection == NULL)
- return NULL;
+ return null;
return m_connection->getConnectionInfos();
}
-ref <SMTPConnection> SMTPTransport::getConnection()
+shared_ptr <SMTPConnection> SMTPTransport::getConnection()
{
return m_connection;
}
@@ -139,7 +139,7 @@ void SMTPTransport::disconnect()
throw exceptions::not_connected();
m_connection->disconnect();
- m_connection = NULL;
+ m_connection = null;
}
@@ -150,7 +150,7 @@ void SMTPTransport::noop()
m_connection->sendRequest(SMTPCommand::NOOP());
- ref <SMTPResponse> resp = m_connection->readResponse();
+ shared_ptr <SMTPResponse> resp = m_connection->readResponse();
if (resp->getCode() != 250)
{
@@ -177,8 +177,8 @@ void SMTPTransport::sendEnvelope
getInfos().getPropertyValue <bool>(getSession(),
dynamic_cast <const SMTPServiceInfos&>(getInfos()).getProperties().PROPERTY_OPTIONS_PIPELINING);
- ref <SMTPResponse> resp;
- ref <SMTPCommandSet> commands = SMTPCommandSet::create(hasPipelining);
+ shared_ptr <SMTPResponse> resp;
+ shared_ptr <SMTPCommandSet> commands = SMTPCommandSet::create(hasPipelining);
// Emit a "RSET" command if we previously sent a message on this connection
if (needReset)
@@ -336,7 +336,7 @@ void SMTPTransport::send
// Send end-of-data delimiter
m_connection->getSocket()->sendRaw("\r\n.\r\n", 5);
- ref <SMTPResponse> resp;
+ shared_ptr <SMTPResponse> resp;
if ((resp = m_connection->readResponse())->getCode() != 250)
{
@@ -349,7 +349,7 @@ void SMTPTransport::send
void SMTPTransport::send
- (ref <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
+ (shared_ptr <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
utility::progressListener* progress, const mailbox& sender)
{
if (!isConnected())
diff --git a/src/net/tls/TLSSecuredConnectionInfos.cpp b/src/net/tls/TLSSecuredConnectionInfos.cpp
index 5060aede..4856e9af 100644
--- a/src/net/tls/TLSSecuredConnectionInfos.cpp
+++ b/src/net/tls/TLSSecuredConnectionInfos.cpp
@@ -38,7 +38,7 @@ namespace tls {
TLSSecuredConnectionInfos::TLSSecuredConnectionInfos
(const string& host, const port_t port,
- ref <TLSSession> tlsSession, ref <TLSSocket> tlsSocket)
+ shared_ptr <TLSSession> tlsSession, shared_ptr <TLSSocket> tlsSocket)
: m_host(host), m_port(port),
m_tlsSession(tlsSession), m_tlsSocket(tlsSocket)
{
@@ -57,7 +57,7 @@ port_t TLSSecuredConnectionInfos::getPort() const
}
-ref <const security::cert::certificateChain> TLSSecuredConnectionInfos::getPeerCertificates() const
+shared_ptr <const security::cert::certificateChain> TLSSecuredConnectionInfos::getPeerCertificates() const
{
return m_tlsSocket->getPeerCertificates();
}
diff --git a/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp b/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp
index 2a161dee..36ab7d7a 100644
--- a/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp
+++ b/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp
@@ -42,7 +42,7 @@ namespace tls {
TLSProperties::TLSProperties()
- : m_data(vmime::create <TLSProperties_GnuTLS>())
+ : m_data(make_shared <TLSProperties_GnuTLS>())
{
setCipherSuite(CIPHERSUITE_DEFAULT);
}
@@ -50,9 +50,9 @@ TLSProperties::TLSProperties()
TLSProperties::TLSProperties(const TLSProperties& props)
: object(),
- m_data(vmime::create <TLSProperties_GnuTLS>())
+ m_data(make_shared <TLSProperties_GnuTLS>())
{
- *m_data.dynamicCast <TLSProperties_GnuTLS>() = *props.m_data.dynamicCast <TLSProperties_GnuTLS>();
+ *dynamicCast <TLSProperties_GnuTLS>(m_data) = *dynamicCast <TLSProperties_GnuTLS>(props.m_data);
}
@@ -86,13 +86,13 @@ void TLSProperties::setCipherSuite(const GenericCipherSuite cipherSuite)
void TLSProperties::setCipherSuite(const string& cipherSuite)
{
- m_data.dynamicCast <TLSProperties_GnuTLS>()->cipherSuite = cipherSuite;
+ dynamicCast <TLSProperties_GnuTLS>(m_data)->cipherSuite = cipherSuite;
}
const string TLSProperties::getCipherSuite() const
{
- return m_data.dynamicCast <TLSProperties_GnuTLS>()->cipherSuite;
+ return dynamicCast <TLSProperties_GnuTLS>(m_data)->cipherSuite;
}
diff --git a/src/net/tls/gnutls/TLSSession_GnuTLS.cpp b/src/net/tls/gnutls/TLSSession_GnuTLS.cpp
index 52fedc78..1c520ed1 100644
--- a/src/net/tls/gnutls/TLSSession_GnuTLS.cpp
+++ b/src/net/tls/gnutls/TLSSession_GnuTLS.cpp
@@ -134,13 +134,13 @@ static TLSGlobal g_gnutlsGlobal;
// static
-ref <TLSSession> TLSSession::create(ref <security::cert::certificateVerifier> cv, ref <TLSProperties> props)
+shared_ptr <TLSSession> TLSSession::create(shared_ptr <security::cert::certificateVerifier> cv, shared_ptr <TLSProperties> props)
{
- return vmime::create <TLSSession_GnuTLS>(cv, props);
+ return make_shared <TLSSession_GnuTLS>(cv, props);
}
-TLSSession_GnuTLS::TLSSession_GnuTLS(ref <security::cert::certificateVerifier> cv, ref <TLSProperties> props)
+TLSSession_GnuTLS::TLSSession_GnuTLS(shared_ptr <security::cert::certificateVerifier> cv, shared_ptr <TLSProperties> props)
: m_certVerifier(cv), m_props(props)
{
int res;
@@ -267,13 +267,13 @@ TLSSession_GnuTLS::~TLSSession_GnuTLS()
}
-ref <TLSSocket> TLSSession_GnuTLS::getSocket(ref <socket> sok)
+shared_ptr <TLSSocket> TLSSession_GnuTLS::getSocket(shared_ptr <socket> sok)
{
- return TLSSocket::wrap(thisRef().dynamicCast <TLSSession>(), sok);
+ return TLSSocket::wrap(dynamicCast <TLSSession>(shared_from_this()), sok);
}
-ref <security::cert::certificateVerifier> TLSSession_GnuTLS::getCertificateVerifier()
+shared_ptr <security::cert::certificateVerifier> TLSSession_GnuTLS::getCertificateVerifier()
{
return m_certVerifier;
}
diff --git a/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp b/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp
index 0a24b720..bb21cb9d 100644
--- a/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp
+++ b/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp
@@ -44,14 +44,14 @@ namespace tls {
// static
-ref <TLSSocket> TLSSocket::wrap(ref <TLSSession> session, ref <socket> sok)
+shared_ptr <TLSSocket> TLSSocket::wrap(shared_ptr <TLSSession> session, shared_ptr <socket> sok)
{
- return vmime::create <TLSSocket_GnuTLS>
- (session.dynamicCast <TLSSession_GnuTLS>(), sok);
+ return make_shared <TLSSocket_GnuTLS>
+ (dynamicCast <TLSSession_GnuTLS>(session), sok);
}
-TLSSocket_GnuTLS::TLSSocket_GnuTLS(ref <TLSSession_GnuTLS> session, ref <socket> sok)
+TLSSocket_GnuTLS::TLSSocket_GnuTLS(shared_ptr <TLSSession_GnuTLS> session, shared_ptr <socket> sok)
: m_session(session), m_wrapped(sok), m_connected(false),
m_handshaking(false), m_ex(NULL), m_status(0)
{
@@ -85,7 +85,7 @@ void TLSSocket_GnuTLS::connect(const string& address, const port_t port)
{
m_wrapped->connect(address, port);
- handshake(NULL);
+ handshake(null);
m_connected = true;
}
@@ -219,7 +219,7 @@ unsigned int TLSSocket_GnuTLS::getStatus() const
}
-void TLSSocket_GnuTLS::handshake(ref <timeoutHandler> toHandler)
+void TLSSocket_GnuTLS::handshake(shared_ptr <timeoutHandler> toHandler)
{
if (toHandler)
toHandler->resetTimeOut();
@@ -260,16 +260,16 @@ void TLSSocket_GnuTLS::handshake(ref <timeoutHandler> toHandler)
catch (...)
{
m_handshaking = false;
- m_toHandler = NULL;
+ m_toHandler = null;
throw;
}
m_handshaking = false;
- m_toHandler = NULL;
+ m_toHandler = null;
// Verify server's certificate(s)
- ref <security::cert::certificateChain> certs = getPeerCertificates();
+ shared_ptr <security::cert::certificateChain> certs = getPeerCertificates();
if (certs == NULL)
throw exceptions::tls_exception("No peer certificate.");
@@ -364,14 +364,14 @@ ssize_t TLSSocket_GnuTLS::gnutlsPullFunc
}
-ref <security::cert::certificateChain> TLSSocket_GnuTLS::getPeerCertificates() const
+shared_ptr <security::cert::certificateChain> TLSSocket_GnuTLS::getPeerCertificates() const
{
unsigned int certCount = 0;
const gnutls_datum* rawData = gnutls_certificate_get_peers
(*m_session->m_gnutlsSession, &certCount);
if (rawData == NULL)
- return NULL;
+ return null;
// Try X.509
gnutls_x509_crt* x509Certs = new gnutls_x509_crt[certCount];
@@ -387,12 +387,12 @@ ref <security::cert::certificateChain> TLSSocket_GnuTLS::getPeerCertificates() c
{
// XXX more fine-grained error reporting?
delete [] x509Certs;
- return NULL;
+ return null;
}
}
{
- std::vector <ref <security::cert::certificate> > certs;
+ std::vector <shared_ptr <security::cert::certificate> > certs;
bool error = false;
for (unsigned int i = 0 ; i < certCount ; ++i)
@@ -407,7 +407,7 @@ ref <security::cert::certificateChain> TLSSocket_GnuTLS::getPeerCertificates() c
gnutls_x509_crt_export(x509Certs[i],
GNUTLS_X509_FMT_DER, &data[0], &dataSize);
- ref <security::cert::X509Certificate> cert =
+ shared_ptr <security::cert::X509Certificate> cert =
security::cert::X509Certificate::import(&data[0], dataSize);
if (cert != NULL)
@@ -421,14 +421,14 @@ ref <security::cert::certificateChain> TLSSocket_GnuTLS::getPeerCertificates() c
delete [] x509Certs;
if (error)
- return NULL;
+ return null;
- return vmime::create <security::cert::certificateChain>(certs);
+ return make_shared <security::cert::certificateChain>(certs);
}
delete [] x509Certs;
- return NULL;
+ return null;
}
@@ -457,7 +457,7 @@ private:
void TLSSocket_GnuTLS::internalThrow()
{
- static std::vector <ref <TLSSocket_DeleteExWrapper> > exToDelete;
+ static std::vector <shared_ptr <TLSSocket_DeleteExWrapper> > exToDelete;
if (m_ex)
{
@@ -467,7 +467,7 @@ void TLSSocket_GnuTLS::internalThrow()
m_ex = NULL;
// To avoid memory leaks
- exToDelete.push_back(vmime::create <TLSSocket_DeleteExWrapper>(ex));
+ exToDelete.push_back(make_shared <TLSSocket_DeleteExWrapper>(ex));
throw *ex;
}
diff --git a/src/net/tls/openssl/OpenSSLInitializer.cpp b/src/net/tls/openssl/OpenSSLInitializer.cpp
index 8238b864..1bbb9ee5 100644
--- a/src/net/tls/openssl/OpenSSLInitializer.cpp
+++ b/src/net/tls/openssl/OpenSSLInitializer.cpp
@@ -49,7 +49,7 @@ namespace net {
namespace tls {
-ref <vmime::utility::sync::criticalSection >* OpenSSLInitializer::sm_mutexes;
+shared_ptr <vmime::utility::sync::criticalSection >* OpenSSLInitializer::sm_mutexes;
OpenSSLInitializer::autoInitializer::autoInitializer()
@@ -93,7 +93,7 @@ void OpenSSLInitializer::initialize()
RAND_seed(seed, SEEDSIZE);
int numMutexes = CRYPTO_num_locks();
- sm_mutexes = new ref <vmime::utility::sync::criticalSection>[numMutexes];
+ sm_mutexes = new shared_ptr <vmime::utility::sync::criticalSection>[numMutexes];
for (int i = 0 ; i < numMutexes ; ++i)
sm_mutexes[i] = vmime::platform::getHandler()->createCriticalSection();
diff --git a/src/net/tls/openssl/TLSProperties_OpenSSL.cpp b/src/net/tls/openssl/TLSProperties_OpenSSL.cpp
index 34e31cf1..932477df 100644
--- a/src/net/tls/openssl/TLSProperties_OpenSSL.cpp
+++ b/src/net/tls/openssl/TLSProperties_OpenSSL.cpp
@@ -40,7 +40,7 @@ namespace tls {
TLSProperties::TLSProperties()
- : m_data(vmime::create <TLSProperties_OpenSSL>())
+ : m_data(make_shared <TLSProperties_OpenSSL>())
{
setCipherSuite(CIPHERSUITE_DEFAULT);
}
@@ -48,9 +48,9 @@ TLSProperties::TLSProperties()
TLSProperties::TLSProperties(const TLSProperties& props)
: object(),
- m_data(vmime::create <TLSProperties_OpenSSL>())
+ m_data(make_shared <TLSProperties_OpenSSL>())
{
- *m_data.dynamicCast <TLSProperties_OpenSSL>() = *props.m_data.dynamicCast <TLSProperties_OpenSSL>();
+ *dynamicCast <TLSProperties_OpenSSL>(m_data) = *dynamicCast <TLSProperties_OpenSSL>(props.m_data);
}
@@ -84,13 +84,13 @@ void TLSProperties::setCipherSuite(const GenericCipherSuite cipherSuite)
void TLSProperties::setCipherSuite(const string& cipherSuite)
{
- m_data.dynamicCast <TLSProperties_OpenSSL>()->cipherSuite = cipherSuite;
+ dynamicCast <TLSProperties_OpenSSL>(m_data)->cipherSuite = cipherSuite;
}
const string TLSProperties::getCipherSuite() const
{
- return m_data.dynamicCast <TLSProperties_OpenSSL>()->cipherSuite;
+ return dynamicCast <TLSProperties_OpenSSL>(m_data)->cipherSuite;
}
diff --git a/src/net/tls/openssl/TLSSession_OpenSSL.cpp b/src/net/tls/openssl/TLSSession_OpenSSL.cpp
index 953e4ebc..cf600a63 100644
--- a/src/net/tls/openssl/TLSSession_OpenSSL.cpp
+++ b/src/net/tls/openssl/TLSSession_OpenSSL.cpp
@@ -46,13 +46,13 @@ static OpenSSLInitializer::autoInitializer openSSLInitializer;
// static
-ref <TLSSession> TLSSession::create(ref <security::cert::certificateVerifier> cv, ref <TLSProperties> props)
+shared_ptr <TLSSession> TLSSession::create(shared_ptr <security::cert::certificateVerifier> cv, shared_ptr <TLSProperties> props)
{
- return vmime::create <TLSSession_OpenSSL>(cv, props);
+ return make_shared <TLSSession_OpenSSL>(cv, props);
}
-TLSSession_OpenSSL::TLSSession_OpenSSL(ref <vmime::security::cert::certificateVerifier> cv, ref <TLSProperties> props)
+TLSSession_OpenSSL::TLSSession_OpenSSL(shared_ptr <vmime::security::cert::certificateVerifier> cv, shared_ptr <TLSProperties> props)
: m_sslctx(0), m_certVerifier(cv), m_props(props)
{
m_sslctx = SSL_CTX_new(SSLv23_client_method());
@@ -76,13 +76,13 @@ TLSSession_OpenSSL::~TLSSession_OpenSSL()
}
-ref <TLSSocket> TLSSession_OpenSSL::getSocket(ref <socket> sok)
+shared_ptr <TLSSocket> TLSSession_OpenSSL::getSocket(shared_ptr <socket> sok)
{
- return TLSSocket::wrap(thisRef().dynamicCast <TLSSession>(), sok);
+ return TLSSocket::wrap(dynamicCast <TLSSession>(shared_from_this()), sok);
}
-ref <security::cert::certificateVerifier> TLSSession_OpenSSL::getCertificateVerifier()
+shared_ptr <security::cert::certificateVerifier> TLSSession_OpenSSL::getCertificateVerifier()
{
return m_certVerifier;
}
diff --git a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
index 7fda1f15..9aec43e5 100644
--- a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
+++ b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
@@ -65,14 +65,14 @@ BIO_METHOD TLSSocket_OpenSSL::sm_customBIOMethod =
// static
-ref <TLSSocket> TLSSocket::wrap(ref <TLSSession> session, ref <socket> sok)
+shared_ptr <TLSSocket> TLSSocket::wrap(shared_ptr <TLSSession> session, shared_ptr <socket> sok)
{
- return vmime::create <TLSSocket_OpenSSL>
- (session.dynamicCast <TLSSession_OpenSSL>(), sok);
+ return make_shared <TLSSocket_OpenSSL>
+ (dynamicCast <TLSSession_OpenSSL>(session), sok);
}
-TLSSocket_OpenSSL::TLSSocket_OpenSSL(ref <TLSSession_OpenSSL> session, ref <socket> sok)
+TLSSocket_OpenSSL::TLSSocket_OpenSSL(shared_ptr <TLSSession_OpenSSL> session, shared_ptr <socket> sok)
: m_session(session), m_wrapped(sok), m_connected(false), m_ssl(0), m_ex(NULL)
{
}
@@ -128,7 +128,7 @@ void TLSSocket_OpenSSL::connect(const string& address, const port_t port)
createSSLHandle();
- handshake(NULL);
+ handshake(null);
m_connected = true;
}
@@ -224,7 +224,7 @@ TLSSocket_OpenSSL::size_type TLSSocket_OpenSSL::sendRawNonBlocking(const char* b
}
-void TLSSocket_OpenSSL::handshake(ref <timeoutHandler> toHandler)
+void TLSSocket_OpenSSL::handshake(shared_ptr <timeoutHandler> toHandler)
{
if (toHandler)
toHandler->resetTimeOut();
@@ -245,14 +245,14 @@ void TLSSocket_OpenSSL::handshake(ref <timeoutHandler> toHandler)
{
SSL_free(m_ssl);
m_ssl = 0;
- m_toHandler = NULL;
+ m_toHandler = null;
throw;
}
- m_toHandler = NULL;
+ m_toHandler = null;
// Verify server's certificate(s)
- ref <security::cert::certificateChain> certs = getPeerCertificates();
+ shared_ptr <security::cert::certificateChain> certs = getPeerCertificates();
if (certs == NULL)
throw exceptions::tls_exception("No peer certificate.");
@@ -263,24 +263,24 @@ void TLSSocket_OpenSSL::handshake(ref <timeoutHandler> toHandler)
}
-ref <security::cert::certificateChain> TLSSocket_OpenSSL::getPeerCertificates() const
+shared_ptr <security::cert::certificateChain> TLSSocket_OpenSSL::getPeerCertificates() const
{
STACK_OF(X509)* chain = SSL_get_peer_cert_chain(m_ssl);
if (chain == NULL)
- return NULL;
+ return null;
int certCount = sk_X509_num(chain);
if (certCount == 0)
- return NULL;
+ return null;
bool error = false;
- std::vector <ref <security::cert::certificate> > certs;
+ std::vector <shared_ptr <security::cert::certificate> > certs;
for (int i = 0; i < certCount && !error; i++)
{
- ref <vmime::security::cert::X509Certificate> cert =
+ shared_ptr <vmime::security::cert::X509Certificate> cert =
vmime::security::cert::X509Certificate_OpenSSL::importInternal(sk_X509_value(chain, i));
if (cert)
@@ -290,9 +290,9 @@ ref <security::cert::certificateChain> TLSSocket_OpenSSL::getPeerCertificates()
}
if (error)
- return NULL;
+ return null;
- return vmime::create <security::cert::certificateChain>(certs);
+ return make_shared <security::cert::certificateChain>(certs);
}
diff --git a/src/net/transport.cpp b/src/net/transport.cpp
index 88ea6773..eae4a024 100644
--- a/src/net/transport.cpp
+++ b/src/net/transport.cpp
@@ -43,33 +43,33 @@ namespace vmime {
namespace net {
-transport::transport(ref <session> sess, const serviceInfos& infos, ref <security::authenticator> auth)
+transport::transport(shared_ptr <session> sess, const serviceInfos& infos, shared_ptr <security::authenticator> auth)
: service(sess, infos, auth)
{
}
-ref <headerField> transport::processHeaderField(ref <headerField> field)
+shared_ptr <headerField> transport::processHeaderField(shared_ptr <headerField> field)
{
if (utility::stringUtils::isStringEqualNoCase(field->getName(), fields::BCC))
{
// Remove Bcc headers from the message, as required by the RFC.
// Some SMTP server automatically strip this header (Postfix, qmail),
// and others have an option for this (Exim).
- return NULL;
+ return null;
}
else if (utility::stringUtils::isStringEqualNoCase(field->getName(), fields::RETURN_PATH))
{
// RFC-2821: Return-Path header is added by the final transport system
// that delivers the message to its recipient. Then, it should not be
// transmitted to MSA.
- return NULL;
+ return null;
}
else if (utility::stringUtils::isStringEqualNoCase(field->getName(), fields::ORIGINAL_RECIPIENT))
{
// RFC-2298: Delivering MTA may add the Original-Recipient header and
// discard existing one; so, no need to send it.
- return NULL;
+ return null;
}
// Leave the header field as is
@@ -77,7 +77,7 @@ ref <headerField> transport::processHeaderField(ref <headerField> field)
}
-void transport::processHeader(ref <header> header)
+void transport::processHeader(shared_ptr <header> header)
{
if (header->getFieldCount() == 0)
return;
@@ -85,8 +85,8 @@ void transport::processHeader(ref <header> header)
// Remove/replace fields
for (size_t idx = header->getFieldCount() ; idx != 0 ; --idx)
{
- ref <headerField> field = header->getFieldAt(idx - 1);
- ref <headerField> newField = processHeaderField(field);
+ shared_ptr <headerField> field = header->getFieldAt(idx - 1);
+ shared_ptr <headerField> newField = processHeaderField(field);
if (newField == NULL)
header->removeField(field);
@@ -114,7 +114,7 @@ static void extractMailboxes
{
for (size_t i = 0 ; i < list.getAddressCount() ; ++i)
{
- ref <mailbox> mbox = list.getAddressAt(i)->clone().dynamicCast <mailbox>();
+ shared_ptr <mailbox> mbox = dynamicCast <mailbox>(list.getAddressAt(i)->clone());
if (mbox != NULL)
recipients.appendMailbox(mbox);
@@ -122,15 +122,15 @@ static void extractMailboxes
}
-void transport::send(ref <vmime::message> msg, utility::progressListener* progress)
+void transport::send(shared_ptr <vmime::message> msg, utility::progressListener* progress)
{
// Extract expeditor
mailbox expeditor;
try
{
- const mailbox& mbox = *msg->getHeader()->findField(fields::FROM)->
- getValue().dynamicCast <const mailbox>();
+ const mailbox& mbox =
+ *msg->getHeader()->findField(fields::FROM)->getValue <mailbox>();
expeditor = mbox;
}
@@ -144,8 +144,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
try
{
- const mailbox& mbox = *msg->getHeader()->findField(fields::SENDER)->
- getValue().dynamicCast <const mailbox>();
+ const mailbox& mbox =
+ *msg->getHeader()->findField(fields::SENDER)->getValue <mailbox>();
sender = mbox;
}
@@ -159,8 +159,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
try
{
- const addressList& to = *msg->getHeader()->findField(fields::TO)->
- getValue().dynamicCast <const addressList>();
+ const addressList& to =
+ *msg->getHeader()->findField(fields::TO)->getValue <addressList>();
extractMailboxes(recipients, to);
}
@@ -168,8 +168,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
try
{
- const addressList& cc = *msg->getHeader()->findField(fields::CC)->
- getValue().dynamicCast <const addressList>();
+ const addressList& cc =
+ *msg->getHeader()->findField(fields::CC)->getValue <addressList>();
extractMailboxes(recipients, cc);
}
@@ -177,8 +177,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
try
{
- const addressList& bcc = *msg->getHeader()->findField(fields::BCC)->
- getValue().dynamicCast <const addressList>();
+ const addressList& bcc =
+ *msg->getHeader()->findField(fields::BCC)->getValue <addressList>();
extractMailboxes(recipients, bcc);
}
@@ -187,7 +187,7 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
// Process message header by removing fields that should be removed
// before transmitting the message to MSA, and adding missing fields
// which are required/recommended by the RFCs.
- ref <header> hdr = msg->getHeader()->clone().dynamicCast <header>();
+ shared_ptr <header> hdr = vmime::clone(msg->getHeader());
processHeader(hdr);
// To avoid cloning message body (too much overhead), use processed
@@ -195,8 +195,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
// Revert it back to original header after.
struct XChangeMsgHeader
{
- XChangeMsgHeader(vmime::ref <vmime::message> _msg,
- vmime::ref <vmime::header> _hdr)
+ XChangeMsgHeader(shared_ptr <vmime::message> _msg,
+ shared_ptr <vmime::header> _hdr)
: msg(_msg), hdr(msg->getHeader())
{
// Set new header
@@ -211,8 +211,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
private:
- vmime::ref <vmime::message> msg;
- vmime::ref <vmime::header> hdr;
+ shared_ptr <vmime::message> msg;
+ shared_ptr <vmime::header> hdr;
} headerExchanger(msg, hdr);
send(msg, expeditor, recipients, progress, sender);
@@ -220,7 +220,7 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
void transport::send
- (ref <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
+ (shared_ptr <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
utility::progressListener* progress, const mailbox& sender)
{
// Generate the message, "stream" it and delegate the sending