source: trunk/SapphireAppliance.m @ 261

Revision 261, 2.7 KB checked in by gbooker, 7 years ago (diff)

Get around the undefined initWithScene and scene selectors.

Line 
1//
2//  SapphireAppliance.m
3//  Sapphire
4//
5//  Created by pnmerrill on 6/20/07.
6//  Copyright 2007 www.nanopi.net. All rights reserved.
7//
8
9
10#import "SapphireAppliance.h"
11#import "SapphireApplianceController.h"
12#import <BackRow/BackRow.h>
13#import <objc/objc-class.h>
14
15#import "BackRowUtils.h"
16
17@implementation SapphireAppliance
18
19+ (void) initialize
20{
21    Class cls = NSClassFromString( @"BRFeatureManager" );
22    if ( cls == Nil )
23        return;
24       
25    [[cls sharedInstance] enableFeatureNamed: [[NSBundle bundleForClass: self] bundleIdentifier]];
26}
27
28+ (NSString *) className
29{
30        static BOOL checked = NO;
31    // get around the whitelist
32   
33    // this function will get the real class name from the runtime, and
34    // will assuredly not recurse back to here
35    NSString * className = NSStringFromClass( self );
36   
37    // BackRow has its own exception class which provides backtrace
38    // helpers. It returns a parsed trace, with function names. We'll
39    // look for the name of the function which is known to call this
40    // function to check against the whitelist, and if we find it we'll
41    // lie about our name, purely to escape that check.
42    // Also, the backtracer method is a class routine, meaning that we
43    // don't have to even generate an exception - woohoo!
44        NSString *backtrace = [BRBacktracingException backtrace];
45    NSRange range = [backtrace rangeOfString: @"_loadApplianceInfoAtPath:"];
46        if (range.location == NSNotFound && !checked)
47        {
48                range = [backtrace rangeOfString: @"(in BackRow)"];
49                checked = YES;
50        }
51    if ( range.location != NSNotFound )
52    {
53        // this is the whitelist check -- tell a Great Big Fib
54        BRLog( @"[%@ className] called for whitelist check; returning RUICalibrationAppliance instead",
55               className );
56        className = @"RUIMoviesAppliance";     // could be anything in the whitelist, really
57    }
58   
59    return ( className );
60}
61
62- (NSString *) moduleIconName
63{
64    // replace this with your own icon name
65    return ( @"SapphireIcon.png" );
66}
67
68- (NSString *) moduleName
69{
70    // this doesn't appear to be actually *used*, but even so:
71    return ( BRLocalizedString(@"Sapphire", @"Main Menu item name") );
72}
73
74+ (NSString *) moduleKey
75{
76    // change this to match your CFBundleIdentifier
77    return ( @"Nanopi.net.UCIJoker.Sapphire" );
78}
79
80- (NSString *) moduleKey
81{
82    return ( [SapphireAppliance moduleKey] );
83}
84
85- (BRLayerController *)applianceController
86{
87    return ( [[[SapphireApplianceController alloc] initWithScene: nil] autorelease] );
88}
89
90- (BRLayerController *) applianceControllerWithScene: (BRRenderScene *) scene
91{
92    // this function is called when your item is selected on the main menu
93    return ( [[[SapphireApplianceController alloc] initWithScene: nil] autorelease] );
94}
95
96@end
Note: See TracBrowser for help on using the repository browser.