mirror of
https://github.com/gnustep/libs-ec.git
synced 2025-02-15 16:11:01 +00:00
Tidied alarm reminder behavior
This commit is contained in:
parent
dcb5368a23
commit
917e7f8bb5
2 changed files with 28 additions and 33 deletions
|
@ -68,7 +68,7 @@
|
|||
* <desc>The type of message ... <em>Error</em>, <em>Alert</em>,
|
||||
* <em>Alarm</em>, <em>Raise</em> or <em>Clear</em>.<br />
|
||||
* If this is not specified, messages of any type may match.<br />
|
||||
* NB. Alarm reminders have one of three types. The type <em>Raise</em>
|
||||
* NB. Alarm alerts have one of three types. The type <em>Raise</em>
|
||||
* matches only the initial raising of an alarm while <em>Clear</em>
|
||||
* matches only the final clearing of the alarm. The type <em>Alarm</em>
|
||||
* will match raising, clearing, and also (if ReminderInterval is set)
|
||||
|
|
59
EcAlerter.m
59
EcAlerter.m
|
@ -865,6 +865,7 @@ replaceFields(NSDictionary *fields, NSString *template)
|
|||
EcAlertRegex *e;
|
||||
NSString *s;
|
||||
id o;
|
||||
int ri;
|
||||
BOOL isReminder;
|
||||
|
||||
RELEASE(pool);
|
||||
|
@ -963,46 +964,32 @@ replaceFields(NSDictionary *fields, NSString *template)
|
|||
}
|
||||
}
|
||||
|
||||
/* The next set are matches only for alarms.
|
||||
*/
|
||||
|
||||
ri = [[d objectForKey: @"ReminderInterval"] intValue];
|
||||
if (event->isAlarm && event->reminder > 0 && NO == event->isClear)
|
||||
{
|
||||
isReminder = YES;
|
||||
/* This is an alarm reminder (neither the initial alarm
|
||||
* nor the clear), so we check the ReminderInterval.
|
||||
* In order for a match to occur, the ReminderInterval
|
||||
* must be set and must match the number of the reminder
|
||||
* using division modulo the reminder interval value.
|
||||
* NB, unlike other patterns, the absence of this one
|
||||
* implies a match failure!
|
||||
*/
|
||||
if (ri < 1 || (event->reminder % ri) != 0)
|
||||
{
|
||||
continue; // Not a match.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
isReminder = NO;
|
||||
}
|
||||
|
||||
/* The next set are matches only for alarms.
|
||||
*/
|
||||
if (nil != (s = [d objectForKey: @"Component"]))
|
||||
{
|
||||
if (NO == [s isEqual: event->component])
|
||||
if (ri > 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (nil != (s = [d objectForKey: @"ReminderInterval"]))
|
||||
{
|
||||
if (isReminder)
|
||||
{
|
||||
int v = [s intValue];
|
||||
|
||||
/* This is an alarm reminder (neither the initial alarm
|
||||
* nor the clear), so we check the ReminderInterval.
|
||||
* In order for a match to occur, the ReminderInterval
|
||||
* must be set and must match the number of the reminder
|
||||
* using division modulo the reminder interval value.
|
||||
* NB, unlike other patterns, the absence of this one
|
||||
* implies a match failure!
|
||||
*/
|
||||
if (v < 1 || (event->reminder % v) != 0)
|
||||
{
|
||||
continue; // Not a match.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
continue; // Not a reminder
|
||||
continue; // Rule matches only reminders
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1030,6 +1017,14 @@ replaceFields(NSDictionary *fields, NSString *template)
|
|||
continue; // Not a match.
|
||||
}
|
||||
|
||||
if (nil != (s = [d objectForKey: @"Component"]))
|
||||
{
|
||||
if (NO == [s isEqual: event->component])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (nil != (e = [d objectForKey: @"SeverityTextRegex"])
|
||||
&& (NO == event->isAlarm || [e match: event->severityText] == nil))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue