X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-account.c;h=2115d69854636fc789c33923f89802efc29bca6e;hp=2496a16c298577d965e6e16ceb8cfa1cec42833d;hb=41c33d2e51bef2ae3d750c2848ab13cb4bb8d392;hpb=a87b228eaa0848907bd3e7f722d644dc1cb2dbd4 diff --git a/src/modest-tny-account.c b/src/modest-tny-account.c index 2496a16..2115d69 100644 --- a/src/modest-tny-account.c +++ b/src/modest-tny-account.c @@ -274,7 +274,10 @@ update_tny_account (TnyAccount *tny_account, g_return_val_if_fail (account_name, FALSE); g_return_val_if_fail (tny_account, FALSE); - tny_account_set_id (tny_account, account_name); + /* Do not change the id if it's not needed */ + if (tny_account_get_id (tny_account) && + strcmp (tny_account_get_id (tny_account), account_name)) + tny_account_set_id (tny_account, account_name); /* mbox and maildir accounts use a URI instead of the rest: * Note that this is not where we create the special local folders account. @@ -285,7 +288,7 @@ update_tny_account (TnyAccount *tny_account, else { /* Set camel-specific options: */ /* Enable secure connection settings: */ - const gchar* option_security = NULL; + TnyPair *option_security = NULL; const gchar* auth_mech_name = NULL; ModestTransportStoreProtocol protocol; ModestConnectionProtocol security; @@ -294,33 +297,35 @@ update_tny_account (TnyAccount *tny_account, const gchar *hostname; guint port; + /* First of all delete old options */ + tny_camel_account_clear_options (TNY_CAMEL_ACCOUNT (tny_account)); + protocol = modest_server_account_settings_get_protocol (server_settings); security = modest_server_account_settings_get_security (server_settings); auth_protocol = modest_server_account_settings_get_auth_protocol (server_settings); switch (security) { case MODEST_PROTOCOL_CONNECTION_NORMAL: - option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_NEVER; + option_security = tny_pair_new (MODEST_ACCOUNT_OPTION_SSL,MODEST_ACCOUNT_OPTION_SSL_NEVER); break; case MODEST_PROTOCOL_CONNECTION_SSL: /* Apparently, use of "IMAPS" (specified in our UI spec), implies * use of the "wrapped" option: */ - option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_WRAPPED; + option_security = tny_pair_new (MODEST_ACCOUNT_OPTION_SSL,MODEST_ACCOUNT_OPTION_SSL_WRAPPED); break; case MODEST_PROTOCOL_CONNECTION_TLS: - option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_TLS; + option_security = tny_pair_new (MODEST_ACCOUNT_OPTION_SSL,MODEST_ACCOUNT_OPTION_SSL_TLS); break; case MODEST_PROTOCOL_CONNECTION_TLS_OP: /* This is not actually in our UI: */ - option_security = MODEST_ACCOUNT_OPTION_SSL "=" MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE; + option_security = tny_pair_new (MODEST_ACCOUNT_OPTION_SSL,MODEST_ACCOUNT_OPTION_SSL_WHEN_POSSIBLE); break; default: break; } if(option_security) - tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account), - option_security); + tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account), option_security); /* Secure authentication: */ switch (auth_protocol) { @@ -331,8 +336,6 @@ update_tny_account (TnyAccount *tny_account, if (protocol == MODEST_PROTOCOL_STORE_IMAP || protocol == MODEST_PROTOCOL_STORE_POP) auth_mech_name = NULL; - else if (protocol == MODEST_PROTOCOL_TRANSPORT_SMTP) - auth_mech_name = NULL; else auth_mech_name = MODEST_ACCOUNT_AUTH_PLAIN; break; @@ -360,16 +363,15 @@ update_tny_account (TnyAccount *tny_account, break; } - if(auth_mech_name) - tny_account_set_secure_auth_mech (tny_account, auth_mech_name); + tny_account_set_secure_auth_mech (tny_account, auth_mech_name); if (modest_protocol_info_protocol_is_store(protocol) && (protocol == MODEST_PROTOCOL_STORE_IMAP) ) { /* Other connection options, needed for IMAP. */ tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account), - MODEST_ACCOUNT_OPTION_USE_LSUB); + tny_pair_new (MODEST_ACCOUNT_OPTION_USE_LSUB, "")); tny_camel_account_add_option (TNY_CAMEL_ACCOUNT (tny_account), - MODEST_ACCOUNT_OPTION_CHECK_ALL); + tny_pair_new (MODEST_ACCOUNT_OPTION_CHECK_ALL, "")); } username = modest_server_account_settings_get_username (server_settings); @@ -529,13 +531,6 @@ modest_tny_account_update_from_account (TnyAccount *tny_account, g_object_unref (server_settings); g_object_unref (settings); - tny_account_set_forget_pass_func (tny_account, NULL); - tny_account_set_pass_func (tny_account, NULL); - tny_account_set_forget_pass_func (tny_account, - forget_pass_func ? forget_pass_func : forget_pass_dummy); - tny_account_set_pass_func (tny_account, - get_pass_func ? get_pass_func: get_pass_dummy); - tny_account_set_connection_policy (tny_account, modest_default_connection_policy_new ()); /* The callback will have an error for you if the reconnect