Update of /cvsroot/mahogany/M/src/classes
In directory usw-pr-cvs1:/tmp/cvs-serv3405/src/classes
Modified Files:
MFilter.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: MFilter.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/MFilter.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -b -u -2 -r1.22 -r1.23
--- MFilter.cpp 8 Sep 2002 19:23:09 -0000 1.22
+++ MFilter.cpp 19 Oct 2002 14:12:47 -0000 1.23
@@ -148,4 +148,5 @@
"score() < ", // ORC_T_ScoreBelow
"istome()", // ORC_T_IsToMe
+ "hasflag(", // ORC_T_HasFlag
NULL
};
@@ -154,26 +155,37 @@
#define ORC_F_NeedsTarget 0x01
#define ORC_F_NeedsArg 0x02
+#define ORC_F_Unimplemented 0x80
static unsigned char ORC_T_Flags[] =
{
- 0, // ORC_T_Always = 0,
- ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_Match,
- ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_Contains,
- ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_MatchC,
- ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_ContainsC,
- ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_MatchRegExC,
- ORC_F_NeedsArg, // ORC_T_LargerThan,
- ORC_F_NeedsArg, // ORC_T_SmallerThan,
- ORC_F_NeedsArg, // ORC_T_OlderThan,
- ORC_F_NeedsArg, // ORC_T_NewerThan,
- ORC_F_NeedsArg, // ORC_T_IsSpam,
- ORC_F_NeedsArg, // ORC_T_Python,
- ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_MatchRegEx,
- ORC_F_NeedsArg, // ORC_T_ScoreAbove,
+ 0, // ORC_T_Always
+ ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_Match
+ ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_Contains
+ ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_MatchC
+ ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_ContainsC
+ ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_MatchRegExC
+ ORC_F_NeedsArg, // ORC_T_LargerThan
+ ORC_F_NeedsArg, // ORC_T_SmallerThan
+ ORC_F_NeedsArg, // ORC_T_OlderThan
+ ORC_F_NeedsArg, // ORC_T_NewerThan
+ ORC_F_NeedsArg, // ORC_T_IsSpam
+#ifndef USE_PYTHON
+ ORC_F_Unimplemented|
+#endif
+ ORC_F_NeedsArg, // ORC_T_Python
+ ORC_F_NeedsTarget|ORC_F_NeedsArg, // ORC_T_MatchRegEx
+#ifndef USE_HEADER_SCORE
+ ORC_F_Unimplemented|
+#endif
+ ORC_F_NeedsArg, // ORC_T_ScoreAbove
+#ifndef USE_HEADER_SCORE
+ ORC_F_Unimplemented|
+#endif
ORC_F_NeedsArg, // ORC_T_ScoreBelow
0, // ORC_T_IsToMe
+ ORC_F_NeedsArg // ORC_T_HasFlag
};
-bool FilterTestNeedsArgument(int test)
+bool FilterTestNeedsArgument(MFDialogTest test)
{
CHECK( test >= 0 && (unsigned)test < WXSIZEOF(ORC_T_Flags), false,
@@ -183,5 +195,5 @@
}
-bool FilterTestNeedsTarget(int test)
+bool FilterTestNeedsTarget(MFDialogTest test)
{
CHECK( test >= 0 && (unsigned)test < WXSIZEOF(ORC_T_Flags), false,
@@ -191,15 +203,23 @@
}
+bool FilterTestImplemented(MFDialogTest test)
+{
+ CHECK( test >= 0 && (unsigned)test < WXSIZEOF(ORC_T_Flags), false,
+ _T("invalid filter test") );
+
+ return (ORC_T_Flags[test] & ORC_F_Unimplemented) == 0;
+}
+
static
const char * ORC_W_Names[] =
{
- "subject()",
- "header()",
- "from()",
- "body()",
- "message()",
- "to()",
- "header(\"Sender\")",
- "recipients()",
+ "subject()", // ORC_W_Subject
+ "header()", // ORC_W_Header
+ "from()", // ORC_W_From
+ "body()", // ORC_W_Body
+ "message()", // ORC_W_Message
+ "to()", // ORC_W_To
+ "header(\"Sender\")", // ORC_W_Sender
+ "recipients()", // ORC_W_Recipients
NULL
};
@@ -207,32 +227,51 @@
static const char * OAC_T_Names[] =
{
- "delete(",
- "copy(",
- "move(",
- "expunge(",
- "message(",
- "log(",
- "python(",
- "addscore(",
- "setcolour(",
- "zap(",
- "print(",
+ "delete(", // OAC_T_Delete
+ "copy(", // OAC_T_CopyTo
+ "move(", // OAC_T_MoveTo
+ "expunge(", // OAC_T_Expunge
+ "message(", // OAC_T_MessageBox
+ "log(", // OAC_T_LogEntry
+ "python(", // OAC_T_Python
+ "addscore(", // OAC_T_AddScore
+ "setcolour(", // OAC_T_SetColour
+ "zap(", // OAC_T_Zap
+ "print(", // OAC_T_Print
+ "setflag(", // OAC_T_SetFlag
+ "clearflag(", // OAC_T_ClearFlag
+ "setscore(", // OAC_T_SetScore
NULL
};
#define OAC_F_NeedsArg 0x01
+#define OAC_F_Colour 0x02
+#define OAC_F_Folder 0x04
+#define OAC_F_MsgFlag 0x08
+#define OAC_F_Unimplemented 0x80
static unsigned char OAC_T_Flags[] =
{
- 0,
- OAC_F_NeedsArg,
- OAC_F_NeedsArg,
- 0,
- OAC_F_NeedsArg,
- OAC_F_NeedsArg,
- OAC_F_NeedsArg,
- OAC_F_NeedsArg,
- OAC_F_NeedsArg,
- 0,
- 0,
+ 0, // OAC_T_Delete
+ OAC_F_NeedsArg|OAC_F_Folder, // OAC_T_CopyTo
+ OAC_F_NeedsArg|OAC_F_Folder, // OAC_T_MoveTo
+ 0, // OAC_T_Expunge
+ OAC_F_NeedsArg, // OAC_T_MessageBox
+ OAC_F_NeedsArg, // OAC_T_LogEntry
+#ifndef USE_PYTHON
+ OAC_F_Unimplemented|
+#endif
+ OAC_F_NeedsArg, // OAC_T_Python
+#ifndef USE_HEADER_SCORE
+ OAC_F_Unimplemented|
+#endif
+ OAC_F_NeedsArg, // OAC_T_AddScore
+ OAC_F_NeedsArg|OAC_F_Colour, // OAC_T_SetColour
+ 0, // OAC_T_Zap
+ 0, // OAC_T_Print
+ OAC_F_NeedsArg|OAC_F_MsgFlag, // OAC_T_SetFlag
+ OAC_F_NeedsArg|OAC_F_MsgFlag, // OAC_T_ClearFlag
+#ifndef USE_HEADER_SCORE
+ OAC_F_Unimplemented|
+#endif
+ OAC_F_NeedsArg // OAC_T_SetScore
};
@@ -246,4 +285,44 @@
MismatchInTargetArray );
+bool FilterActionNeedsArg(MFDialogAction action)
+{
+ CHECK( action >= 0 && (unsigned)action < WXSIZEOF(ORC_T_Flags), false,
+ _T("invalid filter action") );
+
+ return (OAC_T_Flags[action] & OAC_F_NeedsArg) != 0;
+}
+
+bool FilterActionUsesColour(MFDialogAction action)
+{
+ CHECK( action >= 0 && (unsigned)action < WXSIZEOF(ORC_T_Flags), false,
+ _T("invalid filter action") );
+
+ return (OAC_T_Flags[action] & OAC_F_Colour) != 0;
+}
+
+bool FilterActionUsesFolder(MFDialogAction action)
+{
+ CHECK( action >= 0 && (unsigned)action < WXSIZEOF(ORC_T_Flags), false,
+ _T("invalid filter action") );
+
+ return (OAC_T_Flags[action] & OAC_F_Folder) != 0;
+}
+
+bool FilterActionMsgFlag(MFDialogAction action)
+{
+ CHECK( action >= 0 && (unsigned)action < WXSIZEOF(ORC_T_Flags), false,
+ _T("invalid filter action") );
+
+ return (OAC_T_Flags[action] & OAC_F_MsgFlag) != 0;
+}
+
+bool FilterActionImplemented(MFDialogAction action)
+{
+ CHECK( action >= 0 && (unsigned)action < WXSIZEOF(ORC_T_Flags), false,
+ _T("invalid filter action") );
+
+ return (OAC_T_Flags[action] & OAC_F_Unimplemented) == 0;
+}
+
String
MFDialogComponent::WriteTest(void)
@@ -251,5 +330,6 @@
String program;
- CHECK( m_Test >= 0 && m_Test < ORC_T_Max, program, _T("illegal filter test") );
+ CHECK( m_Test >= 0 && m_Test < ORC_T_Max, program,
+ _T("illegal filter test") );
// This returns the bit to go into an if between the brackets:
@@ -524,5 +604,5 @@
return "";
}
- bool needsArgument = OAC_T_Flags[m_Action] & OAC_F_NeedsArg;
+ bool needsArgument = FilterActionNeedsArg(m_Action);
program << OAC_T_Names[m_Action];
if(needsArgument)
@@ -561,5 +641,5 @@
break;
}
- bool needsArgument = OAC_T_Flags[m_Action] & OAC_F_NeedsArg;
+ bool needsArgument = FilterActionNeedsArg(m_Action);
if(needsArgument)
{
@@ -731,5 +811,6 @@
// if we have matching dialog settings, we prefer to
// write them as they are more compact in the config file
- m_Profile->writeEntry(MP_FILTER_GUIDESC, m_Settings->WriteSettings());
+ m_Profile->writeEntry(MP_FILTER_GUIDESC,
+ m_Settings->WriteSettings());
}
else
@@ -937,3 +1018,2 @@
return filterRule;
}
-
-------------------------------------------------------
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