Changeset 494
- Timestamp:
- 02/20/08 16:53:20 (9 months ago)
- Files:
-
- trunk/SapphireFrappliance/Info.plist (modified) (1 diff)
- trunk/SapphireFrappliance/Sapphire.xcodeproj/project.pbxproj (modified) (3 diffs)
- trunk/SapphireFrappliance/SapphireAppliance.h (modified) (1 diff)
- trunk/SapphireFrappliance/SapphireAppliance.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/SapphireFrappliance/Info.plist
r468 r494 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> trunk/SapphireFrappliance/Sapphire.xcodeproj/project.pbxproj
r466 r494 122 122 remoteGlobalIDString = F5003FF80D19980A003FEA08; 123 123 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; 124 131 }; 125 132 F5B418700D0B29DE00BDD361 /* PBXContainerItemProxy */ = { … … 579 586 F5EBE6DD0D4A775400042BA0 /* SapphireCompatClasses.framework */, 580 587 F5EBE6DF0D4A775400042BA0 /* SapphireLeopardCompatClasses.framework */, 588 F56895E10D6CE30D00F9D9B0 /* SapphireTakeTwoCompatClasses.framework */, 581 589 ); 582 590 name = Products; … … 683 691 684 692 /* 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 }; 685 700 F5EBE6DD0D4A775400042BA0 /* SapphireCompatClasses.framework */ = { 686 701 isa = PBXReferenceProxy; trunk/SapphireFrappliance/SapphireAppliance.h
r461 r494 20 20 21 21 /*! 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 /*! 22 34 * @brief The Main class 23 35 * 24 36 * This class bypasses the whitelist check and sets up backrow to load and use the main controller. 25 37 */ 26 @interface SapphireAppliance : BRAppliance 27 { 38 @interface SapphireAppliance : NSObject <BRAppliance, BRApplianceProtocol> { 28 39 } 29 40 @end 41 trunk/SapphireFrappliance/SapphireAppliance.m
r461 r494 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 … … 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 ); 89 } 90 91 -(NSString *)applianceKey { 92 return @"SapphireAppliance"; 93 } 94 95 -(NSString *)applianceName { 96 return @"SapphireAppliance"; 74 97 } 75 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 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"; 108 180 } 109 181
