Ignore:
Timestamp:
Sep 20, 2018 3:20:39 AM (20 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
85ebb2f
Parents:
3c0a8cf
Message:

Mac OS X Launcher: more cleanup and some bugfixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/main.mm

    r3c0a8cf re8decff5  
    1212#import <Foundation/Foundation.h>
    1313#import <Foundation/NSFileManager.h>
    14 
    15 
    16 #include <CoreFoundation/CoreFoundation.h>
    17 #include <CoreFoundation/CFStream.h>
    18 #include <CoreFoundation/CFPropertyList.h>
    19 #include <CoreFoundation/CFDictionary.h>
    20 #include <CoreFoundation/CFArray.h>
    21 #include <CoreFoundation/CFString.h>
    2214#include <CoreFoundation/CFPreferences.h>
    2315
     
    3123#include "AppDelegate.h"
    3224#include "RouterTask.h"
    33 #include "JavaHelper.h"
    3425#include "include/fn.h"
    3526#include "include/portcheck.h"
     
    112103      cli.push_back("net.i2p.launchers.BaseExtractor");
    113104      auto rs = [[RouterProcessStatus alloc] init];
    114       NSString* jh = [rs getJavaHome];
    115       if (jh != nil) {
    116         NSLog(@"jh er %@", jh);
    117       }
    118      
    119       NSString* newString = [NSString stringWithFormat:@"file://%@", rs.getJavaHome];
    120       NSURL *baseURL = [NSURL fileURLWithPath:newString];
    121105     
    122106      std::string execStr = std::string([rs.getJavaHome UTF8String]);
     
    133117        if (extractStatus == 0)
    134118        {
    135           //success = YES;
    136           NSLog(@"Time to detect I2P version in install directory");
    137           [self.swiftRuntime findInstalledI2PVersion];
     119          NSLog(@"Extraction complete!");
    138120        }
    139121     
     
    147129      // All done. Assume success and error are already set.
    148130      dispatch_async(dispatch_get_main_queue(), ^{
    149         //sendUserNotification(APP_IDSTR, @"Extraction complete!", self.contentImage);
    150131        if (completion) {
    151132          completion(success, error);
     
    159140    }
    160141  });
    161    
    162  
    163 }
    164 
    165 
    166 - (NSString *)userSelectJavaHome:(JvmListPtr)rawJvmList
    167 {
    168   NSString *appleScriptString = @"set jvmlist to {\"Newest\"";
    169   for (auto item : *rawJvmList) {
    170     auto str = strprintf(",\"%s\"", item->JVMName.c_str()).c_str();
    171     NSString* tmp = [NSString stringWithUTF8String:str];
    172     appleScriptString = [appleScriptString stringByAppendingString:tmp];
    173   }
    174   appleScriptString = [appleScriptString stringByAppendingString:@"}\nchoose from list jvmlist\n"];
    175   NSAppleScript *theScript = [[NSAppleScript alloc] initWithSource:appleScriptString];
    176   NSDictionary *theError = nil;
    177   NSString* userResult = [[theScript executeAndReturnError: &theError] stringValue];
    178   NSLog(@"User choosed %@.\n", userResult);
    179   if (theError != nil)
    180   {
    181     NSLog(@"Error: %@.\n", theError);
    182   }
    183   return userResult;
    184142}
    185143
    186144- (void)setApplicationDefaultPreferences {
    187   auto defaultJVMHome = check_output({"/usr/libexec/java_home","-v",DEF_MIN_JVM_VER});
    188   auto tmpStdStr = std::string(defaultJVMHome.buf.data());
    189   trim(tmpStdStr);
    190   auto cfDefaultHome  = CFStringCreateWithCString(NULL, const_cast<const char *>(tmpStdStr.c_str()), kCFStringEncodingUTF8);
    191145  [self.userPreferences registerDefaults:@{
    192     @"javaHome" : (NSString *)cfDefaultHome,
    193     @"lastI2PVersion" : (NSString *)CFSTR(DEF_I2P_VERSION),
    194146    @"enableLogging": @YES,
    195147    @"enableVerboseLogging": @YES,
     
    197149    @"i2pBaseDirectory": (NSString *)CFStringCreateWithCString(NULL, const_cast<const char *>(getDefaultBaseDir().c_str()), kCFStringEncodingUTF8)
    198150  }];
    199   if (self.enableVerboseLogging) NSLog(@"Default JVM home preference set to: %@", cfDefaultHome);
    200151
    201152  auto dict = [self.userPreferences dictionaryRepresentation];
     
    206157
    207158  if (self.enableVerboseLogging) NSLog(@"Default preferences stored!");
     159}
     160
    208161#endif
    209 }
    210 
    211 
    212162
    213163
     
    232182
    233183#ifdef __cplusplus
    234   //gRawJvmList = std::make_shared<std::list<JvmVersionPtr> >(std::list<JvmVersionPtr>());
    235184
    236185  RouterProcessStatus* routerStatus = [[RouterProcessStatus alloc] init];
     
    256205
    257206  NSBundle *launcherBundle = [NSBundle mainBundle];
     207  auto sBridge = [[SBridge alloc] init];
    258208 
    259209  // Helper object to hold statefull path information
     
    270220  jarfile += [self.metaInfo.zipFile UTF8String];
    271221 
    272   auto sBridge = [[SBridge alloc] init];
    273  
    274222  // Initialize the Swift environment (the UI components)
    275223  [self.swiftRuntime applicationDidFinishLaunching];
     
    287235      NSLog(@"Done extracting I2P");
    288236     
     237      NSLog(@"Time to detect I2P version in install directory");
     238      [self.swiftRuntime findInstalledI2PVersion];
    289239      if (shouldAutoStartRouter) {
    290240        [sBridge startupI2PRouter:self.metaInfo.i2pBase javaBinPath:self.metaInfo.javaBinary];
     
    295245  } else {
    296246    // I2P was already found extracted
     247    NSLog(@"Time to detect I2P version in install directory");
     248    [self.swiftRuntime findInstalledI2PVersion];
    297249   
    298250    if (shouldAutoStartRouter) {
Note: See TracChangeset for help on using the changeset viewer.