Improved support for notifications

"Only the in-built macOS apps can send alerts by default"  😭
...so we have have to ask (beg) the user to enable alerts via the Notification pane in System Preferences
This commit is contained in:
Patrick Wardle 2022-11-23 14:59:51 -10:00
parent 34fa18d522
commit 9f00793fa3
17 changed files with 224 additions and 121 deletions

View File

@ -469,7 +469,7 @@
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO;
CODE_SIGN_IDENTITY = "Developer ID Application";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.1.1;
CURRENT_PROJECT_VERSION = 2.1.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
@ -480,7 +480,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(LD_RUNPATH_SEARCH_PATHS_$(IS_MACCATALYST)) @executable_path/../Frameworks";
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.1.1;
MARKETING_VERSION = 2.1.2;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.objective-see.oversight";
PRODUCT_NAME = OverSight;
@ -495,7 +495,7 @@
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO;
CODE_SIGN_IDENTITY = "Developer ID Application";
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.1.1;
CURRENT_PROJECT_VERSION = 2.1.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
@ -506,7 +506,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(LD_RUNPATH_SEARCH_PATHS_$(IS_MACCATALYST)) @executable_path/../Frameworks";
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.1.1;
MARKETING_VERSION = 2.1.2;
ONLY_ACTIVE_ARCH = NO;
PRODUCT_BUNDLE_IDENTIFIER = "com.objective-see.oversight";
PRODUCT_NAME = OverSight;

View File

