Changeset 1083 for trunk/macosx


Ignore:
Timestamp:
Nov 13, 2006, 12:12:58 AM (15 years ago)
Author:
livings124
Message:

improving to adding url's

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r1082 r1083  
    410410- (void) applicationWillTerminate: (NSNotification *) notification
    411411{
     412    //remove all torrent downloads
     413    NSEnumerator * enumerator = [[fPendingTorrentDownloads allValues] objectEnumerator];
     414    NSURLDownload * download;
     415    while ((download = [enumerator nextObject]))
     416    {
     417        [download cancel];
     418        [download release];
     419    }
     420    [fPendingTorrentDownloads removeAllObjects];
     421   
    412422    //stop timers
    413423    [fSpeedLimitTimer invalidate];
     
    438448    BOOL timeUp = NO;
    439449   
    440     NSEnumerator * enumerator = [fTorrents objectEnumerator];
     450    enumerator = [fTorrents objectEnumerator];
    441451    Torrent * torrent;
    442452    while (!timeUp && ((torrent = [enumerator nextObject]) || tr_natTraversalStatus(fLib) != TR_NAT_TRAVERSAL_DISABLED))
     
    479489}
    480490
    481 - (void) download: (NSURLDownload *) download didReceiveResponse: (NSURLResponse *) response
    482 {
    483     NSString * suggestedName = [response suggestedFilename];
    484    
     491- (void) download: (NSURLDownload *) download decideDestinationWithSuggestedFilename: (NSString *) suggestedName
     492{
    485493    if ([[suggestedName pathExtension] caseInsensitiveCompare: @"torrent"] != NSOrderedSame)
    486494    {
     495        [download cancel];
     496       
    487497        NSRunAlertPanel(NSLocalizedString(@"Torrent download failed",
    488498            @"Download not a torrent -> title"), [NSString stringWithFormat:
     
    491501            NSLocalizedString(@"OK", @"Download not a torrent -> button"), nil, nil);
    492502       
    493         [download cancel];
     503        [download release];
    494504    }
    495505    else
     
    497507        NSString * path = [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]];
    498508        [download setDestination: path allowOverwrite: NO];
    499         [fPendingTorrentDownloads setObject: path forKey: [[download request] URL]];
     509        [fPendingTorrentDownloads setObject: download forKey: [[download request] URL]];
    500510    }
    501511}
     
    510520   
    511521    [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
     522    [download release];
    512523}
    513524
     
    519530   
    520531    [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
     532    [download release];
    521533}
    522534
Note: See TracChangeset for help on using the changeset viewer.