Ticket #126: basic_atv2_changes.patch

File basic_atv2_changes.patch, 9.2 kB (added by Stephan, 10 months ago)

patch to enable Sapphire in ATV2 menu

  • SapphireFrappliance/Info.plist

    old new  
    2525        <key>FRApplianceIconReflectionOffset</key> 
    2626        <real>-0.20999999999999999</real> 
    2727        <key>FRAppliancePreferedOrderValue</key> 
    28         <integer>-1</integer> 
     28        <integer>2</integer> 
    2929        <key>FRRemoteAppliance</key> 
    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> 
  • SapphireFrappliance/SapphireAppliance.m

    old new  
    2727 
    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 
    3246+ (void) initialize 
     
    3448        NSString *myBundlePath = [[NSBundle bundleForClass:[self class]] bundlePath]; 
    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 ); 
    7489} 
    7590 
     91-(NSString *)applianceKey { 
     92        return @"SapphireAppliance"; 
     93} 
     94 
     95-(NSString *)applianceName { 
     96        return @"SapphireAppliance"; 
     97} 
     98 
    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] ); 
    108132} 
    109133 
     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"; 
     180} 
     181 
    110182@end 
  • SapphireFrappliance/SapphireAppliance.h

    old new  
    2323 * 
    2424 * This class bypasses the whitelist check and sets up backrow to load and use the main controller. 
    2525 */ 
    26 @interface SapphireAppliance : BRAppliance  
    27 
     26 
     27@protocol BRAppliance <NSObject> 
     28- (id)applianceInfo; 
     29- (id)applianceCategories; 
     30- (id)identifierForContentAlias:(id)fp8; 
     31- (id)controllerForIdentifier:(id)fp8; 
     32@end 
     33 
     34// this just makes the warnings shut up 
     35@interface SapphireAppliance : NSObject <BRAppliance, BRApplianceProtocol> { 
     36         
    2837} 
     38// BRApplianceProtocol protocol 
     39-(id)applianceController; 
     40-(id)applianceControllerWithScene:(id)scene; 
     41-(id)version; 
     42-(id)initWithSettings:(id)settings; 
     43 
     44// BRAppliance protocol 
     45-(id)applianceInfo; 
     46-(id)applianceCategories; 
     47-(id)identifierForContentAlias:(id)fp8; 
     48-(id)controllerForIdentifier:(id)fp8; 
    2949@end 
     50