aboutsummaryrefslogtreecommitdiffstats
path: root/src/messaging
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/messaging/serviceFactory.cpp9
-rw-r--r--src/messaging/session.cpp28
-rw-r--r--src/messaging/session.hpp25
3 files changed, 56 insertions, 6 deletions
diff --git a/src/messaging/serviceFactory.cpp b/src/messaging/serviceFactory.cpp
index 666e052d..9d51e79b 100644
--- a/src/messaging/serviceFactory.cpp
+++ b/src/messaging/serviceFactory.cpp
@@ -62,9 +62,10 @@ service* serviceFactory::create
if (u.getPort() != url::UNSPECIFIED_PORT)
sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.port"] = u.getPort();
- // Path portion of the URL is used to point a specific folder (empty = root)
- //if (!u.path().empty())
- // sess->properties()[serv->getInfos().getPropertyPrefix() + "server.path"] = u.getPath();
+ // Path portion of the URL is used to point a specific folder (empty = root).
+ // In maildir, this is used to point to the root of the message repository.
+ if (!u.getPath().empty())
+ sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.rootpath"] = u.getPath();
if (!u.getUsername().empty())
{
@@ -87,7 +88,7 @@ const serviceFactory::registeredService* serviceFactory::getServiceByProtocol(co
return (*it);
}
- throw exceptions::no_service_available();
+ throw exceptions::no_service_available(name);
}
diff --git a/src/messaging/session.cpp b/src/messaging/session.cpp
index 76d3c07a..8edfcab4 100644
--- a/src/messaging/session.cpp
+++ b/src/messaging/session.cpp
@@ -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)
{
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
{
return (m_props);
diff --git a/src/messaging/session.hpp b/src/messaging/session.hpp
index 61e94fb1..4ee25157 100644
--- a/src/messaging/session.hpp
+++ b/src/messaging/session.hpp
@@ -23,6 +23,7 @@
#include "messaging/authenticator.hpp"
#include "messaging/progressionListener.hpp"
+#include "messaging/url.hpp"
#include "propertySet.hpp"
@@ -70,6 +71,16 @@ public:
*/
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
* in the session properties.
*
@@ -78,7 +89,7 @@ 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 transport service
+ * @return a new store service
*/
store* getStore(authenticator* auth = NULL);
@@ -88,10 +99,20 @@ 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 transport service
+ * @return a new store service
*/
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:[email protected]/")
+ * @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.
*/
const propertySet& getProperties() const;