mirror of
https://github.com/transmission/transmission
synced 2025-02-20 13:16:53 +00:00
No choice but to delete the torrent file when adding when adding with url.
This commit is contained in:
parent
6c09899704
commit
c97aa2b55a
4 changed files with 41 additions and 33 deletions
|
@ -94,11 +94,12 @@
|
|||
NSMutableDictionary * fPendingTorrentDownloads;
|
||||
}
|
||||
|
||||
- (void) openFiles: (NSArray *) filenames;
|
||||
- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore;
|
||||
- (void) openFilesAsk: (NSMutableArray *) files;
|
||||
- (void) openShowSheet: (id) sender;
|
||||
- (void) openURL: (NSURL *) torrentURL;
|
||||
- (void) openFiles: (NSArray *) filenames;
|
||||
- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore forceDeleteTorrent: (BOOL) delete;
|
||||
- (void) openFilesAsk: (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete;
|
||||
- (void) openFilesAskWithDict: (NSDictionary *) dictionary;
|
||||
- (void) openShowSheet: (id) sender;
|
||||
- (void) openURL: (NSURL *) torrentURL;
|
||||
|
||||
- (void) quitSheetDidEnd: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo;
|
||||
|
||||
|
|
|
@ -353,7 +353,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
- (void) applicationDidFinishLaunching: (NSNotification *) notification
|
||||
{
|
||||
[NSApp setServicesProvider:self];
|
||||
[NSApp setServicesProvider: self];
|
||||
|
||||
//register for dock icon drags
|
||||
[[NSAppleEventManager sharedAppleEventManager] setEventHandler: self
|
||||
|
@ -411,9 +411,11 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
{
|
||||
//remove all torrent downloads
|
||||
NSEnumerator * enumerator = [[fPendingTorrentDownloads allValues] objectEnumerator];
|
||||
NSDictionary * downloadDict;
|
||||
NSURLDownload * download;
|
||||
while ((download = [enumerator nextObject]))
|
||||
while ((downloadDict = [enumerator nextObject]))
|
||||
{
|
||||
download = [downloadDict objectForKey: @"Download"];
|
||||
[download cancel];
|
||||
[download release];
|
||||
}
|
||||
|
@ -457,11 +459,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
}
|
||||
}
|
||||
|
||||
- (void) application: (NSApplication *) sender openFiles: (NSArray *) filenames
|
||||
{
|
||||
[self openFiles: filenames ignoreDownloadFolder: NO];
|
||||
}
|
||||
|
||||
- (void) handleOpenContentsEvent: (NSAppleEventDescriptor *) event replyEvent: (NSAppleEventDescriptor *) replyEvent
|
||||
{
|
||||
NSString * urlString;
|
||||
|
@ -483,7 +480,6 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
- (void) openURL: (NSURL *) url
|
||||
{
|
||||
#warning remove when quitting
|
||||
NSURLDownload * torrentDownload = [[NSURLDownload alloc] initWithRequest: [NSURLRequest requestWithURL: url]
|
||||
delegate: self];
|
||||
}
|
||||
|
@ -506,7 +502,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
{
|
||||
NSString * path = [NSTemporaryDirectory() stringByAppendingPathComponent: [suggestedName lastPathComponent]];
|
||||
[download setDestination: path allowOverwrite: NO];
|
||||
[fPendingTorrentDownloads setObject: download forKey: [[download request] URL]];
|
||||
[fPendingTorrentDownloads setObject: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||
path, @"Path", download, @"Download", nil] forKey: [[download request] URL]];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -525,19 +522,24 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
- (void) downloadDidFinish: (NSURLDownload *) download
|
||||
{
|
||||
#warning try to open, if not delete
|
||||
[self openFiles: [NSArray arrayWithObject: [fPendingTorrentDownloads objectForKey: [[download request] URL]]]
|
||||
ignoreDownloadFolder: NO];
|
||||
[self openFiles: [NSArray arrayWithObject: [[fPendingTorrentDownloads objectForKey:
|
||||
[[download request] URL]] objectForKey: @"Path"]] ignoreDownloadFolder: NO forceDeleteTorrent: YES];
|
||||
|
||||
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
|
||||
[download release];
|
||||
}
|
||||
|
||||
- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore
|
||||
- (void) application: (NSApplication *) sender openFiles: (NSArray *) filenames
|
||||
{
|
||||
[self openFiles: filenames ignoreDownloadFolder: NO forceDeleteTorrent: NO];
|
||||
}
|
||||
|
||||
- (void) openFiles: (NSArray *) filenames ignoreDownloadFolder: (BOOL) ignore forceDeleteTorrent: (BOOL) delete
|
||||
{
|
||||
NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
|
||||
if (ignore || [downloadChoice isEqualToString: @"Ask"])
|
||||
{
|
||||
[self openFilesAsk: [filenames mutableCopy]];
|
||||
[self openFilesAsk: [filenames mutableCopy] forceDeleteTorrent: delete];
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -546,7 +548,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
NSEnumerator * enumerator = [filenames objectEnumerator];
|
||||
while ((torrentPath = [enumerator nextObject]))
|
||||
{
|
||||
if (!(torrent = [[Torrent alloc] initWithPath: torrentPath lib: fLib]))
|
||||
if (!(torrent = [[Torrent alloc] initWithPath: torrentPath forceDeleteTorrent: delete lib: fLib]))
|
||||
continue;
|
||||
|
||||
//add it to the "File > Open Recent" menu
|
||||
|
@ -571,7 +573,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
}
|
||||
|
||||
//called by the main open method to show sheet for choosing download location
|
||||
- (void) openFilesAsk: (NSMutableArray *) files
|
||||
- (void) openFilesAsk: (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete
|
||||
{
|
||||
NSString * torrentPath;
|
||||
Torrent * torrent;
|
||||
|
@ -588,7 +590,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
}
|
||||
|
||||
torrentPath = [files objectAtIndex: 0];
|
||||
torrent = [[Torrent alloc] initWithPath: torrentPath lib: fLib];
|
||||
torrent = [[Torrent alloc] initWithPath: torrentPath forceDeleteTorrent: delete lib: fLib];
|
||||
|
||||
[files removeObjectAtIndex: 0];
|
||||
} while (!torrent);
|
||||
|
@ -606,14 +608,15 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the download folder for \"%@\"",
|
||||
"Open torrent -> select destination folder"), [torrent name]]];
|
||||
|
||||
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrent, @"Torrent", files, @"Files", nil];
|
||||
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: torrent, @"Torrent", files, @"Files",
|
||||
[NSNumber numberWithBool: delete], @"Delete", nil];
|
||||
|
||||
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
|
||||
didEndSelector: @selector(folderChoiceClosed:returnCode:contextInfo:) contextInfo: dictionary];
|
||||
[torrent release];
|
||||
}
|
||||
|
||||
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code
|
||||
contextInfo: (NSDictionary *) dictionary
|
||||
- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (NSDictionary *) dictionary
|
||||
{
|
||||
Torrent * torrent = [dictionary objectForKey: @"Torrent"];
|
||||
|
||||
|
@ -629,10 +632,13 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[self applyFilter: nil];
|
||||
}
|
||||
|
||||
[self performSelectorOnMainThread: @selector(openFilesAsk:) withObject: [dictionary objectForKey: @"Files"]
|
||||
waitUntilDone: NO];
|
||||
|
||||
[torrent release];
|
||||
[self performSelectorOnMainThread: @selector(openFilesAskWithDict:) withObject: dictionary waitUntilDone: NO];
|
||||
}
|
||||
|
||||
- (void) openFilesAskWithDict: (NSDictionary *) dictionary
|
||||
{
|
||||
[self openFilesAsk: [dictionary objectForKey: @"Files"]
|
||||
forceDeleteTorrent: [[dictionary objectForKey: @"Delete"] boolValue]];
|
||||
[dictionary release];
|
||||
}
|
||||
|
||||
|
@ -644,7 +650,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
- (void) openFiles: (NSArray *) filenames
|
||||
{
|
||||
[self openFiles: filenames ignoreDownloadFolder: NO];
|
||||
[self openFiles: filenames ignoreDownloadFolder: NO forceDeleteTorrent: NO];
|
||||
}
|
||||
|
||||
- (void) openShowSheet: (id) sender
|
||||
|
@ -673,7 +679,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
- (void) openFromSheet: (NSDictionary *) dictionary
|
||||
{
|
||||
[self openFiles: [dictionary objectForKey: @"Files"]
|
||||
ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue]];
|
||||
ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue] forceDeleteTorrent: NO];
|
||||
|
||||
[dictionary release];
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
int8_t * fPieces;
|
||||
}
|
||||
|
||||
- (id) initWithPath: (NSString *) path lib: (tr_handle_t *) lib;
|
||||
- (id) initWithPath: (NSString *) path forceDeleteTorrent: (BOOL) delete lib: (tr_handle_t *) lib;
|
||||
- (id) initWithHistory: (NSDictionary *) history lib: (tr_handle_t *) lib;
|
||||
|
||||
- (NSDictionary *) history;
|
||||
|
|
|
@ -58,9 +58,10 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
|||
kGreen3 = BE(0x00FF66FF), //0, 255, 102
|
||||
kWhite = BE(0xFFFFFFFF); //255, 255, 255
|
||||
|
||||
- (id) initWithPath: (NSString *) path lib: (tr_handle_t *) lib
|
||||
- (id) initWithPath: (NSString *) path forceDeleteTorrent: (BOOL) delete lib: (tr_handle_t *) lib
|
||||
{
|
||||
self = [self initWithHash: nil path: path lib: lib publicTorrent: nil
|
||||
self = [self initWithHash: nil path: path lib: lib
|
||||
publicTorrent: delete ? [NSNumber numberWithBool: NO] : nil
|
||||
date: nil stopRatioSetting: nil ratioLimit: nil waitToStart: nil orderValue: nil];
|
||||
|
||||
if (self)
|
||||
|
|
Loading…
Reference in a new issue