Changeset 1144 for branches

Show
Ignore:
Timestamp:
02/18/10 18:59:01 (2 years ago)
Author:
gbooker
Message:

Added framework loader (and copying) code

Location:
branches/PlayerFramework/CommonMediaPlayer
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • branches/PlayerFramework/CommonMediaPlayer/Classes/CMPPlayerManager.h

    r1107 r1144  
    4040 
    4141@end 
     42 
     43#ifdef FrameworkLoadDebug 
     44#define FrameworkLoadPrint(...) NSLog(__VA_ARGS__) 
     45#else 
     46#define FrameworkLoadPrint(...) 
     47#endif 
     48 
     49static inline BOOL needCopy(NSString *frameworkPath) 
     50{ 
     51        NSFileManager *fm = [NSFileManager defaultManager]; 
     52        BOOL isDir = NO; 
     53        FrameworkLoadPrint(@"Checking if dir exists"); 
     54        if(![fm fileExistsAtPath:frameworkPath isDirectory:&isDir] || !isDir) 
     55                return YES; 
     56         
     57        NSBundle *bundle = [NSBundle bundleWithPath:frameworkPath]; 
     58        NSString *plistPath = [bundle pathForResource:@"Info" ofType:@"plist"]; 
     59        NSDictionary *plist = [NSDictionary dictionaryWithContentsOfFile:plistPath]; 
     60         
     61        NSString *version = [plist objectForKey:@"CFBundleVersion"]; 
     62        FrameworkLoadPrint(@"Version is %@:%d compared to %d", version, [version intValue], CMPVersion); 
     63        if([version intValue] < CMPVersion) 
     64                return YES; 
     65         
     66        return NO; 
     67} 
     68 
     69static inline BOOL loadCMPFramework(NSString *frapPath) 
     70{ 
     71        NSString *frameworkPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Frameworks/CommonMediaPlayer.framework"]; 
     72        FrameworkLoadPrint(@"Path is at %@", frameworkPath); 
     73        BOOL neededCopy = needCopy(frameworkPath); 
     74        FrameworkLoadPrint(@"Need copy is %d", neededCopy); 
     75        if(neededCopy) 
     76        { 
     77                NSFileManager *fm = [NSFileManager defaultManager]; 
     78                FrameworkLoadPrint(@"Going to copy %@", [frapPath stringByAppendingPathComponent:@"Contents/Frameworks/CommonMediaPlayer.framework"]); 
     79                BOOL success = [fm removeFileAtPath:frameworkPath handler:nil]; 
     80                FrameworkLoadPrint(@"Delete success is %d", success); 
     81                success = [fm copyPath:[frapPath stringByAppendingPathComponent:@"Contents/Frameworks/CommonMediaPlayer.framework"] toPath:frameworkPath handler:nil]; 
     82                FrameworkLoadPrint(@"Copy success is %d", success); 
     83                if(!success || needCopy(frameworkPath)) 
     84                        //We failed in our copy too! 
     85                        return NO; 
     86        } 
     87         
     88        NSBundle *framework = [NSBundle bundleWithPath:frameworkPath]; 
     89        FrameworkLoadPrint(@"Bundle is %@", framework); 
     90        if([framework isLoaded] && neededCopy) 
     91        { 
     92                //We should restart here 
     93                FrameworkLoadPrint(@"Need to restart"); 
     94                [[NSApplication sharedApplication] terminate:nil]; 
     95        } 
     96         
     97        FrameworkLoadPrint(@"Loading framework"); 
     98        return [framework load]; 
     99} 
  • branches/PlayerFramework/CommonMediaPlayer/Classes/CMPTypesDefines.h

    r1136 r1144  
    2020 */ 
    2121 
     22#import "CMPDefines.h" 
     23 
    2224typedef enum{ 
    2325        CMPPlayerManagerFileTypeQTCompatibleVideo = 0, 
  • branches/PlayerFramework/CommonMediaPlayer/CommonMediaPlayer.xcodeproj/project.pbxproj

    r1136 r1144  
    5050                F595C652111A70CD00C6C322 /* CMPBaseMediaAsset.h in Headers */ = {isa = PBXBuildFile; fileRef = F595C650111A70CD00C6C322 /* CMPBaseMediaAsset.h */; }; 
    5151                F595C653111A70CD00C6C322 /* CMPBaseMediaAsset.m in Sources */ = {isa = PBXBuildFile; fileRef = F595C651111A70CD00C6C322 /* CMPBaseMediaAsset.m */; }; 
     52                F5FE4F18112E11D1007EC309 /* CMPDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = F5FE4F17112E11D1007EC309 /* CMPDefines.h */; settings = {ATTRIBUTES = (Public, ); }; }; 
    5253/* End PBXBuildFile section */ 
    5354 
     
    110111                F595C650111A70CD00C6C322 /* CMPBaseMediaAsset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMPBaseMediaAsset.h; sourceTree = "<group>"; }; 
    111112                F595C651111A70CD00C6C322 /* CMPBaseMediaAsset.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CMPBaseMediaAsset.m; sourceTree = "<group>"; }; 
     113                F5FE4F17112E11D1007EC309 /* CMPDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CMPDefines.h; sourceTree = "<group>"; }; 
    112114/* End PBXFileReference section */ 
    113115 
     
    192194                                F595C650111A70CD00C6C322 /* CMPBaseMediaAsset.h */, 
    193195                                F595C651111A70CD00C6C322 /* CMPBaseMediaAsset.m */, 
     196                                F5FE4F17112E11D1007EC309 /* CMPDefines.h */, 
    194197                        ); 
    195198                        path = Classes; 
     
    319322                                8768EBDC112A563800318F1A /* CMPDVDImporter.h in Headers */, 
    320323                                8768EC49112A5E4200318F1A /* AGProcess.h in Headers */, 
     324                                F5FE4F18112E11D1007EC309 /* CMPDefines.h in Headers */, 
    321325                        ); 
    322326                        runOnlyForDeploymentPostprocessing = 0; 
     
    465469                                GCC_PREFIX_HEADER = "General Headers/CommonMediaPlayer_Prefix.pch"; 
    466470                                INFOPLIST_FILE = Info.plist; 
     471                                INFOPLIST_PREFIX_HEADER = Classes/CMPDefines.h; 
     472                                INFOPLIST_PREPROCESS = YES; 
    467473                                INSTALL_PATH = /System/Library/CoreServices/Finder.app/Contents/PlugIns/nitoTV.frappliance/Contents/Frameworks; 
    468474                                OTHER_LDFLAGS = ( 
     
    492498                                GCC_PREFIX_HEADER = "General Headers/CommonMediaPlayer_Prefix.pch"; 
    493499                                INFOPLIST_FILE = Info.plist; 
     500                                INFOPLIST_PREFIX_HEADER = Classes/CMPDefines.h; 
     501                                INFOPLIST_PREPROCESS = YES; 
    494502                                INSTALL_PATH = /System/Library/CoreServices/Finder.app/Contents/PlugIns/nitoTV.frappliance/Contents/Frameworks/; 
    495503                                OTHER_LDFLAGS = ( 
  • branches/PlayerFramework/CommonMediaPlayer/Info.plist

    r1095 r1144  
    77        <key>CFBundleExecutable</key> 
    88        <string>${EXECUTABLE_NAME}</string> 
    9         <key>CFBundleName</key> 
    10         <string>${PRODUCT_NAME}</string> 
    119        <key>CFBundleIconFile</key> 
    1210        <string></string> 
    1311        <key>CFBundleIdentifier</key> 
    14         <string>com.yourcompany.${PRODUCT_NAME:rfc1034Identifier}</string> 
     12        <string>net.nanopi.appletv.CommonMediaPlayer</string> 
    1513        <key>CFBundleInfoDictionaryVersion</key> 
    1614        <string>6.0</string> 
     15        <key>CFBundleName</key> 
     16        <string>${PRODUCT_NAME}</string> 
    1717        <key>CFBundlePackageType</key> 
    1818        <string>FMWK</string> 
     19        <key>CFBundleShortVersionString</key> 
     20        <string>1.0</string> 
    1921        <key>CFBundleSignature</key> 
    2022        <string>????</string> 
    2123        <key>CFBundleVersion</key> 
    22         <string>1</string> 
    23         <key>CFBundleShortVersionString</key> 
    24         <string>1.0</string> 
     24        <string>CMPVersion</string> 
    2525        <key>NSPrincipalClass</key> 
    2626        <string></string>