Update of /cvsroot/mahogany/M/src/modules
In directory usw-pr-cvs1:/tmp/cvs-serv3405/src/modules
Modified Files:
Filters.cpp
Log Message:
patches from Michael A Chase:
1. added new filter test hasflag()
2. and new filter actions set/clearflag()
3. hide unimplemented (in this binary) filter tests in the GUI
4. general clean up of filter code
Index: Filters.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/Filters.cpp,v
retrieving revision 1.135
retrieving revision 1.136
diff -b -u -2 -r1.135 -r1.136
--- Filters.cpp 25 Sep 2002 16:47:07 -0000 1.135
+++ Filters.cpp 19 Oct 2002 14:12:47 -0000 1.136
@@ -718,5 +718,6 @@
{
public:
- QueryOp(const SyntaxNode *cond, const SyntaxNode *left, const SyntaxNode *right)
+ QueryOp(const SyntaxNode *cond, const SyntaxNode *left,
+ const SyntaxNode *right)
: m_Cond(cond), m_Left(left), m_Right(right)
{
@@ -1547,5 +1548,6 @@
return NULL;
}
-LeftAssoc(BAnds,BAndOp,Relational,_("Expected expression after bit AND operator"))
+LeftAssoc(BAnds,BAndOp,Relational,
+ _("Expected expression after bit AND operator"))
static inline OpCreate
@@ -1613,5 +1615,6 @@
}
}
-LeftAssoc(Factor,MulOp,Unary,_("Expected factor after multiply/divide/modulus
operator"))
+LeftAssoc(Factor,MulOp,Unary,
+ _("Expected factor after multiply/divide/modulus operator"))
const SyntaxNode *
@@ -2127,5 +2130,6 @@
if ( !count )
{
- wxLogWarning(_("No SPAM tests configured, please edit this filter rule."));
+ wxLogWarning(
+ _("No SPAM tests configured, please edit this filter rule."));
return Value();
@@ -2490,4 +2494,33 @@
}
+static Value func_hasflag(ArgList *args, FilterRuleImpl *p)
+{
+ if(args->Count() != 1)
+ return Value(false);
+ const Value v1 = args->GetArg(0)->Evaluate();
+ String flag_str = v1.ToString();
+ if(flag_str.Length() != 1)
+ return Value(false);
+ Message_obj msg = p->GetMessage();
+ if(! msg)
+ return Value(false);
+ int status = msg->GetStatus();
+
+ if ( flag_str == "U" ) // Unread (result is inverted)
+ return Value(status & MailFolder::MSG_STAT_SEEN ? false : true);
+ else if ( flag_str == "D" ) // Deleted
+ return Value(status & MailFolder::MSG_STAT_DELETED ? true : false);
+ else if ( flag_str == "A" ) // Answered
+ return Value(status & MailFolder::MSG_STAT_ANSWERED ? true : false);
+ else if ( flag_str == "R" ) // Recent
+ return Value(status & MailFolder::MSG_STAT_RECENT ? true : false);
+// else if ( flag_str == "S" ) // Search match
+// return Value(status & MailFolder::MSG_STAT_SEARCHED ? true : false);
+ else if ( flag_str == "*" ) // Flagged/Important
+ return Value(status & MailFolder::MSG_STAT_FLAGGED ? true : false);
+
+ return Value(false);
+}
+
static Value func_header(ArgList *args, FilterRuleImpl *p)
{
@@ -2649,4 +2682,33 @@
}
+static Value func_setscore(ArgList *args, FilterRuleImpl *p)
+{
+ if(args->Count() != 1)
+ return Value(-1);
+
+ const Value d = args->GetArg(0)->Evaluate();
+
+#ifdef USE_HEADER_SCORE
+ MailFolder_obj mf = p->GetFolder();
+ if ( mf )
+ {
+ HeaderInfoList_obj hil = mf->GetHeaders();
+ if(hil)
+ {
+ Message_obj msg = p->GetMessage();
+ if ( msg )
+ {
+ // MAC: I'd rather use ->SetScore() or something similar,
+ // MAC: but I couldn't find any of the scoring methods.
+ int score = hil->GetEntryUId( msg->GetUId() )->GetScore();
+ hil->GetEntryUId( msg->GetUId() )->AddScore(d.ToNumber() - score);
+ }
+ }
+ }
+#endif // USE_HEADER_SCORE
+
+ return Value(0);
+}
+
static Value func_addscore(ArgList *args, FilterRuleImpl *p)
{
@@ -2674,4 +2736,5 @@
return Value(0);
}
+
static Value func_setcolour(ArgList *args, FilterRuleImpl *p)
{
@@ -2700,4 +2763,50 @@
}
+static Value func_do_setflag(ArgList *args, FilterRuleImpl *p, bool set)
+{
+ if(args->Count() != 1)
+ return Value(false);
+ const Value v1 = args->GetArg(0)->Evaluate();
+ String flag_str = v1.ToString();
+ if(flag_str.Length() != 1)
+ return Value(false);
+
+ int flag = 0;
+ if ( flag_str == "U" ) // Unread, inverse of actual flag (SEEN)
+ {
+ flag = MailFolder::MSG_STAT_SEEN;
+ set = ! set;
+ }
+ else if ( flag_str == "D" ) // Deleted
+ flag = MailFolder::MSG_STAT_DELETED;
+ else if ( flag_str == "A" ) // Answered
+ flag = MailFolder::MSG_STAT_ANSWERED;
+ // The Recent flag is not changable.
+ // else if ( flag_str == "R" ) // Recent
+ // flag = MailFolder::MSG_STAT_RECENT;
+// else if ( flag_str == "S" ) // Search match
+// flag = MailFolder::MSG_STAT_SEARCHED;
+ else if ( flag_str == "*" ) // Flagged/Important
+ flag = MailFolder::MSG_STAT_FLAGGED;
+ else
+ return Value(false);
+
+ // Set or clear the selected flag
+ MailFolder_obj mf = p->GetFolder();
+ if ( ! mf )
+ return Value(false);
+ return Value(mf->SetMessageFlag(p->GetMessageUId(), flag, set));
+}
+
+static Value func_setflag(ArgList *args, FilterRuleImpl *p)
+{
+ return func_do_setflag(args, p, true);
+}
+
+static Value func_clearflag(ArgList *args, FilterRuleImpl *p)
+{
+ return func_do_setflag(args, p, false);
+}
+
/* * * * * * * * * * * * * * *
@@ -2757,4 +2866,5 @@
Define("headerline", func_headerline);
Define("from", func_from);
+ Define("hasflag", func_hasflag);
Define("header", func_header);
Define("body", func_body);
@@ -2774,6 +2884,9 @@
Define("setcolour", func_setcolour);
Define("score", func_score);
+ Define("setscore", func_setscore);
Define("addscore", func_addscore);
Define("istome", func_istome);
+ Define("setflag", func_setflag);
+ Define("clearflag", func_clearflag);
#ifdef TEST
Define("nargs", func_nargs);
@@ -2871,5 +2984,6 @@
{
// maybe another session deleted it?
- wxLogDebug(_T("Filter error: message with UID %ld in folder '%s' doesn't
exist any more."),
+ wxLogDebug(
+ _T("Filter error: message with UID %ld in folder '%s' doesn't exist
+any more."),
m_MessageUId, m_MailFolder->GetName().c_str());
continue;
@@ -3106,7 +3220,6 @@
// remove the deleted messages from msgs
-
- // iterate from end because otherwise the indices would shift while
we
- // traverse them
+ // iterate from end because otherwise the indices would shift
+ // while we traverse them
size_t count = indicesDeleted.GetCount();
for ( size_t n = count; n > 0; n-- )
@@ -3408,3 +3521,2 @@
}
#endif // TEST
-
-------------------------------------------------------
This sf.net email is sponsored by:
Access Your PC Securely with GoToMyPC. Try Free Now
https://www.gotomypc.com/s/OSND/DD
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates