2023-11-01 21:11:11 +00:00
// This file Copyright © Transmission authors and contributors.
2022-06-03 17:47:33 +00:00
// It may be used under the MIT (SPDX: MIT) license.
// License text can be found in the licenses/ folder.
2022-06-29 00:15:52 +00:00
@import ObjectiveC;
@import AppKit;
2022-10-31 14:37:34 +00:00
#import "NSStringAdditions.h"
2022-06-03 17:47:33 +00:00
2022-10-31 14:37:34 +00:00
// Development-only proxy when app is not signed for running Sparkle
2022-12-21 20:21:16 +00:00
void SUUpdater_checkForUpdates(id /*self*/, SEL /*_cmd*/, ...)
2022-06-03 17:47:33 +00:00
{
dispatch_async(dispatch_get_main_queue(), ^{
NSAlert* alert = [[NSAlert alloc] init];
2022-10-31 14:37:34 +00:00
alert.messageText = LocalizationNotNeeded(@"Sparkle not configured");
2022-06-03 17:47:33 +00:00
alert.informativeText = [NSString
stringWithFormat:@"App needs to be codesigned for Development to support Sparkle with Hardened Runtime. Alternatively, re-codesign without the Hardened Runtime option: `sudo codesign -s - %@`",
NSBundle.mainBundle.bundleURL.lastPathComponent];
[alert runModal];
});
}
/// Proxy SUUpdater if isn't registered at program startup due to codesigning.
__attribute__((constructor)) static void registerSUUpdater()
{
if (!objc_getClass("SUUpdater"))
{
NSLog(@"App is not signed for running Sparkle");
Class SUUpdaterClass = objc_allocateClassPair(objc_getClass("NSObject"), "SUUpdater", 0);
class_addMethod(SUUpdaterClass, sel_getUid("checkForUpdates:"), (IMP)SUUpdater_checkForUpdates, "v@:@");
objc_registerClassPair(SUUpdaterClass);
}
}