Ticket #126: basic_atv2_changes.patch
| File basic_atv2_changes.patch, 9.2 kB (added by Stephan, 10 months ago) |
|---|
-
SapphireFrappliance/Info.plist
old new 25 25 <key>FRApplianceIconReflectionOffset</key> 26 26 <real>-0.20999999999999999</real> 27 27 <key>FRAppliancePreferedOrderValue</key> 28 <integer> -1</integer>28 <integer>2</integer> 29 29 <key>FRRemoteAppliance</key> 30 30 <true/> 31 31 <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> 33 53 </dict> 34 54 </plist> -
SapphireFrappliance/SapphireAppliance.m
old new 27 27 28 28 #import <SapphireCompatClasses/BackRowUtils.h> 29 29 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 30 44 @implementation SapphireAppliance 31 45 32 46 + (void) initialize … … 34 48 NSString *myBundlePath = [[NSBundle bundleForClass:[self class]] bundlePath]; 35 49 NSString *frameworkPath = [myBundlePath stringByAppendingPathComponent:@"Contents/Frameworks"]; 36 50 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]]; 42 55 } 43 56 44 57 + (NSString *) className 45 58 { 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 ); 48 63 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! 60 71 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 ) 63 74 { 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! 64 81 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 } 66 87 } 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 ); 74 89 } 75 90 91 -(NSString *)applianceKey { 92 return @"SapphireAppliance"; 93 } 94 95 -(NSString *)applianceName { 96 return @"SapphireAppliance"; 97 } 98 76 99 - (NSString *) moduleIconName 77 100 { 78 // replace this with your own icon name79 return ( @"SapphireIcon.png" );101 // replace this with your own icon name 102 return ( @"SapphireIcon.png" ); 80 103 } 81 104 82 105 - (NSString *) moduleName 83 106 { 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") ); 86 109 } 87 110 88 111 + (NSString *) moduleKey 89 112 { 90 // change this to match your CFBundleIdentifier91 return ( @"Nanopi.net.UCIJoker.Sapphire" );113 // change this to match your CFBundleIdentifier 114 return ( @"Nanopi.net.UCIJoker.Sapphire" ); 92 115 } 93 116 94 117 - (NSString *) moduleKey 95 118 { 96 return ( [SapphireAppliance moduleKey] );119 return ( [SapphireAppliance moduleKey] ); 97 120 } 98 121 99 - ( BRLayerController *)applianceController122 - (id)applianceController 100 123 { 101 return ( [[[SapphireApplianceController alloc] initWithScene: nil] autorelease] ); 124 NSLog(@"in -SapphireApplicance applianceController"); 125 return ( [[[SapphireApplianceController alloc] initWithScene: nil] autorelease] ); 102 126 } 103 127 104 - ( BRLayerController *) applianceControllerWithScene: (BRRenderScene *) scene128 - (id) applianceControllerWithScene: (id) scene 105 129 { 106 // this function is called when your item is selected on the main menu107 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] ); 108 132 } 109 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"; 180 } 181 110 182 @end -
SapphireFrappliance/SapphireAppliance.h
old new 23 23 * 24 24 * This class bypasses the whitelist check and sets up backrow to load and use the main controller. 25 25 */ 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 28 37 } 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; 29 49 @end 50
