Update of /cvsroot/mahogany/M/src/mail
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29690/src/mail

Modified Files:
        SpamFilter.cpp 
Log Message:
added spam filter cost and use the cheapest filters first

Index: SpamFilter.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/SpamFilter.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -u -2 -r1.3 -r1.4
--- SpamFilter.cpp      10 Jul 2004 20:26:45 -0000      1.3
+++ SpamFilter.cpp      10 Jul 2004 20:55:38 -0000      1.4
@@ -84,10 +84,12 @@
    for ( size_t n = 0; n < count; n++ )
    {
-      const wxString& param = params[n];
+      wxString param = params[n];
       int pos = param.Find(_T('='));
       if ( pos == wxNOT_FOUND )
       {
-         wxLogDebug(_T("Invalid spam filter parameter \"%s\""), param.c_str());
-         continue;
+         // hack: for backwards compatibility with older versions when there
+         // was only one spam filter
+         param = _T("headers=") + param;
+         pos = 7;
       }
 
@@ -152,8 +154,24 @@
          factory = static_cast<SpamFilterFactory *>(module);
 
-      // create the filter and insert it into the linked list
-      SpamFilter *next = ms_first;
-      ms_first = factory->Create();
-      ms_first->m_next = next;
+      // create the filter and insert it into the linked list ordered by cost
+      SpamFilter * const filterNew = factory->Create();
+
+      const unsigned int cost = filterNew->GetCost();
+      SpamFilter **next = &ms_first;
+      for ( SpamFilter *filter = ms_first; ; filter = filter->m_next )
+      {
+         // insert it here?
+         if ( !filter || cost < filter->GetCost() )
+         {
+            // yes, adjust the links
+            *next = filterNew;
+
+            filterNew->m_next = filter;
+
+            break;
+         }
+
+         next = &filter->m_next;
+      }
 
       factory->DecRef();



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to