add option to change download location

This commit is contained in:
Mitchell Livingston 2007-05-09 05:07:44 +00:00
parent 7b64e68386
commit 2d20ae7e32
6 changed files with 75 additions and 7 deletions

View File

@ -133,6 +133,8 @@
- (void) removeDeleteTorrent: (id) sender;
- (void) removeDeleteDataAndTorrent: (id) sender;
- (void) moveDataFiles: (id) sender;
- (void) copyTorrentFile: (id) sender;
- (void) copyTorrentFileForTorrents: (NSMutableArray *) torrents;
- (void) saveTorrentCopySheetClosed: (NSSavePanel *) panel returnCode: (int) code

View File

@ -983,8 +983,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
[self updateTorrentHistory];
}
- (void) removeTorrents: (NSArray *) torrents
deleteData: (BOOL) deleteData deleteTorrent: (BOOL) deleteTorrent
- (void) removeTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData deleteTorrent: (BOOL) deleteTorrent
{
[torrents retain];
int active = 0, downloading = 0;
@ -1135,6 +1134,15 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
deleteData: YES deleteTorrent: YES];
}
- (void) moveDataFiles: (id) sender
{
NSEnumerator * enumerator = [[fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]] objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
[torrent moveTorrent];
}
#warning move to Torrent
- (void) copyTorrentFile: (id) sender
{
[self copyTorrentFileForTorrents: [[NSMutableArray alloc] initWithArray:
@ -2659,6 +2667,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
return NO;
}
//enable move torrent file item
if (action == @selector(moveDataFiles:))
return canUseTable && [fTableView numberOfSelectedRows] > 0;
//enable copy torrent file item
if (action == @selector(copyTorrentFile:))
return canUseTable && [fTableView numberOfSelectedRows] > 0;

View File

@ -11,6 +11,7 @@
doNothing = id;
linkForums = id;
linkHomepage = id;
moveDataFiles = id;
openShowSheet = id;
openURLCancelEndSheet = id;
openURLEndSheet = id;

Binary file not shown.

View File

@ -106,15 +106,16 @@
- (int) downloadLimit;
- (void) setDownloadLimit: (int) limit;
- (void) updateSpeedSetting;
- (void) updateSpeedSetting;
- (void) setWaitToStart: (BOOL) wait;
- (BOOL) waitingToStart;
- (void) revealData;
- (void) revealPublicTorrent;
- (void) trashData;
- (void) trashTorrent;
- (void) revealData;
- (void) revealPublicTorrent;
- (void) trashData;
- (void) trashTorrent;
- (void) moveTorrent;
- (BOOL) alertForRemainingDiskSpace;
- (BOOL) alertForFolderAvailable;

View File

@ -691,6 +691,58 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[self trashFile: [self publicTorrentLocation]];
}
- (void) moveTorrent
{
NSOpenPanel * panel = [NSOpenPanel openPanel];
[panel setPrompt: NSLocalizedString(@"Select", "Move torrent -> prompt")];
[panel setAllowsMultipleSelection: NO];
[panel setCanChooseFiles: NO];
[panel setCanChooseDirectories: YES];
[panel setCanCreateDirectories: YES];
[panel setMessage: [NSString stringWithFormat: NSLocalizedString(@"Select the new folder for \"%@\"",
"Move torrent -> select destination folder"), [self name]]];
[[NSNotificationCenter defaultCenter] postNotificationName: @"MakeWindowKey" object: nil];
[panel beginSheetForDirectory: nil file: nil types: nil modalForWindow: [NSApp keyWindow] modalDelegate: self
didEndSelector: @selector(moveTorrentChoiceClosed:returnCode:contextInfo:) contextInfo: nil];
}
- (void) moveTorrentChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) context
{
if (code != NSOKButton)
return;
NSString * folder = [[openPanel filenames] objectAtIndex: 0];
if (![[self downloadFolder] isEqualToString: folder] || ![fDownloadFolder isEqualToString: folder])
{
//pause without actually stopping
tr_setDownloadLimit(fHandle, 0);
tr_setUploadLimit(fHandle, 0);
if ([[NSFileManager defaultManager] movePath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]
toPath: [folder stringByAppendingPathComponent: [self name]] handler: nil])
{
//get rid of both incomplete folder and download folder
fUseIncompleteFolder = NO;
if (fIncompleteFolder)
{
[fIncompleteFolder release];
fIncompleteFolder = nil;
}
[fDownloadFolder release];
fDownloadFolder = [folder retain];
tr_torrentSetFolder(fHandle, [fDownloadFolder UTF8String]);
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateInfoSettings" object: nil];
}
[self updateSpeedSetting];
}
}
- (BOOL) alertForRemainingDiskSpace
{
if ([self allDownloaded] || ![fDefaults boolForKey: @"WarningRemainingSpace"])