aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--src/net/imap/IMAPConnection.cpp5
-rw-r--r--src/net/imap/IMAPServiceInfos.cpp3
-rw-r--r--src/net/pop3/POP3ServiceInfos.cpp3
-rw-r--r--src/net/pop3/POP3Store.cpp13
-rw-r--r--src/net/service.cpp15
-rw-r--r--src/net/serviceInfos.cpp3
-rw-r--r--src/net/smtp/SMTPServiceInfos.cpp3
-rw-r--r--src/net/smtp/SMTPTransport.cpp5
-rw-r--r--src/platforms/posix/posixHandler.cpp10
-rw-r--r--src/platforms/windows/windowsHandler.cpp10
-rw-r--r--vmime/net/imap/IMAPServiceInfos.hpp1
-rw-r--r--vmime/net/pop3/POP3ServiceInfos.hpp1
-rw-r--r--vmime/net/service.hpp17
-rw-r--r--vmime/net/serviceInfos.hpp5
-rw-r--r--vmime/net/smtp/SMTPServiceInfos.hpp1
-rw-r--r--vmime/net/socket.hpp2
-rw-r--r--vmime/net/timeoutHandler.hpp2
-rw-r--r--vmime/platformDependant.hpp12
-rw-r--r--vmime/platforms/posix/posixHandler.hpp4
-rw-r--r--vmime/platforms/windows/windowsHandler.hpp4
21 files changed, 60 insertions, 65 deletions
diff --git a/ChangeLog b/ChangeLog
index a4775a5c..948352ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
VERSION 0.7.2cvs
================
+2005-10-04 Vincent Richard <[email protected]>
+
+ * 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 <[email protected]>
* Added TLS/SSL support, using GNU TLS library.
diff --git a/src/net/imap/IMAPConnection.cpp b/src/net/imap/IMAPConnection.cpp
index b0716f45..180caa4b 100644
--- a/src/net/imap/IMAPConnection.cpp
+++ b/src/net/imap/IMAPConnection.cpp
@@ -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
diff --git a/src/net/imap/IMAPServiceInfos.cpp b/src/net/imap/IMAPServiceInfos.cpp
index d8164ce1..a5d1ca5a 100644
--- a/src/net/imap/IMAPServiceInfos.cpp
+++ b/src/net/imap/IMAPServiceInfos.cpp
@@ -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);
diff --git a/src/net/pop3/POP3ServiceInfos.cpp b/src/net/pop3/POP3ServiceInfos.cpp
index 52387c5d..54a44771 100644
--- a/src/net/pop3/POP3ServiceInfos.cpp
+++ b/src/net/pop3/POP3ServiceInfos.cpp
@@ -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);
diff --git a/src/net/pop3/POP3Store.cpp b/src/net/pop3/POP3Store.cpp
index 4f373268..4c3ba224 100644
--- a/src/net/pop3/POP3Store.cpp
+++ b/src/net/pop3/POP3Store.cpp
@@ -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);
}
}
diff --git a/src/net/service.cpp b/src/net/service.cpp
index 35e8aa55..1589f3f2 100644
--- a/src/net/service.cpp
+++ b/src/net/service.cpp
@@ -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
diff --git a/src/net/serviceInfos.cpp b/src/net/serviceInfos.cpp
index 306c1ec3..c76744a2 100644
--- a/src/net/serviceInfos.cpp
+++ b/src/net/serviceInfos.cpp
@@ -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);
diff --git a/src/net/smtp/SMTPServiceInfos.cpp b/src/net/smtp/SMTPServiceInfos.cpp
index 1f0bca6c..5563608d 100644
--- a/src/net/smtp/SMTPServiceInfos.cpp
+++ b/src/net/smtp/SMTPServiceInfos.cpp
@@ -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);
diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp
index d0c72a13..645f6aa2 100644
--- a/src/net/smtp/SMTPTransport.cpp
+++ b/src/net/smtp/SMTPTransport.cpp
@@ -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
diff --git a/src/platforms/posix/posixHandler.cpp b/src/platforms/posix/posixHandler.cpp
index ef7e55cc..8703d4c0 100644
--- a/src/platforms/posix/posixHandler.cpp
+++ b/src/platforms/posix/posixHandler.cpp
@@ -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>();
}
diff --git a/src/platforms/windows/windowsHandler.cpp b/src/platforms/windows/windowsHandler.cpp
index d67b9d5a..4f5a94b5 100644
--- a/src/platforms/windows/windowsHandler.cpp
+++ b/src/platforms/windows/windowsHandler.cpp
@@ -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>();
}
diff --git a/vmime/net/imap/IMAPServiceInfos.hpp b/vmime/net/imap/IMAPServiceInfos.hpp
index 67ef0980..0b66bd0e 100644
--- a/vmime/net/imap/IMAPServiceInfos.hpp
+++ b/vmime/net/imap/IMAPServiceInfos.hpp
@@ -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;
};
diff --git a/vmime/net/pop3/POP3ServiceInfos.hpp b/vmime/net/pop3/POP3ServiceInfos.hpp
index 04f14b78..b2c668cb 100644
--- a/vmime/net/pop3/POP3ServiceInfos.hpp
+++ b/vmime/net/pop3/POP3ServiceInfos.hpp
@@ -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;
};
diff --git a/vmime/net/service.hpp b/vmime/net/service.hpp
index 8025ebd9..5a03b789 100644
--- a/vmime/net/service.hpp
+++ b/vmime/net/service.hpp
@@ -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;
};
diff --git a/vmime/net/serviceInfos.hpp b/vmime/net/serviceInfos.hpp
index 14657b2b..f913f838 100644
--- a/vmime/net/serviceInfos.hpp
+++ b/vmime/net/serviceInfos.hpp
@@ -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;
diff --git a/vmime/net/smtp/SMTPServiceInfos.hpp b/vmime/net/smtp/SMTPServiceInfos.hpp
index ac3ae372..dcdef9f9 100644
--- a/vmime/net/smtp/SMTPServiceInfos.hpp
+++ b/vmime/net/smtp/SMTPServiceInfos.hpp
@@ -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;
};
diff --git a/vmime/net/socket.hpp b/vmime/net/socket.hpp
index 1d61e0dc..a0c2608c 100644
--- a/vmime/net/socket.hpp
+++ b/vmime/net/socket.hpp
@@ -99,7 +99,7 @@ private:
/** A class to create 'socket' objects.
*/
-class socketFactory
+class socketFactory : public object
{
public:
diff --git a/vmime/net/timeoutHandler.hpp b/vmime/net/timeoutHandler.hpp
index 5f8bcc59..ae43a9de 100644
--- a/vmime/net/timeoutHandler.hpp
+++ b/vmime/net/timeoutHandler.hpp
@@ -64,7 +64,7 @@ public:
/** A class to create 'timeoutHandler' objects.
*/
-class timeoutHandlerFactory
+class timeoutHandlerFactory : public object
{
public:
diff --git a/vmime/platformDependant.hpp b/vmime/platformDependant.hpp
index a09161ef..17a2656b 100644
--- a/vmime/platformDependant.hpp
+++ b/vmime/platformDependant.hpp
@@ -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
diff --git a/vmime/platforms/posix/posixHandler.hpp b/vmime/platforms/posix/posixHandler.hpp
index bb8ef359..d5ba1826 100644
--- a/vmime/platforms/posix/posixHandler.hpp
+++ b/vmime/platforms/posix/posixHandler.hpp
@@ -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
diff --git a/vmime/platforms/windows/windowsHandler.hpp b/vmime/platforms/windows/windowsHandler.hpp
index df2cb6c0..4a94628f 100644
--- a/vmime/platforms/windows/windowsHandler.hpp
+++ b/vmime/platforms/windows/windowsHandler.hpp
@@ -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