Permalink
Browse files

- rewrite the XBMCAppliance and XBMCController for using obj-c runtim…

…e class definition and hooking. This is needed for supporting atv2 on ios6 (see the comments in the impl.)
  • Loading branch information...
1 parent 686f89f commit b89e04bfb7c967043a05631088311f711b171937 @Memphiz Memphiz committed with davilla Feb 20, 2013
@@ -894,7 +894,7 @@
F56C7B8A131EC155000AD0F6 /* ViewDatabase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C780C131EC154000AD0F6 /* ViewDatabase.cpp */; };
F56C7B8B131EC155000AD0F6 /* XBApplicationEx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F56C780E131EC154000AD0F6 /* XBApplicationEx.cpp */; };
F56C7B9B131EC1B4000AD0F6 /* AutoPool.mm in Sources */ = {isa = PBXBuildFile; fileRef = F56C7B9A131EC1B4000AD0F6 /* AutoPool.mm */; };
- F56C7BC9131EC2DB000AD0F6 /* XBMCAppliance.m in Sources */ = {isa = PBXBuildFile; fileRef = F56C7BC2131EC2DB000AD0F6 /* XBMCAppliance.m */; };
+ F56C7BC9131EC2DB000AD0F6 /* XBMCAppliance.mm in Sources */ = {isa = PBXBuildFile; fileRef = F56C7BC2131EC2DB000AD0F6 /* XBMCAppliance.mm */; };
F56C7BCA131EC2DB000AD0F6 /* XBMCController.mm in Sources */ = {isa = PBXBuildFile; fileRef = F56C7BC5131EC2DB000AD0F6 /* XBMCController.mm */; };
F56C7BD0131EC301000AD0F6 /* XBMC.png in Resources */ = {isa = PBXBuildFile; fileRef = F56C7BCD131EC301000AD0F6 /* XBMC.png */; };
F56C7BDC131EC390000AD0F6 /* WinEventsIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = F56C7BD9131EC390000AD0F6 /* WinEventsIOS.mm */; };
@@ -2967,7 +2967,7 @@
F56C780F131EC154000AD0F6 /* XBApplicationEx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBApplicationEx.h; sourceTree = "<group>"; };
F56C7B99131EC1B4000AD0F6 /* AutoPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AutoPool.h; sourceTree = "<group>"; };
F56C7B9A131EC1B4000AD0F6 /* AutoPool.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AutoPool.mm; sourceTree = "<group>"; };
- F56C7BC2131EC2DB000AD0F6 /* XBMCAppliance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XBMCAppliance.m; sourceTree = "<group>"; };
+ F56C7BC2131EC2DB000AD0F6 /* XBMCAppliance.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = XBMCAppliance.mm; sourceTree = "<group>"; };
F56C7BC3131EC2DB000AD0F6 /* XBMCAppliance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBMCAppliance.h; sourceTree = "<group>"; };
F56C7BC4131EC2DB000AD0F6 /* XBMCController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBMCController.h; sourceTree = "<group>"; };
F56C7BC5131EC2DB000AD0F6 /* XBMCController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = XBMCController.mm; sourceTree = "<group>"; };
@@ -5997,7 +5997,7 @@
F56C7F2D131F0BB4000AD0F6 /* English.lproj */,
F56C7BCD131EC301000AD0F6 /* XBMC.png */,
F56C7BC3131EC2DB000AD0F6 /* XBMCAppliance.h */,
- F56C7BC2131EC2DB000AD0F6 /* XBMCAppliance.m */,
+ F56C7BC2131EC2DB000AD0F6 /* XBMCAppliance.mm */,
F56C7BCE131EC301000AD0F6 /* XBMCATV2-Info.plist */,
F56C7BC4131EC2DB000AD0F6 /* XBMCController.h */,
F56C7BC5131EC2DB000AD0F6 /* XBMCController.mm */,
@@ -7309,7 +7309,7 @@
F56C7B8A131EC155000AD0F6 /* ViewDatabase.cpp in Sources */,
F56C7B8B131EC155000AD0F6 /* XBApplicationEx.cpp in Sources */,
F56C7B9B131EC1B4000AD0F6 /* AutoPool.mm in Sources */,
- F56C7BC9131EC2DB000AD0F6 /* XBMCAppliance.m in Sources */,
+ F56C7BC9131EC2DB000AD0F6 /* XBMCAppliance.mm in Sources */,
F56C7BCA131EC2DB000AD0F6 /* XBMCController.mm in Sources */,
F56C7BDC131EC390000AD0F6 /* WinEventsIOS.mm in Sources */,
F56C7BDD131EC390000AD0F6 /* WinSystemIOS.mm in Sources */,
@@ -28,4 +28,10 @@
XBMCTopShelfController *_topShelfController;
}
@property(nonatomic, readonly, retain) id topShelfController;
+
+- (id) initWithApplianceInfo:(id) applianceInfo;
+- (void) setTopShelfController:(id) topShelfControl;
+- (void) setApplianceCategories:(id) applianceCategories;
+- (void) XBMCfixUIDevice;
+- (id) init;
@end
@@ -1,218 +0,0 @@
-/*
- * Copyright (C) 2010-2012 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, see
- * <http://www.gnu.org/licenses/>.
- *
- */
-
-#import <Foundation/Foundation.h>
-#import <UIKit/UIKit.h>
-#import <BackRow/BackRow.h>
-// objc-runtime.h is missing from iPhoneOS4.2SDK but present in iPhoneSimulator4.2.sdk
-// pull it from runtime system for now
-#import "/usr/include/objc/objc-runtime.h"
-
-#import "XBMCAppliance.h"
-#import "XBMCController.h"
-
-#define XBMCAppliance_CAT [BRApplianceCategory categoryWithName:@"XBMC" identifier:@"xbmc" preferredOrder:-5]
-
-// ATVVersionInfo declare to shut up compiler warning
-@interface ATVVersionInfo : NSObject
-{
-}
-+ (id)currentOSVersion;
-@end
-//--------------------------------------------------------------
-//--------------------------------------------------------------
-@interface BRTopShelfView (specialAdditions)
-//
-- (BRImageControl *)productImage;
-
-@end
-
-@implementation BRTopShelfView (specialAdditions)
-- (BRImageControl *)productImage
-{
- Ivar ivar = object_getInstanceVariable(self, "_productImage", NULL);
- id result = object_getIvar(self, ivar);
- return result;
-}
-@end
-
-//--------------------------------------------------------------
-//--------------------------------------------------------------
-@interface XBMCTopShelfController : NSObject
-{
-}
-- (void) selectCategoryWithIdentifier:(id)identifier;
-- (id) topShelfView;
-// added in 4.1+
-- (void) refresh;
-@end
-
-@implementation XBMCTopShelfController
-//
-- (void) selectCategoryWithIdentifier:(id)identifier
-{
-}
-
-- (BRTopShelfView *)topShelfView {
- BRTopShelfView *topShelf = [[BRTopShelfView alloc] init];
- BRImageControl *imageControl = [topShelf productImage];
- BRImage *gpImage = [BRImage imageWithPath:[[NSBundle bundleForClass:[XBMCAppliance class]] pathForResource:@"XBMC" ofType:@"png"]];
- [imageControl setImage:gpImage];
-
- return topShelf;
-}
-- (void) refresh
-{
-}
-@end
-
-//--------------------------------------------------------------
-//--------------------------------------------------------------
-@implementation XBMCAppliance
-@synthesize topShelfController=_topShelfController;
-
--(void)XBMCfixUIDevice
-{
- // iOS 5.x has removed the internal load of UIKit in AppleTV app
- // and there is an overlap of some UIKit and AppleTV methods.
- // This voodoo seems to clear up the wonkiness. :)
- Class cls = NSClassFromString(@"ATVVersionInfo");
- if (cls != nil && [[cls currentOSVersion] rangeOfString:@"5."].location != NSNotFound)
- {
- id cd = nil;
-
- @try
- {
- cd = [UIDevice currentDevice];
- }
-
- @catch (NSException *e)
- {
- NSLog(@"exception: %@", e);
- }
-
- @finally
- {
- //NSLog(@"will it work the second try?");
- cd = [UIDevice currentDevice];
- NSLog(@"current device fixed: %@", cd);
- }
- }
-}
-
--(id) init
-{
- //NSLog(@"%s", __PRETTY_FUNCTION__);
-
- if ((self = [super init]) != nil)
- {
- _topShelfController = [[XBMCTopShelfController alloc] init];
- _applianceCategories = [[NSArray alloc] initWithObjects:XBMCAppliance_CAT ,nil];
- }
-
- return self;
-}
-
-- (void) dealloc
-{
- //NSLog(@"%s", __PRETTY_FUNCTION__);
-
- [_applianceCategories release];
- [_topShelfController release];
-
- [super dealloc];
-}
-
-- (id) applianceCategories
-{
- // on ios 5.x this gets called whenever a user hits the xbmc icon
- // in the frontrow mainmenu
- // we use this indication for faking the "select" key.
- // This leads to a one click start of XBMC instead of needing
- // to hit select on the only XBMC category called "XBMC" again ;)
- Class cls = NSClassFromString(@"ATVVersionInfo");
- if (cls != nil && [[cls currentOSVersion] rangeOfString:@"5."].location != NSNotFound)
- {
- // eventaction 5 == kBREventRemoteActionPlay from XBMCController.m
- // value == 1 meanse we pressed that key
- BREvent *eventKeySelect = [BREvent eventWithAction:5 value:1];
- // when we suppress the sound below
- // this will even suppress the initial click
- // sound because this is threaded
- // thats why we just play that first click sound
- // directly here before suppressing the sounds
- // and doing the fake click (which would result in an unwanted
- // second click sound without that hack)
- [BRSoundHandler playSound:1];// sound number 1 is the ios click sound
- // ios >= 5 only - so ignore the compiler warning on older SDKs
- // since we guarded that code with the currentOSVersion above
- [BRSoundHandler setSoundSuppressed:TRUE];
- [[BRApplication sharedApplication] postEvent:eventKeySelect];
- }
-
- return _applianceCategories;
-}
-
-- (id) identifierForContentAlias:(id)contentAlias
-{
- return @"xbmc";
-}
-
-- (id) selectCategoryWithIdentifier:(id)ident
-{
- //NSLog(@"eglv2:selecteCategoryWithIdentifier: %@", ident);
-
- return nil;
-}
-- (BOOL) handleObjectSelection:(id)fp8 userInfo:(id)fp12
-{
- //NSLog(@"%s", __PRETTY_FUNCTION__);
-
- return YES;
-}
-
-- (id) applianceSpecificControllerForIdentifier:(id)arg1 args:(id)arg2
-{
- return nil;
-}
-- (BOOL) handlePlay:(id)play userInfo:(id)info
-{
- //NSLog(@"%s", __PRETTY_FUNCTION__);
-
- return YES;
-}
-
-- (id) controllerForIdentifier:(id)identifier args:(id)args
-{
- //NSLog(@"%s", __PRETTY_FUNCTION__);
-
- [self XBMCfixUIDevice];
- XBMCController *controller = [[[XBMCController alloc] init] autorelease];
- //XBMCController *controller = [XBMCController sharedInstance];
- return controller;
-}
-
-- (id) localizedSearchTitle { return @"xbmc"; }
-- (id) applianceName { return @"xbmc"; }
-- (id) moduleName { return @"xbmc"; }
-- (id) applianceKey { return @"xbmc"; }
-
-@end
-
Oops, something went wrong.

0 comments on commit b89e04b

Please sign in to comment.