Permalink
Browse files

SMFCenteredMenuController fixes + more

  • Loading branch information...
tomcool420 committed Jan 7, 2011
1 parent 83e7df7 commit d14eb8fc9eea90c0272939232d2300de1357f236
View
@@ -14,7 +14,7 @@
NSMutableDictionary *_meta;
BRImage *_image;
}
-
++(SMFBaseAsset *)asset;
-(void)setObject:(id)arg1 forKey:(id)arg2;
-(void)setTitle:(NSString *)title;
-(void)setSummary:(NSString *)summary;
View
@@ -11,6 +11,10 @@
@implementation SMFBaseAsset
++(SMFBaseAsset *)asset
+{
+ return [[[SMFBaseAsset alloc ]init] autorelease];
+}
-(id)init
{
self=[super init];
@@ -16,7 +16,7 @@ - (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];
+ return [[self itemForRow:row] text];
}
- (long)defaultIndex { return 0;}
//- (id)previewControlForItem:(long)row
View
@@ -113,7 +113,6 @@ -(int)syscallSeatbeltEnabled
-(int)disableSeatbelt
{
- NSLog(@"disable in framework");
return system("SMFHelper security.mac.vnode_enforce 0");
}
-(int)enableSeatbelt
View
@@ -13,4 +13,4 @@ include $(FW_MAKEDIR)/tool.mk
after-SMFHelper-stage::
$(FAKEROOT) chmod 4755 $(FW_STAGING_DIR)/usr/bin/SMFHelper
# $(FAKEROOT) chmod u+s $(FW_STAGING_DIR)/usr/bin/SMFHelper
- $(FAKEROOT) chown root:staff $(FW_STAGING_DIR)/usr/bin/SMFHelper
+ $(FAKEROOT) chown root:wheel $(FW_STAGING_DIR)/usr/bin/SMFHelper
View
Binary file not shown.
View
Binary file not shown.
View
@@ -9,21 +9,14 @@
#include <unistd.h>
#import <Foundation/Foundation.h>
#import <Backrow/Backrow.h>
-#import "../SynthesizeSingleton.h"
-@interface SMFHelperClass : NSObject
-//-(SMFHelperClass *)sharedInstance;
--(int)setSysValue:(NSString *)val forKey:(NSString *)key;
-@end
-@implementation SMFHelperClass
-//SYNTHESIZE_SINGLETON_FOR_CLASS(SMFHelperClass,sharedInstance)
--(int)setSysValue:(NSString *)val forKey:(NSString *)key
+
+static int setSysValue(NSString * val, NSString *k)
{
- return system([[NSString stringWithFormat:@"sysctl -w %@=%@",key,val,nil] UTF8String]);
+ NSLog(@"settingValue: %@ to key %@",val,k);
+ return system([[NSString stringWithFormat:@"sysctl -w %@=%@",k,val,nil] UTF8String]);
}
-@end
-
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
@@ -40,9 +33,7 @@ int main (int argc, const char * argv[]) {
NSString *option = [NSString stringWithUTF8String:argv[1]]; //argument 1
NSString *value = [NSString stringWithUTF8String:argv[2]]; //argument 2
int rvalue=0;
- SMFHelperClass *c = [[SMFHelperClass alloc] init];
- rvalue=[c setSysValue:value forKey:option];
- [c release];
+ rvalue = setSysValue(value,option);
[pool release];
return rvalue;
}
View
@@ -8,7 +8,7 @@
#import "SMFMediaMenuController.h"
#import "SMFPopup.h"
-
+#import "SMFMediaPreview.h"
@implementation SMFMediaMenuController
- (float)heightForRow:(long)row { return 0.0f;}
- (BOOL)rowSelectable:(long)row { return YES;}
@@ -24,10 +24,9 @@ - (id)titleForRow:(long)row
- (long)defaultIndex { return 0;}
- (id)previewControlForItem:(long)row
{
- BRImage * image = [[BRThemeInfo sharedTheme] appleTVIcon];
- BRImageAndSyncingPreviewController *preview = [[BRImageAndSyncingPreviewController alloc] init];
- [preview setImage:image];
- return [preview autorelease];
+ return [SMFMediaPreview simplePreviewWithTitle:[self titleForRow:row]
+ withSummary:nil
+ withImage:[[BRThemeInfo sharedTheme] appleTVIcon]];
}
- (id)init
{
View
@@ -11,28 +11,17 @@
#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;
-
+@class SMFBaseAsset;
@interface SMFMediaPreview : BRMetadataPreviewControl{
- NSMutableDictionary *meta;
- SMMetaType MetaDataType;
BRImage *image;
- id *_assetCustom;
}
+(SMFMediaPreview *)simplePreviewWithTitle:(NSString *)title withSummary:(NSString *)summary withImage:(BRImage *)img;
++(SMFMediaPreview *)mediaPreviewWithAsset:(SMFBaseAsset *)a;
+(SMFMediaPreview *)mediaPreview;
- (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
View
@@ -32,25 +32,21 @@ -(id)texture;
//@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 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;
@@ -59,34 +55,29 @@ - (NSString *)coverArtForPath;
@implementation SMFMediaPreview
-static NSSet *coverArtExtentions = nil;
+(SMFMediaPreview *)simplePreviewWithTitle:(NSString *)title withSummary:(NSString *)summary withImage:(BRImage *)img
{
- SMFBaseAsset *a = [[SMFBaseAsset alloc] init];
- [a setTitle:title];
- [a setSummary:summary];
- [a setCoverArt:img];
+ SMFBaseAsset *a = [SMFBaseAsset asset];
+ if (title)
+ [a setTitle:title];
+ if(summary)
+ [a setSummary:summary];
+ if(img)
+ [a setCoverArt:img];
SMFMediaPreview *p = [[SMFMediaPreview alloc] init];
[p setAsset:a];
- [a release];
return [p autorelease];
}
+(SMFMediaPreview *)mediaPreview
{
return [[[SMFMediaPreview alloc] init] autorelease];
}
-+ (void)initialize
++(SMFMediaPreview *)mediaPreviewWithAsset:(SMFBaseAsset *)a
{
- /*Initialize the set of cover art extensions*/
- coverArtExtentions = [[NSSet alloc] initWithObjects:
- @"jpg",
- @"jpeg",
- @"tif",
- @"tiff",
- @"png",
- @"gif",
- nil];
+ SMFMediaPreview *p = [[SMFMediaPreview alloc] init];
+ [p setAsset:a];
+ return [p autorelease];
}
-(BRCoverArtImageLayer *)coverArtLayer
{
@@ -95,32 +86,18 @@ -(BRCoverArtImageLayer *)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
{
@@ -131,28 +108,14 @@ - (void)setImage:(BRImage *)currentImage
}
- (void)setImagePath:(NSString *)path
{
- if([[NSFileManager defaultManager] fileExistsAtPath:path] && [coverArtExtentions containsObject:[path pathExtension]])
+ if([[NSFileManager defaultManager] fileExistsAtPath:path])
{
[self setImage:[BRImage imageWithPath:path]];
}
}
-- (void)setAsset:(id)a
-{
- 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];
@@ -171,31 +134,6 @@ - (id)coverArtForPath
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
-{
- [super _populateMetadata];
- [self doPopulation];
-}
-
-
- (void)_updateMetadataLayer
{
[super _updateMetadataLayer];
@@ -204,35 +142,20 @@ - (void)_updateMetadataLayer
- (void)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:
+ //BRMetadataControl *metaLayer = [self gimmieMetadataLayer];
+ BRMetadataControl *metaLayer = [self metadataControl];
+ 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])
{
- [metaLayer setTitle:[meta objectForKey:METADATA_TITLE]];
- [metaLayer setSummary:[meta objectForKey:METADATA_SUMMARY]];
- break;
+ [metaLayer setMetadata:[assetDict objectForKey:METADATA_CUSTOM_OBJECTS] withLabels:[assetDict objectForKey:METADATA_CUSTOM_KEYS]];
}
-
}
- //`NSLog(@"donePopulating");
@@ -241,6 +164,10 @@ - (void)doPopulation
- (BOOL)_assetHasMetadata
{
+ if ([[self asset] respondsToSelector:@selector(orderedDictionary)]) {
+ return YES;
+ }
+ NSLog(@"asset has not meta??");
return YES;
}
View
@@ -56,12 +56,12 @@ - (id)initWithTitle:(NSString *)t withDescription:(NSString *)desc withBoxes:(in
}
- (void) dealloc
{
-// self.title=nil;
-// self.delegate=nil;
-// self.description=nil;
-// self.key=nil;
-// self.domain=nil;
-// self.icon=nil;
+ self.title=nil;
+ self.delegate=nil;
+ self.description=nil;
+ self.key=nil;
+ self.domain=nil;
+ self.icon=nil;
[super dealloc];
}
-(void)controlWasActivated
Oops, something went wrong.

0 comments on commit d14eb8f

Please sign in to comment.