From 3c74da6893887b68caa185f6d2eb2a280a0e445e Mon Sep 17 00:00:00 2001 From: Parthasarathi Susarla Date: Wed, 23 Nov 2005 06:46:51 +0000 Subject: ** See bug #315987 Send only if account is enabled 2005-11-23 Parthasarathi Susarla ** See bug #315987 * em-composer-utils.c: (em_utils_composer_send_cb): Send only if account is enabled (em_utils_composer_save_draft_cb): Save message to server folder only if the account is enabled, else save it locally (generate_account_hash): Add default account into the account hash only if the account none of the account is enabled. (guess_account): use only enabled account * mail.error.xml: Add error message for send-no-account-enabled svn path=/trunk/; revision=30646 --- mail/ChangeLog | 13 +++++++++++++ mail/em-composer-utils.c | 21 ++++++++++++++------- mail/mail-send-recv.c | 2 +- mail/mail.error.xml | 5 +++++ 4 files changed, 33 insertions(+), 8 deletions(-) diff --git a/mail/ChangeLog b/mail/ChangeLog index 839ec6af0e..8d534329e4 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,16 @@ +2005-11-23 Parthasarathi Susarla + + ** See bug #315987 + * em-composer-utils.c: + (em_utils_composer_send_cb): Send only if account is enabled + (em_utils_composer_save_draft_cb): Save message to server + folder only if the account is enabled, else save it locally + (generate_account_hash): Add default account into the account hash + only if the account none of the account is enabled. + (guess_account): use only enabled account + + * mail.error.xml: Add error message for send-no-account-enabled + 2005-11-11 Boby Wang ** See bug 321214. diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 66f4ca90a0..b0eac88d5e 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -381,6 +381,13 @@ em_utils_composer_send_cb (EMsgComposer *composer, gpointer user_data) CamelMessageInfo *info; struct _send_data *send; CamelFolder *mail_folder; + EAccount *account; + + account = e_msg_composer_get_preferred_account (composer); + if (!account->enabled) { + e_error_run(NULL, "mail:send-no-account-enabled", NULL); + return; + } if (!(message = composer_get_message (composer, FALSE))) return; @@ -519,7 +526,7 @@ em_utils_composer_save_draft_cb (EMsgComposer *composer, int quit, gpointer user id = mail_get_folder (account->drafts_folder_uri, 0, save_draft_folder, &folder, mail_thread_new); mail_msg_wait (id); - if (!folder) { + if (!folder || !account->enabled) { if (e_error_run((GtkWindow *)composer, "mail:ask-default-drafts", NULL) != GTK_RESPONSE_YES) { g_object_unref(composer); camel_object_unref(msg); @@ -1270,11 +1277,7 @@ generate_account_hash (void) accounts = mail_config_get_accounts (); account_hash = g_hash_table_new (camel_strcase_hash, camel_strcase_equal); - /* add the default account to the hash first */ - if ((def = mail_config_get_default_account ())) { - if (def->id->address) - g_hash_table_insert (account_hash, (char *) def->id->address, (void *) def); - } + def = mail_config_get_default_account (); iter = e_list_get_iterator ((EList *) accounts); while (e_iterator_is_valid (iter)) { @@ -1303,6 +1306,10 @@ generate_account_hash (void) } g_object_unref (iter); + + /* The default account has to be there if none of the enabled accounts are present */ + if (g_hash_table_size (account_hash) == 0 && def && def->id->address) + g_hash_table_insert (account_hash, (char *) def->id->address, (void *) def); return account_hash; } @@ -1460,7 +1467,7 @@ guess_account (CamelMimeMessage *message, CamelFolder *folder) if (to) { for (i = 0; camel_internet_address_get(to, i, NULL, &tmp); i++) { account = g_hash_table_lookup(account_hash, tmp); - if (account) + if (account && account->enabled) break; } } diff --git a/mail/mail-send-recv.c b/mail/mail-send-recv.c index ad8f79b669..efd0a2f884 100644 --- a/mail/mail-send-recv.c +++ b/mail/mail-send-recv.c @@ -1064,7 +1064,7 @@ mail_send (void) send_info_t type; transport = mail_config_get_default_transport (); - if (!transport || !transport->url) + if (!transport || !transport->url) return; data = setup_send_data (); diff --git a/mail/mail.error.xml b/mail/mail.error.xml index 2b23652f03..6c3aae2cde 100644 --- a/mail/mail.error.xml +++ b/mail/mail.error.xml @@ -378,6 +378,11 @@ You can choose to ignore this folder, overwrite or append its contents, or quit. <_primary>Blank Signature <_secondary>Please provide an unique name to identify this signature. + + + <_primary>This message cannot be sent because the account you chose to send with is not enabled + <_secondary xml:space="preserve">Please enable the account or send using another account. + -- cgit