aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-session.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-02-25 05:19:05 +0800
committerDan Winship <danw@src.gnome.org>2000-02-25 05:19:05 +0800
commit64edd4d5dee866e1fb793f04c54a7c810c2c020d (patch)
treec2c46fb7d6bf2b25a128460d39c65bc20ca53cac /camel/camel-session.c
parent8034bd125495a5b1adcd2449534d1d2208bd96e8 (diff)
downloadgsoc2013-evolution-64edd4d5dee866e1fb793f04c54a7c810c2c020d.tar.gz
gsoc2013-evolution-64edd4d5dee866e1fb793f04c54a7c810c2c020d.tar.zst
gsoc2013-evolution-64edd4d5dee866e1fb793f04c54a7c810c2c020d.zip
add camel_session_get_transport_for_protocol
svn path=/trunk/; revision=1922
Diffstat (limited to 'camel/camel-session.c')
-rw-r--r--camel/camel-session.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/camel/camel-session.c b/camel/camel-session.c
index f014d46596..6b93cc1d3f 100644
--- a/camel/camel-session.c
+++ b/camel/camel-session.c
@@ -26,6 +26,7 @@
#include <config.h>
#include "camel-session.h"
#include "camel-store.h"
+#include "camel-transport.h"
#include "camel-exception.h"
#include "string-utils.h"
#include "url-util.h"
@@ -277,3 +278,45 @@ camel_session_query_authenticator (CamelSession *session, char *prompt,
{
return session->authenticator (prompt, secret, service, item, ex);
}
+
+
+
+/**
+ * camel_session_get_transport_for_protocol: get the transport for a protocol
+ * @session: the session
+ * @protocol: protocol name
+ * @ex: a CamelException
+ *
+ * Return a CamelTransport object associated with a given transport
+ * protocol. If a provider has been set for this protocol in the
+ * session @session using camel_session_set_provider (), then a transport
+ * obtained from this provider is returned. Otherwise, if one or more
+ * providers corresponding to this protocol have been registered (See
+ * camel_provider_register_as_module), the last registered one is
+ * used.
+ *
+ * Return value: transport associated with this protocol, or NULL if no provider was found.
+ **/
+CamelTransport *
+camel_session_get_transport_for_protocol (CamelSession *session,
+ const char *protocol,
+ CamelException *ex)
+{
+ const CamelProvider *provider = NULL;
+
+ /* See if there is a provider assiciated with this
+ * protocol in this session.
+ */
+ provider = CAMEL_PROVIDER (g_hash_table_lookup (session->transport_provider_list, protocol));
+ if (!provider) {
+ /* No provider was found in this session. See
+ * if there is a registered provider for this
+ * protocol.
+ */
+ provider = camel_provider_get_for_protocol (protocol, PROVIDER_TRANSPORT);
+ }
+ if (!provider)
+ return NULL;
+
+ return CAMEL_TRANSPORT (gtk_object_new (provider->object_type, NULL));
+}