Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

first commit

  • Loading branch information...
commit e5c326fbcf24b1b47676bd59ec7ff7aff2092869 0 parents
@tomcool420 authored
Showing with 13,083 additions and 0 deletions.
  1. +16 −0 BRMenuItem_SMF.h
  2. BIN  Classes/.DS_Store
  3. +11 −0 Classes/BackRowExtras.h
  4. +28 −0 Makefile
  5. +73 −0 NSTask.h
  6. BIN  Resources/.DS_Store
  7. +8 −0 Resources/English.lproj/InfoPlist.strings
  8. +39 −0 Resources/Info.plist
  9. BIN  Resources/selsettings.png
  10. +25 −0 SMFBaseAsset.h
  11. +99 −0 SMFBaseAsset.m
  12. +38 −0 SMFCenteredMenuController.h
  13. +148 −0 SMFCenteredMenuController.m
  14. +25 −0 SMFClockController.h
  15. +101 −0 SMFClockController.m
  16. +16 −0 SMFCommonTools.h
  17. +18 −0 SMFCommonTools.m
  18. +56 −0 SMFController.h
  19. +115 −0 SMFController.m
  20. +32 −0 SMFDefines.h
  21. +18 −0 SMFEvent.h
  22. +22 −0 SMFEvent.m
  23. +33 −0 SMFEventConfiguration.h
  24. +144 −0 SMFEventConfiguration.m
  25. +57 −0 SMFEventManager.h
  26. +279 −0 SMFEventManager.m
  27. +41 −0 SMFFolderBrowser.h
  28. +264 −0 SMFFolderBrowser.m
  29. +16 −0 SMFFolderDelegate.h
  30. +14 −0 SMFFolderDelegate.m
  31. +18 −0 SMFInvocationCenteredMenuController.h
  32. +67 −0 SMFInvocationCenteredMenuController.m
  33. +37 −0 SMFMediaMenuController.h
  34. +142 −0 SMFMediaMenuController.m
  35. +38 −0 SMFMediaPreview.h
  36. +246 −0 SMFMediaPreview.mm
  37. +37 −0 SMFMenuController.h
  38. +136 −0 SMFMenuController.m
  39. +26 −0 SMFMenuItem.h
  40. +75 −0 SMFMenuItem.m
  41. +71 −0 SMFPasscodeController.h
  42. +289 −0 SMFPasscodeController.m
  43. +49 −0 SMFPhotoMethods.h
  44. +269 −0 SMFPhotoMethods.mm
  45. +16 −0 SMFPhotos.h
  46. +14 −0 SMFPhotos.m
  47. +27 −0 SMFQueryMenu.h
  48. +122 −0 SMFQueryMenu.m
  49. +21 −0 SMFScreenCapture.h
  50. +130 −0 SMFScreenCapture.m
  51. +16 −0 SMFTask.h
  52. +18 −0 SMFTask.m
  53. +16 −0 SMFThemeInfo.h
  54. +18 −0 SMFThemeInfo.m
  55. +21 −0 SMFramework.h
  56. +550 −0 SMFramework.xcodeproj/blunt.pbxuser
  57. +1,720 −0 SMFramework.xcodeproj/blunt.perspectivev3
  58. +520 −0 SMFramework.xcodeproj/project.pbxproj
  59. +1,486 −0 SMFramework.xcodeproj/tomcool.mode1v3
  60. +4,960 −0 SMFramework.xcodeproj/tomcool.pbxuser
  61. +68 −0 SynthesizeSingleton.h
  62. +8 −0 control
  63. BIN  eventcatcher/.DS_Store
  64. 0  eventcatcher/.debmake/fakeroot
  65. +1 −0  eventcatcher/.theos/packages/org.tomcool.eventcatcher-0.0.1
  66. +1 −0  eventcatcher/EventCatcher.plist
  67. +12 −0 eventcatcher/Makefile
  68. +92 −0 eventcatcher/Tweak.xm
  69. +9 −0 eventcatcher/control
  70. 0  eventcatcher/obj/.stamp
  71. BIN  eventcatcher/obj/EventCatcher.dylib
  72. BIN  eventcatcher/obj/Tweak.xm.o
  73. +1 −0  eventcatcher/theos
