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

View File

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

View File

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

View File

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