[evolution-kolab] EPlugin: added configurable port number for backend connections
- From: Christian Hilberg <chilberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] EPlugin: added configurable port number for backend connections
- Date: Wed, 6 Jun 2012 15:06:37 +0000 (UTC)
commit 45def361497ab4e5ab17d28cd7bfbaa4ea43e637
Author: Christian Hilberg <hilberg kernelconcepts de>
Date: Wed Jun 6 14:26:17 2012 +0200
EPlugin: added configurable port number for backend connections
* when setting up a new backend config, a port
number can now be set alongside the encryption
method (None, SSL, STARTTLS)
* when changing the encryption method, the port
number is set to the default port for that
method, but can be edited afterwards
src/eplugin/e-kolab-account-setup.c | 74 ++++++++++++++++++++++++++++++++--
1 files changed, 69 insertions(+), 5 deletions(-)
---
diff --git a/src/eplugin/e-kolab-account-setup.c b/src/eplugin/e-kolab-account-setup.c
index 2f72b25..aff26fb 100644
--- a/src/eplugin/e-kolab-account-setup.c
+++ b/src/eplugin/e-kolab-account-setup.c
@@ -71,10 +71,16 @@ typedef struct {
GtkEntry *kolab_foldername;
GtkComboBoxText *kolab_conflict_strategy;
GtkComboBoxText *encryption_method;
+ gboolean *encryption_method_changed;
+ GtkSpinButton *port_number;
GtkCheckButton *require_pkcs11_infrastructure;
GtkEntry *pkcs11_pin;
} kolab_ui_data;
+static gint tls_variant_to_imap_port_map[] = { KOLAB_SERVER_IMAP_PORT, /* KOLAB_TLS_VARIANT_NONE */
+ KOLAB_SERVER_IMAPS_PORT, /* KOLAB_TLS_VARIANT_SSL */
+ KOLAB_SERVER_IMAP_PORT /* KOLAB_TLS_VARIANT_STARTTLS */ };
+
/*----------------------------------------------------------------------------*/
/* internal statics (non-UI) */
@@ -121,11 +127,13 @@ set_ui_from_source (kolab_ui_data *uidata)
const gchar *path = NULL;
const gchar *sync_prop = NULL;
const gchar *enc_prop = NULL;
+ const gchar *port_prop = NULL;
const gchar *req_pkcs11_prop = NULL;
const gchar *pin_prop = NULL;
KolabSyncStrategyID sync_value = KOLAB_SYNC_STRATEGY_DEFAULT;
KolabTLSVariantID enc_value = KOLAB_TLS_VARIANT_DEFAULT;
KolabReqPkcs11 req_pkcs11_value;
+ gint port_value = 0;
CamelURL *c_url = NULL;
GError *tmp_error = NULL;
@@ -135,9 +143,11 @@ set_ui_from_source (kolab_ui_data *uidata)
kolab_uri = e_source_get_uri (source);
sync_prop = e_source_get_property (source, KOLAB_SYNC_STRATEGY_PROP);
- enc_prop = e_source_get_property (source, KOLAB_TLS_VARIANT_PROP);
sync_value = kolab_util_misc_sync_value_from_property (sync_prop);
+ enc_prop = e_source_get_property (source, KOLAB_TLS_VARIANT_PROP);
enc_value = kolab_util_misc_tls_variant_from_property (enc_prop);
+ port_prop = e_source_get_property (source, KOLAB_PORT_NUMBER_PROP);
+ port_value = kolab_util_misc_port_number_from_property (port_prop);
req_pkcs11_prop = e_source_get_property (source, KOLAB_REQ_PKCS11_PROP);
req_pkcs11_value = kolab_util_misc_req_pkcs11_from_property (req_pkcs11_prop);
pin_prop = e_source_get_property (source, KOLAB_PKCS11_PIN_PROP);
@@ -169,12 +179,17 @@ set_ui_from_source (kolab_ui_data *uidata)
if (pin_prop != NULL)
gtk_entry_set_text (uidata->pkcs11_pin, pin_prop);
+ if (port_value < 0)
+ port_value = tls_variant_to_imap_port_map[enc_value];
+ gtk_spin_button_set_value (uidata->port_number, port_value);
+
/* Encryption settings */
if (uidata->is_new) {
gtk_widget_set_sensitive (GTK_WIDGET (uidata->encryption_method), TRUE);
- }
- else {
+ gtk_widget_set_sensitive (GTK_WIDGET (uidata->port_number), TRUE);
+ } else {
gtk_widget_set_sensitive (GTK_WIDGET (uidata->encryption_method), FALSE);
+ gtk_widget_set_sensitive (GTK_WIDGET (uidata->port_number), FALSE);
}
if (uidata->is_new && (enc_value > KOLAB_TLS_VARIANT_NONE)) {
gtk_widget_set_sensitive (GTK_WIDGET (uidata->require_pkcs11_infrastructure), TRUE);
@@ -211,9 +226,11 @@ set_source_from_ui (kolab_ui_data *uidata,
const gchar *pin_prop = NULL;
gchar *sync_prop = NULL;
gchar *enc_prop = NULL;
+ gchar *port_prop = NULL;
gchar *req_pkcs11_prop = NULL;
gint sync_value;
gint enc_value;
+ gint port_value;
gint req_pkcs11_value;
gchar *kolab_uri = NULL;
gchar *username_encoded = NULL;
@@ -235,6 +252,16 @@ set_source_from_ui (kolab_ui_data *uidata,
}
enc_prop = g_strdup_printf ("%u", enc_value);
+ if (uidata->encryption_method_changed) {
+ port_value = tls_variant_to_imap_port_map[enc_value];
+ gtk_spin_button_set_value (uidata->port_number,
+ (gdouble)port_value);
+ uidata->encryption_method_changed = FALSE;
+ } else {
+ port_value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (uidata->port_number));
+ }
+ port_prop = g_strdup_printf ("%u", port_value);
+
req_pkcs11_value = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (uidata->require_pkcs11_infrastructure));
if (enc_value < 0) {
enc_value = KOLAB_PKCS11_INFRASTRUCTURE_DEFAULT;
@@ -264,6 +291,7 @@ set_source_from_ui (kolab_ui_data *uidata,
e_source_set_property (uidata->source, "auth", auth);
e_source_set_property (uidata->source, KOLAB_SYNC_STRATEGY_PROP, sync_prop);
e_source_set_property (uidata->source, KOLAB_TLS_VARIANT_PROP, enc_prop);
+ e_source_set_property (uidata->source, KOLAB_PORT_NUMBER_PROP, port_prop);
e_source_set_property (uidata->source, KOLAB_REQ_PKCS11_PROP, req_pkcs11_prop);
e_source_set_property (uidata->source, KOLAB_PKCS11_PIN_PROP, pin_prop);
@@ -283,6 +311,9 @@ set_source_from_ui (kolab_ui_data *uidata,
}
g_free (sync_prop);
+ g_free (enc_prop);
+ g_free (port_prop);
+ g_free (req_pkcs11_prop);
g_free (kolab_uri);
} /* set_source_from_ui () */
@@ -298,6 +329,20 @@ set_calendar_source_from_ui_cb (kolab_ui_data *uidata)
set_source_from_ui (uidata, "true");
}
+static void
+set_contact_source_from_ui_with_encryption_changed_cb (kolab_ui_data *uidata)
+{
+ uidata->encryption_method_changed = TRUE;
+ set_source_from_ui (uidata, "plain/password");
+}
+
+static void
+set_calendar_source_from_ui_with_encryption_changed_cb (kolab_ui_data *uidata)
+{
+ uidata->encryption_method_changed = TRUE;
+ set_source_from_ui (uidata, "true");
+}
+
/*----------------------------------------------------------------------------*/
/* API functions (non-UI) */
@@ -472,6 +517,15 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
gtk_combo_box_text_append (uidata->encryption_method, NULL, kolab_util_backend_get_tls_variant_desc(i));
}
gtk_combo_box_set_active (GTK_COMBO_BOX (uidata->encryption_method), KOLAB_TLS_VARIANT_DEFAULT);
+ label = gtk_label_new(C_("Networking", "Server Port Number:"));
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ uidata->port_number = GTK_SPIN_BUTTON (gtk_spin_button_new_with_range (0.0, 99999.0, 1.0));
+ gtk_spin_button_set_digits (uidata->port_number, 0);
+ gtk_spin_button_set_increments (uidata->port_number, 1.0, 20.0);
+ gtk_spin_button_set_numeric (uidata->port_number, TRUE);
+ gtk_spin_button_set_wrap (uidata->port_number, TRUE);
+ gtk_spin_button_set_snap_to_ticks (uidata->port_number, TRUE);
+ gtk_box_pack_start (GTK_BOX (hbox), GTK_WIDGET (uidata->port_number), FALSE, FALSE, 0);
/* PKCS #11 infrastructure initiation */
hbox = gtk_hbox_new (FALSE, 10);
@@ -515,6 +569,8 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
gtk_widget_set_sensitive (GTK_WIDGET (uidata->kolab_foldername), FALSE);
}
+ uidata->encryption_method_changed = FALSE;
+
set_ui_from_source (uidata);
gtk_widget_show_all (kolab_vbox);
@@ -542,8 +598,12 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
uidata);
g_signal_connect_swapped (G_OBJECT (uidata->encryption_method),
"changed",
- G_CALLBACK (set_contact_source_from_ui_cb),
+ G_CALLBACK (set_contact_source_from_ui_with_encryption_changed_cb),
uidata);
+ g_signal_connect_swapped (G_OBJECT (uidata->port_number),
+ "value-changed",
+ G_CALLBACK (set_contact_source_from_ui_cb),
+ uidata),
g_signal_connect_swapped (G_OBJECT (uidata->require_pkcs11_infrastructure),
"toggled",
G_CALLBACK (set_contact_source_from_ui_cb),
@@ -572,8 +632,12 @@ e_kolab_account_setup_backend_create (EPlugin *epl,
uidata);
g_signal_connect_swapped (G_OBJECT (uidata->encryption_method),
"changed",
- G_CALLBACK (set_calendar_source_from_ui_cb),
+ G_CALLBACK (set_calendar_source_from_ui_with_encryption_changed_cb),
uidata);
+ g_signal_connect_swapped (G_OBJECT (uidata->port_number),
+ "value-changed",
+ G_CALLBACK (set_calendar_source_from_ui_cb),
+ uidata),
g_signal_connect_swapped (G_OBJECT (uidata->require_pkcs11_infrastructure),
"toggled",
G_CALLBACK (set_calendar_source_from_ui_cb),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]