Changeset 572
- Timestamp:
- 06/02/08 14:42:05 (7 months ago)
- Files:
-
- branches/CoreData/SapphireCompatibilityClasses/SapphireFrontRowCompat.h (modified) (1 diff)
- branches/CoreData/SapphireCompatibilityClasses/SapphireFrontRowCompat.m (modified) (2 diffs)
- branches/CoreData/SapphireFrappliance/FRAppliance/SapphireAppliance.h (modified) (1 diff)
- branches/CoreData/SapphireFrappliance/FRAppliance/SapphireAppliance.m (modified) (7 diffs)
- branches/CoreData/SapphireFrappliance/FRAppliance/SapphireApplianceController.h (modified) (3 diffs)
- branches/CoreData/SapphireFrappliance/FRAppliance/SapphireApplianceController.m (modified) (3 diffs)
- branches/CoreData/SapphireFrappliance/FRAppliance/SapphireMetaDataUpgrading.h (modified) (1 diff)
- branches/CoreData/SapphireFrappliance/FRAppliance/SapphireMetaDataUpgrading.m (modified) (4 diffs)
- branches/CoreData/SapphireFrappliance/MetaData/Support/SapphireMetaDataSupport.m (modified) (1 diff)
- branches/CoreData/SapphireFrappliance/Sapphire.xcodeproj/project.pbxproj (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/CoreData/SapphireCompatibilityClasses/SapphireFrontRowCompat.h
r499 r572 356 356 */ 357 357 + (BRTextWithSpinnerController *)textWithSpinnerControllerTitled:(NSString *)title text:(NSString *)text isNetworkDependent:(BOOL)networkDependent scene:(BRRenderScene *)scene; 358 359 /*! 360 * @brief Sets whether a BRWaitSpinnerControl should spin or not 361 * 362 * @param spinner The spinner 363 * @param spin YES if the spinner should spin, NO otherwise 364 */ 365 + (void)setSpinner:(BRWaitSpinnerControl *)spinner toSpin:(BOOL)spin; 358 366 359 367 /*! branches/CoreData/SapphireCompatibilityClasses/SapphireFrontRowCompat.m
r501 r572 80 80 @end 81 81 82 @interface BRWaitSpinnerControl (compat) 83 - (void)setSpins:(BOOL)spin; 84 @end 85 82 86 @implementation SapphireFrontRowCompat 83 87 … … 411 415 } 412 416 417 + (void)setSpinner:(BRWaitSpinnerControl *)spinner toSpin:(BOOL)spin 418 { 419 if([spinner respondsToSelector:@selector(setSpins:)]) 420 [spinner setSpins:spin]; 421 else if([spinner respondsToSelector:@selector(startSpinning)]) 422 { 423 if(spin) 424 [spinner startSpinning]; 425 else 426 [spinner stopSpinning]; 427 } 428 } 429 413 430 + (NSArray *)callStackReturnAddressesForException:(NSException *)exception 414 431 { branches/CoreData/SapphireFrappliance/FRAppliance/SapphireAppliance.h
r541 r572 37 37 */ 38 38 @interface SapphireAppliance : NSObject <BRAppliance, BRApplianceProtocol> { 39 BOOL upgradeNeeded; /*!< @brief YES if upgrade is needed*/ 39 40 } 40 41 @end branches/CoreData/SapphireFrappliance/FRAppliance/SapphireAppliance.m
r570 r572 49 49 @end 50 50 51 52 51 @implementation SapphireAppliance 53 52 … … 128 127 } 129 128 129 - (id)upgradeControllerWithScene:(BRRenderScene *)scene 130 { 131 return [[[SapphireMetaDataUpgrading alloc] initWithScene:scene] autorelease]; 132 } 133 130 134 static SapphireApplianceController *mainCont = nil; 131 135 - (id)applianceController 132 136 { 137 return [self applianceControllerWithScene:nil]; 138 } 139 140 - (id) applianceControllerWithScene: (id) scene 141 { 142 // this function is called when your item is selected on the main menu 133 143 @try { 134 mainCont = [[[SapphireApplianceController alloc] initWithScene: nil] autorelease]; 144 if([SapphireApplianceController upgradeNeeded]) 145 return [self upgradeControllerWithScene:scene]; 146 mainCont = [[[SapphireApplianceController alloc] initWithScene:scene] autorelease]; 135 147 } 136 148 @catch (NSException * e) { … … 139 151 140 152 return mainCont; 141 }142 143 - (id) applianceControllerWithScene: (id) scene144 {145 // this function is called when your item is selected on the main menu146 return ( [[[SapphireApplianceController alloc] initWithScene: scene] autorelease] );147 153 } 148 154 … … 151 157 */ 152 158 -(id)applianceInfo { 153 BRApplianceInfo* p = [BRApplianceInfo infoForApplianceBundle:[NSBundle bundleForClass:[self class]]];154 NSMutableArray *categories = [NSMutableArray array];155 156 NSEnumerator *enumerator = [[p applianceCategoryDescriptors] objectEnumerator];157 id obj;158 while((obj = [enumerator nextObject]) != nil) {159 BRApplianceCategory *category = [BRApplianceCategory categoryWithName:[obj valueForKey:@"name"] identifier:[obj valueForKey:@"identifier"] preferredOrder:[[obj valueForKey:@"preferred-order"] floatValue]];160 [categories addObject:category];161 }162 [[self applianceController] setToMountsOnly];163 159 return [BRApplianceInfo infoForApplianceBundle:[NSBundle bundleForClass:[self class]]]; 164 160 } … … 167 163 NSMutableArray *categories = [NSMutableArray array]; 168 164 169 if([ [self applianceController]upgradeNeeded])165 if([SapphireApplianceController upgradeNeeded]) 170 166 { 171 167 categories = [NSArray arrayWithObject: … … 180 176 [categories addObject:category]; 181 177 } 182 }183 [[self applianceController] setToMountsOnly];178 [[self applianceController] setToMountsOnly]; 179 } 184 180 return categories; 185 181 } … … 192 188 { 193 189 NSString *identifier = (NSString *)ident; 194 SapphireApplianceController *controller = [self applianceController];195 190 if([identifier isEqualToString:UPGRADE_IDENTIFIER]) 196 191 { 197 NSLog(@"Starting upgrade");198 192 [mainCont release]; 199 193 mainCont = nil; 200 return [[[SapphireMetaDataUpgrading alloc] initWithScene:nil title:BRLocalizedString(@"Importing Metadata", @"") text:BRLocalizedString(@"Importing Metadata", @"") showBack:NO isNetworkDependent:NO] autorelease]; 201 } 194 return [self upgradeControllerWithScene:nil]; 195 } 196 SapphireApplianceController *controller = [self applianceController]; 202 197 if([identifier isEqualToString:TV_SHOW_IDENTIFIER]) 203 198 return [controller tvBrowser]; branches/CoreData/SapphireFrappliance/FRAppliance/SapphireApplianceController.h
r570 r572 38 38 SapphireLeopardOnly *leoOnly; /*!< @brief Leopard only stuff*/ 39 39 BOOL mountsOnly; /*!< @brief YES if only display mounts*/ 40 BOOL needsUpgrade; /*!< @brief YES if we need to do an upgrade*/41 40 } 42 41 … … 86 85 87 86 /*! 87 * @brief Gets whether an upgrade is needed 88 * 89 * @return YES if upgrade neeeded, NO otherwise 90 */ 91 + (BOOL)upgradeNeeded; 92 93 /*! 88 94 * @brief Sets to display mounts only 89 95 * … … 127 133 */ 128 134 - (SapphireSettings *)settings; 129 130 /*!131 * @brief Gets whether an upgrade is needed132 *133 * @return YES if upgrade neeeded, NO otherwise134 */135 - (BOOL)upgradeNeeded;136 135 @end branches/CoreData/SapphireFrappliance/FRAppliance/SapphireApplianceController.m
r570 r572 168 168 } 169 169 170 - (id) initWithScene: (BRRenderScene *) scene 171 { 172 self = [super initWithScene:scene]; 173 174 //Setup the theme's scene 175 SapphireTheme *theme = [SapphireTheme sharedTheme]; 176 [theme setScene:[self scene]]; 177 170 + (BOOL)upgradeNeeded 171 { 178 172 NSFileManager *fm = [NSFileManager defaultManager]; 179 173 NSString *storeFile = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/Sapphire/metaData.sapphireData"]; … … 181 175 NSString *plistFile = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/Sapphire/metaData.plist"]; 182 176 BOOL oldExists = [fm fileExistsAtPath:plistFile]; 183 if(!exists && oldExists) 184 { 185 NSLog(@"Detected upgrade needed"); 186 needsUpgrade = YES; 187 return self; 188 } 177 return !exists && oldExists; 178 } 179 180 - (id) initWithScene: (BRRenderScene *) scene 181 { 182 self = [super initWithScene:scene]; 183 184 //Setup the theme's scene 185 SapphireTheme *theme = [SapphireTheme sharedTheme]; 186 [theme setScene:[self scene]]; 187 188 NSString *storeFile = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/Sapphire/metaData.sapphireData"]; 189 189 moc = [[NSManagedObjectContext alloc] init]; 190 190 [moc setUndoManager:nil]; … … 321 321 } 322 322 323 - (BOOL)upgradeNeeded324 {325 return needsUpgrade;326 }327 328 323 - (void)setMenuFromSettings 329 324 { branches/CoreData/SapphireFrappliance/FRAppliance/SapphireMetaDataUpgrading.h
r571 r572 19 19 */ 20 20 21 #import <SapphireCompatClasses/Sapphire TextWithSpinnerController.h>21 #import <SapphireCompatClasses/SapphireCenteredMenuController.h> 22 22 23 @interface SapphireMetaDataUpgrading : SapphireTextWithSpinnerController { 23 @interface SapphireMetaDataUpgrading : SapphireCenteredMenuController { 24 BRWaitSpinnerControl *spinner; /*!< @brief The spinner*/ 25 BRTextControl *status; /*!< @brief Status message*/ 24 26 NSManagedObjectContext *moc; /*!< @brief The context*/ 25 27 } branches/CoreData/SapphireFrappliance/FRAppliance/SapphireMetaDataUpgrading.m
r571 r572 23 23 #import "SapphireMetaDataSupport.h" 24 24 25 @interface SapphireMetaDataUpgrading (private) 26 - (void)layoutFrame; 27 @end 28 25 29 @implementation SapphireMetaDataUpgrading 26 30 27 - (id) initWithScene: (BRRenderScene *) scene title:(id)fp12 text:(id)fp16 showBack:(BOOL)fp20 isNetworkDependent:(BOOL)fp2431 - (id) initWithScene: (BRRenderScene *) scene 28 32 { 29 self = [super initWithScene:scene title:fp12 text:fp16 showBack:fp20 isNetworkDependent:fp24];33 self = [super initWithScene:scene]; 30 34 if(self == nil) 31 35 return self; 36 37 [self setListTitle:BRLocalizedString(@"Upgrading Metadata", @"")]; 32 38 33 39 moc = [[NSManagedObjectContext alloc] init]; … … 44 50 NSError *error = nil; 45 51 [coord addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&error]; 52 53 status = [SapphireFrontRowCompat newTextControlWithScene:scene]; 54 if([BRWaitSpinnerControl instancesRespondToSelector:@selector(initWithScene:)]) 55 spinner = [[BRWaitSpinnerControl alloc] initWithScene:scene]; 56 else 57 spinner = [[BRWaitSpinnerControl alloc] init]; 58 59 if([SapphireFrontRowCompat usingFrontRow] && ![SapphireFrontRowCompat usingTakeTwo]) 60 { 61 [spinner release]; 62 spinner = [[BRWaitSpinnerLayer alloc] init]; 63 } 64 65 [self layoutFrame]; 66 67 [self addControl:status]; 68 if([SapphireFrontRowCompat usingFrontRow] && ![SapphireFrontRowCompat usingTakeTwo]) 69 [SapphireFrontRowCompat addSublayer:spinner toControl:self]; 70 else 71 [self addControl:spinner]; 46 72 47 73 return self; … … 49 75 } 50 76 77 - (void)layoutFrame 78 { 79 /*title*/ 80 NSRect frame = [SapphireFrontRowCompat frameOfController:self]; 81 frame.origin.y += frame.size.height / 2.0f; 82 frame.origin.x = frame.size.width / 2.0f; 83 frame.size.width = frame.size.height = frame.size.height / 6.0f; 84 [spinner setFrame:frame] ; 85 } 86 51 87 - (void) dealloc 52 88 { 89 [spinner release]; 90 [status release]; 53 91 [moc release]; 54 92 [super dealloc]; 55 93 } 56 94 95 - (void)realSetCurrentFile:(NSString *)file 96 { 97 if(file == nil) 98 file = @""; 99 [SapphireFrontRowCompat setText:file withAtrributes:[[BRThemeInfo sharedTheme] paragraphTextAttributes] forControl:status]; 100 101 NSRect master = [SapphireFrontRowCompat frameOfController:self]; 102 NSSize progressSize = [SapphireFrontRowCompat textControl:status renderedSizeWithMaxSize:NSMakeSize(master.size.width * 1.0f/2.0f, master.size.height * 0.3f)]; 103 104 NSRect frame; 105 frame.origin.x = (master.size.width) * 0.1f; 106 frame.origin.y = (master.size.height * 0.12f) + master.origin.y; 107 frame.size = progressSize; 108 [status setFrame:frame]; 109 } 110 57 111 - (void)setCurrentFile:(NSString *)file 58 112 { 113 [self performSelectorOnMainThread:@selector(realSetCurrentFile:) withObject:file waitUntilDone:YES]; 59 114 } 60 115 61 116 - (void)finished 62 117 { 63 [[self stack] pop ];118 [[self stack] popController]; 64 119 } 65 120 … … 76 131 - (void)wasPushed 77 132 { 78 NSLog(@"Upgrade pushed");79 133 [super wasPushed]; 134 [SapphireFrontRowCompat setSpinner:spinner toSpin:YES]; 80 135 [NSThread detachNewThreadSelector:@selector(doUpgrade:) toTarget:self withObject:nil]; 81 136 } branches/CoreData/SapphireFrappliance/MetaData/Support/SapphireMetaDataSupport.m
r571 r572 237 237 NSLog(@"%@", error); 238 238 } 239 240 NSLog(@"Sapphire Import Complete");241 239 } 242 240 branches/CoreData/SapphireFrappliance/Sapphire.xcodeproj/project.pbxproj
r570 r572 712 712 F5B418360D0B1EA100BDD361 /* SapphireImportHelper.h */, 713 713 F5B418370D0B1EA100BDD361 /* SapphireImportHelper.m */, 714 F5B418640D0B28A200BDD361 /* main_helper.m */,715 714 F59BB9160DF43C3E00EC11A2 /* SapphireMetaDataUpgrading.h */, 716 715 F59BB9170DF43C3E00EC11A2 /* SapphireMetaDataUpgrading.m */, 716 F5B418640D0B28A200BDD361 /* main_helper.m */, 717 717 ); 718 718 path = FRAppliance;
