1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-17 17:25:32 +00:00

more changes to make future porting to ARC easier

This commit is contained in:
Mitchell Livingston 2012-03-13 03:39:56 +00:00
parent 4252d0ca02
commit b6c2134338
4 changed files with 38 additions and 21 deletions

View file

@ -105,7 +105,9 @@ typedef enum
NSMutableDictionary * fPendingTorrentDownloads;
NSMutableSet * fAddingTransfers;
NSMutableSet * fAddWindows;
URLSheetWindowController * fUrlSheetController;
BOOL fGlobalPopoverShown;
BOOL fSoundPlaying;
@ -128,7 +130,6 @@ typedef enum
- (void) openURL: (NSString *) urlString;
- (void) openURLShowSheet: (id) sender;
- (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode;
- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;

View file

@ -752,6 +752,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
{
[download cancel];
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
if ([fPendingTorrentDownloads count] == 0)
{
[fPendingTorrentDownloads release];
fPendingTorrentDownloads = nil;
}
NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", "Download not a torrent -> title"),
[NSString stringWithFormat: NSLocalizedString(@"It appears that the file \"%@\" from %@ is not a torrent file.",
"Download not a torrent -> message"), suggestedName,
@ -767,11 +774,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
-(void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path
{
if (!fPendingTorrentDownloads)
fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
[fPendingTorrentDownloads setObject: [NSDictionary dictionaryWithObjectsAndKeys:
path, @"Path", download, @"Download", nil] forKey: [[download request] URL]];
[(NSMutableDictionary *)[fPendingTorrentDownloads objectForKey: [[download request] URL]] setObject: path forKey: @"Path"];
}
- (void) download: (NSURLDownload *) download didFailWithError: (NSError *) error
@ -1203,21 +1206,41 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: urlString]
cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval: 60];
[[NSURLDownload alloc] initWithRequest: request delegate: self];
if ([fPendingTorrentDownloads objectForKey: [request URL]])
{
NSLog(@"Already downloading %@", [request URL]);
return;
}
NSURLDownload * download = [[NSURLDownload alloc] initWithRequest: request delegate: self];
if (!fPendingTorrentDownloads)
fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
[fPendingTorrentDownloads setObject: [NSMutableDictionary dictionaryWithObject: download forKey: @"Download"] forKey: [request URL]];
}
}
- (void) openURLShowSheet: (id) sender
{
[[[URLSheetWindowController alloc] initWithController: self] beginSheetForWindow: fWindow];
if (!fUrlSheetController)
{
fUrlSheetController = [[URLSheetWindowController alloc] initWithController: self];
[NSApp beginSheet: [fUrlSheetController window] modalForWindow: fWindow modalDelegate: self didEndSelector: @selector(urlSheetDidEnd:returnCode:contextInfo:) contextInfo: nil];
}
}
- (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode
- (void) urlSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
{
if (returnCode == 1)
{
NSString * urlString = [fUrlSheetController urlString];
[self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
}
[controller release];
[fUrlSheetController release];
fUrlSheetController = nil;
}
- (void) createFile: (id) sender

View file

@ -36,9 +36,10 @@
}
- (id) initWithController: (Controller *) controller;
- (void) beginSheetForWindow: (NSWindow *) window;
- (void) openURLEndSheet: (id) sender;
- (void) openURLCancelEndSheet: (id) sender;
- (NSString *) urlString;
@end

View file

@ -80,12 +80,6 @@ NSString * urlString = nil;
[fCancelButton setFrame: cancelFrame];
}
- (IBAction) beginSheetForWindow: (NSWindow *) window
{
[NSApp beginSheet: [self window] modalForWindow: window modalDelegate: self
didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: nil];
}
- (void) openURLEndSheet: (id) sender
{
[[self window] orderOut: sender];
@ -98,11 +92,9 @@ NSString * urlString = nil;
[NSApp endSheet: [self window] returnCode: 0];
}
- (void) sheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
- (NSString *) urlString
{
[urlString release];
urlString = [[fTextField stringValue] retain];
[fController urlSheetDidEnd: self url: urlString returnCode: returnCode];
return [[[fTextField stringValue] retain] autorelease];
}
- (void) controlTextDidChange: (NSNotification *) notification