Clarified object construction where 'enabled_shared_from_this' is used. Use it only where it is needed.

This commit is contained in:
Vincent Richard 2016-04-05 22:11:47 +02:00
parent 4d76e8afbc
commit b1c2d4b61e
36 changed files with 144 additions and 115 deletions

View File

@ -68,7 +68,7 @@ services. Before using a messaging service, you must create and
initialize a session object:
\begin{lstlisting}
vmime::shared_ptr <net::session> theSession = vmime::make_shared <net::session>();
vmime::shared_ptr <vmime::net::session> theSession = vmime::net::session::create();
\end{lstlisting}
Session properties include:
@ -328,8 +328,7 @@ This is how to use it:
\begin{lstlisting}
// First, create a session
vmime::shared_ptr <vmime::net::session> sess =
vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create();
// Next, initialize a service which will use our authenticator
vmime::shared_ptr <vmime::net::store> st =
@ -417,8 +416,7 @@ const vmime::string msgData =
// Create a new session
vmime::utility::url url("smtp://example.com");
vmime::shared_ptr <vmime::net::session> sess =
vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create();
// Create an instance of the transport service
vmime::shared_ptr <vmime::net::transport> tr = sess->getTransport(url);
@ -471,8 +469,7 @@ store service:
// Create a new session
vmime::utility::url url("imap://vincent:password@imap:example.org");
vmime::shared_ptr <vmime::net::session> sess =
vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create();
// Create an instance of the transport service
vmime::shared_ptr <vmime::net::store> store = sess->getStore(url);

View File

