Play-/Source/ui_ios/AltServerJitService.mm

74 lines
1.5 KiB
Text
Raw Normal View History

#import "AltServerJitService.h"
#import "AltKit-Swift.h"
2025-03-11 12:48:26 -04:00
#include "AppConfig.h"
#import "PreferenceDefs.h"
@implementation AltServerJitService
- (id)init
{
if(self = [super init])
{
[self registerPreferences];
}
return self;
}
+ (AltServerJitService*)sharedAltServerJitService
{
static AltServerJitService* sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
2021-11-20 17:01:30 -05:00
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
- (void)registerPreferences
{
CAppConfig::GetInstance().RegisterPreferenceBoolean(PREFERENCE_ALTSTORE_JIT_ENABLED, false);
}
- (void)startProcess
{
//Don't start the process if it's not enabled
if(!CAppConfig::GetInstance().GetPreferenceBoolean(PREFERENCE_ALTSTORE_JIT_ENABLED))
{
return;
}
2021-11-20 17:01:30 -05:00
//Don't start the process if we've already started it
if(self.processStarted)
{
return;
}
2021-11-20 17:01:30 -05:00
self.processStarted = YES;
2021-11-20 17:01:30 -05:00
[[ALTServerManager sharedManager] startDiscovering];
[[ALTServerManager sharedManager] autoconnectWithCompletionHandler:^(ALTServerConnection* connection, NSError* error) {
if(error)
{
return NSLog(@"Could not auto-connect to server. %@", error);
}
[connection enableUnsignedCodeExecutionWithCompletionHandler:^(BOOL success, NSError* error) {
if(success)
{
NSLog(@"Successfully enabled JIT compilation!");
[[ALTServerManager sharedManager] stopDiscovering];
self.jitEnabled = true;
}
else
{
NSLog(@"Could not enable JIT compilation. %@", error);
}
[connection disconnect];
}];
}];
}
@end