@ -65,43 +65,6 @@ extern os_log_t logHandle;
//set up delegate
UNUserNotificationCenter.currentNotificationCenter.delegate = self;
//ask for notificaitons
[UNUserNotificationCenter.currentNotificationCenter requestAuthorizationWithOptions:(UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error)
{
//dbg msg
os_log_debug(logHandle, "permission to display notifications granted? %d (error: %@)", granted, error);
//not granted/error
if( (nil != error) ||
(YES != granted) )
{
//main thread?
if(YES == NSThread.isMainThread)
{
//show alert
showAlert(@"ERROR: OverSight not authorized to display notifications!", @"Please authorize via the \"Notifications\" pane (in System Preferences).");
//open `System Preferences` notifications pane
[NSWorkspace.sharedWorkspace openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.notifications"]];
}
//bg thread
// show alert on main thread
else
{
//on main thread
dispatch_async(dispatch_get_main_queue(),
^{
//show alert
showAlert(@"ERROR: OverSight not authorized to display notifications!", @"Please authorize via the \"Notifications\" pane (in System Preferences).");
//open `System Preferences` notifications pane
[NSWorkspace.sharedWorkspace openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.notifications"]];
});
}
}
}];
//init ok action
ok = [UNNotificationAction actionWithIdentifier:@"Ok" title:@"Ok" options:UNNotificationActionOptionNone];
@ -1225,7 +1188,7 @@ bail:
request = [UNNotificationRequest requestWithIdentifier:NSUUID.UUID.UUIDString content:content trigger:NULL];
//send notification
[[UNUserNotificationCenter currentNotificationCenter] addNotificationRequest:request withCompletionHandler:^(NSError *_Nullable error)
[UNUserNotificationCenter.currentNotificationCenter addNotificationRequest:request withCompletionHandler:^(NSError *_Nullable error)
{
//error?
if(nil != error)
@ -1428,8 +1391,15 @@ bail:
# pragma mark UNNotificationCenter Delegate Methods
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler {
completionHandler(UNNotificationPresentationOptionAlert);
return;
}
//handle user response to notification
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
-(void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler {
//allowed items
NSMutableArray* allowedItems = nil;
@ -1533,7 +1503,7 @@ bail:
os_log_error(logHandle, "ERROR: failed to kill %@ (%@)", processName, processID);
//show an alert
showAlert([NSString stringWithFormat:@"ERROR: failed to block %@ (%@)", processName, processID], [NSString stringWithFormat:@"system error code: %d", error]);
showAlert([NSString stringWithFormat:@"ERROR: failed to terminate %@ (%@)", processName, processID], [NSString stringWithFormat:@"system error code: %d", error], @"OK");
//bail
goto bail;

View File

@ -95,12 +95,89 @@ extern os_log_t logHandle;
[self check4Update];
});
}
//can show notifications?
[self checkNotificationState];
bail:
return;
}
//can show notifications?
-(void)checkNotificationState
{
//notification style
__block NSString* style = nil;
//request authorization to allow notifications
// can always invoke this, as if user has already approved, this won't trigger any (secondary) prompt
[UNUserNotificationCenter.currentNotificationCenter requestAuthorizationWithOptions:(UNAuthorizationOptionAlert) completionHandler:^(BOOL granted, NSError * _Nullable error)
{
//dbg msg
os_log_debug(logHandle, "permission to display notifications granted? %d (error: %@)", granted, error);
//not granted/error
if( (nil != error) ||
(YES != granted) )
{
//on main thread
// show alert / open system preferences
dispatch_async(dispatch_get_main_queue(), ^{
//show alert
showAlert(@"ERROR: OverSight is not authorized to display notifications.", @"Please authorize (style: \"Alerts\") via the Notifications pane in System Preferences.", @"Open System Preferences...");
//open `System Preferences` notifications pane
[NSWorkspace.sharedWorkspace openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.notifications?com.objective-see.oversight"]];
});
}
//granted?
// on first run, ask nicely to have "alert" style set
else if( (YES == granted) &&
(YES == [NSProcessInfo.processInfo.arguments containsObject:INITIAL_LAUNCH]) )
{
//get settings
[UNUserNotificationCenter.currentNotificationCenter getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings * _Nonnull settings)
{
//enabled / alert style?
if( (UNAlertStyleAlert != settings.alertStyle) ||
(UNNotificationSettingEnabled != settings.alertSetting) )
{
//set style: none
if(UNAlertStyleNone == settings.alertStyle)
{
//set
style = @"\"None\"";
}
//set style: banners
else if(UNAlertStyleBanner == settings.alertStyle)
{
//set
style = @"\"Banners\"";
}
//on main thread
// show alert / open system preferences
dispatch_async(dispatch_get_main_queue(), ^{
//show alert
showAlert([NSString stringWithFormat:@"OverSight notification mode set to %@.", style], @"Please change to \"Alerts\" via the Notifications pane in System Preferences.", @"Open System Preferences...");
//open `System Preferences` notifications pane
[NSWorkspace.sharedWorkspace openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.notifications?com.objective-see.oversight"]];
});
}
}];
}
}];
return;
}
//handle user double-clicks
// app is (likely) already running as login item, so show (or) activate window
-(BOOL)applicationShouldHandleReopen:(NSApplication *)sender hasVisibleWindows:(BOOL)hasVisibleWindows

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21225" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21225"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21225" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21225"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21225" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21225"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>

View File

@ -384,14 +384,14 @@
CODE_SIGN_ENTITLEMENTS = "";
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2.1.1;
CURRENT_PROJECT_VERSION = 2.1.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = NO;
INFOPLIST_FILE = Helper/Info.plist;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.1.1;
MARKETING_VERSION = 2.1.2;
ONLY_ACTIVE_ARCH = NO;
OTHER_CODE_SIGN_FLAGS = "";
OTHER_LDFLAGS = (
@ -419,14 +419,14 @@
CODE_SIGN_ENTITLEMENTS = "";
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 2.1.1;
CURRENT_PROJECT_VERSION = 2.1.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = NO;
INFOPLIST_FILE = Helper/Info.plist;
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.1.1;
MARKETING_VERSION = 2.1.2;
ONLY_ACTIVE_ARCH = NO;
OTHER_CODE_SIGN_FLAGS = "";
OTHER_LDFLAGS = (
@ -455,7 +455,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.1.1;
CURRENT_PROJECT_VERSION = 2.1.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
@ -467,7 +467,7 @@
);
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.1.1;
MARKETING_VERSION = 2.1.2;
OTHER_CODE_SIGN_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "com.objective-see.oversight.installer";
PRODUCT_NAME = "OverSight Installer";
@ -484,7 +484,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 2.1.1;
CURRENT_PROJECT_VERSION = 2.1.2;
DEVELOPMENT_TEAM = VBG97UB4TA;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)/../Carthage/Build/Mac";
@ -496,7 +496,7 @@
);
LIBRARY_SEARCH_PATHS = "";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 2.1.1;
MARKETING_VERSION = 2.1.2;
OTHER_CODE_SIGN_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = "com.objective-see.oversight.installer";
PRODUCT_NAME = "OverSight Installer";

View File

@ -0,0 +1,35 @@
{
"images" : [
{
"idiom" : "mac",
"filename" : "darkMode.png"
},
{
"idiom" : "mac",
"filename" : "lightMode.png",
"appearances" : [
{
"appearance" : "luminosity",
"value" : "light"
}
]
},
{
"idiom" : "mac",
"filename" : "darkMode.png",
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
]
}
],
"info" : {
"version" : 1,
"author" : "xcode"
},
"properties" : {
"preserves-vector-representation" : true
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

View File

@ -35,6 +35,14 @@
//spinner
@property (weak, nonatomic) IBOutlet NSProgressIndicator *activityIndicator;
/* INFO ABOUT NOTIFICATIONS */
//notifications view
@property (strong, nonatomic) IBOutlet NSView *notificationsView;
//support us
@property (weak, nonatomic) IBOutlet NSButton *gotoSupportViewButton;
/* SUPPORT US */
//support us view

View File

@ -196,6 +196,21 @@ extern os_log_t logHandle;
break;
}
//show 'support' view
case ACTION_SHOW_NOTIFICATIONS:
{
//dbg msg
os_log_debug(logHandle, "showing 'notifcations' view");
//show view
[self showView:self.notificationsView firstResponder:self.gotoSupportViewButton];
//unset window title
self.window.title = @"";
break;
}
//show 'support' view
case ACTION_SHOW_SUPPORT:
@ -508,7 +523,7 @@ extern os_log_t logHandle;
self.installButton.title = ACTION_NEXT;
//set tag
self.installButton.tag = ACTION_SHOW_SUPPORT;
self.installButton.tag = ACTION_SHOW_NOTIFICATIONS;
}
//otherwise
// set button and tag for close/exit

View File

@ -1,16 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21225" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21225"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="ConfigureWindowController">
<connections>
<outlet property="activityIndicator" destination="b1w-5W-ayX" id="P5e-PO-Ozi"/>
<outlet property="gotoSupportViewButton" destination="8I9-ag-g5s" id="7ej-Ft-edA"/>
<outlet property="installButton" destination="553-2y-kvm" id="nxf-wO-EI3"/>
<outlet property="moreInfoButton" destination="QWu-qZ-Za2" id="8kC-Ga-5oJ"/>
<outlet property="notificationsView" destination="DoQ-oR-CLI" id="F1Y-Mo-2E6"/>
<outlet property="statusMsg" destination="SpB-Xc-WlB" id="jlm-ke-XfM"/>
<outlet property="supportButton" destination="pM7-Wp-KdU" id="fez-2X-gLE"/>
<outlet property="supportView" destination="bkk-rY-ALC" id="3xt-YX-akQ"/>
@ -95,6 +97,49 @@
</connections>
<point key="canvasLocation" x="216.5" y="-225.5"/>
</window>
<customView id="DoQ-oR-CLI" userLabel="Notifications">
<rect key="frame" x="0.0" y="0.0" width="812" height="500"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<box fixedFrame="YES" boxType="custom" borderType="none" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="4k7-qq-cJd">
<rect key="frame" x="0.0" y="0.0" width="812" height="48"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<view key="contentView" id="lkA-o8-ZEW">
<rect key="frame" x="0.0" y="0.0" width="812" height="48"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button verticalHuggingPriority="750" fixedFrame="YES" tag="3" translatesAutoresizingMaskIntoConstraints="NO" id="8I9-ag-g5s">
<rect key="frame" x="718" y="7" width="81" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Next »" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="DHG-bQ-JvA">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" size="13" name="Menlo-Bold"/>
</buttonCell>
<connections>
<action selector="configureButtonHandler:" target="-2" id="6Tl-Ce-fBS"/>
</connections>
</button>
</subviews>
</view>
<color key="fillColor" red="0.52700018810000004" green="0.69087679930000001" blue="0.21211786799999999" alpha="0.99595620600000001" colorSpace="custom" customColorSpace="sRGB"/>
</box>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" preferredMaxLayoutWidth="660" translatesAutoresizingMaskIntoConstraints="NO" id="06L-aW-Qeu">
<rect key="frame" x="93" y="370" width="615" height="110"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="If prompted, please allow OverSight to show notifications, setting the style to &quot;Alerts&quot;" id="8dX-bb-vf1">
<font key="font" size="32" name="AvenirNextCondensed-Regular"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="wmq-9S-jMi">
<rect key="frame" x="41" y="39" width="731" height="359"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="Notifications" id="tTt-LO-Ecg"/>
</imageView>
</subviews>
<point key="canvasLocation" x="686" y="1393"/>
</customView>
<customView id="bkk-rY-ALC" userLabel="Support">
<rect key="frame" x="0.0" y="0.0" width="812" height="500"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
@ -117,7 +162,7 @@
<action selector="configureButtonHandler:" target="-2" id="Ipm-LG-LXx"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" tag="5" translatesAutoresizingMaskIntoConstraints="NO" id="pM7-Wp-KdU">
<button verticalHuggingPriority="750" fixedFrame="YES" tag="4" translatesAutoresizingMaskIntoConstraints="NO" id="pM7-Wp-KdU">
<rect key="frame" x="718" y="7" width="81" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Yes!" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="E5X-AO-6V1">
@ -228,6 +273,7 @@
<image name="FriendsSophos" width="518" height="137"/>
<image name="Icon" width="512" height="512"/>
<image name="Love" width="256" height="256"/>
<image name="Notifications" width="1430" height="607"/>
<image name="OverSight" width="1301" height="227"/>
</resources>
</document>

View File

@ -40,7 +40,7 @@ int main(int argc, char *argv[])
if(YES != hasAdminPrivileges())
{
//show alert
showAlert(@"ERROR: Insuffient Privileges.", @"OverSight can only be installed / run on accounts with administrative privileges");
showAlert(@"ERROR: Insuffient Privileges.", @"OverSight can only be installed / run on accounts with administrative privileges", @"Exit");
//bail
goto bail;

View File

@ -202,11 +202,14 @@
//button title: next
#define ACTION_NEXT @"Next »"
//show info about notifications
#define ACTION_SHOW_NOTIFICATIONS 2
//show friends
#define ACTION_SHOW_SUPPORT 4
#define ACTION_SHOW_SUPPORT 3
//support us
#define ACTION_SUPPORT 5
#define ACTION_SUPPORT 4
//path to chmod
#define CHMOD @"/bin/chmod"

View File

@ -34,7 +34,6 @@ NSString* getAppVersion(void);
//get (true) parent
NSDictionary* getRealParent(pid_t pid);
//extract value from plist
// takes optional wait time...
id getValueFromPlist(NSString* plistFile, NSString* key, BOOL insensitive, float maxWait);
@ -125,12 +124,10 @@ NSString* valueForStringItem(NSString* item);
// thanks: http://lapcatsoftware.com/articles/detect-app-translocation.html
BOOL isTranslocated(NSString* path);
//running on M1?
BOOL AppleSilicon(void);
//show an alert
NSModalResponse showAlert(NSString* messageText, NSString* informativeText);
NSModalResponse showAlert(NSString* messageText, NSString* informativeText, NSString* buttonTitle);
//does console user have admin privs?
BOOL hasAdminPrivileges(void);
#endif

View File

@ -1590,56 +1590,9 @@ BOOL isDarkMode()
return [[[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"] isEqualToString:@"Dark"];
}
//running on M1?
BOOL AppleSilicon(void)
{
//flag
BOOL isAppleSilicon = NO;
//type
cpu_type_t type = -1;
//size
size_t size = 0;
//mib
int mib[CTL_MAXNAME] = {0};
//length
size_t length = CTL_MAXNAME;
//get mib for 'proc_cputype'
if(noErr != sysctlnametomib("sysctl.proc_cputype", mib, &length))
{
//bail
goto bail;
}
//add pid
mib[length] = getpid();
//inc length
length++;
//init size
size = sizeof(cpu_type_t);
//get CPU type
if(noErr != sysctl(mib, (u_int)length, &type, &size, 0, 0))
{
//bail
goto bail;
}
isAppleSilicon = (CPU_TYPE_ARM64 == type);
bail:
return isAppleSilicon;
}
//show an alert
NSModalResponse showAlert(NSString* messageText, NSString* informativeText)
NSModalResponse showAlert(NSString* messageText, NSString* informativeText, NSString* buttonTitle)
{
//alert
NSAlert* alert = nil;
@ -1664,7 +1617,7 @@ NSModalResponse showAlert(NSString* messageText, NSString* informativeText)
}
//add button
[alert addButtonWithTitle:@"OK"];
[alert addButtonWithTitle:buttonTitle];
//make app active
[NSApp activateIgnoringOtherApps:YES];
@ -1675,9 +1628,8 @@ NSModalResponse showAlert(NSString* messageText, NSString* informativeText)
return response;
}
//checks if user has admin privs
// ->based off http://stackoverflow.com/questions/30000443/asking-for-admin-privileges-for-only-standard-accounts
// based off http://stackoverflow.com/questions/30000443/asking-for-admin-privileges-for-only-standard-accounts
BOOL hasAdminPrivileges()
{
//flag