Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // FMDQueueItem.m
- // Free Mac Downloader
- //
- // Created by Diego Massanti on 9/23/09.
- // Copyright 2009 PlusMedia de Argentina LLC. All rights reserved.
- //
- #import "FMDQueueItem.h"
- @implementation FMDQueueItem
- @class FMDHeaders;
- @synthesize itemURL, itemPassword, itemUserName, itemName, itemStatus, itemIcon, itemStatusImage, itemHTTPHeaders;
- - (id) initWithURL:(NSURL*)theURL
- {
- self = [super init];
- if (self != nil) {
- DLog(@"FMDQueueItem initialized for URL %@", [theURL absoluteString]);
- itemURL = theURL;
- [self setItemName:[theURL lastPathComponent]];
- // Set Item representative icon
- [self setItemIcon:[[NSWorkspace sharedWorkspace]iconForFileType:[[self itemName]pathExtension]]];
- FMDHeadersOperation * headersOp = [[FMDHeadersOperation alloc]initWithURL:self.itemURL];
- [self addDependency:headersOp];
- [headersOp release];
- [headersOp addObserver:self
- forKeyPath:@"isFinished"
- options:NSKeyValueObservingOptionNew
- context:NULL];
- [headersOp setPassword:self.itemPassword];
- [headersOp setUserName:self.itemUserName];
- [headersOp setUserName:self.itemUserName andPassword:self.itemPassword];
- }
- return self;
- }
- - (void)main
- {
- DLog(@"Queue Item main method called");
- }
- #pragma mark -
- #pragma mark KVO Observers
- - (void)observeValueForKeyPath:(NSString *)keyPath
- ofObject:(id)object
- change:(NSDictionary *)change
- context:(void *)context
- {
- if ([keyPath isEqual:@"isFinished"]) {
- if ([[change valueForKey:NSKeyValueChangeNewKey]boolValue] == YES) {
- FMDHeadersOperation * headersOperation = object;
- DLog(@"Dependency finished");
- [self setItemHTTPHeaders:headersOperation.headers];
- [headersOperation release];
- [self start];
- }
- }
- }
- @end
Add Comment
Please, Sign In to add comment