diff options
-rw-r--r-- | camel/ChangeLog | 2 | ||||
-rw-r--r-- | camel/camel-session.c | 43 | ||||
-rw-r--r-- | camel/camel-session.h | 3 |
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, |