Changeset b25dec1


Ignore:
Timestamp:
Oct 11, 2018 4:58:20 PM (22 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
3988a86
Parents:
f57f8c60
Message:

OSX Launcher: some changes to the Swift↔Objective-C bridge

Location:
launchers/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/I2PLauncher/I2PLauncher-Bridging-Header.h

    rf57f8c60 rb25dec1  
    66#import "AppDelegate.h"
    77#import "RouterTask.h"
    8 #import "Sparkle/SUUpdater.h"
    9 
     8#import "logger_c.h"
  • launchers/macosx/SBridge.h

    rf57f8c60 rb25dec1  
    5656#endif
    5757
     58
    5859@interface SBridge : NSObject
    5960@property (nonatomic, assign) I2PRouterTask* currentRouterInstance;
    6061- (NSString*) buildClassPath:(NSString*)i2pPath;
    61 - (void) startupI2PRouter:(NSString*)i2pRootPath javaBinPath:(NSString*)javaBinPath;
     62- (void) startupI2PRouter:(NSString*)i2pRootPath;
    6263- (void) openUrl:(NSString*)url;
     64+ (void) logProxy:(int)level formattedMsg:(NSString*)formattedMsg;
    6365+ (instancetype)sharedInstance; // this makes it a singleton
    6466@end
  • launchers/macosx/SBridge.mm

    rf57f8c60 rb25dec1  
    3232std::future<int> startupRouter(NSString* javaBin, NSArray<NSString*>* arguments, NSString* i2pBaseDir, RouterProcessStatus* routerStatus) {
    3333  @try {
     34   
     35    /**
     36     *
     37     * The following code will do a test, where it lists all known processes in the OS (visibility depending on user rights)
     38     * and scan for any command/arguments matching the substring "i2p.jar" - and in which case it won't start I2P itself.
     39     *
     40     **/
    3441    IIProcessInfo* processInfoObj = [[IIProcessInfo alloc] init];
    3542    [processInfoObj obtainFreshProcessList];
    3643    auto anyRouterLookingProcs = [processInfoObj findProcessWithStringInNameOrArguments:@"i2p.jar"];
    3744    if (anyRouterLookingProcs) {
     45      /**
     46       * The router was found running
     47       */
    3848      auto errMessage = @"Seems i2p is already running - I've detected another process with i2p.jar in it's arguments.";
    3949      MLog(4, @"%@", errMessage);
     
    4454      });
    4555    } else {
     56      /**
     57       * No router was detected running
     58       **/
    4659      RTaskOptions* options = [RTaskOptions alloc];
    4760      options.binPath = javaBin;
     
    121134}
    122135
    123 
    124 
    125 - (void)startupI2PRouter:(NSString*)i2pRootPath javaBinPath:(NSString*)javaBinPath
     136+ (void) logProxy:(int)level formattedMsg:(NSString*)formattedMsg
     137{
     138  MLog(level, formattedMsg);
     139}
     140
     141
     142- (void)startupI2PRouter:(NSString*)i2pRootPath
    126143{
    127144  std::string basePath([i2pRootPath UTF8String]);
     
    135152  try {
    136153    std::vector<NSString*> argList = {
     154      @"-v",
     155      @"1.7+",
     156      @"--exec",
     157      @"java",
    137158      @"-Xmx512M",
    138159      @"-Xms128m",
     
    158179    argList.push_back([NSString stringWithUTF8String:classPathStr.c_str()]);
    159180    argList.push_back(@"net.i2p.router.Router");
    160     auto javaBin = std::string([javaBinPath UTF8String]);
     181    auto javaBin = std::string("/usr/libexec/java_home");
    161182   
    162183   
    163184    sendUserNotification(APP_IDSTR, @"I2P Router is starting up!");
    164     auto nsJavaBin = javaBinPath;
     185    auto nsJavaBin = [NSString stringWithUTF8String:javaBin.c_str()];
    165186    auto nsBasePath = i2pRootPath;
    166187    NSArray* arrArguments = [NSArray arrayWithObjects:&argList[0] count:argList.size()];
    167188   
    168     MLog(0, @"Trying to run command: %@", javaBinPath);
     189    MLog(0, @"Trying to run command: %@", nsJavaBin);
    169190    MLog(0, @"With I2P Base dir: %@", i2pRootPath);
    170191    MLog(0, @"And Arguments: %@", arrArguments);
Note: See TracChangeset for help on using the changeset viewer.