Allow creating a service from an URL.
This commit is contained in:
parent
057e8a4cfa
commit
f5f15e5076
@ -10,6 +10,9 @@ VERSION 0.6.1-cvs
|
|||||||
|
|
||||||
* Added versioning in library name (eg. libvmime-0.6.a).
|
* Added versioning in library name (eg. libvmime-0.6.a).
|
||||||
|
|
||||||
|
* Allow creating a service from an URL (session::getStore("url") and
|
||||||
|
session::getTransport("url"))
|
||||||
|
|
||||||
2004-12-24 Vincent Richard <vincent@vincent-richard.net>
|
2004-12-24 Vincent Richard <vincent@vincent-richard.net>
|
||||||
|
|
||||||
* Renamed class 'disposition' to 'contentDisposition' and the enum
|
* Renamed class 'disposition' to 'contentDisposition' and the enum
|
||||||
|
@ -355,8 +355,10 @@ const string unsupported_option::name() const { return "unsupported_option"; }
|
|||||||
//
|
//
|
||||||
|
|
||||||
no_service_available::~no_service_available() throw() {}
|
no_service_available::~no_service_available() throw() {}
|
||||||
no_service_available::no_service_available(const exception& other)
|
no_service_available::no_service_available(const string& proto, const exception& other)
|
||||||
: messaging_exception("No service available for this protocol.", other) {}
|
: messaging_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); }
|
exception* no_service_available::clone() const { return new no_service_available(*this); }
|
||||||
const string no_service_available::name() const { return "no_service_available"; }
|
const string no_service_available::name() const { return "no_service_available"; }
|
||||||
|
@ -399,7 +399,7 @@ class no_service_available : public messaging_exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
no_service_available(const exception& other = NO_EXCEPTION);
|
no_service_available(const string& proto = "", const exception& other = NO_EXCEPTION);
|
||||||
~no_service_available() throw();
|
~no_service_available() throw();
|
||||||
|
|
||||||
exception* clone() const;
|
exception* clone() const;
|
||||||
|
@ -62,9 +62,10 @@ service* serviceFactory::create
|
|||||||
if (u.getPort() != url::UNSPECIFIED_PORT)
|
if (u.getPort() != url::UNSPECIFIED_PORT)
|
||||||
sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.port"] = u.getPort();
|
sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.port"] = u.getPort();
|
||||||
|
|
||||||
// Path portion of the URL is used to point a specific folder (empty = root)
|
// Path portion of the URL is used to point a specific folder (empty = root).
|
||||||
//if (!u.path().empty())
|
// In maildir, this is used to point to the root of the message repository.
|
||||||
// sess->properties()[serv->getInfos().getPropertyPrefix() + "server.path"] = u.getPath();
|
if (!u.getPath().empty())
|
||||||
|
sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.rootpath"] = u.getPath();
|
||||||
|
|
||||||
if (!u.getUsername().empty())
|
if (!u.getUsername().empty())
|
||||||
{
|
{
|
||||||
@ -87,7 +88,7 @@ const serviceFactory::registeredService* serviceFactory::getServiceByProtocol(co
|
|||||||
return (*it);
|
return (*it);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw exceptions::no_service_available();
|
throw exceptions::no_service_available(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,6 +64,20 @@ transport* session::getTransport(const string& protocol, authenticator* auth)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
transport* session::getTransport(const messaging::url& url, authenticator* auth)
|
||||||
|
{
|
||||||
|
service* sv = serviceFactory::getInstance()->create(this, url, auth);
|
||||||
|
|
||||||
|
if (sv->getType() != service::TYPE_TRANSPORT)
|
||||||
|
{
|
||||||
|
delete (sv);
|
||||||
|
throw exceptions::no_service_available();
|
||||||
|
}
|
||||||
|
|
||||||
|
return static_cast<transport*>(sv);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
store* session::getStore(authenticator* auth)
|
store* session::getStore(authenticator* auth)
|
||||||
{
|
{
|
||||||
return (getStore(m_props["store.protocol"], auth));
|
return (getStore(m_props["store.protocol"], auth));
|
||||||
@ -84,6 +98,20 @@ store* session::getStore(const string& protocol, authenticator* auth)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
store* session::getStore(const messaging::url& url, authenticator* auth)
|
||||||
|
{
|
||||||
|
service* sv = serviceFactory::getInstance()->create(this, url, auth);
|
||||||
|
|
||||||
|
if (sv->getType() != service::TYPE_STORE)
|
||||||
|
{
|
||||||
|
delete (sv);
|
||||||
|
throw exceptions::no_service_available();
|
||||||
|
}
|
||||||
|
|
||||||
|
return static_cast<store*>(sv);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const propertySet& session::getProperties() const
|
const propertySet& session::getProperties() const
|
||||||
{
|
{
|
||||||
return (m_props);
|
return (m_props);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "messaging/authenticator.hpp"
|
#include "messaging/authenticator.hpp"
|
||||||
#include "messaging/progressionListener.hpp"
|
#include "messaging/progressionListener.hpp"
|
||||||
|
#include "messaging/url.hpp"
|
||||||
|
|
||||||
#include "propertySet.hpp"
|
#include "propertySet.hpp"
|
||||||
|
|
||||||
@ -70,6 +71,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
transport* getTransport(const string& protocol, authenticator* auth = NULL);
|
transport* getTransport(const string& protocol, authenticator* auth = NULL);
|
||||||
|
|
||||||
|
/** Return a transport service instance for the specified URL.
|
||||||
|
*
|
||||||
|
* @param url full URL with at least the protocol to use (eg: "smtp://myserver.com/")
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
transport* getTransport(const messaging::url& url, authenticator* auth = NULL);
|
||||||
|
|
||||||
/** Return a transport service instance for the protocol specified
|
/** Return a transport service instance for the protocol specified
|
||||||
* in the session properties.
|
* in the session properties.
|
||||||
*
|
*
|
||||||
@ -78,7 +89,7 @@ public:
|
|||||||
* @param auth authenticator object to use for the new store service. If
|
* @param auth authenticator object to use for the new store service. If
|
||||||
* NULL, a default one is used. The default authenticator simply return user
|
* NULL, a default one is used. The default authenticator simply return user
|
||||||
* credentials by reading the session properties "auth.username" and "auth.password".
|
* credentials by reading the session properties "auth.username" and "auth.password".
|
||||||
* @return a new transport service
|
* @return a new store service
|
||||||
*/
|
*/
|
||||||
store* getStore(authenticator* auth = NULL);
|
store* getStore(authenticator* auth = NULL);
|
||||||
|
|
||||||
@ -88,10 +99,20 @@ public:
|
|||||||
* @param auth authenticator object to use for the new store service. If
|
* @param auth authenticator object to use for the new store service. If
|
||||||
* NULL, a default one is used. The default authenticator simply return user
|
* NULL, a default one is used. The default authenticator simply return user
|
||||||
* credentials by reading the session properties "auth.username" and "auth.password".
|
* credentials by reading the session properties "auth.username" and "auth.password".
|
||||||
* @return a new transport service
|
* @return a new store service
|
||||||
*/
|
*/
|
||||||
store* getStore(const string& protocol, authenticator* auth = NULL);
|
store* getStore(const string& protocol, authenticator* auth = NULL);
|
||||||
|
|
||||||
|
/** Return a store service instance for the specified URL.
|
||||||
|
*
|
||||||
|
* @param url full URL with at least the protocol to use (eg: "imap://username:password@myserver.com/")
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
store* getStore(const messaging::url& url, authenticator* auth = NULL);
|
||||||
|
|
||||||
/** Properties for the session and for the services.
|
/** Properties for the session and for the services.
|
||||||
*/
|
*/
|
||||||
const propertySet& getProperties() const;
|
const propertySet& getProperties() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user