Added service::setSocketFactory().
This commit is contained in:
parent
7d2d25da3e
commit
09d9e11439
@ -2,6 +2,12 @@
|
||||
VERSION 0.7.2cvs
|
||||
================
|
||||
|
||||
2005-10-04 Vincent Richard <vincent@vincent-richard.net>
|
||||
|
||||
* net/service: removed "server.socket-factory" property; added the
|
||||
service::setSocketFactory() function instead. Removed "name" parameter
|
||||
from platformDependant::getSocketFactory() function.
|
||||
|
||||
2005-10-03 Vincent Richard <vincent@vincent-richard.net>
|
||||
|
||||
* Added TLS/SSL support, using GNU TLS library.
|
||||
|
@ -94,10 +94,7 @@ void IMAPConnection::connect()
|
||||
}
|
||||
|
||||
// Create and connect the socket
|
||||
socketFactory* sf = platformDependant::getHandler()->
|
||||
getSocketFactory(GET_PROPERTY(string, PROPERTY_SERVER_SOCKETFACTORY));
|
||||
|
||||
m_socket = sf->create();
|
||||
m_socket = m_store->getSocketFactory()->create();
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
if (m_store->isSecuredConnection()) // dedicated port/IMAPS
|
||||
|
@ -61,7 +61,6 @@ const IMAPServiceInfos::props& IMAPServiceInfos::getProperties() const
|
||||
|
||||
property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED),
|
||||
property(serviceInfos::property::SERVER_PORT, "143"),
|
||||
property(serviceInfos::property::SERVER_SOCKETFACTORY),
|
||||
|
||||
property(serviceInfos::property::TIMEOUT_FACTORY)
|
||||
};
|
||||
@ -85,7 +84,6 @@ const IMAPServiceInfos::props& IMAPServiceInfos::getProperties() const
|
||||
|
||||
property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED),
|
||||
property(serviceInfos::property::SERVER_PORT, "993"),
|
||||
property(serviceInfos::property::SERVER_SOCKETFACTORY),
|
||||
|
||||
property(serviceInfos::property::TIMEOUT_FACTORY)
|
||||
};
|
||||
@ -119,7 +117,6 @@ const std::vector <serviceInfos::property> IMAPServiceInfos::getAvailablePropert
|
||||
|
||||
list.push_back(p.PROPERTY_SERVER_ADDRESS);
|
||||
list.push_back(p.PROPERTY_SERVER_PORT);
|
||||
list.push_back(p.PROPERTY_SERVER_SOCKETFACTORY);
|
||||
|
||||
list.push_back(p.PROPERTY_TIMEOUT_FACTORY);
|
||||
|
||||
|
@ -63,7 +63,6 @@ const POP3ServiceInfos::props& POP3ServiceInfos::getProperties() const
|
||||
|
||||
property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED),
|
||||
property(serviceInfos::property::SERVER_PORT, "110"),
|
||||
property(serviceInfos::property::SERVER_SOCKETFACTORY),
|
||||
|
||||
property(serviceInfos::property::TIMEOUT_FACTORY)
|
||||
};
|
||||
@ -89,7 +88,6 @@ const POP3ServiceInfos::props& POP3ServiceInfos::getProperties() const
|
||||
|
||||
property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED),
|
||||
property(serviceInfos::property::SERVER_PORT, "995"),
|
||||
property(serviceInfos::property::SERVER_SOCKETFACTORY),
|
||||
|
||||
property(serviceInfos::property::TIMEOUT_FACTORY)
|
||||
};
|
||||
@ -125,7 +123,6 @@ const std::vector <serviceInfos::property> POP3ServiceInfos::getAvailablePropert
|
||||
|
||||
list.push_back(p.PROPERTY_SERVER_ADDRESS);
|
||||
list.push_back(p.PROPERTY_SERVER_PORT);
|
||||
list.push_back(p.PROPERTY_SERVER_SOCKETFACTORY);
|
||||
|
||||
list.push_back(p.PROPERTY_TIMEOUT_FACTORY);
|
||||
|
||||
|
@ -132,10 +132,7 @@ void POP3Store::connect()
|
||||
}
|
||||
|
||||
// Create and connect the socket
|
||||
socketFactory* sf = platformDependant::getHandler()->
|
||||
getSocketFactory(GET_PROPERTY(string, PROPERTY_SERVER_SOCKETFACTORY));
|
||||
|
||||
m_socket = sf->create();
|
||||
m_socket = getSocketFactory()->create();
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
if (m_secured) // dedicated port/POP3S
|
||||
@ -272,13 +269,12 @@ void POP3Store::authenticate(const messageId& randomMID)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Some servers close the connection after an
|
||||
// unsuccessful APOP command, so the fallback
|
||||
// may not always work...
|
||||
// Some servers close the connection after an unsuccessful APOP
|
||||
// command, so the fallback may not always work...
|
||||
//
|
||||
// S: +OK Qpopper (version 4.0.5) at xxx starting. <30396.1126730747@xxx>
|
||||
// C: APOP plop c5e0a87d088ec71d60e32692d4c5bdf4
|
||||
// S: -ERR [AUTH] Password supplied for "o" is incorrect.
|
||||
// S: -ERR [AUTH] Password supplied for "plop" is incorrect.
|
||||
// S: +OK Pop server at xxx signing off.
|
||||
// [Connection closed by foreign host.]
|
||||
|
||||
@ -298,6 +294,7 @@ void POP3Store::authenticate(const messageId& randomMID)
|
||||
}
|
||||
catch (exceptions::socket_exception&)
|
||||
{
|
||||
internalDisconnect();
|
||||
throw exceptions::authentication_error(response);
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "vmime/config.hpp"
|
||||
#include "vmime/net/service.hpp"
|
||||
|
||||
#include "vmime/platformDependant.hpp"
|
||||
|
||||
#if VMIME_HAVE_SASL_SUPPORT
|
||||
#include "vmime/security/sasl/defaultSASLAuthenticator.hpp"
|
||||
#else
|
||||
@ -54,6 +56,7 @@ service::service(ref <session> sess, const serviceInfos& /* infos */,
|
||||
m_certVerifier = vmime::create <tls::defaultCertificateVerifier>();
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
m_socketFactory = platformDependant::getHandler()->getSocketFactory();
|
||||
}
|
||||
|
||||
|
||||
@ -108,5 +111,17 @@ ref <tls::certificateVerifier> service::getCertificateVerifier()
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
|
||||
void service::setSocketFactory(ref <socketFactory> sf)
|
||||
{
|
||||
m_socketFactory = sf;
|
||||
}
|
||||
|
||||
|
||||
ref <socketFactory> service::getSocketFactory()
|
||||
{
|
||||
return m_socketFactory;
|
||||
}
|
||||
|
||||
|
||||
} // net
|
||||
} // vmime
|
||||
|
@ -34,9 +34,6 @@ const serviceInfos::property serviceInfos::property::SERVER_PORT
|
||||
const serviceInfos::property serviceInfos::property::SERVER_ROOTPATH
|
||||
("server.rootpath", serviceInfos::property::TYPE_STRING);
|
||||
|
||||
const serviceInfos::property serviceInfos::property::SERVER_SOCKETFACTORY
|
||||
("server.socket-factory", serviceInfos::property::TYPE_STRING, "default");
|
||||
|
||||
const serviceInfos::property serviceInfos::property::AUTH_USERNAME
|
||||
("auth.username", serviceInfos::property::TYPE_STRING);
|
||||
|
||||
|
@ -62,7 +62,6 @@ const SMTPServiceInfos::props& SMTPServiceInfos::getProperties() const
|
||||
|
||||
property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED),
|
||||
property(serviceInfos::property::SERVER_PORT, "25"),
|
||||
property(serviceInfos::property::SERVER_SOCKETFACTORY),
|
||||
|
||||
property(serviceInfos::property::TIMEOUT_FACTORY)
|
||||
};
|
||||
@ -87,7 +86,6 @@ const SMTPServiceInfos::props& SMTPServiceInfos::getProperties() const
|
||||
|
||||
property(serviceInfos::property::SERVER_ADDRESS, serviceInfos::property::FLAG_REQUIRED),
|
||||
property(serviceInfos::property::SERVER_PORT, "465"),
|
||||
property(serviceInfos::property::SERVER_SOCKETFACTORY),
|
||||
|
||||
property(serviceInfos::property::TIMEOUT_FACTORY)
|
||||
};
|
||||
@ -122,7 +120,6 @@ const std::vector <serviceInfos::property> SMTPServiceInfos::getAvailablePropert
|
||||
|
||||
list.push_back(p.PROPERTY_SERVER_ADDRESS);
|
||||
list.push_back(p.PROPERTY_SERVER_PORT);
|
||||
list.push_back(p.PROPERTY_SERVER_SOCKETFACTORY);
|
||||
|
||||
list.push_back(p.PROPERTY_TIMEOUT_FACTORY);
|
||||
|
||||
|
@ -98,10 +98,7 @@ void SMTPTransport::connect()
|
||||
}
|
||||
|
||||
// Create and connect the socket
|
||||
socketFactory* sf = platformDependant::getHandler()->
|
||||
getSocketFactory(GET_PROPERTY(string, PROPERTY_SERVER_SOCKETFACTORY));
|
||||
|
||||
m_socket = sf->create();
|
||||
m_socket = getSocketFactory()->create();
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
if (m_secured) // dedicated port/SMTPS
|
||||
|
@ -48,7 +48,7 @@ namespace posix {
|
||||
posixHandler::posixHandler()
|
||||
{
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
m_socketFactory = new posixSocketFactory();
|
||||
m_socketFactory = vmime::create <posixSocketFactory>();
|
||||
#endif
|
||||
#if VMIME_HAVE_FILESYSTEM_FEATURES
|
||||
m_fileSysFactory = new posixFileSystemFactory();
|
||||
@ -59,9 +59,6 @@ posixHandler::posixHandler()
|
||||
|
||||
posixHandler::~posixHandler()
|
||||
{
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
delete (m_socketFactory);
|
||||
#endif
|
||||
#if VMIME_HAVE_FILESYSTEM_FEATURES
|
||||
delete (m_fileSysFactory);
|
||||
delete (m_childProcFactory);
|
||||
@ -172,10 +169,9 @@ const unsigned int posixHandler::getProcessId() const
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
|
||||
vmime::net::socketFactory* posixHandler::getSocketFactory
|
||||
(const vmime::string& /* name */) const
|
||||
ref <vmime::net::socketFactory> posixHandler::getSocketFactory() const
|
||||
{
|
||||
return (m_socketFactory);
|
||||
return m_socketFactory.dynamicCast <vmime::net::socketFactory>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -42,7 +42,7 @@ namespace windows {
|
||||
windowsHandler::windowsHandler()
|
||||
{
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
m_socketFactory = new windowsSocketFactory();
|
||||
m_socketFactory = vmime::create <windowsSocketFactory>();
|
||||
#endif
|
||||
#if VMIME_HAVE_FILESYSTEM_FEATURES
|
||||
m_fileSysFactory = new windowsFileSystemFactory();
|
||||
@ -52,9 +52,6 @@ windowsHandler::windowsHandler()
|
||||
|
||||
windowsHandler::~windowsHandler()
|
||||
{
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
delete (m_socketFactory);
|
||||
#endif
|
||||
#if VMIME_HAVE_FILESYSTEM_FEATURES
|
||||
delete (m_fileSysFactory);
|
||||
#endif
|
||||
@ -237,10 +234,9 @@ const unsigned int windowsHandler::getProcessId() const
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
|
||||
vmime::net::socketFactory* windowsHandler::getSocketFactory
|
||||
(const vmime::string& /* name */) const
|
||||
ref <vmime::net::socketFactory> windowsHandler::getSocketFactory() const
|
||||
{
|
||||
return (m_socketFactory);
|
||||
return m_socketFactory.dynamicCast <vmime::net::socketFactory>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +62,6 @@ public:
|
||||
|
||||
serviceInfos::property PROPERTY_SERVER_ADDRESS;
|
||||
serviceInfos::property PROPERTY_SERVER_PORT;
|
||||
serviceInfos::property PROPERTY_SERVER_SOCKETFACTORY;
|
||||
|
||||
serviceInfos::property PROPERTY_TIMEOUT_FACTORY;
|
||||
};
|
||||
|
@ -64,7 +64,6 @@ public:
|
||||
|
||||
serviceInfos::property PROPERTY_SERVER_ADDRESS;
|
||||
serviceInfos::property PROPERTY_SERVER_PORT;
|
||||
serviceInfos::property PROPERTY_SERVER_SOCKETFACTORY;
|
||||
|
||||
serviceInfos::property PROPERTY_TIMEOUT_FACTORY;
|
||||
};
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include "vmime/net/serviceFactory.hpp"
|
||||
#include "vmime/net/serviceInfos.hpp"
|
||||
|
||||
#include "vmime/net/socket.hpp"
|
||||
|
||||
#if VMIME_HAVE_TLS_SUPPORT
|
||||
#include "vmime/net/tls/certificateVerifier.hpp"
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
@ -146,6 +148,20 @@ public:
|
||||
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
/** Set the factory used to create socket objects for this
|
||||
* service.
|
||||
*
|
||||
* @param sf socket factory
|
||||
*/
|
||||
void setSocketFactory(ref <socketFactory> sf);
|
||||
|
||||
/** Return the factory used to create socket objects for this
|
||||
* service.
|
||||
*
|
||||
* @return socket factory
|
||||
*/
|
||||
ref <socketFactory> getSocketFactory();
|
||||
|
||||
/** Set a property for this service (service prefix is added automatically).
|
||||
*
|
||||
* WARNING: this sets the property on the session object, so all service
|
||||
@ -184,6 +200,7 @@ private:
|
||||
ref <tls::certificateVerifier> m_certVerifier;
|
||||
#endif // VMIME_HAVE_TLS_SUPPORT
|
||||
|
||||
ref <socketFactory> m_socketFactory;
|
||||
};
|
||||
|
||||
|
||||
|
@ -76,11 +76,6 @@ public:
|
||||
* maildir, this is the local filesystem directory). */
|
||||
static const property SERVER_ROOTPATH;
|
||||
|
||||
/** The common property 'server.socket-factory' used
|
||||
* to indicate which factory to use to instanciate
|
||||
* new socket objects. */
|
||||
static const property SERVER_SOCKETFACTORY;
|
||||
|
||||
/** The common property 'auth.username' which is the
|
||||
* username used to authenticate with the server. */
|
||||
static const property AUTH_USERNAME;
|
||||
|
@ -63,7 +63,6 @@ public:
|
||||
|
||||
serviceInfos::property PROPERTY_SERVER_ADDRESS;
|
||||
serviceInfos::property PROPERTY_SERVER_PORT;
|
||||
serviceInfos::property PROPERTY_SERVER_SOCKETFACTORY;
|
||||
|
||||
serviceInfos::property PROPERTY_TIMEOUT_FACTORY;
|
||||
};
|
||||
|
@ -99,7 +99,7 @@ private:
|
||||
/** A class to create 'socket' objects.
|
||||
*/
|
||||
|
||||
class socketFactory
|
||||
class socketFactory : public object
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
/** A class to create 'timeoutHandler' objects.
|
||||
*/
|
||||
|
||||
class timeoutHandlerFactory
|
||||
class timeoutHandlerFactory : public object
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -103,18 +103,12 @@ public:
|
||||
virtual void wait() const = 0;
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
/** Return a pointer to a socket factory for the specified socket
|
||||
* type name (this is user-defined, and used for example when you
|
||||
* want to set up a SSL connection to a server).
|
||||
* The returned object will not be deleted by VMime, so it can be
|
||||
* a pointer to a static object.
|
||||
/** Return a pointer to the default socket factory for
|
||||
* this platform.
|
||||
*
|
||||
* @param name socket type name (user-dependant): this is usually
|
||||
* the value of the property "server.socket-factory" set in the
|
||||
* session object
|
||||
* @return socket factory
|
||||
*/
|
||||
virtual net::socketFactory* getSocketFactory(const string& name = "default") const = 0;
|
||||
virtual ref <net::socketFactory> getSocketFactory() const = 0;
|
||||
|
||||
/** Return a pointer to a timeout-handler factory for the specified name.
|
||||
* The returned object will not be deleted by VMime, so it can be a
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
const unsigned int getProcessId() const;
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
vmime::net::socketFactory* getSocketFactory(const vmime::string& name) const;
|
||||
ref <vmime::net::socketFactory> getSocketFactory() const;
|
||||
|
||||
vmime::net::timeoutHandlerFactory* getTimeoutHandlerFactory(const vmime::string& name) const;
|
||||
#endif
|
||||
@ -77,7 +77,7 @@ public:
|
||||
private:
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
posixSocketFactory* m_socketFactory;
|
||||
ref <posixSocketFactory> m_socketFactory;
|
||||
#endif
|
||||
|
||||
#if VMIME_HAVE_FILESYSTEM_FEATURES
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
const unsigned int getProcessId() const;
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
vmime::net::socketFactory* getSocketFactory(const vmime::string& name) const;
|
||||
ref <vmime::net::socketFactory> getSocketFactory() const;
|
||||
|
||||
vmime::net::timeoutHandlerFactory* getTimeoutHandlerFactory(const vmime::string& name) const;
|
||||
#endif
|
||||
@ -76,7 +76,7 @@ public:
|
||||
private:
|
||||
|
||||
#if VMIME_HAVE_MESSAGING_FEATURES
|
||||
windowsSocketFactory* m_socketFactory;
|
||||
ref <windowsSocketFactory> m_socketFactory;
|
||||
#endif
|
||||
|
||||
#if VMIME_HAVE_FILESYSTEM_FEATURES
|
||||
|
Loading…
Reference in New Issue
Block a user