Update of /cvsroot/mahogany/M/src/modules
In directory sc8-pr-cvs1:/tmp/cvs-serv22470/src/modules
Modified Files:
Filters.cpp
Log Message:
Don't show subject while running spam filter, it's like watching commercials...
Index: Filters.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/Filters.cpp,v
retrieving revision 1.157
retrieving revision 1.158
diff -b -u -2 -r1.157 -r1.158
--- Filters.cpp 30 Sep 2003 13:46:22 -0000 1.157
+++ Filters.cpp 2 Oct 2003 14:53:44 -0000 1.158
@@ -476,4 +476,5 @@
void ProgressDelete();
void IndicateDeleted();
+ bool ContainsSpamTest();
static String GetExecuteProgressString(const String& s)
@@ -505,4 +506,8 @@
// Result of evaluating filter
Value m_retval;
+
+ // Cache for ContainsSpamTest
+ bool m_spamTestValid;
+ bool m_spamTest;
};
@@ -520,4 +525,7 @@
virtual String ToString(void) const
{ return Evaluate().ToString(); }
+ virtual const SyntaxNode *GetChild(size_t order) const { return NULL; }
+ virtual const SyntaxNode *GetNext() const { return NULL; }
+ virtual bool IsFunctionCall() const { return false; }
#ifdef DEBUG
virtual String Debug(void) const = 0;
@@ -527,4 +535,20 @@
};
+// TreeIterator-compatible wrapper around SyntaxNode
+class SyntaxNodeIteratorDriver
+{
+public:
+ typedef const SyntaxNode *Type;
+
+ const SyntaxNode *GetChild(const SyntaxNode *actual,size_t child)
+ { return actual->GetChild(child); }
+ const SyntaxNode *GetNext(const SyntaxNode *actual)
+ { return actual->GetNext(); }
+ bool IsNull(const SyntaxNode *actual) { return actual == NULL; }
+};
+
+// SyntaxNodeIterator walks all nodes deriving from SyntaxNode
+DECLARE_TREE_ITERATOR(SyntaxNodeIterator,SyntaxNodeIteratorDriver);
+
class SequentialEval : public SyntaxNode
{
@@ -550,4 +574,7 @@
return m_Next->Evaluate();
}
+ virtual const SyntaxNode *GetChild(size_t order) const
+ { return order == 0 ? m_Rule : NULL; }
+ virtual const SyntaxNode *GetNext() const { return m_Next; }
protected:
@@ -654,4 +681,6 @@
}
#endif
+ virtual const SyntaxNode *GetChild(size_t order) const
+ { return order == 0 ? m_Sn : NULL; }
private:
const SyntaxNode *m_Sn;
@@ -680,4 +709,6 @@
}
#endif
+ virtual const SyntaxNode *GetChild(size_t order) const
+ { return order == 0 ? m_Sn : NULL; }
private:
const SyntaxNode *m_Sn;
@@ -784,4 +815,8 @@
}
#endif
+ virtual const SyntaxNode *GetChild(size_t order) const
+ { return order < m_args->Count() ? m_args->GetArg(order) : NULL; }
+ String Name() const { return m_fd->GetName(); }
+ virtual bool IsFunctionCall() const { return true; }
private:
const FunctionDefinition *m_fd;
@@ -828,4 +863,14 @@
}
#endif
+ virtual const SyntaxNode *GetChild(size_t order) const
+ {
+ switch(order)
+ {
+ case 0: return m_Cond;
+ case 1: return m_Left;
+ case 2: return m_Right;
+ }
+ return NULL;
+ }
private:
@@ -859,4 +904,13 @@
}
#endif
+ virtual const SyntaxNode *GetChild(size_t order) const
+ {
+ switch(order)
+ {
+ case 0: return m_Left;
+ case 1: return m_Right;
+ }
+ return NULL;
+ }
protected:
const SyntaxNode *m_Left, *m_Right;
@@ -1022,4 +1076,14 @@
}
#endif
+ virtual const SyntaxNode *GetChild(size_t order) const
+ {
+ switch(order)
+ {
+ case 0: return m_Condition;
+ case 1: return m_IfBlock;
+ case 2: return m_ElseBlock;
+ }
+ return NULL;
+ }
private:
const SyntaxNode *m_Condition, *m_IfBlock, *m_ElseBlock;
@@ -3295,4 +3359,6 @@
m_pd = NULL;
m_doExpunge = false;
+ m_spamTestValid = false;
+ m_spamTest = false;
}
@@ -3502,4 +3568,10 @@
String from = MailFolder::DecodeHeader(m_parent->m_MailMessage->From());
+ if( ContainsSpamTest() )
+ {
+ subject = _("(hidden in spam filter)");
+ from = _("(hidden in spam filter)");
+ }
+
m_textLog.Printf(_("Filtering message %u/%u"),
m_idx + 1, m_msgs.GetCount());
@@ -3770,4 +3842,25 @@
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