From: Alfons Hoogervorst Date: Sat, 10 Apr 2004 14:01:45 +0000 (+0000) Subject: * src/compose.c X-Git-Tag: rel_0_9_11~36 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=d344bb5272ac50f5d3dcb09656a88800ff99ef4d * src/compose.c appropriate auto account selection when forwarding (fixes bug #476, "forward as attachment does not listen to account rules") --- diff --git a/ChangeLog.claws b/ChangeLog.claws index a9f1f78ed..b1e518831 100644 --- a/ChangeLog.claws +++ b/ChangeLog.claws @@ -1,3 +1,10 @@ +2004-04-10 [alfons] 0.9.10claws44 + + * src/compose.c + appropriate auto account selection when forwarding + (fixes bug #476, "forward as attachment does not listen + to account rules") + 2004-04-09 [alfons] 0.9.10claws43 * src/summaryview.c diff --git a/configure.ac b/configure.ac index 50a20e714..1ca5de539 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=9 MICRO_VERSION=10 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=43 +EXTRA_VERSION=44 if test $EXTRA_VERSION -eq 0; then VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws else diff --git a/src/compose.c b/src/compose.c index 292f353f8..fb2ea7f83 100644 --- a/src/compose.c +++ b/src/compose.c @@ -500,6 +500,7 @@ static void compose_check_forwards_go (Compose *compose); static gboolean compose_send_control_enter (Compose *compose); static gint compose_defer_auto_save_draft (Compose *compose); +static PrefsAccount *compose_guess_forward_account_from_msginfo (MsgInfo *msginfo); static GtkItemFactoryEntry compose_popup_entries[] = { @@ -1046,33 +1047,10 @@ Compose *compose_forward(PrefsAccount *account, MsgInfo *msginfo, g_return_val_if_fail(msginfo != NULL, NULL); g_return_val_if_fail(msginfo->folder != NULL, NULL); - if (msginfo->folder->prefs->enable_default_account) - account = account_find_from_id(msginfo->folder->prefs->default_account); - if (!account) - account = msginfo->folder->folder->account; - if (!account && msginfo->to && prefs_common.forward_account_autosel) { - gchar *to; - Xstrdup_a(to, msginfo->to, return NULL); - extract_address(to); - account = account_find_from_address(to); - } - - if (!account && prefs_common.forward_account_autosel) { - gchar cc[BUFFSIZE]; - if (!procheader_get_header_from_msginfo(msginfo,cc,sizeof(cc),"CC:")){ /* Found a CC header */ - extract_address(cc); - account = account_find_from_address(cc); - } - } - - if (account == NULL) { + if (!account && + !(account = compose_guess_forward_account_from_msginfo + (msginfo))) account = cur_account; - /* - account = msginfo->folder->folder->account; - if (!account) account = cur_account; - */ - } - g_return_val_if_fail(account != NULL, NULL); compose = compose_create(account, COMPOSE_FORWARD); @@ -1174,19 +1152,17 @@ Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_list) gchar *msgfile; g_return_val_if_fail(msginfo_list != NULL, NULL); - - for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) { - if ( ((MsgInfo *)msginfo->data)->folder == NULL ) + + for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) + if (((MsgInfo *)msginfo->data)->folder == NULL) return NULL; - } - if (account == NULL) { + /* guess account from first selected message */ + if (!account && + !(account = compose_guess_forward_account_from_msginfo + (msginfo_list->data))) account = cur_account; - /* - account = msginfo->folder->folder->account; - if (!account) account = cur_account; - */ - } + g_return_val_if_fail(account != NULL, NULL); for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) { @@ -1198,7 +1174,7 @@ Compose *compose_forward_multiple(PrefsAccount *account, GSList *msginfo_list) text = GTK_STEXT(compose->text); gtk_stext_freeze(text); - + for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) { msgfile = procmsg_get_message_file_path((MsgInfo *)msginfo->data); if (!is_file_exist(msgfile)) @@ -7319,6 +7295,43 @@ static void compose_check_forwards_go(Compose *compose) } #endif +/*! + *\brief Guess originating forward account from MsgInfo and several + * "common preference" settings. Return NULL if no guess. + */ +static PrefsAccount *compose_guess_forward_account_from_msginfo(MsgInfo *msginfo) +{ + PrefsAccount *account = NULL; + + g_return_val_if_fail(msginfo, NULL); + g_return_val_if_fail(msginfo->folder, NULL); + g_return_val_if_fail(msginfo->folder->prefs, NULL); + + if (msginfo->folder->prefs->enable_default_account) + account = account_find_from_id(msginfo->folder->prefs->default_account); + + if (!account) + account = msginfo->folder->folder->account; + + if (!account && msginfo->to && prefs_common.forward_account_autosel) { + gchar *to; + Xstrdup_a(to, msginfo->to, return NULL); + extract_address(to); + account = account_find_from_address(to); + } + + if (!account && prefs_common.forward_account_autosel) { + gchar cc[BUFFSIZE]; + if (!procheader_get_header_from_msginfo + (msginfo, cc,sizeof cc , "CC:")) { /* Found a CC header */ + extract_address(cc); + account = account_find_from_address(cc); + } + } + + return account; +} + /** * Add entry field for each address in list. * \param compose E-Mail composition object.