Guest User

Untitled

a guest
Jul 14th, 2018
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. //
  2. // FMDQueueItem.m
  3. // Free Mac Downloader
  4. //
  5. // Created by Diego Massanti on 9/23/09.
  6. // Copyright 2009 PlusMedia de Argentina LLC. All rights reserved.
  7. //
  8.  
  9. #import "FMDQueueItem.h"
  10.  
  11.  
  12. @implementation FMDQueueItem
  13.  
  14. @class FMDHeaders;
  15.  
  16. @synthesize itemURL, itemPassword, itemUserName, itemName, itemStatus, itemIcon, itemStatusImage, itemHTTPHeaders;
  17.  
  18. - (id) initWithURL:(NSURL*)theURL
  19. {
  20. self = [super init];
  21. if (self != nil) {
  22. DLog(@"FMDQueueItem initialized for URL %@", [theURL absoluteString]);
  23. itemURL = theURL;
  24. [self setItemName:[theURL lastPathComponent]];
  25. // Set Item representative icon
  26. [self setItemIcon:[[NSWorkspace sharedWorkspace]iconForFileType:[[self itemName]pathExtension]]];
  27.  
  28. FMDHeadersOperation * headersOp = [[FMDHeadersOperation alloc]initWithURL:self.itemURL];
  29.  
  30. [self addDependency:headersOp];
  31. [headersOp release];
  32. [headersOp addObserver:self
  33. forKeyPath:@"isFinished"
  34. options:NSKeyValueObservingOptionNew
  35. context:NULL];
  36. [headersOp setPassword:self.itemPassword];
  37. [headersOp setUserName:self.itemUserName];
  38.  
  39. [headersOp setUserName:self.itemUserName andPassword:self.itemPassword];
  40. }
  41. return self;
  42. }
  43.  
  44. - (void)main
  45. {
  46. DLog(@"Queue Item main method called");
  47. }
  48.  
  49.  
  50.  
  51.  
  52. #pragma mark -
  53. #pragma mark KVO Observers
  54.  
  55. - (void)observeValueForKeyPath:(NSString *)keyPath
  56. ofObject:(id)object
  57. change:(NSDictionary *)change
  58. context:(void *)context
  59. {
  60. if ([keyPath isEqual:@"isFinished"]) {
  61. if ([[change valueForKey:NSKeyValueChangeNewKey]boolValue] == YES) {
  62. FMDHeadersOperation * headersOperation = object;
  63. DLog(@"Dependency finished");
  64. [self setItemHTTPHeaders:headersOperation.headers];
  65. [headersOperation release];
  66. [self start];
  67. }
  68.  
  69.  
  70. }
  71.  
  72. }
  73.  
  74. @end
Add Comment
Please, Sign In to add comment