Esempio n. 1
0
void AutoCollectAddresses(const Message *message,
                          MAction autocollectFlag,
                          bool senderOnly,
                          bool collectNamed,
                          const String& bookName,
                          const String& groupName,
                          wxFrame *frame)
{
   static const MessageAddressType addressTypesToCollect[] =
   {
      // In this array, the values corresponding to 'Sender' headers
      // (e.g. From and ReplyTo) must appear before the others. And if
      // some other 'sender' headers must be taken into account, the ending
      // index in the for loop below (named stopAt) must be changed.
      MAT_REPLYTO,
      MAT_FROM,
      MAT_TO,
      MAT_CC,
   };

   // the email addresses we have already seen
   wxArrayString addressesSeen;

   const size_t stopAt = senderOnly ? 2 : WXSIZEOF(addressTypesToCollect);
   for ( size_t n = 0; n < stopAt; n++ )
   {
      AddressList *addrList = message->GetAddressList(addressTypesToCollect[n]);
      if ( !addrList )
         continue;

      for ( Address *addr = addrList->GetFirst();
            addr;
            addr = addrList->GetNext(addr) )
      {
         const String email = addr->GetEMail();
         if ( addressesSeen.Index(email) == wxNOT_FOUND )
         {
            addressesSeen.Add(email);

            AutoCollectAddress(email,
                               addr->GetName(),
                               autocollectFlag,
                               collectNamed,
                               bookName,
                               groupName,
                               frame);
         }
      }

      addrList->DecRef();
   }
}