* src/compose.c
authorAlfons Hoogervorst <alfons@proteus.demon.nl>
Sat, 10 Apr 2004 14:01:45 +0000 (14:01 +0000)
committerAlfons Hoogervorst <alfons@proteus.demon.nl>
Sat, 10 Apr 2004 14:01:45 +0000 (14:01 +0000)
appropriate auto account selection when forwarding
(fixes bug #476, "forward as attachment does not listen
to account rules")

ChangeLog.claws
configure.ac
src/compose.c

index a9f1f78..b1e5188 100644 (file)
@@ -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
index 50a20e7..1ca5de5 100644 (file)
@@ -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
index 292f353..fb2ea7f 100644 (file)
@@ -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.