From 5d3e16ae8bcc183e9b9efa084fba75acc6155866 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 1 Feb 2002 20:48:45 +0000 Subject: Update the auto-cc/bcc recipients in the composer header fields to match 2002-02-01 Jeffrey Stedfast * e-msg-composer.c (update_auto_recipients): Update the auto-cc/bcc recipients in the composer header fields to match the ones chosen in the account configuration. svn path=/trunk/; revision=15548 --- composer/ChangeLog | 6 +++ composer/e-msg-composer.c | 114 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 118 insertions(+), 2 deletions(-) (limited to 'composer') diff --git a/composer/ChangeLog b/composer/ChangeLog index 8ad37b0cb7..c302fe61ef 100644 --- a/composer/ChangeLog +++ b/composer/ChangeLog @@ -1,3 +1,9 @@ +2002-02-01 Jeffrey Stedfast + + * e-msg-composer.c (update_auto_recipients): Update the + auto-cc/bcc recipients in the composer header fields to match the + ones chosen in the account configuration. + 2002-01-31 Radek Doulik * e-msg-composer.c (e_msg_composer_ignore): new method, tells diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 3dfd9962f8..64c4c5ed75 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -1868,6 +1868,109 @@ hdrs_changed_cb (EMsgComposerHdrs *hdrs, e_msg_composer_set_changed (composer); } +enum { + UPDATE_AUTO_CC, + UPDATE_AUTO_BCC, +}; + +static void +update_auto_recipients (EMsgComposerHdrs *hdrs, int mode, const char *auto_addrs) +{ + EDestination *dest, **destv = NULL; + CamelInternetAddress *iaddr; + GList *list, *tail, *node; + int i, n = 0; + + switch (mode) { + case UPDATE_AUTO_CC: + destv = e_msg_composer_hdrs_get_cc (hdrs); + break; + case UPDATE_AUTO_BCC: + destv = e_msg_composer_hdrs_get_bcc (hdrs); + break; + default: + g_assert_not_reached (); + } + + tail = list = NULL; + if (destv) { + for (i = 0; destv[i]; i++) { + if (!e_destination_is_auto_recipient (destv[i])) { + node = g_list_alloc (); + node->data = e_destination_copy (destv[i]); + node->next = NULL; + + if (tail) { + node->prev = tail; + tail->next = node; + } else { + node->prev = NULL; + list = node; + } + + tail = node; + n++; + } + } + + e_destination_freev (destv); + } + + if (auto_addrs) { + iaddr = camel_internet_address_new (); + if (camel_address_decode (CAMEL_ADDRESS (iaddr), auto_addrs) != -1) { + for (i = 0; i < camel_address_length (CAMEL_ADDRESS (iaddr)); i++) { + const char *name, *addr; + + if (!camel_internet_address_get (iaddr, i, &name, &addr)) + continue; + + dest = e_destination_new (); + e_destination_set_auto_recipient (dest, TRUE); + + if (name) + e_destination_set_name (dest, name); + + if (addr) + e_destination_set_email (dest, addr); + + node = g_list_alloc (); + node->data = dest; + node->next = NULL; + + if (tail) { + node->prev = tail; + tail->next = node; + } else { + node->prev = NULL; + list = node; + } + + tail = node; + n++; + } + } + + camel_object_unref (CAMEL_OBJECT (iaddr)); + } + + destv = e_destination_list_to_vector_sized (list, n); + g_list_free (list); + + switch (mode) { + case UPDATE_AUTO_CC: + e_msg_composer_hdrs_set_cc (hdrs, destv); + break; + case UPDATE_AUTO_BCC: + e_msg_composer_hdrs_set_bcc (hdrs, destv); + break; + default: + g_assert_not_reached (); + } + + e_destination_freev (destv); +} + static void from_changed_cb (EMsgComposerHdrs *hdrs, void *data) { @@ -1876,8 +1979,15 @@ from_changed_cb (EMsgComposerHdrs *hdrs, void *data) composer = E_MSG_COMPOSER (data); if (hdrs->account) { - e_msg_composer_set_pgp_sign (composer, hdrs->account->pgp_always_sign); - e_msg_composer_set_smime_sign (composer, hdrs->account->smime_always_sign); + const MailConfigAccount *account = hdrs->account; + + e_msg_composer_set_pgp_sign (composer, account->pgp_always_sign); + e_msg_composer_set_smime_sign (composer, account->smime_always_sign); + update_auto_recipients (hdrs, UPDATE_AUTO_CC, account->always_cc ? account->cc_addrs : NULL); + update_auto_recipients (hdrs, UPDATE_AUTO_BCC, account->always_bcc ? account->bcc_addrs : NULL); + } else { + update_auto_recipients (hdrs, UPDATE_AUTO_CC, NULL); + update_auto_recipients (hdrs, UPDATE_AUTO_BCC, NULL); } e_msg_composer_show_sig_file (composer); -- cgit v1.2.3