mirror of
https://github.com/transmission/transmission.git
synced 2025-12-24 04:18:39 +00:00
more changes to make future porting to ARC easier
This commit is contained in:
@@ -105,7 +105,9 @@ typedef enum
|
|||||||
NSMutableDictionary * fPendingTorrentDownloads;
|
NSMutableDictionary * fPendingTorrentDownloads;
|
||||||
|
|
||||||
NSMutableSet * fAddingTransfers;
|
NSMutableSet * fAddingTransfers;
|
||||||
|
|
||||||
NSMutableSet * fAddWindows;
|
NSMutableSet * fAddWindows;
|
||||||
|
URLSheetWindowController * fUrlSheetController;
|
||||||
|
|
||||||
BOOL fGlobalPopoverShown;
|
BOOL fGlobalPopoverShown;
|
||||||
BOOL fSoundPlaying;
|
BOOL fSoundPlaying;
|
||||||
@@ -128,7 +130,6 @@ typedef enum
|
|||||||
|
|
||||||
- (void) openURL: (NSString *) urlString;
|
- (void) openURL: (NSString *) urlString;
|
||||||
- (void) openURLShowSheet: (id) sender;
|
- (void) openURLShowSheet: (id) sender;
|
||||||
- (void) urlSheetDidEnd: (URLSheetWindowController *) controller url: (NSString *) urlString returnCode: (NSInteger) returnCode;
|
|
||||||
|
|
||||||
- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;
|
- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo;
|
||||||
|
|
||||||
|
|||||||
@@ -752,6 +752,13 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
|
|||||||
{
|
{
|
||||||
[download cancel];
|
[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"),
|
NSRunAlertPanel(NSLocalizedString(@"Torrent download failed", "Download not a torrent -> title"),
|
||||||
[NSString stringWithFormat: NSLocalizedString(@"It appears that the file \"%@\" from %@ is not a torrent file.",
|
[NSString stringWithFormat: NSLocalizedString(@"It appears that the file \"%@\" from %@ is not a torrent file.",
|
||||||
"Download not a torrent -> message"), suggestedName,
|
"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
|
-(void) download: (NSURLDownload *) download didCreateDestination: (NSString *) path
|
||||||
{
|
{
|
||||||
if (!fPendingTorrentDownloads)
|
[(NSMutableDictionary *)[fPendingTorrentDownloads objectForKey: [[download request] URL]] setObject: path forKey: @"Path"];
|
||||||
fPendingTorrentDownloads = [[NSMutableDictionary alloc] init];
|
|
||||||
|
|
||||||
[fPendingTorrentDownloads setObject: [NSDictionary dictionaryWithObjectsAndKeys:
|
|
||||||
path, @"Path", download, @"Download", nil] forKey: [[download request] URL]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) download: (NSURLDownload *) download didFailWithError: (NSError *) error
|
- (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]
|
NSURLRequest * request = [NSURLRequest requestWithURL: [NSURL URLWithString: urlString]
|
||||||
cachePolicy: NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval: 60];
|
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
|
- (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)
|
if (returnCode == 1)
|
||||||
|
{
|
||||||
|
NSString * urlString = [fUrlSheetController urlString];
|
||||||
[self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
|
[self performSelectorOnMainThread: @selector(openURL:) withObject: urlString waitUntilDone: NO];
|
||||||
|
}
|
||||||
|
|
||||||
[controller release];
|
[fUrlSheetController release];
|
||||||
|
fUrlSheetController = nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) createFile: (id) sender
|
- (void) createFile: (id) sender
|
||||||
|
|||||||
@@ -36,9 +36,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithController: (Controller *) controller;
|
- (id) initWithController: (Controller *) controller;
|
||||||
- (void) beginSheetForWindow: (NSWindow *) window;
|
|
||||||
|
|
||||||
- (void) openURLEndSheet: (id) sender;
|
- (void) openURLEndSheet: (id) sender;
|
||||||
- (void) openURLCancelEndSheet: (id) sender;
|
- (void) openURLCancelEndSheet: (id) sender;
|
||||||
|
|
||||||
|
- (NSString *) urlString;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -80,12 +80,6 @@ NSString * urlString = nil;
|
|||||||
[fCancelButton setFrame: cancelFrame];
|
[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
|
- (void) openURLEndSheet: (id) sender
|
||||||
{
|
{
|
||||||
[[self window] orderOut: sender];
|
[[self window] orderOut: sender];
|
||||||
@@ -98,11 +92,9 @@ NSString * urlString = nil;
|
|||||||
[NSApp endSheet: [self window] returnCode: 0];
|
[NSApp endSheet: [self window] returnCode: 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) sheetDidEnd: (NSWindow *) sheet returnCode: (NSInteger) returnCode contextInfo: (void *) contextInfo
|
- (NSString *) urlString
|
||||||
{
|
{
|
||||||
[urlString release];
|
return [[[fTextField stringValue] retain] autorelease];
|
||||||
urlString = [[fTextField stringValue] retain];
|
|
||||||
[fController urlSheetDidEnd: self url: urlString returnCode: returnCode];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) controlTextDidChange: (NSNotification *) notification
|
- (void) controlTextDidChange: (NSNotification *) notification
|
||||||
|
|||||||
Reference in New Issue
Block a user