@ -38,8 +38,7 @@
// Global session object
static vmime::shared_ptr <vmime::net::session> g_session
= vmime::make_shared <vmime::net::session>();
static vmime::shared_ptr <vmime::net::session> g_session = vmime::net::session::create();
/** Returns the messaging protocols supported by VMime.

View File

@ -47,7 +47,7 @@ namespace events {
/** Event occurring on folders or messages.
*/
class VMIME_EXPORT event : public object
class VMIME_EXPORT event : public object, public enable_shared_from_this <event>
{
public:

View File

@ -59,11 +59,11 @@ class store;
/** Abstract representation of a folder in a message store.
*/
class VMIME_EXPORT folder : public object
class VMIME_EXPORT folder : public object, public enable_shared_from_this <folder>
{
protected:
folder(const folder&) : object() { }
folder(const folder&) : object(), enable_shared_from_this <folder>() { }
folder() { }

View File

@ -48,7 +48,7 @@ class IMAPConnection;
/** An IMAP command that will be sent to the server.
*/
class VMIME_EXPORT IMAPCommand : public object
class VMIME_EXPORT IMAPCommand : public object, public enable_shared_from_this <IMAPCommand>
{
public:

View File

@ -325,7 +325,7 @@ void IMAPConnection::authenticateSASL()
std::vector <shared_ptr <security::sasl::SASLMechanism> > mechList;
shared_ptr <security::sasl::SASLContext> saslContext =
make_shared <security::sasl::SASLContext>();
security::sasl::SASLContext::create();
for (unsigned int i = 0 ; i < saslMechs.size() ; ++i)
{

View File

@ -52,7 +52,7 @@ class IMAPStore;
class IMAPCommand;
class VMIME_EXPORT IMAPConnection : public object
class VMIME_EXPORT IMAPConnection : public object, public enable_shared_from_this <IMAPConnection>
{
public:

View File

@ -652,7 +652,7 @@ shared_ptr <folder> IMAPFolder::getFolder(const folder::path::component& name)
if (!store)
throw exceptions::illegal_state("Store disconnected");
return make_shared <IMAPFolder>(m_path / name, store, shared_ptr <folderAttributes>());
return shared_ptr <IMAPFolder>(new IMAPFolder(m_path / name, store, shared_ptr <folderAttributes>()));
}
@ -734,7 +734,7 @@ std::vector <shared_ptr <folder> > IMAPFolder::getFolders(const bool recursive)
IMAPUtils::mailboxFlagsToFolderAttributes
(m_connection, mailbox_flag_list, *attribs);
v.push_back(make_shared <IMAPFolder>(path, store, attribs));
v.push_back(shared_ptr <IMAPFolder>(new IMAPFolder(path, store, attribs)));
}
}
@ -945,7 +945,9 @@ shared_ptr <folder> IMAPFolder::getParent()
if (m_path.isEmpty())
return null;
else
return make_shared <IMAPFolder>(m_path.getParent(), m_store.lock(), shared_ptr <folderAttributes>());
return shared_ptr <IMAPFolder>(
new IMAPFolder(m_path.getParent(), m_store.lock(), shared_ptr <folderAttributes>())
);
}

View File

@ -63,11 +63,10 @@ private:
friend class IMAPMessage;
IMAPFolder(const IMAPFolder&);
IMAPFolder(const folder::path& path, shared_ptr <IMAPStore> store, shared_ptr <folderAttributes> attribs);
public:
IMAPFolder(const folder::path& path, shared_ptr <IMAPStore> store, shared_ptr <folderAttributes> attribs);
~IMAPFolder();
int getMode() const;

View File

@ -75,10 +75,10 @@ shared_ptr <folder> IMAPStore::getRootFolder()
if (!isConnected())
throw exceptions::illegal_state("Not connected");
return make_shared <IMAPFolder>
(folder::path(),
dynamicCast <IMAPStore>(shared_from_this()),
shared_ptr <folderAttributes>());
return shared_ptr <IMAPFolder>
(new IMAPFolder(folder::path(),
dynamicCast <IMAPStore>(shared_from_this()),
shared_ptr <folderAttributes>()));
}
@ -87,10 +87,10 @@ shared_ptr <folder> IMAPStore::getDefaultFolder()
if (!isConnected())
throw exceptions::illegal_state("Not connected");
return make_shared <IMAPFolder>
(folder::path::component("INBOX"),
dynamicCast <IMAPStore>(shared_from_this()),
shared_ptr <folderAttributes>());
return shared_ptr <IMAPFolder>
(new IMAPFolder(folder::path::component("INBOX"),
dynamicCast <IMAPStore>(shared_from_this()),
shared_ptr <folderAttributes>()));
}
@ -99,10 +99,10 @@ shared_ptr <folder> IMAPStore::getFolder(const folder::path& path)
if (!isConnected())
throw exceptions::illegal_state("Not connected");
return make_shared <IMAPFolder>
(path,
dynamicCast <IMAPStore>(shared_from_this()),
shared_ptr <folderAttributes>());
return shared_ptr <IMAPFolder>
(new IMAPFolder(path,
dynamicCast <IMAPStore>(shared_from_this()),
shared_ptr <folderAttributes>()));
}

View File

@ -462,7 +462,7 @@ shared_ptr <folder> maildirFolder::getFolder(const folder::path::component& name
if (!store)
throw exceptions::illegal_state("Store disconnected");
return make_shared <maildirFolder>(m_path / name, store);
return shared_ptr <maildirFolder>(new maildirFolder(m_path / name, store));
}
@ -495,7 +495,7 @@ void maildirFolder::listFolders(std::vector <shared_ptr <folder> >& list, const
for (std::vector <folder::path>::size_type i = 0, n = pathList.size() ; i < n ; ++i)
{
shared_ptr <maildirFolder> subFolder =
make_shared <maildirFolder>(pathList[i], store);
shared_ptr <maildirFolder>(new maildirFolder(pathList[i], store));
list.push_back(subFolder);
}
@ -1170,7 +1170,7 @@ shared_ptr <folder> maildirFolder::getParent()
if (m_path.isEmpty())
return null;
else
return make_shared <maildirFolder>(m_path.getParent(), m_store.lock());
return shared_ptr <maildirFolder>(new maildirFolder(m_path.getParent(), m_store.lock()));
}

