diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2011-08-15 22:26:26 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2011-08-15 23:56:26 +0800 |
commit | 704d330db6d136c0f13cce452bd7ed6f6edcab28 (patch) | |
tree | 915ad11bb04d4d0db0fbe9627e1898f041a373e9 /widgets/misc | |
parent | ccacbe5d128dff4dac72cd2af37e80303b377a45 (diff) | |
download | gsoc2013-evolution-704d330db6d136c0f13cce452bd7ed6f6edcab28.tar.gz gsoc2013-evolution-704d330db6d136c0f13cce452bd7ed6f6edcab28.tar.zst gsoc2013-evolution-704d330db6d136c0f13cce452bd7ed6f6edcab28.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')
-rw-r--r-- | widgets/misc/e-port-entry.c | 180 | ||||
-rw-r--r-- | widgets/misc/e-port-entry.h | 33 |
2 files changed, 138 insertions, 75 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. diff --git a/widgets/misc/e-port-entry.h b/widgets/misc/e-port-entry.h index 64e0a6b234..2ef9b45cf7 100644 --- a/widgets/misc/e-port-entry.h +++ b/widgets/misc/e-port-entry.h @@ -60,22 +60,27 @@ struct _EPortEntryClass { GtkComboBoxClass parent_class; }; -GType e_port_entry_get_type (void) G_GNUC_CONST; -GtkWidget * e_port_entry_new (void); -void e_port_entry_set_camel_entries (EPortEntry *pentry, - CamelProviderPortEntry *entries); -void e_port_entry_security_port_changed - (EPortEntry *pentry, - gchar *ssl); -gint e_port_entry_get_port (EPortEntry *pentry); -void e_port_entry_set_port (EPortEntry *pentry, gint port); -gboolean e_port_entry_is_valid (EPortEntry *pentry); +GType e_port_entry_get_type (void) G_GNUC_CONST; +GtkWidget * e_port_entry_new (void); +void e_port_entry_set_camel_entries + (EPortEntry *port_entry, + CamelProviderPortEntry *entries); +gint e_port_entry_get_port (EPortEntry *port_entry); +void e_port_entry_set_port (EPortEntry *port_entry, + gint port); +gboolean e_port_entry_is_valid (EPortEntry *port_entry); +CamelNetworkSecurityMethod + e_port_entry_get_security_method + (EPortEntry *port_entry); +void e_port_entry_set_security_method + (EPortEntry *port_entry, + CamelNetworkSecurityMethod method); void e_port_entry_activate_secured_port - (EPortEntry *pentry, - gint index); + (EPortEntry *port_entry, + gint index); void e_port_entry_activate_nonsecured_port - (EPortEntry *pentry, - gint index); + (EPortEntry *port_entry, + gint index); G_END_DECLS |