aboutsummaryrefslogtreecommitdiffstats
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
parent8034bd125495a5b1adcd2449534d1d2208bd96e8 (diff)
downloadgsoc2013-evolution-64edd4d5dee866e1fb793f04c54a7c810c2c020d.tar
gsoc2013-evolution-64edd4d5dee866e1fb793f04c54a7c810c2c020d.tar.gz
gsoc2013-evolution-64edd4d5dee866e1fb793f04c54a7c810c2c020d.tar.bz2
gsoc2013-evolution-64edd4d5dee866e1fb793f04c54a7c810c2c020d.tar.lz
gsoc2013-evolution-64edd4d5dee866e1fb793f04c54a7c810c2c020d.tar.xz
gsoc2013-evolution-64edd4d5dee866e1fb793f04c54a7c810c2c020d.tar.zst
gsoc2013-evolution-64edd4d5dee866e1fb793f04c54a7c810c2c020d.zip
add camel_session_get_transport_for_protocol
svn path=/trunk/; revision=1922
-rw-r--r--camel/ChangeLog2
-rw-r--r--camel/camel-session.c43
-rw-r--r--camel/camel-session.h3
3 files changed, 48 insertions, 0 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 4166f9b7c0..0a45793135 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,5 +1,7 @@
2000-02-24 Dan Winship <danw@helixcode.com>
+ * camel-session.c: Add camel_session_get_transport_for_protocol.
+
* camel-transport.h:
* camel-transport.c: Add an abstract CamelTransport class.
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));
+}
diff --git a/camel/camel-session.h b/camel/camel-session.h
index 272417644c..838731b03c 100644
--- a/camel/camel-session.h
+++ b/camel/camel-session.h
@@ -83,6 +83,9 @@ CamelStore *camel_session_get_store_for_protocol (CamelSession *session,
CamelStore *camel_session_get_store (CamelSession *session,
const char *url_string,
CamelException *ex);
+CamelTransport *camel_session_get_transport_for_protocol (CamelSession *session,
+ const char *protocol,
+ CamelException *ex);
char *camel_session_query_authenticator (CamelSession *session, char *prompt,
gboolean secret,
CamelService *service, char *item,