aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-08-15 22:26:26 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-09-14 20:08:49 +0800
commitebbc16b464bc6a50f455b5ff7a178253fad6eb49 (patch)
treed1d49dcbefa769d58b2728baf390f996c80f3a0b
parentaa28e1dea318b74ab76da88aab3a04467dee0dcf (diff)
downloadgsoc2013-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.
-rw-r--r--widgets/misc/e-port-entry.c180
-rw-r--r--widgets/misc/e-port-entry.h33
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