vmime/src/net/service.cpp

140 lines
2.9 KiB
C++
Raw Normal View History

//
// VMime library (http://www.vmime.org)
2006-02-05 10:22:59 +00:00
// Copyright (C) 2002-2006 Vincent Richard <vincent@vincent-richard.net>
//
// 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 2 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.
//
2005-09-17 10:10:29 +00:00
// You should have received a copy of the GNU General Public License along along
// with this program; if not, write to the Free Software Foundation, Inc., Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA..
//
2005-09-17 09:08:45 +00:00
#include "vmime/config.hpp"
#include "vmime/net/service.hpp"
2005-10-04 18:34:25 +00:00
#include "vmime/platformDependant.hpp"
2005-09-17 09:08:45 +00:00
#if VMIME_HAVE_SASL_SUPPORT
#include "vmime/security/sasl/defaultSASLAuthenticator.hpp"
#else
#include "vmime/security/defaultAuthenticator.hpp"
#endif // VMIME_HAVE_SASL_SUPPORT
2005-10-03 21:29:04 +00:00
#if VMIME_HAVE_TLS_SUPPORT
#include "vmime/security/cert/defaultCertificateVerifier.hpp"
2005-10-03 21:29:04 +00:00
#endif // VMIME_HAVE_TLS_SUPPORT
namespace vmime {
namespace net {
2005-09-17 09:08:45 +00:00
service::service(ref <session> sess, const serviceInfos& /* infos */,
ref <security::authenticator> auth)
: m_session(sess), m_auth(auth)
{
if (!auth)
{
2005-09-17 09:08:45 +00:00
#if VMIME_HAVE_SASL_SUPPORT
m_auth = vmime::create
<security::sasl::defaultSASLAuthenticator>();
#else
m_auth = vmime::create
<security::defaultAuthenticator>();
#endif // VMIME_HAVE_SASL_SUPPORT
}
2005-10-03 21:29:04 +00:00
#if VMIME_HAVE_TLS_SUPPORT
m_certVerifier = vmime::create <security::cert::defaultCertificateVerifier>();
2005-10-03 21:29:04 +00:00
#endif // VMIME_HAVE_TLS_SUPPORT
2005-10-04 18:34:25 +00:00
m_socketFactory = platformDependant::getHandler()->getSocketFactory();
}
service::~service()
{
}
ref <const session> service::getSession() const
{
return (m_session);
}
ref <session> service::getSession()
{
return (m_session);
}
2005-09-17 09:08:45 +00:00
ref <const security::authenticator> service::getAuthenticator() const
{
return (m_auth);
}
2005-09-17 09:08:45 +00:00
ref <security::authenticator> service::getAuthenticator()
{
return (m_auth);
}
2005-09-17 09:08:45 +00:00
void service::setAuthenticator(ref <security::authenticator> auth)
{
m_auth = auth;
}
2005-10-03 21:29:04 +00:00
#if VMIME_HAVE_TLS_SUPPORT
void service::setCertificateVerifier(ref <security::cert::certificateVerifier> cv)
2005-10-03 21:29:04 +00:00
{
m_certVerifier = cv;
}
ref <security::cert::certificateVerifier> service::getCertificateVerifier()
2005-10-03 21:29:04 +00:00
{
return m_certVerifier;
}
#endif // VMIME_HAVE_TLS_SUPPORT
2005-10-04 18:34:25 +00:00
void service::setSocketFactory(ref <socketFactory> sf)
{
m_socketFactory = sf;
}
ref <socketFactory> service::getSocketFactory()
{
return m_socketFactory;
}
void service::setTimeoutHandlerFactory(ref <timeoutHandlerFactory> thf)
{
m_toHandlerFactory = thf;
}
ref <timeoutHandlerFactory> service::getTimeoutHandlerFactory()
{
return m_toHandlerFactory;
}
} // net
} // vmime