View File

@ -61,11 +61,10 @@ private:
friend class maildirMessage;
maildirFolder(const maildirFolder&) : folder() { }
maildirFolder(const folder::path& path, shared_ptr <maildirStore> store);
public:
maildirFolder(const folder::path& path, shared_ptr <maildirStore> store);
~maildirFolder();

View File

@ -83,9 +83,9 @@ shared_ptr <folder> maildirStore::getRootFolder()
if (!isConnected())
throw exceptions::illegal_state("Not connected");
return make_shared <maildirFolder>
(folder::path(),
dynamicCast <maildirStore>(shared_from_this()));
return shared_ptr <maildirFolder>
(new maildirFolder(folder::path(),
dynamicCast <maildirStore>(shared_from_this())));
}
@ -94,9 +94,9 @@ shared_ptr <folder> maildirStore::getDefaultFolder()
if (!isConnected())
throw exceptions::illegal_state("Not connected");
return make_shared <maildirFolder>
(folder::path::component("inbox"),
dynamicCast <maildirStore>(shared_from_this()));
return shared_ptr <maildirFolder>
(new maildirFolder(folder::path::component("inbox"),
dynamicCast <maildirStore>(shared_from_this())));
}
@ -105,8 +105,8 @@ shared_ptr <folder> maildirStore::getFolder(const folder::path& path)
if (!isConnected())
throw exceptions::illegal_state("Not connected");
return make_shared <maildirFolder>
(path, dynamicCast <maildirStore>(shared_from_this()));
return shared_ptr <maildirFolder>
(new maildirFolder(path, dynamicCast <maildirStore>(shared_from_this())));
}

View File

