Added both power and ease-of-use to the Match Header addon. A regular case-sensitive string search is done unless REGEX: appears at the beginning, in which case a full-blown regular expression search is done
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19683 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -50,8 +50,8 @@ RuleFilterConfig::RuleFilterConfig(BMessage *settings) : BView(BRect(0,0,260,85)
|
||||
attr->SetText(settings->FindString("attribute"));
|
||||
AddChild(attr);
|
||||
|
||||
regex = new BTextControl(BRect(104,5,255,20),"attr",MDR_DIALECT_CHOICE (" is "," が "),MDR_DIALECT_CHOICE ("value (can be a regular expression, like *spam*)","値(正規表現対応)"),NULL);
|
||||
regex->SetDivider(be_plain_font->StringWidth(MDR_DIALECT_CHOICE (" is "," が ")) + 4);
|
||||
regex = new BTextControl(BRect(104,5,255,20),"attr",MDR_DIALECT_CHOICE (" has "," が "),MDR_DIALECT_CHOICE ("value (use REGEX: in from of regular expressions like *spam*)","値(正規表現対応)"),NULL);
|
||||
regex->SetDivider(be_plain_font->StringWidth(MDR_DIALECT_CHOICE (" has "," が ")) + 4);
|
||||
if (settings->HasString("regex"))
|
||||
regex->SetText(settings->FindString("regex"));
|
||||
AddChild(regex);
|
||||
|
||||
@@ -21,9 +21,16 @@ RuleFilter::RuleFilter(BMessage *settings) : BMailFilter(settings) {
|
||||
attr.CapitalizeEachWord();
|
||||
attribute = strdup(attr.String());
|
||||
|
||||
const char *regex = NULL;
|
||||
BString regex;
|
||||
settings->FindString("regex",®ex);
|
||||
matcher.SetPattern(regex,true);
|
||||
|
||||
int32 index = regex.FindFirst("REGEX:");
|
||||
if (index == B_ERROR || index > 0)
|
||||
EscapeRegexTokens(regex);
|
||||
else
|
||||
regex.RemoveFirst("REGEX:");
|
||||
|
||||
matcher.SetPattern(regex.String(),false);
|
||||
|
||||
settings->FindString("argument",&arg);
|
||||
settings->FindInt32("do_what",(long *)&do_what);
|
||||
@@ -59,10 +66,10 @@ status_t RuleFilter::ProcessMailMessage
|
||||
|
||||
if (data == NULL) //--- How would this happen? No idea
|
||||
return B_OK;
|
||||
|
||||
|
||||
if (!matcher.Match(data))
|
||||
return B_OK; //-----There wasn't an error. We're just not supposed to do anything
|
||||
|
||||
|
||||
switch (do_what) {
|
||||
case Z_MOVE_TO:
|
||||
if (io_headers->ReplaceString("DESTINATION",arg) != B_OK)
|
||||
|
||||
Reference in New Issue
Block a user