improving to adding url's
This commit is contained in:
parent
faa173ecd2
commit
6c09899704
|
@ -409,6 +409,16 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
|
|
||||||
- (void) applicationWillTerminate: (NSNotification *) notification
|
- (void) applicationWillTerminate: (NSNotification *) notification
|
||||||
{
|
{
|
||||||
|
//remove all torrent downloads
|
||||||
|
NSEnumerator * enumerator = [[fPendingTorrentDownloads allValues] objectEnumerator];
|
||||||
|
NSURLDownload * download;
|
||||||
|
while ((download = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
[download cancel];
|
||||||
|
[download release];
|
||||||
|
}
|
||||||
|
[fPendingTorrentDownloads removeAllObjects];
|
||||||
|
|
||||||
//stop timers
|
//stop timers
|
||||||
[fSpeedLimitTimer invalidate];
|
[fSpeedLimitTimer invalidate];
|
||||||
[fTimer invalidate];
|
[fTimer invalidate];
|
||||||
|
@ -437,7 +447,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
NSDate * start = [NSDate date];
|
NSDate * start = [NSDate date];
|
||||||
BOOL timeUp = NO;
|
BOOL timeUp = NO;
|
||||||
|
|
||||||
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
enumerator = [fTorrents objectEnumerator];
|
||||||
Torrent * torrent;
|
Torrent * torrent;
|
||||||
while (!timeUp && ((torrent = [enumerator nextObject]) || tr_natTraversalStatus(fLib) != TR_NAT_TRAVERSAL_DISABLED))
|
while (!timeUp && ((torrent = [enumerator nextObject]) || tr_natTraversalStatus(fLib) != TR_NAT_TRAVERSAL_DISABLED))
|
||||||
while (![torrent isPaused] && !(timeUp = [start timeIntervalSinceNow] < -5.0))
|
while (![torrent isPaused] && !(timeUp = [start timeIntervalSinceNow] < -5.0))
|
||||||
|
@ -478,25 +488,25 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
delegate: self];
|
delegate: self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) download: (NSURLDownload *) download didReceiveResponse: (NSURLResponse *) response
|
- (void) download: (NSURLDownload *) download decideDestinationWithSuggestedFilename: (NSString *) suggestedName
|
||||||
{
|
{
|
||||||
NSString * suggestedName = [response suggestedFilename];
|
|
||||||
|
|
||||||
if ([[suggestedName pathExtension] caseInsensitiveCompare: @"torrent"] != NSOrderedSame)
|
if ([[suggestedName pathExtension] caseInsensitiveCompare: @"torrent"] != NSOrderedSame)
|
||||||
{
|
{
|
||||||
|
[download cancel];
|
||||||
|
|
||||||
NSRunAlertPanel(NSLocalizedString(@"Torrent download failed",
|
NSRunAlertPanel(NSLocalizedString(@"Torrent download failed",
|
||||||
@"Download not a torrent -> title"), [NSString stringWithFormat:
|
@"Download not a torrent -> title"), [NSString stringWithFormat:
|
||||||
NSLocalizedString(@"It appears that the file from %@ is not a torrent file",
|
NSLocalizedString(@"It appears that the file from %@ is not a torrent file",
|
||||||
@"Download not a torrent -> message"), [[[download request] URL] absoluteString]],
|
@"Download not a torrent -> message"), [[[download request] URL] absoluteString]],
|
||||||
NSLocalizedString(@"OK", @"Download not a torrent -> button"), nil, nil);
|
NSLocalizedString(@"OK", @"Download not a torrent -> button"), nil, nil);
|
||||||
|
|
||||||
[download cancel];
|
[download release];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSString * path = [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]];
|
NSString * path = [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]];
|
||||||
[download setDestination: path allowOverwrite: NO];
|
[download setDestination: path allowOverwrite: NO];
|
||||||
[fPendingTorrentDownloads setObject: path forKey: [[download request] URL]];
|
[fPendingTorrentDownloads setObject: download forKey: [[download request] URL]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,6 +519,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
[error localizedDescription]], NSLocalizedString(@"OK", @"Torrent download failed -> button"), nil, nil);
|
[error localizedDescription]], NSLocalizedString(@"OK", @"Torrent download failed -> button"), nil, nil);
|
||||||
|
|
||||||
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
|
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
|
||||||
|
[download release];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) downloadDidFinish: (NSURLDownload *) download
|
- (void) downloadDidFinish: (NSURLDownload *) download
|
||||||
|
@ -518,6 +529,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||||
ignoreDownloadFolder: NO];
|
ignoreDownloadFolder: NO];
|
||||||
|
|
||||||
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
|
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
|
||||||
|
[download release];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore
|
- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore
|
||||||
|
|
Loading…
Reference in New Issue