Changeset e8decff5 for launchers/macosx/main.mm
- Timestamp:
- Sep 20, 2018 3:20:39 AM (3 years ago)
- Branches:
- master
- Children:
- 85ebb2f
- Parents:
- 3c0a8cf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
launchers/macosx/main.mm
r3c0a8cf re8decff5 12 12 #import <Foundation/Foundation.h> 13 13 #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>22 14 #include <CoreFoundation/CFPreferences.h> 23 15 … … 31 23 #include "AppDelegate.h" 32 24 #include "RouterTask.h" 33 #include "JavaHelper.h"34 25 #include "include/fn.h" 35 26 #include "include/portcheck.h" … … 112 103 cli.push_back("net.i2p.launchers.BaseExtractor"); 113 104 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];121 105 122 106 std::string execStr = std::string([rs.getJavaHome UTF8String]); … … 133 117 if (extractStatus == 0) 134 118 { 135 //success = YES; 136 NSLog(@"Time to detect I2P version in install directory"); 137 [self.swiftRuntime findInstalledI2PVersion]; 119 NSLog(@"Extraction complete!"); 138 120 } 139 121 … … 147 129 // All done. Assume success and error are already set. 148 130 dispatch_async(dispatch_get_main_queue(), ^{ 149 //sendUserNotification(APP_IDSTR, @"Extraction complete!", self.contentImage);150 131 if (completion) { 151 132 completion(success, error); … … 159 140 } 160 141 }); 161 162 163 }164 165 166 - (NSString *)userSelectJavaHome:(JvmListPtr)rawJvmList167 {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;184 142 } 185 143 186 144 - (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);191 145 [self.userPreferences registerDefaults:@{ 192 @"javaHome" : (NSString *)cfDefaultHome,193 @"lastI2PVersion" : (NSString *)CFSTR(DEF_I2P_VERSION),194 146 @"enableLogging": @YES, 195 147 @"enableVerboseLogging": @YES, … … 197 149 @"i2pBaseDirectory": (NSString *)CFStringCreateWithCString(NULL, const_cast<const char *>(getDefaultBaseDir().c_str()), kCFStringEncodingUTF8) 198 150 }]; 199 if (self.enableVerboseLogging) NSLog(@"Default JVM home preference set to: %@", cfDefaultHome);200 151 201 152 auto dict = [self.userPreferences dictionaryRepresentation]; … … 206 157 207 158 if (self.enableVerboseLogging) NSLog(@"Default preferences stored!"); 159 } 160 208 161 #endif 209 }210 211 212 162 213 163 … … 232 182 233 183 #ifdef __cplusplus 234 //gRawJvmList = std::make_shared<std::list<JvmVersionPtr> >(std::list<JvmVersionPtr>());235 184 236 185 RouterProcessStatus* routerStatus = [[RouterProcessStatus alloc] init]; … … 256 205 257 206 NSBundle *launcherBundle = [NSBundle mainBundle]; 207 auto sBridge = [[SBridge alloc] init]; 258 208 259 209 // Helper object to hold statefull path information … … 270 220 jarfile += [self.metaInfo.zipFile UTF8String]; 271 221 272 auto sBridge = [[SBridge alloc] init];273 274 222 // Initialize the Swift environment (the UI components) 275 223 [self.swiftRuntime applicationDidFinishLaunching]; … … 287 235 NSLog(@"Done extracting I2P"); 288 236 237 NSLog(@"Time to detect I2P version in install directory"); 238 [self.swiftRuntime findInstalledI2PVersion]; 289 239 if (shouldAutoStartRouter) { 290 240 [sBridge startupI2PRouter:self.metaInfo.i2pBase javaBinPath:self.metaInfo.javaBinary]; … … 295 245 } else { 296 246 // I2P was already found extracted 247 NSLog(@"Time to detect I2P version in install directory"); 248 [self.swiftRuntime findInstalledI2PVersion]; 297 249 298 250 if (shouldAutoStartRouter) {
Note: See TracChangeset
for help on using the changeset viewer.