Changeset 13254


Ignore:
Timestamp:
Mar 13, 2012, 3:39:56 AM (9 years ago)
Author:
livings124
Message:

more changes to make future porting to ARC easier

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.h

    r13253 r13254  
    106106   
    107107    NSMutableSet                    * fAddingTransfers;
     108   
    108109    NSMutableSet                    * fAddWindows;
     110    URLSheetWindowController        * fUrlSheetController;
    109111   
    110112    BOOL                            fGlobalPopoverShown;
     
    129131- (void) openURL: (NSString *) urlString;
    130132- (void) openURLShowSheet: (id) sender;
    131 - (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode;
    132133
    133134- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;
  • trunk/macosx/Controller.m

    r13253 r13254  
    753753        [download cancel];
    754754       
     755        [fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
     756        if ([fPendingTorrentDownloads count] == 0)
     757        {
     758            [fPendingTorrentDownloads release];
     759            fPendingTorrentDownloads = nil;
     760        }
     761       
    755762        NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", "Download not a torrent -> title"),
    756763            [NSString stringWithFormat: NSLocalizedString(@"It appears that the file \"%@\" from %@ is not a torrent file.",
     
    768775-(void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path
    769776{
    770     if (!fPendingTorrentDownloads)
    771         fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
    772    
    773     [fPendingTorrentDownloads setObject: [NSDictionary dictionaryWithObjectsAndKeys:
    774                     path, @"Path", download, @"Download", nil] forKey: [[download request] URL]];
     777    [(NSMutableDictionary *)[fPendingTorrentDownloads objectForKey: [[download request] URL]] setObject: path forKey: @"Path"];
    775778}
    776779
     
    12041207        NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: urlString]
    12051208                                    cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval: 60];
    1206         [[NSURLDownload alloc] initWithRequest: request delegate: self];
     1209       
     1210        if ([fPendingTorrentDownloads objectForKey: [request URL]])
     1211        {
     1212            NSLog(@"Already downloading %@", [request URL]);
     1213            return;
     1214        }
     1215       
     1216        NSURLDownload * download = [[NSURLDownload alloc] initWithRequest: request delegate: self];
     1217       
     1218        if (!fPendingTorrentDownloads)
     1219            fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
     1220        [fPendingTorrentDownloads setObject: [NSMutableDictionary dictionaryWithObject: download forKey: @"Download"] forKey: [request URL]];
    12071221    }
    12081222}
     
    12101224- (void) openURLShowSheet: (id) sender
    12111225{
    1212     [[[URLSheetWindowController alloc] initWithController: self] beginSheetForWindow: fWindow];
    1213 }
    1214 
    1215 - (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode
     1226    if (!fUrlSheetController)
     1227    {
     1228        fUrlSheetController = [[URLSheetWindowController alloc] initWithController: self];
     1229   
     1230        [NSApp beginSheet: [fUrlSheetController window] modalForWindow: fWindow modalDelegate: self didEndSelector: @selector(urlSheetDidEnd:returnCode:contextInfo:) contextInfo: nil];
     1231    }
     1232}
     1233
     1234- (void) urlSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
    12161235{
    12171236    if (returnCode == 1)
     1237    {
     1238        NSString * urlString = [fUrlSheetController urlString];
    12181239        [self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
    1219    
    1220     [controller release];
     1240    }
     1241   
     1242    [fUrlSheetController release];
     1243    fUrlSheetController = nil;
    12211244}
    12221245
  • trunk/macosx/URLSheetWindowController.h

    r13251 r13254  
    3737
    3838- (id) initWithController: (Controller *) controller;
    39 - (void) beginSheetForWindow: (NSWindow *) window;
    4039
    4140- (void) openURLEndSheet: (id) sender;
    4241- (void) openURLCancelEndSheet: (id) sender;
    4342
     43- (NSString *) urlString;
     44
    4445@end
  • trunk/macosx/URLSheetWindowController.m

    r13251 r13254  
    8181}
    8282
    83 - (IBAction) beginSheetForWindow: (NSWindow *) window
    84 {
    85     [NSApp beginSheet: [self window] modalForWindow: window modalDelegate: self
    86         didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: nil];
    87 }
    88 
    8983- (void) openURLEndSheet: (id) sender
    9084{
     
    9993}
    10094
    101 - (void) sheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
     95- (NSString *) urlString
    10296{
    103     [urlString release];
    104     urlString = [[fTextField stringValue] retain];
    105     [fController urlSheetDidEnd: self url: urlString returnCode: returnCode];
     97    return [[[fTextField stringValue] retain] autorelease];
    10698}
    10799
Note: See TracChangeset for help on using the changeset viewer.