blob: 5fb1085b74fcfdeeedcd8c79c02b96bc0e19709c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
//
// DownloadManager.m
// Liaison
//
// Created by Brian Cully on Wed Jun 04 2003.
// Copyright (c) 2003 Brian Cully. All rights reserved.
//
#import "DownloadManager.h"
#import "Downloader.h"
@implementation DownloadManager
DownloadManager *defaultManager = nil;
+ (DownloadManager *)defaultManager
{
if (defaultManager == nil)
defaultManager = [[DownloadManager alloc] init];
return defaultManager;
}
- (id)init
{
self = [super init];
[self setDownloads: [NSMutableDictionary dictionary]];
return self;
}
- (void)dealloc
{
[self setDownloads: nil];
[super dealloc];
}
- (void)downloadFileHandle: (LiFileHandle *)aFileHandle
fromSocket: (NSFileHandle *)aSocket
target: (id)anObject
didFinishSelector: (SEL)aSelector
withContext: (void *)someContext
{
Downloader *downloader;
downloader = [[Downloader alloc] initWithSocket: aSocket
target: anObject
selector: aSelector
context: someContext];
[[self downloads] setObject: downloader forKey: aFileHandle];
[downloader downloadFileHandle: aFileHandle];
[downloader release];
}
@synthesize theDownloads;
@end
@implementation DownloadManager (Accessors)
- (NSMutableDictionary *)downloads
{
return theDownloads;
}
- (void)setDownloads: (NSMutableDictionary *)someDownloads
{
[someDownloads retain];
[theDownloads release];
theDownloads = someDownloads;
}
@end
|