From 3ec0f17ade68adec05f8b0af40c61a4f3a595b75 Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Tue, 4 Oct 2005 18:49:59 +0000 Subject: [PATCH] Added service::setTimeoutHandlerFactory(). --- ChangeLog | 4 ++++ src/net/imap/IMAPConnection.cpp | 9 ++------- src/net/imap/IMAPServiceInfos.cpp | 6 ------ src/net/pop3/POP3ServiceInfos.cpp | 6 ------ src/net/pop3/POP3Store.cpp | 9 ++------- src/net/service.cpp | 12 ++++++++++++ src/net/serviceInfos.cpp | 3 --- src/net/smtp/SMTPServiceInfos.cpp | 6 ------ src/net/smtp/SMTPTransport.cpp | 9 ++------- src/platforms/posix/posixHandler.cpp | 8 -------- src/platforms/windows/windowsHandler.cpp | 8 -------- vmime/net/imap/IMAPServiceInfos.hpp | 2 -- vmime/net/pop3/POP3ServiceInfos.hpp | 2 -- vmime/net/service.hpp | 18 ++++++++++++++++++ vmime/net/serviceInfos.hpp | 6 ------ vmime/net/smtp/SMTPServiceInfos.hpp | 2 -- vmime/platformDependant.hpp | 15 +-------------- vmime/platforms/posix/posixHandler.hpp | 2 -- vmime/platforms/windows/windowsHandler.hpp | 2 -- 19 files changed, 41 insertions(+), 88 deletions(-) diff --git a/ChangeLog b/ChangeLog index 948352ef..84422aef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 * Added TLS/SSL support, using GNU TLS library. diff --git a/src/net/imap/IMAPConnection.cpp b/src/net/imap/IMAPConnection.cpp index 180caa4b..69dfcb1e 100644 --- a/src/net/imap/IMAPConnection.cpp +++ b/src/net/imap/IMAPConnection.cpp @@ -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(); diff --git a/src/net/imap/IMAPServiceInfos.cpp b/src/net/imap/IMAPServiceInfos.cpp index a5d1ca5a..85b23a34 100644 --- a/src/net/imap/IMAPServiceInfos.cpp +++ b/src/net/imap/IMAPServiceInfos.cpp @@ -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 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; } diff --git a/src/net/pop3/POP3ServiceInfos.cpp b/src/net/pop3/POP3ServiceInfos.cpp index 54a44771..27c2a7e3 100644 --- a/src/net/pop3/POP3ServiceInfos.cpp +++ b/src/net/pop3/POP3ServiceInfos.cpp @@ -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 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; } diff --git a/src/net/pop3/POP3Store.cpp b/src/net/pop3/POP3Store.cpp index 4c3ba224..1b15c9f6 100644 --- a/src/net/pop3/POP3Store.cpp +++ b/src/net/pop3/POP3Store.cpp @@ -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(); diff --git a/src/net/service.cpp b/src/net/service.cpp index 1589f3f2..8dde675a 100644 --- a/src/net/service.cpp +++ b/src/net/service.cpp @@ -123,5 +123,17 @@ ref service::getSocketFactory() } +void service::setTimeoutHandlerFactory(ref thf) +{ + m_toHandlerFactory = thf; +} + + +ref service::getTimeoutHandlerFactory() +{ + return m_toHandlerFactory; +} + + } // net } // vmime diff --git a/src/net/serviceInfos.cpp b/src/net/serviceInfos.cpp index c76744a2..624a559e 100644 --- a/src/net/serviceInfos.cpp +++ b/src/net/serviceInfos.cpp @@ -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 diff --git a/src/net/smtp/SMTPServiceInfos.cpp b/src/net/smtp/SMTPServiceInfos.cpp index 5563608d..a1d800cd 100644 --- a/src/net/smtp/SMTPServiceInfos.cpp +++ b/src/net/smtp/SMTPServiceInfos.cpp @@ -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 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; } diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp index 645f6aa2..2e6013e9 100644 --- a/src/net/smtp/SMTPTransport.cpp +++ b/src/net/smtp/SMTPTransport.cpp @@ -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(); diff --git a/src/platforms/posix/posixHandler.cpp b/src/platforms/posix/posixHandler.cpp index 8703d4c0..c8c57ce6 100644 --- a/src/platforms/posix/posixHandler.cpp +++ b/src/platforms/posix/posixHandler.cpp @@ -174,14 +174,6 @@ ref posixHandler::getSocketFactory() const return m_socketFactory.dynamicCast (); } - -vmime::net::timeoutHandlerFactory* posixHandler::getTimeoutHandlerFactory - (const vmime::string& /* name */) const -{ - // Not used by default - return (NULL); -} - #endif diff --git a/src/platforms/windows/windowsHandler.cpp b/src/platforms/windows/windowsHandler.cpp index 4f5a94b5..926ccb98 100644 --- a/src/platforms/windows/windowsHandler.cpp +++ b/src/platforms/windows/windowsHandler.cpp @@ -239,14 +239,6 @@ ref windowsHandler::getSocketFactory() const return m_socketFactory.dynamicCast (); } - -vmime::net::timeoutHandlerFactory* windowsHandler::getTimeoutHandlerFactory - (const vmime::string& /* name */) const -{ - // Not used by default - return (NULL); -} - #endif diff --git a/vmime/net/imap/IMAPServiceInfos.hpp b/vmime/net/imap/IMAPServiceInfos.hpp index 0b66bd0e..85b2012a 100644 --- a/vmime/net/imap/IMAPServiceInfos.hpp +++ b/vmime/net/imap/IMAPServiceInfos.hpp @@ -62,8 +62,6 @@ public: serviceInfos::property PROPERTY_SERVER_ADDRESS; serviceInfos::property PROPERTY_SERVER_PORT; - - serviceInfos::property PROPERTY_TIMEOUT_FACTORY; }; const props& getProperties() const; diff --git a/vmime/net/pop3/POP3ServiceInfos.hpp b/vmime/net/pop3/POP3ServiceInfos.hpp index b2c668cb..ae0b4793 100644 --- a/vmime/net/pop3/POP3ServiceInfos.hpp +++ b/vmime/net/pop3/POP3ServiceInfos.hpp @@ -64,8 +64,6 @@ public: serviceInfos::property PROPERTY_SERVER_ADDRESS; serviceInfos::property PROPERTY_SERVER_PORT; - - serviceInfos::property PROPERTY_TIMEOUT_FACTORY; }; const props& getProperties() const; diff --git a/vmime/net/service.hpp b/vmime/net/service.hpp index 5a03b789..20c2a500 100644 --- a/vmime/net/service.hpp +++ b/vmime/net/service.hpp @@ -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 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 thf); + + /** Return the factory used to create timeoutHandler objects for + * this service. + * + * @return timeoutHandler factory + */ + ref 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 m_socketFactory; + + ref m_toHandlerFactory; }; diff --git a/vmime/net/serviceInfos.hpp b/vmime/net/serviceInfos.hpp index f913f838..4564efd9 100644 --- a/vmime/net/serviceInfos.hpp +++ b/vmime/net/serviceInfos.hpp @@ -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 diff --git a/vmime/net/smtp/SMTPServiceInfos.hpp b/vmime/net/smtp/SMTPServiceInfos.hpp index dcdef9f9..3a4cbdd9 100644 --- a/vmime/net/smtp/SMTPServiceInfos.hpp +++ b/vmime/net/smtp/SMTPServiceInfos.hpp @@ -63,8 +63,6 @@ public: serviceInfos::property PROPERTY_SERVER_ADDRESS; serviceInfos::property PROPERTY_SERVER_PORT; - - serviceInfos::property PROPERTY_TIMEOUT_FACTORY; }; const props& getProperties() const; diff --git a/vmime/platformDependant.hpp b/vmime/platformDependant.hpp index 17a2656b..1c924f61 100644 --- a/vmime/platformDependant.hpp +++ b/vmime/platformDependant.hpp @@ -109,21 +109,8 @@ public: * @return socket factory */ virtual ref 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. * diff --git a/vmime/platforms/posix/posixHandler.hpp b/vmime/platforms/posix/posixHandler.hpp index d5ba1826..18a03240 100644 --- a/vmime/platforms/posix/posixHandler.hpp +++ b/vmime/platforms/posix/posixHandler.hpp @@ -62,8 +62,6 @@ public: #if VMIME_HAVE_MESSAGING_FEATURES ref getSocketFactory() const; - - vmime::net::timeoutHandlerFactory* getTimeoutHandlerFactory(const vmime::string& name) const; #endif #if VMIME_HAVE_FILESYSTEM_FEATURES diff --git a/vmime/platforms/windows/windowsHandler.hpp b/vmime/platforms/windows/windowsHandler.hpp index 4a94628f..d775ab99 100644 --- a/vmime/platforms/windows/windowsHandler.hpp +++ b/vmime/platforms/windows/windowsHandler.hpp @@ -61,8 +61,6 @@ public: #if VMIME_HAVE_MESSAGING_FEATURES ref getSocketFactory() const; - - vmime::net::timeoutHandlerFactory* getTimeoutHandlerFactory(const vmime::string& name) const; #endif #if VMIME_HAVE_FILESYSTEM_FEATURES