improved notification logic
This commit is contained in:
parent
03b248fef2
commit
9a18b359ab
|
@ -179,10 +179,11 @@ extern os_log_t logHandle;
|
||||||
if(NSControlStateValueOn == self.cameraState)
|
if(NSControlStateValueOn == self.cameraState)
|
||||||
{
|
{
|
||||||
//show notification
|
//show notification
|
||||||
[self generateNotification:event];
|
if(YES == [self generateNotification:event])
|
||||||
|
{
|
||||||
//execute action
|
//execute action
|
||||||
[self executeUserAction:event];
|
[self executeUserAction:event];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//will handle when "on" camera msg is delivered
|
//will handle when "on" camera msg is delivered
|
||||||
|
@ -217,10 +218,11 @@ extern os_log_t logHandle;
|
||||||
event = [[Event alloc] init:client device:Device_Camera state:self.cameraState];
|
event = [[Event alloc] init:client device:Device_Camera state:self.cameraState];
|
||||||
|
|
||||||
//show notification
|
//show notification
|
||||||
[self generateNotification:event];
|
if(YES == [self generateNotification:event])
|
||||||
|
{
|
||||||
//execute action
|
//execute action
|
||||||
[self executeUserAction:event];
|
[self executeUserAction:event];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//dead client
|
//dead client
|
||||||
|
@ -273,20 +275,12 @@ extern os_log_t logHandle;
|
||||||
//init event
|
//init event
|
||||||
event = [[Event alloc] init:nil device:Device_Camera state:self.cameraState];
|
event = [[Event alloc] init:nil device:Device_Camera state:self.cameraState];
|
||||||
|
|
||||||
//show inactive notifcations?
|
//show notification
|
||||||
if(YES != [NSUserDefaults.standardUserDefaults boolForKey:PREF_DISABLE_INACTIVE])
|
if(YES == [self generateNotification:event])
|
||||||
{
|
{
|
||||||
//show notification
|
|
||||||
[self generateNotification:event];
|
|
||||||
|
|
||||||
//execute action
|
//execute action
|
||||||
[self executeUserAction:event];
|
[self executeUserAction:event];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//dbg msg
|
|
||||||
os_log_debug(logHandle, "user has set preference to ingore 'inactive' notifications");
|
|
||||||
}
|
|
||||||
|
|
||||||
//sync
|
//sync
|
||||||
@synchronized (self) {
|
@synchronized (self) {
|
||||||
|
@ -437,10 +431,11 @@ extern os_log_t logHandle;
|
||||||
|
|
||||||
//show notification
|
//show notification
|
||||||
// ok if client is (still) nil...
|
// ok if client is (still) nil...
|
||||||
[self generateNotification:event];
|
if(YES == [self generateNotification:event])
|
||||||
|
{
|
||||||
//execute action
|
//execute action
|
||||||
[self executeUserAction:event];
|
[self executeUserAction:event];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//dead client
|
//dead client
|
||||||
|
@ -510,20 +505,12 @@ extern os_log_t logHandle;
|
||||||
//init event
|
//init event
|
||||||
event = [[Event alloc] init:nil device:Device_Camera state:self.cameraState];
|
event = [[Event alloc] init:nil device:Device_Camera state:self.cameraState];
|
||||||
|
|
||||||
//show inactive notifcations?
|
//show notification
|
||||||
if(YES != [NSUserDefaults.standardUserDefaults boolForKey:PREF_DISABLE_INACTIVE])
|
if(YES == [self generateNotification:event])
|
||||||
{
|
{
|
||||||
//show notification
|
|
||||||
[self generateNotification:event];
|
|
||||||
|
|
||||||
//execute action
|
//execute action
|
||||||
[self executeUserAction:event];
|
[self executeUserAction:event];
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
//dbg msg
|
|
||||||
os_log_debug(logHandle, "user has set preference to ingore 'inactive' notifications");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1024,10 +1011,11 @@ bail:
|
||||||
}//sync
|
}//sync
|
||||||
|
|
||||||
//show notification
|
//show notification
|
||||||
[weakSelf generateNotification:event];
|
if(YES == [weakSelf generateNotification:event])
|
||||||
|
{
|
||||||
//execute action
|
//execute action
|
||||||
[weakSelf executeUserAction:event];
|
[weakSelf executeUserAction:event];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1181,8 +1169,11 @@ bail:
|
||||||
}
|
}
|
||||||
|
|
||||||
//build and display notification
|
//build and display notification
|
||||||
-(void)generateNotification:(Event*)event
|
-(BOOL)generateNotification:(Event*)event
|
||||||
{
|
{
|
||||||
|
//flag
|
||||||
|
BOOL wasDelivered = NO;
|
||||||
|
|
||||||
//notification content
|
//notification content
|
||||||
UNMutableNotificationContent* content = nil;
|
UNMutableNotificationContent* content = nil;
|
||||||
|
|
||||||
|
@ -1195,6 +1186,23 @@ bail:
|
||||||
//title
|
//title
|
||||||
NSMutableString* title = nil;
|
NSMutableString* title = nil;
|
||||||
|
|
||||||
|
//inactive disabled?
|
||||||
|
// ignore if event is an off
|
||||||
|
if(YES == [NSUserDefaults.standardUserDefaults boolForKey:PREF_DISABLE_INACTIVE])
|
||||||
|
{
|
||||||
|
//dbg msg
|
||||||
|
os_log_debug(logHandle, "user has set preference to ingore 'inactive' notifications");
|
||||||
|
|
||||||
|
//off?
|
||||||
|
// ignore...
|
||||||
|
if(NSControlStateValueOff == event.state)
|
||||||
|
{
|
||||||
|
//dbg msg
|
||||||
|
os_log_debug(logHandle, "...so ignoring inactive/off event");
|
||||||
|
goto bail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//(new) mic event?
|
//(new) mic event?
|
||||||
if(Device_Microphone == event.device)
|
if(Device_Microphone == event.device)
|
||||||
{
|
{
|
||||||
|
@ -1206,7 +1214,16 @@ bail:
|
||||||
{
|
{
|
||||||
//dbg msg
|
//dbg msg
|
||||||
os_log_debug(logHandle, "ignoring mic event, as it happened <0.5s ");
|
os_log_debug(logHandle, "ignoring mic event, as it happened <0.5s ");
|
||||||
return;
|
return wasDelivered;
|
||||||
|
}
|
||||||
|
|
||||||
|
//or, was a 2x off?
|
||||||
|
if( (NSControlStateValueOff == event.state) &&
|
||||||
|
(NSControlStateValueOff == self.lastMicEvent.state) )
|
||||||
|
{
|
||||||
|
//dbg msg
|
||||||
|
os_log_debug(logHandle, "ignoring mic event, as it was a 2x off");
|
||||||
|
return wasDelivered;
|
||||||
}
|
}
|
||||||
|
|
||||||
//update
|
//update
|
||||||
|
@ -1272,10 +1289,13 @@ bail:
|
||||||
os_log_error(logHandle, "ERROR failed to deliver notification (error: %@)", error);
|
os_log_error(logHandle, "ERROR failed to deliver notification (error: %@)", error);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
//happy
|
||||||
|
wasDelivered = YES;
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
|
|
||||||
return;
|
return wasDelivered;
|
||||||
}
|
}
|
||||||
|
|
||||||
//execute user action
|
//execute user action
|
||||||
|
|
Loading…
Reference in New Issue