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

Modified Files:
        Address.cpp 
Log Message:
added more anti-spam filter tests


Index: Address.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/Address.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -b -u -2 -r1.6 -r1.7
--- Address.cpp 26 Apr 2002 13:15:06 -0000      1.6
+++ Address.cpp 18 Jun 2002 14:48:13 -0000      1.7
@@ -27,7 +27,19 @@
 #ifndef USE_PCH
    #include "Mcommon.h"
+
+   #include "strutil.h"
 #endif // USE_PCH
 
 #include "Address.h"
+#include "Mdefaults.h"
+#include "Profile.h"
+
+// ----------------------------------------------------------------------------
+// options we use here
+// ----------------------------------------------------------------------------
+
+extern const MOption MP_FROM_REPLACE_ADDRESSES;
+extern const MOption MP_FROM_ADDRESS;
+extern const MOption MP_LIST_ADDRESSES;
 
 // ============================================================================
@@ -247,8 +259,57 @@
 }
 
-extern bool operator==(const AddressList_obj& addrList1,
-                       const AddressList_obj& addrList2)
+bool
+operator==(const AddressList_obj& addrList1, const AddressList_obj& addrList2)
 {
    return addrList1->IsSameAs(addrList2.operator->());
+}
+
+// ----------------------------------------------------------------------------
+// global functions
+// ----------------------------------------------------------------------------
+
+bool ContainsOwnAddress(const String& str, Profile *profile)
+{
+   // get the list of our own addresses
+   String returnAddrs = READ_CONFIG(profile, MP_FROM_REPLACE_ADDRESSES);
+   if ( returnAddrs == GetStringDefault(MP_FROM_REPLACE_ADDRESSES) )
+   {
+      // the default for this option is just the return address
+      returnAddrs = READ_CONFIG_TEXT(profile, MP_FROM_ADDRESS);
+   }
+
+   wxArrayString addresses = strutil_restore_array(returnAddrs);
+
+   // and also add the mailing list addresses because we consider them to be
+   // "own" as well -- after all we're probably subscribed to them
+   wxArrayString addressesML = strutil_restore_array(
+                                 READ_CONFIG(profile, MP_LIST_ADDRESSES)
+                               );
+   WX_APPEND_ARRAY(addresses, addressesML);
+
+
+   // now check whether any of these addresses occurs in str
+   size_t count = addresses.GetCount();
+   for ( size_t n = 0; n < count; n++ )
+   {
+      if ( str.find(addresses[n]) != String::npos )
+         return true;
+   }
+
+#if 0 // do we really need to do this? IMHO dumb text search is enough
+   AddressList_obj addrList(str);
+   Address *addr = addrList->GetFirst();
+   while ( addr )
+   {
+      if ( addr->IsSameAs() )
+      {
+         return true;
+      }
+
+      addr = addrList->GetNext(addr);
+   }
+#endif // 0
+
+   return false;
 }
 


----------------------------------------------------------------------------
                   Bringing you mounds of caffeinated joy
                      >>>     http://thinkgeek.com/sf    <<<

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

Reply via email to