Update of /cvsroot/mahogany/M/src/modules
In directory sc8-pr-cvs1:/tmp/cvs-serv29856/src/modules

Modified Files:
        Filters.cpp 
Log Message:
Don't show subject while filtering spam (shut up header prefetch)

Index: Filters.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/Filters.cpp,v
retrieving revision 1.160
retrieving revision 1.161
diff -b -u -2 -r1.160 -r1.161
--- Filters.cpp 3 Oct 2003 15:27:57 -0000       1.160
+++ Filters.cpp 3 Oct 2003 17:08:06 -0000       1.161
@@ -208,7 +208,9 @@
    };
 
-   // implement the base class pure virtual
+   // implement the base class pure virtuals
    virtual int Apply(MailFolder *folder, UIdArray& msgs);
 
+   virtual bool ContainsSpamTest();
+
    static FilterRule * Create(const String &filterrule,
                               MInterface *minterface,
@@ -343,4 +345,8 @@
         m_hasHeaderFunc;
 
+   // Cache for ContainsSpamTest
+   bool m_spamTestValid;
+   bool m_spamTest;
+
    friend class FilterRuleApply;
 
@@ -476,5 +482,4 @@
    void ProgressDelete();
    void IndicateDeleted();
-   bool ContainsSpamTest();
 
    static String GetExecuteProgressString(const String& s)
@@ -506,8 +511,4 @@
    // Result of evaluating filter
    Value m_retval;
-   
-   // Cache for ContainsSpamTest
-   bool m_spamTestValid;
-   bool m_spamTest;
 };
 
@@ -3320,4 +3321,26 @@
 }
 
+bool
+FilterRuleImpl::ContainsSpamTest()
+{
+   // Member m_Program is initialized in constructor and it is not
+   // modified afterwards. That means we can easily cache our results.
+   if( !m_spamTestValid )
+   {
+      m_spamTest = false;
+      for( SyntaxNodeIterator each(m_Program); !each.End(); ++each )
+      {
+         const SyntaxNode *node = each.Actual();
+         if( node->IsFunctionCall() )
+         {
+            const FunctionCall *call = (const FunctionCall *)node;
+            m_spamTest = m_spamTest || (call && call->Name() == "isspam");
+         }
+      }
+   }
+   
+   return m_spamTest;
+}
+
 FilterRuleImpl::FilterRuleImpl(const String &filterrule,
                                MInterface *minterface,
@@ -3340,4 +3363,6 @@
    m_MailMessage = NULL;
    m_MailFolder = NULL;
+   m_spamTestValid = false;
+   m_spamTest = false;
 }
 
@@ -3369,6 +3394,4 @@
    m_pd = NULL;
    m_doExpunge = false;
-   m_spamTestValid = false;
-   m_spamTest = false;
 }
 
@@ -3578,8 +3601,7 @@
    String from = MailFolder::DecodeHeader(m_parent->m_MailMessage->From());
 
-   if( ContainsSpamTest() )
+   if( m_parent->ContainsSpamTest() )
    {
-      subject = _("(hidden in spam filter)");
-      from = _("(hidden in spam filter)");
+      subject = from = _("(hidden in spam filter)");
    }
    
@@ -3852,25 +3874,4 @@
       m_msgs.RemoveAt(m_indicesDeleted[n - 1]);
    }
-}
-
-bool
-FilterRuleApply::ContainsSpamTest()
-{
-   if( !m_spamTestValid )
-   {
-      m_spamTest = false;
-      for( SyntaxNodeIterator each(m_parent->m_Program); !each.End();
-         ++each )
-      {
-         const SyntaxNode *node = each.Actual();
-         if( node->IsFunctionCall() )
-         {
-            const FunctionCall *call = (const FunctionCall *)node;
-            m_spamTest = m_spamTest || (call && call->Name() == "isspam");
-         }
-      }
-   }
-   
-   return m_spamTest;
 }
 



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to