diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-08-15 22:26:26 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@gnome-db.org> | 2011-09-14 20:08:49 +0800 |
commit | ebbc16b464bc6a50f455b5ff7a178253fad6eb49 (patch) | |
tree | d1d49dcbefa769d58b2728baf390f996c80f3a0b /widgets/misc/e-port-entry.c | |
parent | aa28e1dea318b74ab76da88aab3a04467dee0dcf (diff) | |
download | gsoc2013-evolution-ebbc16b464bc6a50f455b5ff7a178253fad6eb49.tar gsoc2013-evolution-ebbc16b464bc6a50f455b5ff7a178253fad6eb49.tar.gz gsoc2013-evolution-ebbc16b464bc6a50f455b5ff7a178253fad6eb49.tar.bz2 gsoc2013-evolution-ebbc16b464bc6a50f455b5ff7a178253fad6eb49.tar.lz gsoc2013-evolution-ebbc16b464bc6a50f455b5ff7a178253fad6eb49.tar.xz gsoc2013-evolution-ebbc16b464bc6a50f455b5ff7a178253fad6eb49.tar.zst gsoc2013-evolution-ebbc16b464bc6a50f455b5ff7a178253fad6eb49.zip |
EPortEntry: Add a "security-method" property.
This is an enum property of type CAMEL_TYPE_NETWORK_SECURITY_METHOD.
We can then bind it to CamelNetworkSettings:security-method.
Diffstat (limited to 'widgets/misc/e-port-entry.c')
-rw-r--r-- | widgets/misc/e-port-entry.c | 180 |
1 files changed, 119 insertions, 61 deletions
diff --git a/widgets/misc/e-port-entry.c b/widgets/misc/e-port-entry.c index a353613039..dd27ffa371 100644 --- a/widgets/misc/e-port-entry.c +++ b/widgets/misc/e-port-entry.c @@ -23,6 +23,7 @@ struct _EPortEntryPrivate { guint port; gboolean is_valid; + CamelNetworkSecurityMethod method; }; enum { @@ -34,7 +35,8 @@ enum { enum { PROP_0, PROP_IS_VALID, - PROP_PORT + PROP_PORT, + PROP_SECURITY_METHOD }; G_DEFINE_TYPE ( @@ -73,50 +75,6 @@ port_entry_get_model_active_port (EPortEntry *port_entry) } static void -port_entry_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_IS_VALID: - port_entry_set_is_valid ( - E_PORT_ENTRY (object), - g_value_get_boolean (value)); - return; - case PROP_PORT: - e_port_entry_set_port ( - E_PORT_ENTRY (object), - g_value_get_uint (value)); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void -port_entry_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec) -{ - switch (property_id) { - case PROP_IS_VALID: - g_value_set_boolean ( - value, e_port_entry_is_valid ( - E_PORT_ENTRY (object))); - return; - case PROP_PORT: - g_value_set_uint ( - value, e_port_entry_get_port ( - E_PORT_ENTRY (object))); - return; - } - - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); -} - -static void port_entry_port_changed (EPortEntry *port_entry) { GtkTreeModel *model; @@ -164,6 +122,81 @@ port_entry_port_changed (EPortEntry *port_entry) } static void +port_entry_method_changed (EPortEntry *port_entry) +{ + CamelNetworkSecurityMethod method; + + method = e_port_entry_get_security_method (port_entry); + + switch (method) { + case CAMEL_NETWORK_SECURITY_METHOD_SSL_ON_ALTERNATE_PORT: + e_port_entry_activate_secured_port (port_entry, 0); + break; + default: + e_port_entry_activate_nonsecured_port (port_entry, 0); + break; + } +} + +static void +port_entry_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_IS_VALID: + port_entry_set_is_valid ( + E_PORT_ENTRY (object), + g_value_get_boolean (value)); + return; + + case PROP_PORT: + e_port_entry_set_port ( + E_PORT_ENTRY (object), + g_value_get_uint (value)); + return; + + case PROP_SECURITY_METHOD: + e_port_entry_set_security_method ( + E_PORT_ENTRY (object), + g_value_get_enum (value)); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void +port_entry_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + switch (property_id) { + case PROP_IS_VALID: + g_value_set_boolean ( + value, e_port_entry_is_valid ( + E_PORT_ENTRY (object))); + return; + + case PROP_PORT: + g_value_set_uint ( + value, e_port_entry_get_port ( + E_PORT_ENTRY (object))); + return; + + case PROP_SECURITY_METHOD: + g_value_set_enum ( + value, e_port_entry_get_security_method ( + E_PORT_ENTRY (object))); + return; + } + + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); +} + +static void port_entry_get_preferred_width (GtkWidget *widget, gint *minimum_size, gint *natural_size) @@ -236,7 +269,8 @@ e_port_entry_class_init (EPortEntryClass *class) NULL, NULL, FALSE, - G_PARAM_READABLE)); + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); g_object_class_install_property ( object_class, @@ -248,7 +282,20 @@ e_port_entry_class_init (EPortEntryClass *class) 0, /* Min port, 0 = invalid port */ G_MAXUINT16, /* Max port */ 0, - G_PARAM_READWRITE)); + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); + + g_object_class_install_property ( + object_class, + PROP_SECURITY_METHOD, + g_param_spec_enum ( + "security-method", + "Security Method", + "Method used to establish a network connection", + CAMEL_TYPE_NETWORK_SECURITY_METHOD, + CAMEL_NETWORK_SECURITY_METHOD_NONE, + G_PARAM_READWRITE | + G_PARAM_STATIC_STRINGS)); } static void @@ -292,6 +339,10 @@ e_port_entry_init (EPortEntry *port_entry) g_signal_connect ( port_entry, "changed", G_CALLBACK (port_entry_port_changed), NULL); + + g_signal_connect ( + port_entry, "notify::security-method", + G_CALLBACK (port_entry_method_changed), NULL); } GtkWidget * @@ -340,20 +391,6 @@ e_port_entry_set_camel_entries (EPortEntry *port_entry, e_port_entry_set_port (port_entry, entries[0].port); } -void -e_port_entry_security_port_changed (EPortEntry *port_entry, - gchar *ssl) -{ - g_return_if_fail (E_IS_PORT_ENTRY (port_entry)); - g_return_if_fail (ssl != NULL); - - if (strcmp (ssl, "always") == 0) { - e_port_entry_activate_secured_port (port_entry, 0); - } else { - e_port_entry_activate_nonsecured_port (port_entry, 0); - } -} - gint e_port_entry_get_port (EPortEntry *port_entry) { @@ -402,6 +439,27 @@ e_port_entry_is_valid (EPortEntry *port_entry) return port_entry->priv->is_valid; } +CamelNetworkSecurityMethod +e_port_entry_get_security_method (EPortEntry *port_entry) +{ + g_return_val_if_fail ( + E_IS_PORT_ENTRY (port_entry), + CAMEL_NETWORK_SECURITY_METHOD_NONE); + + return port_entry->priv->method; +} + +void +e_port_entry_set_security_method (EPortEntry *port_entry, + CamelNetworkSecurityMethod method) +{ + g_return_if_fail (E_IS_PORT_ENTRY (port_entry)); + + port_entry->priv->method = method; + + g_object_notify (G_OBJECT (port_entry), "security-method"); +} + /** * If there are more then one secured port in the model, you can specify * which of the secured ports should be activated by specifying the index. |