on_apply (ModestAccountAssistant *self, gpointer user_data)
{
ModestAccountAssistantPrivate *priv;
- ModestProtocol proto;
+ ModestProtocol proto, security, auth;
gchar *store_name, *transport_name;
const gchar *account_name, *username, *servername, *path;
ModestStoreWidget *store;
username = modest_store_widget_get_username (store);
servername = modest_store_widget_get_servername (store);
path = modest_store_widget_get_path (store);
+ security = modest_store_widget_get_security (store);
+ auth = modest_store_widget_get_auth (store);
store_name = get_new_server_account_name (priv->account_mgr, proto,username, servername);
if (proto == MODEST_PROTOCOL_STORE_MAILDIR ||
g_free (uri);
} else
modest_account_mgr_add_server_account (priv->account_mgr, store_name, servername,
- username, NULL, proto);
+ username, NULL, proto, security, auth);
/* create server account -> transport */
transport = MODEST_TRANSPORT_WIDGET(priv->transport_widget);
modest_account_mgr_add_server_account (priv->account_mgr,
transport_name, servername,
username, NULL,
- proto);
+ proto, security, auth);
/* create account */
account_name = get_account_name (self);
GtkWidget *security;
GtkWidget *auth;
GtkWidget *chooser;
- GtkWidget *remember_pwd;
ModestProtocol proto;
};
ModestPairList *protos;
ModestStoreWidgetPrivate *priv;
GtkWidget *label, *box, *hbox;
- GtkWidget *combo;
priv = MODEST_STORE_WIDGET_GET_PRIVATE(self);
box = gtk_vbox_new (FALSE, 6);
gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 6);
protos = modest_protocol_info_get_protocol_pair_list (MODEST_PROTOCOL_TYPE_AUTH);
- combo = modest_combo_box_new (protos, g_str_equal);
+ priv->auth = modest_combo_box_new (protos, g_str_equal);
modest_pair_list_free (protos);
- gtk_box_pack_start (GTK_BOX(hbox), combo, FALSE, FALSE, 0);
- priv->remember_pwd =
- gtk_check_button_new_with_label (_("Remember password"));
- gtk_box_pack_start (GTK_BOX(hbox),priv->remember_pwd,
- FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX(hbox), priv->auth, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(box), hbox, FALSE, FALSE, 0);
return GTK_WIDGET(self);
}
-gboolean
-modest_store_widget_get_remember_password (ModestStoreWidget *self)
-{
- ModestStoreWidgetPrivate *priv;
-
- g_return_val_if_fail (self, FALSE);
- priv = MODEST_STORE_WIDGET_GET_PRIVATE(self);
-
- if (GTK_IS_TOGGLE_BUTTON(priv->remember_pwd))
- return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(priv->remember_pwd));
- else
- return FALSE;
-}
-
const gchar*
modest_store_widget_get_username (ModestStoreWidget *self)
{
else
return NULL;
}
+
+static ModestProtocol
+get_protocol_from_combo (GtkWidget *combo)
+{
+ gchar *chosen;
+
+ if (!combo)
+ return MODEST_PROTOCOL_UNKNOWN;
+
+ chosen = gtk_combo_box_get_active_text (GTK_COMBO_BOX (combo));
+
+ return modest_protocol_info_get_protocol (chosen);
+
+}
+
+ModestProtocol
+modest_store_widget_get_auth (ModestStoreWidget *self)
+{
+ ModestStoreWidgetPrivate *priv;
+
+ g_return_val_if_fail (self, MODEST_PROTOCOL_UNKNOWN);
+ priv = MODEST_STORE_WIDGET_GET_PRIVATE(self);
+
+ return get_protocol_from_combo (priv->auth);
+}
+
+ModestProtocol
+modest_store_widget_get_security (ModestStoreWidget *self)
+{
+ ModestStoreWidgetPrivate *priv;
+
+ g_return_val_if_fail (self, MODEST_PROTOCOL_UNKNOWN);
+ priv = MODEST_STORE_WIDGET_GET_PRIVATE(self);
+
+ return get_protocol_from_combo (priv->security);
+}
};
/* member functions */
-GType modest_store_widget_get_type (void) G_GNUC_CONST;
+GType modest_store_widget_get_type (void) G_GNUC_CONST;
-GtkWidget* modest_store_widget_new (ModestProtocol proto);
+GtkWidget* modest_store_widget_new (ModestProtocol proto);
-gboolean modest_store_widget_get_remember_password (ModestStoreWidget *self);
const gchar* modest_store_widget_get_username (ModestStoreWidget *self);
const gchar* modest_store_widget_get_servername (ModestStoreWidget *self);
ModestProtocol modest_store_widget_get_proto (ModestStoreWidget *self);
gchar * modest_store_widget_get_path (ModestStoreWidget *self);
-
+ModestProtocol modest_store_widget_get_auth (ModestStoreWidget *self);
+ModestProtocol modest_store_widget_get_security (ModestStoreWidget *self);
G_END_DECLS
modest_account_mgr_add_server_account (ModestAccountMgr * self,
const gchar * name, const gchar *hostname,
const gchar * username, const gchar * password,
- ModestProtocol proto)
+ ModestProtocol proto,
+ ModestProtocol security,
+ ModestProtocol auth)
{
ModestAccountMgrPrivate *priv;
gchar *key;
ModestProtocolType proto_type;
- gboolean ok;
+ gboolean ok = TRUE;
GError *err = NULL;
g_return_val_if_fail (MODEST_IS_ACCOUNT_MGR(self), FALSE);
g_free (key);
ok = FALSE;
}
- g_free (key);
if (!ok)
goto cleanup;
ok = FALSE;
}
g_free (key);
+ if (!ok)
+ goto cleanup;
+
+ /* auth mechanism */
+ key = _modest_account_mgr_get_account_keyname (name, MODEST_ACCOUNT_AUTH_MECH, TRUE);
+ ok = modest_conf_set_string (priv->modest_conf, key,
+ modest_protocol_info_get_protocol_name (auth), &err);
+ if (err) {
+ g_printerr ("modest: failed to set %s: %s\n", key, err->message);
+ g_error_free (err);
+ ok = FALSE;
+ }
+ g_free (key);
+ if (!ok)
+ goto cleanup;
+
+ if (proto_type == MODEST_PROTOCOL_TYPE_STORE) {
+
+ GSList *option_list = NULL;
+
+ /* Connection options. Some options are only valid for IMAP
+ accounts but it's OK for just now since POP is still not
+ supported */
+ key = _modest_account_mgr_get_account_keyname (name, MODEST_ACCOUNT_OPTIONS, TRUE);
+ /* Enable subscriptions and check the mails in all folders */
+ option_list = g_slist_append (option_list, "use_lsub");
+ option_list = g_slist_append (option_list, "check_all");
+ /* Security options */
+ switch (security) {
+ case MODEST_PROTOCOL_SECURITY_NONE:
+ option_list = g_slist_append (option_list, "use_ssl=never");
+ break;
+ case MODEST_PROTOCOL_SECURITY_SSL:
+ case MODEST_PROTOCOL_SECURITY_TLS:
+ option_list = g_slist_append (option_list, "use_ssl=always");
+ break;
+ case MODEST_PROTOCOL_SECURITY_TLS_OP:
+ option_list = g_slist_append (option_list, "use_ssl=when-possible");
+ break;
+ default:
+ g_warning ("Invalid security option");
+ }
+ ok = modest_conf_set_list (priv->modest_conf, key,
+ option_list, MODEST_CONF_VALUE_STRING, &err);
+ if (err) {
+ g_printerr ("modest: failed to set %s: %s\n", key, err->message);
+ g_error_free (err);
+ ok = FALSE;
+ }
+ g_slist_free (option_list);
+ g_free (key);
+ }
cleanup:
if (!ok) {
* @username: the username
* @password: the password
* @proto: the protocol (imap, smtp, ...) used for this account
+ * @security: the security options, (SSL, TLS ...) used to access the server
+ * @auth: the authentication method (password, none ...) used to access the server
*
* add a server account to the configuration.
* the server account with @name should not already exist
const gchar *hostname,
const gchar *username,
const gchar *password,
- ModestProtocol proto);
+ ModestProtocol proto,
+ ModestProtocol security,
+ ModestProtocol auth);
/**
priv = MODEST_CONF_GET_PRIVATE(self);
gconf_type = modest_conf_type_to_gconf_type (list_type, err);
- if (err)
+ if (*err)
return FALSE;
return gconf_client_set_list (priv->gconf_client, key, gconf_type, val, err);
#define MODEST_ACCOUNT_LEAVE_ON_SERVER "leave_on_server" /* boolean */
#define MODEST_ACCOUNT_PREFERRED_CNX "preferred_cnx" /* string */
#define MODEST_ACCOUNT_OPTIONS "options" /* list */
-
-
-
+#define MODEST_ACCOUNT_AUTH_MECH "auth_mech" /* string */
#endif /*__MODEST_DEFS_H__*/
{ MODEST_PROTOCOL_STORE_MAILDIR, "maildir", N_("Maildir") },
{ MODEST_PROTOCOL_STORE_MBOX, "mbox", N_("MBox") },
+ { MODEST_PROTOCOL_SECURITY_NONE, "none", N_("None") },
{ MODEST_PROTOCOL_SECURITY_SSL, "ssl", N_("SSL") },
{ MODEST_PROTOCOL_SECURITY_TLS, "tls", N_("TLS") },
+ { MODEST_PROTOCOL_SECURITY_TLS_OP, "tls-op", N_("TLS when possible") }, /* op stands for optional */
- { MODEST_PROTOCOL_AUTH_NONE, "none", N_("none") },
+ { MODEST_PROTOCOL_AUTH_NONE, "none", N_("None") },
{ MODEST_PROTOCOL_AUTH_PASSWORD, "password", N_("Password") }
};
const guint PROTOCOL_MAP_SIZE = sizeof(ProtocolMap)/sizeof(ProtocolInfo);
case MODEST_PROTOCOL_STORE_MBOX:
return MODEST_PROTOCOL_TYPE_STORE;
+ case MODEST_PROTOCOL_SECURITY_NONE:
case MODEST_PROTOCOL_SECURITY_SSL:
case MODEST_PROTOCOL_SECURITY_TLS:
+ case MODEST_PROTOCOL_SECURITY_TLS_OP:
return MODEST_PROTOCOL_TYPE_SECURITY;
case MODEST_PROTOCOL_AUTH_NONE:
MODEST_PROTOCOL_STORE_MAILDIR,
MODEST_PROTOCOL_STORE_MBOX,
+ MODEST_PROTOCOL_SECURITY_NONE,
MODEST_PROTOCOL_SECURITY_SSL,
MODEST_PROTOCOL_SECURITY_TLS,
+ MODEST_PROTOCOL_SECURITY_TLS_OP,
MODEST_PROTOCOL_AUTH_NONE,
MODEST_PROTOCOL_AUTH_PASSWORD,
modest_text_utils_validate_email_address (const gchar *email_address)
{
int count = 0;
- const gchar *c, *domain;
+ const gchar *c = NULL, *domain = NULL;
static gchar *rfc822_specials = "()<>@,;:\\\"[]";
/* first we validate the name portion (name@domain) */