16 BRMenuItem_SMF.h
@@ -0,0 +1,16 @@
+//
+// BRMenuItem.h
+// SMFramework
+//
+// Created by Thomas Cool on 10/24/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+
+
+
+@interface BRMenuItem (SMFExtensions)
++(BRMenuItem *)smfFolderMenuItem;
++(BRMenuItem *)smfMenuItem;
+-(void)setTitle:(NSString *)title;
+@end
BIN  Classes/.DS_Store
Binary file not shown
11 Classes/BackRowExtras.h
@@ -0,0 +1,11 @@
+
+
+#import <objc/runtime.h>
+
+
+template <typename Type_>
+static inline Type_ &MSHookIvar(id self, const char *name) {
+ Ivar ivar(class_getInstanceVariable(object_getClass(self), name));
+ void *pointer(ivar == NULL ? NULL : reinterpret_cast<char *>(self) + ivar_getOffset(ivar));
+ return *reinterpret_cast<Type_ *>(pointer);
+}
28 Makefile
@@ -0,0 +1,28 @@
+GO_EASY_ON_ME=1
+FW_DEVICE_IP=10.0.1.5
+first: clean package install
+include theos/makefiles/common.mk
+
+FRAMEWORK_NAME = SMFramework
+SMFramework_FILES = SMFMediaMenuController.m SMFCenteredMenuController.m SMFFolderBrowser.m SMFMediaPreview.mm SMFBaseAsset.m SMFPasscodeController.m SMFMenuController.m
+SMFramework_FILES += BRMenuItem_SMF.m SMFInvocationCenteredMenuController.m SMFMenuItem.m SMFScreenCapture.m SMFThemeInfo.m SMFClockController.m
+SMFramework_FILES += SMFEventManager.m SMFEvent.m SMFEventConfiguration.m
+SMFramework_FILES += SMFPhotoMethods.mm SMFQueryMenu.m
+SMFramework_INSTALL_PATH = /Library/Frameworks
+#SMFramework_BUNDLE_EXTENSION = framework
+SMFramework_LDFLAGS = -undefined dynamic_lookup -framework UIKit -framework ImageIO#-L$(FW_PROJECT_DIR) -lBackRow
+SUBPROJECTS = eventcatcher
+
+
+
+include $(FW_MAKEDIR)/framework.mk
+include $(FW_MAKEDIR)/aggregate.mk
+after-install::
+ ssh root@$(FW_DEVICE_IP) killall Lowtide
+
+after-SMFramework-stage::
+ rm -rf "Headers"
+ mkdir "Headers"
+ cp *.h "Headers/"
+ mkdir "$(FW_SHARED_BUNDLE_RESOURCE_PATH)/Headers"
+ cp *.h "$(FW_SHARED_BUNDLE_RESOURCE_PATH)/Headers/"
73 NSTask.h
@@ -0,0 +1,73 @@
+/* NSTask.h
+ Copyright (c) 1996-2007, Apple Inc. All rights reserved.
+*/
+
+#import <Foundation/NSObject.h>
+
+@class NSString, NSArray, NSDictionary;
+
+@interface NSTask : NSObject
+
+// Create an NSTask which can be run at a later time
+// An NSTask can only be run once. Subsequent attempts to
+// run an NSTask will raise.
+// Upon task death a notification will be sent
+// { Name = NSTaskDidTerminateNotification; object = task; }
+//
+
+- (id)init;
+
+// set parameters
+// these methods can only be done before a launch
+- (void)setLaunchPath:(NSString *)path;
+- (void)setArguments:(NSArray *)arguments;
+- (void)setEnvironment:(NSDictionary *)dict;
+ // if not set, use current
+- (void)setCurrentDirectoryPath:(NSString *)path;
+ // if not set, use current
+
+// set standard I/O channels; may be either an NSFileHandle or an NSPipe
+- (void)setStandardInput:(id)input;
+- (void)setStandardOutput:(id)output;
+- (void)setStandardError:(id)error;
+
+// get parameters
+- (NSString *)launchPath;
+- (NSArray *)arguments;
+- (NSDictionary *)environment;
+- (NSString *)currentDirectoryPath;
+
+// get standard I/O channels; could be either an NSFileHandle or an NSPipe
+- (id)standardInput;
+- (id)standardOutput;
+- (id)standardError;
+
+// actions
+- (void)launch;
+
+- (void)interrupt; // Not always possible. Sends SIGINT.
+- (void)terminate; // Not always possible. Sends SIGTERM.
+
+- (BOOL)suspend;
+- (BOOL)resume;
+
+// status
+- (int)processIdentifier;
+- (BOOL)isRunning;
+
+- (int)terminationStatus;
+
+@end
+
+@interface NSTask (NSTaskConveniences)
+
++ (NSTask *)launchedTaskWithLaunchPath:(NSString *)path arguments:(NSArray *)arguments;
+ // convenience; create and launch
+
+- (void)waitUntilExit;
+ // poll the runLoop in defaultMode until task completes
+
+@end
+
+FOUNDATION_EXPORT NSString * const NSTaskDidTerminateNotification;
+
BIN  Resources/.DS_Store
Binary file not shown
8 Resources/English.lproj/InfoPlist.strings
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleName</key>
+ <string>Hello World</string>
+</dict>
+</plist>
39 Resources/Info.plist
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>DTXcode</key>
+ <string>0324</string>
+ <key>FRApplianceDataSourceType</key>
+ <string>All</string>
+ <key>UIDeviceFamily</key>
+ <array>
+ <integer>3</integer>
+ <integer>2</integer>
+ </array>
+ <key>CFBundleExecutable</key>
+ <string>SMFramework</string>
+ <key>CFBundleIdentifier</key>
+ <string>org.tomcool.smframework</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundlePackageType</key>
+ <string>BNDL</string>
+ <key>CFBundleSignature</key>
+ <string>fnrw</string>
+ <key>CFBundleSupportedPlatforms</key>
+ <array>
+ <string>iPhoneOS</string>
+ </array>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>DTPlatformName</key>
+ <string>iphoneos</string>
+ <key>DTSDKName</key>
+ <string>iphoneos4.1</string>
+ <key>LSRequiresIPhoneOS</key>
+ <string>1</string>
+ <key>MinimumOSVersion</key>
+ <string>3.0</string>
+</dict>
+</plist>
BIN  Resources/selsettings.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 SMFBaseAsset.h
@@ -0,0 +1,25 @@
+//
+// SMFBaseAsset.h
+// SoftwareMenuFramework
+//
+// Created by Thomas Cool on 2/4/10.
+// Copyright 2010 Thomas Cool. All rights reserved.
+//
+
+
+
+
+@interface SMFBaseAsset : BRXMLMediaAsset {
+ int padding[64];
+ NSMutableDictionary *_meta;
+ BRImage *_image;
+}
+
+-(void)setObject:(id)arg1 forKey:(id)arg2;
+-(void)setTitle:(NSString *)title;
+-(void)setSummary:(NSString *)summary;
+-(void)setCustomKeys:(NSArray *)keys forObjects:(NSArray *)objects;
+-(void)setCoverArt:(BRImage *)coverArt;
+-(void)setCoverArtPath:(NSString *)path;
+-(NSDictionary *)orderedDictionary;
+@end
99 SMFBaseAsset.m
@@ -0,0 +1,99 @@
+//
+// SMFBaseAsset.m
+// SoftwareMenuFramework
+//
+// Created by Thomas Cool on 2/4/10.
+// Copyright 2010 Thomas Cool. All rights reserved.
+//
+
+#import "SMFBaseAsset.h"
+#import "SMFMediaPreview.h"
+
+
+@implementation SMFBaseAsset
+-(id)init
+{
+ self=[super init];
+ _meta=[[NSMutableDictionary alloc]init];
+ _image=[[BRThemeInfo sharedTheme]appleTVIcon];
+ [_image retain];
+ return self;
+}
+-(void)setObject:(id)arg1 forKey:(id)arg2
+{
+ [_meta setObject:arg1 forKey:arg2];
+}
+-(void)setTitle:(NSString *)title
+{
+ [_meta setObject:title forKey:METADATA_TITLE];
+}
+-(void)setSummary:(NSString *)summary
+{
+ [_meta setObject:summary forKey:METADATA_SUMMARY];
+}
+-(void)setCustomKeys:(NSArray *)keys forObjects:(NSArray *)objects
+{
+ if([keys count]==[objects count])
+ {
+ [_meta setObject:keys forKey:METADATA_CUSTOM_KEYS];
+ [_meta setObject:objects forKey:METADATA_CUSTOM_OBJECTS];
+ }
+}
+-(BRImage *)coverArt
+{
+ return _image;
+}
+-(void)setCoverArt:(BRImage *)coverArt
+{
+ //[_image release];
+ _image=[coverArt retain];
+}
+-(void)setCoverArtPath:(NSString *)path
+{
+ if ([[NSFileManager defaultManager] fileExistsAtPath:path]) {
+ [_image release];
+ _image=[[BRImage imageWithPath:path] retain];
+ }
+
+}
+-(NSDictionary *)orderedDictionary
+{
+ NSMutableDictionary *a=[[NSMutableDictionary alloc] init];
+ if([_meta objectForKey:METADATA_TITLE]!=nil)
+ [a setObject:[_meta objectForKey:METADATA_TITLE] forKey:METADATA_TITLE];
+ if([_meta objectForKey:METADATA_SUMMARY]!=nil)
+ [a setObject:[_meta objectForKey:METADATA_SUMMARY] forKey:METADATA_SUMMARY];
+ if ([_meta objectForKey:METADATA_CUSTOM_KEYS]!=nil && [_meta objectForKey:METADATA_CUSTOM_OBJECTS]!=nil) {
+ [a setObject:[_meta objectForKey:METADATA_CUSTOM_KEYS] forKey:METADATA_CUSTOM_KEYS];
+ [a setObject:[_meta objectForKey:METADATA_CUSTOM_OBJECTS] forKey:METADATA_CUSTOM_OBJECTS];
+
+ }
+ return [a autorelease];
+}
+- (id)mediaType
+{
+ return [BRMediaType movie];
+}
+-(id)assetID
+{
+ return @"BaseAsset";
+}
+-(id)title
+{
+ return [_meta objectForKey:METADATA_TITLE];
+}
+-(id)summary
+{
+ return [_meta objectForKey:METADATA_SUMMARY];
+}
+- (BOOL)hasCoverArt
+{
+ return YES;
+}
+- (void)dealloc
+{
+ [_image release];
+ [_meta release];
+ [super dealloc];
+}
+@end
38 SMFCenteredMenuController.h
@@ -0,0 +1,38 @@
+//
+// SMFCenteredMediaMenuController.h
+// SoftwareMenuFramework
+//
+// Created by Thomas Cool on 2/25/10.
+// Copyright 2010 Thomas Cool. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+//#import "SMFMediaMenuController.h"
+#import "SMFDefines.h"
+@class SMFMediaMenuController;
+@interface SMFCenteredMenuController : BRMenuController {
+ int padding[128];
+ NSMutableArray * _items;
+ NSMutableArray * _options;
+}
+-(float)heightForRow:(long)row;
+-(BOOL)rowSelectable:(long)row;
+-(long)itemCount;
+-(id)itemForRow:(long)row;
+-(long)rowForTitle:(id)title;
+-(id)titleForRow:(long)row;
+-(int)getSelection;
+- (void)setSelection:(int)sel;
+-(id)everyLoad;
+/*
+ * Action Called Every Time someone Presses on Left Arrow
+ */
+-(void)leftActionForRow:(long)row;
+
+/*
+ * Action Called Every Time someone Presses on Right Arrow
+ */
+-(void)rightActionForRow:(long)row;
+
+
+@end
148 SMFCenteredMenuController.m
@@ -0,0 +1,148 @@
+//
+// SMFCenteredMediaMenuController.m
+// SoftwareMenuFramework
+//
+// Created by Thomas Cool on 2/25/10.
+// Copyright 2010 Thomas Cool. All rights reserved.
+//
+
+#import "SMFCenteredMenuController.h"
+
+@implementation SMFCenteredMenuController
+- (float)heightForRow:(long)row { return 0.0f;}
+- (BOOL)rowSelectable:(long)row { return YES;}
+- (long)itemCount { return (long)[_items count];}
+- (id)itemForRow:(long)row { return [_items objectAtIndex:row];}
+- (long)rowForTitle:(id)title { return (long)[_items indexOfObject:title];}
+- (id)titleForRow:(long)row
+{
+ return [[_items objectAtIndex:row] text];
+}
+- (long)defaultIndex { return 0;}
+//- (id)previewControlForItem:(long)row
+//{
+//// BRImage * image = [[BRThemeInfo sharedTheme] appleTVIcon];
+//// BRImageAndSyncingPreviewController *preview = [[BRImageAndSyncingPreviewController alloc] init];
+//// [preview setImage:image];
+//// return preview;
+// return nil;
+//}
+- (id)init
+{
+ self=[super init];
+ _items = [[NSMutableArray alloc]init];
+ _options = [[NSMutableArray alloc] init];
+ [[self list] setDatasource:self];
+ [self setUseCenteredLayout:YES];
+ [self setMenuWidthFactor:2.0];
+ return self;
+}
+- (void)dealloc
+{
+ [_items release];
+ [_options release];
+ [super dealloc];
+}
+-(id)everyLoad
+{
+ return self;
+}
+-(int)getSelection
+{
+ BRListControl *list = [self list];
+ int row;
+ NSMethodSignature *signature = [list methodSignatureForSelector:@selector(selection)];
+ NSInvocation *selInv = [NSInvocation invocationWithMethodSignature:signature];
+ [selInv setSelector:@selector(selection)];
+ [selInv invokeWithTarget:list];
+ if([signature methodReturnLength] == 8)
+ {
+ double retDoub = 0;
+ [selInv getReturnValue:&retDoub];
+ row = retDoub;
+ }
+ else
+ [selInv getReturnValue:&row];
+ return row;
+}
+-(void)controlWasActivated
+{
+ if([self respondsToSelector:@selector(everyLoad)])
+ [self everyLoad];
+ [super controlWasActivated];
+}
+- (void)wasExhumedByPoppingController:(id)fp8 {[self wasExhumed];}
+-(void)wasExhumed {[[self list] reload];}
+//-(id)init
+//{
+// self=[super init];
+// [self setUseCenteredLayout:YES];
+// return self;
+//}
+-(void)leftActionForRow:(long)row
+{
+
+}
+-(void)rightActionForRow:(long)row
+{
+ [self leftActionForRow:row];
+}
+-(BOOL)brEventAction:(BREvent *)event
+{
+ int remoteAction = [event remoteAction];
+ if ([(BRControllerStack *)[self stack] peekController] != self)
+ remoteAction = 0;
+
+ int itemCount = [[(BRListControl *)[self list] datasource] itemCount];
+ switch (remoteAction)
+ {
+ case kBREventRemoteActionSwipeLeft:
+ case kBREventRemoteActionLeft:
+ if([event value] == 1)
+ [self leftActionForRow:[self getSelection]];
+ return YES;
+ break;
+ case kBREventRemoteActionSwipeRight:
+ case kBREventRemoteActionRight:
+ if([event value] == 1)
+ [self rightActionForRow:[self getSelection]];
+ return YES;
+ break;
+ case kBREventRemoteActionUp:
+ case kBREventRemoteActionHoldUp:
+ if([self getSelection] == 0 && [event value] == 1)
+ {
+ [self setSelection:itemCount-1];
+ return YES;
+ }
+ break;
+ case kBREventRemoteActionDown:
+ case kBREventRemoteActionHoldDown:
+ if([self getSelection] == itemCount-1 && [event value] == 1)
+ {
+ [self setSelection:0];
+ return YES;
+ }
+ break;
+ }
+ return [super brEventAction:event];
+}
+- (void)setSelection:(int)sel
+{
+ BRListControl *list = [self list];
+ NSMethodSignature *signature = [list methodSignatureForSelector:@selector(setSelection:)];
+ NSInvocation *selInv = [NSInvocation invocationWithMethodSignature:signature];
+ [selInv setSelector:@selector(setSelection:)];
+ if(strcmp([signature getArgumentTypeAtIndex:2], "l"))
+ {
+ double dvalue = sel;
+ [selInv setArgument:&dvalue atIndex:2];
+ }
+ else
+ {
+ long lvalue = sel;
+ [selInv setArgument:&lvalue atIndex:2];
+ }
+ [selInv invokeWithTarget:list];
+}
+@end
25 SMFClockController.h
@@ -0,0 +1,25 @@
+//
+// SMFClockController.h
+// SMFramework
+//
+// Created by Thomas Cool on 10/31/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+
+
+
+@interface SMFClockController : BRTextControl {
+ NSTimer *_timer;
+ NSDateFormatter *_formatter;
+ NSDictionary *textAttributes;
+ NSTimeZone *timeZone;
+ NSLocale *_currentlocale;
+}
+-(void)timerRun;
+-(NSLocale *)currentlocale;
+-(void)setCurrentlocale:(NSLocale *)l;
+-(void)setTimeZone:(NSTimeZone*)tz;
+-(NSTimeZone *)timeZone;
+@property (retain) NSDictionary *textAttributes;
+@end
101 SMFClockController.m
@@ -0,0 +1,101 @@
+//
+// SMFClockController.m
+// SMFramework
+//
+// Created by Thomas Cool on 10/31/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import "SMFClockController.h"
+
+
+@implementation SMFClockController
+@synthesize textAttributes;
+-(id)init
+{
+ self=[super init];
+ _timer = [[NSTimer scheduledTimerWithTimeInterval:5
+ target:self
+ selector:@selector(timerRun)
+ userInfo:nil
+ repeats:YES] retain];
+
+ _formatter = [[NSDateFormatter alloc]init];
+
+ [_formatter setTimeStyle:NSDateFormatterShortStyle];
+ [_formatter setDateStyle:NSDateFormatterShortStyle];
+ [self setTextAttributes:[[BRThemeInfo sharedTheme] menuItemTextAttributes]];
+ [self setText:[_formatter stringFromDate:[NSDate date]]
+ withAttributes:[[BRThemeInfo sharedTheme]menuTitleTextAttributes]];
+
+ [self setTimeZone:[NSTimeZone timeZoneWithName:@"America/Chicago"]];
+ [self setCurrentlocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]];
+ return self;
+}
+-(void)setCurrentlocale:(NSLocale *)l
+{
+ [_currentlocale release];
+ _currentlocale=nil;
+ _currentlocale = [l retain];
+ [_formatter setLocale:l];
+}
+-(NSLocale *)currentlocale
+{
+ return _currentlocale;
+}
+-(void)setTimeZone:(NSTimeZone *)tz
+{
+ [timeZone release];
+ timeZone=nil;
+ timeZone=[tz retain];
+ [_formatter setTimeZone:timeZone];
+}
+-(NSTimeZone *)timeZone
+{
+ return timeZone;
+}
+-(void)timerRun
+{
+ BRController *tc= [[[BRApplicationStackManager singleton] stack] peekController];
+ BOOL done=FALSE;
+
+ BRControl *c=self;
+ while (done == FALSE) {
+ c=[c parent];
+ if ([c isKindOfClass:[BRController class]]) {
+ done = TRUE;
+ }
+ if (c==nil) {
+ done = TRUE;
+ }
+
+ }
+ if (c!=nil)
+ {
+
+ if (tc==c) {
+ [self setText:[_formatter stringFromDate:[NSDate date]]
+ withAttributes:[[BRThemeInfo sharedTheme]menuTitleTextAttributes]];
+ }
+
+ // NSLog(@"timer run: %@ %@,parent: %@ %@ %@",self,[NSDate date],c,[self parent],tc);
+ }
+
+
+}
+-(CGSize)renderedSize
+{
+ CGSize s = [super renderedSize];
+ s.width=s.width*1.2;
+ return s;
+
+}
+-(void)dealloc
+{
+ [_timer invalidate];
+ [_timer release];
+ _timer = nil;
+ [_formatter release];
+ [super dealloc];
+}
+@end
16 SMFCommonTools.h
@@ -0,0 +1,16 @@
+//
+// SMFCommonTools.h
+// SMFramework
+//
+// Created by Thomas Cool on 11/4/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface SMFCommonTools : NSObject {
+
+}
++(SMFCommonTools *)sharedManager
+@end
18 SMFCommonTools.m
@@ -0,0 +1,18 @@
+//
+// SMFCommonTools.m
+// SMFramework
+//
+// Created by Thomas Cool on 11/4/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import "SMFCommonTools.h"
+
+
+@implementation SMFCommonTools
+SYNTHESIZE_SINGLETON_FOR_CLASS(SMFCommonTools,sharedManager)
+-(void)restartLowtide
+{
+
+}
+@end
56 SMFController.h
@@ -0,0 +1,56 @@
+//
+// SMController.h
+// SoftwareMenuFramework
+//
+// Created by Thomas Cool on 11/30/09.
+// Copyright 2009 Thomas Cool. All rights reserved.
+//
+@interface BRController (Compat)
+
+-(CGRect)frame;
+
+@end
+
+
+
+@interface SMFController : BRController {
+ int padding[128];
+ int m_screen_saver_timeout;
+ NSString * _title;
+ BRHeaderControl * _headerControl;
+ BRWaitSpinnerControl * _spinner;
+ BRImage * _image;
+ BRImageControl * _imageControl;
+}
+/*
+ * Used to disable the screen
+ */
+- (void) disableScreenSaver;
+- (void) enableScreenSaver;
+/*
+ * getMasterFrame returns the Controller frame actually used to add the controls to.
+ */
+- (CGRect)getMasterFrame;
+/*
+ * The following two are simply to adjust the screen size for 1080i as TV
+ * seems to return strange values for that size. They should be used at same time
+ * as getMasterFrame
+ */
+- (BOOL)is1080i;
+- (CGSize)sizeFor1080i;
+/*
+ *Method to overwrite when subclassing. THis is where all the drawing calls are made
+ */
+- (void)drawSelf;
+@end
+@interface SMFController (layout)
+/*
+ * The Following three methods provide examples of layouts and how to set them up
+ * You would simply call them from the draw self in the following way:
+ * [self layoutSpinner]
+ */
+-(void)layoutSpinner;
+-(void)layoutHeader;
+-(void)layoutImage;
+@end
+
115 SMFController.m
@@ -0,0 +1,115 @@
+//
+// SMFController.m
+// SoftwareMenuFramework
+//
+// Created by Thomas Cool on 11/30/09.
+// Copyright 2009 Thomas Cool. All rights reserved.
+//
+
+
+#import "SMFController.h"
+
+@implementation SMFController
+
+-(CGRect)getMasterFrame
+{
+ CGRect master ;
+// if ([SMFPreferences twoPointThreeOrGreater]){
+// master = [[self parent] frame];
+// } else {
+// master = [self frame];
+// }
+ master=[self frame];
+ if ([self is1080i])
+ master.size=[self sizeFor1080i];
+ return master;
+}
+
+- (BOOL)is1080i
+{
+// NSString *displayUIString = [BRDisplayManager currentDisplayModeUIString];
+// NSArray *displayCom = [displayUIString componentsSeparatedByString:@" "];
+// NSString *shortString = [displayCom objectAtIndex:0];
+// if ([shortString isEqualToString:@"1080i"])
+// return YES;
+// else
+ return NO;
+}
+
+- (CGSize)sizeFor1080i
+{
+
+ CGSize currentSize;
+ currentSize.width = 1280.0f;
+ currentSize.height = 720.0f;
+
+
+ return currentSize;
+}
+-(void)dealloc
+{
+ [_title release];
+ [_headerControl release];
+ [_spinner release];
+ [_imageControl release];
+ [_image release];
+ [super dealloc];
+}
+-(void)drawSelf;
+{
+ [self _removeAllControls];
+
+}
+@end
+@implementation SMFController (layout)
+
+
+-(void)layoutSpinner
+{
+ [_spinner removeFromParent];
+ CGRect masterFrame=[self getMasterFrame];
+ CGRect frame2 = masterFrame;
+ frame2.origin.x = masterFrame.size.width * 0.39f;
+ frame2.origin.y = (masterFrame.size.height * 0.05f);// - txtSize.height;
+
+ frame2.size.width = masterFrame.size.width*0.22f;
+ frame2.size.height = masterFrame.size.height*0.22f;
+ [_spinner setFrame:frame2];
+ [_spinner setSpins:YES];
+ [self addControl:_spinner];
+}
+-(void)layoutHeader
+{
+ [_headerControl removeFromParent];
+ if(_title == nil)
+ _title = DEFAULT_CONTROLLER_TITLE;
+ [_headerControl setTitle:_title];
+ CGRect masterFrame = [self getMasterFrame];
+ CGRect frame=masterFrame;
+ frame.origin.y = frame.size.height * 0.82f;
+ frame.size.height = [[BRThemeInfo sharedTheme] listIconHeight];
+ [_headerControl setFrame:frame];
+ [self addControl:_headerControl];
+}
+-(void)layoutImage
+{
+ [_imageControl removeFromParent];
+ if (_image==nil)
+ _image = [[BRThemeInfo sharedTheme] appleTVIcon];
+ [_imageControl setImage:_image];
+ [_imageControl setAutomaticDownsample:YES];
+ CGRect masterFrame = [self getMasterFrame];
+ float aspectRatio = [_image aspectRatio];
+ CGRect frame;
+ frame.origin.x = masterFrame.size.width *0.7f;
+ frame.origin.y = masterFrame.size.height *0.3f;
+ frame.size.width = masterFrame.size.height*0.4f;
+ frame.size.height= frame.size.width/aspectRatio;
+ [_imageControl setFrame:frame];
+ [self addControl:_imageControl];
+}
+
+
+
+@end
+
32 SMFDefines.h
@@ -0,0 +1,32 @@
+//
+// SMFDefines.h
+// SMFramework
+//
+// Created by Thomas Cool on 10/24/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+typedef enum {
+ // for originator kBREventOriginatorRemote
+ kBREventRemoteActionMenu = 1,
+ kBREventRemoteActionMenuHold,
+ kBREventRemoteActionUp,
+ kBREventRemoteActionDown,
+ kBREventRemoteActionPlay,
+ kBREventRemoteActionLeft,
+ kBREventRemoteActionRight,
+
+ kBREventRemoteActionPlayHold = 20,
+
+ // Gestures, for originator kBREventOriginatorGesture
+ kBREventRemoteActionTap = 30,
+ kBREventRemoteActionSwipeLeft,
+ kBREventRemoteActionSwipeRight,
+ kBREventRemoteActionSwipeUp,
+ kBREventRemoteActionSwipeDown,
+
+ // Custom remote actions for old remote actions
+ kBREventRemoteActionHoldLeft = 0xfeed0001,
+ kBREventRemoteActionHoldRight,
+ kBREventRemoteActionHoldUp,
+ kBREventRemoteActionHoldDown,
+} BREventRemoteAction;
18 SMFEvent.h
@@ -0,0 +1,18 @@
+//
+// SMFEvent.h
+// SMFramework
+//
+// Created by Thomas Cool on 10/31/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+
+
+@interface SMFEvent : NSObject {
+ NSString *key;
+ NSString *name;
+}
++(SMFEvent *)eventWithName:(NSString *)n andKey:(NSString *)k;
+@property (retain)NSString *key;
+@property (retain)NSString *name;
+@end
22 SMFEvent.m
@@ -0,0 +1,22 @@
+//
+// SMFEvent.m
+// SMFramework
+//
+// Created by Thomas Cool on 10/31/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import "SMFEvent.h"
+
+
+@implementation SMFEvent
++(SMFEvent *)eventWithName:(NSString *)n andKey:(NSString *)k
+{
+ SMFEvent *e = [[SMFEvent alloc] init];
+ [e setKey:k];
+ [e setName:n];
+ return [e autorelease];
+}
+@synthesize key;
+@synthesize name;
+@end
33 SMFEventConfiguration.h
@@ -0,0 +1,33 @@
+//
+// SMFEventConfiguration.h
+// SMFramework
+//
+// Created by Thomas Cool on 11/4/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import "SMFMediaMenuController.h"
+#import "SMFEventManager.h"
+@interface SMFEventConfiguration : SMFMediaMenuController {
+ NSArray *_listeners;
+}
+
+@end
+
+@interface SMFListenerConfiguration: SMFMediaMenuController
+{
+ NSArray *_events;
+ id<SMFEventDelegate>listener;
+}
+-(id)initForListener:(id<SMFEventDelegate>)l;
+@end
+@interface SMFKeySelectMenu:BRAlertController
+{
+ NSString *_event;
+ NSString *_eventName;
+ NSString *_eventDescription;
+ NSString *_currentKey;
+ int currentAction;
+}
+-(void)setEvent:(NSString *)event;
+@end
144 SMFEventConfiguration.m
@@ -0,0 +1,144 @@
+//
+// SMFEventConfiguration.m
+// SMFramework
+//
+// Created by Thomas Cool on 11/4/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import "SMFEventConfiguration.h"
+
+#import "SMFMenuItem.h"
+
+@implementation SMFEventConfiguration
+-(id)init
+{
+ self=[super init];
+ _listeners=[[[SMFEventManager sharedManager] listeners] retain];
+ [self setListTitle:@"Event Manager"];
+ for(id<SMFEventDelegate> l in _listeners)
+ {
+ SMFMenuItem *it = [SMFMenuItem folderMenuItem];
+ [it setTitle:[l displayName]];
+ [_items addObject:it];
+ [_options addObject:l];
+ }
+ return self;
+}
+-(void)itemSelected:(long)row
+{
+ SMFListenerConfiguration *l = [[SMFListenerConfiguration alloc] initForListener:[_options objectAtIndex:row]];
+ [[self stack] pushController:l];
+ [l release];
+}
+@end
+
+@implementation SMFListenerConfiguration
+
+-(id)initForListener:(id<SMFEventDelegate>)l
+{
+ self=[super init];
+ [self setListTitle:[l displayName]];
+ listener=l;
+ _events=[[SMFEventManager sharedManager] eventsForListener:listener];
+ for(NSString *e in _events)
+ {
+ SMFMenuItem *it = [SMFMenuItem folderMenuItem];
+ [it setTitle:e];
+ [_items addObject:it];
+ [_options addObject:e];
+ }
+ return self;
+
+}
+-(void)itemSelected:(long)selected
+{
+ SMFKeySelectMenu *k = [[SMFKeySelectMenu alloc] init];
+ [k setPrimaryText:[_options objectAtIndex:selected]];
+ [k setEvent:[_options objectAtIndex:selected]];
+ [k setSecondaryText:@"Please press a key"];
+ [[self stack] pushController:k];
+}
+@end
+@implementation SMFKeySelectMenu
+-(void)setEvent:(NSString *)event
+{
+ _event=[event retain];
+}
+-(id)init
+{
+ self=[super init];
+ currentAction=0;
+ return self;
+}
+-(void)wasPushed
+{
+ NSLog(@"was Pushed");
+ [[SMFEventManager sharedManager]startLearning];
+}
+-(void)wasPopped
+{
+ NSLog(@"was Popped");
+ [[SMFEventManager sharedManager]stopLearning];
+}
+-(BOOL)brEventAction:(BREvent *)action
+{
+ int c=[action remoteAction];
+
+ NSString *str=nil;
+ if (action.value==0x01) {
+ if (c==47)
+ {
+ str=[[action eventDictionary] objectForKey:@"kBRKeyEventCharactersKey"];
+ if (str!=nil)
+ {
+ if (_currentKey!=nil && [_currentKey isEqualToString:str] && currentAction==47) {
+ //register key here
+ if (_event!=nil) {
+ NSLog(@"event: %@",_event);
+ [[SMFEventManager sharedManager]setKey:str forName:_event];
+
+ }
+ NSLog(@"final key = %@",str);
+ [[self stack]popController];
+ }
+ else {
+ [_currentKey release];
+ _currentKey=nil;
+ currentAction=47;
+ _currentKey=[str retain];
+ [self setSecondaryText:@"Please press same key again"];
+ }
+
+ }
+ else
+ {
+ [_currentKey release];
+ _currentKey=nil;
+ currentAction=0;
+ }
+ }
+ else {
+ if (currentAction==c) {
+ if (_event!=nil) {
+ NSLog(@"event: %@",_event);
+ [[SMFEventManager sharedManager] setRemoteAction:c forName:_event];
+ }
+ NSLog(@"final remoteAction: %d",c);
+ [[self stack] popController];
+ }
+ else
+ {
+ currentAction=c;
+ [self setSecondaryText:@"Please press same key again"];
+ }
+
+ }
+
+ }
+
+
+ NSLog(@"Action Pressed: %d",[action remoteAction]);
+ return NO;
+}
+@end
57 SMFEventManager.h
@@ -0,0 +1,57 @@
+//
+// SMFEventManager.h
+// SMFramework
+//
+// Created by Thomas Cool on 10/31/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import "SynthesizeSingleton.h"
+#import "SMFEvent.h"
+@protocol SMFEventDelegate
+-(void)actionForEvent:(SMFEvent *)event;
+-(NSString *)displayName;
+@optional
+-(BRImage *)icon;
+-(NSString *)displayNameForEventKey:(NSString *)event;
+@end
+
+
+@interface SMFEventManager : NSObject {
+ NSMutableDictionary * _delegates;
+ NSMutableDictionary * _keys;
+ NSMutableDictionary * _remoteActionKeys;
+ NSMutableDictionary * _listeners;
+ NSMutableSet * _listenerSet;
+ BOOL _learning;
+}
++(SMFEventManager *)sharedManager;
+-(void)registerListener:(id<SMFEventDelegate>)listener forName:(NSString *)name;
+-(void)registerListener:(id<SMFEventDelegate>)listener forNames:(NSArray*)names;
+
+-(void)setKey:(NSString *)key forName:(NSString *)name;
+-(void)setRemoteAction:(int)action forName:(NSString *)name;
+-(void)callEventForAction:(NSString *)key;
+-(BOOL)callEventForRemoteAction:(int)action;
+-(void)callEventForBREvent:(BREvent *)event;
+-(BOOL)actionDefinedForKey:(NSString *)key;
+-(BOOL)actionDefinedForAction:(int)action;
+-(NSArray *)listeners;
+-(NSArray *)eventsForListener:(id<SMFEventDelegate>)listener;
+-(void)startLearning;
+-(void)stopLearning;
+-(void)loadInformation;
+@end
+@interface SMFDefaultEvents : NSObject<SMFEventDelegate>
+{
+}
++(SMFDefaultEvents *)sharedDefaults;
+-(void)takeScreenshot;
+-(void)restartLowtide;
+-(void)configureEventManager;
+-(void)startSlideshowController;
+-(void)test1;
+-(void)test2;
+
+@end
+
279 SMFEventManager.m
@@ -0,0 +1,279 @@
+//
+// SMFEventManager.m
+// SMFramework
+//
+// Created by Thomas Cool on 10/31/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import "SMFEventManager.h"
+#import "SMFScreenCapture.h"
+#import "SMFEventConfiguration.h"
+#import "SMFPhotoMethods.h"
+#define eventsPlist (CFStringRef)@"org.tomcool.eventManager"
+#define remoteActionDict (CFStringRef)@"remoteActions"
+#define keyDict (CFStringRef)@"keyboardKeys"
+
+#define kSMFEventDefaultScreenshot @"defaults.screenshot"
+#define kSMFEventDefaultRestartLowtide @"defaults.restartLowtide"
+#define kSMFEventDefaultSetup @"defaults.setup"
+#define kSMFEventDefaultSlideshow @"defaults.slideshow"
+
+@implementation SMFEventManager
+SYNTHESIZE_SINGLETON_FOR_CLASS(SMFEventManager,sharedManager)
+-(id)init
+{
+ self = [super init];
+ _delegates=[[NSMutableDictionary alloc] init];
+ [self loadInformation];
+ _listeners=[[NSMutableDictionary alloc]init];
+ _listenerSet=[[NSMutableSet alloc]init];
+ [SMFScreenCapture sharedInstance];
+ [SMFDefaultEvents sharedDefaults];
+ _learning=NO;
+ return self;
+}
+-(void)registerListener:(id<SMFEventDelegate>)listener forName:(NSString *)name
+{
+ [_listenerSet addObject:listener];
+ [_delegates setObject:listener forKey:name];
+}
+-(void)registerListener:(id<SMFEventDelegate>)listener forNames:(NSArray*)names
+{
+ [_listenerSet addObject:listener];
+ for(NSString *name in names)
+ {
+ [_delegates setObject:listener forKey:name];
+ }
+}
+
+-(void)loadInformation
+{
+ _remoteActionKeys=[(NSDictionary *) CFPreferencesCopyAppValue(remoteActionDict, eventsPlist)mutableCopy];
+ if (_remoteActionKeys==nil) {
+ _remoteActionKeys=[[NSMutableDictionary alloc]init];
+ }
+ _keys=[(NSDictionary *) CFPreferencesCopyAppValue(keyDict, eventsPlist)mutableCopy];
+ if (_keys==nil) {
+ _keys=[[NSMutableDictionary alloc]init];
+ }
+}
+-(void)startLearning
+{
+ _learning=YES;
+}
+-(void)stopLearning
+{
+ _learning=NO;
+}
+-(NSArray *)listeners
+{
+ return [_listenerSet allObjects];
+}
+-(NSArray *)eventsForListener:(id<SMFEventDelegate>)listener
+{
+ NSMutableArray *a = [NSMutableArray array];
+ for(NSString *k in [_delegates allKeys])
+ {
+ if ([_delegates objectForKey:k]==listener) {
+ [a addObject:k];
+ }
+ }
+ return a;
+}
+-(void)setKey:(NSString *)key forName:(NSString *)name
+{
+ [_keys setObject:name forKey:key];
+ CFPreferencesSetAppValue(keyDict, (CFDictionaryRef)_keys, eventsPlist);
+ CFPreferencesAppSynchronize(eventsPlist);
+}
+-(void)setRemoteAction:(int)action forName:(NSString *)name
+{
+ [_remoteActionKeys setObject:name forKey:[NSString stringWithFormat:@"%d",action,nil]];
+ CFPreferencesSetAppValue(remoteActionDict, (CFDictionaryRef)_remoteActionKeys, eventsPlist);
+ CFPreferencesAppSynchronize(eventsPlist);
+}
+-(void)callEventForAction:(NSString *)key
+{
+ if ([[_keys allKeys] containsObject:key])
+ {
+ NSString *name = [_keys objectForKey:key];
+ if ([[_delegates allKeys] containsObject:name])
+ {
+ id<SMFEventDelegate>listener = [_delegates objectForKey:name];
+ SMFEvent *e = [SMFEvent eventWithName:name andKey:key];
+ [listener actionForEvent:e];
+ }
+ }
+}
+-(void)callEventForBREvent:(BREvent *)event
+{
+ NSDictionary *d = [event eventDictionary];
+ NSString *s = [d objectForKey:@"kBRKeyEventCharactersKey"];
+ if (d!=nil && s!=nil) {
+ [self callEventForAction:s];
+ }
+ else if([event value]==0x01)
+ {
+ [self callEventForRemoteAction:[event remoteAction]];
+ }
+
+}
+-(BOOL)callEventForRemoteAction:(int)action
+{
+
+ NSString *key=[NSString stringWithFormat:@"%d",action,nil];
+ if ([[_remoteActionKeys allKeys] containsObject:key])
+ {
+ NSString *name = [_remoteActionKeys objectForKey:key];
+ if ([[_delegates allKeys] containsObject:name])
+ {
+ id<SMFEventDelegate>listener = [_delegates objectForKey:name];
+ SMFEvent *e = [SMFEvent eventWithName:name andKey:key];
+ [listener actionForEvent:e];
+ return YES;
+ }
+ else
+ return NO;
+ }
+ else
+ return NO;
+}
+-(BOOL)actionDefinedForBREvent:(BREvent *)event
+{
+ if (_learning)
+ return NO;
+ if ([event remoteAction]==47) {
+ NSDictionary *d = [event eventDictionary];
+ NSString *s = [d objectForKey:@"kBRKeyEventCharactersKey"];
+ if (d!=nil && s!=nil)
+ {
+ if ([s isEqualToString:@" "] && [[BRMediaPlayerManager singleton]_presentedPlayerController]==[[[BRApplicationStackManager singleton] stack]peekController]) {
+ return YES;
+ }
+ else
+ return [self actionDefinedForKey:s];
+ }
+ else
+ return NO;
+ }
+ else if([event value]==0x01)
+ {
+ return [self actionDefinedForKey:[event remoteAction]];
+ }
+ return NO;
+}
+-(BOOL)actionDefinedForKey:(NSString *)key
+{
+ if(_learning)
+ return NO;
+ return [[_keys allKeys] containsObject:key];
+}
+-(BOOL)actionDefinedForAction:(int)action
+{
+ if (_learning)
+ return NO;
+ NSString *key=[NSString stringWithFormat:@"%d",action,nil];
+ return [[_remoteActionKeys allKeys]containsObject:key];
+
+}
+
+@end
+@implementation SMFDefaultEvents
+SYNTHESIZE_SINGLETON_FOR_CLASS(SMFDefaultEvents,sharedDefaults)
+-(id)init
+{
+ self=[super init];
+ [[SMFEventManager sharedManager]registerListener:self
+ forNames:[NSArray arrayWithObjects:
+ kSMFEventDefaultScreenshot,
+ kSMFEventDefaultRestartLowtide,
+ kSMFEventDefaultSetup,
+ kSMFEventDefaultSlideshow,
+ nil]];
+ [[SMFEventManager sharedManager]setRemoteAction:63265 forName:kSMFEventDefaultScreenshot];
+ [[SMFEventManager sharedManager]setRemoteAction:63266 forName:kSMFEventDefaultRestartLowtide];
+ [[SMFEventManager sharedManager]setRemoteAction:63267 forName:kSMFEventDefaultSlideshow];
+ [[SMFEventManager sharedManager]setRemoteAction:18 forName:kSMFEventDefaultScreenshot];
+ [[SMFEventManager sharedManager]setRemoteAction:15 forName:kSMFEventDefaultScreenshot];
+
+ [[SMFEventManager sharedManager]setKey:@"=" forName:kSMFEventDefaultSetup];
+ return self;
+
+}
+-(NSString *)displayName
+{
+ return @"Default Settings";
+}
+-(void)restartLowtide
+{
+ [[BRApplication sharedApplication] terminate];
+}
+-(void)actionForEvent:(SMFEvent *)event
+{
+ NSLog(@"%@ %@ %@ %@",kSMFEventDefaultScreenshot,kSMFEventDefaultRestartLowtide,kSMFEventDefaultSetup,kSMFEventDefaultSlideshow);
+ NSLog(@"event: %@ %@",event,[event name]);
+
+ if ([[event name] isEqualToString:kSMFEventDefaultScreenshot])
+ [self takeScreenshot];
+ else if ([[event name] isEqualToString:kSMFEventDefaultRestartLowtide])
+ [self restartLowtide];
+ else if ([[event name] isEqualToString:kSMFEventDefaultSetup])
+ [self configureEventManager];
+ else if ([[event name] isEqualToString:kSMFEventDefaultSlideshow])
+ [self startSlideshowController];
+
+}
+-(NSString *)displayNameForEventKey:(NSString *)key
+{
+ if ([key isEqualToString:kSMFEventDefaultScreenshot])
+ return @"Screenshot";
+ else if ([key isEqualToString:kSMFEventDefaultRestartLowtide])
+ return @"Restart Lowtide";
+ else if ([key isEqualToString:kSMFEventDefaultRestartLowtide])
+ return @"Configure Events Triggers";
+ return nil;
+}
+-(void)takeScreenshot
+{
+ NSFileManager *man = [NSFileManager defaultManager];
+ BOOL good=TRUE;
+ NSString *path=@"/screenshot.png";
+ if ([man fileExistsAtPath:@"/screenshot.png"]) {
+ good =FALSE;
+ }
+ int i =1;
+ while (!good) {
+ i++;
+ path = [NSString stringWithFormat:@"/screenshot_%i.png",i,nil];
+ if (![man fileExistsAtPath:path])
+ good=TRUE;
+ }
+ [SMFScreenCapture saveScreenToFile:path];
+}
+-(void)startSlideshowController
+{
+ NSLog(@"slideshow");
+ //BRDataStore *store = [SMFPhotoMethods dataStoreForPath:@"/System/Library/PrivateFrameworks/AppleTV.framework/DefaultAnimalPhotos/"];
+ BRDataStore *store = [SMFPhotoMethods dataStoreForPath:@"/nature"];
+ NSLog(@"store: %@",store);
+ BRPhotoControlFactory* controlFactory = [BRPhotoControlFactory standardFactory];
+ SMFPhotoCollectionProvider* provider = [SMFPhotoCollectionProvider providerWithDataStore:store controlFactory:controlFactory];//[[ATVSettingsFacade sharedInstance] providerForScreenSaver];//[collection provider];
+ SMFPhotoBrowserController* pc = [SMFPhotoBrowserController controllerForProvider:provider];
+ [pc setTitle:@"DefaultAnimalPhotos"];
+ [[[BRApplicationStackManager singleton] stack] pushController:pc];
+}
+-(void)configureEventManager
+{
+ SMFEventConfiguration *c = [[[SMFEventConfiguration alloc] init] autorelease];
+ [[[BRApplicationStackManager singleton] stack]pushController:c];
+}
+-(void)test1
+{
+
+}
+-(void)test2
+{
+
+}
+@end
41 SMFFolderBrowser.h
@@ -0,0 +1,41 @@
+//
+// SMFolderBrowser.h
+// SoftwareMenuFramework
+//
+// Created by Thomas on 4/19/09.
+// Copyright 2009 tomcool.org. All rights reserved.
+//
+
+#import "SMFMediaMenuController.h"
+
+@interface SMFFolderBrowser : SMFMediaMenuController
+ {
+
+ NSString * path;
+ NSMutableArray * _paths;
+ NSFileManager * _man;
+ NSMutableArray * _files;
+ NSMutableArray * _folders;
+ BOOL separate;
+ BOOL showHidden;
+ BOOL showOnlyFolders;
+ NSString *plistPath;
+ NSString *plistKey;
+ id delegate;
+ NSString *fpath;
+
+ }
+
++ (void)setString:(NSString *)inputString forKey:(NSString *)theKey inDomain:(NSString *)theDomain;
++ (NSString *)stringForKey:(NSString *)theKey inDomain:(NSString *)theDomain;
+-(void)setPath:(NSString *)thePath;
+-(void)reloadFiles;
+-(id)initWithPath:(NSString *)thePath;
+@property (assign) BOOL separate;
+@property (assign) BOOL showHidden;
+@property (assign) BOOL showOnlyFolders;
+@property (retain) NSString *plistKey;
+@property (retain) NSString *plistPath;
+@property (retain) id delegate;
+@property (retain) NSString *fpath;
+@end
264 SMFFolderBrowser.m
@@ -0,0 +1,264 @@
+//
+// SMFolderBrowser.m
+// SoftwareMenuFramework
+//
+// Created by Thomas on 4/19/09.
+// Copyright 2010 Thomas Cool. All rights reserved.
+//
+
+
+
+#import "SMFFolderBrowser.h"
+#import "SMFBaseAsset.h"
+#import "SMFMediaPreview.h"
+#import "SMFMenuItem.h"
+#import "SMFThemeInfo.h"
+
+@implementation SMFFolderBrowser
+@synthesize separate;
+@synthesize showHidden;
+@synthesize showOnlyFolders;
+@synthesize delegate;
+@synthesize plistKey;
+@synthesize plistPath;
+@synthesize fpath;
+
+//- (id) previewControlForItem: (long) item
+//{
+// ////NSLog(@"%@ %s", self, _cmd);
+// SMFBaseAsset *meta = [[SMFBaseAsset alloc] init];
+// [meta setTitle:[_paths objectAtIndex:item]];
+// [meta setCoverArt:[[BRThemeInfo sharedTheme] appleTVImage]];
+// [meta setSummary:[_paths objectAtIndex:item]];
+// BRMetadataPreviewControl *obj = [[BRMetadataPreviewControl alloc] init];
+// [obj setShowsMetadataImmediately:NO];
+// [obj setAsset:meta];
+// [meta release];
+// return [obj autorelease];
+//}
++ (void)setString:(NSString *)inputString forKey:(NSString *)theKey inDomain:(NSString *)theDomain
+{
+ CFPreferencesSetAppValue((CFStringRef)theKey, (CFStringRef)inputString, (CFStringRef)theDomain);
+ CFPreferencesAppSynchronize((CFStringRef)theDomain);
+ //CFRelease(inputString);
+}
++ (NSString *)stringForKey:(NSString *)theKey inDomain:(NSString *)theDomain
+{
+ NSLog(@"The Domain: %@",theDomain);
+ CFPreferencesAppSynchronize((CFStringRef)theDomain);
+ NSString * myString = (NSString *)CFPreferencesCopyAppValue((CFStringRef)theKey, (CFStringRef)theDomain);
+ return [(NSString *)myString autorelease];
+}
+-(id)init{
+ self = [super init];
+ [self addLabel:@"org.tomcool.Software.SMF"];
+ separate = TRUE;
+ showHidden = FALSE;
+ _items = [[NSMutableArray alloc] initWithObjects:nil];
+ _paths = [[NSMutableArray alloc] initWithObjects:nil];
+ _man = [[NSFileManager defaultManager] retain];
+ _files = [[NSMutableArray alloc]init];
+ _folders = [[NSMutableArray alloc]init];
+ [[self list] setDatasource:self];
+ return self;
+}
+- (id)initWithPath:(NSString *)thePath
+{
+ self = [super init];
+ [self addLabel:@"org.tomcool.Software.SMF"];
+ separate = TRUE;
+ showHidden = FALSE;
+ _items = [[NSMutableArray alloc] initWithObjects:nil];
+ _paths = [[NSMutableArray alloc] initWithObjects:nil];
+ _man = [[NSFileManager defaultManager] retain];
+ _files = [[NSMutableArray alloc]init];
+ _folders = [[NSMutableArray alloc]init];
+ [[self list] setDatasource:self];
+ [self setPath:thePath];
+ return self;
+}
+- (void)setPath:(NSString *)thePath
+{
+ [path release];
+ path = thePath;
+ [path retain];
+ [self setListTitle: [path lastPathComponent]];
+ [self reloadFiles];
+}
+
+-(void)reloadFiles
+{
+ [_paths removeAllObjects];
+ [_items removeAllObjects];
+ [_folders removeAllObjects];
+ if (plistKey!=nil && plistPath!=nil ) {
+ [self setFpath:[SMFFolderBrowser stringForKey:plistKey inDomain:plistPath]];
+ }
+
+ [[self list] removeDividers];
+ NSFileManager *man = [NSFileManager defaultManager];
+ BOOL isDir;
+ NSArray *files= [man contentsOfDirectoryAtPath:path error:nil];
+ for (NSString *file in files)
+ {
+ //NSLog(@"file: %@",file);
+ if (![file hasPrefix:@":"]) {
+ if (![file hasPrefix:@"."] || showHidden) {
+ NSString *tf = [path stringByAppendingPathComponent:file];
+ if ([man fileExistsAtPath:tf isDirectory:&isDir])
+ {
+ if (!(!isDir && showOnlyFolders))
+ {
+ if (separate)
+ {
+ if (isDir)
+ [_folders addObject:tf];
+ else
+ [_files addObject:tf];
+ }
+ else
+ [_files addObject:tf];
+ }
+ }
+ }
+ }
+ }
+ [[self list] addDividerAtIndex:[_folders count] withLabel:@"Files"];
+ NSLog(@"files count: %i",[_files count]);
+ NSLog(@"folders count: %i",[_folders count]);
+ //[[self list] reload];
+}
+-(void)leftActionForRow:(long)row
+{
+ [self rightActionForRow:row];
+}
+-(void)rightActionForRow:(long)row
+{
+ NSString *p=nil;
+ BOOL dir=NO;
+ if (separate && row<[_folders count])
+ {
+ p=[_folders objectAtIndex:row];
+ }
+ else if(!separate &&
+ [[NSFileManager defaultManager] fileExistsAtPath:[_folders objectAtIndex:row] isDirectory:&dir]
+ && dir)
+ {
+ p=[_files objectAtIndex:row];
+ }
+ NSLog(@"p: %@",p);
+ NSLog(@"plistKey: %@",plistKey);
+ NSLog(@"plistPath: %@",plistPath);
+ if (p)
+ {
+
+ if (plistKey!=nil && plistPath!=nil) {
+ [SMFFolderBrowser setString:p forKey:plistKey inDomain:plistPath];
+ NSLog(@"plistKey and Path is good");
+ }
+ NSLog(@"p is good");
+ }
+ [self reloadFiles];
+ [[self list] reload];
+
+}
+-(void)itemSelected:(long)row
+{
+ NSFileManager *man = [NSFileManager defaultManager];
+ if (separate)
+ {
+ if (row<[_folders count])
+ {
+ NSString *newPath = [path stringByAppendingPathComponent:[_folders objectAtIndex:row]];
+ SMFFolderBrowser *p = [[SMFFolderBrowser alloc]initWithPath:newPath];
+ [[self stack]pushController:p];
+ [p release];
+ }
+ }
+ else
+ {
+ NSString *newPath = [_files objectAtIndex:row];//[path stringByAppendingPathComponent:[_files objectAtIndex:row]];
+ BOOL isDir;
+ if([man fileExistsAtPath:newPath isDirectory:&isDir] && isDir)
+ {
+ SMFFolderBrowser *p = [[SMFFolderBrowser alloc]initWithPath:[_files objectAtIndex:row]];
+ [[self stack]pushController:p];
+ [p release];
+ }
+ }
+}
+
+- (id)itemForRow:(long)row
+{
+ if (separate)
+ {
+ if (row<[_folders count])
+ {
+ SMFMenuItem *it = [SMFMenuItem folderMenuItem];
+ [it setText:[[_folders objectAtIndex:row] lastPathComponent]
+ withAttributes:[[BRThemeInfo sharedTheme]menuItemTextAttributes]];
+ if (fpath!=nil&&
+ [[_folders objectAtIndex:row] localizedCaseInsensitiveCompare:fpath]==NSOrderedSame) {
+ //NSLog(@"it :%@ %@",[_folders objectAtIndex:row],fpath);
+ [it setImage:[[SMFThemeInfo sharedTheme] selectedImage]];
+ }
+ return it;
+ }
+ else if(row<([_folders count]+[_files count]))
+ {
+ SMFMenuItem *it = [SMFMenuItem menuItem];
+ [it setText:[[_files objectAtIndex:(row-[_folders count])] lastPathComponent]
+ withAttributes:[[BRThemeInfo sharedTheme]menuItemTextAttributes]];
+
+ return it;
+ }
+ }
+ else
+ {
+ BRMenuItem *it = [[BRMenuItem alloc] init];
+ //NSLog(@"it: %@, %@",it,[[_files objectAtIndex:row] lastPathComponent]);
+ [it setText:[[_files objectAtIndex:row] lastPathComponent]
+ withAttributes:[[BRThemeInfo sharedTheme]menuItemTextAttributes]];
+ if (fpath && [[_files objectAtIndex:row] localizedCaseInsensitiveCompare:fpath]==NSOrderedSame) {
+
+ [it setImage:[[SMFThemeInfo sharedTheme] selectedImage]];
+ }
+ return [it autorelease];
+ }
+ return nil;
+
+}
+-(id)titleForRow:(long)row
+{
+ if (separate)
+ {
+ if (row<[_folders count])
+ {
+ return [[_folders objectAtIndex:row] lastPathComponent];
+ }
+ else if(row<([_folders count]+[_files count]))
+ {
+ return [[_files objectAtIndex:(row-[_folders count])] lastPathComponent];
+ }
+ }
+ else
+ {
+ //NSLog(@"title: %@",[[_files objectAtIndex:row] lastPathComponent]);
+ return [[_files objectAtIndex:row] lastPathComponent];
+ }
+ return nil;
+}
+-(long)itemCount
+{
+ return ([_folders count]+[_files count]);
+}
+-(void)dealloc
+{
+ [_man release];
+ [_folders release];
+ [_files release];
+ [super dealloc];
+
+}
+
+@end
16 SMFFolderDelegate.h
@@ -0,0 +1,16 @@
+//
+// SMFFolderDelegate.h
+// SMFramework
+//
+// Created by Thomas Cool on 10/30/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface SMFFolderDelegate : NSObject {
+
+}
+
+@end
14 SMFFolderDelegate.m
@@ -0,0 +1,14 @@
+//
+// SMFFolderDelegate.m
+// SMFramework
+//
+// Created by Thomas Cool on 10/30/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import "SMFFolderDelegate.h"
+
+
+@implementation SMFFolderDelegate
+
+@end
18 SMFInvocationCenteredMenuController.h
@@ -0,0 +1,18 @@
+//
+// SMFInvocationCenteredMenuController.h
+// SoftwareMenuFramework
+//
+// Created by Thomas Cool on 2/27/10.
+// Copyright 2010 Thomas Cool. All rights reserved.
+//
+
+#import "SMFCenteredMenuController.h"
+
+@class SMFCenteredMenuController;
+@interface SMFInvocationCenteredMenuController : SMFCenteredMenuController {
+
+}
++(id)invocationsForObject:(id)target withSelectorVal:(NSString *)selectorString withArguments:(NSArray *)arguments;
+-(id)initWithTitles:(NSArray *)titles withInvocations:(NSArray *)invocations withTitle:(NSString *)title withDescription:(NSString *)description;
+
+@end
67 SMFInvocationCenteredMenuController.m
@@ -0,0 +1,67 @@
+//
+// SMFInvocationCenteredMenuController.m
+// SoftwareMenuFramework
+//
+// Created by Thomas Cool on 2/27/10.
+// Copyright 2010 Thomas Cool. All rights reserved.
+//
+
+#import "SMFInvocationCenteredMenuController.h"
+
+@implementation SMFInvocationCenteredMenuController
+-(id)initWithTitles:(NSArray *)titles withInvocations:(NSArray *)invocations withTitle:(NSString *)title withDescription:(NSString *)description
+{
+ self=[super init];
+ [self setListTitle:title];
+ [self setPrimaryInfoText:description];
+ int i,count=[titles count];
+ BRMenuItem *a;
+ for(i=0;i<count;i++)
+ {
+ a=[[BRMenuItem alloc] init];
+
+ [a setText:[titles objectAtIndex:i] withAttributes:[[BRThemeInfo sharedTheme]menuItemTextAttributes]];
+ [_items addObject:a];
+ [_options addObject:[invocations objectAtIndex:i]];
+ }
+ return self;
+}
+-(void)itemSelected:(long)arg1
+{
+ if([[_options objectAtIndex:arg1] respondsToSelector:@selector(invoke)])
+ [(NSInvocation *)[_options objectAtIndex:arg1]invoke];
+ [[self stack]popController];
+}
++(id)invocationsForObject:(id)target withSelectorVal:(NSString *)selectorString withArguments:(NSArray *)arguments
+{
+
+ if (selectorString==nil) {
+ return @"none";
+ }
+ SEL theSelector;
+ NSMethodSignature *aSignature;
+ NSInvocation *anInvocation;
+ id b = target;
+ theSelector = NSSelectorFromString(selectorString);
+ //theSelector= @selector(removeFromQueue:);
+ // NSLog(@"selector)
+ aSignature = [[target class] instanceMethodSignatureForSelector:theSelector];
+ //NSLog(@"signature: %@",aSignature);
+ anInvocation = [NSInvocation invocationWithMethodSignature:aSignature];
+ [anInvocation setSelector:theSelector];
+ [anInvocation setTarget:b];
+ if (arguments !=nil)
+ {
+ int i,count=[arguments count];
+ id c;
+ for(i=2;i<count+2;i++)
+ {
+ c=[arguments objectAtIndex:i-2];
+ [anInvocation setArgument:&c atIndex:i];
+ }
+
+ }
+ [anInvocation retainArguments];
+ return anInvocation;
+}
+@end
37 SMFMediaMenuController.h
@@ -0,0 +1,37 @@
+//
+// SMFMediaMenuController.h
+// Untitled
+//
+// Created by Thomas Cool on 10/22/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "SMFDefines.h"
+@interface SMFMediaMenuController : BRMediaMenuController {
+ NSMutableArray *_items;
+ NSMutableArray *_options;
+}
+
+-(float)heightForRow:(long)row;
+-(BOOL)rowSelectable:(long)row;
+-(long)itemCount;
+-(id)itemForRow:(long)row;
+-(long)rowForTitle:(id)title;
+-(id)titleForRow:(long)row;
+-(int)getSelection;
+-(id)everyLoad;
+
+- (void)setSelection:(int)sel;
+/*
+ * Action Called Every Time someone Presses on Left Arrow
+ */
+-(void)leftActionForRow:(long)row;
+
+/*
+ * Action Called Every Time someone Presses on Right Arrow
+ */
+-(void)rightActionForRow:(long)row;
+
+
+@end
142 SMFMediaMenuController.m
@@ -0,0 +1,142 @@
+//
+// OFMediaMenuController.m
+// Untitled
+//
+// Created by Thomas Cool on 10/22/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import "SMFMediaMenuController.h"
+
+
+@implementation SMFMediaMenuController
+- (float)heightForRow:(long)row { return 0.0f;}
+- (BOOL)rowSelectable:(long)row { return YES;}
+- (long)itemCount { return (long)[_items count];}
+- (id)itemForRow:(long)row { return [_items objectAtIndex:row];}
+- (long)rowForTitle:(id)title { return (long)[_items indexOfObject:title];}
+- (id)titleForRow:(long)row
+{
+
+ return [[_items objectAtIndex:row] text];
+}
+- (long)defaultIndex { return 0;}
+- (id)previewControlForItem:(long)row
+{
+ BRImage * image = [[BRThemeInfo sharedTheme] appleTVIcon];
+ BRImageAndSyncingPreviewController *preview = [[BRImageAndSyncingPreviewController alloc] init];
+ [preview setImage:image];
+ return [preview autorelease];
+}
+- (id)init
+{
+ self=[super init];
+ _items = [[NSMutableArray alloc]init];
+ _options = [[NSMutableArray alloc] init];
+ [[self list] setDatasource:self];
+ return self;
+}
+- (void)dealloc
+{
+ [_items release];
+ [_options release];
+ [super dealloc];
+}
+-(id)everyLoad
+{
+ return self;
+}
+-(int)getSelection
+{
+ BRListControl *list = [self list];
+ int row;
+ NSMethodSignature *signature = [list methodSignatureForSelector:@selector(selection)];
+ NSInvocation *selInv = [NSInvocation invocationWithMethodSignature:signature];
+ [selInv setSelector:@selector(selection)];
+ [selInv invokeWithTarget:list];
+ if([signature methodReturnLength] == 8)
+ {
+ double retDoub = 0;
+ [selInv getReturnValue:&retDoub];
+ row = retDoub;
+ }
+ else
+ [selInv getReturnValue:&row];
+ return row;
+}
+-(void)leftActionForRow:(long)row
+{
+
+}
+-(void)rightActionForRow:(long)row
+{
+
+}
+-(BOOL)brEventAction:(BREvent *)event
+{
+ int remoteAction = [event remoteAction];
+ if ([(BRControllerStack *)[self stack] peekController] != self)
+ remoteAction = 0;
+
+ int itemCount = [[(BRListControl *)[self list] datasource] itemCount];
+ switch (remoteAction)
+ {
+ case kBREventRemoteActionSwipeLeft:
+ case kBREventRemoteActionLeft:
+ if([event value] == 1)
+ [self leftActionForRow:[self getSelection]];
+ return YES;
+ break;
+ case kBREventRemoteActionSwipeRight:
+ case kBREventRemoteActionRight:
+ if([event value] == 1)
+ [self rightActionForRow:[self getSelection]];
+ return YES;
+ break;
+ case kBREventRemoteActionUp:
+ case kBREventRemoteActionHoldUp:
+ if([self getSelection] == 0 && [event value] == 1)
+ {
+ [self setSelection:itemCount-1];
+ return YES;
+ }
+ break;
+ case kBREventRemoteActionDown:
+ case kBREventRemoteActionHoldDown:
+ if([self getSelection] == itemCount-1 && [event value] == 1)
+ {
+ [self setSelection:0];
+ return YES;
+ }
+ break;
+ }
+ return [super brEventAction:event];
+}
+- (void)setSelection:(int)sel
+{
+ BRListControl *list = [self list];
+ NSMethodSignature *signature = [list methodSignatureForSelector:@selector(setSelection:)];
+ NSInvocation *selInv = [NSInvocation invocationWithMethodSignature:signature];
+ [selInv setSelector:@selector(setSelection:)];
+ if(strcmp([signature getArgumentTypeAtIndex:2], "l"))
+ {
+ double dvalue = sel;
+ [selInv setArgument:&dvalue atIndex:2];
+ }
+ else
+ {
+ long lvalue = sel;
+ [selInv setArgument:&lvalue atIndex:2];
+ }
+ [selInv invokeWithTarget:list];
+}
+
+-(void)controlWasActivated
+{
+ if([self respondsToSelector:@selector(everyLoad)])
+ [self everyLoad];
+ [super controlWasActivated];
+}
+- (void)wasExhumedByPoppingController:(id)fp8 {[self wasExhumed];}
+-(void)wasExhumed {[[self list] reload];}
+@end
38 SMFMediaPreview.h
@@ -0,0 +1,38 @@
+//
+// SMFMediaPreview.h
+// SoftwareMenuFramework
+//
+// Created by Thomas Cool on 11/9/09.
+// Copyright 2009 Thomas Cool. All rights reserved.
+//
+
+#define METADATA_IMAGE_URL @"ImageURL"
+#define METADATA_TITLE @"Name"
+#define METADATA_SUMMARY @"Summary"
+#define METADATA_CUSTOM_KEYS @"KeysArray"
+#define METADATA_CUSTOM_OBJECTS @"ObjectsArray"
+typedef enum {
+ kMetaTypePlugin=0,
+ kMetaTypeCustom=1,
+ kMetaTypeSimple=2,
+ kMetaTypeAsset=3,
+} SMMetaType;
+
+@interface SMFMediaPreview : BRMetadataPreviewControl{
+ NSMutableDictionary *meta;
+ SMMetaType MetaDataType;
+ BRImage *image;
+ id *_assetCustom;
+}
+
+//- (NSMutableDictionary *)getPluginMetaData;
+//- (void)setUtilityData:(NSMutableDictionary *)newMeta;
+- (id)coverArtForPath;
+//- (void)setUtilityData:(NSMutableDictionary *)newMeta;
+//- (void)setCustomMetaData:(NSMutableDictionary *)customMeta;
+- (void)setImage:(BRImage *)currentImage;
+- (void)setImagePath:(NSString *)path;
+//- (void)setSimpleMetaDataWithTitle:(NSString *)title andSummary:(NSString *)summary;
+//- (void)setAssetMeta:(id)asset;
+
+@end
246 SMFMediaPreview.mm
@@ -0,0 +1,246 @@
+//
+// SMFMediaPreview.m
+// SoftwareMenuFramework
+//
+// Created by Thomas Cool on 11/9/09.
+// Copyright 2009 Thomas Cool. All rights reserved.
+//
+
+
+#import "SMFMediaPreview.h"
+#import "SMFBaseAsset.h"
+#import "Classes/BackRowExtras.h"
+@interface BRCoverArtImageLayer (compat)
+-(id)texture;
+@end
+
+/*These interfaces are to access variables not available*/
+//@interface BRMetadataControl (protectedAccess)
+//- (NSArray *)gimmieMetadataObjs;
+//@end
+//
+//
+///* There is no BRMetadataLayer class in ATV2.0 anymore, it seems to be BRMetadataControl now*/
+///* So just do the same stuff as above, but for BRMetadataControl*/
+//
+//@implementation BRMetadataControl (protectedAccess)
+// -(NSArray *)gimmieMetadataObjs {
+// Class klass = [self class];
+// Ivar ret = class_getInstanceVariable(klass, "_metadataObjs");
+// return *(NSArray * *)(((char *)self)+ret->ivar_offset);
+//}
+//@end
+
+
+@interface BRMetadataPreviewControl (compat)
+- (void)_populateMetadata;
+- (void)_updateMetadataLayer;
+- (id) _loadCoverArt;
+@end
+
+@interface BRMetadataPreviewControl (protectedAccess)
+- (BRMetadataControl *)gimmieMetadataLayer;
+@end
+
+@implementation BRMetadataPreviewControl (protectedAccess)
+- (BRMetadataControl *)gimmieMetadataLayer
+{
+// Class myClass = [self class];
+// Ivar ret = class_getInstanceVariable(myClass,"_metadataLayer");
+//
+ return MSHookIvar<BRMetadataControl *>(self, "_metadataLayer");
+}
+@end
+
+@interface SMFMediaPreview (Custom)
+- (void)doPopulation;
+- (NSString *)coverArtForPath;
+@end
+
+@implementation SMFMediaPreview
+
+/*List of extensions to look for cover art*/
+static NSSet *coverArtExtentions = nil;
+
++ (void)initialize
+{
+ /*Initialize the set of cover art extensions*/
+ coverArtExtentions = [[NSSet alloc] initWithObjects:
+ @"jpg",
+ @"jpeg",
+ @"tif",
+ @"tiff",
+ @"png",
+ @"gif",
+ nil];
+}
+-(BRCoverArtImageLayer *)coverArtLayer
+{
+ return MSHookIvar<BRCoverArtImageLayer *>(self, "_coverArtLayer");
+}
+- (id)init
+{
+ self=[super init];
+ meta=[[NSMutableDictionary alloc] init];
+
+ [meta setObject:@"No Title" forKey:METADATA_TITLE];
+ image=[[BRThemeInfo sharedTheme] appleTVIcon];
+ [image retain];
+ return self;
+}
+
+- (void)dealloc
+{
+ [meta release];
+ [image release];
+ //[coverArtExtentions release];
+ //[dirMeta release];
+ [super dealloc];
+}
+
+//- (void)setUtilityData:(NSMutableDictionary *)newMeta
+//{
+// [meta release];
+// meta=[newMeta retain];
+// SMFMedia *asset =[SMFMedia alloc];
+// [asset setDefaultImage];
+// [self setAsset:asset];
+//
+//}
+
+- (void)setImage:(BRImage *)currentImage
+{
+ [image release];
+ image=[currentImage retain];
+// NSLog(@"%@",_asset);
+// [_asset setBRImage:image];
+// if (_asset!=nil && [_asset respondsToSelector:@selector(setBRImage:)])
+// [_asset setBRImage:image];
+ BRCoverArtImageLayer * c = [self coverArtLayer];
+ [c setImage:image];
+// [_reflectionLayer setImage:image];
+// [_reflectionLayer setReflectionAmount:0.337531];
+}
+- (void)setImagePath:(NSString *)path
+{
+ if([[NSFileManager defaultManager] fileExistsAtPath:path] && [coverArtExtentions containsObject:[path pathExtension]])
+ {
+ [self setImage:[BRImage imageWithPath:path]];
+ }
+
+}
+
+- (void)setAsset:(id)a
+{
+ //NSLog(@"assetMeta: %@",asset);
+ MetaDataType=kMetaTypeAsset;
+ [super setAsset:a];
+ BRReflectionControl *c = MSHookIvar<BRReflectionControl *>(self, "_reflectionLayer");
+ [c setImage:[a coverArt]];
+ [c setReflectionAmount:0.337531];
+
+ [[self coverArtLayer] setImage:[a coverArt]];
+
+ //[_coverArtLayer setImage:[asset coverArt]];
+ //NSLog(@"_asset: %@",_asset);
+
+ //[self _updateMetadataLayer];
+}
+-(void)setAssetMeta:(id)a
+{
+ [self setAsset:a];
+}
+
+
+
+
+- (id)coverArtForPath
+{
+ if (image!=nil)
+ return image;
+ image=[[self asset] coverArt];
+ if (image!=nil)
+ return image;
+ return [[BRThemeInfo sharedTheme] appleTVIcon];
+}
+
+
+- (id)_loadCoverArt
+{
+ //NSLog(@"loading cover art");
+ [super _loadCoverArt];
+ if([[self coverArtLayer] texture] != nil)
+ return nil;
+ id localImage = [self coverArtForPath];
+
+ BRReflectionControl *c = MSHookIvar<BRReflectionControl *>(self, "_reflectionLayer");
+ [c setImage:localImage];
+ [c setReflectionAmount:0.337531];
+
+ [[self coverArtLayer] setImage:localImage];
+
+ return nil;
+}
+
+- (void)_populateMetadata
+{
+ //NSLog(@"_populate");
+ [super _populateMetadata];
+ [self doPopulation];
+}
+
+
+- (void)_updateMetadataLayer
+{
+ //NSLog(@"update");
+ [super _updateMetadataLayer];
+ [self doPopulation];
+}
+
+- (void)doPopulation
+{
+ //NSLog(@"doPopulation");
+ BRMetadataControl *metaLayer = [self gimmieMetadataLayer];
+ switch (MetaDataType) {
+ case kMetaTypeAsset:
+ {
+ id a = [self asset];
+ if ([a respondsToSelector:@selector(orderedDictionary)]) {
+ NSDictionary *assetDict=[a orderedDictionary];
+ if([[assetDict allKeys] containsObject:METADATA_TITLE])
+ [metaLayer setTitle:[assetDict objectForKey:METADATA_TITLE]];
+ if([[assetDict allKeys] containsObject:METADATA_SUMMARY])
+ [metaLayer setSummary:[assetDict objectForKey:METADATA_SUMMARY]];
+ if([[assetDict allKeys] containsObject:METADATA_CUSTOM_KEYS])
+ {
+ //NSLog(@"%@",[assetDict objectForKey:METADATA_CUSTOM_OBJECTS]);
+ //NSLog(@"%@",[assetDict objectForKey:METADATA_CUSTOM_KEYS]);
+ [metaLayer setMetadata:[assetDict objectForKey:METADATA_CUSTOM_OBJECTS] withLabels:[assetDict objectForKey:METADATA_CUSTOM_KEYS]];
+ }
+ }
+ break;
+ }
+ default:
+ {
+ [metaLayer setTitle:[meta objectForKey:METADATA_TITLE]];
+ [metaLayer setSummary:[meta objectForKey:METADATA_SUMMARY]];
+ break;
+ }
+
+ }
+ //`NSLog(@"donePopulating");
+
+
+
+}
+
+
+- (BOOL)_assetHasMetadata
+{
+ return YES;
+}
+
+@end
+
+
+
37 SMFMenuController.h
@@ -0,0 +1,37 @@
+//
+// SMFMenuController.h
+// Untitled
+//
+// Created by Thomas Cool on 10/22/10.
+// Copyright 2010 tomcool.org. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import "SMFDefines.h"
+@interface SMFMenuController : BRMenuController {
+ NSMutableArray *_items;
+ NSMutableArray *_options;
+}
+
+-(float)heightForRow:(long)row;