aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/address.cpp13
-rw-r--r--src/addressList.cpp66
-rw-r--r--src/attachmentHelper.cpp71
-rw-r--r--src/base.cpp8
-rw-r--r--src/body.cpp163
-rw-r--r--src/bodyPart.cpp70
-rw-r--r--src/bodyPartAttachment.cpp28
-rw-r--r--src/charset.cpp12
-rw-r--r--src/charsetConverter.cpp4
-rw-r--r--src/charsetConverter_iconv.cpp8
-rw-r--r--src/charsetConverter_icu.cpp8
-rw-r--r--src/charsetConverter_idna.cpp4
-rw-r--r--src/component.cpp30
-rw-r--r--src/contentDisposition.cpp8
-rw-r--r--src/dateTime.cpp8
-rw-r--r--src/defaultAttachment.cpp26
-rw-r--r--src/disposition.cpp8
-rw-r--r--src/emailAddress.cpp14
-rw-r--r--src/emptyContentHandler.cpp4
-rw-r--r--src/encoding.cpp16
-rw-r--r--src/fileAttachment.cpp20
-rw-r--r--src/fileContentHandler.cpp8
-rw-r--r--src/generatedMessageAttachment.cpp16
-rw-r--r--src/header.cpp82
-rw-r--r--src/headerField.cpp34
-rw-r--r--src/headerFieldFactory.cpp12
-rw-r--r--src/htmlTextPart.cpp106
-rw-r--r--src/mailbox.cpp8
-rw-r--r--src/mailboxField.cpp8
-rw-r--r--src/mailboxGroup.cpp54
-rw-r--r--src/mailboxList.cpp54
-rw-r--r--src/mdn/MDNHelper.cpp82
-rw-r--r--src/mdn/receivedMDNInfos.cpp17
-rw-r--r--src/mdn/sendableMDNInfos.cpp4
-rw-r--r--src/mediaType.cpp8
-rw-r--r--src/messageBuilder.cpp34
-rw-r--r--src/messageId.cpp14
-rw-r--r--src/messageIdSequence.cpp46
-rw-r--r--src/messageParser.cpp64
-rw-r--r--src/misc/importanceHelper.cpp26
-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
-rw-r--r--src/object.cpp50
-rw-r--r--src/parameter.cpp14
-rw-r--r--src/parameterizedHeaderField.cpp64
-rw-r--r--src/parsedMessageAttachment.cpp20
-rw-r--r--src/path.cpp8
-rw-r--r--src/plainTextPart.cpp22
-rw-r--r--src/platform.cpp14
-rw-r--r--src/platforms/posix/posixChildProcess.cpp19
-rw-r--r--src/platforms/posix/posixFile.cpp34
-rw-r--r--src/platforms/posix/posixHandler.cpp16
-rw-r--r--src/platforms/posix/posixSocket.cpp12
-rw-r--r--src/platforms/windows/windowsFile.cpp32
-rw-r--r--src/platforms/windows/windowsHandler.cpp14
-rw-r--r--src/platforms/windows/windowsSocket.cpp12
-rw-r--r--src/propertySet.cpp32
-rw-r--r--src/relay.cpp8
-rw-r--r--src/security/cert/certificateChain.cpp4
-rw-r--r--src/security/cert/defaultCertificateVerifier.cpp32
-rw-r--r--src/security/cert/gnutls/X509Certificate_GnuTLS.cpp28
-rw-r--r--src/security/cert/openssl/X509Certificate_OpenSSL.cpp32
-rw-r--r--src/security/defaultAuthenticator.cpp8
-rw-r--r--src/security/digest/messageDigestFactory.cpp2
-rw-r--r--src/security/sasl/SASLContext.cpp24
-rw-r--r--src/security/sasl/SASLMechanismFactory.cpp8
-rw-r--r--src/security/sasl/SASLSession.cpp26
-rw-r--r--src/security/sasl/SASLSocket.cpp2
-rw-r--r--src/security/sasl/builtinSASLMechanism.cpp8
-rw-r--r--src/security/sasl/defaultSASLAuthenticator.cpp24
-rw-r--r--src/streamContentHandler.cpp20
-rw-r--r--src/stringContentHandler.cpp12
-rw-r--r--src/text.cpp70
-rw-r--r--src/textPartFactory.cpp2
-rw-r--r--src/utility/encoder/encoderFactory.cpp18
-rw-r--r--src/utility/parserInputStreamAdapter.cpp4
-rw-r--r--src/utility/seekableInputStreamRegionAdapter.cpp2
-rw-r--r--src/utility/smartPtr.cpp41
-rw-r--r--src/utility/smartPtrInt.cpp295
-rw-r--r--src/word.cpp23
-rw-r--r--src/wordEncoder.cpp6
134 files changed, 1949 insertions, 2330 deletions
diff --git a/src/address.cpp b/src/address.cpp
index b57892d5..08a478ec 100644
--- a/src/address.cpp
+++ b/src/address.cpp
@@ -66,7 +66,7 @@ address-list = (address *("," address)) / obs-addr-list
*/
-ref <address> address::parseNext
+shared_ptr <address> address::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition, bool *isLastAddressOfGroup)
{
@@ -196,9 +196,12 @@ ref <address> address::parseNext
// Parse extracted address (mailbox or group)
if (pos != start)
{
- ref <address> parsedAddress = isGroup
- ? create <mailboxGroup>().dynamicCast <address>()
- : create <mailbox>().dynamicCast <address>();
+ shared_ptr <address> parsedAddress;
+
+ if (isGroup)
+ parsedAddress = make_shared <mailboxGroup>();
+ else
+ parsedAddress = make_shared <mailbox>();
parsedAddress->parse(ctx, buffer, start, pos, NULL);
parsedAddress->setParsedBounds(start, pos);
@@ -206,7 +209,7 @@ ref <address> address::parseNext
return (parsedAddress);
}
- return (NULL);
+ return null;
}
diff --git a/src/addressList.cpp b/src/addressList.cpp
index 326a54e3..957be503 100644
--- a/src/addressList.cpp
+++ b/src/addressList.cpp
@@ -60,7 +60,7 @@ void addressList::parseImpl
while (pos < end)
{
- ref <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL);
+ shared_ptr <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL);
if (parsedAddress != NULL)
m_list.push_back(parsedAddress);
@@ -84,7 +84,7 @@ void addressList::generateImpl
if (!m_list.empty())
{
- for (std::vector <ref <address> >::const_iterator i = m_list.begin() ; ; )
+ for (std::vector <shared_ptr <address> >::const_iterator i = m_list.begin() ; ; )
{
(*i)->generate(ctx, os, pos, &pos);
@@ -107,10 +107,10 @@ void addressList::copyFrom(const component& other)
removeAllAddresses();
- for (std::vector <ref <address> >::const_iterator it = addrList.m_list.begin() ;
+ for (std::vector <shared_ptr <address> >::const_iterator it = addrList.m_list.begin() ;
it != addrList.m_list.end() ; ++it)
{
- m_list.push_back((*it)->clone().dynamicCast <address>());
+ m_list.push_back(vmime::clone(*it));
}
}
@@ -127,27 +127,27 @@ addressList& addressList::operator=(const mailboxList& other)
removeAllAddresses();
for (size_t i = 0 ; i < other.getMailboxCount() ; ++i)
- m_list.push_back(other.getMailboxAt(i)->clone().dynamicCast <address>());
+ m_list.push_back(dynamicCast <address>(other.getMailboxAt(i)->clone()));
return (*this);
}
-ref <component> addressList::clone() const
+shared_ptr <component> addressList::clone() const
{
- return vmime::create <addressList>(*this);
+ return make_shared <addressList>(*this);
}
-void addressList::appendAddress(ref <address> addr)
+void addressList::appendAddress(shared_ptr <address> addr)
{
m_list.push_back(addr);
}
-void addressList::insertAddressBefore(ref <address> beforeAddress, ref <address> addr)
+void addressList::insertAddressBefore(shared_ptr <address> beforeAddress, shared_ptr <address> addr)
{
- const std::vector <ref <address> >::iterator it = std::find
+ const std::vector <shared_ptr <address> >::iterator it = std::find
(m_list.begin(), m_list.end(), beforeAddress);
if (it == m_list.end())
@@ -157,15 +157,15 @@ void addressList::insertAddressBefore(ref <address> beforeAddress, ref <address>
}
-void addressList::insertAddressBefore(const size_t pos, ref <address> addr)
+void addressList::insertAddressBefore(const size_t pos, shared_ptr <address> addr)
{
m_list.insert(m_list.begin() + pos, addr);
}
-void addressList::insertAddressAfter(ref <address> afterAddress, ref <address> addr)
+void addressList::insertAddressAfter(shared_ptr <address> afterAddress, shared_ptr <address> addr)
{
- const std::vector <ref <address> >::iterator it = std::find
+ const std::vector <shared_ptr <address> >::iterator it = std::find
(m_list.begin(), m_list.end(), afterAddress);
if (it == m_list.end())
@@ -175,15 +175,15 @@ void addressList::insertAddressAfter(ref <address> afterAddress, ref <address> a
}
-void addressList::insertAddressAfter(const size_t pos, ref <address> addr)
+void addressList::insertAddressAfter(const size_t pos, shared_ptr <address> addr)
{
m_list.insert(m_list.begin() + pos + 1, addr);
}
-void addressList::removeAddress(ref <address> addr)
+void addressList::removeAddress(shared_ptr <address> addr)
{
- const std::vector <ref <address> >::iterator it = std::find
+ const std::vector <shared_ptr <address> >::iterator it = std::find
(m_list.begin(), m_list.end(), addr);
if (it == m_list.end())
@@ -195,7 +195,7 @@ void addressList::removeAddress(ref <address> addr)
void addressList::removeAddress(const size_t pos)
{
- const std::vector <ref <address> >::iterator it = m_list.begin() + pos;
+ const std::vector <shared_ptr <address> >::iterator it = m_list.begin() + pos;
m_list.erase(it);
}
@@ -219,25 +219,25 @@ bool addressList::isEmpty() const
}
-ref <address> addressList::getAddressAt(const size_t pos)
+shared_ptr <address> addressList::getAddressAt(const size_t pos)
{
return (m_list[pos]);
}
-const ref <const address> addressList::getAddressAt(const size_t pos) const
+const shared_ptr <const address> addressList::getAddressAt(const size_t pos) const
{
return (m_list[pos]);
}
-const std::vector <ref <const address> > addressList::getAddressList() const
+const std::vector <shared_ptr <const address> > addressList::getAddressList() const
{
- std::vector <ref <const address> > list;
+ std::vector <shared_ptr <const address> > list;
list.reserve(m_list.size());
- for (std::vector <ref <address> >::const_iterator it = m_list.begin() ;
+ for (std::vector <shared_ptr <address> >::const_iterator it = m_list.begin() ;
it != m_list.end() ; ++it)
{
list.push_back(*it);
@@ -247,15 +247,15 @@ const std::vector <ref <const address> > addressList::getAddressList() const
}
-const std::vector <ref <address> > addressList::getAddressList()
+const std::vector <shared_ptr <address> > addressList::getAddressList()
{
return (m_list);
}
-const std::vector <ref <component> > addressList::getChildComponents()
+const std::vector <shared_ptr <component> > addressList::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
copy_vector(m_list, list);
@@ -263,21 +263,21 @@ const std::vector <ref <component> > addressList::getChildComponents()
}
-ref <mailboxList> addressList::toMailboxList() const
+shared_ptr <mailboxList> addressList::toMailboxList() const
{
- ref <mailboxList> res = vmime::create <mailboxList>();
+ shared_ptr <mailboxList> res = make_shared <mailboxList>();
- for (std::vector <ref <address> >::const_iterator it = m_list.begin() ;
+ for (std::vector <shared_ptr <address> >::const_iterator it = m_list.begin() ;
it != m_list.end() ; ++it)
{
- ref <const address> addr = *it;
+ shared_ptr <const address> addr = *it;
if (addr->isGroup())
{
- const std::vector <ref <const mailbox> > mailboxes =
- addr.dynamicCast <const mailboxGroup>()->getMailboxList();
+ const std::vector <shared_ptr <const mailbox> > mailboxes =
+ dynamicCast <const mailboxGroup>(addr)->getMailboxList();
- for (std::vector <ref <const mailbox> >::const_iterator jt = mailboxes.begin() ;
+ for (std::vector <shared_ptr <const mailbox> >::const_iterator jt = mailboxes.begin() ;
jt != mailboxes.end() ; ++jt)
{
res->appendMailbox(vmime::clone(*jt));
@@ -285,7 +285,7 @@ ref <mailboxList> addressList::toMailboxList() const
}
else
{
- res->appendMailbox(addr->clone().dynamicCast <mailbox>());
+ res->appendMailbox(dynamicCast <mailbox>(addr->clone()));
}
}
diff --git a/src/attachmentHelper.cpp b/src/attachmentHelper.cpp
index 16e42bd4..7168fd93 100644
--- a/src/attachmentHelper.cpp
+++ b/src/attachmentHelper.cpp
@@ -39,15 +39,14 @@ namespace vmime
// static
bool attachmentHelper::isBodyPartAnAttachment
- (ref <const bodyPart> part, const unsigned int options)
+ (shared_ptr <const bodyPart> part, const unsigned int options)
{
try
{
- const contentDispositionField& cdf = dynamic_cast<contentDispositionField&>
- (*part->getHeader()->findField(fields::CONTENT_DISPOSITION));
+ const contentDispositionField& cdf =
+ *part->getHeader()->findField <contentDispositionField>(fields::CONTENT_DISPOSITION);
- const contentDisposition disp = *cdf.getValue()
- .dynamicCast <const contentDisposition>();
+ const contentDisposition disp = *cdf.getValue <const contentDisposition>();
if (disp.getName() != contentDispositionTypes::INLINE)
return true;
@@ -80,10 +79,10 @@ bool attachmentHelper::isBodyPartAnAttachment
try
{
- const contentTypeField& ctf = dynamic_cast<contentTypeField&>
- (*part->getHeader()->findField(fields::CONTENT_TYPE));
+ const contentTypeField& ctf =
+ *part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- type = *ctf.getValue().dynamicCast <const mediaType>();
+ type = *ctf.getValue <const mediaType>();
if (ctf.hasParameter("name"))
hasContentTypeName = true;
@@ -125,20 +124,20 @@ bool attachmentHelper::isBodyPartAnAttachment
// static
-ref <const attachment> attachmentHelper::getBodyPartAttachment
- (ref <const bodyPart> part, const unsigned int options)
+shared_ptr <const attachment> attachmentHelper::getBodyPartAttachment
+ (shared_ptr <const bodyPart> part, const unsigned int options)
{
if (!isBodyPartAnAttachment(part, options))
- return NULL;
+ return null;
mediaType type;
try
{
- const contentTypeField& ctf = dynamic_cast<contentTypeField&>
- (*part->getHeader()->findField(fields::CONTENT_TYPE));
+ const contentTypeField& ctf =
+ *part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- type = *ctf.getValue().dynamicCast <const mediaType>();
+ type = *ctf.getValue <mediaType>();
}
catch (exceptions::no_such_field&)
{
@@ -150,30 +149,30 @@ ref <const attachment> attachmentHelper::getBodyPartAttachment
if (type.getType() == mediaTypes::MESSAGE &&
type.getSubType() == mediaTypes::MESSAGE_RFC822)
{
- return vmime::create <generatedMessageAttachment>(part);
+ return make_shared <generatedMessageAttachment>(part);
}
else
{
- return vmime::create <bodyPartAttachment>(part);
+ return make_shared <bodyPartAttachment>(part);
}
}
// static
-const std::vector <ref <const attachment> >
+const std::vector <shared_ptr <const attachment> >
attachmentHelper::findAttachmentsInMessage
- (ref <const message> msg, const unsigned int options)
+ (shared_ptr <const message> msg, const unsigned int options)
{
return findAttachmentsInBodyPart(msg, options);
}
// static
-const std::vector <ref <const attachment> >
+const std::vector <shared_ptr <const attachment> >
attachmentHelper::findAttachmentsInBodyPart
- (ref <const bodyPart> part, const unsigned int options)
+ (shared_ptr <const bodyPart> part, const unsigned int options)
{
- std::vector <ref <const attachment> > atts;
+ std::vector <shared_ptr <const attachment> > atts;
// Test this part
if (isBodyPartAnAttachment(part, options))
@@ -183,11 +182,11 @@ const std::vector <ref <const attachment> >
// Find in sub-parts
else
{
- ref <const body> bdy = part->getBody();
+ shared_ptr <const body> bdy = part->getBody();
for (size_t i = 0 ; i < bdy->getPartCount() ; ++i)
{
- std::vector <ref <const attachment> > partAtts =
+ std::vector <shared_ptr <const attachment> > partAtts =
findAttachmentsInBodyPart(bdy->getPartAt(i), options);
std::copy(partAtts.begin(), partAtts.end(), std::back_inserter(atts));
@@ -199,7 +198,7 @@ const std::vector <ref <const attachment> >
// static
-void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
+void attachmentHelper::addAttachment(shared_ptr <message> msg, shared_ptr <attachment> att)
{
// We simply search for a "multipart/mixed" part. If no one exists,
// create it in the root part. This (very simple) algorithm should
@@ -208,7 +207,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
vmime::mediaType mpMixed(vmime::mediaTypes::MULTIPART,
vmime::mediaTypes::MULTIPART_MIXED);
- ref <bodyPart> part = findBodyPart(msg, mpMixed);
+ shared_ptr <bodyPart> part = findBodyPart(msg, mpMixed);
if (part == NULL) // create it
{
@@ -216,7 +215,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
{
// Create a new container part for the parts that were in
// the root part of the message
- ref <bodyPart> container = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> container = make_shared <bodyPart>();
try
{
@@ -238,7 +237,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
}
// Move parts from the root part to this new part
- const std::vector <ref <bodyPart> > partList =
+ const std::vector <shared_ptr <bodyPart> > partList =
msg->getBody()->getPartList();
msg->getBody()->removeAllParts();
@@ -253,7 +252,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
// The message is a simple (RFC-822) message, and do not
// contains any MIME part. Move the contents from the
// root to a new child part.
- ref <bodyPart> child = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> child = make_shared <bodyPart>();
if (msg->getHeader()->hasField(fields::CONTENT_TYPE))
{
@@ -268,7 +267,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
}
child->getBody()->setContents(msg->getBody()->getContents());
- msg->getBody()->setContents(vmime::create <emptyContentHandler>());
+ msg->getBody()->setContents(make_shared <emptyContentHandler>());
msg->getBody()->appendPart(child);
}
@@ -288,32 +287,32 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
// static
-ref <bodyPart> attachmentHelper::findBodyPart
- (ref <bodyPart> part, const mediaType& type)
+shared_ptr <bodyPart> attachmentHelper::findBodyPart
+ (shared_ptr <bodyPart> part, const mediaType& type)
{
if (part->getBody()->getContentType() == type)
return part;
// Try in sub-parts
- ref <body> bdy = part->getBody();
+ shared_ptr <body> bdy = part->getBody();
for (size_t i = 0 ; i < bdy->getPartCount() ; ++i)
{
- ref <bodyPart> found =
+ shared_ptr <bodyPart> found =
findBodyPart(bdy->getPartAt(i), type);
if (found != NULL)
return found;
}
- return NULL;
+ return null;
}
// static
-void attachmentHelper::addAttachment(ref <message> msg, ref <message> amsg)
+void attachmentHelper::addAttachment(shared_ptr <message> msg, shared_ptr <message> amsg)
{
- ref <attachment> att = vmime::create <parsedMessageAttachment>(amsg);
+ shared_ptr <attachment> att = make_shared <parsedMessageAttachment>(amsg);
addAttachment(msg, att);
}
diff --git a/src/base.cpp b/src/base.cpp
index d5f3e787..f7985376 100644
--- a/src/base.cpp
+++ b/src/base.cpp
@@ -98,9 +98,13 @@ const string CRLF = "\r\n";
const string SUPPORTED_MIME_VERSION = "1.0";
-/** Null reference.
+#ifndef VMIME_BUILDING_DOC
+
+/** Null shared pointer.
*/
-const null_ref null = null_ref();
+nullPtrType null;
+
+#endif // VMIME_BUILDING_DOC
// Line length limits
diff --git a/src/body.cpp b/src/body.cpp
index f1a8cc0f..8d6bab3f 100644
--- a/src/body.cpp
+++ b/src/body.cpp
@@ -44,7 +44,7 @@ namespace vmime
body::body()
- : m_contents(create <emptyContentHandler>()), m_part(NULL), m_header(NULL)
+ : m_contents(make_shared <emptyContentHandler>())
{
}
@@ -56,7 +56,7 @@ body::~body()
// static
utility::stream::size_type body::findNextBoundaryPosition
- (ref <utility::parserInputStreamAdapter> parser, const string& boundary,
+ (shared_ptr <utility::parserInputStreamAdapter> parser, const string& boundary,
const utility::stream::size_type position, const utility::stream::size_type end,
utility::stream::size_type* boundaryStart, utility::stream::size_type* boundaryEnd)
{
@@ -129,7 +129,7 @@ utility::stream::size_type body::findNextBoundaryPosition
void body::parseImpl
(const parsingContext& /* ctx */,
- ref <utility::parserInputStreamAdapter> parser,
+ shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end,
utility::stream::size_type* newPosition)
@@ -156,10 +156,10 @@ void body::parseImpl
try
{
- const ref <const contentTypeField> ctf =
- m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ const shared_ptr <const contentTypeField> ctf =
+ m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- const mediaType type = *ctf->getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf->getValue <mediaType>();
if (type.getType() == mediaTypes::MULTIPART)
{
@@ -302,7 +302,7 @@ void body::parseImpl
}
else // index > 0
{
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = m_part->createChildPart();
// End before start may happen on empty bodyparts (directly
// successive boundaries without even a line-break)
@@ -310,7 +310,6 @@ void body::parseImpl
std::swap(partStart, partEnd);
part->parse(parser, partStart, partEnd, NULL);
- part->m_parent = m_part;
m_parts.push_back(part);
}
@@ -322,12 +321,12 @@ void body::parseImpl
(parser, boundary, boundaryEnd, end, &boundaryStart, &boundaryEnd);
}
- m_contents = vmime::create <emptyContentHandler>();
+ m_contents = make_shared <emptyContentHandler>();
// Last part was not found: recover from missing boundary
if (!lastPart && pos == utility::stream::npos)
{
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = m_part->createChildPart();
try
{
@@ -338,8 +337,6 @@ void body::parseImpl
throw;
}
- part->m_parent = m_part;
-
m_parts.push_back(part);
}
// Treat remaining text as epilog
@@ -358,10 +355,10 @@ void body::parseImpl
try
{
- const ref <const headerField> cef =
- m_header.acquire()->findField(fields::CONTENT_TRANSFER_ENCODING);
+ const shared_ptr <headerField> cef =
+ m_part->getHeader()->findField(fields::CONTENT_TRANSFER_ENCODING);
- enc = *cef->getValue().dynamicCast <const encoding>();
+ enc = *cef->getValue <encoding>();
}
catch (exceptions::no_such_field&)
{
@@ -372,11 +369,11 @@ void body::parseImpl
// Extract the (encoded) contents
const utility::stream::size_type length = end - position;
- ref <utility::inputStream> contentStream =
- vmime::create <utility::seekableInputStreamRegionAdapter>
+ shared_ptr <utility::inputStream> contentStream =
+ make_shared <utility::seekableInputStreamRegionAdapter>
(parser->getUnderlyingStream(), position, length);
- m_contents = vmime::create <streamContentHandler>(contentStream, length, enc);
+ m_contents = make_shared <streamContentHandler>(contentStream, length, enc);
}
setParsedBounds(position, end);
@@ -429,7 +426,7 @@ void body::generateImpl
{
string boundary;
- if (m_header.acquire() == NULL)
+ if (!m_part)
{
boundary = generateRandomBoundaryString();
}
@@ -437,9 +434,8 @@ void body::generateImpl
{
try
{
- ref <const contentTypeField> ctf =
- m_header.acquire()->findField(fields::CONTENT_TYPE)
- .dynamicCast <const contentTypeField>();
+ shared_ptr <contentTypeField> ctf =
+ m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
boundary = ctf->getBoundary();
}
@@ -494,7 +490,7 @@ void body::generateImpl
else
{
// Generate the contents
- ref <contentHandler> contents = m_contents->clone();
+ shared_ptr <contentHandler> contents = m_contents->clone();
contents->setContentTypeHint(getContentType());
contents->generate(os, getEncoding(), ctx.getMaxLineLength());
@@ -548,8 +544,8 @@ utility::stream::size_type body::getGeneratedSize(const generationContext& ctx)
// Simple body
else
{
- ref <utility::encoder::encoder> srcEncoder = m_contents->getEncoding().getEncoder();
- ref <utility::encoder::encoder> dstEncoder = getEncoding().getEncoder();
+ shared_ptr <utility::encoder::encoder> srcEncoder = m_contents->getEncoding().getEncoder();
+ shared_ptr <utility::encoder::encoder> dstEncoder = getEncoding().getEncoder();
return dstEncoder->getEncodedSize(srcEncoder->getDecodedSize(m_contents->getLength()));
}
@@ -646,7 +642,8 @@ bool body::isValidBoundary(const string& boundary)
void body::setContentType(const mediaType& type, const charset& chset)
{
- ref <contentTypeField> ctf = m_header.acquire()->ContentType().dynamicCast <contentTypeField>();
+ shared_ptr <contentTypeField> ctf =
+ dynamicCast <contentTypeField>(m_part->getHeader()->ContentType());
ctf->setValue(type);
ctf->setCharset(chset);
@@ -655,7 +652,7 @@ void body::setContentType(const mediaType& type, const charset& chset)
void body::setContentType(const mediaType& type)
{
- m_header.acquire()->ContentType()->setValue(type);
+ m_part->getHeader()->ContentType()->setValue(type);
}
@@ -663,10 +660,10 @@ const mediaType body::getContentType() const
{
try
{
- ref <const contentTypeField> ctf =
- m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <const contentTypeField>();
+ shared_ptr <const contentTypeField> ctf =
+ m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- return (*ctf->getValue().dynamicCast <const mediaType>());
+ return (*ctf->getValue <mediaType>());
}
catch (exceptions::no_such_field&)
{
@@ -681,8 +678,8 @@ void body::setCharset(const charset& chset)
// If a Content-Type field exists, set charset
try
{
- ref <contentTypeField> ctf =
- m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ shared_ptr <contentTypeField> ctf =
+ m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
ctf->setCharset(chset);
}
@@ -699,8 +696,8 @@ const charset body::getCharset() const
{
try
{
- const ref <const contentTypeField> ctf =
- m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ const shared_ptr <const contentTypeField> ctf =
+ m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
return (ctf->getCharset());
}
@@ -719,7 +716,7 @@ const charset body::getCharset() const
void body::setEncoding(const encoding& enc)
{
- m_header.acquire()->ContentTransferEncoding()->setValue(enc);
+ m_part->getHeader()->ContentTransferEncoding()->setValue(enc);
}
@@ -727,10 +724,10 @@ const encoding body::getEncoding() const
{
try
{
- const ref <const headerField> cef =
- m_header.acquire()->findField(fields::CONTENT_TRANSFER_ENCODING);
+ const shared_ptr <const headerField> cef =
+ m_part->getHeader()->findField(fields::CONTENT_TRANSFER_ENCODING);
- return (*cef->getValue().dynamicCast <const encoding>());
+ return *cef->getValue <encoding>();
}
catch (exceptions::no_such_field&)
{
@@ -747,30 +744,28 @@ const encoding body::getEncoding() const
}
-void body::setParentPart(ref <bodyPart> parent)
+void body::setParentPart(bodyPart* parent)
{
m_part = parent;
- m_header = (parent != NULL ? parent->getHeader() : NULL);
- for (std::vector <ref <bodyPart> >::iterator it = m_parts.begin() ;
+ for (std::vector <shared_ptr <bodyPart> >::iterator it = m_parts.begin() ;
it != m_parts.end() ; ++it)
{
- ref <bodyPart> childPart = *it;
- childPart->m_parent = parent;
+ shared_ptr <bodyPart> childPart = *it;
+ parent->importChildPart(childPart);
}
}
bool body::isRootPart() const
{
- ref <const bodyPart> part = m_part.acquire();
- return (part == NULL || part->getParentPart() == NULL);
+ return (m_part == NULL || m_part->getParentPart() == NULL);
}
-ref <component> body::clone() const
+shared_ptr <component> body::clone() const
{
- ref <body> bdy = vmime::create <body>();
+ shared_ptr <body> bdy = make_shared <body>();
bdy->copyFrom(*this);
@@ -791,9 +786,9 @@ void body::copyFrom(const component& other)
for (size_t p = 0 ; p < bdy.getPartCount() ; ++p)
{
- ref <bodyPart> part = bdy.getPartAt(p)->clone().dynamicCast <bodyPart>();
+ shared_ptr <bodyPart> part = m_part->createChildPart();
- part->m_parent = m_part;
+ part->copyFrom(*bdy.getPartAt(p));
m_parts.push_back(part);
}
@@ -831,19 +826,19 @@ void body::setEpilogText(const string& epilogText)
}
-const ref <const contentHandler> body::getContents() const
+const shared_ptr <const contentHandler> body::getContents() const
{
return (m_contents);
}
-void body::setContents(ref <const contentHandler> contents)
+void body::setContents(shared_ptr <const contentHandler> contents)
{
m_contents = contents;
}
-void body::setContents(ref <const contentHandler> contents, const mediaType& type)
+void body::setContents(shared_ptr <const contentHandler> contents, const mediaType& type)
{
m_contents = contents;
@@ -851,7 +846,7 @@ void body::setContents(ref <const contentHandler> contents, const mediaType& typ
}
-void body::setContents(ref <const contentHandler> contents, const mediaType& type, const charset& chset)
+void body::setContents(shared_ptr <const contentHandler> contents, const mediaType& type, const charset& chset)
{
m_contents = contents;
@@ -859,7 +854,7 @@ void body::setContents(ref <const contentHandler> contents, const mediaType& typ
}
-void body::setContents(ref <const contentHandler> contents, const mediaType& type,
+void body::setContents(shared_ptr <const contentHandler> contents, const mediaType& type,
const charset& chset, const encoding& enc)
{
m_contents = contents;
@@ -869,19 +864,25 @@ void body::setContents(ref <const contentHandler> contents, const mediaType& typ
}
-void body::initNewPart(ref <bodyPart> part)
+void body::initNewPart(shared_ptr <bodyPart> part)
{
- part->m_parent = m_part;
-
- ref <header> hdr = m_header.acquire();
+ // A part can be in only one body at the same time: if part is
+ // already attached to a parent part, remove it from the current
+ // parent part
+ if (part->getParentPart())
+ part->getParentPart()->getBody()->removePart(part);
- if (hdr != NULL)
+ if (m_part != NULL)
{
+ m_part->importChildPart(part);
+
+ shared_ptr <header> hdr = m_part->getHeader();
+
// Check whether we have a boundary string
try
{
- ref <contentTypeField> ctf =
- hdr->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ shared_ptr <contentTypeField> ctf =
+ hdr->findField <contentTypeField>(fields::CONTENT_TYPE);
try
{
@@ -896,7 +897,7 @@ void body::initNewPart(ref <bodyPart> part)
ctf->setBoundary(generateRandomBoundaryString());
}
- if (ctf->getValue().dynamicCast <const mediaType>()->getType() != mediaTypes::MULTIPART)
+ if (ctf->getValue <mediaType>()->getType() != mediaTypes::MULTIPART)
{
// Warning: multi-part body but the Content-Type is
// not specified as "multipart/..."
@@ -906,8 +907,8 @@ void body::initNewPart(ref <bodyPart> part)
{
// No "Content-Type" field: create a new one and generate
// a random boundary string.
- ref <contentTypeField> ctf =
- hdr->getField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ shared_ptr <contentTypeField> ctf =
+ hdr->getField <contentTypeField>(fields::CONTENT_TYPE);
ctf->setValue(mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_MIXED));
ctf->setBoundary(generateRandomBoundaryString());
@@ -916,7 +917,7 @@ void body::initNewPart(ref <bodyPart> part)
}
-void body::appendPart(ref <bodyPart> part)
+void body::appendPart(shared_ptr <bodyPart> part)
{
initNewPart(part);
@@ -924,11 +925,11 @@ void body::appendPart(ref <bodyPart> part)
}
-void body::insertPartBefore(ref <bodyPart> beforePart, ref <bodyPart> part)
+void body::insertPartBefore(shared_ptr <bodyPart> beforePart, shared_ptr <bodyPart> part)
{
initNewPart(part);
- const std::vector <ref <bodyPart> >::iterator it = std::find
+ const std::vector <shared_ptr <bodyPart> >::iterator it = std::find
(m_parts.begin(), m_parts.end(), beforePart);
if (it == m_parts.end())
@@ -938,7 +939,7 @@ void body::insertPartBefore(ref <bodyPart> beforePart, ref <bodyPart> part)
}
-void body::insertPartBefore(const size_t pos, ref <bodyPart> part)
+void body::insertPartBefore(const size_t pos, shared_ptr <bodyPart> part)
{
initNewPart(part);
@@ -946,11 +947,11 @@ void body::insertPartBefore(const size_t pos, ref <bodyPart> part)
}
-void body::insertPartAfter(ref <bodyPart> afterPart, ref <bodyPart> part)
+void body::insertPartAfter(shared_ptr <bodyPart> afterPart, shared_ptr <bodyPart> part)
{
initNewPart(part);
- const std::vector <ref <bodyPart> >::iterator it = std::find
+ const std::vector <shared_ptr <bodyPart> >::iterator it = std::find
(m_parts.begin(), m_parts.end(), afterPart);
if (it == m_parts.end())
@@ -960,7 +961,7 @@ void body::insertPartAfter(ref <bodyPart> afterPart, ref <bodyPart> part)
}
-void body::insertPartAfter(const size_t pos, ref <bodyPart> part)
+void body::insertPartAfter(const size_t pos, shared_ptr <bodyPart> part)
{
initNewPart(part);
@@ -968,9 +969,9 @@ void body::insertPartAfter(const size_t pos, ref <bodyPart> part)
}
-void body::removePart(ref <bodyPart> part)
+void body::removePart(shared_ptr <bodyPart> part)
{
- const std::vector <ref <bodyPart> >::iterator it = std::find
+ const std::vector <shared_ptr <bodyPart> >::iterator it = std::find
(m_parts.begin(), m_parts.end(), part);
if (it == m_parts.end())
@@ -1004,25 +1005,25 @@ bool body::isEmpty() const
}
-ref <bodyPart> body::getPartAt(const size_t pos)
+shared_ptr <bodyPart> body::getPartAt(const size_t pos)
{
return (m_parts[pos]);
}
-const ref <const bodyPart> body::getPartAt(const size_t pos) const
+const shared_ptr <const bodyPart> body::getPartAt(const size_t pos) const
{
return (m_parts[pos]);
}
-const std::vector <ref <const bodyPart> > body::getPartList() const
+const std::vector <shared_ptr <const bodyPart> > body::getPartList() const
{
- std::vector <ref <const bodyPart> > list;
+ std::vector <shared_ptr <const bodyPart> > list;
list.reserve(m_parts.size());
- for (std::vector <ref <bodyPart> >::const_iterator it = m_parts.begin() ;
+ for (std::vector <shared_ptr <bodyPart> >::const_iterator it = m_parts.begin() ;
it != m_parts.end() ; ++it)
{
list.push_back(*it);
@@ -1032,15 +1033,15 @@ const std::vector <ref <const bodyPart> > body::getPartList() const
}
-const std::vector <ref <bodyPart> > body::getPartList()
+const std::vector <shared_ptr <bodyPart> > body::getPartList()
{
return (m_parts);
}
-const std::vector <ref <component> > body::getChildComponents()
+const std::vector <shared_ptr <component> > body::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
copy_vector(m_parts, list);
diff --git a/src/bodyPart.cpp b/src/bodyPart.cpp
index f63fd670..be5b8e3a 100644
--- a/src/bodyPart.cpp
+++ b/src/bodyPart.cpp
@@ -29,26 +29,17 @@ namespace vmime
bodyPart::bodyPart()
- : m_header(vmime::create <header>()),
- m_body(vmime::create <body>()),
- m_parent(NULL)
+ : m_header(make_shared <header>()),
+ m_body(make_shared <body>()),
+ m_parent()
{
- m_body->setParentPart(thisRef().dynamicCast <bodyPart>());
-}
-
-
-bodyPart::bodyPart(weak_ref <vmime::bodyPart> parentPart)
- : m_header(vmime::create <header>()),
- m_body(vmime::create <body>()),
- m_parent(parentPart)
-{
- m_body->setParentPart(thisRef().dynamicCast <bodyPart>());
+ m_body->setParentPart(this);
}
void bodyPart::parseImpl
(const parsingContext& ctx,
- ref <utility::parserInputStreamAdapter> parser,
+ shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end,
utility::stream::size_type* newPosition)
@@ -88,11 +79,11 @@ utility::stream::size_type bodyPart::getGeneratedSize(const generationContext& c
}
-ref <component> bodyPart::clone() const
+shared_ptr <component> bodyPart::clone() const
{
- ref <bodyPart> p = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> p = make_shared <bodyPart>();
- p->m_parent = null;
+ p->m_parent = NULL;
p->m_header->copyFrom(*m_header);
p->m_body->copyFrom(*m_body);
@@ -117,64 +108,79 @@ bodyPart& bodyPart::operator=(const bodyPart& other)
}
-const ref <const header> bodyPart::getHeader() const
+const shared_ptr <const header> bodyPart::getHeader() const
{
return (m_header);
}
-ref <header> bodyPart::getHeader()
+shared_ptr <header> bodyPart::getHeader()
{
return (m_header);
}
-void bodyPart::setHeader(ref <header> h)
+void bodyPart::setHeader(shared_ptr <header> h)
{
m_header = h;
}
-const ref <const body> bodyPart::getBody() const
+const shared_ptr <const body> bodyPart::getBody() const
{
return (m_body);
}
-ref <body> bodyPart::getBody()
+shared_ptr <body> bodyPart::getBody()
{
return (m_body);
}
-void bodyPart::setBody(ref <body> b)
+void bodyPart::setBody(shared_ptr <body> b)
{
- ref <bodyPart> oldPart = b->m_part.acquire();
+ bodyPart* oldPart = b->m_part;
m_body = b;
- m_body->setParentPart(thisRef().dynamicCast <bodyPart>());
+ m_body->setParentPart(this);
// A body is associated to one and only one part
if (oldPart != NULL)
- oldPart->setBody(vmime::create <body>());
+ oldPart->setBody(make_shared <body>());
}
-ref <bodyPart> bodyPart::getParentPart()
+bodyPart* bodyPart::getParentPart()
{
- return m_parent.acquire();
+ return m_parent;
+}
+
+
+const bodyPart* bodyPart::getParentPart() const
+{
+ return m_parent;
+}
+
+
+shared_ptr <bodyPart> bodyPart::createChildPart()
+{
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
+ part->m_parent = this;
+
+ return part;
}
-ref <const bodyPart> bodyPart::getParentPart() const
+void bodyPart::importChildPart(shared_ptr <bodyPart> part)
{
- return m_parent.acquire();
+ part->m_parent = this;
}
-const std::vector <ref <component> > bodyPart::getChildComponents()
+const std::vector <shared_ptr <component> > bodyPart::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
list.push_back(m_header);
list.push_back(m_body);
diff --git a/src/bodyPartAttachment.cpp b/src/bodyPartAttachment.cpp
index 5ae433ad..c8361238 100644
--- a/src/bodyPartAttachment.cpp
+++ b/src/bodyPartAttachment.cpp
@@ -28,7 +28,7 @@ namespace vmime
{
-bodyPartAttachment::bodyPartAttachment(ref <const bodyPart> part)
+bodyPartAttachment::bodyPartAttachment(shared_ptr <const bodyPart> part)
: m_part(part)
{
}
@@ -40,7 +40,7 @@ const mediaType bodyPartAttachment::getType() const
try
{
- type = *getContentType()->getValue().dynamicCast <const mediaType>();
+ type = *getContentType()->getValue <mediaType>();
}
catch (exceptions::no_such_field&)
{
@@ -76,7 +76,7 @@ const word bodyPartAttachment::getName() const
{
try
{
- ref <parameter> prm = getContentType()->findParameter("name");
+ shared_ptr <parameter> prm = getContentType()->findParameter("name");
if (prm != NULL)
name = prm->getValue();
@@ -101,10 +101,10 @@ const text bodyPartAttachment::getDescription() const
try
{
- ref <const headerField> cd =
+ shared_ptr <const headerField> cd =
getHeader()->findField(fields::CONTENT_DESCRIPTION);
- description = *cd->getValue().dynamicCast <const text>();
+ description = *cd->getValue <text>();
}
catch (exceptions::no_such_field&)
{
@@ -121,39 +121,37 @@ const encoding bodyPartAttachment::getEncoding() const
}
-const ref <const contentHandler> bodyPartAttachment::getData() const
+const shared_ptr <const contentHandler> bodyPartAttachment::getData() const
{
return m_part->getBody()->getContents();
}
-ref <const object> bodyPartAttachment::getPart() const
+shared_ptr <const object> bodyPartAttachment::getPart() const
{
return m_part;
}
-ref <const header> bodyPartAttachment::getHeader() const
+shared_ptr <const header> bodyPartAttachment::getHeader() const
{
return m_part->getHeader();
}
-ref <const contentDispositionField> bodyPartAttachment::getContentDisposition() const
+shared_ptr <const contentDispositionField> bodyPartAttachment::getContentDisposition() const
{
- return getHeader()->findField(fields::CONTENT_DISPOSITION).
- dynamicCast <const contentDispositionField>();
+ return getHeader()->findField <contentDispositionField>(fields::CONTENT_DISPOSITION);
}
-ref <const contentTypeField> bodyPartAttachment::getContentType() const
+shared_ptr <const contentTypeField> bodyPartAttachment::getContentType() const
{
- return getHeader()->findField(fields::CONTENT_TYPE).
- dynamicCast <const contentTypeField>();
+ return getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
}
-void bodyPartAttachment::generateIn(ref <bodyPart> /* parent */) const
+void bodyPartAttachment::generateIn(shared_ptr <bodyPart> /* parent */) const
{
// Not used
}
diff --git a/src/charset.cpp b/src/charset.cpp
index f68c7c4f..03c7b6a9 100644
--- a/src/charset.cpp
+++ b/src/charset.cpp
@@ -90,7 +90,7 @@ void charset::convert(utility::inputStream& in, utility::outputStream& out,
const charset& source, const charset& dest,
const charsetConverterOptions& opts)
{
- ref <charsetConverter> conv = charsetConverter::create(source, dest, opts);
+ shared_ptr <charsetConverter> conv = charsetConverter::create(source, dest, opts);
conv->convert(in, out);
}
@@ -104,7 +104,7 @@ void charset::convert(const string& in, string& out, const charset& source, cons
return;
}
- ref <charsetConverter> conv = charsetConverter::create(source, dest, opts);
+ shared_ptr <charsetConverter> conv = charsetConverter::create(source, dest, opts);
conv->convert(in, out);
}
@@ -134,9 +134,9 @@ bool charset::operator!=(const charset& value) const
}
-ref <component> charset::clone() const
+shared_ptr <component> charset::clone() const
{
- return vmime::create <charset>(m_name);
+ return make_shared <charset>(m_name);
}
@@ -152,9 +152,9 @@ void charset::copyFrom(const component& other)
}
-const std::vector <ref <component> > charset::getChildComponents()
+const std::vector <shared_ptr <component> > charset::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/charsetConverter.cpp b/src/charsetConverter.cpp
index 5d3ab626..87886823 100644
--- a/src/charsetConverter.cpp
+++ b/src/charsetConverter.cpp
@@ -31,12 +31,12 @@ namespace vmime
// static
-ref <charsetConverter> charsetConverter::create
+shared_ptr <charsetConverter> charsetConverter::create
(const charset& source, const charset& dest,
const charsetConverterOptions& opts)
{
if (source == "idna" || dest == "idna")
- return vmime::create <charsetConverter_idna>(source, dest, opts);
+ return make_shared <charsetConverter_idna>(source, dest, opts);
else
return createGenericConverter(source, dest, opts);
}
diff --git a/src/charsetConverter_iconv.cpp b/src/charsetConverter_iconv.cpp
index 43556298..0efa8445 100644
--- a/src/charsetConverter_iconv.cpp
+++ b/src/charsetConverter_iconv.cpp
@@ -89,11 +89,11 @@ namespace vmime
// static
-ref <charsetConverter> charsetConverter::createGenericConverter
+shared_ptr <charsetConverter> charsetConverter::createGenericConverter
(const charset& source, const charset& dest,
const charsetConverterOptions& opts)
{
- return vmime::create <charsetConverter_iconv>(source, dest, opts);
+ return make_shared <charsetConverter_iconv>(source, dest, opts);
}
@@ -222,9 +222,9 @@ void charsetConverter_iconv::convert(const string& in, string& out)
}
-ref <utility::charsetFilteredOutputStream> charsetConverter_iconv::getFilteredOutputStream(utility::outputStream& os)
+shared_ptr <utility::charsetFilteredOutputStream> charsetConverter_iconv::getFilteredOutputStream(utility::outputStream& os)
{
- return vmime::create <utility::charsetFilteredOutputStream_iconv>(m_source, m_dest, &os);
+ return make_shared <utility::charsetFilteredOutputStream_iconv>(m_source, m_dest, &os);
}
diff --git a/src/charsetConverter_icu.cpp b/src/charsetConverter_icu.cpp
index 581d933b..a641d5ee 100644
--- a/src/charsetConverter_icu.cpp
+++ b/src/charsetConverter_icu.cpp
@@ -53,11 +53,11 @@ namespace vmime
// static
-ref <charsetConverter> charsetConverter::createGenericConverter
+shared_ptr <charsetConverter> charsetConverter::createGenericConverter
(const charset& source, const charset& dest,
const charsetConverterOptions& opts)
{
- return vmime::create <charsetConverter_icu>(source, dest, opts);
+ return make_shared <charsetConverter_icu>(source, dest, opts);
}
@@ -195,9 +195,9 @@ void charsetConverter_icu::convert(const string& in, string& out)
}
-ref <utility::charsetFilteredOutputStream> charsetConverter_icu::getFilteredOutputStream(utility::outputStream& os)
+shared_ptr <utility::charsetFilteredOutputStream> charsetConverter_icu::getFilteredOutputStream(utility::outputStream& os)
{
- return vmime::create <utility::charsetFilteredOutputStream_icu>(m_source, m_dest, &os);
+ return make_shared <utility::charsetFilteredOutputStream_icu>(m_source, m_dest, &os);
}
diff --git a/src/charsetConverter_idna.cpp b/src/charsetConverter_idna.cpp
index cde2209a..a6b339b6 100644
--- a/src/charsetConverter_idna.cpp
+++ b/src/charsetConverter_idna.cpp
@@ -159,9 +159,9 @@ void charsetConverter_idna::convert(const string& in, string& out)
}
-ref <utility::charsetFilteredOutputStream> charsetConverter_idna::getFilteredOutputStream(utility::outputStream& /* os */)
+shared_ptr <utility::charsetFilteredOutputStream> charsetConverter_idna::getFilteredOutputStream(utility::outputStream& /* os */)
{
- return NULL;
+ return null;
}
diff --git a/src/component.cpp b/src/component.cpp
index d2138b60..cb013899 100644
--- a/src/component.cpp
+++ b/src/component.cpp
@@ -47,14 +47,14 @@ component::~component()
void component::parse
- (ref <utility::inputStream> inputStream, const utility::stream::size_type length)
+ (shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type length)
{
parse(inputStream, 0, length, NULL);
}
void component::parse
- (ref <utility::inputStream> inputStream, const utility::stream::size_type position,
+ (shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type position,
const utility::stream::size_type end, utility::stream::size_type* newPosition)
{
parse(parsingContext::getDefaultContext(), inputStream, position, end, newPosition);
@@ -63,13 +63,13 @@ void component::parse
void component::parse
(const parsingContext& ctx,
- ref <utility::inputStream> inputStream, const utility::stream::size_type position,
+ shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type position,
const utility::stream::size_type end, utility::stream::size_type* newPosition)
{
m_parsedOffset = m_parsedLength = 0;
- ref <utility::seekableInputStream> seekableStream =
- inputStream.dynamicCast <utility::seekableInputStream>();
+ shared_ptr <utility::seekableInputStream> seekableStream =
+ dynamicCast <utility::seekableInputStream>(inputStream);
if (seekableStream == NULL || end == 0)
{
@@ -84,8 +84,8 @@ void component::parse
}
else
{
- ref <utility::parserInputStreamAdapter> parser =
- vmime::create <utility::parserInputStreamAdapter>(seekableStream);
+ shared_ptr <utility::parserInputStreamAdapter> parser =
+ make_shared <utility::parserInputStreamAdapter>(seekableStream);
parseImpl(ctx, parser, position, end, newPosition);
}
@@ -136,7 +136,7 @@ void component::offsetParsedBounds(const utility::stream::size_type offset)
m_parsedOffset += offset;
// Offset parsed bounds of our children
- std::vector <ref <component> > children = getChildComponents();
+ std::vector <shared_ptr <component> > children = getChildComponents();
for (size_t i = 0, n = children.size() ; i < n ; ++i)
children[i]->offsetParsedBounds(offset);
@@ -144,7 +144,7 @@ void component::offsetParsedBounds(const utility::stream::size_type offset)
void component::parseImpl
- (const parsingContext& ctx, ref <utility::parserInputStreamAdapter> parser,
+ (const parsingContext& ctx, shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end, utility::stream::size_type* newPosition)
{
@@ -169,11 +169,11 @@ void component::parseImpl
// This is the default implementation for parsing from a string:
// actually, we encapsulate the string buffer in an input stream, then use
// the "parse from input stream" implementation
- ref <utility::seekableInputStream> stream =
- vmime::create <utility::inputStreamStringAdapter>(buffer);
+ shared_ptr <utility::seekableInputStream> stream =
+ make_shared <utility::inputStreamStringAdapter>(buffer);
- ref <utility::parserInputStreamAdapter> parser =
- vmime::create <utility::parserInputStreamAdapter>(stream);
+ shared_ptr <utility::parserInputStreamAdapter> parser =
+ make_shared <utility::parserInputStreamAdapter>(stream);
parseImpl(ctx, parser, position, end, newPosition);
}
@@ -235,10 +235,10 @@ void component::setParsedBounds(const string::size_type start, const string::siz
utility::stream::size_type component::getGeneratedSize(const generationContext& ctx)
{
- std::vector <ref <component> > children = getChildComponents();
+ std::vector <shared_ptr <component> > children = getChildComponents();
utility::stream::size_type totalSize = 0;
- for (std::vector <ref <component> >::iterator it = children.begin() ; it != children.end() ; ++it)
+ for (std::vector <shared_ptr <component> >::iterator it = children.begin() ; it != children.end() ; ++it)
totalSize += (*it)->getGeneratedSize(ctx);
return totalSize;
diff --git a/src/contentDisposition.cpp b/src/contentDisposition.cpp
index 300d4ee3..aa9b4fe3 100644
--- a/src/contentDisposition.cpp
+++ b/src/contentDisposition.cpp
@@ -91,9 +91,9 @@ bool contentDisposition::operator!=(const contentDisposition& value) const
}
-ref <component> contentDisposition::clone() const
+shared_ptr <component> contentDisposition::clone() const
{
- return vmime::create <contentDisposition>(*this);
+ return make_shared <contentDisposition>(*this);
}
@@ -124,9 +124,9 @@ void contentDisposition::setName(const string& name)
}
-const std::vector <ref <component> > contentDisposition::getChildComponents()
+const std::vector <shared_ptr <component> > contentDisposition::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/dateTime.cpp b/src/dateTime.cpp
index a0c03ede..2c045e6d 100644
--- a/src/dateTime.cpp
+++ b/src/dateTime.cpp
@@ -776,15 +776,15 @@ const datetime datetime::now()
}
-ref <component> datetime::clone() const
+shared_ptr <component> datetime::clone() const
{
- return vmime::create <datetime>(*this);
+ return make_shared <datetime>(*this);
}
-const std::vector <ref <component> > datetime::getChildComponents()
+const std::vector <shared_ptr <component> > datetime::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/defaultAttachment.cpp b/src/defaultAttachment.cpp
index 9076fdb3..8f8ad453 100644
--- a/src/defaultAttachment.cpp
+++ b/src/defaultAttachment.cpp
@@ -37,14 +37,14 @@ defaultAttachment::defaultAttachment()
}
-defaultAttachment::defaultAttachment(ref <const contentHandler> data,
+defaultAttachment::defaultAttachment(shared_ptr <const contentHandler> data,
const encoding& enc, const mediaType& type, const text& desc, const word& name)
: m_type(type), m_desc(desc), m_data(data), m_encoding(enc), m_name(name)
{
}
-defaultAttachment::defaultAttachment(ref <const contentHandler> data,
+defaultAttachment::defaultAttachment(shared_ptr <const contentHandler> data,
const mediaType& type, const text& desc, const word& name)
: m_type(type), m_desc(desc), m_data(data),
m_encoding(encoding::decide(data)), m_name(name)
@@ -54,7 +54,7 @@ defaultAttachment::defaultAttachment(ref <const contentHandler> data,
defaultAttachment::defaultAttachment(const defaultAttachment& attach)
: attachment(), m_type(attach.m_type), m_desc(attach.m_desc),
- m_data(attach.m_data->clone().dynamicCast <contentHandler>()),
+ m_data(vmime::clone(attach.m_data)),
m_encoding(attach.m_encoding), m_name(attach.m_name)
{
}
@@ -70,31 +70,31 @@ defaultAttachment& defaultAttachment::operator=(const defaultAttachment& attach)
m_type = attach.m_type;
m_desc = attach.m_desc;
m_name = attach.m_name;
- m_data = attach.m_data->clone().dynamicCast <contentHandler>();
+ m_data = vmime::clone(attach.m_data);
m_encoding = attach.m_encoding;
return (*this);
}
-void defaultAttachment::generateIn(ref <bodyPart> parent) const
+void defaultAttachment::generateIn(shared_ptr <bodyPart> parent) const
{
// Create and append a new part for this attachment
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
parent->getBody()->appendPart(part);
generatePart(part);
}
-void defaultAttachment::generatePart(ref <bodyPart> part) const
+void defaultAttachment::generatePart(shared_ptr <bodyPart> part) const
{
// Set header fields
part->getHeader()->ContentType()->setValue(m_type);
if (!m_desc.isEmpty()) part->getHeader()->ContentDescription()->setValue(m_desc);
part->getHeader()->ContentTransferEncoding()->setValue(m_encoding);
part->getHeader()->ContentDisposition()->setValue(contentDisposition(contentDispositionTypes::ATTACHMENT));
- part->getHeader()->ContentDisposition().dynamicCast <contentDispositionField>()->setFilename(m_name);
+ dynamicCast <contentDispositionField>(part->getHeader()->ContentDisposition())->setFilename(m_name);
// Set contents
part->getBody()->setContents(m_data);
@@ -119,7 +119,7 @@ const word defaultAttachment::getName() const
}
-const ref <const contentHandler> defaultAttachment::getData() const
+const shared_ptr <const contentHandler> defaultAttachment::getData() const
{
return m_data;
}
@@ -131,15 +131,15 @@ const encoding defaultAttachment::getEncoding() const
}
-ref <const object> defaultAttachment::getPart() const
+shared_ptr <const object> defaultAttachment::getPart() const
{
- return NULL;
+ return null;
}
-ref <const header> defaultAttachment::getHeader() const
+shared_ptr <const header> defaultAttachment::getHeader() const
{
- return NULL;
+ return null;
}
diff --git a/src/disposition.cpp b/src/disposition.cpp
index c5da6e30..08e34afc 100644
--- a/src/disposition.cpp
+++ b/src/disposition.cpp
@@ -44,9 +44,9 @@ disposition::disposition(const string& actionMode, const string& sendingMode,
}
-ref <component> disposition::clone() const
+shared_ptr <component> disposition::clone() const
{
- ref <disposition> disp = vmime::create <disposition>();
+ shared_ptr <disposition> disp = make_shared <disposition>();
disp->m_actionMode = m_actionMode;
disp->m_sendingMode = m_sendingMode;
@@ -79,9 +79,9 @@ disposition& disposition::operator=(const disposition& other)
}
-const std::vector <ref <component> > disposition::getChildComponents()
+const std::vector <shared_ptr <component> > disposition::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/emailAddress.cpp b/src/emailAddress.cpp
index c4119aba..eb76e16d 100644
--- a/src/emailAddress.cpp
+++ b/src/emailAddress.cpp
@@ -469,9 +469,9 @@ emailAddress& emailAddress::operator=(const emailAddress& other)
}
-ref <component>emailAddress::clone() const
+shared_ptr <component>emailAddress::clone() const
{
- return vmime::create <emailAddress>(*this);
+ return make_shared <emailAddress>(*this);
}
@@ -499,9 +499,9 @@ void emailAddress::setDomainName(const word& domainName)
}
-const std::vector <ref <component> > emailAddress::getChildComponents()
+const std::vector <shared_ptr <component> > emailAddress::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
@@ -528,9 +528,9 @@ const string emailAddress::toString() const
const text emailAddress::toText() const
{
text txt;
- txt.appendWord(vmime::create <vmime::word>(m_localName));
- txt.appendWord(vmime::create <vmime::word>("@", vmime::charsets::US_ASCII));
- txt.appendWord(vmime::create <vmime::word>(m_domainName));
+ txt.appendWord(make_shared <vmime::word>(m_localName));
+ txt.appendWord(make_shared <vmime::word>("@", vmime::charsets::US_ASCII));
+ txt.appendWord(make_shared <vmime::word>(m_domainName));
return txt;
}
diff --git a/src/emptyContentHandler.cpp b/src/emptyContentHandler.cpp
index 07b53391..f6cdee95 100644
--- a/src/emptyContentHandler.cpp
+++ b/src/emptyContentHandler.cpp
@@ -33,9 +33,9 @@ emptyContentHandler::emptyContentHandler()
}
-ref <contentHandler> emptyContentHandler::clone() const
+shared_ptr <contentHandler> emptyContentHandler::clone() const
{
- return vmime::create <emptyContentHandler>();
+ return make_shared <emptyContentHandler>();
}
diff --git a/src/encoding.cpp b/src/encoding.cpp
index 53f88531..317d441f 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -92,9 +92,9 @@ void encoding::generateImpl
}
-ref <utility::encoder::encoder> encoding::getEncoder() const
+shared_ptr <utility::encoder::encoder> encoding::getEncoder() const
{
- ref <utility::encoder::encoder> encoder =
+ shared_ptr <utility::encoder::encoder> encoder =
utility::encoder::encoderFactory::getInstance()->create(generate());
// FIXME: this should not be here (move me into QP encoder instead?)
@@ -200,7 +200,7 @@ bool encoding::shouldReencode() const
const encoding encoding::decide
- (ref <const contentHandler> data, const EncodingUsage usage)
+ (shared_ptr <const contentHandler> data, const EncodingUsage usage)
{
// Do not re-encode data if it is already encoded
if (data->isEncoded() && !data->getEncoding().shouldReencode())
@@ -231,7 +231,7 @@ const encoding encoding::decide
}
-const encoding encoding::decide(ref <const contentHandler> data,
+const encoding encoding::decide(shared_ptr <const contentHandler> data,
const charset& chset, const EncodingUsage usage)
{
// Do not re-encode data if it is already encoded
@@ -253,9 +253,9 @@ const encoding encoding::decide(ref <const contentHandler> data,
}
-ref <component> encoding::clone() const
+shared_ptr <component> encoding::clone() const
{
- return vmime::create <encoding>(*this);
+ return make_shared <encoding>(*this);
}
@@ -291,9 +291,9 @@ void encoding::setUsage(const EncodingUsage usage)
}
-const std::vector <ref <component> > encoding::getChildComponents()
+const std::vector <shared_ptr <component> > encoding::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/fileAttachment.cpp b/src/fileAttachment.cpp
index 4f4a87d3..1db1a1a8 100644
--- a/src/fileAttachment.cpp
+++ b/src/fileAttachment.cpp
@@ -79,7 +79,7 @@ fileAttachment::fileAttachment(const string& filepath, const mediaType& type,
}
-fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename, const mediaType& type)
+fileAttachment::fileAttachment(shared_ptr <contentHandler> cts, const word& filename, const mediaType& type)
{
if (!filename.isEmpty())
m_fileInfo.setFilename(filename);
@@ -92,7 +92,7 @@ fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename, c
}
-fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
+fileAttachment::fileAttachment(shared_ptr <contentHandler> cts, const word& filename,
const mediaType& type, const text& desc)
{
if (!filename.isEmpty())
@@ -107,7 +107,7 @@ fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
}
-fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
+fileAttachment::fileAttachment(shared_ptr <contentHandler> cts, const word& filename,
const mediaType& type, const text& desc, const encoding& enc)
{
if (!filename.isEmpty())
@@ -123,15 +123,15 @@ fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
void fileAttachment::setData(const string& filepath)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path path = fsf->stringToPath(filepath);
- ref <utility::file> file = fsf->create(path);
+ shared_ptr <utility::file> file = fsf->create(path);
if (!file->isFile())
throw exceptions::open_file_error();
- m_data = vmime::create <streamContentHandler>
+ m_data = make_shared <streamContentHandler>
(file->getFileReader()->getInputStream(), file->getLength());
m_fileInfo.setFilename(path.getLastComponent());
@@ -139,7 +139,7 @@ void fileAttachment::setData(const string& filepath)
}
-void fileAttachment::setData(ref <contentHandler> cts)
+void fileAttachment::setData(shared_ptr <contentHandler> cts)
{
m_data = cts;
@@ -147,12 +147,12 @@ void fileAttachment::setData(ref <contentHandler> cts)
}
-void fileAttachment::generatePart(ref <bodyPart> part) const
+void fileAttachment::generatePart(shared_ptr <bodyPart> part) const
{
defaultAttachment::generatePart(part);
- ref <contentDispositionField> cdf = part->getHeader()->ContentDisposition().
- dynamicCast <contentDispositionField>();
+ shared_ptr <contentDispositionField> cdf =
+ dynamicCast <contentDispositionField>(part->getHeader()->ContentDisposition());
if (m_fileInfo.hasSize()) cdf->setSize(utility::stringUtils::toString(m_fileInfo.getSize()));
if (m_fileInfo.hasFilename() && !m_fileInfo.getFilename().isEmpty()) cdf->setFilename(m_fileInfo.getFilename());
diff --git a/src/fileContentHandler.cpp b/src/fileContentHandler.cpp
index 295bc887..53ec9f69 100644
--- a/src/fileContentHandler.cpp
+++ b/src/fileContentHandler.cpp
@@ -35,7 +35,7 @@ fileContentHandler::fileContentHandler()
fileContentHandler::fileContentHandler
- (ref <utility::file> file, const vmime::encoding& enc)
+ (shared_ptr <utility::file> file, const vmime::encoding& enc)
{
setData(file, enc);
}
@@ -61,14 +61,14 @@ fileContentHandler& fileContentHandler::operator=(const fileContentHandler& cts)
}
-ref <contentHandler> fileContentHandler::clone() const
+shared_ptr <contentHandler> fileContentHandler::clone() const
{
- return vmime::create <fileContentHandler>(*this);
+ return make_shared <fileContentHandler>(*this);
}
void fileContentHandler::setData
- (ref <utility::file> file, const vmime::encoding& enc)
+ (shared_ptr <utility::file> file, const vmime::encoding& enc)
{
m_file = file;
m_encoding = enc;
diff --git a/src/generatedMessageAttachment.cpp b/src/generatedMessageAttachment.cpp
index 927d3d43..0473d247 100644
--- a/src/generatedMessageAttachment.cpp
+++ b/src/generatedMessageAttachment.cpp
@@ -30,8 +30,8 @@ namespace vmime
{
-generatedMessageAttachment::generatedMessageAttachment(ref <const bodyPart> part)
- : m_bpa(vmime::create <bodyPartAttachment>(part))
+generatedMessageAttachment::generatedMessageAttachment(shared_ptr <const bodyPart> part)
+ : m_bpa(make_shared <bodyPartAttachment>(part))
{
}
@@ -54,7 +54,7 @@ const word generatedMessageAttachment::getName() const
}
-const ref <const contentHandler> generatedMessageAttachment::getData() const
+const shared_ptr <const contentHandler> generatedMessageAttachment::getData() const
{
return m_bpa->getData();
}
@@ -66,19 +66,19 @@ const encoding generatedMessageAttachment::getEncoding() const
}
-ref <const object> generatedMessageAttachment::getPart() const
+shared_ptr <const object> generatedMessageAttachment::getPart() const
{
return m_bpa->getPart();
}
-ref <const header> generatedMessageAttachment::getHeader() const
+shared_ptr <const header> generatedMessageAttachment::getHeader() const
{
return m_bpa->getHeader();
}
-ref <message> generatedMessageAttachment::getMessage() const
+shared_ptr <message> generatedMessageAttachment::getMessage() const
{
if (m_msg == NULL)
{
@@ -89,7 +89,7 @@ ref <message> generatedMessageAttachment::getMessage() const
getData()->extract(os);
// Parse message
- m_msg = vmime::create <message>();
+ m_msg = make_shared <message>();
m_msg->parse(oss.str());
}
@@ -97,7 +97,7 @@ ref <message> generatedMessageAttachment::getMessage() const
}
-void generatedMessageAttachment::generateIn(ref <bodyPart> /* parent */) const
+void generatedMessageAttachment::generateIn(shared_ptr <bodyPart> /* parent */) const
{
// Not used (see 'parsedMessageAttachment')
}
diff --git a/src/header.cpp b/src/header.cpp
index ec98976f..8e04cadc 100644
--- a/src/header.cpp
+++ b/src/header.cpp
@@ -72,7 +72,7 @@ void header::parseImpl
while (pos < end)
{
- ref <headerField> field = headerField::parseNext(ctx, buffer, pos, end, &pos);
+ shared_ptr <headerField> field = headerField::parseNext(ctx, buffer, pos, end, &pos);
if (field == NULL) break;
m_fields.push_back(field);
@@ -90,7 +90,7 @@ void header::generateImpl
const string::size_type /* curLinePos */, string::size_type* newLinePos) const
{
// Generate the fields
- for (std::vector <ref <headerField> >::const_iterator it = m_fields.begin() ;
+ for (std::vector <shared_ptr <headerField> >::const_iterator it = m_fields.begin() ;
it != m_fields.end() ; ++it)
{
(*it)->generate(ctx, os);
@@ -108,16 +108,16 @@ utility::stream::size_type header::getGeneratedSize(const generationContext& ctx
}
-ref <component> header::clone() const
+shared_ptr <component> header::clone() const
{
- ref <header> hdr = vmime::create <header>();
+ shared_ptr <header> hdr = make_shared <header>();
hdr->m_fields.reserve(m_fields.size());
- for (std::vector <ref <headerField> >::const_iterator it = m_fields.begin() ;
+ for (std::vector <shared_ptr <headerField> >::const_iterator it = m_fields.begin() ;
it != m_fields.end() ; ++it)
{
- hdr->m_fields.push_back((*it)->clone().dynamicCast <headerField>());
+ hdr->m_fields.push_back(vmime::clone(*it));
}
return (hdr);
@@ -128,14 +128,14 @@ void header::copyFrom(const component& other)
{
const header& h = dynamic_cast <const header&>(other);
- std::vector <ref <headerField> > fields;
+ std::vector <shared_ptr <headerField> > fields;
fields.reserve(h.m_fields.size());
- for (std::vector <ref <headerField> >::const_iterator it = h.m_fields.begin() ;
+ for (std::vector <shared_ptr <headerField> >::const_iterator it = h.m_fields.begin() ;
it != h.m_fields.end() ; ++it)
{
- fields.push_back((*it)->clone().dynamicCast <headerField>());
+ fields.push_back(vmime::clone(*it));
}
m_fields.clear();
@@ -154,7 +154,7 @@ header& header::operator=(const header& other)
bool header::hasField(const string& fieldName) const
{
- std::vector <ref <headerField> >::const_iterator pos =
+ std::vector <shared_ptr <headerField> >::const_iterator pos =
std::find_if(m_fields.begin(), m_fields.end(),
fieldHasName(utility::stringUtils::toLower(fieldName)));
@@ -162,10 +162,10 @@ bool header::hasField(const string& fieldName) const
}
-ref <headerField> header::findField(const string& fieldName) const
+shared_ptr <headerField> header::findField(const string& fieldName) const
{
// Find the first field that matches the specified name
- std::vector <ref <headerField> >::const_iterator pos =
+ std::vector <shared_ptr <headerField> >::const_iterator pos =
std::find_if(m_fields.begin(), m_fields.end(),
fieldHasName(utility::stringUtils::toLower(fieldName)));
@@ -182,10 +182,10 @@ ref <headerField> header::findField(const string& fieldName) const
}
-std::vector <ref <headerField> > header::findAllFields(const string& fieldName)
+std::vector <shared_ptr <headerField> > header::findAllFields(const string& fieldName)
{
- std::vector <ref <headerField> > result;
- std::back_insert_iterator <std::vector <ref <headerField> > > back(result);
+ std::vector <shared_ptr <headerField> > result;
+ std::back_insert_iterator <std::vector <shared_ptr <headerField> > > back(result);
std::remove_copy_if(m_fields.begin(), m_fields.end(), back,
fieldHasNotName(utility::stringUtils::toLower(fieldName)));
@@ -194,13 +194,13 @@ std::vector <ref <headerField> > header::findAllFields(const string& fieldName)
}
-ref <headerField> header::getField(const string& fieldName)
+shared_ptr <headerField> header::getField(const string& fieldName)
{
const string name = utility::stringUtils::toLower(fieldName);
// Find the first field that matches the specified name
- std::vector <ref <headerField> >::const_iterator pos = m_fields.begin();
- const std::vector <ref <headerField> >::const_iterator end = m_fields.end();
+ std::vector <shared_ptr <headerField> >::const_iterator pos = m_fields.begin();
+ const std::vector <shared_ptr <headerField> >::const_iterator end = m_fields.end();
while (pos != end && utility::stringUtils::toLower((*pos)->getName()) != name)
++pos;
@@ -208,7 +208,7 @@ ref <headerField> header::getField(const string& fieldName)
// If no field with this name can be found, create a new one
if (pos == end)
{
- ref <headerField> field = headerFieldFactory::getInstance()->create(fieldName);
+ shared_ptr <headerField> field = headerFieldFactory::getInstance()->create(fieldName);
appendField(field);
@@ -223,15 +223,15 @@ ref <headerField> header::getField(const string& fieldName)
}
-void header::appendField(ref <headerField> field)
+void header::appendField(shared_ptr <headerField> field)
{
m_fields.push_back(field);
}
-void header::insertFieldBefore(ref <headerField> beforeField, ref <headerField> field)
+void header::insertFieldBefore(shared_ptr <headerField> beforeField, shared_ptr <headerField> field)
{
- const std::vector <ref <headerField> >::iterator it = std::find
+ const std::vector <shared_ptr <headerField> >::iterator it = std::find
(m_fields.begin(), m_fields.end(), beforeField);
if (it == m_fields.end())
@@ -241,15 +241,15 @@ void header::insertFieldBefore(ref <headerField> beforeField, ref <headerField>
}
-void header::insertFieldBefore(const size_t pos, ref <headerField> field)
+void header::insertFieldBefore(const size_t pos, shared_ptr <headerField> field)
{
m_fields.insert(m_fields.begin() + pos, field);
}
-void header::insertFieldAfter(ref <headerField> afterField, ref <headerField> field)
+void header::insertFieldAfter(shared_ptr <headerField> afterField, shared_ptr <headerField> field)
{
- const std::vector <ref <headerField> >::iterator it = std::find
+ const std::vector <shared_ptr <headerField> >::iterator it = std::find
(m_fields.begin(), m_fields.end(), afterField);
if (it == m_fields.end())
@@ -259,15 +259,15 @@ void header::insertFieldAfter(ref <headerField> afterField, ref <headerField> fi
}
-void header::insertFieldAfter(const size_t pos, ref <headerField> field)
+void header::insertFieldAfter(const size_t pos, shared_ptr <headerField> field)
{
m_fields.insert(m_fields.begin() + pos + 1, field);
}
-void header::removeField(ref <headerField> field)
+void header::removeField(shared_ptr <headerField> field)
{
- const std::vector <ref <headerField> >::iterator it = std::find
+ const std::vector <shared_ptr <headerField> >::iterator it = std::find
(m_fields.begin(), m_fields.end(), field);
if (it == m_fields.end())
@@ -279,13 +279,13 @@ void header::removeField(ref <headerField> field)
void header::removeField(const size_t pos)
{
- const std::vector <ref <headerField> >::iterator it = m_fields.begin() + pos;
+ const std::vector <shared_ptr <headerField> >::iterator it = m_fields.begin() + pos;
m_fields.erase(it);
}
-void header::replaceField(ref <headerField> field, ref <headerField> newField)
+void header::replaceField(shared_ptr <headerField> field, shared_ptr <headerField> newField)
{
insertFieldBefore(field, newField);
removeField(field);
@@ -300,7 +300,7 @@ void header::removeAllFields()
void header::removeAllFields(const string& fieldName)
{
- std::vector <ref <headerField> > fields = findAllFields(fieldName);
+ std::vector <shared_ptr <headerField> > fields = findAllFields(fieldName);
for (unsigned int i = 0 ; i < fields.size() ; ++i)
removeField(fields[i]);
@@ -319,25 +319,25 @@ bool header::isEmpty() const
}
-const ref <headerField> header::getFieldAt(const size_t pos)
+const shared_ptr <headerField> header::getFieldAt(const size_t pos)
{
return (m_fields[pos]);
}
-const ref <const headerField> header::getFieldAt(const size_t pos) const
+const shared_ptr <const headerField> header::getFieldAt(const size_t pos) const
{
return (m_fields[pos]);
}
-const std::vector <ref <const headerField> > header::getFieldList() const
+const std::vector <shared_ptr <const headerField> > header::getFieldList() const
{
- std::vector <ref <const headerField> > list;
+ std::vector <shared_ptr <const headerField> > list;
list.reserve(m_fields.size());
- for (std::vector <ref <headerField> >::const_iterator it = m_fields.begin() ;
+ for (std::vector <shared_ptr <headerField> >::const_iterator it = m_fields.begin() ;
it != m_fields.end() ; ++it)
{
list.push_back(*it);
@@ -347,15 +347,15 @@ const std::vector <ref <const headerField> > header::getFieldList() const
}
-const std::vector <ref <headerField> > header::getFieldList()
+const std::vector <shared_ptr <headerField> > header::getFieldList()
{
return (m_fields);
}
-const std::vector <ref <component> > header::getChildComponents()
+const std::vector <shared_ptr <component> > header::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
copy_vector(m_fields, list);
@@ -372,7 +372,7 @@ header::fieldHasName::fieldHasName(const string& name)
{
}
-bool header::fieldHasName::operator() (const ref <const headerField>& field)
+bool header::fieldHasName::operator() (const shared_ptr <const headerField>& field)
{
return utility::stringUtils::toLower(field->getName()) == m_name;
}
@@ -383,7 +383,7 @@ header::fieldHasNotName::fieldHasNotName(const string& name)
{
}
-bool header::fieldHasNotName::operator() (const ref <const headerField>& field)
+bool header::fieldHasNotName::operator() (const shared_ptr <const headerField>& field)
{
return utility::stringUtils::toLower(field->getName()) != m_name;
}
diff --git a/src/headerField.cpp b/src/headerField.cpp
index 7f24e176..c6baa32e 100644
--- a/src/headerField.cpp
+++ b/src/headerField.cpp
@@ -50,9 +50,9 @@ headerField::~headerField()
}
-ref <component> headerField::clone() const
+shared_ptr <component> headerField::clone() const
{
- ref <headerField> field = headerFieldFactory::getInstance()->create(m_name);
+ shared_ptr <headerField> field = headerFieldFactory::getInstance()->create(m_name);
field->copyFrom(*this);
@@ -75,7 +75,7 @@ headerField& headerField::operator=(const headerField& other)
}
-ref <headerField> headerField::parseNext
+shared_ptr <headerField> headerField::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
{
@@ -93,14 +93,14 @@ ref <headerField> headerField::parseNext
if (newPosition)
*newPosition = pos + 1; // LF: illegal
- return (NULL);
+ return null;
}
else if (c == '\r' && pos + 1 < end && buffer[pos + 1] == '\n')
{
if (newPosition)
*newPosition = pos + 2; // CR+LF
- return (NULL);
+ return null;
}
// This line may be a field description
@@ -230,7 +230,7 @@ ref <headerField> headerField::parseNext
}
// Return a new field
- ref <headerField> field = headerFieldFactory::getInstance()->create(name);
+ shared_ptr <headerField> field = headerFieldFactory::getInstance()->create(name);
field->parse(ctx, buffer, contentsStart, contentsEnd, NULL);
field->setParsedBounds(nameStart, pos);
@@ -253,14 +253,14 @@ ref <headerField> headerField::parseNext
if (newPosition)
*newPosition = pos + 1; // LF: illegal
- return NULL;
+ return null;
}
else if (pos + 1 < end && buffer[pos] == '\r' && buffer[pos + 1] == '\n')
{
if (newPosition)
*newPosition = pos + 2; // CR+LF
- return NULL;
+ return null;
}
// Skip this error and advance to the next line
@@ -275,7 +275,7 @@ ref <headerField> headerField::parseNext
if (newPosition)
*newPosition = pos;
- return (NULL);
+ return null;
}
@@ -321,9 +321,9 @@ bool headerField::isCustom() const
}
-const std::vector <ref <component> > headerField::getChildComponents()
+const std::vector <shared_ptr <component> > headerField::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
if (m_value)
list.push_back(m_value);
@@ -332,19 +332,19 @@ const std::vector <ref <component> > headerField::getChildComponents()
}
-ref <const headerFieldValue> headerField::getValue() const
+shared_ptr <const headerFieldValue> headerField::getValue() const
{
return m_value;
}
-ref <headerFieldValue> headerField::getValue()
+shared_ptr <headerFieldValue> headerField::getValue()
{
return m_value;
}
-void headerField::setValue(ref <headerFieldValue> value)
+void headerField::setValue(shared_ptr <headerFieldValue> value)
{
if (!headerFieldFactory::getInstance()->isValueTypeValid(*this, *value))
throw exceptions::bad_field_value_type(getName());
@@ -354,12 +354,12 @@ void headerField::setValue(ref <headerFieldValue> value)
}
-void headerField::setValueConst(ref <const headerFieldValue> value)
+void headerField::setValueConst(shared_ptr <const headerFieldValue> value)
{
if (!headerFieldFactory::getInstance()->isValueTypeValid(*this, *value))
throw exceptions::bad_field_value_type(getName());
- m_value = value->clone().dynamicCast <headerFieldValue>();
+ m_value = vmime::clone(value);
}
@@ -368,7 +368,7 @@ void headerField::setValue(const headerFieldValue& value)
if (!headerFieldFactory::getInstance()->isValueTypeValid(*this, value))
throw exceptions::bad_field_value_type(getName());
- m_value = value.clone().dynamicCast <headerFieldValue>();
+ m_value = vmime::clone(value);
}
diff --git a/src/headerFieldFactory.cpp b/src/headerFieldFactory.cpp
index 7e021f59..5c60543e 100644
--- a/src/headerFieldFactory.cpp
+++ b/src/headerFieldFactory.cpp
@@ -90,18 +90,18 @@ headerFieldFactory::~headerFieldFactory()
}
-headerFieldFactory* headerFieldFactory::getInstance()
+shared_ptr <headerFieldFactory> headerFieldFactory::getInstance()
{
static headerFieldFactory instance;
- return (&instance);
+ return shared_ptr <headerFieldFactory>(&instance, noop_shared_ptr_deleter <headerFieldFactory>());
}
-ref <headerField> headerFieldFactory::create
+shared_ptr <headerField> headerFieldFactory::create
(const string& name, const string& body)
{
NameMap::const_iterator pos = m_nameMap.find(utility::stringUtils::toLower(name));
- ref <headerField> field = NULL;
+ shared_ptr <headerField> field;
if (pos != m_nameMap.end())
field = ((*pos).second)();
@@ -118,12 +118,12 @@ ref <headerField> headerFieldFactory::create
}
-ref <headerFieldValue> headerFieldFactory::createValue(const string& fieldName)
+shared_ptr <headerFieldValue> headerFieldFactory::createValue(const string& fieldName)
{
ValueMap::const_iterator pos = m_valueMap.find
(utility::stringUtils::toLower(fieldName));
- ref <headerFieldValue> value = NULL;
+ shared_ptr <headerFieldValue> value;
if (pos != m_valueMap.end())
value = ((*pos).second.allocFunc)();
diff --git a/src/htmlTextPart.cpp b/src/htmlTextPart.cpp
index ebb6587c..0aabbdc4 100644
--- a/src/htmlTextPart.cpp
+++ b/src/htmlTextPart.cpp
@@ -39,8 +39,8 @@ namespace vmime
htmlTextPart::htmlTextPart()
- : m_plainText(vmime::create <emptyContentHandler>()),
- m_text(vmime::create <emptyContentHandler>())
+ : m_plainText(make_shared <emptyContentHandler>()),
+ m_text(make_shared <emptyContentHandler>())
{
}
@@ -62,13 +62,13 @@ size_t htmlTextPart::getPartCount() const
}
-void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> parent) const
+void htmlTextPart::generateIn(shared_ptr <bodyPart> /* message */, shared_ptr <bodyPart> parent) const
{
// Plain text
if (!m_plainText->isEmpty())
{
// -- Create a new part
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
parent->getBody()->appendPart(part);
// -- Set contents
@@ -79,7 +79,7 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
// HTML text
// -- Create a new part
- ref <bodyPart> htmlPart = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> htmlPart = make_shared <bodyPart>();
// -- Set contents
htmlPart->getBody()->setContents(m_text,
@@ -90,7 +90,7 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
if (!m_objects.empty())
{
// Create a "multipart/related" body part
- ref <bodyPart> relPart = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> relPart = make_shared <bodyPart>();
parent->getBody()->appendPart(relPart);
relPart->getHeader()->ContentType()->
@@ -100,10 +100,10 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
relPart->getBody()->appendPart(htmlPart);
// Also add objects into this part
- for (std::vector <ref <embeddedObject> >::const_iterator it = m_objects.begin() ;
+ for (std::vector <shared_ptr <embeddedObject> >::const_iterator it = m_objects.begin() ;
it != m_objects.end() ; ++it)
{
- ref <bodyPart> objPart = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> objPart = make_shared <bodyPart>();
relPart->getBody()->appendPart(objPart);
string id = (*it)->getId();
@@ -129,11 +129,11 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
void htmlTextPart::findEmbeddedParts(const bodyPart& part,
- std::vector <ref <const bodyPart> >& cidParts, std::vector <ref <const bodyPart> >& locParts)
+ std::vector <shared_ptr <const bodyPart> >& cidParts, std::vector <shared_ptr <const bodyPart> >& locParts)
{
for (size_t i = 0 ; i < part.getBody()->getPartCount() ; ++i)
{
- ref <const bodyPart> p = part.getBody()->getPartAt(i);
+ shared_ptr <const bodyPart> p = part.getBody()->getPartAt(i);
// For a part to be an embedded object, it must have a
// Content-Id field or a Content-Location field.
@@ -174,25 +174,25 @@ void htmlTextPart::addEmbeddedObject(const bodyPart& part, const string& id,
try
{
- const ref <const headerField> ctf = part.getHeader()->ContentType();
- type = *ctf->getValue().dynamicCast <const mediaType>();
+ const shared_ptr <const headerField> ctf = part.getHeader()->ContentType();
+ type = *ctf->getValue <mediaType>();
}
catch (exceptions::no_such_field)
{
// No "Content-type" field: assume "application/octet-stream".
}
- m_objects.push_back(vmime::create <embeddedObject>
- (part.getBody()->getContents()->clone().dynamicCast <contentHandler>(),
+ m_objects.push_back(make_shared <embeddedObject>
+ (vmime::clone(part.getBody()->getContents()),
part.getBody()->getEncoding(), id, type, refType));
}
-void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> parent, ref <const bodyPart> textPart)
+void htmlTextPart::parse(shared_ptr <const bodyPart> message, shared_ptr <const bodyPart> parent, shared_ptr <const bodyPart> textPart)
{
// Search for possible embedded objects in the _whole_ message.
- std::vector <ref <const bodyPart> > cidParts;
- std::vector <ref <const bodyPart> > locParts;
+ std::vector <shared_ptr <const bodyPart> > cidParts;
+ std::vector <shared_ptr <const bodyPart> > locParts;
findEmbeddedParts(*message, cidParts, locParts);
@@ -208,8 +208,8 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> pare
try
{
- const ref <const contentTypeField> ctf =
- textPart->getHeader()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ const shared_ptr <const contentTypeField> ctf =
+ textPart->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
m_charset = ctf->getCharset();
}
@@ -224,12 +224,12 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> pare
// Extract embedded objects. The algorithm is quite simple: for each previously
// found inline part, we check if its CID/Location is contained in the HTML text.
- for (std::vector <ref <const bodyPart> >::const_iterator p = cidParts.begin() ; p != cidParts.end() ; ++p)
+ for (std::vector <shared_ptr <const bodyPart> >::const_iterator p = cidParts.begin() ; p != cidParts.end() ; ++p)
{
- const ref <const headerField> midField =
+ const shared_ptr <const headerField> midField =
(*p)->getHeader()->findField(fields::CONTENT_ID);
- const messageId mid = *midField->getValue().dynamicCast <const messageId>();
+ const messageId mid = *midField->getValue <messageId>();
if (data.find("CID:" + mid.getId()) != string::npos ||
data.find("cid:" + mid.getId()) != string::npos)
@@ -240,12 +240,12 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> pare
}
}
- for (std::vector <ref <const bodyPart> >::const_iterator p = locParts.begin() ; p != locParts.end() ; ++p)
+ for (std::vector <shared_ptr <const bodyPart> >::const_iterator p = locParts.begin() ; p != locParts.end() ; ++p)
{
- const ref <const headerField> locField =
+ const shared_ptr <const headerField> locField =
(*p)->getHeader()->findField(fields::CONTENT_LOCATION);
- const text loc = *locField->getValue().dynamicCast <const text>();
+ const text loc = *locField->getValue <text>();
const string locStr = loc.getWholeBuffer();
if (data.find(locStr) != string::npos)
@@ -259,7 +259,7 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> pare
// Extract plain text, if any.
if (!findPlainTextPart(*message, *parent, *textPart))
{
- m_plainText = vmime::create <emptyContentHandler>();
+ m_plainText = make_shared <emptyContentHandler>();
}
}
@@ -269,22 +269,22 @@ bool htmlTextPart::findPlainTextPart(const bodyPart& part, const bodyPart& paren
// We search for the nearest "multipart/alternative" part.
try
{
- const ref <const headerField> ctf =
+ const shared_ptr <const headerField> ctf =
part.getHeader()->findField(fields::CONTENT_TYPE);
- const mediaType type = *ctf->getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf->getValue <mediaType>();
if (type.getType() == mediaTypes::MULTIPART &&
type.getSubType() == mediaTypes::MULTIPART_ALTERNATIVE)
{
- ref <const bodyPart> foundPart = NULL;
+ shared_ptr <const bodyPart> foundPart;
for (size_t i = 0 ; i < part.getBody()->getPartCount() ; ++i)
{
- const ref <const bodyPart> p = part.getBody()->getPartAt(i);
+ const shared_ptr <const bodyPart> p = part.getBody()->getPartAt(i);
- if (p == &parent || // if "text/html" is in "multipart/related"
- p == &textPart) // if not...
+ if (p.get() == &parent || // if "text/html" is in "multipart/related"
+ p.get() == &textPart) // if not...
{
foundPart = p;
}
@@ -297,14 +297,14 @@ bool htmlTextPart::findPlainTextPart(const bodyPart& part, const bodyPart& paren
// Now, search for the alternative plain text part
for (size_t i = 0 ; !found && i < part.getBody()->getPartCount() ; ++i)
{
- const ref <const bodyPart> p = part.getBody()->getPartAt(i);
+ const shared_ptr <const bodyPart> p = part.getBody()->getPartAt(i);
try
{
- const ref <const headerField> ctf =
+ const shared_ptr <const headerField> ctf =
p->getHeader()->findField(fields::CONTENT_TYPE);
- const mediaType type = *ctf->getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf->getValue <mediaType>();
if (type.getType() == mediaTypes::TEXT &&
type.getSubType() == mediaTypes::TEXT_PLAIN)
@@ -354,25 +354,25 @@ void htmlTextPart::setCharset(const charset& ch)
}
-ref <const contentHandler> htmlTextPart::getPlainText() const
+shared_ptr <const contentHandler> htmlTextPart::getPlainText() const
{
return m_plainText;
}
-void htmlTextPart::setPlainText(ref <contentHandler> plainText)
+void htmlTextPart::setPlainText(shared_ptr <contentHandler> plainText)
{
m_plainText = plainText->clone();
}
-const ref <const contentHandler> htmlTextPart::getText() const
+const shared_ptr <const contentHandler> htmlTextPart::getText() const
{
return m_text;
}
-void htmlTextPart::setText(ref <contentHandler> text)
+void htmlTextPart::setText(shared_ptr <contentHandler> text)
{
m_text = text->clone();
}
@@ -384,15 +384,15 @@ size_t htmlTextPart::getObjectCount() const
}
-ref <const htmlTextPart::embeddedObject> htmlTextPart::getObjectAt(const size_t pos) const
+shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::getObjectAt(const size_t pos) const
{
return m_objects[pos];
}
-ref <const htmlTextPart::embeddedObject> htmlTextPart::findObject(const string& id) const
+shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::findObject(const string& id) const
{
- for (std::vector <ref <embeddedObject> >::const_iterator o = m_objects.begin() ;
+ for (std::vector <shared_ptr <embeddedObject> >::const_iterator o = m_objects.begin() ;
o != m_objects.end() ; ++o)
{
if ((*o)->matchesId(id))
@@ -405,7 +405,7 @@ ref <const htmlTextPart::embeddedObject> htmlTextPart::findObject(const string&
bool htmlTextPart::hasObject(const string& id) const
{
- for (std::vector <ref <embeddedObject> >::const_iterator o = m_objects.begin() ;
+ for (std::vector <shared_ptr <embeddedObject> >::const_iterator o = m_objects.begin() ;
o != m_objects.end() ; ++o)
{
if ((*o)->matchesId(id))
@@ -416,12 +416,12 @@ bool htmlTextPart::hasObject(const string& id) const
}
-ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
- (ref <contentHandler> data, const vmime::encoding& enc, const mediaType& type)
+shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::addObject
+ (shared_ptr <contentHandler> data, const vmime::encoding& enc, const mediaType& type)
{
const messageId mid(messageId::generateId());
- ref <embeddedObject> obj = vmime::create <embeddedObject>
+ shared_ptr <embeddedObject> obj = make_shared <embeddedObject>
(data, enc, mid.getId(), type, embeddedObject::REFERENCED_BY_ID);
m_objects.push_back(obj);
@@ -430,17 +430,17 @@ ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
}
-ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
- (ref <contentHandler> data, const mediaType& type)
+shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::addObject
+ (shared_ptr <contentHandler> data, const mediaType& type)
{
return addObject(data, encoding::decide(data), type);
}
-ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
+shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::addObject
(const string& data, const mediaType& type)
{
- ref <stringContentHandler> cts = vmime::create <stringContentHandler>(data);
+ shared_ptr <stringContentHandler> cts = make_shared <stringContentHandler>(data);
return addObject(cts, encoding::decide(cts), type);
}
@@ -451,15 +451,15 @@ ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
//
htmlTextPart::embeddedObject::embeddedObject
- (ref <contentHandler> data, const encoding& enc,
+ (shared_ptr <contentHandler> data, const encoding& enc,
const string& id, const mediaType& type, const ReferenceType refType)
- : m_data(data->clone().dynamicCast <contentHandler>()),
+ : m_data(vmime::clone(data)),
m_encoding(enc), m_id(id), m_type(type), m_refType(refType)
{
}
-ref <const contentHandler> htmlTextPart::embeddedObject::getData() const
+shared_ptr <const contentHandler> htmlTextPart::embeddedObject::getData() const
{
return m_data;
}
diff --git a/src/mailbox.cpp b/src/mailbox.cpp
index 1c199a76..a38aada0 100644
--- a/src/mailbox.cpp
+++ b/src/mailbox.cpp
@@ -452,9 +452,9 @@ mailbox& mailbox::operator=(const mailbox& other)
}
-ref <component>mailbox::clone() const
+shared_ptr <component>mailbox::clone() const
{
- return vmime::create <mailbox>(*this);
+ return make_shared <mailbox>(*this);
}
@@ -501,9 +501,9 @@ void mailbox::setEmail(const emailAddress& email)
}
-const std::vector <ref <component> > mailbox::getChildComponents()
+const std::vector <shared_ptr <component> > mailbox::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/mailboxField.cpp b/src/mailboxField.cpp
index 4eb9d734..7d138f3e 100644
--- a/src/mailboxField.cpp
+++ b/src/mailboxField.cpp
@@ -47,12 +47,12 @@ void mailboxField::parse
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
{
- ref <mailbox> mbox = vmime::create <mailbox>();
+ shared_ptr <mailbox> mbox = make_shared <mailbox>();
// Here, we cannot simply call "m_mailbox.parse()" because it
// may have more than one address specified (even if this field
// should contain only one). We are never too much careful...
- ref <address> parsedAddress = address::parseNext(ctx, buffer, position, end, newPosition, NULL);
+ shared_ptr <address> parsedAddress = address::parseNext(ctx, buffer, position, end, newPosition, NULL);
if (parsedAddress)
{
@@ -60,7 +60,7 @@ void mailboxField::parse
{
// If it is a group of mailboxes, take the first
// mailbox of the group
- ref <mailboxGroup> group = parsedAddress.staticCast <mailboxGroup>();
+ shared_ptr <mailboxGroup> group = dynamicCast <mailboxGroup>(parsedAddress);
if (!group->isEmpty())
mbox = group->getMailboxAt(0);
@@ -68,7 +68,7 @@ void mailboxField::parse
else
{
// Parse only if it is a mailbox
- mbox = parsedAddress.staticCast <mailbox>();
+ mbox = dynamicCast <mailbox>(parsedAddress);
}
}
diff --git a/src/mailboxGroup.cpp b/src/mailboxGroup.cpp
index 9da16653..559d8778 100644
--- a/src/mailboxGroup.cpp
+++ b/src/mailboxGroup.cpp
@@ -82,24 +82,24 @@ void mailboxGroup::parseImpl
while (pos < end && !isLastAddressOfGroup)
{
- ref <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, &isLastAddressOfGroup);
+ shared_ptr <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, &isLastAddressOfGroup);
if (parsedAddress)
{
if (parsedAddress->isGroup())
{
- ref <mailboxGroup> group = parsedAddress.staticCast <mailboxGroup>();
+ shared_ptr <mailboxGroup> group = dynamicCast <mailboxGroup>(parsedAddress);
// Sub-groups are not allowed in mailbox groups: so, we add all
// the contents of the sub-group into this group...
for (size_t i = 0 ; i < group->getMailboxCount() ; ++i)
{
- m_list.push_back(group->getMailboxAt(i)->clone().staticCast <mailbox>());
+ m_list.push_back(vmime::clone(group->getMailboxAt(i)));
}
}
else
{
- m_list.push_back(parsedAddress.staticCast <mailbox>());
+ m_list.push_back(dynamicCast <mailbox>(parsedAddress));
}
}
}
@@ -168,7 +168,7 @@ void mailboxGroup::generateImpl
os << ":";
++pos;
- for (std::vector <ref <mailbox> >::const_iterator it = m_list.begin() ;
+ for (std::vector <shared_ptr <mailbox> >::const_iterator it = m_list.begin() ;
it != m_list.end() ; ++it)
{
if (it != m_list.begin())
@@ -201,17 +201,17 @@ void mailboxGroup::copyFrom(const component& other)
removeAllMailboxes();
- for (std::vector <ref <mailbox> >::const_iterator it = source.m_list.begin() ;
+ for (std::vector <shared_ptr <mailbox> >::const_iterator it = source.m_list.begin() ;
it != source.m_list.end() ; ++it)
{
- m_list.push_back((*it)->clone().staticCast <mailbox>());
+ m_list.push_back(vmime::clone(*it));
}
}
-ref <component> mailboxGroup::clone() const
+shared_ptr <component> mailboxGroup::clone() const
{
- return vmime::create <mailboxGroup>(*this);
+ return make_shared <mailboxGroup>(*this);
}
@@ -246,15 +246,15 @@ bool mailboxGroup::isEmpty() const
}
-void mailboxGroup::appendMailbox(ref <mailbox> mbox)
+void mailboxGroup::appendMailbox(shared_ptr <mailbox> mbox)
{
m_list.push_back(mbox);
}
-void mailboxGroup::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox> mbox)
+void mailboxGroup::insertMailboxBefore(shared_ptr <mailbox> beforeMailbox, shared_ptr <mailbox> mbox)
{
- const std::vector <ref <mailbox> >::iterator it = std::find
+ const std::vector <shared_ptr <mailbox> >::iterator it = std::find
(m_list.begin(), m_list.end(), beforeMailbox);
if (it == m_list.end())
@@ -264,15 +264,15 @@ void mailboxGroup::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox
}
-void mailboxGroup::insertMailboxBefore(const size_t pos, ref <mailbox> mbox)
+void mailboxGroup::insertMailboxBefore(const size_t pos, shared_ptr <mailbox> mbox)
{
m_list.insert(m_list.begin() + pos, mbox);
}
-void mailboxGroup::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox> mbox)
+void mailboxGroup::insertMailboxAfter(shared_ptr <mailbox> afterMailbox, shared_ptr <mailbox> mbox)
{
- const std::vector <ref <mailbox> >::iterator it = std::find
+ const std::vector <shared_ptr <mailbox> >::iterator it = std::find
(m_list.begin(), m_list.end(), afterMailbox);
if (it == m_list.end())
@@ -282,15 +282,15 @@ void mailboxGroup::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox>
}
-void mailboxGroup::insertMailboxAfter(const size_t pos, ref <mailbox> mbox)
+void mailboxGroup::insertMailboxAfter(const size_t pos, shared_ptr <mailbox> mbox)
{
m_list.insert(m_list.begin() + pos + 1, mbox);
}
-void mailboxGroup::removeMailbox(ref <mailbox> mbox)
+void mailboxGroup::removeMailbox(shared_ptr <mailbox> mbox)
{
- const std::vector <ref <mailbox> >::iterator it = std::find
+ const std::vector <shared_ptr <mailbox> >::iterator it = std::find
(m_list.begin(), m_list.end(), mbox);
if (it == m_list.end())
@@ -302,7 +302,7 @@ void mailboxGroup::removeMailbox(ref <mailbox> mbox)
void mailboxGroup::removeMailbox(const size_t pos)
{
- const std::vector <ref <mailbox> >::iterator it = m_list.begin() + pos;
+ const std::vector <shared_ptr <mailbox> >::iterator it = m_list.begin() + pos;
m_list.erase(it);
}
@@ -320,25 +320,25 @@ size_t mailboxGroup::getMailboxCount() const
}
-ref <mailbox> mailboxGroup::getMailboxAt(const size_t pos)
+shared_ptr <mailbox> mailboxGroup::getMailboxAt(const size_t pos)
{
return (m_list[pos]);
}
-const ref <const mailbox> mailboxGroup::getMailboxAt(const size_t pos) const
+const shared_ptr <const mailbox> mailboxGroup::getMailboxAt(const size_t pos) const
{
return (m_list[pos]);
}
-const std::vector <ref <const mailbox> > mailboxGroup::getMailboxList() const
+const std::vector <shared_ptr <const mailbox> > mailboxGroup::getMailboxList() const
{
- std::vector <ref <const mailbox> > list;
+ std::vector <shared_ptr <const mailbox> > list;
list.reserve(m_list.size());
- for (std::vector <ref <mailbox> >::const_iterator it = m_list.begin() ;
+ for (std::vector <shared_ptr <mailbox> >::const_iterator it = m_list.begin() ;
it != m_list.end() ; ++it)
{
list.push_back(*it);
@@ -348,15 +348,15 @@ const std::vector <ref <const mailbox> > mailboxGroup::getMailboxList() const
}
-const std::vector <ref <mailbox> > mailboxGroup::getMailboxList()
+const std::vector <shared_ptr <mailbox> > mailboxGroup::getMailboxList()
{
return (m_list);
}
-const std::vector <ref <component> > mailboxGroup::getChildComponents()
+const std::vector <shared_ptr <component> > mailboxGroup::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
copy_vector(m_list, list);
diff --git a/src/mailboxList.cpp b/src/mailboxList.cpp
index f0f40ca8..0a76c52a 100644
--- a/src/mailboxList.cpp
+++ b/src/mailboxList.cpp
@@ -41,13 +41,13 @@ mailboxList::mailboxList(const mailboxList& mboxList)
}
-void mailboxList::appendMailbox(ref <mailbox> mbox)
+void mailboxList::appendMailbox(shared_ptr <mailbox> mbox)
{
m_list.appendAddress(mbox);
}
-void mailboxList::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox> mbox)
+void mailboxList::insertMailboxBefore(shared_ptr <mailbox> beforeMailbox, shared_ptr <mailbox> mbox)
{
try
{
@@ -60,13 +60,13 @@ void mailboxList::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox>
}
-void mailboxList::insertMailboxBefore(const size_t pos, ref <mailbox> mbox)
+void mailboxList::insertMailboxBefore(const size_t pos, shared_ptr <mailbox> mbox)
{
m_list.insertAddressBefore(pos, mbox);
}
-void mailboxList::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox> mbox)
+void mailboxList::insertMailboxAfter(shared_ptr <mailbox> afterMailbox, shared_ptr <mailbox> mbox)
{
try
{
@@ -79,13 +79,13 @@ void mailboxList::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox> m
}
-void mailboxList::insertMailboxAfter(const size_t pos, ref <mailbox> mbox)
+void mailboxList::insertMailboxAfter(const size_t pos, shared_ptr <mailbox> mbox)
{
m_list.insertAddressAfter(pos, mbox);
}
-void mailboxList::removeMailbox(ref <mailbox> mbox)
+void mailboxList::removeMailbox(shared_ptr <mailbox> mbox)
{
try
{
@@ -122,27 +122,27 @@ bool mailboxList::isEmpty() const
}
-ref <mailbox> mailboxList::getMailboxAt(const size_t pos)
+shared_ptr <mailbox> mailboxList::getMailboxAt(const size_t pos)
{
- return m_list.getAddressAt(pos).staticCast <mailbox>();
+ return dynamicCast <mailbox>(m_list.getAddressAt(pos));
}
-const ref <const mailbox> mailboxList::getMailboxAt(const size_t pos) const
+const shared_ptr <const mailbox> mailboxList::getMailboxAt(const size_t pos) const
{
- return m_list.getAddressAt(pos).staticCast <const mailbox>();
+ return dynamicCast <const mailbox>(m_list.getAddressAt(pos));
}
-const std::vector <ref <const mailbox> > mailboxList::getMailboxList() const
+const std::vector <shared_ptr <const mailbox> > mailboxList::getMailboxList() const
{
- const std::vector <ref <const address> > addrList = m_list.getAddressList();
- std::vector <ref <const mailbox> > res;
+ const std::vector <shared_ptr <const address> > addrList = m_list.getAddressList();
+ std::vector <shared_ptr <const mailbox> > res;
- for (std::vector <ref <const address> >::const_iterator it = addrList.begin() ;
+ for (std::vector <shared_ptr <const address> >::const_iterator it = addrList.begin() ;
it != addrList.end() ; ++it)
{
- const ref <const mailbox> mbox = (*it).dynamicCast <const mailbox>();
+ const shared_ptr <const mailbox> mbox = dynamicCast <const mailbox>(*it);
if (mbox != NULL)
res.push_back(mbox);
@@ -152,15 +152,15 @@ const std::vector <ref <const mailbox> > mailboxList::getMailboxList() const
}
-const std::vector <ref <mailbox> > mailboxList::getMailboxList()
+const std::vector <shared_ptr <mailbox> > mailboxList::getMailboxList()
{
- const std::vector <ref <address> > addrList = m_list.getAddressList();
- std::vector <ref <mailbox> > res;
+ const std::vector <shared_ptr <address> > addrList = m_list.getAddressList();
+ std::vector <shared_ptr <mailbox> > res;
- for (std::vector <ref <address> >::const_iterator it = addrList.begin() ;
+ for (std::vector <shared_ptr <address> >::const_iterator it = addrList.begin() ;
it != addrList.end() ; ++it)
{
- const ref <mailbox> mbox = (*it).dynamicCast <mailbox>();
+ const shared_ptr <mailbox> mbox = dynamicCast <mailbox>(*it);
if (mbox != NULL)
res.push_back(mbox);
@@ -170,9 +170,9 @@ const std::vector <ref <mailbox> > mailboxList::getMailboxList()
}
-ref <component> mailboxList::clone() const
+shared_ptr <component> mailboxList::clone() const
{
- return vmime::create <mailboxList>(*this);
+ return make_shared <mailboxList>(*this);
}
@@ -191,7 +191,7 @@ mailboxList& mailboxList::operator=(const mailboxList& other)
}
-const std::vector <ref <component> > mailboxList::getChildComponents()
+const std::vector <shared_ptr <component> > mailboxList::getChildComponents()
{
return (m_list.getChildComponents());
}
@@ -207,13 +207,13 @@ void mailboxList::parseImpl
while (pos < end)
{
- ref <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL);
+ shared_ptr <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL);
if (parsedAddress != NULL)
{
if (parsedAddress->isGroup())
{
- ref <mailboxGroup> group = parsedAddress.staticCast <mailboxGroup>();
+ shared_ptr <mailboxGroup> group = dynamicCast <mailboxGroup>(parsedAddress);
for (size_t i = 0 ; i < group->getMailboxCount() ; ++i)
{
@@ -241,9 +241,9 @@ void mailboxList::generateImpl(const generationContext& ctx, utility::outputStre
}
-ref <addressList> mailboxList::toAddressList() const
+shared_ptr <addressList> mailboxList::toAddressList() const
{
- return m_list.clone().dynamicCast <addressList>();
+ return vmime::clone(m_list);
}
diff --git a/src/mdn/MDNHelper.cpp b/src/mdn/MDNHelper.cpp
index a0d48599..1205aef2 100644
--- a/src/mdn/MDNHelper.cpp
+++ b/src/mdn/MDNHelper.cpp
@@ -38,33 +38,33 @@ namespace vmime {
namespace mdn {
-void MDNHelper::attachMDNRequest(ref <message> msg, const mailboxList& mailboxes)
+void MDNHelper::attachMDNRequest(shared_ptr <message> msg, const mailboxList& mailboxes)
{
- ref <header> hdr = msg->getHeader();
+ shared_ptr <header> hdr = msg->getHeader();
hdr->DispositionNotificationTo()->setValue(mailboxes);
}
-void MDNHelper::attachMDNRequest(ref <message> msg, const mailbox& mbox)
+void MDNHelper::attachMDNRequest(shared_ptr <message> msg, const mailbox& mbox)
{
mailboxList mboxList;
- mboxList.appendMailbox(mbox.clone().dynamicCast <mailbox>());
+ mboxList.appendMailbox(vmime::clone(mbox));
attachMDNRequest(msg, mboxList);
}
-const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const ref <const message> msg)
+const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const shared_ptr <const message> msg)
{
std::vector <sendableMDNInfos> result;
- const ref <const header> hdr = msg->getHeader();
+ const shared_ptr <const header> hdr = msg->getHeader();
if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO))
{
- const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue()
- .dynamicCast <const mailboxList>();
+ const mailboxList& dnto =
+ *hdr->DispositionNotificationTo()->getValue <mailboxList>();
for (size_t i = 0 ; i < dnto.getMailboxCount() ; ++i)
result.push_back(sendableMDNInfos(msg, *dnto.getMailboxAt(i)));
@@ -74,9 +74,9 @@ const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const ref <const
}
-bool MDNHelper::isMDN(const ref <const message> msg)
+bool MDNHelper::isMDN(const shared_ptr <const message> msg)
{
- const ref <const header> hdr = msg->getHeader();
+ const shared_ptr <const header> hdr = msg->getHeader();
// A MDN message implies the following:
// - a Content-Type field is present and its value is "multipart/report"
@@ -84,10 +84,9 @@ bool MDNHelper::isMDN(const ref <const message> msg)
// and its value is "disposition-notification"
if (hdr->hasField(fields::CONTENT_TYPE))
{
- const contentTypeField& ctf = *(hdr->ContentType()
- .dynamicCast <const contentTypeField>());
+ const contentTypeField& ctf = *dynamicCast <const contentTypeField>(hdr->ContentType());
- const mediaType type = *ctf.getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf.getValue <mediaType>();
if (type.getType() == vmime::mediaTypes::MULTIPART &&
type.getSubType() == vmime::mediaTypes::MULTIPART_REPORT)
@@ -104,7 +103,7 @@ bool MDNHelper::isMDN(const ref <const message> msg)
}
-receivedMDNInfos MDNHelper::getReceivedMDN(const ref <const message> msg)
+receivedMDNInfos MDNHelper::getReceivedMDN(const shared_ptr <const message> msg)
{
if (!isMDN(msg))
throw exceptions::invalid_argument();
@@ -113,9 +112,9 @@ receivedMDNInfos MDNHelper::getReceivedMDN(const ref <const message> msg)
}
-bool MDNHelper::needConfirmation(const ref <const message> msg)
+bool MDNHelper::needConfirmation(const shared_ptr <const message> msg)
{
- ref <const header> hdr = msg->getHeader();
+ shared_ptr <const header> hdr = msg->getHeader();
// No "Return-Path" field
if (!hdr->hasField(fields::RETURN_PATH))
@@ -124,8 +123,7 @@ bool MDNHelper::needConfirmation(const ref <const message> msg)
// More than one address in Disposition-Notification-To
if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO))
{
- const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue()
- .dynamicCast <const mailboxList>();
+ const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue <mailboxList>();
if (dnto.getMailboxCount() > 1)
return true;
@@ -134,7 +132,7 @@ bool MDNHelper::needConfirmation(const ref <const message> msg)
// Return-Path != Disposition-Notification-To
const mailbox& mbox = *dnto.getMailboxAt(0);
- const path& rp = *hdr->ReturnPath()->getValue().dynamicCast <const path>();
+ const path& rp = *hdr->ReturnPath()->getValue <path>();
if (mbox.getEmail() != rp.getLocalPart() + "@" + rp.getDomain())
return true;
@@ -145,7 +143,7 @@ bool MDNHelper::needConfirmation(const ref <const message> msg)
}
-ref <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
+shared_ptr <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
const string& text,
const charset& ch,
const mailbox& expeditor,
@@ -155,19 +153,19 @@ ref <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
const std::map <string, string>& fields)
{
// Create a new message
- ref <message> msg = vmime::create <message>();
+ shared_ptr <message> msg = make_shared <message>();
// Fill-in header fields
- ref <header> hdr = msg->getHeader();
+ shared_ptr <header> hdr = msg->getHeader();
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MULTIPART,
vmime::mediaTypes::MULTIPART_REPORT));
- hdr->ContentType().dynamicCast <contentTypeField>()->setReportType("disposition-notification");
+ dynamicCast <contentTypeField>(hdr->ContentType())->setReportType("disposition-notification");
hdr->Disposition()->setValue(dispo);
addressList to;
- to.appendAddress(vmime::create <mailbox>(mdnInfos.getRecipient()));
+ to.appendAddress(make_shared <mailbox>(mdnInfos.getRecipient()));
hdr->To()->setValue(to);
hdr->From()->setValue(expeditor);
@@ -186,36 +184,36 @@ ref <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
}
-ref <bodyPart> MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos */,
+shared_ptr <bodyPart> MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos */,
const string& text, const charset& ch)
{
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
// Header
- ref <header> hdr = part->getHeader();
+ shared_ptr <header> hdr = part->getHeader();
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT,
vmime::mediaTypes::TEXT_PLAIN));
- hdr->ContentType().dynamicCast <contentTypeField>()->setCharset(ch);
+ dynamicCast <contentTypeField>(hdr->ContentType())->setCharset(ch);
// Body
- part->getBody()->setContents(vmime::create <stringContentHandler>(text));
+ part->getBody()->setContents(make_shared <stringContentHandler>(text));
return (part);
}
-ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
+shared_ptr <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
const disposition& dispo,
const string& reportingUA,
const std::vector <string>& reportingUAProducts,
const std::map <string, string>& additionalFields)
{
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
// Header
- ref <header> hdr = part->getHeader();
+ shared_ptr <header> hdr = part->getHeader();
hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE);
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MESSAGE,
@@ -257,7 +255,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
ruaText += reportingUAProducts[i];
}
- ref <headerField> rua = headerFieldFactory::getInstance()->
+ shared_ptr <headerField> rua = headerFieldFactory::getInstance()->
create(vmime::fields::REPORTING_UA);
rua->setValue(ruaText);
@@ -266,7 +264,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
}
// -- Final-Recipient
- ref <headerField> fr = headerFieldFactory::getInstance()->
+ shared_ptr <headerField> fr = headerFieldFactory::getInstance()->
create(vmime::fields::FINAL_RECIPIENT);
fr->setValue("rfc822; " + mdnInfos.getRecipient().getEmail().generate());
@@ -291,7 +289,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
it = additionalFields.find(vmime::fields::ERROR);
if (it != additionalFields.end())
{
- ref <headerField> error = headerFieldFactory::getInstance()->
+ shared_ptr <headerField> error = headerFieldFactory::getInstance()->
create(vmime::fields::ERROR);
error->setValue(it->second);
fields.appendField(error);
@@ -300,7 +298,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
it = additionalFields.find(vmime::fields::WARNING);
if (it != additionalFields.end())
{
- ref <headerField> warn = headerFieldFactory::getInstance()->
+ shared_ptr <headerField> warn = headerFieldFactory::getInstance()->
create(vmime::fields::WARNING);
warn->setValue(it->second);
fields.appendField(warn);
@@ -309,7 +307,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
it = additionalFields.find(vmime::fields::FAILURE);
if (it != additionalFields.end())
{
- ref <headerField> fail = headerFieldFactory::getInstance()->
+ shared_ptr <headerField> fail = headerFieldFactory::getInstance()->
create(vmime::fields::FAILURE);
fail->setValue(it->second);
fields.appendField(fail);
@@ -322,18 +320,18 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
fields.generate(vos);
- part->getBody()->setContents(vmime::create <stringContentHandler>(oss.str()));
+ part->getBody()->setContents(make_shared <stringContentHandler>(oss.str()));
return (part);
}
-ref <bodyPart> MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
+shared_ptr <bodyPart> MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
{
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
// Header
- ref <header> hdr = part->getHeader();
+ shared_ptr <header> hdr = part->getHeader();
hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE);
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT,
@@ -345,7 +343,7 @@ ref <bodyPart> MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
mdnInfos.getMessage()->getHeader()->generate(vos);
- part->getBody()->setContents(vmime::create <stringContentHandler>(oss.str()));
+ part->getBody()->setContents(make_shared <stringContentHandler>(oss.str()));
return (part);
}
diff --git a/src/mdn/receivedMDNInfos.cpp b/src/mdn/receivedMDNInfos.cpp
index 876ba3d9..1c523be7 100644
--- a/src/mdn/receivedMDNInfos.cpp
+++ b/src/mdn/receivedMDNInfos.cpp
@@ -30,7 +30,7 @@ namespace vmime {
namespace mdn {
-receivedMDNInfos::receivedMDNInfos(const ref <const message> msg)
+receivedMDNInfos::receivedMDNInfos(const shared_ptr <const message> msg)
: m_msg(msg)
{
extract();
@@ -51,7 +51,7 @@ receivedMDNInfos& receivedMDNInfos::operator=(const receivedMDNInfos& other)
}
-const ref <const message> receivedMDNInfos::getMessage() const
+const shared_ptr <const message> receivedMDNInfos::getMessage() const
{
return (m_msg);
}
@@ -86,17 +86,16 @@ void receivedMDNInfos::copyFrom(const receivedMDNInfos& other)
void receivedMDNInfos::extract()
{
- const ref <const body> bdy = m_msg->getBody();
+ const shared_ptr <const body> bdy = m_msg->getBody();
for (size_t i = 0 ; i < bdy->getPartCount() ; ++i)
{
- const ref <const bodyPart> part = bdy->getPartAt(i);
+ const shared_ptr <const bodyPart> part = bdy->getPartAt(i);
if (!part->getHeader()->hasField(fields::CONTENT_TYPE))
continue;
- const mediaType& type = *part->getHeader()->ContentType()->
- getValue().dynamicCast <const mediaType>();
+ const mediaType& type = *part->getHeader()->ContentType()->getValue <mediaType>();
// Extract from second part (message/disposition-notification)
if (type.getType() == vmime::mediaTypes::MESSAGE &&
@@ -111,15 +110,15 @@ void receivedMDNInfos::extract()
header fields;
fields.parse(oss.str());
- try { m_omid = *fields.OriginalMessageId()->getValue().dynamicCast <const messageId>(); }
+ try { m_omid = *fields.OriginalMessageId()->getValue <messageId>(); }
catch (exceptions::no_such_field&) { /* Ignore */ }
- try { m_disp = *fields.Disposition()->getValue().dynamicCast <const disposition>(); }
+ try { m_disp = *fields.Disposition()->getValue <disposition>(); }
catch (exceptions::no_such_field&) { /* Ignore */ }
try
{
- text t = *fields.findField("Received-content-MIC")->getValue().dynamicCast <const text>();
+ text t = *fields.findField("Received-content-MIC")->getValue <text>();
m_contentMIC = t.generate();
}
catch (exceptions::no_such_field&) { /* Ignore */ }
diff --git a/src/mdn/sendableMDNInfos.cpp b/src/mdn/sendableMDNInfos.cpp
index 44c0515c..c145c3b6 100644
--- a/src/mdn/sendableMDNInfos.cpp
+++ b/src/mdn/sendableMDNInfos.cpp
@@ -28,7 +28,7 @@ namespace vmime {
namespace mdn {
-sendableMDNInfos::sendableMDNInfos(const ref <const message> msg, const mailbox& mbox)
+sendableMDNInfos::sendableMDNInfos(const shared_ptr <const message> msg, const mailbox& mbox)
: m_msg(msg), m_mailbox(mbox)
{
}
@@ -48,7 +48,7 @@ sendableMDNInfos& sendableMDNInfos::operator=(const sendableMDNInfos& other)
}
-const ref <const message> sendableMDNInfos::getMessage() const
+const shared_ptr <const message> sendableMDNInfos::getMessage() const
{
return (m_msg);
}
diff --git a/src/mediaType.cpp b/src/mediaType.cpp
index 123c8cee..2f9ca6b1 100644
--- a/src/mediaType.cpp
+++ b/src/mediaType.cpp
@@ -126,9 +126,9 @@ mediaType& mediaType::operator=(const string& type)
}
-ref <component> mediaType::clone() const
+shared_ptr <component> mediaType::clone() const
{
- return vmime::create <mediaType>(m_type, m_subType);
+ return make_shared <mediaType>(m_type, m_subType);
}
@@ -178,9 +178,9 @@ void mediaType::setFromString(const string& type)
}
-const std::vector <ref <component> > mediaType::getChildComponents()
+const std::vector <shared_ptr <component> > mediaType::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/messageBuilder.cpp b/src/messageBuilder.cpp
index ecd0f5d7..64880483 100644
--- a/src/messageBuilder.cpp
+++ b/src/messageBuilder.cpp
@@ -43,10 +43,10 @@ messageBuilder::~messageBuilder()
}
-ref <message> messageBuilder::construct() const
+shared_ptr <message> messageBuilder::construct() const
{
// Create a new message
- ref <message> msg = vmime::create <message>();
+ shared_ptr <message> msg = make_shared <message>();
// Generate the header fields
msg->getHeader()->Subject()->setValue(m_subject);
@@ -101,7 +101,7 @@ ref <message> messageBuilder::construct() const
(mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_MIXED));
// Create a sub-part "multipart/alternative" for text parts
- ref <bodyPart> subPart = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> subPart = make_shared <bodyPart>();
msg->getBody()->appendPart(subPart);
subPart->getHeader()->ContentType()->setValue
@@ -133,7 +133,7 @@ ref <message> messageBuilder::construct() const
// Generate the attachments
if (!m_attach.empty())
{
- for (std::vector <ref <attachment> >::const_iterator a = m_attach.begin() ;
+ for (std::vector <shared_ptr <attachment> >::const_iterator a = m_attach.begin() ;
a != m_attach.end() ; ++a)
{
(*a)->generateIn(msg);
@@ -147,12 +147,12 @@ ref <message> messageBuilder::construct() const
const bodyPart& part = *msg->getBody()->getPartAt(0);
// Make a full copy of the body, otherwise the copyFrom() will delete the body we're copying
- ref <body> bodyCopy = part.getBody()->clone().dynamicCast <body>();
+ shared_ptr <body> bodyCopy = vmime::clone(part.getBody());
// First, copy (and replace) the header fields
- const std::vector <ref <const headerField> > fields = part.getHeader()->getFieldList();
+ const std::vector <shared_ptr <const headerField> > fields = part.getHeader()->getFieldList();
- for (std::vector <ref <const headerField> >::const_iterator it = fields.begin() ;
+ for (std::vector <shared_ptr <const headerField> >::const_iterator it = fields.begin() ;
it != fields.end() ; ++it)
{
*(msg->getHeader()->getField((*it)->getName())) = **it;
@@ -167,13 +167,13 @@ ref <message> messageBuilder::construct() const
}
-void messageBuilder::attach(ref <attachment> attach)
+void messageBuilder::attach(shared_ptr <attachment> attach)
{
appendAttachment(attach);
}
-void messageBuilder::appendAttachment(ref <attachment> attach)
+void messageBuilder::appendAttachment(shared_ptr <attachment> attach)
{
m_attach.push_back(attach);
}
@@ -181,7 +181,7 @@ void messageBuilder::appendAttachment(ref <attachment> attach)
void messageBuilder::constructTextPart(const mediaType& type)
{
- ref <textPart> part = NULL;
+ shared_ptr <textPart> part;
try
{
@@ -196,7 +196,7 @@ void messageBuilder::constructTextPart(const mediaType& type)
}
-ref <textPart> messageBuilder::getTextPart()
+shared_ptr <textPart> messageBuilder::getTextPart()
{
return (m_textPart);
}
@@ -286,13 +286,13 @@ void messageBuilder::removeAttachment(const size_t pos)
}
-const ref <const attachment> messageBuilder::getAttachmentAt(const size_t pos) const
+const shared_ptr <const attachment> messageBuilder::getAttachmentAt(const size_t pos) const
{
return (m_attach[pos]);
}
-ref <attachment> messageBuilder::getAttachmentAt(const size_t pos)
+shared_ptr <attachment> messageBuilder::getAttachmentAt(const size_t pos)
{
return (m_attach[pos]);
}
@@ -304,13 +304,13 @@ size_t messageBuilder::getAttachmentCount() const
}
-const std::vector <ref <const attachment> > messageBuilder::getAttachmentList() const
+const std::vector <shared_ptr <const attachment> > messageBuilder::getAttachmentList() const
{
- std::vector <ref <const attachment> > res;
+ std::vector <shared_ptr <const attachment> > res;
res.reserve(m_attach.size());
- for (std::vector <ref <attachment> >::const_iterator it = m_attach.begin() ;
+ for (std::vector <shared_ptr <attachment> >::const_iterator it = m_attach.begin() ;
it != m_attach.end() ; ++it)
{
res.push_back(*it);
@@ -320,7 +320,7 @@ const std::vector <ref <const attachment> > messageBuilder::getAttachmentList()
}
-const std::vector <ref <attachment> > messageBuilder::getAttachmentList()
+const std::vector <shared_ptr <attachment> > messageBuilder::getAttachmentList()
{
return (m_attach);
}
diff --git a/src/messageId.cpp b/src/messageId.cpp
index 6b558e1b..d981f061 100644
--- a/src/messageId.cpp
+++ b/src/messageId.cpp
@@ -146,7 +146,7 @@ void messageId::parseImpl
}
-ref <messageId> messageId::parseNext
+shared_ptr <messageId> messageId::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
{
@@ -162,7 +162,7 @@ ref <messageId> messageId::parseNext
while (pos < end && !parserHelpers::isSpace(buffer[pos]))
++pos;
- ref <messageId> mid = vmime::create <messageId>();
+ shared_ptr <messageId> mid = make_shared <messageId>();
mid->parse(ctx, buffer, begin, pos, NULL);
if (newPosition != NULL)
@@ -174,7 +174,7 @@ ref <messageId> messageId::parseNext
if (newPosition != NULL)
*newPosition = end;
- return (NULL);
+ return null;
}
@@ -245,9 +245,9 @@ bool messageId::operator!=(const messageId& mid) const
}
-ref <component> messageId::clone() const
+shared_ptr <component> messageId::clone() const
{
- return vmime::create <messageId>(*this);
+ return make_shared <messageId>(*this);
}
@@ -291,9 +291,9 @@ void messageId::setRight(const string& right)
}
-const std::vector <ref <component> > messageId::getChildComponents()
+const std::vector <shared_ptr <component> > messageId::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/messageIdSequence.cpp b/src/messageIdSequence.cpp
index 99c96319..bfd0c30f 100644
--- a/src/messageIdSequence.cpp
+++ b/src/messageIdSequence.cpp
@@ -50,9 +50,9 @@ messageIdSequence::messageIdSequence(const messageIdSequence& midSeq)
}
-ref <component> messageIdSequence::clone() const
+shared_ptr <component> messageIdSequence::clone() const
{
- return vmime::create <messageIdSequence>(*this);
+ return make_shared <messageIdSequence>(*this);
}
@@ -63,7 +63,7 @@ void messageIdSequence::copyFrom(const component& other)
removeAllMessageIds();
for (unsigned int i = 0 ; i < midSeq.m_list.size() ; ++i)
- m_list.push_back(midSeq.m_list[i]->clone().dynamicCast <messageId>());
+ m_list.push_back(vmime::clone(midSeq.m_list[i]));
}
@@ -74,9 +74,9 @@ messageIdSequence& messageIdSequence::operator=(const messageIdSequence& other)
}
-const std::vector <ref <component> > messageIdSequence::getChildComponents()
+const std::vector <shared_ptr <component> > messageIdSequence::getChildComponents()
{
- std::vector <ref <component> > res;
+ std::vector <shared_ptr <component> > res;
copy_vector(m_list, res);
@@ -94,7 +94,7 @@ void messageIdSequence::parseImpl
while (pos < end)
{
- ref <messageId> parsedMid = messageId::parseNext(ctx, buffer, pos, end, &pos);
+ shared_ptr <messageId> parsedMid = messageId::parseNext(ctx, buffer, pos, end, &pos);
if (parsedMid != NULL)
m_list.push_back(parsedMid);
@@ -118,7 +118,7 @@ void messageIdSequence::generateImpl
generationContext tmpCtx(ctx);
tmpCtx.setMaxLineLength(ctx.getMaxLineLength() - 2);
- for (std::vector <ref <messageId> >::const_iterator it = m_list.begin() ; ; )
+ for (std::vector <shared_ptr <messageId> >::const_iterator it = m_list.begin() ; ; )
{
(*it)->generate(ctx, os, pos, &pos);
@@ -135,15 +135,15 @@ void messageIdSequence::generateImpl
}
-void messageIdSequence::appendMessageId(ref <messageId> mid)
+void messageIdSequence::appendMessageId(shared_ptr <messageId> mid)
{
m_list.push_back(mid);
}
-void messageIdSequence::insertMessageIdBefore(ref <messageId> beforeMid, ref <messageId> mid)
+void messageIdSequence::insertMessageIdBefore(shared_ptr <messageId> beforeMid, shared_ptr <messageId> mid)
{
- const std::vector <ref <messageId> >::iterator it = std::find
+ const std::vector <shared_ptr <messageId> >::iterator it = std::find
(m_list.begin(), m_list.end(), beforeMid);
if (it == m_list.end())
@@ -153,15 +153,15 @@ void messageIdSequence::insertMessageIdBefore(ref <messageId> beforeMid, ref <me
}
-void messageIdSequence::insertMessageIdBefore(const size_t pos, ref <messageId> mid)
+void messageIdSequence::insertMessageIdBefore(const size_t pos, shared_ptr <messageId> mid)
{
m_list.insert(m_list.begin() + pos, mid);
}
-void messageIdSequence::insertMessageIdAfter(ref <messageId> afterMid, ref <messageId> mid)
+void messageIdSequence::insertMessageIdAfter(shared_ptr <messageId> afterMid, shared_ptr <messageId> mid)
{
- const std::vector <ref <messageId> >::iterator it = std::find
+ const std::vector <shared_ptr <messageId> >::iterator it = std::find
(m_list.begin(), m_list.end(), afterMid);
if (it == m_list.end())
@@ -171,15 +171,15 @@ void messageIdSequence::insertMessageIdAfter(ref <messageId> afterMid, ref <mess
}
-void messageIdSequence::insertMessageIdAfter(const size_t pos, ref <messageId> mid)
+void messageIdSequence::insertMessageIdAfter(const size_t pos, shared_ptr <messageId> mid)
{
m_list.insert(m_list.begin() + pos + 1, mid);
}
-void messageIdSequence::removeMessageId(ref <messageId> mid)
+void messageIdSequence::removeMessageId(shared_ptr <messageId> mid)
{
- const std::vector <ref <messageId> >::iterator it = std::find
+ const std::vector <shared_ptr <messageId> >::iterator it = std::find
(m_list.begin(), m_list.end(), mid);
if (it == m_list.end())
@@ -191,7 +191,7 @@ void messageIdSequence::removeMessageId(ref <messageId> mid)
void messageIdSequence::removeMessageId(const size_t pos)
{
- const std::vector <ref <messageId> >::iterator it = m_list.begin() + pos;
+ const std::vector <shared_ptr <messageId> >::iterator it = m_list.begin() + pos;
m_list.erase(it);
}
@@ -215,25 +215,25 @@ bool messageIdSequence::isEmpty() const
}
-const ref <messageId> messageIdSequence::getMessageIdAt(const size_t pos)
+const shared_ptr <messageId> messageIdSequence::getMessageIdAt(const size_t pos)
{
return (m_list[pos]);
}
-const ref <const messageId> messageIdSequence::getMessageIdAt(const size_t pos) const
+const shared_ptr <const messageId> messageIdSequence::getMessageIdAt(const size_t pos) const
{
return (m_list[pos]);
}
-const std::vector <ref <const messageId> > messageIdSequence::getMessageIdList() const
+const std::vector <shared_ptr <const messageId> > messageIdSequence::getMessageIdList() const
{
- std::vector <ref <const messageId> > list;
+ std::vector <shared_ptr <const messageId> > list;
list.reserve(m_list.size());
- for (std::vector <ref <messageId> >::const_iterator it = m_list.begin() ;
+ for (std::vector <shared_ptr <messageId> >::const_iterator it = m_list.begin() ;
it != m_list.end() ; ++it)
{
list.push_back(*it);
@@ -243,7 +243,7 @@ const std::vector <ref <const messageId> > messageIdSequence::getMessageIdList()
}
-const std::vector <ref <messageId> > messageIdSequence::getMessageIdList()
+const std::vector <shared_ptr <messageId> > messageIdSequence::getMessageIdList()
{
return (m_list);
}
diff --git a/src/messageParser.cpp b/src/messageParser.cpp
index 1377072c..41be3803 100644
--- a/src/messageParser.cpp
+++ b/src/messageParser.cpp
@@ -39,14 +39,14 @@ namespace vmime
messageParser::messageParser(const string& buffer)
{
- ref <message> msg = vmime::create <message>();
+ shared_ptr <message> msg = make_shared <message>();
msg->parse(buffer);
parse(msg);
}
-messageParser::messageParser(ref <const message> msg)
+messageParser::messageParser(shared_ptr <const message> msg)
{
parse(msg);
}
@@ -57,13 +57,13 @@ messageParser::~messageParser()
}
-void messageParser::parse(ref <const message> msg)
+void messageParser::parse(shared_ptr <const message> msg)
{
// Header fields (if field is present, copy its value, else do nothing)
#ifndef VMIME_BUILDING_DOC
#define TRY_FIELD(var, type, name) \
- try { var = *msg->getHeader()->findField(name)->getValue().dynamicCast <type>(); } \
+ try { var = *msg->getHeader()->findField(name)->getValue <type>(); } \
catch (exceptions::no_such_field) { }
TRY_FIELD(m_from, mailbox, fields::FROM);
@@ -82,14 +82,14 @@ void messageParser::parse(ref <const message> msg)
try
{
const headerField& recv = *msg->getHeader()->findField(fields::RECEIVED);
- m_date = recv.getValue().dynamicCast <const relay>()->getDate();
+ m_date = recv.getValue <relay>()->getDate();
}
catch (vmime::exceptions::no_such_field&)
{
try
{
const headerField& date = *msg->getHeader()->findField(fields::DATE);
- m_date = *date.getValue().dynamicCast <const datetime>();
+ m_date = *date.getValue <datetime>();
}
catch (vmime::exceptions::no_such_field&)
{
@@ -105,13 +105,13 @@ void messageParser::parse(ref <const message> msg)
}
-void messageParser::findAttachments(ref <const message> msg)
+void messageParser::findAttachments(shared_ptr <const message> msg)
{
m_attach = attachmentHelper::findAttachmentsInMessage(msg);
}
-void messageParser::findTextParts(ref <const bodyPart> msg, ref <const bodyPart> part)
+void messageParser::findTextParts(shared_ptr <const bodyPart> msg, shared_ptr <const bodyPart> part)
{
// Handle the case in which the message is not multipart: if the body part is
// "text/*", take this part.
@@ -122,11 +122,11 @@ void messageParser::findTextParts(ref <const bodyPart> msg, ref <const bodyPart>
try
{
- const contentTypeField& ctf = dynamic_cast<contentTypeField&>
- (*msg->getHeader()->findField(fields::CONTENT_TYPE));
+ const contentTypeField& ctf =
+ *msg->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
const mediaType ctfType =
- *ctf.getValue().dynamicCast <const mediaType>();
+ *ctf.getValue <mediaType>();
if (ctfType.getType() == mediaTypes::TEXT)
{
@@ -142,7 +142,7 @@ void messageParser::findTextParts(ref <const bodyPart> msg, ref <const bodyPart>
if (accept)
{
- ref <textPart> txtPart = textPartFactory::getInstance()->create(type);
+ shared_ptr <textPart> txtPart = textPartFactory::getInstance()->create(type);
txtPart->parse(msg, msg, msg);
m_textParts.push_back(txtPart);
@@ -156,35 +156,35 @@ void messageParser::findTextParts(ref <const bodyPart> msg, ref <const bodyPart>
}
-bool messageParser::findSubTextParts(ref <const bodyPart> msg, ref <const bodyPart> part)
+bool messageParser::findSubTextParts(shared_ptr <const bodyPart> msg, shared_ptr <const bodyPart> part)
{
// In general, all the text parts are contained in parallel in the same
// parent part (or message).
// So, wherever the text parts are, all we have to do is to find the first
// MIME part which is a text part.
- std::vector <ref <const bodyPart> > textParts;
+ std::vector <shared_ptr <const bodyPart> > textParts;
for (size_t i = 0 ; i < part->getBody()->getPartCount() ; ++i)
{
- const ref <const bodyPart> p = part->getBody()->getPartAt(i);
+ const shared_ptr <const bodyPart> p = part->getBody()->getPartAt(i);
try
{
- const contentTypeField& ctf = dynamic_cast <const contentTypeField&>
- (*(p->getHeader()->findField(fields::CONTENT_TYPE)));
+ const contentTypeField& ctf =
+ *p->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- const mediaType type = *ctf.getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf.getValue <mediaType>();
contentDisposition disp; // default should be inline
if (type.getType() == mediaTypes::TEXT)
{
try
{
- ref <const contentDispositionField> cdf = p->getHeader()->
- findField(fields::CONTENT_DISPOSITION).dynamicCast <const contentDispositionField>();
+ shared_ptr <const contentDispositionField> cdf = p->getHeader()->
+ findField <contentDispositionField>(fields::CONTENT_DISPOSITION);
- disp = *cdf->getValue().dynamicCast <const contentDisposition>();
+ disp = *cdf->getValue <contentDisposition>();
}
catch (exceptions::no_such_field&)
{
@@ -204,17 +204,17 @@ bool messageParser::findSubTextParts(ref <const bodyPart> msg, ref <const bodyPa
if (textParts.size())
{
// Okay. So we have found at least one text part
- for (std::vector <ref <const bodyPart> >::const_iterator p = textParts.begin() ;
+ for (std::vector <shared_ptr <const bodyPart> >::const_iterator p = textParts.begin() ;
p != textParts.end() ; ++p)
{
- const contentTypeField& ctf = dynamic_cast <const contentTypeField&>
- (*((*p)->getHeader()->findField(fields::CONTENT_TYPE)));
+ const contentTypeField& ctf =
+ *(*p)->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- const mediaType type = *ctf.getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf.getValue <mediaType>();
try
{
- ref <textPart> txtPart = textPartFactory::getInstance()->create(type);
+ shared_ptr <textPart> txtPart = textPartFactory::getInstance()->create(type);
txtPart->parse(msg, part, *p);
m_textParts.push_back(txtPart);
@@ -273,7 +273,7 @@ const datetime& messageParser::getDate() const
}
-const std::vector <ref <const attachment> > messageParser::getAttachmentList() const
+const std::vector <shared_ptr <const attachment> > messageParser::getAttachmentList() const
{
return m_attach;
}
@@ -285,19 +285,19 @@ size_t messageParser::getAttachmentCount() const
}
-const ref <const attachment> messageParser::getAttachmentAt(const size_t pos) const
+const shared_ptr <const attachment> messageParser::getAttachmentAt(const size_t pos) const
{
return (m_attach[pos]);
}
-const std::vector <ref <const textPart> > messageParser::getTextPartList() const
+const std::vector <shared_ptr <const textPart> > messageParser::getTextPartList() const
{
- std::vector <ref <const textPart> > res;
+ std::vector <shared_ptr <const textPart> > res;
res.reserve(m_textParts.size());
- for (std::vector <ref <textPart> >::const_iterator it = m_textParts.begin() ;
+ for (std::vector <shared_ptr <textPart> >::const_iterator it = m_textParts.begin() ;
it != m_textParts.end() ; ++it)
{
res.push_back(*it);
@@ -313,7 +313,7 @@ size_t messageParser::getTextPartCount() const
}
-const ref <const textPart> messageParser::getTextPartAt(const size_t pos) const
+const shared_ptr <const textPart> messageParser::getTextPartAt(const size_t pos) const
{
return (m_textParts[pos]);
}
diff --git a/src/misc/importanceHelper.cpp b/src/misc/importanceHelper.cpp
index 2cc7ce6a..8066cc5f 100644
--- a/src/misc/importanceHelper.cpp
+++ b/src/misc/importanceHelper.cpp
@@ -31,17 +31,17 @@ namespace vmime {
namespace misc {
-void importanceHelper::resetImportance(ref <message> msg)
+void importanceHelper::resetImportance(shared_ptr <message> msg)
{
resetImportanceHeader(msg->getHeader());
}
-void importanceHelper::resetImportanceHeader(ref <header> hdr)
+void importanceHelper::resetImportanceHeader(shared_ptr <header> hdr)
{
try
{
- ref <headerField> fld = hdr->findField("X-Priority");
+ shared_ptr <headerField> fld = hdr->findField("X-Priority");
hdr->removeField(fld);
}
catch (exceptions::no_such_field)
@@ -51,7 +51,7 @@ void importanceHelper::resetImportanceHeader(ref <header> hdr)
try
{
- ref <headerField> fld = hdr->findField("Importance");
+ shared_ptr <headerField> fld = hdr->findField("Importance");
hdr->removeField(fld);
}
catch (exceptions::no_such_field)
@@ -61,19 +61,19 @@ void importanceHelper::resetImportanceHeader(ref <header> hdr)
}
-importanceHelper::Importance importanceHelper::getImportance(ref <const message> msg)
+importanceHelper::Importance importanceHelper::getImportance(shared_ptr <const message> msg)
{
return getImportanceHeader(msg->getHeader());
}
-importanceHelper::Importance importanceHelper::getImportanceHeader(ref <const header> hdr)
+importanceHelper::Importance importanceHelper::getImportanceHeader(shared_ptr <const header> hdr)
{
// Try "X-Priority" field
try
{
- const ref <const headerField> fld = hdr->findField("X-Priority");
- const string value = fld->getValue().dynamicCast <const text>()->getWholeBuffer();
+ const shared_ptr <const headerField> fld = hdr->findField("X-Priority");
+ const string value = fld->getValue <text>()->getWholeBuffer();
int n = IMPORTANCE_NORMAL;
@@ -98,9 +98,9 @@ importanceHelper::Importance importanceHelper::getImportanceHeader(ref <const he
// Try "Importance" field
try
{
- const ref <const headerField> fld = hdr->findField("Importance");
+ const shared_ptr <const headerField> fld = hdr->findField("Importance");
const string value = utility::stringUtils::toLower(utility::stringUtils::trim
- (fld->getValue().dynamicCast <const text>()->getWholeBuffer()));
+ (fld->getValue <text>()->getWholeBuffer()));
if (value == "low")
return (IMPORTANCE_LOWEST);
@@ -121,16 +121,16 @@ importanceHelper::Importance importanceHelper::getImportanceHeader(ref <const he
}
-void importanceHelper::setImportance(ref <message> msg, const Importance i)
+void importanceHelper::setImportance(shared_ptr <message> msg, const Importance i)
{
setImportanceHeader(msg->getHeader(), i);
}
-void importanceHelper::setImportanceHeader(ref <header> hdr, const Importance i)
+void importanceHelper::setImportanceHeader(shared_ptr <header> hdr, const Importance i)
{
// "X-Priority:" Field
- ref <headerField> fld = hdr->getField("X-Priority");
+ shared_ptr <headerField> fld = hdr->getField("X-Priority");
switch (i)
{
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
diff --git a/src/object.cpp b/src/object.cpp
index 1b50c53c..d07c3c19 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -25,79 +25,29 @@
#include "vmime/object.hpp"
-#ifndef VMIME_BUILDING_DOC
-
-
namespace vmime
{
object::object()
- : m_refMgr(utility::refManager::create(this))
{
}
object::object(const object&)
- : m_refMgr(utility::refManager::create(this))
{
}
object& object::operator=(const object&)
{
- // Do _NOT_ copy 'm_refMgr'
return *this;
}
object::~object()
{
- delete m_refMgr;
- m_refMgr = 0;
-}
-
-
-ref <object> object::thisRef()
-{
- m_refMgr->addStrong();
- return ref <object>::fromPtr(this);
-}
-
-
-ref <const object> object::thisRef() const
-{
- m_refMgr->addStrong();
- return ref <const object>::fromPtr(this);
-}
-
-
-weak_ref <object> object::thisWeakRef()
-{
- return weak_ref <object>(thisRef());
-}
-
-
-weak_ref <const object> object::thisWeakRef() const
-{
- return weak_ref <const object>(thisRef());
-}
-
-
-void object::setRefManager(utility::refManager* mgr)
-{
- m_refMgr = mgr;
-}
-
-
-utility::refManager* object::getRefManager() const
-{
- return m_refMgr;
}
} // vmime
-
-
-#endif // VMIME_BUILDING_DOC
-
diff --git a/src/parameter.cpp b/src/parameter.cpp
index 901139e3..d7fcd7d3 100644
--- a/src/parameter.cpp
+++ b/src/parameter.cpp
@@ -36,19 +36,19 @@ namespace vmime
parameter::parameter(const string& name)
- : m_name(name), m_value(vmime::create <word>())
+ : m_name(name), m_value(make_shared <word>())
{
}
parameter::parameter(const string& name, const word& value)
- : m_name(name), m_value(vmime::create <word>(value))
+ : m_name(name), m_value(make_shared <word>(value))
{
}
parameter::parameter(const string& name, const string& value)
- : m_name(name), m_value(vmime::create <word>(value))
+ : m_name(name), m_value(make_shared <word>(value))
{
}
@@ -59,9 +59,9 @@ parameter::parameter(const parameter&)
}
-ref <component> parameter::clone() const
+shared_ptr <component> parameter::clone() const
{
- ref <parameter> p = vmime::create <parameter>(m_name);
+ shared_ptr <parameter> p = make_shared <parameter>(m_name);
p->copyFrom(*this);
return (p);
@@ -589,9 +589,9 @@ void parameter::generateImpl
}
-const std::vector <ref <component> > parameter::getChildComponents()
+const std::vector <shared_ptr <component> > parameter::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
list.push_back(m_value);
diff --git a/src/parameterizedHeaderField.cpp b/src/parameterizedHeaderField.cpp
index c4e0b368..b329d1c1 100644
--- a/src/parameterizedHeaderField.cpp
+++ b/src/parameterizedHeaderField.cpp
@@ -321,7 +321,7 @@ void parameterizedHeaderField::parseImpl
const paramInfo& info = (*it).second;
// Append this parameter to the list
- ref <parameter> param = vmime::create <parameter>((*it).first);
+ shared_ptr <parameter> param = make_shared <parameter>((*it).first);
param->parse(ctx, info.value);
param->setParsedBounds(info.start, info.end);
@@ -345,7 +345,7 @@ void parameterizedHeaderField::generateImpl
headerField::generateImpl(ctx, os, pos, &pos);
// Parameters
- for (std::vector <ref <parameter> >::const_iterator
+ for (std::vector <shared_ptr <parameter> >::const_iterator
it = m_params.begin() ; it != m_params.end() ; ++it)
{
os << "; ";
@@ -367,10 +367,10 @@ void parameterizedHeaderField::copyFrom(const component& other)
removeAllParameters();
- for (std::vector <ref <parameter> >::const_iterator i = source.m_params.begin() ;
+ for (std::vector <shared_ptr <parameter> >::const_iterator i = source.m_params.begin() ;
i != source.m_params.end() ; ++i)
{
- appendParameter((*i)->clone().dynamicCast <parameter>());
+ appendParameter(vmime::clone(*i));
}
}
@@ -386,8 +386,8 @@ bool parameterizedHeaderField::hasParameter(const string& paramName) const
{
const string name = utility::stringUtils::toLower(paramName);
- std::vector <ref <parameter> >::const_iterator pos = m_params.begin();
- const std::vector <ref <parameter> >::const_iterator end = m_params.end();
+ std::vector <shared_ptr <parameter> >::const_iterator pos = m_params.begin();
+ const std::vector <shared_ptr <parameter> >::const_iterator end = m_params.end();
for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {}
@@ -395,13 +395,13 @@ bool parameterizedHeaderField::hasParameter(const string& paramName) const
}
-ref <parameter> parameterizedHeaderField::findParameter(const string& paramName) const
+shared_ptr <parameter> parameterizedHeaderField::findParameter(const string& paramName) const
{
const string name = utility::stringUtils::toLower(paramName);
// Find the first parameter that matches the specified name
- std::vector <ref <parameter> >::const_iterator pos = m_params.begin();
- const std::vector <ref <parameter> >::const_iterator end = m_params.end();
+ std::vector <shared_ptr <parameter> >::const_iterator pos = m_params.begin();
+ const std::vector <shared_ptr <parameter> >::const_iterator end = m_params.end();
for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {}
@@ -418,20 +418,20 @@ ref <parameter> parameterizedHeaderField::findParameter(const string& paramName)
}
-ref <parameter> parameterizedHeaderField::getParameter(const string& paramName)
+shared_ptr <parameter> parameterizedHeaderField::getParameter(const string& paramName)
{
const string name = utility::stringUtils::toLower(paramName);
// Find the first parameter that matches the specified name
- std::vector <ref <parameter> >::const_iterator pos = m_params.begin();
- const std::vector <ref <parameter> >::const_iterator end = m_params.end();
+ std::vector <shared_ptr <parameter> >::const_iterator pos = m_params.begin();
+ const std::vector <shared_ptr <parameter> >::const_iterator end = m_params.end();
for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {}
// If no parameter with this name can be found, create a new one
if (pos == end)
{
- ref <parameter> param = vmime::create <parameter>(paramName);
+ shared_ptr <parameter> param = make_shared <parameter>(paramName);
appendParameter(param);
@@ -446,15 +446,15 @@ ref <parameter> parameterizedHeaderField::getParameter(const string& paramName)
}
-void parameterizedHeaderField::appendParameter(ref <parameter> param)
+void parameterizedHeaderField::appendParameter(shared_ptr <parameter> param)
{
m_params.push_back(param);
}
-void parameterizedHeaderField::insertParameterBefore(ref <parameter> beforeParam, ref <parameter> param)
+void parameterizedHeaderField::insertParameterBefore(shared_ptr <parameter> beforeParam, shared_ptr <parameter> param)
{
- const std::vector <ref <parameter> >::iterator it = std::find
+ const std::vector <shared_ptr <parameter> >::iterator it = std::find
(m_params.begin(), m_params.end(), beforeParam);
if (it == m_params.end())
@@ -464,15 +464,15 @@ void parameterizedHeaderField::insertParameterBefore(ref <parameter> beforeParam
}
-void parameterizedHeaderField::insertParameterBefore(const size_t pos, ref <parameter> param)
+void parameterizedHeaderField::insertParameterBefore(const size_t pos, shared_ptr <parameter> param)
{
m_params.insert(m_params.begin() + pos, param);
}
-void parameterizedHeaderField::insertParameterAfter(ref <parameter> afterParam, ref <parameter> param)
+void parameterizedHeaderField::insertParameterAfter(shared_ptr <parameter> afterParam, shared_ptr <parameter> param)
{
- const std::vector <ref <parameter> >::iterator it = std::find
+ const std::vector <shared_ptr <parameter> >::iterator it = std::find
(m_params.begin(), m_params.end(), afterParam);
if (it == m_params.end())
@@ -482,15 +482,15 @@ void parameterizedHeaderField::insertParameterAfter(ref <parameter> afterParam,
}
-void parameterizedHeaderField::insertParameterAfter(const size_t pos, ref <parameter> param)
+void parameterizedHeaderField::insertParameterAfter(const size_t pos, shared_ptr <parameter> param)
{
m_params.insert(m_params.begin() + pos + 1, param);
}
-void parameterizedHeaderField::removeParameter(ref <parameter> param)
+void parameterizedHeaderField::removeParameter(shared_ptr <parameter> param)
{
- const std::vector <ref <parameter> >::iterator it = std::find
+ const std::vector <shared_ptr <parameter> >::iterator it = std::find
(m_params.begin(), m_params.end(), param);
if (it == m_params.end())
@@ -502,7 +502,7 @@ void parameterizedHeaderField::removeParameter(ref <parameter> param)
void parameterizedHeaderField::removeParameter(const size_t pos)
{
- const std::vector <ref <parameter> >::iterator it = m_params.begin() + pos;
+ const std::vector <shared_ptr <parameter> >::iterator it = m_params.begin() + pos;
m_params.erase(it);
}
@@ -526,25 +526,25 @@ bool parameterizedHeaderField::isEmpty() const
}
-const ref <parameter> parameterizedHeaderField::getParameterAt(const size_t pos)
+const shared_ptr <parameter> parameterizedHeaderField::getParameterAt(const size_t pos)
{
return (m_params[pos]);
}
-const ref <const parameter> parameterizedHeaderField::getParameterAt(const size_t pos) const
+const shared_ptr <const parameter> parameterizedHeaderField::getParameterAt(const size_t pos) const
{
return (m_params[pos]);
}
-const std::vector <ref <const parameter> > parameterizedHeaderField::getParameterList() const
+const std::vector <shared_ptr <const parameter> > parameterizedHeaderField::getParameterList() const
{
- std::vector <ref <const parameter> > list;
+ std::vector <shared_ptr <const parameter> > list;
list.reserve(m_params.size());
- for (std::vector <ref <parameter> >::const_iterator it = m_params.begin() ;
+ for (std::vector <shared_ptr <parameter> >::const_iterator it = m_params.begin() ;
it != m_params.end() ; ++it)
{
list.push_back(*it);
@@ -554,17 +554,17 @@ const std::vector <ref <const parameter> > parameterizedHeaderField::getParamete
}
-const std::vector <ref <parameter> > parameterizedHeaderField::getParameterList()
+const std::vector <shared_ptr <parameter> > parameterizedHeaderField::getParameterList()
{
return (m_params);
}
-const std::vector <ref <component> > parameterizedHeaderField::getChildComponents()
+const std::vector <shared_ptr <component> > parameterizedHeaderField::getChildComponents()
{
- std::vector <ref <component> > list = headerField::getChildComponents();
+ std::vector <shared_ptr <component> > list = headerField::getChildComponents();
- for (std::vector <ref <parameter> >::iterator it = m_params.begin() ;
+ for (std::vector <shared_ptr <parameter> >::iterator it = m_params.begin() ;
it != m_params.end() ; ++it)
{
list.push_back(*it);
diff --git a/src/parsedMessageAttachment.cpp b/src/parsedMessageAttachment.cpp
index bf58a713..242bfde0 100644
--- a/src/parsedMessageAttachment.cpp
+++ b/src/parsedMessageAttachment.cpp
@@ -33,7 +33,7 @@ namespace vmime
{
-parsedMessageAttachment::parsedMessageAttachment(ref <message> msg)
+parsedMessageAttachment::parsedMessageAttachment(shared_ptr <message> msg)
: m_msg(msg)
{
}
@@ -57,7 +57,7 @@ const word parsedMessageAttachment::getName() const
}
-const ref <const contentHandler> parsedMessageAttachment::getData() const
+const shared_ptr <const contentHandler> parsedMessageAttachment::getData() const
{
if (m_data == NULL)
{
@@ -66,7 +66,7 @@ const ref <const contentHandler> parsedMessageAttachment::getData() const
m_msg->generate(os);
- m_data = vmime::create <stringContentHandler>(oss.str());
+ m_data = make_shared <stringContentHandler>(oss.str());
}
return m_data;
@@ -79,28 +79,28 @@ const encoding parsedMessageAttachment::getEncoding() const
}
-ref <const object> parsedMessageAttachment::getPart() const
+shared_ptr <const object> parsedMessageAttachment::getPart() const
{
- return NULL;
+ return null;
}
-ref <const header> parsedMessageAttachment::getHeader() const
+shared_ptr <const header> parsedMessageAttachment::getHeader() const
{
- return NULL;
+ return null;
}
-ref <message> parsedMessageAttachment::getMessage() const
+shared_ptr <message> parsedMessageAttachment::getMessage() const
{
return m_msg;
}
-void parsedMessageAttachment::generateIn(ref <bodyPart> parent) const
+void parsedMessageAttachment::generateIn(shared_ptr <bodyPart> parent) const
{
// Create and append a new part for this attachment
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
parent->getBody()->appendPart(part);
// Set header fields
diff --git a/src/path.cpp b/src/path.cpp
index 3e6e7a84..8722c9a7 100644
--- a/src/path.cpp
+++ b/src/path.cpp
@@ -93,9 +93,9 @@ void path::copyFrom(const component& other)
}
-ref <component> path::clone() const
+shared_ptr <component> path::clone() const
{
- return vmime::create <path>(*this);
+ return make_shared <path>(*this);
}
@@ -106,9 +106,9 @@ path& path::operator=(const path& other)
}
-const std::vector <ref <component> > path::getChildComponents()
+const std::vector <shared_ptr <component> > path::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/plainTextPart.cpp b/src/plainTextPart.cpp
index c26e146e..e1959af1 100644
--- a/src/plainTextPart.cpp
+++ b/src/plainTextPart.cpp
@@ -35,7 +35,7 @@ namespace vmime
plainTextPart::plainTextPart()
- : m_text(vmime::create <emptyContentHandler>())
+ : m_text(make_shared <emptyContentHandler>())
{
}
@@ -57,10 +57,10 @@ size_t plainTextPart::getPartCount() const
}
-void plainTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> parent) const
+void plainTextPart::generateIn(shared_ptr <bodyPart> /* message */, shared_ptr <bodyPart> parent) const
{
// Create a new part
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
parent->getBody()->appendPart(part);
// Set contents
@@ -70,15 +70,15 @@ void plainTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> pare
}
-void plainTextPart::parse(ref <const bodyPart> /* message */,
- ref <const bodyPart> /* parent */, ref <const bodyPart> textPart)
+void plainTextPart::parse(shared_ptr <const bodyPart> /* message */,
+ shared_ptr <const bodyPart> /* parent */, shared_ptr <const bodyPart> textPart)
{
- m_text = textPart->getBody()->getContents()->clone().dynamicCast <contentHandler>();
+ m_text = vmime::clone(textPart->getBody()->getContents());
try
{
- const contentTypeField& ctf = dynamic_cast<contentTypeField&>
- (*textPart->getHeader()->findField(fields::CONTENT_TYPE));
+ const contentTypeField& ctf =
+ *textPart->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
m_charset = ctf.getCharset();
}
@@ -105,15 +105,15 @@ void plainTextPart::setCharset(const charset& ch)
}
-const ref <const contentHandler> plainTextPart::getText() const
+const shared_ptr <const contentHandler> plainTextPart::getText() const
{
return (m_text);
}
-void plainTextPart::setText(ref <contentHandler> text)
+void plainTextPart::setText(shared_ptr <contentHandler> text)
{
- m_text = text->clone().dynamicCast <contentHandler>();
+ m_text = vmime::clone(text);
}
diff --git a/src/platform.cpp b/src/platform.cpp
index 37c7b027..631d5bcf 100644
--- a/src/platform.cpp
+++ b/src/platform.cpp
@@ -32,7 +32,7 @@ namespace vmime
{
-ref <platform::handler> platform::sm_handler = NULL;
+shared_ptr <platform::handler> platform::sm_handler;
platform::handler::~handler()
@@ -41,29 +41,29 @@ platform::handler::~handler()
// static
-ref <platform::handler> platform::getDefaultHandler()
+shared_ptr <platform::handler> platform::getDefaultHandler()
{
#if VMIME_PLATFORM_IS_WINDOWS
- return vmime::create <platforms::windows::windowsHandler>();
+ return make_shared <platforms::windows::windowsHandler>();
#elif VMIME_PLATFORM_IS_POSIX
- return vmime::create <platforms::posix::posixHandler>();
+ return make_shared <platforms::posix::posixHandler>();
#else
- return NULL;
+ return null;
#endif
}
// static
-ref <platform::handler> platform::getHandler()
+shared_ptr <platform::handler> platform::getHandler()
{
// If a custom platform handler is installed, return it
if (sm_handler)
return sm_handler;
// Else, use the default handler for this platform
- ref <handler> defaultHandler = getDefaultHandler();
+ shared_ptr <handler> defaultHandler = getDefaultHandler();
if (defaultHandler)
{
diff --git a/src/platforms/posix/posixChildProcess.cpp b/src/platforms/posix/posixChildProcess.cpp
index 09119996..c4761624 100644
--- a/src/platforms/posix/posixChildProcess.cpp
+++ b/src/platforms/posix/posixChildProcess.cpp
@@ -32,8 +32,6 @@
#include "vmime/exception.hpp"
-#include "vmime/utility/smartPtr.hpp"
-
#include <unistd.h>
#include <string.h>
#include <errno.h>
@@ -49,9 +47,9 @@ namespace posix {
// posixChildProcessFactory
-ref <utility::childProcess> posixChildProcessFactory::create(const utility::file::path& path) const
+shared_ptr <utility::childProcess> posixChildProcessFactory::create(const utility::file::path& path) const
{
- return vmime::create <posixChildProcess>(path);
+ return make_shared <posixChildProcess>(path);
}
@@ -215,7 +213,7 @@ private:
posixChildProcess::posixChildProcess(const utility::file::path& path)
: m_processPath(path), m_started(false),
- m_stdIn(NULL), m_stdOut(NULL), m_pid(0), m_argArray(NULL)
+ m_stdIn(null), m_stdOut(null), m_pid(0), m_argArray(NULL)
{
m_pipe[0] = 0;
m_pipe[1] = 0;
@@ -319,7 +317,7 @@ void posixChildProcess::start(const std::vector <string> args, const int flags)
if (flags & FLAG_REDIRECT_STDIN)
{
- m_stdIn = vmime::create <outputStreamPosixPipeAdapter>(m_pipe[1]);
+ m_stdIn = make_shared <outputStreamPosixPipeAdapter>(m_pipe[1]);
}
else
{
@@ -329,7 +327,7 @@ void posixChildProcess::start(const std::vector <string> args, const int flags)
if (flags & FLAG_REDIRECT_STDOUT)
{
- m_stdOut = vmime::create <inputStreamPosixPipeAdapter>(m_pipe[0]);
+ m_stdOut = make_shared <inputStreamPosixPipeAdapter>(m_pipe[0]);
}
else
{
@@ -342,13 +340,13 @@ void posixChildProcess::start(const std::vector <string> args, const int flags)
}
-ref <utility::outputStream> posixChildProcess::getStdIn()
+shared_ptr <utility::outputStream> posixChildProcess::getStdIn()
{
return (m_stdIn);
}
-ref <utility::inputStream> posixChildProcess::getStdOut()
+shared_ptr <utility::inputStream> posixChildProcess::getStdOut()
{
return (m_stdOut);
}
@@ -377,8 +375,7 @@ void posixChildProcess::waitForFinish()
{
if (WEXITSTATUS(wstat) == 255)
{
- vmime::utility::auto_ptr <posixFileSystemFactory> pfsf
- = new posixFileSystemFactory();
+ std::auto_ptr <posixFileSystemFactory> pfsf(new posixFileSystemFactory());
throw exceptions::system_error("Could not execute '"
+ pfsf->pathToString(m_processPath) + "'");
diff --git a/src/platforms/posix/posixFile.cpp b/src/platforms/posix/posixFile.cpp
index 744f01ff..1e4dd070 100644
--- a/src/platforms/posix/posixFile.cpp
+++ b/src/platforms/posix/posixFile.cpp
@@ -79,9 +79,9 @@ bool posixFileIterator::hasMoreElements() const
}
-ref <vmime::utility::file> posixFileIterator::nextElement()
+shared_ptr <vmime::utility::file> posixFileIterator::nextElement()
{
- ref <posixFile> file = vmime::create <posixFile>
+ shared_ptr <posixFile> file = make_shared <posixFile>
(m_path / vmime::utility::file::path::component(m_dirEntry->d_name));
getNextElement();
@@ -258,14 +258,14 @@ posixFileWriter::posixFileWriter(const vmime::utility::file::path& path, const v
}
-ref <vmime::utility::outputStream> posixFileWriter::getOutputStream()
+shared_ptr <vmime::utility::outputStream> posixFileWriter::getOutputStream()
{
int fd = 0;
if ((fd = ::open(m_nativePath.c_str(), O_WRONLY, 0660)) == -1)
posixFileSystemFactory::reportError(m_path, errno);
- return vmime::create <posixFileWriterOutputStream>(m_path, fd);
+ return make_shared <posixFileWriterOutputStream>(m_path, fd);
}
@@ -280,14 +280,14 @@ posixFileReader::posixFileReader(const vmime::utility::file::path& path, const v
}
-ref <vmime::utility::inputStream> posixFileReader::getInputStream()
+shared_ptr <vmime::utility::inputStream> posixFileReader::getInputStream()
{
int fd = 0;
if ((fd = ::open(m_nativePath.c_str(), O_RDONLY, 0640)) == -1)
posixFileSystemFactory::reportError(m_path, errno);
- return vmime::create <posixFileReaderInputStream>(m_path, fd);
+ return make_shared <posixFileReaderInputStream>(m_path, fd);
}
@@ -417,12 +417,12 @@ bool posixFile::exists() const
}
-ref <vmime::utility::file> posixFile::getParent() const
+shared_ptr <vmime::utility::file> posixFile::getParent() const
{
if (m_path.isEmpty())
- return NULL;
+ return null;
else
- return vmime::create <posixFile>(m_path.getParent());
+ return make_shared <posixFile>(m_path.getParent());
}
@@ -465,24 +465,24 @@ void posixFile::remove()
}
-ref <vmime::utility::fileWriter> posixFile::getFileWriter()
+shared_ptr <vmime::utility::fileWriter> posixFile::getFileWriter()
{
- return vmime::create <posixFileWriter>(m_path, m_nativePath);
+ return make_shared <posixFileWriter>(m_path, m_nativePath);
}
-ref <vmime::utility::fileReader> posixFile::getFileReader()
+shared_ptr <vmime::utility::fileReader> posixFile::getFileReader()
{
- return vmime::create <posixFileReader>(m_path, m_nativePath);
+ return make_shared <posixFileReader>(m_path, m_nativePath);
}
-ref <vmime::utility::fileIterator> posixFile::getFiles() const
+shared_ptr <vmime::utility::fileIterator> posixFile::getFiles() const
{
if (!isDirectory())
throw vmime::exceptions::not_a_directory(m_path);
- return vmime::create <posixFileIterator>(m_path, m_nativePath);
+ return make_shared <posixFileIterator>(m_path, m_nativePath);
}
@@ -508,9 +508,9 @@ void posixFile::createDirectoryImpl(const vmime::utility::file::path& fullPath,
// posixFileSystemFactory
//
-ref <vmime::utility::file> posixFileSystemFactory::create(const vmime::utility::file::path& path) const
+shared_ptr <vmime::utility::file> posixFileSystemFactory::create(const vmime::utility::file::path& path) const
{
- return vmime::create <posixFile>(path);
+ return make_shared <posixFile>(path);
}
diff --git a/src/platforms/posix/posixHandler.cpp b/src/platforms/posix/posixHandler.cpp
index 73005d7e..b5d08ce6 100644
--- a/src/platforms/posix/posixHandler.cpp
+++ b/src/platforms/posix/posixHandler.cpp
@@ -109,11 +109,11 @@ namespace posix {
posixHandler::posixHandler()
{
#if VMIME_HAVE_MESSAGING_FEATURES
- m_socketFactory = vmime::create <posixSocketFactory>();
+ m_socketFactory = make_shared <posixSocketFactory>();
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES
- m_fileSysFactory = vmime::create <posixFileSystemFactory>();
- m_childProcFactory = vmime::create <posixChildProcessFactory>();
+ m_fileSysFactory = make_shared <posixFileSystemFactory>();
+ m_childProcFactory = make_shared <posixChildProcessFactory>();
#endif
}
@@ -249,7 +249,7 @@ unsigned int posixHandler::getThreadId() const
#if VMIME_HAVE_MESSAGING_FEATURES
-ref <vmime::net::socketFactory> posixHandler::getSocketFactory()
+shared_ptr <vmime::net::socketFactory> posixHandler::getSocketFactory()
{
return m_socketFactory;
}
@@ -259,13 +259,13 @@ ref <vmime::net::socketFactory> posixHandler::getSocketFactory()
#if VMIME_HAVE_FILESYSTEM_FEATURES
-ref <vmime::utility::fileSystemFactory> posixHandler::getFileSystemFactory()
+shared_ptr <vmime::utility::fileSystemFactory> posixHandler::getFileSystemFactory()
{
return m_fileSysFactory;
}
-ref <vmime::utility::childProcessFactory> posixHandler::getChildProcessFactory()
+shared_ptr <vmime::utility::childProcessFactory> posixHandler::getChildProcessFactory()
{
return m_childProcFactory;
}
@@ -308,9 +308,9 @@ void posixHandler::generateRandomBytes(unsigned char* buffer, const unsigned int
}
-ref <utility::sync::criticalSection> posixHandler::createCriticalSection()
+shared_ptr <utility::sync::criticalSection> posixHandler::createCriticalSection()
{
- return vmime::create <posixCriticalSection>();
+ return make_shared <posixCriticalSection>();
}
diff --git a/src/platforms/posix/posixSocket.cpp b/src/platforms/posix/posixSocket.cpp
index bee9f89e..e0bcf03a 100644
--- a/src/platforms/posix/posixSocket.cpp
+++ b/src/platforms/posix/posixSocket.cpp
@@ -59,7 +59,7 @@ namespace posix {
// posixSocket
//
-posixSocket::posixSocket(ref <vmime::net::timeoutHandler> th)
+posixSocket::posixSocket(shared_ptr <vmime::net::timeoutHandler> th)
: m_timeoutHandler(th), m_desc(-1), m_status(0)
{
}
@@ -631,16 +631,16 @@ unsigned int posixSocket::getStatus() const
// posixSocketFactory
//
-ref <vmime::net::socket> posixSocketFactory::create()
+shared_ptr <vmime::net::socket> posixSocketFactory::create()
{
- ref <vmime::net::timeoutHandler> th = NULL;
- return vmime::create <posixSocket>(th);
+ shared_ptr <vmime::net::timeoutHandler> th;
+ return make_shared <posixSocket>(th);
}
-ref <vmime::net::socket> posixSocketFactory::create(ref <vmime::net::timeoutHandler> th)
+shared_ptr <vmime::net::socket> posixSocketFactory::create(shared_ptr <vmime::net::timeoutHandler> th)
{
- return vmime::create <posixSocket>(th);
+ return make_shared <posixSocket>(th);
}
diff --git a/src/platforms/windows/windowsFile.cpp b/src/platforms/windows/windowsFile.cpp
index fd8a9651..8d2a19da 100644
--- a/src/platforms/windows/windowsFile.cpp
+++ b/src/platforms/windows/windowsFile.cpp
@@ -41,9 +41,9 @@ namespace platforms {
namespace windows {
-ref <vmime::utility::file> windowsFileSystemFactory::create(const vmime::utility::file::path& path) const
+shared_ptr <vmime::utility::file> windowsFileSystemFactory::create(const vmime::utility::file::path& path) const
{
- return vmime::create <windowsFile>(path);
+ return make_shared <windowsFile>(path);
}
@@ -307,12 +307,12 @@ bool windowsFile::exists() const
return false;
}
-ref <vmime::utility::file> windowsFile::getParent() const
+shared_ptr <vmime::utility::file> windowsFile::getParent() const
{
if (m_path.isEmpty())
return NULL;
else
- return vmime::create <windowsFile>(m_path.getParent());
+ return make_shared <windowsFile>(m_path.getParent());
}
void windowsFile::rename(const path& newName)
@@ -333,19 +333,19 @@ void windowsFile::remove()
windowsFileSystemFactory::reportError(m_path, GetLastError());
}
-ref <vmime::utility::fileWriter> windowsFile::getFileWriter()
+shared_ptr <vmime::utility::fileWriter> windowsFile::getFileWriter()
{
- return vmime::create <windowsFileWriter>(m_path, m_nativePath);
+ return make_shared <windowsFileWriter>(m_path, m_nativePath);
}
-ref <vmime::utility::fileReader> windowsFile::getFileReader()
+shared_ptr <vmime::utility::fileReader> windowsFile::getFileReader()
{
- return vmime::create <windowsFileReader>(m_path, m_nativePath);
+ return make_shared <windowsFileReader>(m_path, m_nativePath);
}
-ref <vmime::utility::fileIterator> windowsFile::getFiles() const
+shared_ptr <vmime::utility::fileIterator> windowsFile::getFiles() const
{
- return vmime::create <windowsFileIterator>(m_path, m_nativePath);
+ return make_shared <windowsFileIterator>(m_path, m_nativePath);
}
void windowsFile::createDirectoryImpl(const vmime::utility::file::path& fullPath, const vmime::utility::file::path& path, const bool recursive)
@@ -380,9 +380,9 @@ bool windowsFileIterator::hasMoreElements() const
return m_moreElements;
}
-ref <vmime::utility::file> windowsFileIterator::nextElement()
+shared_ptr <vmime::utility::file> windowsFileIterator::nextElement()
{
- ref <vmime::utility::file> pFile = vmime::create <windowsFile>
+ shared_ptr <vmime::utility::file> pFile = make_shared <windowsFile>
(m_path / vmime::utility::file::path::component(m_findData.cFileName));
findNext();
@@ -430,7 +430,7 @@ windowsFileReader::windowsFileReader(const vmime::utility::file::path& path, con
{
}
-ref <vmime::utility::inputStream> windowsFileReader::getInputStream()
+shared_ptr <vmime::utility::inputStream> windowsFileReader::getInputStream()
{
HANDLE hFile = CreateFile(
m_nativePath.c_str(),
@@ -442,7 +442,7 @@ ref <vmime::utility::inputStream> windowsFileReader::getInputStream()
NULL);
if (hFile == INVALID_HANDLE_VALUE)
windowsFileSystemFactory::reportError(m_path, GetLastError());
- return vmime::create <windowsFileReaderInputStream>(m_path, hFile);
+ return make_shared <windowsFileReaderInputStream>(m_path, hFile);
}
windowsFileReaderInputStream::windowsFileReaderInputStream(const vmime::utility::file::path& path, HANDLE hFile)
@@ -505,7 +505,7 @@ windowsFileWriter::windowsFileWriter(const vmime::utility::file::path& path, con
{
}
-ref <vmime::utility::outputStream> windowsFileWriter::getOutputStream()
+shared_ptr <vmime::utility::outputStream> windowsFileWriter::getOutputStream()
{
HANDLE hFile = CreateFile(
m_nativePath.c_str(),
@@ -517,7 +517,7 @@ ref <vmime::utility::outputStream> windowsFileWriter::getOutputStream()
NULL);
if (hFile == INVALID_HANDLE_VALUE)
windowsFileSystemFactory::reportError(m_path, GetLastError());
- return vmime::create <windowsFileWriterOutputStream>(m_path, hFile);
+ return make_shared <windowsFileWriterOutputStream>(m_path, hFile);
}
windowsFileWriterOutputStream::windowsFileWriterOutputStream(const vmime::utility::file::path& path, HANDLE hFile)
diff --git a/src/platforms/windows/windowsHandler.cpp b/src/platforms/windows/windowsHandler.cpp
index d4027801..5b9c37ce 100644
--- a/src/platforms/windows/windowsHandler.cpp
+++ b/src/platforms/windows/windowsHandler.cpp
@@ -57,10 +57,10 @@ windowsHandler::windowsHandler()
WSAStartup(MAKEWORD(1, 1), &wsaData);
#if VMIME_HAVE_MESSAGING_FEATURES
- m_socketFactory = vmime::create <windowsSocketFactory>();
+ m_socketFactory = make_shared <windowsSocketFactory>();
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES
- m_fileSysFactory = vmime::create <windowsFileSystemFactory>();
+ m_fileSysFactory = make_shared <windowsFileSystemFactory>();
#endif
}
@@ -274,7 +274,7 @@ unsigned int windowsHandler::getThreadId() const
#if VMIME_HAVE_MESSAGING_FEATURES
-ref <vmime::net::socketFactory> windowsHandler::getSocketFactory()
+shared_ptr <vmime::net::socketFactory> windowsHandler::getSocketFactory()
{
return m_socketFactory;
}
@@ -284,13 +284,13 @@ ref <vmime::net::socketFactory> windowsHandler::getSocketFactory()
#if VMIME_HAVE_FILESYSTEM_FEATURES
-ref <vmime::utility::fileSystemFactory> windowsHandler::getFileSystemFactory()
+shared_ptr <vmime::utility::fileSystemFactory> windowsHandler::getFileSystemFactory()
{
return m_fileSysFactory;
}
-ref <vmime::utility::childProcessFactory> windowsHandler::getChildProcessFactory()
+shared_ptr <vmime::utility::childProcessFactory> windowsHandler::getChildProcessFactory()
{
// TODO: Not implemented
return (NULL);
@@ -314,9 +314,9 @@ void windowsHandler::generateRandomBytes(unsigned char* buffer, const unsigned i
}
-ref <utility::sync::criticalSection> windowsHandler::createCriticalSection()
+shared_ptr <utility::sync::criticalSection> windowsHandler::createCriticalSection()
{
- return vmime::create <windowsCriticalSection>();
+ return make_shared <windowsCriticalSection>();
}
diff --git a/src/platforms/windows/windowsSocket.cpp b/src/platforms/windows/windowsSocket.cpp
index dc932965..502d1067 100644
--- a/src/platforms/windows/windowsSocket.cpp
+++ b/src/platforms/windows/windowsSocket.cpp
@@ -45,7 +45,7 @@ namespace windows {
// windowsSocket
//
-windowsSocket::windowsSocket(ref <vmime::net::timeoutHandler> th)
+windowsSocket::windowsSocket(shared_ptr <vmime::net::timeoutHandler> th)
: m_timeoutHandler(th), m_desc(INVALID_SOCKET), m_status(0)
{
WSAData wsaData;
@@ -438,15 +438,15 @@ void windowsSocket::waitForData(const WaitOpType t, bool& timedOut)
// posixSocketFactory
//
-ref <vmime::net::socket> windowsSocketFactory::create()
+shared_ptr <vmime::net::socket> windowsSocketFactory::create()
{
- ref <vmime::net::timeoutHandler> th = NULL;
- return vmime::create <windowsSocket>(th);
+ shared_ptr <vmime::net::timeoutHandler> th = NULL;
+ return make_shared <windowsSocket>(th);
}
-ref <vmime::net::socket> windowsSocketFactory::create(ref <vmime::net::timeoutHandler> th)
+shared_ptr <vmime::net::socket> windowsSocketFactory::create(shared_ptr <vmime::net::timeoutHandler> th)
{
- return vmime::create <windowsSocket>(th);
+ return make_shared <windowsSocket>(th);
}
} // posix
diff --git a/src/propertySet.cpp b/src/propertySet.cpp
index 284f3eaa..151c3e12 100644
--- a/src/propertySet.cpp
+++ b/src/propertySet.cpp
@@ -43,8 +43,8 @@ propertySet::propertySet(const string& props)
propertySet::propertySet(const propertySet& set)
: object()
{
- for (std::list <ref <property> >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it)
- m_props.push_back(vmime::create <property>(**it));
+ for (std::list <shared_ptr <property> >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it)
+ m_props.push_back(make_shared <property>(**it));
}
@@ -58,8 +58,8 @@ propertySet& propertySet::operator=(const propertySet& set)
{
removeAllProperties();
- for (std::list <ref <property> >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it)
- m_props.push_back(vmime::create <property>(**it));
+ for (std::list <shared_ptr <property> >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it)
+ m_props.push_back(make_shared <property>(**it));
return (*this);
}
@@ -79,7 +79,7 @@ void propertySet::removeAllProperties()
void propertySet::removeProperty(const string& name)
{
- std::list <ref <property> >::iterator it = std::find_if
+ std::list <shared_ptr <property> >::iterator it = std::find_if
(m_props.begin(), m_props.end(), propFinder(name));
if (it != m_props.end())
@@ -174,24 +174,24 @@ void propertySet::parse(const string& props)
}
}
- m_props.push_back(vmime::create <property>(option, value));
+ m_props.push_back(make_shared <property>(option, value));
}
}
}
-ref <propertySet::property> propertySet::find(const string& name) const
+shared_ptr <propertySet::property> propertySet::find(const string& name) const
{
- std::list <ref <property> >::const_iterator it = std::find_if
+ std::list <shared_ptr <property> >::const_iterator it = std::find_if
(m_props.begin(), m_props.end(), propFinder(name));
- return (it != m_props.end() ? *it : NULL);
+ return (it != m_props.end() ? *it : null);
}
-ref <propertySet::property> propertySet::findOrCreate(const string& name)
+shared_ptr <propertySet::property> propertySet::findOrCreate(const string& name)
{
- std::list <ref <property> >::const_iterator it = std::find_if
+ std::list <shared_ptr <property> >::const_iterator it = std::find_if
(m_props.begin(), m_props.end(), propFinder(name));
if (it != m_props.end())
@@ -200,7 +200,7 @@ ref <propertySet::property> propertySet::findOrCreate(const string& name)
}
else
{
- ref <property> prop = vmime::create <property>(name, "");
+ shared_ptr <property> prop = make_shared <property>(name, "");
m_props.push_back(prop);
return (prop);
}
@@ -225,9 +225,9 @@ bool propertySet::hasProperty(const string& name) const
}
-const std::vector <ref <const propertySet::property> > propertySet::getPropertyList() const
+const std::vector <shared_ptr <const propertySet::property> > propertySet::getPropertyList() const
{
- std::vector <ref <const property> > res;
+ std::vector <shared_ptr <const property> > res;
for (list_type::const_iterator it = m_props.begin() ; it != m_props.end() ; ++it)
res.push_back(*it);
@@ -236,9 +236,9 @@ const std::vector <ref <const propertySet::property> > propertySet::getPropertyL
}
-const std::vector <ref <propertySet::property> > propertySet::getPropertyList()
+const std::vector <shared_ptr <propertySet::property> > propertySet::getPropertyList()
{
- std::vector <ref <property> > res;
+ std::vector <shared_ptr <property> > res;
for (list_type::const_iterator it = m_props.begin() ; it != m_props.end() ; ++it)
res.push_back(*it);
diff --git a/src/relay.cpp b/src/relay.cpp
index 90957dbe..327118c5 100644
--- a/src/relay.cpp
+++ b/src/relay.cpp
@@ -254,9 +254,9 @@ relay& relay::operator=(const relay& other)
}
-ref <component> relay::clone() const
+shared_ptr <component> relay::clone() const
{
- return vmime::create <relay>(*this);
+ return make_shared <relay>(*this);
}
@@ -344,10 +344,10 @@ std::vector <string>& relay::getWithList()
}
-const std::vector <ref <component> > relay::getChildComponents()
+const std::vector <shared_ptr <component> > relay::getChildComponents()
{
// TODO: should fields inherit from 'component'? (using typeAdapter)
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/security/cert/certificateChain.cpp b/src/security/cert/certificateChain.cpp
index ab12453e..3cb4e360 100644
--- a/src/security/cert/certificateChain.cpp
+++ b/src/security/cert/certificateChain.cpp
@@ -29,7 +29,7 @@ namespace security {
namespace cert {
-certificateChain::certificateChain(const std::vector <ref <certificate> >& certs)
+certificateChain::certificateChain(const std::vector <shared_ptr <certificate> >& certs)
: m_certs(certs)
{
}
@@ -41,7 +41,7 @@ unsigned int certificateChain::getCount() const
}
-ref <certificate> certificateChain::getAt(const unsigned int index)
+shared_ptr <certificate> certificateChain::getAt(const unsigned int index)
{
return m_certs[index];
}
diff --git a/src/security/cert/defaultCertificateVerifier.cpp b/src/security/cert/defaultCertificateVerifier.cpp
index bb185f36..1a95b353 100644
--- a/src/security/cert/defaultCertificateVerifier.cpp
+++ b/src/security/cert/defaultCertificateVerifier.cpp
@@ -55,7 +55,7 @@ defaultCertificateVerifier::defaultCertificateVerifier(const defaultCertificateV
void defaultCertificateVerifier::verify
- (ref <certificateChain> chain, const string& hostname)
+ (shared_ptr <certificateChain> chain, const string& hostname)
{
if (chain->getCount() == 0)
return;
@@ -70,7 +70,7 @@ void defaultCertificateVerifier::verify
void defaultCertificateVerifier::verifyX509
- (ref <certificateChain> chain, const string& hostname)
+ (shared_ptr <certificateChain> chain, const string& hostname)
{
// For every certificate in the chain, verify that the certificate
// has been issued by the next certificate in the chain
@@ -78,11 +78,11 @@ void defaultCertificateVerifier::verifyX509
{
for (unsigned int i = 0 ; i < chain->getCount() - 1 ; ++i)
{
- ref <X509Certificate> cert =
- chain->getAt(i).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> cert =
+ dynamicCast <X509Certificate>(chain->getAt(i));
- ref <X509Certificate> next =
- chain->getAt(i + 1).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> next =
+ dynamicCast <X509Certificate>(chain->getAt(i + 1));
if (!cert->checkIssuer(next))
{
@@ -98,8 +98,8 @@ void defaultCertificateVerifier::verifyX509
for (unsigned int i = 0 ; i < chain->getCount() ; ++i)
{
- ref <X509Certificate> cert =
- chain->getAt(i).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> cert =
+ dynamicCast <X509Certificate>(chain->getAt(i));
const datetime begin = cert->getActivationDate();
const datetime end = cert->getExpirationDate();
@@ -115,14 +115,14 @@ void defaultCertificateVerifier::verifyX509
// -- First, verify that the the last certificate in the chain was
// -- issued by a third-party that we trust
- ref <X509Certificate> lastCert =
- chain->getAt(chain->getCount() - 1).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> lastCert =
+ dynamicCast <X509Certificate>(chain->getAt(chain->getCount() - 1));
bool trusted = false;
for (unsigned int i = 0 ; !trusted && i < m_x509RootCAs.size() ; ++i)
{
- ref <X509Certificate> rootCa = m_x509RootCAs[i];
+ shared_ptr <X509Certificate> rootCa = m_x509RootCAs[i];
if (lastCert->verify(rootCa))
trusted = true;
@@ -131,12 +131,12 @@ void defaultCertificateVerifier::verifyX509
// -- Next, if the issuer certificate cannot be verified against
// -- root CAs, compare the subject's certificate against the
// -- trusted certificates
- ref <X509Certificate> firstCert =
- chain->getAt(0).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> firstCert =
+ dynamicCast <X509Certificate>(chain->getAt(0));
for (unsigned int i = 0 ; !trusted && i < m_x509TrustedCerts.size() ; ++i)
{
- ref <X509Certificate> cert = m_x509TrustedCerts[i];
+ shared_ptr <X509Certificate> cert = m_x509TrustedCerts[i];
if (firstCert->equals(cert))
trusted = true;
@@ -158,14 +158,14 @@ void defaultCertificateVerifier::verifyX509
void defaultCertificateVerifier::setX509RootCAs
- (const std::vector <ref <X509Certificate> >& caCerts)
+ (const std::vector <shared_ptr <X509Certificate> >& caCerts)
{
m_x509RootCAs = caCerts;
}
void defaultCertificateVerifier::setX509TrustedCerts
- (const std::vector <ref <X509Certificate> >& trustedCerts)
+ (const std::vector <shared_ptr <X509Certificate> >& trustedCerts)
{
m_x509TrustedCerts = trustedCerts;
}
diff --git a/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp b/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp
index 96137844..327ddefa 100644
--- a/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp
+++ b/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp
@@ -89,7 +89,7 @@ void* X509Certificate_GnuTLS::getInternalData()
// static
-ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
+shared_ptr <X509Certificate> X509Certificate::import(utility::inputStream& is)
{
byteArray bytes;
utility::stream::value_type chunk[4096];
@@ -105,7 +105,7 @@ ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
// static
-ref <X509Certificate> X509Certificate::import
+shared_ptr <X509Certificate> X509Certificate::import
(const byte_t* data, const size_t length)
{
gnutls_datum buffer;
@@ -113,18 +113,18 @@ ref <X509Certificate> X509Certificate::import
buffer.size = static_cast <unsigned int>(length);
// Try DER format
- ref <X509Certificate_GnuTLS> derCert = vmime::create <X509Certificate_GnuTLS>();
+ shared_ptr <X509Certificate_GnuTLS> derCert = make_shared <X509Certificate_GnuTLS>();
if (gnutls_x509_crt_import(derCert->m_data->cert, &buffer, GNUTLS_X509_FMT_DER) >= 0)
return derCert;
// Try PEM format
- ref <X509Certificate_GnuTLS> pemCert = vmime::create <X509Certificate_GnuTLS>();
+ shared_ptr <X509Certificate_GnuTLS> pemCert = make_shared <X509Certificate_GnuTLS>();
if (gnutls_x509_crt_import(pemCert->m_data->cert, &buffer, GNUTLS_X509_FMT_PEM) >= 0)
return pemCert;
- return NULL;
+ return null;
}
@@ -161,20 +161,20 @@ const byteArray X509Certificate_GnuTLS::getSerialNumber() const
}
-bool X509Certificate_GnuTLS::checkIssuer(ref <const X509Certificate> issuer_) const
+bool X509Certificate_GnuTLS::checkIssuer(shared_ptr <const X509Certificate> issuer_) const
{
- ref <const X509Certificate_GnuTLS> issuer =
- issuer_.dynamicCast <const X509Certificate_GnuTLS>();
+ shared_ptr <const X509Certificate_GnuTLS> issuer =
+ dynamicCast <const X509Certificate_GnuTLS>(issuer_);
return (gnutls_x509_crt_check_issuer
(m_data->cert, issuer->m_data->cert) >= 1);
}
-bool X509Certificate_GnuTLS::verify(ref <const X509Certificate> caCert_) const
+bool X509Certificate_GnuTLS::verify(shared_ptr <const X509Certificate> caCert_) const
{
- ref <const X509Certificate_GnuTLS> caCert =
- caCert_.dynamicCast <const X509Certificate_GnuTLS>();
+ shared_ptr <const X509Certificate_GnuTLS> caCert =
+ dynamicCast <const X509Certificate_GnuTLS>(caCert_);
unsigned int verify = 0;
@@ -267,10 +267,10 @@ int X509Certificate_GnuTLS::getVersion() const
}
-bool X509Certificate_GnuTLS::equals(ref <const certificate> other) const
+bool X509Certificate_GnuTLS::equals(shared_ptr <const certificate> other) const
{
- ref <const X509Certificate_GnuTLS> otherX509 =
- other.dynamicCast <const X509Certificate_GnuTLS>();
+ shared_ptr <const X509Certificate_GnuTLS> otherX509 =
+ dynamicCast <const X509Certificate_GnuTLS>(other);
if (!otherX509)
return false;
diff --git a/src/security/cert/openssl/X509Certificate_OpenSSL.cpp b/src/security/cert/openssl/X509Certificate_OpenSSL.cpp
index 8c18583b..8c7174a0 100644
--- a/src/security/cert/openssl/X509Certificate_OpenSSL.cpp
+++ b/src/security/cert/openssl/X509Certificate_OpenSSL.cpp
@@ -158,17 +158,17 @@ void* X509Certificate_OpenSSL::getInternalData()
// static
-ref <X509Certificate> X509Certificate_OpenSSL::importInternal(X509* cert)
+shared_ptr <X509Certificate> X509Certificate_OpenSSL::importInternal(X509* cert)
{
if (cert)
- return vmime::create <X509Certificate_OpenSSL>(reinterpret_cast <X509 *>(cert));
+ return make_shared <X509Certificate_OpenSSL>(reinterpret_cast <X509 *>(cert));
- return NULL;
+ return null;
}
// static
-ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
+shared_ptr <X509Certificate> X509Certificate::import(utility::inputStream& is)
{
byteArray bytes;
utility::stream::value_type chunk[4096];
@@ -184,17 +184,17 @@ ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
// static
-ref <X509Certificate> X509Certificate::import
+shared_ptr <X509Certificate> X509Certificate::import
(const byte_t* data, const size_t length)
{
- ref <X509Certificate_OpenSSL> cert = vmime::create <X509Certificate_OpenSSL>();
+ shared_ptr <X509Certificate_OpenSSL> cert = make_shared <X509Certificate_OpenSSL>();
BIO* membio = BIO_new_mem_buf(const_cast <byte_t*>(data), length);
if (!PEM_read_bio_X509(membio, &(cert->m_data->cert), 0, 0))
{
BIO_vfree(membio);
- return NULL;
+ return null;
}
BIO_vfree(membio);
@@ -270,10 +270,10 @@ const byteArray X509Certificate_OpenSSL::getSerialNumber() const
}
-bool X509Certificate_OpenSSL::checkIssuer(ref <const X509Certificate> cert_) const
+bool X509Certificate_OpenSSL::checkIssuer(shared_ptr <const X509Certificate> cert_) const
{
- ref <const X509Certificate_OpenSSL> cert =
- cert_.dynamicCast <const X509Certificate_OpenSSL>();
+ shared_ptr <const X509Certificate_OpenSSL> cert =
+ dynamicCast <const X509Certificate_OpenSSL>(cert_);
// Get issuer for this cert
BIO *out;
@@ -297,10 +297,10 @@ bool X509Certificate_OpenSSL::checkIssuer(ref <const X509Certificate> cert_) con
}
-bool X509Certificate_OpenSSL::verify(ref <const X509Certificate> caCert_) const
+bool X509Certificate_OpenSSL::verify(shared_ptr <const X509Certificate> caCert_) const
{
- ref <const X509Certificate_OpenSSL> caCert =
- caCert_.dynamicCast <const X509Certificate_OpenSSL>();
+ shared_ptr <const X509Certificate_OpenSSL> caCert =
+ dynamicCast <const X509Certificate_OpenSSL>(caCert_);
bool verified = false;
@@ -550,10 +550,10 @@ int X509Certificate_OpenSSL::getVersion() const
}
-bool X509Certificate_OpenSSL::equals(ref <const certificate> other) const
+bool X509Certificate_OpenSSL::equals(shared_ptr <const certificate> other) const
{
- ref <const X509Certificate_OpenSSL> otherX509 =
- other.dynamicCast <const X509Certificate_OpenSSL>();
+ shared_ptr <const X509Certificate_OpenSSL> otherX509 =
+ dynamicCast <const X509Certificate_OpenSSL>(other);
if (!otherX509)
return false;
diff --git a/src/security/defaultAuthenticator.cpp b/src/security/defaultAuthenticator.cpp
index a2ff37f9..790196d2 100644
--- a/src/security/defaultAuthenticator.cpp
+++ b/src/security/defaultAuthenticator.cpp
@@ -50,7 +50,7 @@ defaultAuthenticator::~defaultAuthenticator()
const string defaultAuthenticator::getUsername() const
{
- ref <const net::service> service = m_service.acquire();
+ shared_ptr <const net::service> service = m_service.lock();
const string prefix = service->getInfos().getPropertyPrefix();
const propertySet& props = service->getSession()->getProperties();
@@ -64,7 +64,7 @@ const string defaultAuthenticator::getUsername() const
const string defaultAuthenticator::getPassword() const
{
- ref <const net::service> service = m_service.acquire();
+ shared_ptr <const net::service> service = m_service.lock();
const string prefix = service->getInfos().getPropertyPrefix();
const propertySet& props = service->getSession()->getProperties();
@@ -95,13 +95,13 @@ const string defaultAuthenticator::getServiceName() const
}
-void defaultAuthenticator::setService(ref <net::service> serv)
+void defaultAuthenticator::setService(shared_ptr <net::service> serv)
{
m_service = serv;
}
-weak_ref <net::service> defaultAuthenticator::getService() const
+weak_ptr <net::service> defaultAuthenticator::getService() const
{
return m_service;
}
diff --git a/src/security/digest/messageDigestFactory.cpp b/src/security/digest/messageDigestFactory.cpp
index 6d424155..2831c5a1 100644
--- a/src/security/digest/messageDigestFactory.cpp
+++ b/src/security/digest/messageDigestFactory.cpp
@@ -52,7 +52,7 @@ messageDigestFactory* messageDigestFactory::getInstance()
}
-ref <messageDigest> messageDigestFactory::create(const string& name)
+shared_ptr <messageDigest> messageDigestFactory::create(const string& name)
{
const MapType::const_iterator it = m_algos.find
(utility::stringUtils::toLower(name));
diff --git a/src/security/sasl/SASLContext.cpp b/src/security/sasl/SASLContext.cpp
index 7b24f1e3..c4d60bd9 100644
--- a/src/security/sasl/SASLContext.cpp
+++ b/src/security/sasl/SASLContext.cpp
@@ -62,27 +62,27 @@ SASLContext::~SASLContext()
}
-ref <SASLSession> SASLContext::createSession
+shared_ptr <SASLSession> SASLContext::createSession
(const string& serviceName,
- ref <authenticator> auth, ref <SASLMechanism> mech)
+ shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech)
{
- return vmime::create <SASLSession>
- (serviceName, thisRef().dynamicCast <SASLContext>(), auth, mech);
+ return make_shared <SASLSession>
+ (serviceName, dynamicCast <SASLContext>(shared_from_this()), auth, mech);
}
-ref <SASLMechanism> SASLContext::createMechanism(const string& name)
+shared_ptr <SASLMechanism> SASLContext::createMechanism(const string& name)
{
return SASLMechanismFactory::getInstance()->create
- (thisRef().dynamicCast <SASLContext>(), name);
+ (dynamicCast <SASLContext>(shared_from_this()), name);
}
-ref <SASLMechanism> SASLContext::suggestMechanism
- (const std::vector <ref <SASLMechanism> >& mechs)
+shared_ptr <SASLMechanism> SASLContext::suggestMechanism
+ (const std::vector <shared_ptr <SASLMechanism> >& mechs)
{
if (mechs.empty())
- return 0;
+ return null;
std::ostringstream oss;
@@ -102,7 +102,7 @@ ref <SASLMechanism> SASLContext::suggestMechanism
}
}
- return 0;
+ return null;
}
@@ -113,7 +113,7 @@ void SASLContext::decodeB64(const string& input, byte_t** output, long* outputLe
utility::inputStreamStringAdapter is(input);
utility::outputStreamStringAdapter os(res);
- ref <utility::encoder::encoder> dec =
+ shared_ptr <utility::encoder::encoder> dec =
utility::encoder::encoderFactory::getInstance()->create("base64");
dec->decode(is, os);
@@ -134,7 +134,7 @@ const string SASLContext::encodeB64(const byte_t* input, const long inputLen)
utility::inputStreamByteBufferAdapter is(input, inputLen);
utility::outputStreamStringAdapter os(res);
- ref <utility::encoder::encoder> enc =
+ shared_ptr <utility::encoder::encoder> enc =
utility::encoder::encoderFactory::getInstance()->create("base64");
enc->encode(is, os);
diff --git a/src/security/sasl/SASLMechanismFactory.cpp b/src/security/sasl/SASLMechanismFactory.cpp
index 0f2dd3af..255a13f1 100644
--- a/src/security/sasl/SASLMechanismFactory.cpp
+++ b/src/security/sasl/SASLMechanismFactory.cpp
@@ -68,15 +68,15 @@ SASLMechanismFactory* SASLMechanismFactory::getInstance()
}
-ref <SASLMechanism> SASLMechanismFactory::create
- (ref <SASLContext> ctx, const string& name_)
+shared_ptr <SASLMechanism> SASLMechanismFactory::create
+ (shared_ptr <SASLContext> ctx, const string& name_)
{
const string name(utility::stringUtils::toUpper(name_));
// Check for built-in mechanisms
if (isMechanismSupported(name))
{
- return vmime::create <builtinSASLMechanism>(ctx, name);
+ return make_shared <builtinSASLMechanism>(ctx, name);
}
// Check for registered mechanisms
else
@@ -88,7 +88,7 @@ ref <SASLMechanism> SASLMechanismFactory::create
}
throw exceptions::no_such_mechanism(name);
- return 0;
+ return null;
}
diff --git a/src/security/sasl/SASLSession.cpp b/src/security/sasl/SASLSession.cpp
index c34bdd7f..1bdd0889 100644
--- a/src/security/sasl/SASLSession.cpp
+++ b/src/security/sasl/SASLSession.cpp
@@ -43,8 +43,8 @@ namespace security {
namespace sasl {
-SASLSession::SASLSession(const string& serviceName, ref <SASLContext> ctx,
- ref <authenticator> auth, ref <SASLMechanism> mech)
+SASLSession::SASLSession(const string& serviceName, shared_ptr <SASLContext> ctx,
+ shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech)
: m_serviceName(serviceName), m_context(ctx), m_auth(auth),
m_mech(mech), m_gsaslContext(0), m_gsaslSession(0)
{
@@ -61,38 +61,38 @@ SASLSession::SASLSession(const string& serviceName, ref <SASLContext> ctx,
SASLSession::~SASLSession()
{
gsasl_finish(m_gsaslSession);
- m_gsaslSession = 0;
+ m_gsaslSession = NULL;
gsasl_done(m_gsaslContext);
- m_gsaslContext = 0;
+ m_gsaslContext = NULL;
}
void SASLSession::init()
{
- ref <SASLAuthenticator> saslAuth = m_auth.dynamicCast <SASLAuthenticator>();
+ shared_ptr <SASLAuthenticator> saslAuth = dynamicCast <SASLAuthenticator>(m_auth);
if (saslAuth)
{
saslAuth->setSASLMechanism(m_mech);
- saslAuth->setSASLSession(thisRef().dynamicCast <SASLSession>());
+ saslAuth->setSASLSession(dynamicCast <SASLSession>(shared_from_this()));
}
}
-ref <authenticator> SASLSession::getAuthenticator()
+shared_ptr <authenticator> SASLSession::getAuthenticator()
{
return m_auth;
}
-ref <SASLMechanism> SASLSession::getMechanism()
+shared_ptr <SASLMechanism> SASLSession::getMechanism()
{
return m_mech;
}
-ref <SASLContext> SASLSession::getContext()
+shared_ptr <SASLContext> SASLSession::getContext()
{
return m_context;
}
@@ -102,14 +102,14 @@ bool SASLSession::evaluateChallenge
(const byte_t* challenge, const long challengeLen,
byte_t** response, long* responseLen)
{
- return m_mech->step(thisRef().dynamicCast <SASLSession>(),
+ return m_mech->step(dynamicCast <SASLSession>(shared_from_this()),
challenge, challengeLen, response, responseLen);
}
-ref <net::socket> SASLSession::getSecuredSocket(ref <net::socket> sok)
+shared_ptr <net::socket> SASLSession::getSecuredSocket(shared_ptr <net::socket> sok)
{
- return vmime::create <SASLSocket>(thisRef().dynamicCast <SASLSession>(), sok);
+ return make_shared <SASLSocket>(dynamicCast <SASLSession>(shared_from_this()), sok);
}
@@ -126,7 +126,7 @@ int SASLSession::gsaslCallback
SASLSession* sess = reinterpret_cast <SASLSession*>(gsasl_callback_hook_get(ctx));
if (!sess) return GSASL_AUTHENTICATION_ERROR;
- ref <authenticator> auth = sess->getAuthenticator();
+ shared_ptr <authenticator> auth = sess->getAuthenticator();
try
{
diff --git a/src/security/sasl/SASLSocket.cpp b/src/security/sasl/SASLSocket.cpp
index b6b1d272..37e297dc 100644
--- a/src/security/sasl/SASLSocket.cpp
+++ b/src/security/sasl/SASLSocket.cpp
@@ -43,7 +43,7 @@ namespace sasl {
-SASLSocket::SASLSocket(ref <SASLSession> sess, ref <net::socket> wrapped)
+SASLSocket::SASLSocket(shared_ptr <SASLSession> sess, shared_ptr <net::socket> wrapped)
: m_session(sess), m_wrapped(wrapped),
m_pendingBuffer(0), m_pendingPos(0), m_pendingLen(0)
{
diff --git a/src/security/sasl/builtinSASLMechanism.cpp b/src/security/sasl/builtinSASLMechanism.cpp
index 86b429bf..e7bd723e 100644
--- a/src/security/sasl/builtinSASLMechanism.cpp
+++ b/src/security/sasl/builtinSASLMechanism.cpp
@@ -45,7 +45,7 @@ namespace security {
namespace sasl {
-builtinSASLMechanism::builtinSASLMechanism(ref <SASLContext> ctx, const string& name)
+builtinSASLMechanism::builtinSASLMechanism(shared_ptr <SASLContext> ctx, const string& name)
: m_context(ctx), m_name(name), m_complete(false)
{
}
@@ -63,7 +63,7 @@ const string builtinSASLMechanism::getName() const
bool builtinSASLMechanism::step
- (ref <SASLSession> sess, const byte_t* challenge, const long challengeLen,
+ (shared_ptr <SASLSession> sess, const byte_t* challenge, const long challengeLen,
byte_t** response, long* responseLen)
{
char* output = 0;
@@ -121,7 +121,7 @@ bool builtinSASLMechanism::isComplete() const
void builtinSASLMechanism::encode
- (ref <SASLSession> sess, const byte_t* input, const long inputLen,
+ (shared_ptr <SASLSession> sess, const byte_t* input, const long inputLen,
byte_t** output, long* outputLen)
{
char* coutput = 0;
@@ -154,7 +154,7 @@ void builtinSASLMechanism::encode
void builtinSASLMechanism::decode
- (ref <SASLSession> sess, const byte_t* input, const long inputLen,
+ (shared_ptr <SASLSession> sess, const byte_t* input, const long inputLen,
byte_t** output, long* outputLen)
{
char* coutput = 0;
diff --git a/src/security/sasl/defaultSASLAuthenticator.cpp b/src/security/sasl/defaultSASLAuthenticator.cpp
index bb72e56f..7fe9b3eb 100644
--- a/src/security/sasl/defaultSASLAuthenticator.cpp
+++ b/src/security/sasl/defaultSASLAuthenticator.cpp
@@ -51,14 +51,14 @@ defaultSASLAuthenticator::~defaultSASLAuthenticator()
}
-const std::vector <ref <SASLMechanism> >
+const std::vector <shared_ptr <SASLMechanism> >
defaultSASLAuthenticator::getAcceptableMechanisms
- (const std::vector <ref <SASLMechanism> >& available,
- ref <SASLMechanism> suggested) const
+ (const std::vector <shared_ptr <SASLMechanism> >& available,
+ shared_ptr <SASLMechanism> suggested) const
{
if (suggested)
{
- std::vector <ref <SASLMechanism> > res;
+ std::vector <shared_ptr <SASLMechanism> > res;
res.push_back(suggested);
@@ -103,42 +103,42 @@ const string defaultSASLAuthenticator::getAnonymousToken() const
const string defaultSASLAuthenticator::getServiceName() const
{
- return m_saslSession.acquire()->getServiceName();
+ return m_saslSession.lock()->getServiceName();
}
-void defaultSASLAuthenticator::setService(ref <net::service> serv)
+void defaultSASLAuthenticator::setService(shared_ptr <net::service> serv)
{
m_service = serv;
m_default.setService(serv);
}
-weak_ref <net::service> defaultSASLAuthenticator::getService() const
+weak_ptr <net::service> defaultSASLAuthenticator::getService() const
{
return m_service;
}
-void defaultSASLAuthenticator::setSASLSession(ref <SASLSession> sess)
+void defaultSASLAuthenticator::setSASLSession(shared_ptr <SASLSession> sess)
{
m_saslSession = sess;
}
-ref <SASLSession> defaultSASLAuthenticator::getSASLSession() const
+shared_ptr <SASLSession> defaultSASLAuthenticator::getSASLSession() const
{
- return m_saslSession.acquire().constCast <SASLSession>();
+ return constCast <SASLSession>(m_saslSession.lock());
}
-void defaultSASLAuthenticator::setSASLMechanism(ref <SASLMechanism> mech)
+void defaultSASLAuthenticator::setSASLMechanism(shared_ptr <SASLMechanism> mech)
{
m_saslMech = mech;
}
-ref <SASLMechanism> defaultSASLAuthenticator::getSASLMechanism() const
+shared_ptr <SASLMechanism> defaultSASLAuthenticator::getSASLMechanism() const
{
return m_saslMech;
}
diff --git a/src/streamContentHandler.cpp b/src/streamContentHandler.cpp
index d6444833..b84fdae5 100644
--- a/src/streamContentHandler.cpp
+++ b/src/streamContentHandler.cpp
@@ -34,12 +34,12 @@ namespace vmime
streamContentHandler::streamContentHandler()
- : m_encoding(NO_ENCODING), m_stream(null)
+ : m_encoding(NO_ENCODING), m_stream(null), m_length(0)
{
}
-streamContentHandler::streamContentHandler(ref <utility::inputStream> is,
+streamContentHandler::streamContentHandler(shared_ptr <utility::inputStream> is,
const utility::stream::size_type length, const vmime::encoding& enc)
{
setData(is, length, enc);
@@ -58,9 +58,9 @@ streamContentHandler::streamContentHandler(const streamContentHandler& cts)
}
-ref <contentHandler> streamContentHandler::clone() const
+shared_ptr <contentHandler> streamContentHandler::clone() const
{
- return vmime::create <streamContentHandler>(*this);
+ return make_shared <streamContentHandler>(*this);
}
@@ -76,7 +76,7 @@ streamContentHandler& streamContentHandler::operator=(const streamContentHandler
}
-void streamContentHandler::setData(ref <utility::inputStream> is,
+void streamContentHandler::setData(shared_ptr <utility::inputStream> is,
const utility::stream::size_type length, const vmime::encoding& enc)
{
m_encoding = enc;
@@ -100,8 +100,8 @@ void streamContentHandler::generate(utility::outputStream& os, const vmime::enco
// buffer, and then re-encode to output stream...
if (m_encoding != enc)
{
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
- ref <utility::encoder::encoder> theEncoder = enc.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder();
theEncoder->getProperties()["maxlinelength"] = maxLineLength;
theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT);
@@ -129,7 +129,7 @@ void streamContentHandler::generate(utility::outputStream& os, const vmime::enco
// Need to encode data before
else
{
- 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);
@@ -159,7 +159,7 @@ void streamContentHandler::extract(utility::outputStream& os,
// Need to decode data
else
{
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
m_stream->reset(); // may not work...
@@ -211,7 +211,7 @@ const vmime::encoding& streamContentHandler::getEncoding() const
bool streamContentHandler::isBuffered() const
{
- if (m_stream.dynamicCast <utility::seekableInputStream>() != NULL)
+ if (dynamicCast <utility::seekableInputStream>(m_stream) != NULL)
return true;
// FIXME: some streams can be resetted
diff --git a/src/stringContentHandler.cpp b/src/stringContentHandler.cpp
index e4762dce..0fb032dd 100644
--- a/src/stringContentHandler.cpp
+++ b/src/stringContentHandler.cpp
@@ -68,9 +68,9 @@ stringContentHandler::~stringContentHandler()
}
-ref <contentHandler> stringContentHandler::clone() const
+shared_ptr <contentHandler> stringContentHandler::clone() const
{
- return vmime::create <stringContentHandler>(*this);
+ return make_shared <stringContentHandler>(*this);
}
@@ -125,8 +125,8 @@ void stringContentHandler::generate(utility::outputStream& os,
// buffer, and then re-encode to output stream...
if (m_encoding != enc)
{
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
- ref <utility::encoder::encoder> theEncoder = enc.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder();
theEncoder->getProperties()["maxlinelength"] = maxLineLength;
theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT);
@@ -152,7 +152,7 @@ void stringContentHandler::generate(utility::outputStream& os,
// Need to encode data before
else
{
- 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);
@@ -174,7 +174,7 @@ void stringContentHandler::extract(utility::outputStream& os,
// Need to decode data
else
{
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
utility::inputStreamStringProxyAdapter in(m_string);
utility::progressListenerSizeAdapter plsa(progress, getLength());
diff --git a/src/text.cpp b/src/text.cpp
index 05353b08..987510c1 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -57,7 +57,7 @@ text::text(const string& t)
text::text(const word& w)
{
- appendWord(vmime::create <word>(w));
+ appendWord(make_shared <word>(w));
}
@@ -75,7 +75,7 @@ void text::parseImpl
string::size_type newPos;
- const std::vector <ref <word> > words = word::parseMultiple(ctx, buffer, position, end, &newPos);
+ const std::vector <shared_ptr <word> > words = word::parseMultiple(ctx, buffer, position, end, &newPos);
copy_vector(words, m_words);
@@ -100,8 +100,8 @@ void text::copyFrom(const component& other)
removeAllWords();
- for (std::vector <ref <word> >::const_iterator i = t.m_words.begin() ; i != t.m_words.end() ; ++i)
- m_words.push_back(vmime::create <word>(**i));
+ for (std::vector <shared_ptr <word> >::const_iterator i = t.m_words.begin() ; i != t.m_words.end() ; ++i)
+ m_words.push_back(make_shared <word>(**i));
}
@@ -125,8 +125,8 @@ bool text::operator==(const text& t) const
{
bool equal = true;
- std::vector <ref <word> >::const_iterator i = m_words.begin();
- std::vector <ref <word> >::const_iterator j = t.m_words.begin();
+ std::vector <shared_ptr <word> >::const_iterator i = m_words.begin();
+ std::vector <shared_ptr <word> >::const_iterator j = t.m_words.begin();
for ( ; equal && i != m_words.end() ; ++i, ++j)
equal = (**i == **j);
@@ -148,26 +148,26 @@ const string text::getConvertedText(const charset& dest, const charsetConverterO
{
string out;
- for (std::vector <ref <word> >::const_iterator i = m_words.begin() ; i != m_words.end() ; ++i)
+ for (std::vector <shared_ptr <word> >::const_iterator i = m_words.begin() ; i != m_words.end() ; ++i)
out += (*i)->getConvertedText(dest, opts);
return (out);
}
-void text::appendWord(ref <word> w)
+void text::appendWord(shared_ptr <word> w)
{
m_words.push_back(w);
}
-void text::insertWordBefore(const size_t pos, ref <word> w)
+void text::insertWordBefore(const size_t pos, shared_ptr <word> w)
{
m_words.insert(m_words.begin() + pos, w);
}
-void text::insertWordAfter(const size_t pos, ref <word> w)
+void text::insertWordAfter(const size_t pos, shared_ptr <word> w)
{
m_words.insert(m_words.begin() + pos + 1, w);
}
@@ -175,7 +175,7 @@ void text::insertWordAfter(const size_t pos, ref <word> w)
void text::removeWord(const size_t pos)
{
- const std::vector <ref <word> >::iterator it = m_words.begin() + pos;
+ const std::vector <shared_ptr <word> >::iterator it = m_words.begin() + pos;
m_words.erase(it);
}
@@ -199,25 +199,25 @@ bool text::isEmpty() const
}
-const ref <word> text::getWordAt(const size_t pos)
+const shared_ptr <word> text::getWordAt(const size_t pos)
{
return (m_words[pos]);
}
-const ref <const word> text::getWordAt(const size_t pos) const
+const shared_ptr <const word> text::getWordAt(const size_t pos) const
{
return (m_words[pos]);
}
-const std::vector <ref <const word> > text::getWordList() const
+const std::vector <shared_ptr <const word> > text::getWordList() const
{
- std::vector <ref <const word> > list;
+ std::vector <shared_ptr <const word> > list;
list.reserve(m_words.size());
- for (std::vector <ref <word> >::const_iterator it = m_words.begin() ;
+ for (std::vector <shared_ptr <word> >::const_iterator it = m_words.begin() ;
it != m_words.end() ; ++it)
{
list.push_back(*it);
@@ -227,21 +227,21 @@ const std::vector <ref <const word> > text::getWordList() const
}
-const std::vector <ref <word> > text::getWordList()
+const std::vector <shared_ptr <word> > text::getWordList()
{
return (m_words);
}
-ref <component> text::clone() const
+shared_ptr <component> text::clone() const
{
- return vmime::create <text>(*this);
+ return make_shared <text>(*this);
}
-ref <text> text::newFromString(const string& in, const charset& ch)
+shared_ptr <text> text::newFromString(const string& in, const charset& ch)
{
- ref <text> t = vmime::create <text>();
+ shared_ptr <text> t = make_shared <text>();
t->createFromString(in, ch);
@@ -272,7 +272,7 @@ void text::createFromString(const string& in, const charset& ch)
// If there are "too much" non-ASCII chars, encode everything
if (alwaysEncode || asciiPercent < 60) // less than 60% ASCII chars
{
- appendWord(vmime::create <word>(in, ch));
+ appendWord(make_shared <word>(in, ch));
}
// Else, only encode words which need it
else
@@ -296,18 +296,18 @@ void text::createFromString(const string& in, const charset& ch)
{
// No need to create a new encoded word, just append
// the current word to the previous one.
- ref <word> w = getWordAt(getWordCount() - 1);
+ shared_ptr <word> w = getWordAt(getWordCount() - 1);
w->getBuffer() += " " + chunk;
}
else
{
if (count)
{
- ref <word> w = getWordAt(getWordCount() - 1);
+ shared_ptr <word> w = getWordAt(getWordCount() - 1);
w->getBuffer() += ' ';
}
- appendWord(vmime::create <word>(chunk, ch));
+ appendWord(make_shared <word>(chunk, ch));
prevIs8bit = true;
++count;
@@ -317,12 +317,12 @@ void text::createFromString(const string& in, const charset& ch)
{
if (count && !prevIs8bit)
{
- ref <word> w = getWordAt(getWordCount() - 1);
+ shared_ptr <word> w = getWordAt(getWordCount() - 1);
w->getBuffer() += " " + chunk;
}
else
{
- appendWord(vmime::create <word>
+ appendWord(make_shared <word>
(chunk, charset(charsets::US_ASCII)));
prevIs8bit = false;
@@ -368,9 +368,9 @@ void text::encodeAndFold
}
-ref <text> text::decodeAndUnfold(const string& in)
+shared_ptr <text> text::decodeAndUnfold(const string& in)
{
- ref <text> t = vmime::create <text>();
+ shared_ptr <text> t = make_shared <text>();
decodeAndUnfold(parsingContext::getDefaultContext(), in, t.get());
@@ -378,9 +378,9 @@ ref <text> text::decodeAndUnfold(const string& in)
}
-ref <text> text::decodeAndUnfold(const parsingContext& ctx, const string& in)
+shared_ptr <text> text::decodeAndUnfold(const parsingContext& ctx, const string& in)
{
- ref <text> t = vmime::create <text>();
+ shared_ptr <text> t = make_shared <text>();
decodeAndUnfold(ctx, in, t.get());
@@ -400,7 +400,7 @@ text* text::decodeAndUnfold(const parsingContext& ctx, const string& in, text* g
out->removeAllWords();
- const std::vector <ref <word> > words = word::parseMultiple(ctx, in, 0, in.length(), NULL);
+ const std::vector <shared_ptr <word> > words = word::parseMultiple(ctx, in, 0, in.length(), NULL);
copy_vector(words, out->m_words);
@@ -408,9 +408,9 @@ text* text::decodeAndUnfold(const parsingContext& ctx, const string& in, text* g
}
-const std::vector <ref <component> > text::getChildComponents()
+const std::vector <shared_ptr <component> > text::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
copy_vector(m_words, list);
@@ -422,7 +422,7 @@ const string text::getWholeBuffer() const
{
string res;
- for (std::vector <ref <word> >::const_iterator it = m_words.begin() ;
+ for (std::vector <shared_ptr <word> >::const_iterator it = m_words.begin() ;
it != m_words.end() ; ++it)
{
res += (*it)->getBuffer();
diff --git a/src/textPartFactory.cpp b/src/textPartFactory.cpp
index baad6292..85fea6e4 100644
--- a/src/textPartFactory.cpp
+++ b/src/textPartFactory.cpp
@@ -53,7 +53,7 @@ textPartFactory* textPartFactory::getInstance()
}
-ref <textPart> textPartFactory::create(const mediaType& type)
+shared_ptr <textPart> textPartFactory::create(const mediaType& type)
{
for (MapType::const_iterator it = m_map.begin() ;
it != m_map.end() ; ++it)
diff --git a/src/utility/encoder/encoderFactory.cpp b/src/utility/encoder/encoderFactory.cpp
index 02800b4c..098a810a 100644
--- a/src/utility/encoder/encoderFactory.cpp
+++ b/src/utility/encoder/encoderFactory.cpp
@@ -61,24 +61,24 @@ encoderFactory::~encoderFactory()
}
-encoderFactory* encoderFactory::getInstance()
+shared_ptr <encoderFactory> encoderFactory::getInstance()
{
static encoderFactory instance;
- return (&instance);
+ return shared_ptr <encoderFactory>(&instance, noop_shared_ptr_deleter <encoderFactory>());
}
-ref <encoder> encoderFactory::create(const string& name)
+shared_ptr <encoder> encoderFactory::create(const string& name)
{
return (getEncoderByName(name)->create());
}
-const ref <const encoderFactory::registeredEncoder> encoderFactory::getEncoderByName(const string& name) const
+const shared_ptr <const encoderFactory::registeredEncoder> encoderFactory::getEncoderByName(const string& name) const
{
const string lcName(utility::stringUtils::toLower(name));
- for (std::vector <ref <registeredEncoder> >::const_iterator it = m_encoders.begin() ;
+ for (std::vector <shared_ptr <registeredEncoder> >::const_iterator it = m_encoders.begin() ;
it != m_encoders.end() ; ++it)
{
if ((*it)->getName() == lcName)
@@ -95,17 +95,17 @@ size_t encoderFactory::getEncoderCount() const
}
-const ref <const encoderFactory::registeredEncoder> encoderFactory::getEncoderAt(const size_t pos) const
+const shared_ptr <const encoderFactory::registeredEncoder> encoderFactory::getEncoderAt(const size_t pos) const
{
return (m_encoders[pos]);
}
-const std::vector <ref <const encoderFactory::registeredEncoder> > encoderFactory::getEncoderList() const
+const std::vector <shared_ptr <const encoderFactory::registeredEncoder> > encoderFactory::getEncoderList() const
{
- std::vector <ref <const registeredEncoder> > res;
+ std::vector <shared_ptr <const registeredEncoder> > res;
- for (std::vector <ref <registeredEncoder> >::const_iterator it = m_encoders.begin() ;
+ for (std::vector <shared_ptr <registeredEncoder> >::const_iterator it = m_encoders.begin() ;
it != m_encoders.end() ; ++it)
{
res.push_back(*it);
diff --git a/src/utility/parserInputStreamAdapter.cpp b/src/utility/parserInputStreamAdapter.cpp
index 0d6248cf..fd10a586 100644
--- a/src/utility/parserInputStreamAdapter.cpp
+++ b/src/utility/parserInputStreamAdapter.cpp
@@ -28,7 +28,7 @@ namespace vmime {
namespace utility {
-parserInputStreamAdapter::parserInputStreamAdapter(ref <seekableInputStream> stream)
+parserInputStreamAdapter::parserInputStreamAdapter(shared_ptr <seekableInputStream> stream)
: m_stream(stream)
{
}
@@ -53,7 +53,7 @@ stream::size_type parserInputStreamAdapter::read
}
-ref <seekableInputStream> parserInputStreamAdapter::getUnderlyingStream()
+shared_ptr <seekableInputStream> parserInputStreamAdapter::getUnderlyingStream()
{
return m_stream;
}
diff --git a/src/utility/seekableInputStreamRegionAdapter.cpp b/src/utility/seekableInputStreamRegionAdapter.cpp
index ec7c20cf..753d81a5 100644
--- a/src/utility/seekableInputStreamRegionAdapter.cpp
+++ b/src/utility/seekableInputStreamRegionAdapter.cpp
@@ -29,7 +29,7 @@ namespace utility {
seekableInputStreamRegionAdapter::seekableInputStreamRegionAdapter
- (ref <seekableInputStream> stream, const size_type begin, const size_type length)
+ (shared_ptr <seekableInputStream> stream, const size_type begin, const size_type length)
: m_stream(stream), m_begin(begin), m_length(length), m_position(0)
{
}
diff --git a/src/utility/smartPtr.cpp b/src/utility/smartPtr.cpp
deleted file mode 100644
index 78cf9032..00000000
--- a/src/utility/smartPtr.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 3 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// Linking this library statically or dynamically with other modules is making
-// a combined work based on this library. Thus, the terms and conditions of
-// the GNU General Public License cover the whole combination.
-//
-
-#include "vmime/object.hpp"
-#include "vmime/utility/smartPtr.hpp"
-
-
-namespace vmime {
-namespace utility {
-
-
-void refManager::deleteObjectImpl(object* obj)
-{
- obj->setRefManager(0);
- delete obj;
-}
-
-
-} // utility
-} // vmime
-
diff --git a/src/utility/smartPtrInt.cpp b/src/utility/smartPtrInt.cpp
deleted file mode 100644
index 2bb9d70d..00000000
--- a/src/utility/smartPtrInt.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-//
-// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 3 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// Linking this library statically or dynamically with other modules is making
-// a combined work based on this library. Thus, the terms and conditions of
-// the GNU General Public License cover the whole combination.
-//
-
-#include "vmime/utility/smartPtrInt.hpp"
-#include "vmime/object.hpp"
-
-
-namespace vmime {
-namespace utility {
-
-
-// static
-refManager* refManager::create(object* obj)
-{
- return new refManagerImpl(obj);
-}
-
-
-//
-// refManager
-//
-
-refManagerImpl::refManagerImpl(object* obj)
- : m_object(obj), m_strongCount(1), m_weakCount(1)
-{
-}
-
-
-refManagerImpl::~refManagerImpl()
-{
-}
-
-
-bool refManagerImpl::addStrong()
-{
- if (m_strongCount <= 0)
- return false;
-
- m_strongCount.increment();
- m_weakCount.increment();
-
- return true;
-}
-
-
-void refManagerImpl::releaseStrong()
-{
- if (m_strongCount.decrement() <= 0)
- deleteObject();
-
- releaseWeak();
-}
-
-
-void refManagerImpl::addWeak()
-{
- m_weakCount.increment();
-}
-
-
-void refManagerImpl::releaseWeak()
-{
- if (m_weakCount.decrement() <= 0)
- deleteManager();
-}
-
-
-object* refManagerImpl::getObject()
-{
- return m_object;
-}
-
-
-void refManagerImpl::deleteManager()
-{
- delete this;
-}
-
-
-void refManagerImpl::deleteObject()
-{
- try
- {
- deleteObjectImpl(m_object);
- }
- catch (...)
- {
- // Exception in destructor
- }
-
- m_object = 0;
-}
-
-
-long refManagerImpl::getStrongRefCount() const
-{
- return m_strongCount;
-}
-
-
-long refManagerImpl::getWeakRefCount() const
-{
- return m_weakCount;
-}
-
-
-
-//
-// refCounter
-//
-
-#ifdef _WIN32
-
-
-refCounter::refCounter(const long initialValue)
- : m_value(initialValue)
-{
-}
-
-
-refCounter::~refCounter()
-{
-}
-
-
-long refCounter::increment()
-{
- return InterlockedIncrement(&m_value);
-}
-
-
-long refCounter::decrement()
-{
- return InterlockedDecrement(&m_value);
-}
-
-
-refCounter::operator long() const
-{
- return m_value;
-}
-
-
-#elif defined(__GNUC__) && (defined(__GLIBCPP__) || defined(__GLIBCXX__))
-
-
-refCounter::refCounter(const long initialValue)
- : m_value(static_cast <int>(initialValue))
-{
-}
-
-
-refCounter::~refCounter()
-{
-}
-
-
-long refCounter::increment()
-{
-#if __GNUC_MINOR__ < 4 && __GNUC__ < 4
- return __exchange_and_add(&m_value, 1) + 1;
-#else
- return __gnu_cxx::__exchange_and_add(&m_value, 1) + 1;
-#endif
-}
-
-
-long refCounter::decrement()
-{
-#if __GNUC_MINOR__ < 4 && __GNUC__ < 4
- return __exchange_and_add(&m_value, -1) - 1;
-#else
- return __gnu_cxx::__exchange_and_add(&m_value, -1) - 1;
-#endif
-}
-
-
-refCounter::operator long() const
-{
-#if __GNUC_MINOR__ < 4 && __GNUC__ < 4
- return static_cast <long>(__exchange_and_add(&m_value, 0));
-#else
- return static_cast <long>(__gnu_cxx::__exchange_and_add(&m_value, 0));
-#endif
-}
-
-
-#elif defined(VMIME_HAVE_PTHREAD)
-
-
-refCounter::refCounter(const long initialValue)
- : m_value(initialValue)
-{
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
- pthread_mutex_init(&m_mutex, &attr);
- pthread_mutexattr_destroy(&attr);
-}
-
-
-refCounter::~refCounter()
-{
- pthread_mutex_destroy(&m_mutex);
-}
-
-
-long refCounter::increment()
-{
- long value;
-
- pthread_mutex_lock(&m_mutex);
- value = ++m_value;
- pthread_mutex_unlock(&m_mutex);
-
- return value;
-}
-
-
-long refCounter::decrement()
-{
- long value;
-
- pthread_mutex_lock(&m_mutex);
- value = --m_value;
- pthread_mutex_unlock(&m_mutex);
-
- return value;
-}
-
-
-refCounter::operator long() const
-{
- return m_value;
-}
-
-
-#else // not thread-safe implementation
-
-
-refCounter::refCounter(const long initialValue)
- : m_value(initialValue)
-{
-}
-
-
-refCounter::~refCounter()
-{
-}
-
-
-long refCounter::increment()
-{
- return ++m_value;
-}
-
-
-long refCounter::decrement()
-{
- return --m_value;
-}
-
-
-refCounter::operator long() const
-{
- return m_value;
-}
-
-
-#endif
-
-
-} // utility
-} // vmime
-
diff --git a/src/word.cpp b/src/word.cpp
index 8e254865..fc791b53 100644
--- a/src/word.cpp
+++ b/src/word.cpp
@@ -25,7 +25,6 @@
#include "vmime/text.hpp"
#include "vmime/utility/stringUtils.hpp"
-#include "vmime/utility/smartPtr.hpp"
#include "vmime/parserHelpers.hpp"
#include "vmime/utility/outputStreamStringAdapter.hpp"
@@ -66,7 +65,7 @@ word::word(const string& buffer, const charset& charset)
}
-ref <word> word::parseNext
+shared_ptr <word> word::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition,
bool prevIsEncoded, bool* isEncoded, bool isFirst)
@@ -128,7 +127,7 @@ ref <word> word::parseNext
if (prevIsEncoded && !isFirst)
unencoded = whiteSpaces + unencoded;
- ref <word> w = vmime::create <word>(unencoded, defaultCharset);
+ shared_ptr <word> w = make_shared <word>(unencoded, defaultCharset);
w->setParsedBounds(position, pos);
if (newPosition)
@@ -185,7 +184,7 @@ ref <word> word::parseNext
pos += 2; // ?=
- ref <word> w = vmime::create <word>();
+ shared_ptr <word> w = make_shared <word>();
w->parse(buffer, wordStart, pos, NULL);
if (newPosition)
@@ -211,7 +210,7 @@ ref <word> word::parseNext
// Treat unencoded text at the end of the buffer
if (!unencoded.empty())
{
- ref <word> w = vmime::create <word>(unencoded, defaultCharset);
+ shared_ptr <word> w = make_shared <word>(unencoded, defaultCharset);
w->setParsedBounds(position, end);
if (newPosition)
@@ -227,12 +226,12 @@ ref <word> word::parseNext
}
-const std::vector <ref <word> > word::parseMultiple
+const std::vector <shared_ptr <word> > word::parseMultiple
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
{
- std::vector <ref <word> > res;
- ref <word> w;
+ std::vector <shared_ptr <word> > res;
+ shared_ptr <word> w;
string::size_type pos = position;
@@ -743,9 +742,9 @@ const string word::getConvertedText(const charset& dest, const charsetConverterO
}
-ref <component> word::clone() const
+shared_ptr <component> word::clone() const
{
- return vmime::create <word>(m_buffer, m_charset);
+ return make_shared <word>(m_buffer, m_charset);
}
@@ -785,9 +784,9 @@ void word::setBuffer(const string& buffer)
}
-const std::vector <ref <component> > word::getChildComponents()
+const std::vector <shared_ptr <component> > word::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/wordEncoder.cpp b/src/wordEncoder.cpp
index 332f9bf2..b3e98fd2 100644
--- a/src/wordEncoder.cpp
+++ b/src/wordEncoder.cpp
@@ -68,11 +68,11 @@ wordEncoder::wordEncoder(const string& buffer, const charset& charset, const Enc
if (m_encoding == ENCODING_B64)
{
- m_encoder = vmime::create <utility::encoder::b64Encoder>();
+ m_encoder = make_shared <utility::encoder::b64Encoder>();
}
else // ENCODING_QP
{
- m_encoder = vmime::create <utility::encoder::qpEncoder>();
+ m_encoder = make_shared <utility::encoder::qpEncoder>();
m_encoder->getProperties()["rfc2047"] = true;
}
}
@@ -168,7 +168,7 @@ const string wordEncoder::getNextChunk(const string::size_type maxLength)
// Fully RFC-compliant encoding
else
{
- ref <charsetConverter> conv = charsetConverter::create(charsets::UTF_8, m_charset);
+ shared_ptr <charsetConverter> conv = charsetConverter::create(charsets::UTF_8, m_charset);
string::size_type inputCount = 0;
string::size_type outputCount = 0;