[evolution-kolab/gnome-3-4] Bug #677102 - Backends try to connect to port 143 even if SSL encryption is configured



commit 593d2a0536ad1ab08e201f17ee5ec748d1639be3
Author: Christian Hilberg <hilberg kernelconcepts de>
Date:   Mon Jun 4 17:07:40 2012 +0200

    Bug #677102 - Backends try to connect to port 143 even if SSL encryption is configured
    
    * provide usable default fallback ports
      in KolabSettingsHandler
    * propagate port number and security
      settings through to CamelIMAPX via
      CamelNetworkSettings instead of the
      old CamelURL construct (needs further
      fixing)

 src/libekolab/kolab-mail-imap-client.c |   52 +++++++++++++++++++++++++++++++-
 src/libekolab/kolab-settings-handler.c |   14 ++++----
 2 files changed, 58 insertions(+), 8 deletions(-)
---
diff --git a/src/libekolab/kolab-mail-imap-client.c b/src/libekolab/kolab-mail-imap-client.c
index a9f772d..089a9b5 100644
--- a/src/libekolab/kolab-mail-imap-client.c
+++ b/src/libekolab/kolab-mail-imap-client.c
@@ -718,6 +718,9 @@ kolab_mail_imap_client_configure_store_settings (KolabMailImapClient *self,
 	CamelService *service = NULL;
 	CamelSettings *camel_settings = NULL;
 	CamelURL *camel_url = NULL;
+	CamelNetworkSecurityMethod security_method = CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT;
+	guint16 port = 0;
+	KolabTLSVariantID tlsvariant = KOLAB_TLS_VARIANT_NONE;
 	GError *tmp_err = NULL;
 
 	/* TODO rework this function for new CamelSettings API
@@ -752,6 +755,54 @@ kolab_mail_imap_client_configure_store_settings (KolabMailImapClient *self,
 
 	camel_settings_load_from_url (camel_settings, camel_url);
 
+	/* get the details not (or no longer) covered by
+	 * CamelURL. Should be done for all details this
+	 * way, instead of using the (deprecated) CamelURL
+	 * for this
+	 */
+
+	/* security and port settings  */
+	tlsvariant = kolab_settings_handler_get_uint_field (priv->ksettings,
+	                                                    KOLAB_SETTINGS_HANDLER_UINT_FIELD_TLS_VARIANT,
+	                                                    &tmp_err);
+	if (tmp_err != NULL) {
+		camel_url_free (camel_url);
+		g_propagate_error (err, tmp_err);
+		return FALSE;
+	}
+
+	switch (tlsvariant) {
+	case KOLAB_TLS_VARIANT_NONE:
+		security_method = CAMEL_NETWORK_SECURITY_METHOD_NONE;
+		port = (guint16)kolab_settings_handler_get_int_field (priv->ksettings,
+		                                                      KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_IMAP_PORT,
+		                                                      &tmp_err);
+		break;
+	case KOLAB_TLS_VARIANT_SSL:
+		security_method = CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT;
+		port = (guint16)kolab_settings_handler_get_int_field (priv->ksettings,
+		                                                      KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_IMAPS_PORT,
+		                                                      &tmp_err);
+		break;
+	case KOLAB_TLS_VARIANT_STARTTLS:
+	default:
+		security_method = CAMEL_NETWORK_SECURITY_METHOD_STARTTLS_ON_STANDARD_PORT;
+		port = (guint16)kolab_settings_handler_get_int_field (priv->ksettings,
+		                                                      KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_IMAP_PORT,
+		                                                      &tmp_err);
+	}
+	if (tmp_err != NULL) {
+		camel_url_free (camel_url);
+		g_propagate_error (err, tmp_err);
+		return FALSE;
+	}
+
+	/* set details */
+	camel_network_settings_set_security_method (CAMEL_NETWORK_SETTINGS (camel_settings),
+	                                            security_method);
+	camel_network_settings_set_port (CAMEL_NETWORK_SETTINGS (camel_settings),
+	                                 port);
+
 	/* re-set the settings for our service (store) */
 	camel_service_set_settings (service, camel_settings);
 
@@ -769,7 +820,6 @@ kolab_mail_imap_client_bringup (KolabMailImapClient *self,
 	CamelService *service = NULL;
 	gchar *dbpath = NULL;
 	gchar *account_uid = NULL;
-	gchar *extd_account_uid = NULL;
 	GError *tmp_err = NULL;
 	gboolean ok = FALSE;
 
diff --git a/src/libekolab/kolab-settings-handler.c b/src/libekolab/kolab-settings-handler.c
index 3b14670..d0bf10f 100644
--- a/src/libekolab/kolab-settings-handler.c
+++ b/src/libekolab/kolab-settings-handler.c
@@ -332,14 +332,14 @@ kolab_settings_handler_init (KolabSettingsHandler *object)
 	for (ii = 0; ii < KOLAB_SETTINGS_HANDLER_BOOL_LAST_FIELD; ii++)
 		priv->sdata_bool[ii] = FALSE;
 
-	/* documenting initial settings */
+	/* documenting initial settings (dumb fallback values) */
 	priv->sdata_uint[KOLAB_SETTINGS_HANDLER_UINT_FIELD_FOLDER_CONTEXT] = KOLAB_FOLDER_CONTEXT_INVAL;
-	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_IMAP_PORT]  = -1;
-	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_IMAPS_PORT] = -1;
-	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_HTTP_PORT]  = -1;
-	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_HTTPS_PORT] = -1;
-	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_LDAP_PORT]  = -1;
-	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_LDAPS_PORT] = -1;
+	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_IMAP_PORT]  = 143;
+	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_IMAPS_PORT] = 993;
+	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_HTTP_PORT]  = 80;
+	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_HTTPS_PORT] = 443;
+	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_LDAP_PORT]  = 389;
+	priv->sdata_int[KOLAB_SETTINGS_HANDLER_INT_FIELD_KOLAB_SERVER_LDAPS_PORT] = 636;
 
 	priv->sdata_tbl = NULL;
 



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