added 'disable inactive alerts' preference/setting

This commit is contained in:
Patrick Wardle 2016-12-18 16:38:47 -10:00
parent 579edd3435
commit 2c1fcc4a72
7 changed files with 96 additions and 54 deletions

View File

@ -888,6 +888,17 @@ bail:
//always (manually) load preferences
preferences = [NSDictionary dictionaryWithContentsOfFile:[APP_PREFERENCES stringByExpandingTildeInPath]];
//check if user wants to ingnore inactive alerts
if( (YES == [preferences[PREF_DISABLE_INACTIVE] boolValue]) &&
(YES == [DEVICE_INACTIVE isEqual:event[EVENT_DEVICE_STATUS]]) )
{
//dbg msg
logMsg(LOG_DEBUG, @"user has decided to ingore 'inactive' events, so bailing");
//bail
goto bail;
}
//set title
// ->audio device
if(YES == [event[EVENT_DEVICE] isKindOfClass:NSClassFromString(@"AVCaptureHALDevice")])

View File

@ -11,6 +11,8 @@
#import "Utilities.h"
#import "AppDelegate.h"
//TODO: "I have a dual monitor setup and just noticed that the alert came up on the other monitor, not the one that Skype was launched on."
@interface AppDelegate ()

View File

@ -29,6 +29,9 @@
//run in headless mode button
@property (weak) IBOutlet NSButton *runHeadless;
//disable 'inactive' alerts
@property (weak) IBOutlet NSButton *disableInactive;
//check for updates now button
@property (weak) IBOutlet NSButton *check4UpdatesNow;

View File

