Update of /cvsroot/mahogany/M/src/mail
In directory usw-pr-cvs1:/tmp/cvs-serv24601/src/mail

Modified Files:
        MailFolder.cpp 
Log Message:
better setting of "To" by default in the messages from ourselves (bug 569)

Index: MailFolder.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolder.cpp,v
retrieving revision 1.271
retrieving revision 1.272
diff -b -u -2 -r1.271 -r1.272
--- MailFolder.cpp      21 Feb 2002 17:05:39 -0000      1.271
+++ MailFolder.cpp      22 Feb 2002 21:26:20 -0000      1.272
@@ -758,7 +758,16 @@
    }
 
+   // our own addresses - used in the code below
+   String returnAddrs = READ_CONFIG(profile, MP_FROM_REPLACE_ADDRESSES);
+   wxArrayString ownAddresses = strutil_restore_array(returnAddrs);
+
+   // is this a message from ourselves?
+   bool fromMyself = false;
+
+   // first try Reply-To
    wxSortedArrayString replyToAddresses;
-   size_t n,
-          countReplyTo = msg->GetAddresses(MAT_REPLYTO, replyToAddresses);
+   size_t countReplyTo = msg->GetAddresses(MAT_REPLYTO, replyToAddresses);
+
+   size_t n, count; // loop variables
 
    // REPLY_LIST overrides any Reply-To in the header
@@ -770,4 +779,5 @@
       // the Reply-To address had been mangled by the mailing list to point to
       // it instead
+      String rcptMain;
       if ( (explicitReplyKind && replyKind == MailFolder::REPLY_SENDER) ||
             !countReplyTo )
@@ -776,9 +786,31 @@
          //
          // FIXME: original encoding is lost here
-         cv->AddTo(MailFolder::DecodeHeader(msg->From()));
+         rcptMain = MailFolder::DecodeHeader(msg->From());
       }
       else // have Reply-To
       {
-         for ( n = 0; n < countReplyTo; n++ )
+         rcptMain = MailFolder::DecodeHeader(replyToAddresses[0]);
+      }
+
+      // an additional complication: when replying to a message written by
+      // oneself you don't usually want to reply to you at all but, instead,
+      // use the "To:" address of the original message for your reply as well -
+      // the code below catches this particular case
+      fromMyself = Message::FindAddress(ownAddresses, rcptMain) != wxNOT_FOUND;
+      if ( fromMyself )
+      {
+         wxArrayString addresses;
+         size_t count = msg->GetAddresses(MAT_TO, addresses);
+         for ( n = 0; n < count; n++ )
+         {
+            cv->AddTo(addresses[n]);
+         }
+      }
+      else // not from myself
+      {
+         cv->AddTo(rcptMain);
+
+         // add the remaining Reply-To addresses (usually there will be none)
+         for ( n = 1; n < countReplyTo; n++ )
          {
             // FIXME: same as above
@@ -821,9 +853,12 @@
    {
       // use From only if not done already above
-      if ( countReplyTo > 0 )
+      if ( countReplyTo > 0 || fromMyself )
          otherAddresses.Add(msg->From());
    }
 
    msg->GetAddresses(MAT_CC, otherAddresses);
+
+   // for messages from oneself we already used the "To" recipients above
+   if ( !fromMyself )
    msg->GetAddresses(MAT_TO, otherAddresses);
 
@@ -834,8 +869,9 @@
 #endif // 0
 
-   // decode headers before comparing them - the problem is that we lost their
-   // original encoding when doing this
-   for ( n = 0; n < otherAddresses.GetCount(); n++ )
+   // decode headers before comparing them
+   count = otherAddresses.GetCount();
+   for ( n = 0; n < count; n++ )
    {
+      // FIXME: as above, we lose the original encoding here
       otherAddresses[n] = MailFolder::DecodeHeader(otherAddresses[n]);
    }
@@ -844,12 +880,6 @@
    wxArrayString uniqueAddresses = strutil_uniq_array(otherAddresses);
 
-   // and also filter out the addresses used in to as well as our own
-   // address(es) by putting their indices into addressesToIgnore array
-   String returnAddrs = READ_CONFIG(profile, MP_FROM_REPLACE_ADDRESSES);
-   wxArrayString ownAddresses = strutil_restore_array(returnAddrs);
-
-   // finally, if we're in REPLY_LIST mode, also remember which reply
-   // addresses correspond to the mailing lists as we want to reply to them
-   // only
+   // if we're in REPLY_LIST mode, also remember which reply addresses
+   // correspond to the mailing lists as we want to reply to them only
    wxArrayString listAddresses;
    if ( replyKind == MailFolder::REPLY_LIST )
@@ -928,5 +958,5 @@
    }
 
-   size_t count = uniqueAddresses.GetCount();
+   count = uniqueAddresses.GetCount();
    for ( n = 0; n < count; n++ )
    {


_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to