Mac OS X Launcher: Misc changes in ObjC, forwarding sendUserNotification to Swift.

This commit is contained in:
meeh
2018-12-08 09:14:33 +00:00
parent a0d356bc56
commit dfcc616cb3
4 changed files with 15 additions and 6 deletions

View File

@@ -63,8 +63,8 @@
}
- (void) requestRestart
{
self.userRequestedRestart = YES;
{ self.userRequestedRestart = YES;
kill([self.routerTask processIdentifier], SIGHUP);
}
@@ -84,7 +84,9 @@
{
NSLog(@"Expection occurred %@", [e reason]);
self.isRouterRunning = NO;
[[[RouterProcessStatus alloc] init] triggerEventWithEn:@"router_exception" details:[e reason]];
[[SBridge sharedInstance] setCurrentRouterInstance:nil];
sendUserNotification(@"An error occured, can't start the I2P Router", [e reason]);
return 0;

View File

@@ -62,5 +62,6 @@ inline std::string buildClassPathForObjC(std::string basePath)
- (void) startupI2PRouter:(NSString*)i2pRootPath;
- (void) openUrl:(NSString*)url;
+ (void) logProxy:(int)level formattedMsg:(NSString*)formattedMsg;
+ (void) sendUserNotification:(NSString*)title formattedMsg:(NSString*)formattedMsg;
+ (instancetype)sharedInstance; // this makes it a singleton
@end

View File

@@ -119,6 +119,11 @@ std::future<int> startupRouter(NSString* javaBin, NSArray<NSString*>* arguments,
return sharedInstance;
}
+ (void) sendUserNotification:(NSString*)title formattedMsg:(NSString*)formattedMsg
{
sendUserNotification(title, formattedMsg);
}
- (void) openUrl:(NSString*)url
{
osx::openUrl(url);

View File

@@ -73,9 +73,10 @@ using namespace subprocess;
[self.userPreferences registerDefaults:@{
@"enableLogging": @YES,
@"enableVerboseLogging": @YES,
@"autoStartRouter": @YES,
@"startRouterAtLogin": @NO,
@"startRouterAtStartup": @NO,
@"autoStartRouterAtBoot": @NO,
@"startLauncherAtLogin": @NO,
@"startRouterAtStartup": @YES,
@"stopRouterAtShutdown": @YES,
@"letRouterLiveEvenLauncherDied": @NO,
@"consolePortCheckNum": @7657,
@"i2pBaseDirectory": (NSString *)CFStringCreateWithCString(NULL, const_cast<const char *>(getDefaultBaseDir().c_str()), kCFStringEncodingUTF8)
@@ -87,7 +88,7 @@ using namespace subprocess;
CFPreferencesSetMultiple((CFDictionaryRef)dict, NULL, CFAPPDOMAIN, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost);
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
if (self.enableVerboseLogging) NSLog(@"Default preferences stored!");
NSLog(@"Default preferences stored!");
}