Changeset 231 for trunk/Cocoa


Ignore:
Timestamp:
05/30/06 07:28:35 (14 years ago)
Author:
rchin
Message:

Updated FScript framework zip to current working version (pre-release). Also added code to better do upgrading of existing outdated fscript framework versions. Also better checking for procmod existence.

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  
    976976                                GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
    977977                                GCC_OPTIMIZATION_LEVEL = 0;
    978                                 HEADER_SEARCH_PATHS = (
    979                                         "$(HEADER_SEARCH_PATHS_QUOTED_1)",
    980                                 );
     978                                HEADER_SEARCH_PATHS = "$(HEADER_SEARCH_PATHS_QUOTED_1)";
    981979                                HEADER_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/include\"";
    982980                                INFOPLIST_FILE = "Info-Application.plist";
    983981                                INSTALL_PATH = /;
    984                                 LIBRARY_SEARCH_PATHS = (
    985                                         "$(LIBRARY_SEARCH_PATHS_QUOTED_1)",
    986                                 );
     982                                LIBRARY_SEARCH_PATHS = "$(LIBRARY_SEARCH_PATHS_QUOTED_1)";
    987983                                LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/libstuff\"";
    988984                                OPTIMIZATION_CFLAGS = "-O0";
     
    10201016                                FRAMEWORK_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)\"";
    10211017                                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)";
    10251019                                HEADER_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/include\"";
    10261020                                INFOPLIST_FILE = "Info-Application.plist";
    10271021                                INSTALL_PATH = /;
    1028                                 LIBRARY_SEARCH_PATHS = (
    1029                                         "$(LIBRARY_SEARCH_PATHS_QUOTED_1)",
    1030                                 );
     1022                                LIBRARY_SEARCH_PATHS = "$(LIBRARY_SEARCH_PATHS_QUOTED_1)";
    10311023                                LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/libstuff\"";
    10321024                                OTHER_CFLAGS = "-DFSA_DEBUG=0";
     
    10581050                                        "$(SRCROOT)",
    10591051                                );
    1060                                 HEADER_SEARCH_PATHS = (
    1061                                         "$(HEADER_SEARCH_PATHS_QUOTED_1)",
    1062                                 );
     1052                                HEADER_SEARCH_PATHS = "$(HEADER_SEARCH_PATHS_QUOTED_1)";
    10631053                                HEADER_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/include\"";
    10641054                                INFOPLIST_FILE = "Info-Application.plist";
    10651055                                INSTALL_PATH = /;
    1066                                 LIBRARY_SEARCH_PATHS = (
    1067                                         "$(LIBRARY_SEARCH_PATHS_QUOTED_1)",
    1068                                 );
     1056                                LIBRARY_SEARCH_PATHS = "$(LIBRARY_SEARCH_PATHS_QUOTED_1)";
    10691057                                LIBRARY_SEARCH_PATHS_QUOTED_1 = "\"$(SRCROOT)/../Darwin source/Commands/Apple/cctools/libstuff\"";
    10701058                                OTHER_LDFLAGS = (
  • trunk/Cocoa/F-Script Anywhere/Source/FSAApp.h

    r230 r231  
    5454
    5555- (IBAction)installBundleInSelectedApp:(id)sender;
     56- (void)installBundleInAppWithPID:(pid_t)pid;
    5657-(BOOL)createAuthorization;
    5758
  • trunk/Cocoa/F-Script Anywhere/Source/FSAApp.mm

    r230 r231  
    3131#import <ApplicationServices/ApplicationServices.h>
    3232#import <Security/AuthorizationTags.h>
     33#include <mach/mach.h>
    3334
    3435NSString * const PatchBundleIdentifier = @"net.sabi.FScriptAnywhere";
     
    120121}
    121122
    122 -(void)installFScript
     123-(void)installFScriptAtPath:(NSString *)installPath
    123124{
    124125    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];
    131126   
    132127    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        }
    134132    }
    135133   
     
    141139                    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]){
    142140            case NSAlertDefaultReturn:  // Current user
    143                 installPath = [@"~/Library/Frameworks/FScript.framework" stringByExpandingTildeInPath];
     141                installPath = [@"~/Library/Frameworks" stringByExpandingTildeInPath];
    144142                break;
    145143            case NSAlertAlternateReturn: // All users
    146                 installPath = @"/Library/Frameworks/FScript.framework";
     144                installPath = @"/Library/Frameworks";
    147145                break;
    148146            default:
     
    152150   
    153151    NSString *fromPath = [[NSBundle mainBundle] pathForResource:@"FScript" ofType:@"framework"];
    154     if(![[NSFileManager defaultManager] fileExistsAtPath:[installPath stringByDeletingLastPathComponent]]){
     152    if(![[NSFileManager defaultManager] fileExistsAtPath:installPath]){
    155153        if ([[NSFileManager defaultManager] isWritableFileAtPath:installPath]){
    156             [[NSFileManager defaultManager] createDirectoryAtPath:[installPath stringByDeletingLastPathComponent]
     154            [[NSFileManager defaultManager] createDirectoryAtPath:installPath
    157155                                                       attributes:nil];
    158156        } else {
    159157            [self createAuthorization];
    160158            NSString *myToolPath = @"/bin/mkdir";
    161             char *myArguments[] = { (char *)[[installPath stringByDeletingLastPathComponent] UTF8String], NULL };
     159            char *myArguments[] = { (char *)[installPath UTF8String], NULL };
    162160            myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, [myToolPath UTF8String],
    163161                                                          myFlags, myArguments,
     
    165163        }
    166164    }
    167     if([[NSFileManager defaultManager] isWritableFileAtPath:[installPath stringByDeletingLastPathComponent]]){
    168         [[NSFileManager defaultManager] copyPath:fromPath toPath:installPath handler:nil];
     165    if([[NSFileManager defaultManager] isWritableFileAtPath:installPath]){
     166        [[NSFileManager defaultManager] copyPath:fromPath toPath:[installPath stringByAppendingString:@"/FScript.framework"] handler:nil];
    169167    } else {
    170168        [self createAuthorization];
    171169        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 };
    173171        myStatus = AuthorizationExecuteWithPrivileges(myAuthorizationRef, [myToolPath UTF8String],
    174172                                                      myFlags, myArguments,
     
    177175}
    178176
    179 - (BOOL)_shouldContinueAfterFrameworkErrorPanelReturnedWithResult:(int)result;
     177- (BOOL)_shouldContinueAfterFrameworkErrorPanelReturnedWithResult:(int)result withFrameworkPath:(NSString *)frameworkPath
    180178{
    181179    switch (result) {
    182180        case NSAlertOtherReturn:
     181            [self terminate: self];
     182            return false;
     183        case NSAlertAlternateReturn:
    183184            return true;
    184         case NSAlertAlternateReturn: /* Install from resources */
    185             [self installFScript];
     185        case NSAlertDefaultReturn: /* Install from resources */
     186            [self installFScriptAtPath:frameworkPath];
    186187            return true;
    187         case NSAlertDefaultReturn:
    188188        default:
    189189            [self terminate: self];
     
    249249- (void)finishLaunching
    250250{
    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"]){
    256259top:
    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                            }
    280294                        }
    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                }
    291305            }
    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    }
     312next:
    297313    patchController = new FSAPatchController(self);
    298314    patchController->AddPatch((CFStringRef)PatchBundleIdentifier, CFSTR("Contents/Resources/"),
     
    320336        NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSAllDomainsMask, TRUE);
    321337    NSString *libPath;
    322     NSString *frameworkPath;
     338    NSString *frameworkPath = NULL;
    323339    CFBundleRef frameworkBundle = NULL;
    324340    BOOL isDirectory;
     
    342358            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 '%@'.",
    343359                              "Framework not found alert message, F-Script Web site URL parameter, 'Continue' button parameter"),
    344             NSLocalizedString(@"Quit", "Quit button title"),
    345360            NSLocalizedString(@"Install F-Script", "'Get F-Script' button title"),
    346361            NSLocalizedString(@"Continue", "Continue button title"),
     362            NSLocalizedString(@"Quit", "Quit button title"),
    347363            FSA_FScriptURL, NSLocalizedString(@"Continue", ""));
    348         if (![self _shouldContinueAfterFrameworkErrorPanelReturnedWithResult: result]) return;
     364        if (![self _shouldContinueAfterFrameworkErrorPanelReturnedWithResult: result withFrameworkPath:nil]) return;
    349365    } else {
     366        CFBundleRef includedBundle = CFBundleCreate(kCFAllocatorDefault, (CFURLRef)[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"FScript" ofType:@"framework"]]);
     367        [(id)includedBundle autorelease];
     368        UInt32 includedVersion = CFBundleGetVersionNumber(includedBundle);
    350369        UInt32 version = CFBundleGetVersionNumber(frameworkBundle);
    351370        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"];
    367403    }
    368404
  • trunk/Cocoa/F-Script Anywhere/Source/SCPatch/SCPatchController/SCPatchController.h

    r153 r231  
    11#pragma once
     2#include <Carbon/Carbon.h>
     3#include <list>
    24
    3 #include <Carbon/Carbon.h>
    4 #include <list.h>
     5using namespace std;
    56
    67#include "SCPatchPrivate.h"
Note: See TracChangeset for help on using the changeset viewer.