Added service::setTimeoutHandlerFactory().

This commit is contained in:
Vincent Richard 2005-10-04 18:49:59 +00:00
parent 09d9e11439
commit 3ec0f17ade
19 changed files with 41 additions and 88 deletions

View File

@ -8,6 +8,10 @@ VERSION 0.7.2cvs
service::setSocketFactory() function instead. Removed "name" parameter
from platformDependant::getSocketFactory() function.
* net/service: removed "timeout.factory" property; added the function
service::setTimeoutHandlerFactory() instead. Removed the function
platformDependant::getTimeoutHandlerFactory().
2005-10-03 Vincent Richard <vincent@vincent-richard.net>
* Added TLS/SSL support, using GNU TLS library.

View File

@ -85,13 +85,8 @@ void IMAPConnection::connect()
const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT);
// Create the time-out handler
if (HAS_PROPERTY(PROPERTY_TIMEOUT_FACTORY))
{
timeoutHandlerFactory* tof = platformDependant::getHandler()->
getTimeoutHandlerFactory(GET_PROPERTY(string, PROPERTY_TIMEOUT_FACTORY));
m_timeoutHandler = tof->create();
}
if (m_store->getTimeoutHandlerFactory())
m_timeoutHandler = m_store->getTimeoutHandlerFactory()->create();
// Create and connect the socket
m_socket = m_store->getSocketFactory()->create();

View File

@ -61,8 +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::TIMEOUT_FACTORY)
};
static props imapsProps =
@ -84,8 +82,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::TIMEOUT_FACTORY)
};
return m_imaps ? imapsProps : imapProps;
@ -118,8 +114,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_TIMEOUT_FACTORY);
return list;
}

View File

@ -63,8 +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::TIMEOUT_FACTORY)
};
static props pop3sProps =
@ -88,8 +86,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::TIMEOUT_FACTORY)
};
return m_pop3s ? pop3sProps : pop3Props;
@ -124,8 +120,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_TIMEOUT_FACTORY);
return list;
}

View File

@ -123,13 +123,8 @@ void POP3Store::connect()
const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT);
// Create the time-out handler
if (HAS_PROPERTY(PROPERTY_TIMEOUT_FACTORY))
{
timeoutHandlerFactory* tof = platformDependant::getHandler()->
getTimeoutHandlerFactory(GET_PROPERTY(string, PROPERTY_TIMEOUT_FACTORY));
m_timeoutHandler = tof->create();
}
if (getTimeoutHandlerFactory())
m_timeoutHandler = getTimeoutHandlerFactory()->create();
// Create and connect the socket
m_socket = getSocketFactory()->create();

View File

@ -123,5 +123,17 @@ ref <socketFactory> service::getSocketFactory()
}
void service::setTimeoutHandlerFactory(ref <timeoutHandlerFactory> thf)
{
m_toHandlerFactory = thf;
}
ref <timeoutHandlerFactory> service::getTimeoutHandlerFactory()
{
return m_toHandlerFactory;
}
} // net
} // vmime

View File

@ -40,9 +40,6 @@ const serviceInfos::property serviceInfos::property::AUTH_USERNAME
const serviceInfos::property serviceInfos::property::AUTH_PASSWORD
("auth.password", serviceInfos::property::TYPE_STRING);
const serviceInfos::property serviceInfos::property::TIMEOUT_FACTORY
("timeout.factory", serviceInfos::property::TYPE_STRING);
#if VMIME_HAVE_TLS_SUPPORT
const serviceInfos::property serviceInfos::property::CONNECTION_TLS

View File

@ -62,8 +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::TIMEOUT_FACTORY)
};
static props smtpsProps =
@ -86,8 +84,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::TIMEOUT_FACTORY)
};
return m_smtps ? smtpsProps : smtpProps;
@ -121,8 +117,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_TIMEOUT_FACTORY);
return list;
}

View File

@ -89,13 +89,8 @@ void SMTPTransport::connect()
const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT);
// Create the time-out handler
if (HAS_PROPERTY(PROPERTY_TIMEOUT_FACTORY))
{
timeoutHandlerFactory* tof = platformDependant::getHandler()->
getTimeoutHandlerFactory(GET_PROPERTY(string, PROPERTY_TIMEOUT_FACTORY));
m_timeoutHandler = tof->create();
}
if (getTimeoutHandlerFactory())
m_timeoutHandler = getTimeoutHandlerFactory()->create();
// Create and connect the socket
m_socket = getSocketFactory()->create();

