mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-19 01:51:03 +00:00
Only ignore invalid alert rules in setRules: and update the cached rules
with the remaining rules.
This commit is contained in:
parent
17e4f1d0bd
commit
f246c07e79
3 changed files with 47 additions and 23 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2019-02-08 Wolfgang Lux <wolfgang.lux@gmail.com>
|
||||||
|
|
||||||
|
* EcAlerter.m: Only ignore invalid rules in setRules: and update
|
||||||
|
the cached rules with the remaining rules.
|
||||||
|
|
||||||
2019-02-08 Richard Frith-Macdonald <rfm@gnu.org>
|
2019-02-08 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* EcCommand.m: Allow the Command server to launch multiple tasks at
|
* EcCommand.m: Allow the Command server to launch multiple tasks at
|
||||||
|
|
|
@ -474,7 +474,7 @@
|
||||||
/** Cache a copy of the Rules with modifications to store information
|
/** Cache a copy of the Rules with modifications to store information
|
||||||
* so we don't need to regenerate it every time we check a message.
|
* so we don't need to regenerate it every time we check a message.
|
||||||
*/
|
*/
|
||||||
- (BOOL) setRules: (NSArray*)ra;
|
- (void) setRules: (NSArray*)ra;
|
||||||
|
|
||||||
/** Called to stop the alerter and shut it down.
|
/** Called to stop the alerter and shut it down.
|
||||||
*/
|
*/
|
||||||
|
|
63
EcAlerter.m
63
EcAlerter.m
|
@ -269,10 +269,11 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
ASSIGNCOPY(eHost, [c objectForKey: @"EmailHost"]);
|
ASSIGNCOPY(eHost, [c objectForKey: @"EmailHost"]);
|
||||||
ASSIGNCOPY(ePort, [c objectForKey: @"EmailPort"]);
|
ASSIGNCOPY(ePort, [c objectForKey: @"EmailPort"]);
|
||||||
[lock unlock];
|
[lock unlock];
|
||||||
return [self setRules: [c objectForKey: @"Rules"]];
|
[self setRules: [c objectForKey: @"Rules"]];
|
||||||
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) setRules: (NSArray*)ra
|
- (void) setRules: (NSArray*)ra
|
||||||
{
|
{
|
||||||
NSMutableArray *r = AUTORELEASE([ra mutableCopy]);
|
NSMutableArray *r = AUTORELEASE([ra mutableCopy]);
|
||||||
NSUInteger i;
|
NSUInteger i;
|
||||||
|
@ -295,7 +296,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
val = [[Regex alloc] initWithString: str];
|
val = [[Regex alloc] initWithString: str];
|
||||||
if (nil == val)
|
if (nil == val)
|
||||||
{
|
{
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
[md setObject: val forKey: @"HostRegex"];
|
[md setObject: val forKey: @"HostRegex"];
|
||||||
[val release];
|
[val release];
|
||||||
|
@ -308,7 +310,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
val = [[Regex alloc] initWithString: str];
|
val = [[Regex alloc] initWithString: str];
|
||||||
if (val == nil)
|
if (val == nil)
|
||||||
{
|
{
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
[md setObject: val forKey: @"PatternRegex"];
|
[md setObject: val forKey: @"PatternRegex"];
|
||||||
RELEASE(val);
|
RELEASE(val);
|
||||||
|
@ -321,7 +324,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
val = [[Regex alloc] initWithString: str];
|
val = [[Regex alloc] initWithString: str];
|
||||||
if (val == nil)
|
if (val == nil)
|
||||||
{
|
{
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
[md setObject: val forKey: @"ServerRegex"];
|
[md setObject: val forKey: @"ServerRegex"];
|
||||||
RELEASE(val);
|
RELEASE(val);
|
||||||
|
@ -334,7 +338,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
val = [[Regex alloc] initWithString: str];
|
val = [[Regex alloc] initWithString: str];
|
||||||
if (val == nil)
|
if (val == nil)
|
||||||
{
|
{
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
[md setObject: val forKey: @"SeverityTextRegex"];
|
[md setObject: val forKey: @"SeverityTextRegex"];
|
||||||
RELEASE(val);
|
RELEASE(val);
|
||||||
|
@ -347,7 +352,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
val = [[Regex alloc] initWithString: str];
|
val = [[Regex alloc] initWithString: str];
|
||||||
if (val == nil)
|
if (val == nil)
|
||||||
{
|
{
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
[md setObject: val forKey: @"Extra1Regex"];
|
[md setObject: val forKey: @"Extra1Regex"];
|
||||||
RELEASE(val);
|
RELEASE(val);
|
||||||
|
@ -360,7 +366,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
val = [[Regex alloc] initWithString: str];
|
val = [[Regex alloc] initWithString: str];
|
||||||
if (val == nil)
|
if (val == nil)
|
||||||
{
|
{
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
[md setObject: val forKey: @"Extra2Regex"];
|
[md setObject: val forKey: @"Extra2Regex"];
|
||||||
RELEASE(val);
|
RELEASE(val);
|
||||||
|
@ -374,7 +381,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
if (nil == d)
|
if (nil == d)
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveFrom='%@' is not a valid date/time", str);
|
NSLog(@"ActiveFrom='%@' is not a valid date/time", str);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -389,7 +397,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
if (nil == d)
|
if (nil == d)
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTo='%@' is not a valid date/time", str);
|
NSLog(@"ActiveTo='%@' is not a valid date/time", str);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -404,7 +413,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
if (nil == d)
|
if (nil == d)
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTimezone='%@' is not a valid time zone", str);
|
NSLog(@"ActiveTimezone='%@' is not a valid time zone", str);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
[md setObject: d forKey: @"ActiveTimeZone"];
|
[md setObject: d forKey: @"ActiveTimeZone"];
|
||||||
}
|
}
|
||||||
|
@ -461,7 +471,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTimes='%@' with bad day of week", obj);
|
NSLog(@"ActiveTimes='%@' with bad day of week", obj);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
a = [[[[t objectForKey: str] componentsSeparatedByString: @","]
|
a = [[[[t objectForKey: str] componentsSeparatedByString: @","]
|
||||||
mutableCopy] autorelease];
|
mutableCopy] autorelease];
|
||||||
|
@ -487,14 +498,16 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTimes='%@' with missing '-' in time range",
|
NSLog(@"ActiveTimes='%@' with missing '-' in time range",
|
||||||
obj);
|
obj);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
str = [r objectAtIndex: 0];
|
str = [r objectAtIndex: 0];
|
||||||
c = sscanf([str UTF8String], "%d:%d", &h, &m);
|
c = sscanf([str UTF8String], "%d:%d", &h, &m);
|
||||||
if (0 == c)
|
if (0 == c)
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTimes='%@' with missing HH:MM", obj);
|
NSLog(@"ActiveTimes='%@' with missing HH:MM", obj);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (1 == c) m = 0;
|
if (1 == c) m = 0;
|
||||||
if (h < 0 || h > 23)
|
if (h < 0 || h > 23)
|
||||||
|
@ -504,7 +517,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
if (m < 0 || m > 59)
|
if (m < 0 || m > 59)
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTimes='%@' with minute out of range", obj);
|
NSLog(@"ActiveTimes='%@' with minute out of range", obj);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
from = (h * 60) + m;
|
from = (h * 60) + m;
|
||||||
|
|
||||||
|
@ -513,7 +527,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
if (0 == c)
|
if (0 == c)
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTimes='%@' with missing HH:MM", obj);
|
NSLog(@"ActiveTimes='%@' with missing HH:MM", obj);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (1 == c) m = 0;
|
if (1 == c) m = 0;
|
||||||
if (h < 0 || h > 24 || (24 == h && 0 != m))
|
if (h < 0 || h > 24 || (24 == h && 0 != m))
|
||||||
|
@ -523,7 +538,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
if (m < 0 || m > 59)
|
if (m < 0 || m > 59)
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTimes='%@' with minute out of range", obj);
|
NSLog(@"ActiveTimes='%@' with minute out of range", obj);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (0 == h && 0 == m)
|
if (0 == h && 0 == m)
|
||||||
{
|
{
|
||||||
|
@ -535,13 +551,15 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTimes='%@' range end earlier than start",
|
NSLog(@"ActiveTimes='%@' range end earlier than start",
|
||||||
obj);
|
obj);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (from < lastMinute)
|
if (from < lastMinute)
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTimes='%@' range start earlier than"
|
NSLog(@"ActiveTimes='%@' range start earlier than"
|
||||||
@" preceding one", obj);
|
@" preceding one", obj);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
lastMinute = to;
|
lastMinute = to;
|
||||||
[r replaceObjectAtIndex: 0
|
[r replaceObjectAtIndex: 0
|
||||||
|
@ -553,7 +571,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
if (0 == [a count])
|
if (0 == [a count])
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTimes='%@' with empty time range", obj);
|
NSLog(@"ActiveTimes='%@' with empty time range", obj);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
[t setObject: a forKey: k];
|
[t setObject: a forKey: k];
|
||||||
}
|
}
|
||||||
|
@ -562,7 +581,8 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
else if (obj != nil)
|
else if (obj != nil)
|
||||||
{
|
{
|
||||||
NSLog(@"ActiveTimes='%@' is not valid", obj);
|
NSLog(@"ActiveTimes='%@' is not valid", obj);
|
||||||
return NO;
|
[r removeObjectAtIndex: i--];
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[lock lock];
|
[lock lock];
|
||||||
|
@ -572,7 +592,6 @@ replaceFields(NSDictionary *fields, NSString *template)
|
||||||
{
|
{
|
||||||
NSLog(@"Installed Rules: %@", r);
|
NSLog(@"Installed Rules: %@", r);
|
||||||
}
|
}
|
||||||
return YES;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
|
|
Loading…
Reference in a new issue