@ -61,7 +61,7 @@
//write em out
// ->note; set 'start at login' to false, since no prefs here, mean installer wasn't run (user can later toggle)
[@{PREF_LOG_ACTIVITY:@YES, PREF_START_AT_LOGIN:@NO, PREF_RUN_HEADLESS:@NO, PREF_CHECK_4_UPDATES:@YES} writeToFile:[APP_PREFERENCES stringByExpandingTildeInPath] atomically:NO];
[@{PREF_LOG_ACTIVITY:@YES, PREF_START_AT_LOGIN:@NO, PREF_RUN_HEADLESS:@NO, PREF_DISABLE_INACTIVE:@NO, PREF_CHECK_4_UPDATES:@YES} writeToFile:[APP_PREFERENCES stringByExpandingTildeInPath] atomically:NO];
}
//start login item in background
@ -99,6 +99,9 @@
//set 'run headless' button state
self.runHeadless.state = [preferences[PREF_RUN_HEADLESS] boolValue];
//set 'disable inactive' button state
self.disableInactive.state = [preferences[PREF_DISABLE_INACTIVE] boolValue];
//set 'automatically check for updates' button state
self.check4Updates.state = [preferences[PREF_CHECK_4_UPDATES] boolValue];
@ -200,7 +203,6 @@ bail:
{
//set
preferences[PREF_CHECK_4_UPDATES] = [NSNumber numberWithBool:[sender state]];
}
//set 'start at login'
@ -233,6 +235,13 @@ bail:
});
}
//set 'disable inactive alerts'
else if(sender == self.disableInactive)
{
//set
preferences[PREF_DISABLE_INACTIVE] = [NSNumber numberWithBool:[sender state]];
}
//save em
[preferences writeToFile:[APP_PREFERENCES stringByExpandingTildeInPath] atomically:YES];
@ -425,8 +434,7 @@ bail:
});
}
//init path
loginItem = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"/Contents/Library/LoginItems/OverSight Helper.app"];

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2555" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11542"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
@ -16,6 +17,7 @@
<outlet property="about" destination="D1u-ER-JrL" id="GCg-51-bW7"/>
<outlet property="check4Updates" destination="Twr-YX-0dG" id="PsA-vI-UHz"/>
<outlet property="check4UpdatesNow" destination="M9W-tZ-0Z8" id="PKA-ah-dde"/>
<outlet property="disableInactive" destination="Nf6-uL-uwr" id="7js-Vr-2nI"/>
<outlet property="logActivity" destination="rVS-uv-DNf" id="5XJ-Ec-mNt"/>
<outlet property="overlay" destination="bHg-M3-YdC" id="dTJ-FV-0Bt"/>
<outlet property="progressIndicator" destination="K08-2Z-AIq" id="0K0-Ao-9Ad"/>
@ -38,7 +40,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rVS-uv-DNf">
<rect key="frame" x="175" y="324" width="136" height="18"/>
<rect key="frame" x="175" y="325" width="136" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Log activity" bezelStyle="regularSquare" imagePosition="left" inset="2" id="3gA-J8-849">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@ -48,17 +50,6 @@
<action selector="togglePreference:" target="Voe-Tx-rLC" id="mmD-hC-ydp"/>
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7bS-hN-Wc7">
<rect key="frame" x="175" y="267" width="179" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Run in Headless Mode" bezelStyle="regularSquare" imagePosition="left" inset="2" id="qXu-as-3Ji">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" size="13" name="Menlo-Regular"/>
</buttonCell>
<connections>
<action selector="togglePreference:" target="Voe-Tx-rLC" id="Bhm-nM-dp6"/>
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ref-d8-8ir">
<rect key="frame" x="175" y="295" width="132" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
@ -70,6 +61,28 @@
<action selector="togglePreference:" target="Voe-Tx-rLC" id="k44-Fx-sN6"/>
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7bS-hN-Wc7">
<rect key="frame" x="175" y="265" width="179" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Run in Headless Mode" bezelStyle="regularSquare" imagePosition="left" inset="2" id="qXu-as-3Ji">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" size="13" name="Menlo-Regular"/>
</buttonCell>
<connections>
<action selector="togglePreference:" target="Voe-Tx-rLC" id="Bhm-nM-dp6"/>
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Nf6-uL-uwr">
<rect key="frame" x="175" y="235" width="218" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Disable 'inactive' alerts" bezelStyle="regularSquare" imagePosition="left" inset="2" id="eWy-FD-wFO">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" size="13" name="Menlo-Regular"/>
</buttonCell>
<connections>
<action selector="togglePreference:" target="Voe-Tx-rLC" id="DyE-Ud-thf"/>
</connections>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="nf3-YB-f25">
<rect key="frame" x="0.0" y="0.0" width="155" height="360"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
@ -89,6 +102,41 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" animates="YES" imageScaling="proportionallyDown" image="icon" id="Cv4-hx-zrt"/>
</imageView>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Twr-YX-0dG">
<rect key="frame" x="175" y="206" width="280" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Automatically check for updates" bezelStyle="regularSquare" imagePosition="left" inset="2" id="rbp-Uw-Gy1">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" size="13" name="Menlo-Regular"/>
</buttonCell>
<connections>
<action selector="togglePreference:" target="Voe-Tx-rLC" id="77r-mm-9ek"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="M9W-tZ-0Z8">
<rect key="frame" x="171" y="177" width="109" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Check Now" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Jld-yC-ZCR">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" size="13" name="Menlo-Regular"/>
</buttonCell>
<connections>
<action selector="check4Update:" target="Voe-Tx-rLC" id="pFd-Ah-19f"/>
</connections>
</button>
<progressIndicator wantsLayer="YES" fixedFrame="YES" maxValue="100" displayedWhenStopped="NO" indeterminate="YES" controlSize="small" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="sph-QU-dL4">
<rect key="frame" x="283" y="186" width="16" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</progressIndicator>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pGb-eI-7vA">
<rect key="frame" x="303" y="184" width="159" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" sendsActionOnEndEditing="YES" title="No new versions" id="S6D-6d-JiZ">
<font key="font" size="13" name="Menlo-Bold"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="D1u-ER-JrL">
<rect key="frame" x="39" y="117" width="77" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
@ -111,34 +159,8 @@
<action selector="manageRules:" target="Voe-Tx-rLC" id="UuK-ti-hYN"/>
</connections>
</button>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Twr-YX-0dG">
<rect key="frame" x="175" y="236" width="280" height="19"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Automatically check for updates" bezelStyle="regularSquare" imagePosition="left" inset="2" id="rbp-Uw-Gy1">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" size="13" name="Menlo-Regular"/>
</buttonCell>
<connections>
<action selector="togglePreference:" target="Voe-Tx-rLC" id="77r-mm-9ek"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="M9W-tZ-0Z8">
<rect key="frame" x="171" y="202" width="109" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Check Now" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Jld-yC-ZCR">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" size="13" name="Menlo-Regular"/>
</buttonCell>
<connections>
<action selector="check4Update:" target="Voe-Tx-rLC" id="pFd-Ah-19f"/>
</connections>
</button>
<progressIndicator wantsLayer="YES" fixedFrame="YES" maxValue="100" displayedWhenStopped="NO" indeterminate="YES" controlSize="small" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="sph-QU-dL4">
<rect key="frame" x="283" y="211" width="16" height="16"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</progressIndicator>
<customView hidden="YES" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bHg-M3-YdC">
<rect key="frame" x="27" y="102" width="426" height="155"/>
<rect key="frame" x="27" y="116" width="426" height="155"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="u4r-or-Aue">
@ -156,15 +178,6 @@
</progressIndicator>
</subviews>
</customView>
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pGb-eI-7vA">
<rect key="frame" x="303" y="209" width="159" height="21"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" sendsActionOnEndEditing="YES" title="No new versions" id="S6D-6d-JiZ">
<font key="font" size="13" name="Menlo-Bold"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
</view>
</window>

View File

@ -89,6 +89,9 @@
//start at login
#define PREF_START_AT_LOGIN @"startAtLogin"
//disable 'inactive' alerts
#define PREF_DISABLE_INACTIVE @"disableInactive"
//keycode for 'q'
#define KEYCODE_Q 0x0C

View File

@ -6,6 +6,8 @@
// Copyright (c) 2016 Objective-See. All rights reserved.
//
//TODO: add os_log_with_type for 10.12+
#import "Consts.h"
#import "Logging.h"
#import "Utilities.h"