-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
FIX(macos): Update some of macOS obj-c code for 10.15 minimum #7004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,6 @@ | |
| #include <xar/xar.h> | ||
| } | ||
|
|
||
| // Ignore deprecation warnings for the whole file, for now. | ||
| #pragma GCC diagnostic ignored "-Wdeprecated-declarations" | ||
|
|
||
| static NSString *MumbleOverlayLoaderBundle = @"/Library/ScriptingAdditions/MumbleOverlay.osax"; | ||
| static NSString *MumbleOverlayLoaderBundleIdentifier = @"net.sourceforge.mumble.OverlayScriptingAddition"; | ||
|
|
@@ -80,53 +78,52 @@ - (void) dealloc { | |
| - (void) appLaunched:(NSNotification *)notification { | ||
| if (active) { | ||
| BOOL overlayEnabled = NO; | ||
| NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; | ||
| NSDictionary *userInfo = [notification userInfo]; | ||
| @autoreleasepool { | ||
| NSDictionary *userInfo = [notification userInfo]; | ||
|
|
||
| NSString *bundleId = [userInfo objectForKey:@"NSApplicationBundleIdentifier"]; | ||
| if ([bundleId isEqualToString:[[NSBundle mainBundle] bundleIdentifier]]) | ||
| return; | ||
| NSString *bundleId = userInfo[@"NSApplicationBundleIdentifier"]; | ||
| if ([bundleId isEqualToString:[[NSBundle mainBundle] bundleIdentifier]]) | ||
| return; | ||
|
|
||
| QString qsBundleIdentifier = QString::fromUtf8([bundleId UTF8String]); | ||
| QString qsBundleIdentifier = QString::fromUtf8([bundleId UTF8String]); | ||
|
|
||
| switch (Global::get().s.os.oemOverlayExcludeMode) { | ||
| case OverlaySettings::LauncherFilterExclusionMode: { | ||
| qWarning("Overlay_macx: launcher filter mode not implemented on macOS, allowing everything"); | ||
| overlayEnabled = YES; | ||
| break; | ||
| } | ||
| case OverlaySettings::WhitelistExclusionMode: { | ||
| if (Global::get().s.os.qslWhitelist.contains(qsBundleIdentifier)) { | ||
| switch (Global::get().s.os.oemOverlayExcludeMode) { | ||
| case OverlaySettings::LauncherFilterExclusionMode: { | ||
| qWarning("Overlay_macx: launcher filter mode not implemented on macOS, allowing everything"); | ||
| overlayEnabled = YES; | ||
| break; | ||
| } | ||
| break; | ||
| } | ||
| case OverlaySettings::BlacklistExclusionMode: { | ||
| if (! Global::get().s.os.qslBlacklist.contains(qsBundleIdentifier)) { | ||
| overlayEnabled = YES; | ||
| case OverlaySettings::WhitelistExclusionMode: { | ||
| if (Global::get().s.os.qslWhitelist.contains(qsBundleIdentifier)) { | ||
| overlayEnabled = YES; | ||
| } | ||
| break; | ||
| } | ||
| case OverlaySettings::BlacklistExclusionMode: { | ||
| if (! Global::get().s.os.qslBlacklist.contains(qsBundleIdentifier)) { | ||
| overlayEnabled = YES; | ||
| } | ||
| break; | ||
| } | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (overlayEnabled) { | ||
| pid_t pid = [[userInfo objectForKey:@"NSApplicationProcessIdentifier"] intValue]; | ||
| SBApplication *app = [SBApplication applicationWithProcessIdentifier:pid]; | ||
| [app setDelegate:self]; | ||
| if (overlayEnabled) { | ||
| pid_t pid = [userInfo[@"NSApplicationProcessIdentifier"] intValue]; | ||
| SBApplication *app = [SBApplication applicationWithProcessIdentifier:pid]; | ||
| [app setDelegate:self]; | ||
|
|
||
| // This timeout is specified in 'ticks'. | ||
| // A tick defined as: "[...] (a tick is approximately 1/60 of a second) [...]" in the | ||
| // Apple Event Manager Reference documentation: | ||
| // http://developer.apple.com/legacy/mac/library/documentation/Carbon/reference/Event_Manager/Event_Manager.pdf | ||
| [app setTimeout:10*60]; | ||
| // This timeout is specified in 'ticks'. | ||
| // A tick defined as: "[...] (a tick is approximately 1/60 of a second) [...]" in the | ||
| // Apple Event Manager Reference documentation: | ||
| // http://developer.apple.com/legacy/mac/library/documentation/Carbon/reference/Event_Manager/Event_Manager.pdf | ||
| [app setTimeout:10*60]; | ||
|
|
||
| [app setSendMode:kAEWaitReply]; | ||
| [app sendEvent:kASAppleScriptSuite id:kGetAEUT parameters:0]; | ||
| [app setSendMode:kAEWaitReply]; | ||
| [app sendEvent:kASAppleScriptSuite id:kGetAEUT parameters:0]; | ||
|
|
||
| [app setSendMode:kAENoReply]; | ||
| [app setSendMode:kAENoReply]; | ||
| } | ||
| } | ||
|
|
||
| [pool release]; | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -308,7 +305,7 @@ static bool isInstallerNewer(QString path, NSUInteger curVer) { | |
| bool OverlayConfig::needsUpgrade() { | ||
| NSDictionary *infoPlist = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/Contents/Info.plist", MumbleOverlayLoaderBundle]]; | ||
| if (infoPlist) { | ||
| NSUInteger curVersion = [[infoPlist objectForKey:@"MumbleOverlayVersion"] unsignedIntegerValue]; | ||
| NSUInteger curVersion = [infoPlist[@"MumbleOverlayVersion"] unsignedIntegerValue]; | ||
|
|
||
| QString path = installerPath(); | ||
| if (path.isEmpty()) | ||
|
|
@@ -321,10 +318,12 @@ static bool isInstallerNewer(QString path, NSUInteger curVer) { | |
| } | ||
|
|
||
| static bool authExec(AuthorizationRef ref, const char **argv) { | ||
| Q_UNUSED(ref); | ||
| Q_UNUSED(argv); | ||
| OSStatus err = noErr; | ||
| int pid = 0, status = 0; | ||
|
|
||
| err = AuthorizationExecuteWithPrivileges(ref, argv[0], kAuthorizationFlagDefaults, const_cast<char * const *>(&argv[1]), nullptr); | ||
| // Deprecated: AuthorizationExecuteWithPrivileges removed. Consider using SMJobBless or a helper tool for privileged operations. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like this effectively removes the entire functionality of
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of removing the functionality entirely, we can replace it with a supported approach. /bin/mv /Library/ScriptingAdditions/MumbleOverlay.osax /tmp/%1_Uninstalled_MumbleOverlay.osaxWe can achieve the same effect using AppleScript. From the AppleScript documentation under
We can use the NSAppleScript class to create the commands and execute them. This should keep the functionality the same but use the supported Apple API. |
||
| if (err == errAuthorizationSuccess) { | ||
| do { | ||
| pid = wait(&status); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment above should be removed as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, definitely can do