mirror of
https://github.com/transmission/transmission.git
synced 2026-05-08 09:39:08 +01:00
(trunk) when automatically opening a newly created torrent file, don't trash it regardless of prefs setting
This commit is contained in:
+2
-2
@@ -106,10 +106,10 @@
|
||||
|
||||
- (void) openFiles: (NSArray *) filenames;
|
||||
- (void) openFiles: (NSArray *) filenames forcePath: (NSString *) path ignoreDownloadFolder: (BOOL) ignore
|
||||
forceDeleteTorrent: (BOOL) delete;
|
||||
deleteTorrentFile: (torrentFileState) deleteTorrent;
|
||||
- (void) openCreatedFile: (NSNotification *) notification;
|
||||
- (void) openFilesWithDict: (NSDictionary *) dictionary;
|
||||
- (void) openFilesAsk: (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete;
|
||||
- (void) openFilesAsk: (NSMutableArray *) files deleteTorrentFile: (torrentFileState) deleteTorrent;
|
||||
- (void) openFilesAskWithDict: (NSDictionary *) dictionary;
|
||||
- (void) openShowSheet: (id) sender;
|
||||
|
||||
|
||||
+17
-17
@@ -660,7 +660,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
NSString * path = [[fPendingTorrentDownloads objectForKey: [[download request] URL]] objectForKey: @"Path"];
|
||||
|
||||
[self openFiles: [NSArray arrayWithObject: path] forcePath: nil ignoreDownloadFolder:
|
||||
![[fDefaults stringForKey: @"DownloadChoice"] isEqualToString: @"Constant"] forceDeleteTorrent: YES];
|
||||
![[fDefaults stringForKey: @"DownloadChoice"] isEqualToString: @"Constant"] deleteTorrentFile: TORRENT_FILE_DELETE];
|
||||
|
||||
[fPendingTorrentDownloads removeObjectForKey: [[download request] URL]];
|
||||
[download release];
|
||||
@@ -673,16 +673,16 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
|
||||
- (void) application: (NSApplication *) app openFiles: (NSArray *) filenames
|
||||
{
|
||||
[self openFiles: filenames forcePath: nil ignoreDownloadFolder: NO forceDeleteTorrent: NO];
|
||||
[self openFiles: filenames forcePath: nil ignoreDownloadFolder: NO deleteTorrentFile: TORRENT_FILE_DEFAULT];
|
||||
}
|
||||
|
||||
- (void) openFiles: (NSArray *) filenames forcePath: (NSString *) path ignoreDownloadFolder: (BOOL) ignore
|
||||
forceDeleteTorrent: (BOOL) delete
|
||||
deleteTorrentFile: (torrentFileState) deleteTorrent
|
||||
{
|
||||
NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
|
||||
if (ignore || (!path && [downloadChoice isEqualToString: @"Ask"]))
|
||||
{
|
||||
[self openFilesAsk: [filenames mutableCopy] forceDeleteTorrent: delete];
|
||||
[self openFilesAsk: [filenames mutableCopy] deleteTorrentFile: deleteTorrent];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -704,7 +704,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
filenames, @"Filenames",
|
||||
[NSNumber numberWithBool: ignore], @"Ignore",
|
||||
[NSNumber numberWithBool: delete], @"Delete", nil];
|
||||
[NSNumber numberWithInt: deleteTorrent], @"DeleteTorrent", nil];
|
||||
|
||||
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
|
||||
didEndSelector: @selector(incompleteChoiceClosed:returnCode:contextInfo:) contextInfo: dict];
|
||||
@@ -727,7 +727,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||
filenames, @"Filenames",
|
||||
[NSNumber numberWithBool: ignore], @"Ignore",
|
||||
[NSNumber numberWithBool: delete], @"Delete", nil];
|
||||
[NSNumber numberWithInt: deleteTorrent], @"DeleteTorrent", nil];
|
||||
|
||||
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
|
||||
didEndSelector: @selector(downloadChoiceClosed:returnCode:contextInfo:) contextInfo: dict];
|
||||
@@ -756,7 +756,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
}
|
||||
tr_metainfoFree(&info);
|
||||
|
||||
if (!(torrent = [[Torrent alloc] initWithPath: torrentPath location: location forceDeleteTorrent: delete lib: fLib]))
|
||||
if (!(torrent = [[Torrent alloc] initWithPath: torrentPath location: location deleteTorrentFile: deleteTorrent lib: fLib]))
|
||||
continue;
|
||||
|
||||
//add it to the "File > Open Recent" menu
|
||||
@@ -770,12 +770,11 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
[self updateTorrentsInQueue];
|
||||
}
|
||||
|
||||
#warning forceDeleteTorrent - make NOT delete
|
||||
- (void) openCreatedFile: (NSNotification *) notification
|
||||
{
|
||||
NSDictionary * dict = [notification userInfo];
|
||||
[self openFiles: [NSArray arrayWithObject: [dict objectForKey: @"File"]] forcePath: [dict objectForKey: @"Path"]
|
||||
ignoreDownloadFolder: NO forceDeleteTorrent: NO];
|
||||
ignoreDownloadFolder: NO deleteTorrentFile: TORRENT_FILE_SAVE];
|
||||
[dict release];
|
||||
}
|
||||
|
||||
@@ -804,13 +803,13 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
{
|
||||
[self openFiles: [dictionary objectForKey: @"Filenames"] forcePath: nil
|
||||
ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue]
|
||||
forceDeleteTorrent: [[dictionary objectForKey: @"Delete"] boolValue]];
|
||||
deleteTorrentFile: [[dictionary objectForKey: @"DeleteTorrent"] intValue]];
|
||||
|
||||
[dictionary release];
|
||||
}
|
||||
|
||||
//called by the main open method to show sheet for choosing download location
|
||||
- (void) openFilesAsk: (NSMutableArray *) files forceDeleteTorrent: (BOOL) delete
|
||||
- (void) openFilesAsk: (NSMutableArray *) files deleteTorrentFile: (torrentFileState) deleteTorrent
|
||||
{
|
||||
//determine the next file that can be opened
|
||||
NSString * torrentPath;
|
||||
@@ -851,7 +850,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
"Open torrent -> select destination folder"), [NSString stringWithUTF8String: info.name]]];
|
||||
|
||||
NSDictionary * dictionary = [[NSDictionary alloc] initWithObjectsAndKeys: [torrentPath retain], @"Path",
|
||||
files, @"Files", [NSNumber numberWithBool: delete], @"Delete", nil];
|
||||
files, @"Files", [NSNumber numberWithInt: deleteTorrent], @"DeleteTorrent", nil];
|
||||
tr_metainfoFree(&info);
|
||||
|
||||
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: fWindow modalDelegate: self
|
||||
@@ -864,7 +863,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
{
|
||||
NSString * torrentPath = [dictionary objectForKey: @"Path"];
|
||||
Torrent * torrent = [[Torrent alloc] initWithPath: torrentPath location: [[openPanel filenames] objectAtIndex: 0]
|
||||
forceDeleteTorrent: [[dictionary objectForKey: @"Delete"] boolValue] lib: fLib];
|
||||
deleteTorrentFile: [[dictionary objectForKey: @"DeleteTorrent"] intValue] lib: fLib];
|
||||
|
||||
//add it to the "File > Open Recent" menu
|
||||
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
|
||||
@@ -882,7 +881,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
- (void) openFilesAskWithDict: (NSDictionary *) dictionary
|
||||
{
|
||||
[self openFilesAsk: [dictionary objectForKey: @"Files"]
|
||||
forceDeleteTorrent: [[dictionary objectForKey: @"Delete"] boolValue]];
|
||||
deleteTorrentFile: [[dictionary objectForKey: @"DeleteTorrent"] intValue]];
|
||||
[dictionary release];
|
||||
}
|
||||
|
||||
@@ -894,7 +893,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
|
||||
- (void) openFiles: (NSArray *) filenames
|
||||
{
|
||||
[self openFiles: filenames forcePath: nil ignoreDownloadFolder: NO forceDeleteTorrent: NO];
|
||||
[self openFiles: filenames forcePath: nil ignoreDownloadFolder: NO deleteTorrentFile: TORRENT_FILE_DEFAULT];
|
||||
}
|
||||
|
||||
- (void) openShowSheet: (id) sender
|
||||
@@ -923,7 +922,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
- (void) openFromSheet: (NSDictionary *) dictionary
|
||||
{
|
||||
[self openFiles: [dictionary objectForKey: @"Files"] forcePath: nil
|
||||
ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue] forceDeleteTorrent: NO];
|
||||
ignoreDownloadFolder: [[dictionary objectForKey: @"Ignore"] boolValue] deleteTorrentFile: TORRENT_FILE_DEFAULT];
|
||||
|
||||
[dictionary release];
|
||||
}
|
||||
@@ -3239,7 +3238,8 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
||||
{
|
||||
int oldCount = [fTorrents count];
|
||||
|
||||
[self openFiles: [NSArray arrayWithObject: path] forcePath: directory ignoreDownloadFolder: NO forceDeleteTorrent: NO];
|
||||
[self openFiles: [NSArray arrayWithObject: path] forcePath: directory ignoreDownloadFolder: NO
|
||||
deleteTorrentFile: TORRENT_FILE_DEFAULT];
|
||||
|
||||
return [fTorrents count] > oldCount;
|
||||
}
|
||||
|
||||
+9
-1
@@ -27,6 +27,13 @@
|
||||
|
||||
#define INVALID -99
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TORRENT_FILE_DELETE,
|
||||
TORRENT_FILE_SAVE,
|
||||
TORRENT_FILE_DEFAULT
|
||||
} torrentFileState;
|
||||
|
||||
@interface Torrent : NSObject
|
||||
{
|
||||
tr_handle_t * fLib;
|
||||
@@ -66,7 +73,8 @@
|
||||
NSDictionary * fQuickPauseDict;
|
||||
}
|
||||
|
||||
- (id) initWithPath: (NSString *) path location: (NSString *) location forceDeleteTorrent: (BOOL) delete lib: (tr_handle_t *) lib;
|
||||
- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete
|
||||
lib: (tr_handle_t *) lib;
|
||||
- (id) initWithHistory: (NSDictionary *) history lib: (tr_handle_t *) lib;
|
||||
|
||||
- (NSDictionary *) history;
|
||||
|
||||
+4
-2
@@ -56,10 +56,12 @@ static int static_lastid = 0;
|
||||
|
||||
@implementation Torrent
|
||||
|
||||
- (id) initWithPath: (NSString *) path location: (NSString *) location forceDeleteTorrent: (BOOL) delete lib: (tr_handle_t *) lib
|
||||
- (id) initWithPath: (NSString *) path location: (NSString *) location deleteTorrentFile: (torrentFileState) torrentDelete
|
||||
lib: (tr_handle_t *) lib
|
||||
{
|
||||
self = [self initWithHash: nil path: path lib: lib
|
||||
publicTorrent: delete ? [NSNumber numberWithBool: NO] : nil
|
||||
publicTorrent: torrentDelete != TORRENT_FILE_DEFAULT
|
||||
? [NSNumber numberWithBool: torrentDelete == TORRENT_FILE_SAVE] : nil
|
||||
downloadFolder: location
|
||||
useIncompleteFolder: nil incompleteFolder: nil
|
||||
dateAdded: nil dateCompleted: nil
|
||||
|
||||
Reference in New Issue
Block a user