Changeset a9bf9e06


Ignore:
Timestamp:
Oct 13, 2018 3:52:40 AM (22 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
5304709
Parents:
e2d2264
Message:

OSX Launcher: make deployer an property so it's not deleted in mid-extract by GC.

Location:
launchers/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/AppDelegate.h

    re2d2264 ra9bf9e06  
    2222
    2323@class SwiftMainDelegate;
     24@class I2PDeployer;
    2425
    2526@protocol SwiftMainDelegateProto
     
    9394@property (assign) NSUserDefaults *userPreferences;
    9495@property (assign) ExtractMetaInfo *metaInfo;
     96@property (assign) I2PDeployer *deployer;
    9597@property (copy) NSImage *contentImage NS_AVAILABLE(10_9, NA);
    9698
  • launchers/macosx/main.mm

    re2d2264 ra9bf9e06  
    6666- (void)extractI2PBaseDir:(void(^)(BOOL success, NSError *error))completion
    6767{
    68   auto deployer = [[I2PDeployer alloc] initWithMetaInfo:self.metaInfo];
    69   [deployer extractI2PBaseDir:completion];
     68  self.deployer = [[I2PDeployer alloc] initWithMetaInfo:self.metaInfo];
     69  [self.deployer extractI2PBaseDir:completion];
    7070}
    7171
     
    7878    @"startRouterAtStartup": @NO,
    7979    @"letRouterLiveEvenLauncherDied": @NO,
     80    @"consolePortCheckNum": @7657,
    8081    @"i2pBaseDirectory": (NSString *)CFStringCreateWithCString(NULL, const_cast<const char *>(getDefaultBaseDir().c_str()), kCFStringEncodingUTF8)
    8182  }];
     
    120121  [self.swiftRuntime applicationDidFinishLaunching];
    121122 
    122   // TODO: Make the port a setting which defaults to 7657
    123   if (port_check(7657) != 0)
     123  NSInteger portNum = [self.userPreferences integerForKey:@"consolePortCheckNum"];
     124  if (port_check((int)portNum) != 0)
    124125  {
    125     NSLog(@"Seems i2p is already running - I will not start the router (port 7657 is in use..)");
     126    NSLog(@"Seems i2p is already running - I will not start the router (port %d is in use..)", (int)portNum);
    126127    sendUserNotification(@"Found already running router", @"TCP port 7657 seem to be used by another i2p instance.");
    127128   
     
    131132  } else {
    132133    shouldAutoStartRouter = true;
     134  }
     135  if (![self.userPreferences boolForKey:@"startRouterAtLogin"] && ![self.userPreferences boolForKey:@"startRouterAtStartup"])
     136  {
     137    // In this case we don't want to find a running service
     138    std::string launchdFile(RealHomeDirectory());
     139    launchdFile += "/Library/LaunchAgents/net.i2p.macosx.I2PRouter.plist";
     140   
    133141  }
    134142
     
    148156  std::string jarfile("-cp ");
    149157  jarfile += [self.metaInfo.zipFile UTF8String];
    150  
    151   // Might be hard to read if you're not used to Objective-C
    152   // But this is a "function call" that contains a "callback function"
    153   /*[routerStatus listenForEventWithEventName:@"router_can_start" callbackActionFn:^(NSString* information) {
    154     NSLog(@"Got signal, router can be started");
    155     [[SBridge sharedInstance] startupI2PRouter:self.metaInfo.i2pBase];
    156   }];*/
    157158 
    158159  // This will trigger the router start after an upgrade.
Note: See TracChangeset for help on using the changeset viewer.