View File

@ -174,14 +174,6 @@ ref <vmime::net::socketFactory> posixHandler::getSocketFactory() const
return m_socketFactory.dynamicCast <vmime::net::socketFactory>();
}
vmime::net::timeoutHandlerFactory* posixHandler::getTimeoutHandlerFactory
(const vmime::string& /* name */) const
{
// Not used by default
return (NULL);
}
#endif

View File

@ -239,14 +239,6 @@ ref <vmime::net::socketFactory> windowsHandler::getSocketFactory() const
return m_socketFactory.dynamicCast <vmime::net::socketFactory>();
}
vmime::net::timeoutHandlerFactory* windowsHandler::getTimeoutHandlerFactory
(const vmime::string& /* name */) const
{
// Not used by default
return (NULL);
}
#endif

View File

@ -62,8 +62,6 @@ public:
serviceInfos::property PROPERTY_SERVER_ADDRESS;
serviceInfos::property PROPERTY_SERVER_PORT;
serviceInfos::property PROPERTY_TIMEOUT_FACTORY;
};
const props& getProperties() const;

View File

@ -64,8 +64,6 @@ public:
serviceInfos::property PROPERTY_SERVER_ADDRESS;
serviceInfos::property PROPERTY_SERVER_PORT;
serviceInfos::property PROPERTY_TIMEOUT_FACTORY;
};
const props& getProperties() const;

View File

@ -34,6 +34,7 @@
#include "vmime/net/serviceInfos.hpp"
#include "vmime/net/socket.hpp"
#include "vmime/net/timeoutHandler.hpp"
#if VMIME_HAVE_TLS_SUPPORT
#include "vmime/net/tls/certificateVerifier.hpp"
@ -162,6 +163,21 @@ public:
*/
ref <socketFactory> getSocketFactory();
/** Set the factory used to create timeoutHandler objects for
* this service. By default, no timeout handler is used. Not all
* services support timeout handling.
*
* @param thf timeoutHandler factory
*/
void setTimeoutHandlerFactory(ref <timeoutHandlerFactory> thf);
/** Return the factory used to create timeoutHandler objects for
* this service.
*
* @return timeoutHandler factory
*/
ref <timeoutHandlerFactory> getTimeoutHandlerFactory();
/** Set a property for this service (service prefix is added automatically).
*
* WARNING: this sets the property on the session object, so all service
@ -201,6 +217,8 @@ private:
#endif // VMIME_HAVE_TLS_SUPPORT
ref <socketFactory> m_socketFactory;
ref <timeoutHandlerFactory> m_toHandlerFactory;
};

View File

@ -84,12 +84,6 @@ public:
* password used to authenticate with the server. */
static const property AUTH_PASSWORD;
/** The common property 'timeout.factory' used to
* specify which factory to use to instanciate
* time-out handler objects. If none is specified,
* no time-out handler is used. */
static const property TIMEOUT_FACTORY;
#if VMIME_HAVE_TLS_SUPPORT
/** The common property 'connection.tls': this is used to

View File

@ -63,8 +63,6 @@ public:
serviceInfos::property PROPERTY_SERVER_ADDRESS;
serviceInfos::property PROPERTY_SERVER_PORT;
serviceInfos::property PROPERTY_TIMEOUT_FACTORY;
};
const props& getProperties() const;

View File

@ -109,21 +109,8 @@ public:
* @return socket factory
*/
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
* pointer to a static object.
*
* This is used when you want to handle a timeout-mechanism when
* connecting to messaging servers (please read the documentation to
* learn how to use it). If you are not using time-out handlers, you
* can safely return NULL here.
*
* @param name time-out type name
* @return time-out factory
*/
virtual net::timeoutHandlerFactory* getTimeoutHandlerFactory(const string& name = "default") const = 0;
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES
/** Return a pointer to a factory that creates file-system objects.
*

View File

@ -62,8 +62,6 @@ public:
#if VMIME_HAVE_MESSAGING_FEATURES
ref <vmime::net::socketFactory> getSocketFactory() const;
vmime::net::timeoutHandlerFactory* getTimeoutHandlerFactory(const vmime::string& name) const;
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES

View File

@ -61,8 +61,6 @@ public:
#if VMIME_HAVE_MESSAGING_FEATURES
ref <vmime::net::socketFactory> getSocketFactory() const;
vmime::net::timeoutHandlerFactory* getTimeoutHandlerFactory(const vmime::string& name) const;
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES