2021-11-20 15:35:14 -05:00
|
|
|
#import "AltServerJitService.h"
|
|
|
|
#import "AltKit-Swift.h"
|
2025-03-11 12:48:26 -04:00
|
|
|
#include "AppConfig.h"
|
2021-11-20 15:35:14 -05:00
|
|
|
#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];
|
2021-11-20 15:35:14 -05:00
|
|
|
});
|
|
|
|
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
|
|
|
|
2021-11-20 15:35:14 -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
|
|
|
|
2021-11-20 15:35:14 -05:00
|
|
|
self.processStarted = YES;
|
2021-11-20 17:01:30 -05:00
|
|
|
|
2021-11-20 15:35:14 -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];
|
2023-10-25 10:47:10 -04:00
|
|
|
self.jitEnabled = true;
|
2021-11-20 15:35:14 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
NSLog(@"Could not enable JIT compilation. %@", error);
|
|
|
|
}
|
|
|
|
|
|
|
|
[connection disconnect];
|
|
|
|
}];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|