[evolution-kolab/account-mgmt: 27/29] Add camel_kolab_imapx_settings_build_url().



commit 57c04bc2ea7b0307dbca4dcee6d23becbb995ef5
Author: Matthew Barnes <mbarnes redhat com>
Date:   Sun Jul 1 17:34:42 2012 -0400

    Add camel_kolab_imapx_settings_build_url().
    
    Returns a CamelURL built from CamelNetworkSettings.

 src/libekolab/camel-kolab-imapx-settings.c |   38 ++++++++++++++++++++++++++++
 src/libekolab/camel-kolab-imapx-settings.h |    3 ++
 2 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/src/libekolab/camel-kolab-imapx-settings.c b/src/libekolab/camel-kolab-imapx-settings.c
index d3f0d5b..711e9b9 100644
--- a/src/libekolab/camel-kolab-imapx-settings.c
+++ b/src/libekolab/camel-kolab-imapx-settings.c
@@ -124,6 +124,44 @@ camel_kolab_imapx_settings_class_init (CamelKolabIMAPXSettingsClass *klass)
 /*----------------------------------------------------------------------------*/
 /* API functions */
 
+CamelURL *
+camel_kolab_imapx_settings_build_url (CamelKolabIMAPXSettings *settings)
+{
+	CamelURL *url;
+	CamelNetworkSettings *network_settings;
+	CamelNetworkSecurityMethod method;
+	const gchar *host;
+	const gchar *user;
+	guint16 port;
+
+	g_return_val_if_fail (CAMEL_IS_KOLAB_IMAPX_SETTINGS (settings), NULL);
+
+	network_settings = CAMEL_NETWORK_SETTINGS (settings);
+
+	host = camel_network_settings_get_host (network_settings);
+	port = camel_network_settings_get_port (network_settings);
+	user = camel_network_settings_get_user (network_settings);
+	method = camel_network_settings_get_security_method (network_settings);
+
+	url = g_new0 (CamelURL, 1);
+
+	switch (method) {
+		case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT:
+		case CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT:
+			camel_url_set_protocol (url, "https");
+			break;
+		default:
+			camel_url_set_protocol (url, "http");
+			break;
+	}
+
+	camel_url_set_host (url, host);
+	camel_url_set_port (url, port);
+	camel_url_set_user (url, user);
+
+	return url;
+}
+
 KolabSyncStrategyID
 camel_kolab_imapx_settings_get_sync_strategy (CamelKolabIMAPXSettings *settings)
 {
diff --git a/src/libekolab/camel-kolab-imapx-settings.h b/src/libekolab/camel-kolab-imapx-settings.h
index 0d0d1c6..8ad6020 100644
--- a/src/libekolab/camel-kolab-imapx-settings.h
+++ b/src/libekolab/camel-kolab-imapx-settings.h
@@ -75,6 +75,9 @@ struct _CamelKolabIMAPXSettingsClass {
 GType
 camel_kolab_imapx_settings_get_type (void);
 
+CamelURL *
+camel_kolab_imapx_settings_build_url (CamelKolabIMAPXSettings *settings);
+
 KolabSyncStrategyID
 camel_kolab_imapx_settings_get_sync_strategy (CamelKolabIMAPXSettings *settings);
 void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]