working on code for new preferences/features
-headless mode -managing rules -switched to manually managing only starting login item when needed
This commit is contained in:
parent
65dbbf9a9a
commit
033fae2879
|
@ -134,5 +134,4 @@ bail:
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
// ->load status bar and kick off monitor
|
||||
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
//default
|
||||
//preferences
|
||||
NSDictionary* preferences = nil;
|
||||
|
||||
//dbg msg
|
||||
|
@ -38,14 +38,8 @@
|
|||
|
||||
//drop user privs
|
||||
setuid(getuid());
|
||||
|
||||
//init/load status bar
|
||||
[self loadStatusBar];
|
||||
|
||||
//dbg msg
|
||||
logMsg(LOG_DEBUG, @"initialized/loaded status bar (icon/menu)");
|
||||
|
||||
//first time, register defaults (manually cuz NSUserDefaults wasn't working - wtf)
|
||||
//first time, register defaults
|
||||
// ->note: do this in here, since main app (with prefs) isn't run until user manually launches it
|
||||
if(YES != [[NSFileManager defaultManager] fileExistsAtPath:[APP_PREFERENCES stringByExpandingTildeInPath]])
|
||||
{
|
||||
|
@ -53,12 +47,29 @@
|
|||
logMsg(LOG_DEBUG, @"preference file not found; manually creating");
|
||||
|
||||
//write em out
|
||||
[@{PREF_LOG_ACTIVITY:@YES, PREF_CHECK_4_UPDATES:@YES} writeToFile:[APP_PREFERENCES stringByExpandingTildeInPath] atomically:NO];
|
||||
[@{PREF_LOG_ACTIVITY:@YES, PREF_START_AT_LOGIN:@YES, PREF_RUN_HEADLESS:@NO, PREF_CHECK_4_UPDATES:@YES} writeToFile:[APP_PREFERENCES stringByExpandingTildeInPath] atomically:NO];
|
||||
}
|
||||
|
||||
//always (manually) load preferences
|
||||
//load preferences
|
||||
preferences = [NSDictionary dictionaryWithContentsOfFile:[APP_PREFERENCES stringByExpandingTildeInPath]];
|
||||
|
||||
//init/load status bar
|
||||
// ->but only if user didn't say: 'run in headless mode'
|
||||
if(YES != [preferences[PREF_RUN_HEADLESS] boolValue])
|
||||
{
|
||||
//load
|
||||
[self loadStatusBar];
|
||||
|
||||
//dbg msg
|
||||
logMsg(LOG_DEBUG, @"initialized/loaded status bar (icon/menu)");
|
||||
}
|
||||
//dbg msg
|
||||
else
|
||||
{
|
||||
//dbg msg
|
||||
logMsg(LOG_DEBUG, @"running in headless mode");
|
||||
}
|
||||
|
||||
//check for updates
|
||||
// ->but only when user has not disabled that feature
|
||||
if(YES == [preferences[PREF_CHECK_4_UPDATES] boolValue])
|
||||
|
|
|
@ -23,6 +23,12 @@
|
|||
//check for updates automatically button
|
||||
@property (weak) IBOutlet NSButton *check4Updates;
|
||||
|
||||
//start at login button
|
||||
@property (weak) IBOutlet NSButton *startAtLogin;
|
||||
|
||||
//run in headless mode button
|
||||
@property (weak) IBOutlet NSButton *runHeadless;
|
||||
|
||||
//check for updates now button
|
||||
@property (weak) IBOutlet NSButton *check4UpdatesNow;
|
||||
|
||||
|
@ -38,6 +44,14 @@
|
|||
//about window controller
|
||||
@property(nonatomic, retain)AboutWindowController* aboutWindowController;
|
||||
|
||||
//overlay view
|
||||
@property (weak) IBOutlet NSView *overlay;
|
||||
|
||||
//status message
|
||||
@property (weak) IBOutlet NSTextField *statusMessage;
|
||||
|
||||
//progress indicator
|
||||
@property (weak) IBOutlet NSProgressIndicator *progressIndicator;
|
||||
|
||||
/* METHODS */
|
||||
|
||||
|
@ -60,9 +74,11 @@
|
|||
//check for an update
|
||||
-(void)isThereAnUpdate;
|
||||
|
||||
//start the login item
|
||||
-(IBAction)startLoginItem:(id)sender;
|
||||
//'manage rules' button handler
|
||||
-(IBAction)manageRules:(id)sender;
|
||||
|
||||
//start the login item
|
||||
-(void)startLoginItem:(BOOL)shouldRestart;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
@ -45,16 +45,23 @@
|
|||
// ->init user interface
|
||||
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
//set 'log activity' button state
|
||||
self.logActivity.state = [[NSUserDefaults standardUserDefaults] boolForKey:PREF_LOG_ACTIVITY];
|
||||
|
||||
//set 'automatically check for updates' button state
|
||||
self.check4Updates.state = [[NSUserDefaults standardUserDefaults] boolForKey:PREF_CHECK_4_UPDATES];
|
||||
//set button states
|
||||
[self setButtonStates];
|
||||
|
||||
//register for hotkey presses
|
||||
// ->for now, just cmd+q to quit app
|
||||
[self registerKeypressHandler];
|
||||
|
||||
//start login item in background
|
||||
// ->checks if already running though
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
|
||||
^{
|
||||
//start
|
||||
[self startLoginItem:NO];
|
||||
});
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -64,6 +71,30 @@
|
|||
return YES;
|
||||
}
|
||||
|
||||
//set button states from preferences
|
||||
-(void)setButtonStates
|
||||
{
|
||||
//preferences
|
||||
NSDictionary* preferences = nil;
|
||||
|
||||
//load preferences
|
||||
preferences = [NSDictionary dictionaryWithContentsOfFile:[APP_PREFERENCES stringByExpandingTildeInPath]];
|
||||
|
||||
//set 'log activity' button state
|
||||
self.logActivity.state = [preferences[PREF_LOG_ACTIVITY] boolValue];
|
||||
|
||||
//set 'start at login' button state
|
||||
self.startAtLogin.state = [preferences[PREF_START_AT_LOGIN] boolValue];
|
||||
|
||||
//set 'run headless' button state
|
||||
self.runHeadless.state = [preferences[PREF_RUN_HEADLESS] boolValue];
|
||||
|
||||
//set 'automatically check for updates' button state
|
||||
self.check4Updates.state = [preferences[PREF_CHECK_4_UPDATES] boolValue];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//register handler for hot keys
|
||||
-(void)registerKeypressHandler
|
||||
{
|
||||
|
@ -138,27 +169,61 @@ bail:
|
|||
//toggle/set preferences
|
||||
-(IBAction)togglePreference:(NSButton *)sender
|
||||
{
|
||||
//preferences
|
||||
NSMutableDictionary* preferences = nil;
|
||||
|
||||
//load preferences
|
||||
preferences = [NSMutableDictionary dictionaryWithContentsOfFile:[APP_PREFERENCES stringByExpandingTildeInPath]];
|
||||
|
||||
//set 'log activity' button
|
||||
if(sender == self.logActivity)
|
||||
{
|
||||
//set
|
||||
[[NSUserDefaults standardUserDefaults] setBool:[sender state] forKey:PREF_LOG_ACTIVITY];
|
||||
preferences[PREF_LOG_ACTIVITY] = [NSNumber numberWithBool:[sender state]];
|
||||
}
|
||||
|
||||
//set 'automatically check for updates'
|
||||
else if (sender == self.check4Updates)
|
||||
else if(sender == self.check4Updates)
|
||||
{
|
||||
//set
|
||||
[[NSUserDefaults standardUserDefaults] setBool:[sender state] forKey:PREF_CHECK_4_UPDATES];
|
||||
preferences[PREF_CHECK_4_UPDATES] = [NSNumber numberWithBool:[sender state]];
|
||||
|
||||
}
|
||||
|
||||
//set 'start at login'
|
||||
// ->then also toggle for current user
|
||||
else if(sender == self.startAtLogin)
|
||||
{
|
||||
//set
|
||||
preferences[PREF_START_AT_LOGIN] = [NSNumber numberWithBool:[sender state]];
|
||||
|
||||
//toggle
|
||||
|
||||
}
|
||||
|
||||
//set 'run in headless mode'
|
||||
// ->then restart login item to realize this
|
||||
else if(sender == self.runHeadless)
|
||||
{
|
||||
//set
|
||||
preferences[PREF_RUN_HEADLESS] = [NSNumber numberWithBool:[sender state]];
|
||||
|
||||
//restart login item in background
|
||||
// ->will read prefs, and run in headless mode
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0),
|
||||
^{
|
||||
//start
|
||||
[self startLoginItem:YES];
|
||||
});
|
||||
}
|
||||
|
||||
//save em
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
[preferences writeToFile:[APP_PREFERENCES stringByExpandingTildeInPath] atomically:YES];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//'about' button handler
|
||||
//'about' button/menu handler
|
||||
-(IBAction)about:(id)sender
|
||||
{
|
||||
//alloc/init settings window
|
||||
|
@ -183,7 +248,6 @@ bail:
|
|||
});
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//'check for update' (now) button handler
|
||||
|
@ -268,35 +332,73 @@ bail:
|
|||
}
|
||||
|
||||
//start the login item
|
||||
-(IBAction)startLoginItem:(id)sender
|
||||
-(void)startLoginItem:(BOOL)shouldRestart
|
||||
{
|
||||
//path to login item
|
||||
NSString* loginItem = nil;
|
||||
|
||||
//alert
|
||||
NSAlert* alert = nil;
|
||||
//login item's pid
|
||||
pid_t loginItemPID = -1;
|
||||
|
||||
//check if already running
|
||||
// ->show alert and then bail
|
||||
if(-1 != getProcessID(@"OverSight Helper"))
|
||||
//get pid of login item
|
||||
loginItemPID = getProcessID(@"OverSight Helper", getuid());
|
||||
|
||||
//already running?
|
||||
// ->kill the login item
|
||||
if( (YES == shouldRestart) &&
|
||||
(-1 != loginItemPID) )
|
||||
{
|
||||
//init alert
|
||||
alert = [NSAlert alertWithMessageText: @"Oversight is already running!" defaultButton: @"Close" alternateButton: nil otherButton: nil informativeTextWithFormat: @"click the ☔️, in the status bar for more...."];
|
||||
//kill
|
||||
kill(loginItemPID, SIGTERM);
|
||||
|
||||
//make app front
|
||||
[[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps];
|
||||
//sleep
|
||||
sleep(2);
|
||||
|
||||
//make modal
|
||||
[alert runModal];
|
||||
//really kill
|
||||
kill(loginItemPID, SIGKILL);
|
||||
|
||||
//bail
|
||||
goto bail;
|
||||
//reset pid
|
||||
loginItemPID = -1;
|
||||
}
|
||||
|
||||
//start not already running
|
||||
if(-1 == loginItemPID)
|
||||
{
|
||||
//dbg msg
|
||||
logMsg(LOG_DEBUG, @"starting login item");
|
||||
|
||||
//show overlay view on main thread
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
|
||||
//pre-req
|
||||
[self.overlay setWantsLayer:YES];
|
||||
|
||||
//set overlay's view color to black
|
||||
self.overlay.layer.backgroundColor = [NSColor whiteColor].CGColor;
|
||||
|
||||
//make it semi-transparent
|
||||
self.overlay.alphaValue = 0.85;
|
||||
|
||||
//show it
|
||||
self.overlay.hidden = NO;
|
||||
|
||||
//TODO:
|
||||
//set message
|
||||
|
||||
//show spinner
|
||||
self.progressIndicator.hidden = NO;
|
||||
|
||||
//animate it
|
||||
[self.progressIndicator startAnimation:nil];
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
//init path
|
||||
loginItem = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"/Contents/Library/LoginItems/OverSight Helper.app"];
|
||||
|
||||
//launch it!
|
||||
//launch it
|
||||
if(YES != [[NSWorkspace sharedWorkspace] launchApplication:loginItem])
|
||||
{
|
||||
//err msg
|
||||
|
@ -305,7 +407,13 @@ bail:
|
|||
//bail
|
||||
goto bail;
|
||||
}
|
||||
|
||||
|
||||
//(re)obtain focus for app
|
||||
[[NSRunningApplication currentApplication] activateWithOptions:NSApplicationActivateIgnoringOtherApps];
|
||||
|
||||
//TODO:
|
||||
//hide overlay
|
||||
|
||||
//bail
|
||||
bail:
|
||||
|
||||
|
@ -313,4 +421,11 @@ bail:
|
|||
}
|
||||
|
||||
|
||||
//manage rules
|
||||
-(IBAction)manageRules:(id)sender
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="10117" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
|
@ -18,7 +17,12 @@
|
|||
<outlet property="check4Updates" destination="Twr-YX-0dG" id="PsA-vI-UHz"/>
|
||||
<outlet property="check4UpdatesNow" destination="M9W-tZ-0Z8" id="PKA-ah-dde"/>
|
||||
<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"/>
|
||||
<outlet property="runHeadless" destination="7bS-hN-Wc7" id="dbA-Sv-fUR"/>
|
||||
<outlet property="spinner" destination="sph-QU-dL4" id="uwr-2X-sg8"/>
|
||||
<outlet property="startAtLogin" destination="Ref-d8-8ir" id="0pj-Va-6Jf"/>
|
||||
<outlet property="statusMessage" destination="u4r-or-Aue" id="CvO-Ub-13a"/>
|
||||
<outlet property="versionLabel" destination="pGb-eI-7vA" id="asA-QR-qQV"/>
|
||||
<outlet property="window" destination="QvC-M9-y7g" id="gIp-Ho-8D9"/>
|
||||
</connections>
|
||||
|
@ -28,13 +32,14 @@
|
|||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1058"/>
|
||||
<view key="contentView" id="EiT-Mj-1SZ">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="rVS-uv-DNf">
|
||||
<rect key="frame" x="175" y="318" width="136" height="18"/>
|
||||
<rect key="frame" x="175" y="324" 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"/>
|
||||
<font key="font" size="13" name="Menlo-Regular"/>
|
||||
|
@ -43,18 +48,31 @@
|
|||
<action selector="togglePreference:" target="Voe-Tx-rLC" id="mmD-hC-ydp"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Twr-YX-0dG">
|
||||
<rect key="frame" x="175" y="260" width="280" height="19"/>
|
||||
<buttonCell key="cell" type="check" title="Automatically check for updates" bezelStyle="regularSquare" imagePosition="left" inset="2" id="rbp-Uw-Gy1">
|
||||
<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="77r-mm-9ek"/>
|
||||
<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"/>
|
||||
<buttonCell key="cell" type="check" title="Start at Login" bezelStyle="regularSquare" imagePosition="left" inset="2" id="A3b-ll-Dt1">
|
||||
<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="k44-Fx-sN6"/>
|
||||
</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"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" drawsBackground="YES" id="zOz-NV-pht">
|
||||
<font key="font" metaFont="system"/>
|
||||
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
|
||||
|
@ -63,14 +81,17 @@
|
|||
</textField>
|
||||
<imageView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="kVc-EA-5LL">
|
||||
<rect key="frame" x="1" y="0.0" width="325" height="65"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" animates="YES" imageScaling="proportionallyDown" image="overSight" id="WbC-HV-n62"/>
|
||||
</imageView>
|
||||
<imageView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ks1-o6-l6E">
|
||||
<rect key="frame" x="-14" y="167" width="183" height="183"/>
|
||||
<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 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"/>
|
||||
<buttonCell key="cell" type="push" title="About" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Jm9-ma-n5o">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" size="13" name="Menlo-Regular"/>
|
||||
|
@ -79,8 +100,31 @@
|
|||
<action selector="about:" target="Voe-Tx-rLC" id="Bf6-4p-Q3A"/>
|
||||
</connections>
|
||||
</button>
|
||||
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3Z7-Cx-v5H">
|
||||
<rect key="frame" x="170" y="117" width="134" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<buttonCell key="cell" type="push" title="Manage Rules" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="js5-fO-HHA">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" size="13" name="Menlo-Regular"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<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="214" width="109" height="32"/>
|
||||
<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"/>
|
||||
|
@ -90,29 +134,64 @@
|
|||
</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="282" y="223" width="16" height="16"/>
|
||||
<rect key="frame" x="282" y="209" 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="280" y="225" width="150" height="17"/>
|
||||
<rect key="frame" x="280" y="211" width="175" height="17"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" 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="Mzd-co-fJo">
|
||||
<rect key="frame" x="389" y="13" width="77" height="32"/>
|
||||
<buttonCell key="cell" type="push" title="Start!" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="zde-cc-enh">
|
||||
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
|
||||
<font key="font" size="13" name="Menlo-Regular"/>
|
||||
</buttonCell>
|
||||
<connections>
|
||||
<action selector="startLoginItem:" target="Voe-Tx-rLC" id="8MX-Nf-yMA"/>
|
||||
</connections>
|
||||
</button>
|
||||
<customView hidden="YES" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bHg-M3-YdC">
|
||||
<rect key="frame" x="0.0" y="102" width="480" height="156"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<subviews>
|
||||
<progressIndicator hidden="YES" wantsLayer="YES" horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" maxValue="100" bezeled="NO" indeterminate="YES" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="K08-2Z-AIq">
|
||||
<rect key="frame" x="251" y="74" width="32" height="32"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
</progressIndicator>
|
||||
<textField hidden="YES" horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="u4r-or-Aue">
|
||||
<rect key="frame" x="-2" y="59" width="484" height="20"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="center" title="status msg" id="vap-C0-2c8">
|
||||
<font key="font" size="13" name="Menlo-Regular"/>
|
||||
<color key="textColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
|
||||
</textFieldCell>
|
||||
</textField>
|
||||
</subviews>
|
||||
</customView>
|
||||
</subviews>
|
||||
</view>
|
||||
</window>
|
||||
<menu title="Main Menu" systemMenu="main" id="vG3-92-ajA">
|
||||
<items>
|
||||
<menuItem title="OverSight" id="R8B-Wd-oK9" userLabel="OverSight">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="OverSight" systemMenu="apple" id="l2x-Sw-2Zo">
|
||||
<items>
|
||||
<menuItem title="About" id="8uW-fm-EDz">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="about:" target="Voe-Tx-rLC" id="4p0-Ra-Mt2"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="doQ-u9-gKW"/>
|
||||
<menuItem title="Quit" keyEquivalent="q" id="2qu-7X-aOy">
|
||||
<connections>
|
||||
<action selector="terminate:" target="-1" id="cAK-3r-Wqe"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
<point key="canvasLocation" x="-49" y="-382"/>
|
||||
</menu>
|
||||
</objects>
|
||||
<resources>
|
||||
<image name="icon" width="512" height="512"/>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<key>LSMinimumSystemVersion</key>
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>LSUIElement</key>
|
||||
<true/>
|
||||
<false/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright (c) 2016 Objective-See. All rights reserved.</string>
|
||||
<key>NSMainNibFile</key>
|
||||
|
|
|
@ -493,7 +493,7 @@ bail:
|
|||
//update iVar
|
||||
self.userClients = currentUserClients;
|
||||
|
||||
AudioUnitRender
|
||||
|
||||
|
||||
/*
|
||||
//parse/check
|
||||
|
|
|
@ -39,11 +39,6 @@ pid_t clientPID = 0;
|
|||
//signing req string
|
||||
NSString *requirementString = nil;
|
||||
|
||||
//TODO: re-enable
|
||||
|
||||
/*
|
||||
|
||||
|
||||
//init signing req string
|
||||
requirementString = [NSString stringWithFormat:@"anchor trusted and certificate leaf [subject.CN] = \"%@\"", SIGNING_AUTH];
|
||||
|
||||
|
@ -63,8 +58,6 @@ pid_t clientPID = 0;
|
|||
//bail
|
||||
goto bail;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
//set the interface that the exported object implements
|
||||
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(XPCProtocol)];
|
||||
|
|
|
@ -77,6 +77,12 @@
|
|||
//automatically check for updates button
|
||||
#define PREF_CHECK_4_UPDATES @"check4Updates"
|
||||
|
||||
//run in headless mode
|
||||
#define PREF_RUN_HEADLESS @"runHeadless"
|
||||
|
||||
//start at login
|
||||
#define PREF_START_AT_LOGIN @"startAtLogin"
|
||||
|
||||
//keycode for 'q'
|
||||
#define KEYCODE_Q 0x0C
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ NSString* getProcessName(pid_t pid);
|
|||
|
||||
//given a process name
|
||||
// ->get the (first) instance of that process
|
||||
pid_t getProcessID(NSString* processName);
|
||||
pid_t getProcessID(NSString* processName, uid_t userID);
|
||||
|
||||
//wait until a window is non nil
|
||||
// ->then make it modal
|
||||
|
|
|
@ -508,7 +508,7 @@ bail:
|
|||
|
||||
//given a process name
|
||||
// ->get the (first) instance of that process
|
||||
pid_t getProcessID(NSString* processName)
|
||||
pid_t getProcessID(NSString* processName, uid_t userID)
|
||||
{
|
||||
//status
|
||||
int status = -1;
|
||||
|
@ -521,7 +521,16 @@ pid_t getProcessID(NSString* processName)
|
|||
|
||||
//array of pids
|
||||
pid_t* pids = NULL;
|
||||
|
||||
|
||||
//process info struct
|
||||
struct kinfo_proc procInfo = {0};
|
||||
|
||||
//size of struct
|
||||
size_t procInfoSize = sizeof(procInfo);
|
||||
|
||||
//mib
|
||||
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, -1};
|
||||
|
||||
//get # of procs
|
||||
numberOfProcesses = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0);
|
||||
|
||||
|
@ -557,12 +566,29 @@ pid_t getProcessID(NSString* processName)
|
|||
continue;
|
||||
}
|
||||
|
||||
//init mib
|
||||
mib[0x3] = pids[i];
|
||||
|
||||
//make syscall to get proc info
|
||||
if( (0 != sysctl(mib, 0x4, &procInfo, &procInfoSize, NULL, 0)) ||
|
||||
(0 == procInfoSize) )
|
||||
{
|
||||
//skip
|
||||
continue;
|
||||
}
|
||||
|
||||
//skip if user id doesn't match
|
||||
if(userID != procInfo.kp_eproc.e_ucred.cr_uid)
|
||||
{
|
||||
//skip
|
||||
continue;
|
||||
}
|
||||
|
||||
//got match
|
||||
processID = pids[i];
|
||||
|
||||
//exit loop
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
//bail
|
||||
|
|
Loading…
Reference in New Issue