Changeset 494

Show
Ignore:
Timestamp:
02/20/08 16:53:20 (9 months ago)
Author:
gbooker
Message:

Start of Take 2 update; thanks Stephan
Refs #126

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/SapphireFrappliance/Info.plist

    r468 r494  
    3030        <true/> 
    3131        <key>NSPrincipalClass</key> 
    32         <string>SapphireAppliance</string> 
     32        <string>SapphireAppliance</string>       
     33        <!-- ATV2 --> 
     34        <key>FRApplianceCategoryDescriptors</key> 
     35        <array> 
     36                <dict> 
     37                        <key>identifier</key> 
     38                        <string>Sapphire</string> 
     39                        <key>is-network-dependent</key> 
     40                        <false/> 
     41                        <key>is-share-dependent</key> 
     42                        <false/> 
     43                        <key>is-store-category</key> 
     44                        <false/> 
     45                        <key>name</key> 
     46                        <string>Sapphire</string> 
     47                        <key>preferred-order</key> 
     48                        <real>1</real> 
     49                        <key>priority</key> 
     50                        <real>6</real> 
     51                </dict> 
     52        </array> 
    3353</dict> 
    3454</plist> 
  • trunk/SapphireFrappliance/Sapphire.xcodeproj/project.pbxproj

    r466 r494  
    122122                        remoteGlobalIDString = F5003FF80D19980A003FEA08; 
    123123                        remoteInfo = LeopardOnly; 
     124                }; 
     125                F56895E00D6CE30D00F9D9B0 /* PBXContainerItemProxy */ = { 
     126                        isa = PBXContainerItemProxy; 
     127                        containerPortal = F51BFD2D0D26BDF300E22363 /* SapphireCompatibilityClasses.xcodeproj */; 
     128                        proxyType = 2; 
     129                        remoteGlobalIDString = DCA299CA0D64A3B30092E9BB /* SapphireTakeTwoCompatClasses.framework */; 
     130                        remoteInfo = SapphireTakeTwoCompatClasses; 
    124131                }; 
    125132                F5B418700D0B29DE00BDD361 /* PBXContainerItemProxy */ = { 
     
    579586                                F5EBE6DD0D4A775400042BA0 /* SapphireCompatClasses.framework */, 
    580587                                F5EBE6DF0D4A775400042BA0 /* SapphireLeopardCompatClasses.framework */, 
     588                                F56895E10D6CE30D00F9D9B0 /* SapphireTakeTwoCompatClasses.framework */, 
    581589                        ); 
    582590                        name = Products; 
     
    683691 
    684692/* Begin PBXReferenceProxy section */ 
     693                F56895E10D6CE30D00F9D9B0 /* SapphireTakeTwoCompatClasses.framework */ = { 
     694                        isa = PBXReferenceProxy; 
     695                        fileType = wrapper.framework; 
     696                        path = SapphireTakeTwoCompatClasses.framework; 
     697                        remoteRef = F56895E00D6CE30D00F9D9B0 /* PBXContainerItemProxy */; 
     698                        sourceTree = BUILT_PRODUCTS_DIR; 
     699                }; 
    685700                F5EBE6DD0D4A775400042BA0 /* SapphireCompatClasses.framework */ = { 
    686701                        isa = PBXReferenceProxy; 
  • trunk/SapphireFrappliance/SapphireAppliance.h

    r461 r494  
    2020 
    2121/*! 
     22 * @brief The ATV 2 protocol 
     23 * 
     24 * This protocol defines the new methods in ATV 2. 
     25 */ 
     26@protocol BRAppliance <NSObject> 
     27- (id)applianceInfo; 
     28- (id)applianceCategories; 
     29- (id)identifierForContentAlias:(id)fp8; 
     30- (id)controllerForIdentifier:(id)fp8; 
     31@end 
     32 
     33/*! 
    2234 * @brief The Main class 
    2335 * 
    2436 * This class bypasses the whitelist check and sets up backrow to load and use the main controller. 
    2537 */ 
    26 @interface SapphireAppliance : BRAppliance  
    27 
     38@interface SapphireAppliance : NSObject <BRAppliance, BRApplianceProtocol> { 
    2839} 
    2940@end 
     41 
  • trunk/SapphireFrappliance/SapphireAppliance.m

    r461 r494  
    2828#import <SapphireCompatClasses/BackRowUtils.h> 
    2929 
     30// BRAppliance protocol 
     31@interface BRApplianceInfo 
     32+(id)infoForApplianceBundle:(id)bundle; 
     33-(id)applianceCategoryDescriptors; 
     34@end 
     35 
     36@interface BRApplianceCategory 
     37+(id)categoryWithName:(NSString *)name identifier:(NSString *)identifier preferredOrder:(float)order; 
     38-(void)setIsStoreCategory:(BOOL)isStoreCategory; 
     39-(void)setIsDefaultCategory:(BOOL)isDefaultCategory; 
     40-(void)setShouldDisplayOnStartup:(BOOL)shouldDisplayOnStartup; 
     41@end 
     42 
     43 
    3044@implementation SapphireAppliance 
    3145 
     
    3549        NSString *frameworkPath = [myBundlePath stringByAppendingPathComponent:@"Contents/Frameworks"]; 
    3650        SapphireLoadFramework(frameworkPath); 
    37     Class cls = NSClassFromString( @"BRFeatureManager" ); 
    38     if ( cls == Nil ) 
    39         return; 
    40          
    41     [[cls sharedInstance] enableFeatureNamed: [[NSBundle bundleForClass: self] bundleIdentifier]]; 
     51        Class cls = NSClassFromString( @"BRFeatureManager" ); 
     52        if ( cls == Nil ) 
     53                return; 
     54        [[cls sharedInstance] enableFeatureNamed: [[NSBundle bundleForClass: self] bundleIdentifier]]; 
    4255} 
    4356 
    4457+ (NSString *) className 
    4558{ 
    46         static BOOL checked = NO; 
    47     // get around the whitelist 
     59        // get around the whitelist 
     60        // this function will get the real class name from the runtime, and 
     61        // will assuredly not recurse back to here 
     62        NSString * className = NSStringFromClass( self ); 
    4863     
    49     // this function will get the real class name from the runtime, and 
    50     // will assuredly not recurse back to here 
    51     NSString * className = NSStringFromClass( self ); 
    52      
    53     // BackRow has its own exception class which provides backtrace 
    54     // helpers. It returns a parsed trace, with function names. We'll 
    55     // look for the name of the function which is known to call this 
    56     // function to check against the whitelist, and if we find it we'll 
    57     // lie about our name, purely to escape that check. 
    58     // Also, the backtracer method is a class routine, meaning that we 
    59     // don't have to even generate an exception - woohoo! 
     64        // BackRow has its own exception class which provides backtrace 
     65        // helpers. It returns a parsed trace, with function names. We'll 
     66        // look for the name of the function which is known to call this 
     67        // function to check against the whitelist, and if we find it we'll 
     68        // lie about our name, purely to escape that check. 
     69        // Also, the backtracer method is a class routine, meaning that we 
     70        // don't have to even generate an exception - woohoo! 
    6071        NSString *backtrace = [BRBacktracingException backtrace]; 
    61     NSRange range = [backtrace rangeOfString: @"_loadApplianceInfoAtPath:"]; 
    62         if (range.location == NSNotFound && !checked
     72       NSRange range = [backtrace rangeOfString: @"_loadApplianceInfoAtPath:"]; 
     73        if ( range.location != NSNotFound
    6374        { 
     75                // this is the whitelist check -- tell a Great Big Fib 
     76                className = @"RUIMoviesAppliance";     // could be anything in the whitelist, really 
     77        } 
     78        if (range.location == NSNotFound) 
     79        { 
     80                //code from ATVFiles. Thx! 
    6481                range = [backtrace rangeOfString: @"(in BackRow)"]; 
    65                 checked = YES; 
     82                if(range.location != NSNotFound) { 
     83                        NSLog(@"+[%@ className] called for Leopard/ATV2 whitelist check, so I'm lying, m'kay?", className); 
     84                        // 10.5/ATV2 (and 1.1, but that's handled above) 
     85                        className = @"RUIDVDAppliance"; 
     86                } 
    6687        } 
    67     if ( range.location != NSNotFound ) 
    68     { 
    69         // this is the whitelist check -- tell a Great Big Fib 
    70         className = @"RUIMoviesAppliance";     // could be anything in the whitelist, really 
    71     } 
    72      
    73     return ( className ); 
     88        return ( className ); 
     89
     90 
     91-(NSString *)applianceKey { 
     92        return @"SapphireAppliance"; 
     93
     94 
     95-(NSString *)applianceName { 
     96        return @"SapphireAppliance"; 
    7497} 
    7598 
    7699- (NSString *) moduleIconName 
    77100{ 
    78     // replace this with your own icon name 
    79     return ( @"SapphireIcon.png" ); 
     101       // replace this with your own icon name 
     102       return ( @"SapphireIcon.png" ); 
    80103} 
    81104 
    82105- (NSString *) moduleName 
    83106{ 
    84     // this doesn't appear to be actually *used*, but even so: 
    85     return ( BRLocalizedString(@"Sapphire", @"Main Menu item name") ); 
     107       // this doesn't appear to be actually *used*, but even so: 
     108       return ( BRLocalizedString(@"Sapphire", @"Main Menu item name") ); 
    86109} 
    87110 
    88111+ (NSString *) moduleKey 
    89112{ 
    90     // change this to match your CFBundleIdentifier 
    91     return ( @"Nanopi.net.UCIJoker.Sapphire" ); 
     113       // change this to match your CFBundleIdentifier 
     114       return ( @"Nanopi.net.UCIJoker.Sapphire" ); 
    92115} 
    93116 
    94117- (NSString *) moduleKey 
    95118{ 
    96     return ( [SapphireAppliance moduleKey] ); 
     119       return ( [SapphireAppliance moduleKey] ); 
    97120} 
    98121 
    99 - (BRLayerController *)applianceController 
     122- (id)applianceController 
    100123{ 
    101     return ( [[[SapphireApplianceController alloc] initWithScene: nil] autorelease] ); 
     124        NSLog(@"in -SapphireApplicance applianceController"); 
     125        return ( [[[SapphireApplianceController alloc] initWithScene: nil] autorelease] ); 
    102126} 
    103127 
    104 - (BRLayerController *) applianceControllerWithScene: (BRRenderScene *) scene 
     128- (id) applianceControllerWithScene: (id) scene 
    105129{ 
    106     // this function is called when your item is selected on the main menu 
    107     return ( [[[SapphireApplianceController alloc] initWithScene: scene] autorelease] ); 
     130        // this function is called when your item is selected on the main menu 
     131        return ( [[[SapphireApplianceController alloc] initWithScene: scene] autorelease] ); 
     132
     133 
     134/** 
     135 * This implements the BRAppliance protocol from ATV2. 
     136 */ 
     137-(id)applianceInfo { 
     138        NSLog(@"in -SapphireApplicance applianceInfo"); 
     139         
     140        BRApplianceInfo* p = [BRApplianceInfo infoForApplianceBundle:[NSBundle bundleForClass:[self class]]]; 
     141        NSMutableArray *categories = [NSMutableArray array]; 
     142         
     143        NSEnumerator *enumerator = [[p applianceCategoryDescriptors] objectEnumerator]; 
     144        id obj; 
     145        while((obj = [enumerator nextObject]) != nil) { 
     146                BRApplianceCategory *category = [BRApplianceCategory categoryWithName:[obj valueForKey:@"name"] identifier:[obj valueForKey:@"identifier"] preferredOrder:[[obj valueForKey:@"preferred-order"] floatValue]]; 
     147                [categories addObject:category]; 
     148                NSLog(@"asdsa"); 
     149        } 
     150        return [BRApplianceInfo infoForApplianceBundle:[NSBundle bundleForClass:[self class]]]; 
     151
     152 
     153-(id)applianceCategories { 
     154        NSLog(@"in -SapphireApplicance applianceCategories"); 
     155        NSMutableArray *categories = [NSMutableArray array]; 
     156         
     157        NSEnumerator *enumerator = [[[self applianceInfo] applianceCategoryDescriptors] objectEnumerator]; 
     158        id obj; 
     159        while((obj = [enumerator nextObject]) != nil) { 
     160                BRApplianceCategory *category = [BRApplianceCategory categoryWithName:[obj valueForKey:@"name"] identifier:[obj valueForKey:@"identifier"] preferredOrder:[[obj valueForKey:@"preferred-order"] floatValue]]; 
     161                [categories addObject:category]; 
     162        } 
     163        return categories; 
     164
     165 
     166-(id)identifierForContentAlias:(id)fp8 { 
     167        return @"Sapphire"; 
     168
     169 
     170-(id)controllerForIdentifier:(id)fp8 { 
     171        return [self applianceController]; 
     172
     173 
     174-(id)initWithSettings:(id)settings { 
     175        return [super init]; 
     176
     177 
     178-(id)version { 
     179        return @"1.0"; 
    108180} 
    109181