incomplete folder for downloading torrents
This commit is contained in:
parent
c111c4fb53
commit
4c36ac4a10
|
@ -44,6 +44,8 @@
|
||||||
<false/>
|
<false/>
|
||||||
<key>History</key>
|
<key>History</key>
|
||||||
<array/>
|
<array/>
|
||||||
|
<key>IncompleteDownloadFolder</key>
|
||||||
|
<string>~/Desktop</string>
|
||||||
<key>InfoTab</key>
|
<key>InfoTab</key>
|
||||||
<string>Info</string>
|
<string>Info</string>
|
||||||
<key>InfoVisible</key>
|
<key>InfoVisible</key>
|
||||||
|
@ -104,5 +106,7 @@
|
||||||
<integer>20</integer>
|
<integer>20</integer>
|
||||||
<key>UseAdvancedBar</key>
|
<key>UseAdvancedBar</key>
|
||||||
<false/>
|
<false/>
|
||||||
|
<key>UseIncompleteDownloadFolder</key>
|
||||||
|
<false/>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
folderSheetShow = id;
|
folderSheetShow = id;
|
||||||
helpForNetwork = id;
|
helpForNetwork = id;
|
||||||
importFolderSheetShow = id;
|
importFolderSheetShow = id;
|
||||||
|
incompleteFolderSheetShow = id;
|
||||||
setAutoImport = id;
|
setAutoImport = id;
|
||||||
setAutoSize = id;
|
setAutoSize = id;
|
||||||
setAutoSpeedLimit = id;
|
setAutoSpeedLimit = id;
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
fFolderPopUp = NSPopUpButton;
|
fFolderPopUp = NSPopUpButton;
|
||||||
fGeneralView = NSView;
|
fGeneralView = NSView;
|
||||||
fImportFolderPopUp = NSPopUpButton;
|
fImportFolderPopUp = NSPopUpButton;
|
||||||
|
fIncompleteFolderPopUp = NSPopUpButton;
|
||||||
fNatCheck = NSButton;
|
fNatCheck = NSButton;
|
||||||
fNatStatusField = NSTextField;
|
fNatStatusField = NSTextField;
|
||||||
fNatStatusImage = NSImageView;
|
fNatStatusImage = NSImageView;
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>IBDocumentLocation</key>
|
<key>IBDocumentLocation</key>
|
||||||
<string>18 87 356 240 0 0 1152 842 </string>
|
<string>19 87 356 240 0 0 1152 842 </string>
|
||||||
<key>IBEditorPositions</key>
|
<key>IBEditorPositions</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>153</key>
|
<key>153</key>
|
||||||
<string>123 483 563 267 0 0 1152 842 </string>
|
<string>294 445 563 267 0 0 1152 842 </string>
|
||||||
<key>28</key>
|
<key>28</key>
|
||||||
<string>294 434 563 290 0 0 1152 842 </string>
|
<string>294 434 563 290 0 0 1152 842 </string>
|
||||||
<key>41</key>
|
<key>41</key>
|
||||||
<string>294 420 563 317 0 0 1152 842 </string>
|
<string>108 420 563 342 0 0 1152 842 </string>
|
||||||
<key>66</key>
|
<key>66</key>
|
||||||
<string>294 507 563 144 0 0 1152 842 </string>
|
<string>294 507 563 144 0 0 1152 842 </string>
|
||||||
</dict>
|
</dict>
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
</array>
|
</array>
|
||||||
<key>IBOpenObjects</key>
|
<key>IBOpenObjects</key>
|
||||||
<array>
|
<array>
|
||||||
<integer>153</integer>
|
<integer>41</integer>
|
||||||
</array>
|
</array>
|
||||||
<key>IBSystem Version</key>
|
<key>IBSystem Version</key>
|
||||||
<string>8L127</string>
|
<string>8L127</string>
|
||||||
|
|
Binary file not shown.
|
@ -36,7 +36,7 @@
|
||||||
NSToolbar * fToolbar;
|
NSToolbar * fToolbar;
|
||||||
IBOutlet NSView * fGeneralView, * fTransfersView, * fBandwidthView, * fNetworkView;
|
IBOutlet NSView * fGeneralView, * fTransfersView, * fBandwidthView, * fNetworkView;
|
||||||
|
|
||||||
IBOutlet NSPopUpButton * fFolderPopUp, * fImportFolderPopUp,
|
IBOutlet NSPopUpButton * fFolderPopUp, * fIncompleteFolderPopUp, * fImportFolderPopUp,
|
||||||
* fDownloadSoundPopUp, * fSeedingSoundPopUp;
|
* fDownloadSoundPopUp, * fSeedingSoundPopUp;
|
||||||
|
|
||||||
NSArray * fSounds;
|
NSArray * fSounds;
|
||||||
|
@ -70,6 +70,7 @@
|
||||||
|
|
||||||
- (void) setDownloadLocation: (id) sender;
|
- (void) setDownloadLocation: (id) sender;
|
||||||
- (void) folderSheetShow: (id) sender;
|
- (void) folderSheetShow: (id) sender;
|
||||||
|
- (void) incompleteFolderSheetShow: (id) sender;
|
||||||
|
|
||||||
- (void) setPort: (id) sender;
|
- (void) setPort: (id) sender;
|
||||||
- (void) updatePortStatus;
|
- (void) updatePortStatus;
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
- (void) setPrefView: (id) sender;
|
- (void) setPrefView: (id) sender;
|
||||||
|
|
||||||
- (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
|
- (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
|
||||||
|
- (void) incompleteFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
|
||||||
- (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
|
- (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -396,6 +397,21 @@
|
||||||
@selector(folderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
|
@selector(folderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) incompleteFolderSheetShow: (id) sender
|
||||||
|
{
|
||||||
|
NSOpenPanel * panel = [NSOpenPanel openPanel];
|
||||||
|
|
||||||
|
[panel setPrompt: @"Select"];
|
||||||
|
[panel setAllowsMultipleSelection: NO];
|
||||||
|
[panel setCanChooseFiles: NO];
|
||||||
|
[panel setCanChooseDirectories: YES];
|
||||||
|
[panel setCanCreateDirectories: YES];
|
||||||
|
|
||||||
|
[panel beginSheetForDirectory: nil file: nil types: nil
|
||||||
|
modalForWindow: [self window] modalDelegate: self didEndSelector:
|
||||||
|
@selector(incompleteFolderSheetClosed:returnCode:contextInfo:) contextInfo: nil];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setAutoImport: (id) sender
|
- (void) setAutoImport: (id) sender
|
||||||
{
|
{
|
||||||
if ([fDefaults boolForKey: @"AutoImport"])
|
if ([fDefaults boolForKey: @"AutoImport"])
|
||||||
|
@ -508,6 +524,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) incompleteFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
|
||||||
|
{
|
||||||
|
if (code == NSOKButton)
|
||||||
|
[fDefaults setObject: [[openPanel filenames] objectAtIndex: 0] forKey: @"IncompleteDownloadFolder"];
|
||||||
|
[fIncompleteFolderPopUp selectItemAtIndex: 0];
|
||||||
|
}
|
||||||
|
|
||||||
- (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
|
- (void) importFolderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
|
||||||
{
|
{
|
||||||
if (code == NSOKButton)
|
if (code == NSOKButton)
|
||||||
|
|
|
@ -39,6 +39,9 @@
|
||||||
BOOL fResumeOnWake;
|
BOOL fResumeOnWake;
|
||||||
NSDate * fDate;
|
NSDate * fDate;
|
||||||
|
|
||||||
|
BOOL fUseIncompleteFolder;
|
||||||
|
NSString * fDownloadFolder, * fIncompleteFolder;
|
||||||
|
|
||||||
BOOL fPrivateTorrent, fPublicTorrent;
|
BOOL fPrivateTorrent, fPublicTorrent;
|
||||||
NSString * fPublicTorrentLocation;
|
NSString * fPublicTorrentLocation;
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
|
fUseIncompleteFolder = [fDefaults boolForKey: @"UseIncompleteDownloadFolder"];
|
||||||
|
fIncompleteFolder = [[fDefaults stringForKey: @"IncompleteDownloadFolder"] copy];
|
||||||
|
|
||||||
if (!fPublicTorrent)
|
if (!fPublicTorrent)
|
||||||
[self trashFile: path];
|
[self trashFile: path];
|
||||||
}
|
}
|
||||||
|
@ -85,9 +88,27 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
|
//download folders
|
||||||
NSString * downloadFolder;
|
NSString * downloadFolder;
|
||||||
if (!(downloadFolder = [history objectForKey: @"DownloadFolder"]))
|
if (!(downloadFolder = [history objectForKey: @"DownloadFolder"]))
|
||||||
downloadFolder = [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath];
|
downloadFolder = [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath];
|
||||||
|
|
||||||
|
NSNumber * useIncompleteFolder;
|
||||||
|
if ((useIncompleteFolder = [history objectForKey: @"UseIncompleteFolder"]))
|
||||||
|
{
|
||||||
|
if ((fUseIncompleteFolder = [useIncompleteFolder boolValue]))
|
||||||
|
{
|
||||||
|
NSString * incompleteFolder;
|
||||||
|
if (incompleteFolder = [history objectForKey: @"IncompleteFolder"])
|
||||||
|
fIncompleteFolder = [incompleteFolder copy];
|
||||||
|
else
|
||||||
|
fIncompleteFolder = [[[fDefaults stringForKey: @"IncompleteDownloadFolder"]
|
||||||
|
stringByExpandingTildeInPath] copy];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
fUseIncompleteFolder = NO;
|
||||||
|
|
||||||
[self setDownloadFolder: downloadFolder];
|
[self setDownloadFolder: downloadFolder];
|
||||||
|
|
||||||
NSString * paused;
|
NSString * paused;
|
||||||
|
@ -105,7 +126,8 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
NSMutableDictionary * history = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
NSMutableDictionary * history = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||||
[NSNumber numberWithBool: fPrivateTorrent], @"PrivateCopy",
|
[NSNumber numberWithBool: fPrivateTorrent], @"PrivateCopy",
|
||||||
[NSNumber numberWithBool: fPublicTorrent], @"PublicCopy",
|
[NSNumber numberWithBool: fPublicTorrent], @"PublicCopy",
|
||||||
[self downloadFolder], @"DownloadFolder",
|
fDownloadFolder, @"DownloadFolder",
|
||||||
|
[NSNumber numberWithBool: fUseIncompleteFolder], @"UseIncompleteFolder",
|
||||||
[self isActive] ? @"NO" : @"YES", @"Paused",
|
[self isActive] ? @"NO" : @"YES", @"Paused",
|
||||||
[self date], @"Date",
|
[self date], @"Date",
|
||||||
[NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting",
|
[NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting",
|
||||||
|
@ -113,6 +135,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
[NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
|
[NSNumber numberWithBool: fWaitToStart], @"WaitToStart",
|
||||||
[self orderValue], @"OrderValue", nil];
|
[self orderValue], @"OrderValue", nil];
|
||||||
|
|
||||||
|
if (fUseIncompleteFolder)
|
||||||
|
[history setObject: fIncompleteFolder forKey: @"IncompleteFolder"];
|
||||||
|
|
||||||
if (fPrivateTorrent)
|
if (fPrivateTorrent)
|
||||||
[history setObject: [self hashString] forKey: @"TorrentHash"];
|
[history setObject: [self hashString] forKey: @"TorrentHash"];
|
||||||
|
|
||||||
|
@ -128,6 +153,11 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
{
|
{
|
||||||
tr_torrentClose(fLib, fHandle);
|
tr_torrentClose(fLib, fHandle);
|
||||||
|
|
||||||
|
if (fDownloadFolder)
|
||||||
|
[fDownloadFolder release];
|
||||||
|
if (fIncompleteFolder)
|
||||||
|
[fIncompleteFolder release];
|
||||||
|
|
||||||
if (fPublicTorrentLocation)
|
if (fPublicTorrentLocation)
|
||||||
[fPublicTorrentLocation release];
|
[fPublicTorrentLocation release];
|
||||||
|
|
||||||
|
@ -151,7 +181,13 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
|
|
||||||
- (void) setDownloadFolder: (NSString *) path
|
- (void) setDownloadFolder: (NSString *) path
|
||||||
{
|
{
|
||||||
|
fDownloadFolder = [path copy];
|
||||||
|
|
||||||
|
if (!fUseIncompleteFolder || [[NSFileManager defaultManager] fileExistsAtPath:
|
||||||
|
[path stringByAppendingPathComponent: [self name]]])
|
||||||
tr_torrentSetFolder(fHandle, [path UTF8String]);
|
tr_torrentSetFolder(fHandle, [path UTF8String]);
|
||||||
|
else
|
||||||
|
tr_torrentSetFolder(fHandle, [fIncompleteFolder UTF8String]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) downloadFolder
|
- (NSString *) downloadFolder
|
||||||
|
@ -175,7 +211,19 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
|
||||||
|
|
||||||
//notification when downloading finished
|
//notification when downloading finished
|
||||||
if ([self justFinished])
|
if ([self justFinished])
|
||||||
|
{
|
||||||
|
//move file from incomplete folder to download folder
|
||||||
|
if (fUseIncompleteFolder && ![[self downloadFolder] isEqualToString: fDownloadFolder])
|
||||||
|
{
|
||||||
|
tr_torrentStop(fHandle);
|
||||||
|
if ([[NSFileManager defaultManager] movePath: [[self downloadFolder] stringByAppendingPathComponent: [self name]]
|
||||||
|
toPath: [fDownloadFolder stringByAppendingPathComponent: [self name]] handler: nil])
|
||||||
|
tr_torrentSetFolder(fHandle, [fDownloadFolder UTF8String]);
|
||||||
|
tr_torrentStart(fHandle);
|
||||||
|
}
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
|
||||||
|
}
|
||||||
|
|
||||||
//check to stop for ratio
|
//check to stop for ratio
|
||||||
if ([self isSeeding] && ((fStopRatioSetting == RATIO_CHECK && [self ratio] >= fRatioLimit)
|
if ([self isSeeding] && ((fStopRatioSetting == RATIO_CHECK && [self ratio] >= fRatioLimit)
|
||||||
|
|
Loading…
Reference in New Issue