X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-tny-account.c;h=8b95766c000b0868a299d51aed225a7d2a4fd777;hp=90c4433ca262124be6c6c7b13add8ec914786e7f;hb=559195a910df17bb5ba5f33c01e9d7e1dd933503;hpb=e61fe85209b2820d2b3a60b38fdc30faf68e46f8 diff --git a/src/modest-tny-account.c b/src/modest-tny-account.c index 90c4433..8b95766 100644 --- a/src/modest-tny-account.c +++ b/src/modest-tny-account.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -78,7 +79,8 @@ modest_tny_account_get_special_folder (TnyAccount *account, */ /* Per-account outbox folders are each in their own on-disk directory: */ - if (special_type == TNY_FOLDER_TYPE_OUTBOX) { + if ((special_type == TNY_FOLDER_TYPE_OUTBOX) && + (!modest_tny_account_is_virtual_local_folders (account))) { gchar *account_id; const gchar *modest_account_name; @@ -272,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. @@ -283,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; @@ -292,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) { @@ -365,9 +372,9 @@ update_tny_account (TnyAccount *tny_account, (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); @@ -432,7 +439,9 @@ modest_tny_account_new_from_server_account_name (ModestAccountMgr *account_mgr, 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 ()); + g_object_unref (server_settings); return tny_account; @@ -457,24 +466,34 @@ forget_pass_dummy (TnyAccount *account) static void set_online_callback (TnyCamelAccount *account, gboolean canceled, GError *err, gpointer user_data) { - /* MODEST TODO: Show a real error message here, this is a significant error! - * Perhaps show the account's settings dialog again?! Reconnecting after - * changing the settings of an account failed in this situation. */ + TnyAccountStore *account_store; - if (err && !canceled) - g_warning ("err: %s", err->message); + account_store = TNY_ACCOUNT_STORE(g_object_get_data (G_OBJECT(account), + "account_store")); + if (err && !canceled) { + /* It seems err is forgotten here ... if the disk is full ! */ + if (account_store) { + tny_account_store_alert ( + account_store, + TNY_ACCOUNT (account), TNY_ALERT_TYPE_ERROR, FALSE, + err); + } + g_warning ("err: %s", err->message); + } } gboolean -modest_tny_account_update_from_account (TnyAccount *tny_account) +modest_tny_account_update_from_account (TnyAccount *tny_account, + TnyGetPassFunc get_pass_func, + TnyForgetPassFunc forget_pass_func) { ModestAccountSettings *settings = NULL; ModestServerAccountSettings *server_settings = NULL; - TnyConnectionStatus conn_status; ModestAccountMgr *account_mgr; const gchar *account_name; TnyAccountType type; const gchar *display_name; + TnyConnectionStatus conn_status; g_return_val_if_fail (tny_account, FALSE); @@ -515,26 +534,34 @@ modest_tny_account_update_from_account (TnyAccount *tny_account) g_object_unref (server_settings); g_object_unref (settings); - /* If the account was online, reconnect to apply the changes */ + 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 + * failed. Please handle it (this is TODO). */ + conn_status = tny_account_get_connection_status (tny_account); if (conn_status != TNY_CONNECTION_STATUS_DISCONNECTED) { TnyAccountStore *account_store = NULL; - - /* The callback will have an error for you if the reconnect - * failed. Please handle it (this is TODO). */ - + account_store = TNY_ACCOUNT_STORE(g_object_get_data (G_OBJECT(tny_account), - "account_store")); - + "account_store")); + if (account_store) { modest_tny_account_store_forget_already_asked (MODEST_TNY_ACCOUNT_STORE (account_store), - tny_account); + tny_account); } - + tny_camel_account_set_online (TNY_CAMEL_ACCOUNT(tny_account), TRUE, - set_online_callback, "online"); + set_online_callback, "online"); } - + return TRUE; } @@ -602,7 +629,9 @@ modest_tny_account_new_from_account (ModestAccountMgr *account_mgr, 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 ()); + modest_tny_account_set_parent_modest_account_name_for_server_account (tny_account, account_name); g_object_unref (server_settings); @@ -794,7 +823,9 @@ modest_tny_account_new_for_local_folders (ModestAccountMgr *account_mgr, TnySess tny_account_set_forget_pass_func (TNY_ACCOUNT(tny_account), forget_pass_dummy); tny_account_set_pass_func (TNY_ACCOUNT(tny_account), get_pass_dummy); - + + tny_account_set_connection_policy (TNY_ACCOUNT (tny_account), modest_default_connection_policy_new ()); + modest_tny_account_set_parent_modest_account_name_for_server_account ( TNY_ACCOUNT (tny_account), id); @@ -864,7 +895,9 @@ modest_tny_account_new_for_per_account_local_outbox_folder (ModestAccountMgr *ac tny_account_set_forget_pass_func (TNY_ACCOUNT(tny_account), forget_pass_dummy); tny_account_set_pass_func (TNY_ACCOUNT(tny_account), get_pass_dummy); - + + tny_account_set_connection_policy (TNY_ACCOUNT (tny_account), modest_default_connection_policy_new ()); + /* Make this think that it belongs to the modest local-folders parent account: */ modest_tny_account_set_parent_modest_account_name_for_server_account ( TNY_ACCOUNT (tny_account), MODEST_LOCAL_FOLDERS_ACCOUNT_ID);