@ -50,12 +50,12 @@ class messageStructure;
/** A MIME part in a message.
*/
class VMIME_EXPORT messagePart : public object
class VMIME_EXPORT messagePart : public object, public enable_shared_from_this <messagePart>
{
protected:
messagePart() { }
messagePart(const messagePart&) : object() { }
messagePart(const messagePart&) : object(), enable_shared_from_this <messagePart>() { }
virtual ~messagePart() { }
@ -126,12 +126,12 @@ public:
/** Structure of a MIME part/message.
*/
class VMIME_EXPORT messageStructure : public object
class VMIME_EXPORT messageStructure : public object, public enable_shared_from_this <messageStructure>
{
protected:
messageStructure() { }
messageStructure(const messageStructure&) : object() { }
messageStructure(const messageStructure&) : object(), enable_shared_from_this <messageStructure>() { }
public:
@ -164,12 +164,12 @@ public:
/** Abstract representation of a message in a store/transport service.
*/
class VMIME_EXPORT message : public object
class VMIME_EXPORT message : public object, public enable_shared_from_this <message>
{
protected:
message() { }
message(const message&) : object() { }
message(const message&) : object(), enable_shared_from_this <message>() { }
enum PrivateConstants
{

View File

@ -409,7 +409,7 @@ void POP3Connection::authenticateSASL()
std::vector <shared_ptr <security::sasl::SASLMechanism> > mechList;
shared_ptr <security::sasl::SASLContext> saslContext =
make_shared <security::sasl::SASLContext>();
security::sasl::SASLContext::create();
for (unsigned int i = 0 ; i < saslMechs.size() ; ++i)
{

View File

@ -61,7 +61,7 @@ class POP3Store;
/** Manage connection to a POP3 server.
*/
class VMIME_EXPORT POP3Connection : public object
class VMIME_EXPORT POP3Connection : public object, public enable_shared_from_this <POP3Connection>
{
public:

View File

@ -287,7 +287,7 @@ shared_ptr <folder> POP3Folder::getFolder(const folder::path::component& name)
if (!store)
throw exceptions::illegal_state("Store disconnected");
return make_shared <POP3Folder>(m_path / name, store);
return shared_ptr <POP3Folder>(new POP3Folder(m_path / name, store));
}
@ -301,7 +301,7 @@ std::vector <shared_ptr <folder> > POP3Folder::getFolders(const bool /* recursiv
if (m_path.isEmpty())
{
std::vector <shared_ptr <folder> > v;
v.push_back(make_shared <POP3Folder>(folder::path::component("INBOX"), store));
v.push_back(shared_ptr <POP3Folder>(new POP3Folder(folder::path::component("INBOX"), store)));
return (v);
}
else
@ -520,7 +520,7 @@ shared_ptr <folder> POP3Folder::getParent()
if (m_path.isEmpty())
return null;
else
return make_shared <POP3Folder>(m_path.getParent(), m_store.lock());
return shared_ptr <POP3Folder>(new POP3Folder(m_path.getParent(), m_store.lock()));
}

View File

@ -59,11 +59,10 @@ private:
friend class POP3Message;
POP3Folder(const POP3Folder&);
POP3Folder(const folder::path& path, shared_ptr <POP3Store> store);
public:
POP3Folder(const folder::path& path, shared_ptr <POP3Store> store);
~POP3Folder();
int getMode() const;

View File

@ -73,9 +73,9 @@ shared_ptr <folder> POP3Store::getDefaultFolder()
if (!isConnected())
throw exceptions::illegal_state("Not connected");
return make_shared <POP3Folder>
(folder::path(folder::path::component("INBOX")),
dynamicCast <POP3Store>(shared_from_this()));
return shared_ptr <POP3Folder>
(new POP3Folder(folder::path(folder::path::component("INBOX")),
dynamicCast <POP3Store>(shared_from_this())));
}
@ -84,8 +84,8 @@ shared_ptr <folder> POP3Store::getRootFolder()
if (!isConnected())
throw exceptions::illegal_state("Not connected");
return make_shared <POP3Folder>
(folder::path(), dynamicCast <POP3Store>(shared_from_this()));
return shared_ptr <POP3Folder>
(new POP3Folder(folder::path(), dynamicCast <POP3Store>(shared_from_this())));
}
@ -94,8 +94,8 @@ shared_ptr <folder> POP3Store::getFolder(const folder::path& path)
if (!isConnected())
throw exceptions::illegal_state("Not connected");
return make_shared <POP3Folder>
(path, dynamicCast <POP3Store>(shared_from_this()));
return shared_ptr <POP3Folder>
(new POP3Folder(path, dynamicCast <POP3Store>(shared_from_this())));
}

View File

@ -56,7 +56,7 @@ namespace net {
/** Base class for messaging services.
*/
class VMIME_EXPORT service : public object
class VMIME_EXPORT service : public object, public enable_shared_from_this <service>
{
protected:

View File

@ -48,17 +48,6 @@ session::session()
}
session::session(const session& sess)
: object(), m_props(sess.m_props)
{
#if VMIME_HAVE_TLS_SUPPORT
m_tlsProps = make_shared <tls::TLSProperties>(*sess.m_tlsProps);
#endif // VMIME_HAVE_TLS_SUPPORT
}
session::session(const propertySet& props)
: m_props(props)
{
@ -75,6 +64,20 @@ session::~session()
}
// static
shared_ptr <session> session::create()
{
return shared_ptr <session>(new session());
}
// static
shared_ptr <session> session::create(const propertySet& props)
{
return shared_ptr <session>(new session(props));
}
shared_ptr <transport> session::getTransport(shared_ptr <security::authenticator> auth)
{
return (getTransport(m_props["transport.protocol"], auth));

View File

@ -54,15 +54,24 @@ class transport;
* for connection to a service.
*/
class VMIME_EXPORT session : public object
class VMIME_EXPORT session : public object, public enable_shared_from_this <session>
{
public:
session();
session(const session& sess);
session(const propertySet& props);
/** Construct a new session.
*
* @return pointer to a new session
*/
static shared_ptr <session> create();
virtual ~session();
/** Construct a new session given properties.
*
* @param props session properties
* @return pointer to a new session
*/
static shared_ptr <session> create(const propertySet& props);
~session();
/** Return a transport service instance for the protocol specified
* in the session properties.
@ -169,6 +178,10 @@ public:
private:
session();
session(const propertySet& props);
propertySet m_props;
#if VMIME_HAVE_TLS_SUPPORT

View File

@ -330,7 +330,7 @@ void SMTPConnection::authenticateSASL()
std::vector <shared_ptr <security::sasl::SASLMechanism> > mechList;
shared_ptr <security::sasl::SASLContext> saslContext =
make_shared <security::sasl::SASLContext>();
security::sasl::SASLContext::create();
for (unsigned int i = 0 ; i < saslMechs.size() ; ++i)
{

View File

@ -46,7 +46,7 @@ namespace tls {
/** Describe a TLS connection between a client and a server.
*/
class VMIME_EXPORT TLSSession : public object
class VMIME_EXPORT TLSSession : public object, public enable_shared_from_this <TLSSession>
{
public:

View File

@ -35,7 +35,6 @@ object::object()
object::object(const object&)
: enable_shared_from_this <object>()
{
}

View File

@ -35,7 +35,7 @@ namespace vmime
/** Base object for all objects in the library.
*/
class VMIME_EXPORT object : public enable_shared_from_this <object>
class VMIME_EXPORT object
{
protected:

View File

@ -35,7 +35,7 @@ namespace cert {
/** Identity certificate for a peer.
*/
class VMIME_EXPORT certificate : public object
class VMIME_EXPORT certificate : public object, public enable_shared_from_this <certificate>
{
public:

View File

@ -62,11 +62,18 @@ SASLContext::~SASLContext()
}
// static
shared_ptr <SASLContext> SASLContext::create()
{
return shared_ptr <SASLContext>(new SASLContext());
}
shared_ptr <SASLSession> SASLContext::createSession
(const string& serviceName,
shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech)
{
return make_shared <SASLSession>
return SASLSession::create
(serviceName, dynamicCast <SASLContext>(shared_from_this()), auth, mech);
}

View File

@ -44,7 +44,7 @@ namespace sasl {
/** An SASL client context.
*/
class VMIME_EXPORT SASLContext : public object
class VMIME_EXPORT SASLContext : public object, public enable_shared_from_this <SASLContext>
{
friend class SASLSession;
friend class builtinSASLMechanism;
@ -54,8 +54,10 @@ public:
~SASLContext();
/** Construct and initialize a new SASL context.
*
* @return pointer to a new SASL context
*/
SASLContext();
static shared_ptr <SASLContext> create();
/** Create and initialize a new SASL session.
*
@ -105,6 +107,10 @@ public:
private:
SASLContext();
SASLContext(SASLContext&);
static const string getErrorMessage(const string& fname, const int code);

View File

@ -68,6 +68,15 @@ SASLSession::~SASLSession()
}
// static
shared_ptr <SASLSession> SASLSession::create
(const string& serviceName, shared_ptr <SASLContext> ctx,
shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech)
{
return shared_ptr <SASLSession>(new SASLSession(serviceName, ctx, auth, mech));
}
void SASLSession::init()
{
shared_ptr <SASLAuthenticator> saslAuth = dynamicCast <SASLAuthenticator>(m_auth);

View File

@ -33,9 +33,10 @@
#include "vmime/types.hpp"
#include "vmime/net/socket.hpp"
#include "vmime/security/sasl/SASLAuthenticator.hpp"
#include "vmime/security/sasl/SASLMechanism.hpp"
#include "vmime/security/sasl/SASLSocket.hpp"
namespace vmime {
@ -48,7 +49,7 @@ class SASLContext;
/** An SASL client session.
*/
class VMIME_EXPORT SASLSession : public object
class VMIME_EXPORT SASLSession : public object, public enable_shared_from_this <SASLSession>
{
friend class builtinSASLMechanism;
friend class SASLSocket;
@ -64,8 +65,9 @@ public:
* @param auth authenticator to use for this session
* @param mech SASL mechanism
*/
SASLSession(const string& serviceName, shared_ptr <SASLContext> ctx,
shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech);
static shared_ptr <SASLSession> create
(const string& serviceName, shared_ptr <SASLContext> ctx,
shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech);
/** Initialize this SASL session. This must be called before
* calling any other method on this object (except accessors).
@ -133,6 +135,11 @@ public:
private:
SASLSession
(const string& serviceName, shared_ptr <SASLContext> ctx,
shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech);
const string m_serviceName;
shared_ptr <SASLContext> m_context;

View File

@ -458,8 +458,7 @@ VMIME_TEST_SUITE_BEGIN(IMAPCommandTest)
{
vmime::shared_ptr <IMAPCommand> cmd = IMAPCommand::createCommand("MY_COMMAND param1 param2");
vmime::shared_ptr <vmime::net::session> sess =
vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create();
vmime::shared_ptr <vmime::security::authenticator> auth =
vmime::make_shared <vmime::security::defaultAuthenticator>();

View File

@ -473,8 +473,7 @@ private:
vmime::shared_ptr <vmime::net::store> createAndConnectStore()
{
vmime::shared_ptr <vmime::net::session> session =
vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
vmime::shared_ptr <vmime::net::store> store =
session->getStore(getStoreURL());

View File

@ -39,8 +39,7 @@ VMIME_TEST_SUITE_BEGIN(POP3StoreTest)
void testCreateFromURL()
{
vmime::shared_ptr <vmime::net::session> sess
= vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create();
// POP3
vmime::utility::url url("pop3://pop3.vmime.org");
@ -57,8 +56,7 @@ VMIME_TEST_SUITE_BEGIN(POP3StoreTest)
void testConnectToInvalidServer()
{
vmime::shared_ptr <vmime::net::session> sess
= vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create();
vmime::utility::url url("pop3://invalid-pop3-server");
vmime::shared_ptr <vmime::net::store> store = sess->getStore(url);

View File

@ -30,7 +30,7 @@ class POP3TestStore : public vmime::net::pop3::POP3Store
public:
POP3TestStore()
: POP3Store(vmime::make_shared <vmime::net::session>(),
: POP3Store(vmime::net::session::create(),
vmime::shared_ptr <vmime::security::authenticator>())
{
}

View File

@ -44,8 +44,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
void testConnectToInvalidServer()
{
vmime::shared_ptr <vmime::net::session> sess
= vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> sess = vmime::net::session::create();
vmime::utility::url url("smtp://invalid-smtp-server");
vmime::shared_ptr <vmime::net::transport> store = sess->getTransport(url);
@ -55,8 +54,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
void testGreetingError()
{
vmime::shared_ptr <vmime::net::session> session =
vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
(vmime::utility::url("smtp://localhost"));
@ -70,8 +68,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
void testMAILandRCPT()
{
vmime::shared_ptr <vmime::net::session> session =
vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
(vmime::utility::url("smtp://localhost"));
@ -96,8 +93,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
void testChunking()
{
vmime::shared_ptr <vmime::net::session> session =
vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
(vmime::utility::url("smtp://localhost"));
@ -122,8 +118,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
void testSize_Chunking()
{
vmime::shared_ptr <vmime::net::session> session =
vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
(vmime::utility::url("smtp://localhost"));
@ -149,8 +144,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
void testSize_NoChunking()
{
vmime::shared_ptr <vmime::net::session> session =
vmime::make_shared <vmime::net::session>();
vmime::shared_ptr <vmime::net::session> session = vmime::net::session::create();
vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
(vmime::utility::url("smtp://localhost"));