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

Modified Files:
        wxComposeView.cpp 
Log Message:
try harder to avoid having duplicate addresses in the composer -- this is especially 
important for group replies

Index: wxComposeView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/gui/wxComposeView.cpp,v
retrieving revision 1.280
retrieving revision 1.281
diff -b -u -2 -r1.280 -r1.281
--- wxComposeView.cpp   13 May 2002 00:27:39 -0000      1.280
+++ wxComposeView.cpp   26 May 2002 23:02:02 -0000      1.281
@@ -266,4 +266,7 @@
    wxComposeView::RecipientType GetType() const;
 
+   // change the address type
+   void SetType(wxComposeView::RecipientType rcptType);
+
    // get the current value of the text field
    wxString GetValue() const;
@@ -749,4 +752,11 @@
 }
 
+void wxRcptControl::SetType(wxComposeView::RecipientType rcptType)
+{
+   m_choice->SetSelection(rcptType);
+
+   OnTypeChange(rcptType);
+}
+
 wxString wxRcptControl::GetValue() const
 {
@@ -1840,17 +1850,11 @@
    size_t count = m_rcptExtra.GetCount();
 
-   bool foundWithAnotherType = false;
    for ( size_t n = 0; n < count; n++ )
    {
-      if ( !IsRecipientEnabled(n) )
-      {
-         // type "none" doesn't count
-         continue;
-      }
-
       if ( Message::CompareAddresses(m_rcptExtra[n]->GetValue(), addr) )
       {
          // ok, we already have this address - is it of the same type?
-         if ( m_rcptExtra[n]->GetType() == addrType )
+         RecipientType existingType = m_rcptExtra[n]->GetType();
+         if ( existingType == addrType )
          {
             // yes, don't add it again
@@ -1859,25 +1863,34 @@
                           "not added."),
                         addr.c_str());
-            return;
          }
+         else // found with a different type
+         {
+            // use the "stronger" recipient type, i.e. if the address was
+            // previously in "Cc" but is now added as "To", make the existing
+            // address "To"
+            if ( existingType > addrType )
+            {
+               wxLogStatus(this,
+                           _("Address '%s' was already in the recipients list "
+                             "with a different type, just changed the type."),
+                           addr.c_str());
 
-         foundWithAnotherType = true;
-
-         // continue - we may yet find it with the same typ later
+               m_rcptExtra[n]->SetType(addrType);
       }
-   }
-
-   if ( foundWithAnotherType )
+            else
    {
-      // warn the user that the address is already present but add it
-      // nevertheless - I think this is the most reasonable thing to do,
-      // anything better?
       wxLogStatus(this,
-                  _("Address '%s' is already in the recipients list but "
-                    "with a different type - will be duplicated."),
+                           _("Address '%s' was already in the recipients list "
+                             "with a different type, not added."),
                   addr.c_str());
    }
+         }
+
+         // don't add it again
+         return;
+      }
+   }
 
-   // do add it (either not found or found with a different address)
+   // do add it if not found
    AddRecipientControls(addr, addrType);
 }


_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm

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

Reply via email to