2005-08-23 19:11:19 +00:00
|
|
|
//
|
|
|
|
// VMime library (http://www.vmime.org)
|
|
|
|
// Copyright (C) 2002-2005 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-08-23 19:11:19 +00:00
|
|
|
//
|
|
|
|
|
2005-09-17 09:08:45 +00:00
|
|
|
#include "vmime/config.hpp"
|
2005-08-23 19:11:19 +00:00
|
|
|
#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-08-23 19:11:19 +00:00
|
|
|
|
2005-10-03 21:29:04 +00:00
|
|
|
#if VMIME_HAVE_TLS_SUPPORT
|
2005-10-30 15:02:39 +00:00
|
|
|
#include "vmime/security/cert/defaultCertificateVerifier.hpp"
|
2005-10-03 21:29:04 +00:00
|
|
|
#endif // VMIME_HAVE_TLS_SUPPORT
|
|
|
|
|
2005-08-23 19:11:19 +00:00
|
|
|
|
|
|
|
namespace vmime {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
|
2005-09-17 09:08:45 +00:00
|
|
|
service::service(ref <session> sess, const serviceInfos& /* infos */,
|
|
|
|
ref <security::authenticator> auth)
|
2005-08-23 19:11:19 +00:00
|
|
|
: 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-08-23 19:11:19 +00:00
|
|
|
}
|
2005-10-03 21:29:04 +00:00
|
|
|
|
|
|
|
#if VMIME_HAVE_TLS_SUPPORT
|
2005-10-30 15:02:39 +00:00
|
|
|
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();
|
2005-08-23 19:11:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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
|
2005-08-23 19:11:19 +00:00
|
|
|
{
|
|
|
|
return (m_auth);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-17 09:08:45 +00:00
|
|
|
ref <security::authenticator> service::getAuthenticator()
|
2005-08-23 19:11:19 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
|
2005-10-30 15:02:39 +00:00
|
|
|
void service::setCertificateVerifier(ref <security::cert::certificateVerifier> cv)
|
2005-10-03 21:29:04 +00:00
|
|
|
{
|
|
|
|
m_certVerifier = cv;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-30 15:02:39 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-04 18:49:59 +00:00
|
|
|
void service::setTimeoutHandlerFactory(ref <timeoutHandlerFactory> thf)
|
|
|
|
{
|
|
|
|
m_toHandlerFactory = thf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ref <timeoutHandlerFactory> service::getTimeoutHandlerFactory()
|
|
|
|
{
|
|
|
|
return m_toHandlerFactory;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-08-23 19:11:19 +00:00
|
|
|
} // net
|
|
|
|
} // vmime
|