diff --git a/src/exception.cpp b/src/exception.cpp index bf37de00..3ea6e25a 100644 --- a/src/exception.cpp +++ b/src/exception.cpp @@ -428,20 +428,6 @@ exception* unsupported_option::clone() const { return new unsupported_option(*th const char* unsupported_option::name() const throw() { return "unsupported_option"; } -// -// no_service_available -// - -no_service_available::~no_service_available() throw() {} -no_service_available::no_service_available(const string& proto, const exception& other) - : net_exception(proto.empty() - ? "No service available for this protocol." - : "No service available for this protocol: '" + proto + "'.", other) {} - -exception* no_service_available::clone() const { return new no_service_available(*this); } -const char* no_service_available::name() const throw() { return "no_service_available"; } - - // // illegal_state // diff --git a/src/net/serviceFactory.cpp b/src/net/serviceFactory.cpp index a16098ce..98aee646 100644 --- a/src/net/serviceFactory.cpp +++ b/src/net/serviceFactory.cpp @@ -101,7 +101,7 @@ shared_ptr serviceFactory::getServiceB return (*it); } - throw exceptions::no_service_available(name); + return null; } diff --git a/src/net/session.cpp b/src/net/session.cpp index fcc5dd12..36b9f2c3 100644 --- a/src/net/session.cpp +++ b/src/net/session.cpp @@ -74,8 +74,8 @@ shared_ptr session::getTransport shared_ptr sess(dynamicCast (shared_from_this())); shared_ptr sv = serviceFactory::getInstance()->create(sess, protocol, auth); - if (sv->getType() != service::TYPE_TRANSPORT) - throw exceptions::no_service_available(); + if (!sv || sv->getType() != service::TYPE_TRANSPORT) + return null; return dynamicCast (sv); } @@ -87,8 +87,8 @@ shared_ptr session::getTransport shared_ptr sess(dynamicCast (shared_from_this())); shared_ptr sv = serviceFactory::getInstance()->create(sess, url, auth); - if (sv->getType() != service::TYPE_TRANSPORT) - throw exceptions::no_service_available(); + if (!sv || sv->getType() != service::TYPE_TRANSPORT) + return null; return dynamicCast (sv); } @@ -106,8 +106,8 @@ shared_ptr session::getStore shared_ptr sess(dynamicCast (shared_from_this())); shared_ptr sv = serviceFactory::getInstance()->create(sess, protocol, auth); - if (sv->getType() != service::TYPE_STORE) - throw exceptions::no_service_available(); + if (!sv || sv->getType() != service::TYPE_STORE) + return null; return dynamicCast (sv); } @@ -119,8 +119,8 @@ shared_ptr session::getStore shared_ptr sess(dynamicCast (shared_from_this())); shared_ptr sv = serviceFactory::getInstance()->create(sess, url, auth); - if (sv->getType() != service::TYPE_STORE) - throw exceptions::no_service_available(); + if (!sv || sv->getType() != service::TYPE_STORE) + return null; return dynamicCast (sv); } diff --git a/vmime/exception.hpp b/vmime/exception.hpp index d39ac2a2..f1a5e1a3 100644 --- a/vmime/exception.hpp +++ b/vmime/exception.hpp @@ -492,21 +492,6 @@ public: }; -/** No service available for this protocol. - */ - -class VMIME_EXPORT no_service_available : public net_exception -{ -public: - - no_service_available(const string& proto = "", const exception& other = NO_EXCEPTION); - ~no_service_available() throw(); - - exception* clone() const; - const char* name() const throw(); -}; - - /** The current state of the object does not permit to execute the * operation (for example, you try to close a folder which is not open). */ diff --git a/vmime/net/serviceFactory.hpp b/vmime/net/serviceFactory.hpp index baf692a8..9295b345 100644 --- a/vmime/net/serviceFactory.hpp +++ b/vmime/net/serviceFactory.hpp @@ -101,9 +101,8 @@ public: * @param sess session * @param protocol protocol name (eg. "pop3") * @param auth authenticator used to provide credentials (can be NULL if not used) - * @return a new service instance for the specified protocol - * @throw exceptions::no_service_available if no service is registered - * for this protocol + * @return a new service instance for the specified protocol, or NULL if no service + * is registered for this protocol */ shared_ptr create (shared_ptr sess, @@ -116,9 +115,8 @@ public: * @param u full URL with at least protocol and server (you can also specify * port, username and password) * @param auth authenticator used to provide credentials (can be NULL if not used) - * @return a new service instance for the specified protocol - * @throw exceptions::no_service_available if no service is registered - * for this protocol + * @return a new service instance for the specified protocol or NULL if no service + * is registered for this protocol */ shared_ptr create (shared_ptr sess, @@ -128,8 +126,7 @@ public: /** Return information about a registered protocol. * * @param protocol protocol name - * @return information about this protocol - * @throw exceptions::no_service_available if no service is registered + * @return information about this protocol, or NULL if no service is registered * for this protocol */ shared_ptr getServiceByProtocol(const string& protocol) const; diff --git a/vmime/net/session.hpp b/vmime/net/session.hpp index 59337879..a7e0ea1a 100644 --- a/vmime/net/session.hpp +++ b/vmime/net/session.hpp @@ -70,7 +70,8 @@ public: * @param auth authenticator object to use for the new transport service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". - * @return a new transport service + * @return a new transport service, or NULL if no service is registered for this + * protocol or is not a transport protocol */ shared_ptr getTransport (shared_ptr auth = null); @@ -81,7 +82,8 @@ public: * @param auth authenticator object to use for the new transport service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". - * @return a new transport service + * @return a new transport service, or NULL if no service is registered for this + * protocol or is not a transport protocol */ shared_ptr getTransport (const string& protocol, @@ -93,7 +95,8 @@ public: * @param auth authenticator object to use for the new transport service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". - * @return a new transport service + * @return a new transport service, or NULL if no service is registered for this + * protocol or is not a transport protocol */ shared_ptr getTransport (const utility::url& url, @@ -107,7 +110,8 @@ public: * @param auth authenticator object to use for the new store service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". - * @return a new store service + * @return a new store service, or NULL if no service is registered for this + * protocol or is not a store protocol */ shared_ptr getStore(shared_ptr auth = null); @@ -117,7 +121,8 @@ public: * @param auth authenticator object to use for the new store service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". - * @return a new store service + * @return a new store service, or NULL if no service is registered for this + * protocol or is not a store protocol */ shared_ptr getStore (const string& protocol, @@ -129,7 +134,8 @@ public: * @param auth authenticator object to use for the new store service. If * NULL, a default one is used. The default authenticator simply return user * credentials by reading the session properties "auth.username" and "auth.password". - * @return a new store service + * @return a new store service, or NULL if no service is registered for this + * protocol or is not a store protocol */ shared_ptr getStore (const utility::url& url,