Changeset 5490
- Timestamp:
- 05/02/08 14:58:58 (2 weeks ago)
- Files:
-
- Spiral/trunk/SPApplicationController.h (modified) (1 diff)
- Spiral/trunk/SPApplicationController.m (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Spiral/trunk/SPApplicationController.h
r5471 r5490 59 59 - (BOOL)openFile:(NSString *)path withPlaylistFile:(SPPlaylistFile *)file; 60 60 - (BOOL)openURL:(WIURL *)url withPlaylistFile:(SPPlaylistFile *)file; 61 - (BOOL)hasPerianInstalled;62 61 - (void)scheduleUpdateCheck; 63 62 Spiral/trunk/SPApplicationController.m
r5485 r5490 39 39 #import "SPWiiRemote.h" 40 40 41 #define SPFilenameErrorKey @"SPFilenameErrorKey" 42 #define SPRecoveryURLErrorKey @"SPRecoveryURLErrorKey" 43 44 41 45 static SPApplicationController *SPSharedApplicationController; 42 46 … … 46 50 - (SPRemoteContext)_remoteContext; 47 51 - (void)_handleRemoteAction:(SPRemoteAction)action; 52 53 - (BOOL)_hasQuicktimeComponentWithName:(NSString *)name; 54 - (BOOL)_hasPerianInstalled; 55 - (BOOL)_hasFlip4MacWMVImportInstalled; 48 56 49 57 @end … … 199 207 } 200 208 209 210 211 #pragma mark - 212 213 - (BOOL)_hasQuicktimeComponentWithName:(NSString *)name { 214 NSString *libraryPath, *componentPath; 215 216 for(libraryPath in NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSAllDomainsMask, YES)) { 217 componentPath = [libraryPath stringByAppendingPathComponent:[NSSWF:@"Quicktime/%@.component", name]]; 218 219 if([[NSFileManager defaultManager] fileExistsAtPath:componentPath]) 220 return YES; 221 } 222 223 return NO; 224 } 225 226 227 228 - (BOOL)_hasPerianInstalled { 229 return [self _hasQuicktimeComponentWithName:@"Perian"]; 230 } 231 232 233 234 - (BOOL)_hasFlip4MacWMVImportInstalled { 235 return [self _hasQuicktimeComponentWithName:@"Flip4Mac WMV Import"]; 236 } 237 201 238 @end 202 239 … … 251 288 - (NSError *)application:(NSApplication *)application willPresentError:(NSError *)error { 252 289 NSMutableDictionary *userInfo; 253 NSString * recoverySuggestion;290 NSString *filename, *recoverySuggestion; 254 291 255 292 if([error domain] == NSOSStatusErrorDomain && [error code] == -2048) { … … 263 300 recoverySuggestion = NSLS(@"The file is not a movie file.", @"Error description"); 264 301 265 if(![self hasPerianInstalled]) { 302 filename = [[error userInfo] objectForKey:SPFilenameErrorKey]; 303 304 if([[[filename pathExtension] lowercaseString] isEqualToString:@"wmv"] && ![self _hasFlip4MacWMVImportInstalled]) { 305 recoverySuggestion = [recoverySuggestion stringByAppendingFormat:@"\n\n%@", 306 NSLS(@"Try installing Flip4Mac WMV, a free QuickTime component that adds native support for the Windows Media file format.", 307 @"Error recovery suggestion")]; 308 309 [userInfo setObject:[NSArray arrayWithObjects: 310 NSLS(@"OK", @"Error button title"), 311 NSLS(@"Flip4Mac WMV Homepage", @"Error button title"), 312 NULL] 313 forKey:NSLocalizedRecoveryOptionsErrorKey]; 314 [userInfo setObject:self forKey:NSRecoveryAttempterErrorKey]; 315 [userInfo setObject:[WIURL URLWithString:@"http://www.flip4mac.com/wmv_download.htm"] forKey:SPRecoveryURLErrorKey]; 316 } 317 else if(![self _hasPerianInstalled]) { 266 318 recoverySuggestion = [recoverySuggestion stringByAppendingFormat:@"\n\n%@", 267 319 NSLS(@"Try installing Perian, a free QuickTime component that adds native support for many popular video formats.", … … 274 326 forKey:NSLocalizedRecoveryOptionsErrorKey]; 275 327 [userInfo setObject:self forKey:NSRecoveryAttempterErrorKey]; 328 [userInfo setObject:[WIURL URLWithString:@"http://www.perian.org/"] forKey:SPRecoveryURLErrorKey]; 276 329 } 277 330 … … 283 336 284 337 return error; 338 } 339 340 341 342 - (BOOL)attemptRecoveryFromError:(NSError *)error optionIndex:(NSUInteger)optionIndex { 343 if(optionIndex == 1) 344 [[NSWorkspace sharedWorkspace] openURL:[[[error userInfo] objectForKey:SPRecoveryURLErrorKey] URL]]; 345 346 return NO; 285 347 } 286 348 … … 560 622 if(!movie) { 561 623 if(error) { 562 if(![[controller movieController] isInFullscreen]) 624 if(![[controller movieController] isInFullscreen]) { 625 error = [error errorByAddingUserInfo: 626 [NSDictionary dictionaryWithObject:[url lastPathComponent] forKey:SPFilenameErrorKey]]; 627 563 628 [[NSDocumentController sharedDocumentController] presentError:error]; 629 } 564 630 } 565 631 … … 582 648 583 649 return YES; 584 }585 586 587 588 - (BOOL)hasPerianInstalled {589 NSString *libraryPath, *perianPath;590 BOOL hasPerian = NO;591 592 for(libraryPath in NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSAllDomainsMask, YES)) {593 perianPath = [libraryPath stringByAppendingPathComponent:@"QuickTime/Perian.component"];594 595 if([[NSFileManager defaultManager] fileExistsAtPath:perianPath]) {596 hasPerian = YES;597 598 break;599 }600 }601 602 return hasPerian;603 650 } 604 651
