Changeset 231
- Timestamp:
- 05/30/06 07:28:35 (18 years ago)
- Location:
- trunk/Cocoa/F-Script Anywhere/Source
- Files:
-
- 1 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Cocoa/F-Script Anywhere/Source/F-Script Anywhere.xcodeproj/project.pbxproj
r230 r231 976 976 GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 977 977 GCC_OPTIMIZATION_LEVEL = 0; 978 HEADER_SEARCH_PATHS = ( 979 "$(HEADER_SEARCH_PATHS_QUOTED_1)", 980 ); 978 HEADER_SEARCH_PATHS = "$(HEADER_SEARCH_PATHS_QUOTED_1)"; 981 979 HEADER_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/include\""; 982 980 INFOPLIST_FILE = "Info-Application.plist"; 983 981 INSTALL_PATH = /; 984 LIBRARY_SEARCH_PATHS = ( 985 "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", 986 ); 982 LIBRARY_SEARCH_PATHS = "$(LIBRARY_SEARCH_PATHS_QUOTED_1)"; 987 983 LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/libstuff\""; 988 984 OPTIMIZATION_CFLAGS = "-O0"; … … 1020 1016 FRAMEWORK_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)\""; 1021 1017 GCC_ENABLE_FIX_AND_CONTINUE = NO; 1022 HEADER_SEARCH_PATHS = ( 1023 "$(HEADER_SEARCH_PATHS_QUOTED_1)", 1024 ); 1018 HEADER_SEARCH_PATHS = "$(HEADER_SEARCH_PATHS_QUOTED_1)"; 1025 1019 HEADER_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/include\""; 1026 1020 INFOPLIST_FILE = "Info-Application.plist"; 1027 1021 INSTALL_PATH = /; 1028 LIBRARY_SEARCH_PATHS = ( 1029 "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", 1030 ); 1022 LIBRARY_SEARCH_PATHS = "$(LIBRARY_SEARCH_PATHS_QUOTED_1)"; 1031 1023 LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/libstuff\""; 1032 1024 OTHER_CFLAGS = "-DFSA_DEBUG=0"; … … 1058 1050 "$(SRCROOT)", 1059 1051 ); 1060 HEADER_SEARCH_PATHS = ( 1061 "$(HEADER_SEARCH_PATHS_QUOTED_1)", 1062 ); 1052 HEADER_SEARCH_PATHS = "$(HEADER_SEARCH_PATHS_QUOTED_1)"; 1063 1053 HEADER_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/include\""; 1064 1054 INFOPLIST_FILE = "Info-Application.plist"; 1065 1055 INSTALL_PATH = /; 1066 LIBRARY_SEARCH_PATHS = ( 1067 "$(LIBRARY_SEARCH_PATHS_QUOTED_1)", 1068 ); 1056 LIBRARY_SEARCH_PATHS = "$(LIBRARY_SEARCH_PATHS_QUOTED_1)"; 1069 1057 LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/libstuff\""; 1070 1058 OTHER_LDFLAGS = ( -
trunk/Cocoa/F-Script Anywhere/Source/FSAApp.h
r230 r231 54 54 55 55 - (IBAction)installBundleInSelectedApp:(id)sender; 56 - (void)installBundleInAppWithPID:(pid_t)pid; 56 57 -(BOOL)createAuthorization; 57 58 -
trunk/Cocoa/F-Script Anywhere/Source/FSAApp.mm
r230 r231 31 31 #import <ApplicationServices/ApplicationServices.h> 32 32 #import <Security/AuthorizationTags.h> 33 #include <mach/mach.h> 33 34 34 35 NSString * const PatchBundleIdentifier = @"net.sabi.FScriptAnywhere"; … … 120 121 } 121 122 122 -(void)installFScript 123 -(void)installFScriptAtPath:(NSString *)installPath 123 124 { 124 125 OSStatus myStatus; 125 126 NSString *installPath = nil;127 if([[NSFileManager defaultManager] fileExistsAtPath:@"/Library/Frameworks/FScript.framework"])128 installPath = @"/Library/Frameworks/FScript.framework";129 if([[NSFileManager defaultManager] fileExistsAtPath:[@"~/Library/Frameworks/FScript.framework" stringByExpandingTildeInPath]])130 installPath = [@"~/Library/Frameworks/FScript.framework" stringByExpandingTildeInPath];131 126 132 127 if(installPath){ 133 [[NSFileManager defaultManager] removeFileAtPath:installPath handler:nil]; 128 if([installPath hasSuffix:@"FScript.framework"]){ 129 installPath = [installPath stringByDeletingLastPathComponent]; 130 NSLog(@"new ip %@", installPath); 131 } 134 132 } 135 133 … … 141 139 informativeTextWithFormat:@"No previous version of F-Script found. You can choose to install for just your current user (~/Library/Frameworks) or for all users (/Library/Frameworks)."] runModal]){ 142 140 case NSAlertDefaultReturn: // Current user 143 installPath = [@"~/Library/Frameworks /FScript.framework" stringByExpandingTildeInPath];141 installPath = [@"~/Library/Frameworks" stringByExpandingTildeInPath]; 144 142 break; 145 143 case NSAlertAlternateReturn: // All users 146 installPath = @"/Library/Frameworks /FScript.framework";144 installPath = @"/Library/Frameworks"; 147 145 break; 148 146 default: … … 152 150 153 151 NSString *fromPath = [[NSBundle mainBundle] pathForResource:@"FScript" ofType:@"framework"]; 154 if(![[NSFileManager defaultManager] fileExistsAtPath: [installPath stringByDeletingLastPathComponent]]){152 if(![[NSFileManager defaultManager] fileExistsAtPath:installPath]){ 155 153 if ([[NSFileManager defaultManager] isWritableFileAtPath:installPath]){ 156 [[NSFileManager defaultManager] createDirectoryAtPath: [installPath stringByDeletingLastPathComponent]154 [[NSFileManager defaultManager] createDirectoryAtPath:installPath 157 155 attributes:nil]; 158 156 } else { 159 157 [self createAuthorization]; 160 158 NSString *myToolPath = @"/bin/mkdir"; 161 char *myArguments[] = { (char *)[ [installPath stringByDeletingLastPathComponent]UTF8String], NULL };159 char *myArguments[] = { (char *)[installPath UTF8String], NULL }; 162 160 myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, [myToolPath UTF8String], 163 161 myFlags, myArguments, … … 165 163 } 166 164 } 167 if([[NSFileManager defaultManager] isWritableFileAtPath: [installPath stringByDeletingLastPathComponent]]){168 [[NSFileManager defaultManager] copyPath:fromPath toPath: installPathhandler:nil];165 if([[NSFileManager defaultManager] isWritableFileAtPath:installPath]){ 166 [[NSFileManager defaultManager] copyPath:fromPath toPath:[installPath stringByAppendingString:@"/FScript.framework"] handler:nil]; 169 167 } else { 170 168 [self createAuthorization]; 171 169 NSString *myToolPath = @"/bin/cp"; 172 char *myArguments[] = { "- r", (char *)[fromPath UTF8String], (char *)[installPath UTF8String], NULL };170 char *myArguments[] = { "-R", "-f", (char *)[fromPath UTF8String], (char *)[installPath UTF8String], NULL }; 173 171 myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, [myToolPath UTF8String], 174 172 myFlags, myArguments, … … 177 175 } 178 176 179 - (BOOL)_shouldContinueAfterFrameworkErrorPanelReturnedWithResult:(int)result ;177 - (BOOL)_shouldContinueAfterFrameworkErrorPanelReturnedWithResult:(int)result withFrameworkPath:(NSString *)frameworkPath 180 178 { 181 179 switch (result) { 182 180 case NSAlertOtherReturn: 181 [self terminate: self]; 182 return false; 183 case NSAlertAlternateReturn: 183 184 return true; 184 case NSAlert AlternateReturn:/* Install from resources */185 [self installFScript ];185 case NSAlertDefaultReturn: /* Install from resources */ 186 [self installFScriptAtPath:frameworkPath]; 186 187 return true; 187 case NSAlertDefaultReturn:188 188 default: 189 189 [self terminate: self]; … … 249 249 - (void)finishLaunching 250 250 { 251 #ifdef __i386__ 252 if(![[NSUserDefaults standardUserDefaults] objectForKey:@"doPathCheck"]) 253 [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"doPathCheck"]; 254 255 if([[NSUserDefaults standardUserDefaults] boolForKey:@"doPathCheck"]){ 251 mach_port_t taskOfOurProcess = mach_task_self(); 252 mach_port_t machPortForProcess; 253 254 if(task_for_pid(taskOfOurProcess, 1, &machPortForProcess) != KERN_SUCCESS){ // launchd should always be pid 1 255 if(![[NSUserDefaults standardUserDefaults] objectForKey:@"doPathCheck"]) 256 [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"doPathCheck"]; 257 258 if([[NSUserDefaults standardUserDefaults] boolForKey:@"doPathCheck"]){ 256 259 top: 257 PathManager *pm = [[PathManager alloc] initWithLocalNode]; 258 [pm backupStack]; 259 [pm cd:@"/Groups/procmod"]; 260 CFDictionaryRef sessionInfoDict = CGSessionCopyCurrentDictionary(); 261 if(sessionInfoDict){ 262 CFStringRef shortUserName = (CFStringRef)CFDictionaryGetValue(sessionInfoDict, kCGSessionUserNameKey); 263 if(![[[pm lastObject] readArray:@"GroupMembership"] containsObject:(NSString *)shortUserName]){ 264 switch([[NSAlert alertWithMessageText:[NSString stringWithFormat:@"User %@ not in the procmod group", shortUserName] 265 defaultButton:@"Add me" 266 alternateButton:@"Disable checking" 267 otherButton:@"Ignore message" 268 informativeTextWithFormat:@"F-Script Anywhere requires that you add yourself to the procmod " 269 "group in order for it to function properly. If you like, F-Script Anywhere can automatically add you " 270 "to the procmod group."] runModal]){ 271 case NSAlertDefaultReturn: 272 { 273 tDirStatus status = [self authorizeAndAddToProcMod:(NSString *)shortUserName]; 274 if(status != eDSNoErr){ 275 [[NSAlert alertWithMessageText:@"Error adding to procmod group" 276 defaultButton:nil 277 alternateButton:nil 278 otherButton:nil 279 informativeTextWithFormat:@"There was an error (%@) adding you to the procmod group. ", [[NSClassFromString(@"DSoStatus") sharedInstance] stringForStatus:status]] runModal]; 260 PathManager *pm = [[PathManager alloc] initWithLocalNode]; 261 [pm backupStack]; 262 @try { 263 [pm cd:@"/Groups/procmod"]; 264 } @catch ( NSException *exception ) { 265 goto next; // this means we must be on ppc 10.4 or less. 266 } 267 CFDictionaryRef sessionInfoDict = CGSessionCopyCurrentDictionary(); 268 if(sessionInfoDict){ 269 CFStringRef shortUserName = (CFStringRef)CFDictionaryGetValue(sessionInfoDict, kCGSessionUserNameKey); 270 if(![[[pm lastObject] readArray:@"GroupMembership"] containsObject:(NSString *)shortUserName]){ 271 switch([[NSAlert alertWithMessageText:[NSString stringWithFormat:@"User %@ not in the procmod group", shortUserName] 272 defaultButton:@"Add me" 273 alternateButton:@"Disable checking" 274 otherButton:@"Ignore message" 275 informativeTextWithFormat:@"F-Script Anywhere requires that you add yourself to the procmod " 276 "group in order for it to function properly. If you like, F-Script Anywhere can automatically add you " 277 "to the procmod group."] runModal]){ 278 case NSAlertDefaultReturn: 279 { 280 tDirStatus status = [self authorizeAndAddToProcMod:(NSString *)shortUserName]; 281 if(status != eDSNoErr){ 282 [[NSAlert alertWithMessageText:@"Error adding to procmod group" 283 defaultButton:nil 284 alternateButton:nil 285 otherButton:nil 286 informativeTextWithFormat:@"There was an error (%@) adding you to the procmod group. ", [[NSClassFromString(@"DSoStatus") sharedInstance] stringForStatus:status]] runModal]; 287 } else { 288 [[NSAlert alertWithMessageText:@"Adding user procmod group succeeded" 289 defaultButton:nil 290 alternateButton:nil 291 otherButton:nil 292 informativeTextWithFormat:@"You may have to wait a few minutes until the system updates its caches (or alternatively, reboot your machine) before things will work properly."] runModal]; 293 } 280 294 } 281 }282 [pm restoreStack];283 [pm release];284 goto top;285 case NSAlertAlternateReturn:286 [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"doPathCheck"];287 break;288 default:289 break;290 } 295 [pm restoreStack]; 296 [pm release]; 297 goto top; 298 case NSAlertAlternateReturn: 299 [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"doPathCheck"]; 300 break; 301 default: 302 break; 303 } 304 } 291 305 } 292 } 293 [pm restoreStack]; 294 [pm release]; 295 } 296 #endif 306 [pm restoreStack]; 307 [pm release]; 308 } 309 } else { 310 mach_port_deallocate(taskOfOurProcess, machPortForProcess); 311 } 312 next: 297 313 patchController = new FSAPatchController(self); 298 314 patchController->AddPatch((CFStringRef)PatchBundleIdentifier, CFSTR("Contents/Resources/"), … … 320 336 NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSAllDomainsMask, TRUE); 321 337 NSString *libPath; 322 NSString *frameworkPath ;338 NSString *frameworkPath = NULL; 323 339 CFBundleRef frameworkBundle = NULL; 324 340 BOOL isDirectory; … … 342 358 NSLocalizedString(@"F-Script Anywhere requires the F-Script framework be installed in a Frameworks directory, such as ~/Library/Frameworks or /Library/Frameworks.\n\nTo download F-Script, please visit its Web site\n%@.\n\nThis package also includes a copy of F-Script for your convenience that can be installed easily by clicking below. Note that there may be a more recent version of F-Script available from the F-Script web site.\n\nIf you believe this message is in error, click '%@'.", 343 359 "Framework not found alert message, F-Script Web site URL parameter, 'Continue' button parameter"), 344 NSLocalizedString(@"Quit", "Quit button title"),345 360 NSLocalizedString(@"Install F-Script", "'Get F-Script' button title"), 346 361 NSLocalizedString(@"Continue", "Continue button title"), 362 NSLocalizedString(@"Quit", "Quit button title"), 347 363 FSA_FScriptURL, NSLocalizedString(@"Continue", "")); 348 if (![self _shouldContinueAfterFrameworkErrorPanelReturnedWithResult: result ]) return;364 if (![self _shouldContinueAfterFrameworkErrorPanelReturnedWithResult: result withFrameworkPath:nil]) return; 349 365 } else { 366 CFBundleRef includedBundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"FScript" ofType:@"framework"]]); 367 [(id)includedBundle autorelease]; 368 UInt32 includedVersion = CFBundleGetVersionNumber(includedBundle); 350 369 UInt32 version = CFBundleGetVersionNumber(frameworkBundle); 351 370 FSALog(@"Framework version 0x%x", version); 352 if (version < FSA_FSCRIPT_MIN_VERSION) { 353 NSString *frameworkVersion = (NSString *)CFBundleGetValueForInfoDictionaryKey(frameworkBundle, kCFBundleVersionKey); 354 if (frameworkVersion == nil) 355 frameworkVersion = NSLocalizedString(@"unavailable", "Framework too old 'unavailable' version"); 356 int result = NSRunInformationalAlertPanel( 357 NSLocalizedString(@"F-Script Framework Too Old", "Framework too old alert title"), 358 NSLocalizedString(@"F-Script Anywhere %s requires version %@ or later of the F-Script framework be installed in a Frameworks directory, such as ~/Library/Frameworks or /Library/Frameworks. The installed version is %@.\n\nTo upgrade F-Script, please visit its Web site\n%@.\n\nThis package also includes a copy of F-Script for your convenience that can be installed easily by clicking below. Note that there may be a more recent version of F-Script available from the F-Script web site.\n\nTo use this version of F-Script regardless of the problems you may experience, click '%@'.", 359 "Framework too old alert message, FSA version parameter, minimum F-Script version parameter, current F-Script version parameter, F-Script Web site URL parameter, 'Continue' button parameter"), 360 NSLocalizedString(@"Quit", "Quit button title"), 361 NSLocalizedString(@"Install F-Script", "'Get F-Script' button title"), 362 NSLocalizedString(@"Continue", "Continue button title"), 363 FSA_VERSION, FSA_FScriptMinimumVersion, frameworkVersion, 364 FSA_FScriptURL, NSLocalizedString(@"Install F-Script", "")); 365 if (![self _shouldContinueAfterFrameworkErrorPanelReturnedWithResult: result]) return; 366 } 371 if(version < includedVersion){ 372 if (version < FSA_FSCRIPT_MIN_VERSION){ // must force upgrade 373 NSString *frameworkVersion = (NSString *)CFBundleGetValueForInfoDictionaryKey(frameworkBundle, kCFBundleVersionKey); 374 if (frameworkVersion == nil) 375 frameworkVersion = NSLocalizedString(@"unavailable", "Framework too old 'unavailable' version"); 376 int result = NSRunInformationalAlertPanel( 377 NSLocalizedString(@"F-Script Framework Too Old", "Framework too old alert title"), 378 NSLocalizedString(@"F-Script Anywhere %s requires version %@ or later of the F-Script framework be installed in a Frameworks directory, such as ~/Library/Frameworks or /Library/Frameworks. The installed version is %@.\n\nTo upgrade F-Script to the latest version, please visit its Web site\n%@.\n\nThis package also includes a copy of F-Script for your convenience that can be installed easily by clicking below. Note that there may be a more recent version of F-Script available from the F-Script web site.\n\nTo use this version of F-Script regardless of the problems you may experience, click '%@'.", 379 "Framework too old alert message, FSA version parameter, minimum F-Script version parameter, current F-Script version parameter, F-Script Web site URL parameter, 'Continue' button parameter"), 380 NSLocalizedString(@"Install F-Script", "'Get F-Script' button title"), 381 NSLocalizedString(@"Continue", "Continue button title"), 382 NSLocalizedString(@"Quit", "Quit button title"), 383 FSA_VERSION, FSA_FScriptMinimumVersion, frameworkVersion, 384 FSA_FScriptURL, NSLocalizedString(@"Install F-Script", "")); 385 if (![self _shouldContinueAfterFrameworkErrorPanelReturnedWithResult: result withFrameworkPath:frameworkPath]) return; 386 } else { 387 NSNumber *lastChecked = [[NSUserDefaults standardUserDefaults] objectForKey:@"LastCheckedVersion"]; 388 if((version < includedVersion) && (!lastChecked || ([lastChecked unsignedIntValue] != version))){ 389 FSALog(@"Included framework in resources is newer than installed version."); 390 int result = NSRunInformationalAlertPanel( 391 NSLocalizedString(@"Newer Version of F-Script Framework Available", "Framework newer found alert title"), 392 NSLocalizedString(@"F-Script Anywhere is bundled with a newer version of the F-Script framework. If you wish, F-Script Anywhere can upgrade your framework version.", 393 "Framework newer found alert message, 'Continue' button parameter"), 394 NSLocalizedString(@"Upgrade F-Script Framework", "Upgrade button title"), 395 NSLocalizedString(@"Continue", "Continue button title"), 396 nil, 397 NSLocalizedString(@"Upgrade", ""), NSLocalizedString(@"Continue", "")); 398 if (![self _shouldContinueAfterFrameworkErrorPanelReturnedWithResult: result withFrameworkPath:frameworkPath]) return; 399 } 400 } 401 } 402 [[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithUnsignedInt:version] forKey:@"LastCheckedVersion"]; 367 403 } 368 404 -
trunk/Cocoa/F-Script Anywhere/Source/SCPatch/SCPatchController/SCPatchController.h
r153 r231 1 1 #pragma once 2 #include <Carbon/Carbon.h> 3 #include <list> 2 4 3 #include <Carbon/Carbon.h> 4 #include <list.h> 5 using namespace std; 5 6 6 7 #include "SCPatchPrivate.h"
Note:
See TracChangeset
for help on using the changeset viewer.