mirror of
https://github.com/transmission/transmission.git
synced 2025-12-22 11:28:32 +00:00
The beginning of queueing. Has some work to go, but the basic infrastructure is set up.
This commit is contained in:
@@ -133,6 +133,8 @@
|
|||||||
- (void) ratioGlobalChange: (NSNotification *) notification;
|
- (void) ratioGlobalChange: (NSNotification *) notification;
|
||||||
- (void) ratioSingleChange: (NSNotification *) notification;
|
- (void) ratioSingleChange: (NSNotification *) notification;
|
||||||
|
|
||||||
|
- (void) checkWaitingForFinished: (NSNotification *) notification;
|
||||||
|
|
||||||
- (void) sleepCallBack: (natural_t) messageType argument:
|
- (void) sleepCallBack: (natural_t) messageType argument:
|
||||||
(void *) messageArgument;
|
(void *) messageArgument;
|
||||||
|
|
||||||
|
|||||||
@@ -212,6 +212,9 @@ static void sleepCallBack(void * controller, io_service_t y,
|
|||||||
[nc addObserver: self selector: @selector(ratioGlobalChange:)
|
[nc addObserver: self selector: @selector(ratioGlobalChange:)
|
||||||
name: @"RatioGlobalChange" object: nil];
|
name: @"RatioGlobalChange" object: nil];
|
||||||
|
|
||||||
|
[nc addObserver: self selector: @selector(checkWaitingForFinished:)
|
||||||
|
name: @"TorrentFinishedDownloading" object: nil];
|
||||||
|
|
||||||
//timer to update the interface
|
//timer to update the interface
|
||||||
fCompleted = 0;
|
fCompleted = 0;
|
||||||
[self updateUI: nil];
|
[self updateUI: nil];
|
||||||
@@ -317,8 +320,22 @@ static void sleepCallBack(void * controller, io_service_t y,
|
|||||||
{
|
{
|
||||||
if (code == NSOKButton)
|
if (code == NSOKButton)
|
||||||
{
|
{
|
||||||
|
//setup for autostart
|
||||||
|
NSString * startSetting = [fDefaults stringForKey: @"StartSetting"];
|
||||||
|
BOOL waitToStart = [startSetting isEqualToString: @"Wait"];
|
||||||
|
int desiredActive, active = 0;
|
||||||
|
if (waitToStart)
|
||||||
|
{
|
||||||
|
desiredActive = [fDefaults integerForKey: @"WaitToStartNumber"];
|
||||||
|
Torrent * tempTorrent;
|
||||||
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||||
|
while ((tempTorrent = [enumerator nextObject]))
|
||||||
|
if ([tempTorrent isActive] && ![tempTorrent isSeeding])
|
||||||
|
active++;
|
||||||
|
}
|
||||||
|
|
||||||
[torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]];
|
[torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]];
|
||||||
if ([fDefaults boolForKey: @"AutoStartDownload"])
|
if ((waitToStart && active < desiredActive) || [startSetting isEqualToString: @"Start"])
|
||||||
[torrent startTransfer];
|
[torrent startTransfer];
|
||||||
[fTorrents addObject: torrent];
|
[fTorrents addObject: torrent];
|
||||||
|
|
||||||
@@ -328,12 +345,24 @@ static void sleepCallBack(void * controller, io_service_t y,
|
|||||||
[NSApp stopModal];
|
[NSApp stopModal];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) application: (NSApplication *) sender
|
- (void) application: (NSApplication *) sender openFiles: (NSArray *) filenames
|
||||||
openFiles: (NSArray *) filenames
|
|
||||||
{
|
{
|
||||||
BOOL autoStart = [fDefaults boolForKey: @"AutoStartDownload"];
|
|
||||||
|
|
||||||
NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"], * torrentPath;
|
NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"], * torrentPath;
|
||||||
|
|
||||||
|
//setup for autostart
|
||||||
|
NSString * startSetting = [fDefaults stringForKey: @"StartSetting"];
|
||||||
|
BOOL waitToStart = [startSetting isEqualToString: @"Wait"];
|
||||||
|
int desiredActive, active = 0;
|
||||||
|
if (waitToStart && ![downloadChoice isEqualToString: @"Ask"])
|
||||||
|
{
|
||||||
|
desiredActive = [fDefaults integerForKey: @"WaitToStartNumber"];
|
||||||
|
Torrent * tempTorrent;
|
||||||
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||||
|
while ((tempTorrent = [enumerator nextObject]))
|
||||||
|
if ([tempTorrent isActive] && ![tempTorrent isSeeding])
|
||||||
|
active++;
|
||||||
|
}
|
||||||
|
|
||||||
Torrent * torrent;
|
Torrent * torrent;
|
||||||
NSEnumerator * enumerator = [filenames objectEnumerator];
|
NSEnumerator * enumerator = [filenames objectEnumerator];
|
||||||
while ((torrentPath = [enumerator nextObject]))
|
while ((torrentPath = [enumerator nextObject]))
|
||||||
@@ -341,7 +370,7 @@ static void sleepCallBack(void * controller, io_service_t y,
|
|||||||
if (!(torrent = [[Torrent alloc] initWithPath: torrentPath lib: fLib]))
|
if (!(torrent = [[Torrent alloc] initWithPath: torrentPath lib: fLib]))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Add it to the "File > Open Recent" menu */
|
//add it to the "File > Open Recent" menu
|
||||||
[[NSDocumentController sharedDocumentController]
|
[[NSDocumentController sharedDocumentController]
|
||||||
noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
|
noteNewRecentDocumentURL: [NSURL fileURLWithPath: torrentPath]];
|
||||||
|
|
||||||
@@ -370,8 +399,12 @@ static void sleepCallBack(void * controller, io_service_t y,
|
|||||||
: [torrentPath stringByDeletingLastPathComponent];
|
: [torrentPath stringByDeletingLastPathComponent];
|
||||||
|
|
||||||
[torrent setDownloadFolder: folder];
|
[torrent setDownloadFolder: folder];
|
||||||
if (autoStart)
|
#warning should check if transfer was already done
|
||||||
|
if ((waitToStart && active < desiredActive) || [startSetting isEqualToString: @"Start"])
|
||||||
|
{
|
||||||
[torrent startTransfer];
|
[torrent startTransfer];
|
||||||
|
active++;
|
||||||
|
}
|
||||||
[fTorrents addObject: torrent];
|
[fTorrents addObject: torrent];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -502,7 +535,7 @@ static void sleepCallBack(void * controller, io_service_t y,
|
|||||||
if ([torrent isActive])
|
if ([torrent isActive])
|
||||||
active++;
|
active++;
|
||||||
|
|
||||||
if( active > 0 && [fDefaults boolForKey: @"CheckRemove"] )
|
if (active > 0 && [fDefaults boolForKey: @"CheckRemove"])
|
||||||
{
|
{
|
||||||
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys:
|
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys:
|
||||||
torrents, @"Torrents",
|
torrents, @"Torrents",
|
||||||
@@ -910,6 +943,46 @@ static void sleepCallBack(void * controller, io_service_t y,
|
|||||||
[fInfoController updateInfoForTorrents: torrents];
|
[fInfoController updateInfoForTorrents: torrents];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) checkWaitingForFinished: (NSNotification *) notification
|
||||||
|
{
|
||||||
|
//don't try to start a transfer if there should be none waiting
|
||||||
|
if (![[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Wait"])
|
||||||
|
return;
|
||||||
|
|
||||||
|
int desiredActive = [fDefaults integerForKey: @"WaitToStartNumber"], active = 0;
|
||||||
|
|
||||||
|
NSEnumerator * enumerator = [fTorrents objectEnumerator];
|
||||||
|
Torrent * torrent, * torrentToStart = nil;
|
||||||
|
while ((torrent = [enumerator nextObject]))
|
||||||
|
{
|
||||||
|
//ignore the torrent just stopped; for some reason it is not marked instantly as not active
|
||||||
|
if (torrent == [notification object])
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if ([torrent isActive])
|
||||||
|
{
|
||||||
|
if (![torrent isSeeding])
|
||||||
|
{
|
||||||
|
active++;
|
||||||
|
if (active >= desiredActive)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!torrentToStart && [torrent waitingToStart])
|
||||||
|
torrentToStart = torrent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//since it hasn't returned, the queue amount has not been met
|
||||||
|
if (torrentToStart)
|
||||||
|
{
|
||||||
|
[torrentToStart startTransfer];
|
||||||
|
[self updateUI: nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (int) numberOfRowsInTableView: (NSTableView *) t
|
- (int) numberOfRowsInTableView: (NSTableView *) t
|
||||||
{
|
{
|
||||||
return [fTorrents count];
|
return [fTorrents count];
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>AutoStartDownload</key>
|
|
||||||
<true/>
|
|
||||||
<key>BadgeDownloadRate</key>
|
<key>BadgeDownloadRate</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>BadgeUploadRate</key>
|
<key>BadgeUploadRate</key>
|
||||||
@@ -50,6 +48,8 @@
|
|||||||
<false/>
|
<false/>
|
||||||
<key>Sort</key>
|
<key>Sort</key>
|
||||||
<string>Date</string>
|
<string>Date</string>
|
||||||
|
<key>StartSetting</key>
|
||||||
|
<string>Start</string>
|
||||||
<key>StatusBar</key>
|
<key>StatusBar</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>UpdateCheck</key>
|
<key>UpdateCheck</key>
|
||||||
@@ -58,5 +58,7 @@
|
|||||||
<integer>20</integer>
|
<integer>20</integer>
|
||||||
<key>UseAdvancedBar</key>
|
<key>UseAdvancedBar</key>
|
||||||
<false/>
|
<false/>
|
||||||
|
<key>WaitToStartNumber</key>
|
||||||
|
<integer>3</integer>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|||||||
6
macosx/English.lproj/PrefsWindow.nib/classes.nib
generated
6
macosx/English.lproj/PrefsWindow.nib/classes.nib
generated
@@ -5,7 +5,6 @@
|
|||||||
{
|
{
|
||||||
ACTIONS = {
|
ACTIONS = {
|
||||||
folderSheetShow = id;
|
folderSheetShow = id;
|
||||||
setAutoStart = id;
|
|
||||||
setBadge = id;
|
setBadge = id;
|
||||||
setDownloadLocation = id;
|
setDownloadLocation = id;
|
||||||
setLimit = id;
|
setLimit = id;
|
||||||
@@ -15,12 +14,13 @@
|
|||||||
setRatio = id;
|
setRatio = id;
|
||||||
setRatioCheck = id;
|
setRatioCheck = id;
|
||||||
setShowMessage = id;
|
setShowMessage = id;
|
||||||
|
setStartSetting = id;
|
||||||
setUpdate = id;
|
setUpdate = id;
|
||||||
|
setWaitToStart = id;
|
||||||
};
|
};
|
||||||
CLASS = PrefsController;
|
CLASS = PrefsController;
|
||||||
LANGUAGE = ObjC;
|
LANGUAGE = ObjC;
|
||||||
OUTLETS = {
|
OUTLETS = {
|
||||||
fAutoStartCheck = NSButton;
|
|
||||||
fBadgeDownloadRateCheck = NSButton;
|
fBadgeDownloadRateCheck = NSButton;
|
||||||
fBadgeUploadRateCheck = NSButton;
|
fBadgeUploadRateCheck = NSButton;
|
||||||
fCopyTorrentCheck = NSButton;
|
fCopyTorrentCheck = NSButton;
|
||||||
@@ -35,11 +35,13 @@
|
|||||||
fRatioCheck = NSButton;
|
fRatioCheck = NSButton;
|
||||||
fRatioField = NSTextField;
|
fRatioField = NSTextField;
|
||||||
fRemoveCheck = NSButton;
|
fRemoveCheck = NSButton;
|
||||||
|
fStartMatrix = NSMatrix;
|
||||||
fTransfersView = NSView;
|
fTransfersView = NSView;
|
||||||
fUpdatePopUp = NSPopUpButton;
|
fUpdatePopUp = NSPopUpButton;
|
||||||
fUpdater = SUUpdater;
|
fUpdater = SUUpdater;
|
||||||
fUploadCheck = NSButton;
|
fUploadCheck = NSButton;
|
||||||
fUploadField = NSTextField;
|
fUploadField = NSTextField;
|
||||||
|
fWaitToStartField = NSTextField;
|
||||||
};
|
};
|
||||||
SUPERCLASS = NSWindowController;
|
SUPERCLASS = NSWindowController;
|
||||||
},
|
},
|
||||||
|
|||||||
10
macosx/English.lproj/PrefsWindow.nib/info.nib
generated
10
macosx/English.lproj/PrefsWindow.nib/info.nib
generated
@@ -7,18 +7,14 @@
|
|||||||
<key>IBEditorPositions</key>
|
<key>IBEditorPositions</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>28</key>
|
<key>28</key>
|
||||||
<string>195 461 462 212 0 0 1152 842 </string>
|
<string>321 472 535 212 0 0 1152 842 </string>
|
||||||
<key>41</key>
|
<key>41</key>
|
||||||
<string>345 427 462 306 0 0 1152 842 </string>
|
<string>286 392 535 345 0 0 1152 842 </string>
|
||||||
<key>66</key>
|
<key>66</key>
|
||||||
<string>345 526 462 104 0 0 1152 842 </string>
|
<string>321 526 535 104 0 0 1152 842 </string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>IBFramework Version</key>
|
<key>IBFramework Version</key>
|
||||||
<string>446.1</string>
|
<string>446.1</string>
|
||||||
<key>IBOpenObjects</key>
|
|
||||||
<array>
|
|
||||||
<integer>41</integer>
|
|
||||||
</array>
|
|
||||||
<key>IBSystem Version</key>
|
<key>IBSystem Version</key>
|
||||||
<string>8I127</string>
|
<string>8I127</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
|||||||
BIN
macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib
generated
BIN
macosx/English.lproj/PrefsWindow.nib/keyedobjects.nib
generated
Binary file not shown.
@@ -408,11 +408,10 @@
|
|||||||
|
|
||||||
- (void) setRatioCheck: (id) sender
|
- (void) setRatioCheck: (id) sender
|
||||||
{
|
{
|
||||||
NSButtonCell * selected = [fRatioMatrix selectedCell];
|
int ratioSetting, tag = [[fRatioMatrix selectedCell] tag];
|
||||||
int ratioSetting;
|
if (tag == RATIO_CHECK_TAG)
|
||||||
if (selected == [fRatioMatrix cellWithTag: RATIO_CHECK_TAG])
|
|
||||||
ratioSetting = RATIO_CHECK;
|
ratioSetting = RATIO_CHECK;
|
||||||
else if (selected == [fRatioMatrix cellWithTag: RATIO_NO_CHECK_TAG])
|
else if (tag == RATIO_NO_CHECK_TAG)
|
||||||
ratioSetting = RATIO_NO_CHECK;
|
ratioSetting = RATIO_NO_CHECK;
|
||||||
else
|
else
|
||||||
ratioSetting = RATIO_GLOBAL;
|
ratioSetting = RATIO_GLOBAL;
|
||||||
@@ -423,7 +422,7 @@
|
|||||||
[torrent setStopRatioSetting: ratioSetting];
|
[torrent setStopRatioSetting: ratioSetting];
|
||||||
|
|
||||||
[self setRatioLimit: fRatioLimitField];
|
[self setRatioLimit: fRatioLimitField];
|
||||||
[fRatioLimitField setEnabled: selected == [fRatioMatrix cellWithTag: RATIO_CHECK_TAG]];
|
[fRatioLimitField setEnabled: tag == RATIO_CHECK_TAG];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setRatioLimit: (id) sender
|
- (void) setRatioLimit: (id) sender
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
IBOutlet NSPopUpButton * fFolderPopUp;
|
IBOutlet NSPopUpButton * fFolderPopUp;
|
||||||
IBOutlet NSButton * fQuitCheck, * fRemoveCheck,
|
IBOutlet NSButton * fQuitCheck, * fRemoveCheck,
|
||||||
* fBadgeDownloadRateCheck, * fBadgeUploadRateCheck,
|
* fBadgeDownloadRateCheck, * fBadgeUploadRateCheck,
|
||||||
* fAutoStartCheck, * fCopyTorrentCheck, * fDeleteOriginalTorrentCheck;
|
* fCopyTorrentCheck, * fDeleteOriginalTorrentCheck;
|
||||||
IBOutlet NSPopUpButton * fUpdatePopUp;
|
IBOutlet NSPopUpButton * fUpdatePopUp;
|
||||||
|
|
||||||
IBOutlet NSTextField * fPortField, * fUploadField, * fDownloadField;
|
IBOutlet NSTextField * fPortField, * fUploadField, * fDownloadField;
|
||||||
@@ -45,6 +45,9 @@
|
|||||||
IBOutlet NSButton * fRatioCheck;
|
IBOutlet NSButton * fRatioCheck;
|
||||||
IBOutlet NSTextField * fRatioField;
|
IBOutlet NSTextField * fRatioField;
|
||||||
|
|
||||||
|
IBOutlet NSMatrix * fStartMatrix;
|
||||||
|
IBOutlet NSTextField * fWaitToStartField;
|
||||||
|
|
||||||
IBOutlet SUUpdater * fUpdater;
|
IBOutlet SUUpdater * fUpdater;
|
||||||
|
|
||||||
NSString * fDownloadFolder;
|
NSString * fDownloadFolder;
|
||||||
@@ -57,7 +60,11 @@
|
|||||||
- (void) setBadge: (id) sender;
|
- (void) setBadge: (id) sender;
|
||||||
- (void) setUpdate: (id) sender;
|
- (void) setUpdate: (id) sender;
|
||||||
- (void) checkUpdate;
|
- (void) checkUpdate;
|
||||||
- (void) setAutoStart: (id) sender;
|
|
||||||
|
|
||||||
|
- (void) setStartSetting: (id) sender;
|
||||||
|
- (void) setWaitToStart: (id) sender;
|
||||||
|
|
||||||
- (void) setMoveTorrent: (id) sender;
|
- (void) setMoveTorrent: (id) sender;
|
||||||
- (void) setDownloadLocation: (id) sender;
|
- (void) setDownloadLocation: (id) sender;
|
||||||
- (void) folderSheetShow: (id) sender;
|
- (void) folderSheetShow: (id) sender;
|
||||||
|
|||||||
@@ -30,7 +30,11 @@
|
|||||||
|
|
||||||
#define DOWNLOAD_FOLDER 0
|
#define DOWNLOAD_FOLDER 0
|
||||||
#define DOWNLOAD_TORRENT 2
|
#define DOWNLOAD_TORRENT 2
|
||||||
#define DOWNLOAD_ASK 3
|
#define DOWNLOAD_ASK 3
|
||||||
|
|
||||||
|
#define START_YES_CHECK_TAG 0
|
||||||
|
#define START_WAIT_CHECK_TAG 1
|
||||||
|
#define START_NO_CHECK_TAG 2
|
||||||
|
|
||||||
#define UPDATE_DAILY 0
|
#define UPDATE_DAILY 0
|
||||||
#define UPDATE_WEEKLY 1
|
#define UPDATE_WEEKLY 1
|
||||||
@@ -142,8 +146,19 @@
|
|||||||
[fBadgeDownloadRateCheck setState: [fDefaults boolForKey: @"BadgeDownloadRate"]];
|
[fBadgeDownloadRateCheck setState: [fDefaults boolForKey: @"BadgeDownloadRate"]];
|
||||||
[fBadgeUploadRateCheck setState: [fDefaults boolForKey: @"BadgeUploadRate"]];
|
[fBadgeUploadRateCheck setState: [fDefaults boolForKey: @"BadgeUploadRate"]];
|
||||||
|
|
||||||
//set auto start
|
//set start setting
|
||||||
[fAutoStartCheck setState: [fDefaults boolForKey: @"AutoStartDownload"]];
|
NSString * startSetting = [fDefaults stringForKey: @"StartSetting"];
|
||||||
|
int tag;
|
||||||
|
if ([startSetting isEqualToString: @"Start"])
|
||||||
|
tag = START_YES_CHECK_TAG;
|
||||||
|
else if ([startSetting isEqualToString: @"Wait"])
|
||||||
|
tag = START_WAIT_CHECK_TAG;
|
||||||
|
else
|
||||||
|
tag = START_NO_CHECK_TAG;
|
||||||
|
|
||||||
|
[fStartMatrix selectCellWithTag: tag];
|
||||||
|
[fWaitToStartField setEnabled: tag == START_WAIT_CHECK_TAG];
|
||||||
|
[fWaitToStartField setIntValue: [fDefaults integerForKey: @"WaitToStartNumber"]];
|
||||||
|
|
||||||
//set private torrents
|
//set private torrents
|
||||||
BOOL copyTorrents = [fDefaults boolForKey: @"SavePrivateTorrent"];
|
BOOL copyTorrents = [fDefaults boolForKey: @"SavePrivateTorrent"];
|
||||||
@@ -407,9 +422,37 @@
|
|||||||
[fUpdater scheduleCheckWithInterval: seconds];
|
[fUpdater scheduleCheckWithInterval: seconds];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setAutoStart: (id) sender
|
- (void) setStartSetting: (id) sender
|
||||||
{
|
{
|
||||||
[fDefaults setBool: [sender state] forKey: @"AutoStartDownload"];
|
NSString * startSetting;
|
||||||
|
|
||||||
|
int tag = [[fStartMatrix selectedCell] tag];
|
||||||
|
if (tag == START_YES_CHECK_TAG)
|
||||||
|
startSetting = @"Start";
|
||||||
|
else if (tag == START_WAIT_CHECK_TAG)
|
||||||
|
startSetting = @"Wait";
|
||||||
|
else
|
||||||
|
startSetting = @"Manual";
|
||||||
|
|
||||||
|
[fDefaults setObject: startSetting forKey: @"StartSetting"];
|
||||||
|
|
||||||
|
[self setWaitToStart: fWaitToStartField];
|
||||||
|
[fWaitToStartField setEnabled: tag == START_WAIT_CHECK_TAG];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setWaitToStart: (id) sender
|
||||||
|
{
|
||||||
|
int waitNumber = [sender intValue];
|
||||||
|
if (![[sender stringValue] isEqualToString: [NSString stringWithInt: waitNumber]] || waitNumber < 1)
|
||||||
|
{
|
||||||
|
NSBeep();
|
||||||
|
waitNumber = [fDefaults floatForKey: @"WaitToStartNumber"];
|
||||||
|
[sender setIntValue: waitNumber];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
[fDefaults setInteger: waitNumber forKey: @"WaitToStartNumber"];
|
||||||
|
|
||||||
|
#warning notification recheck
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setMoveTorrent: (id) sender
|
- (void) setMoveTorrent: (id) sender
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
|
|
||||||
int fStopRatioSetting;
|
int fStopRatioSetting;
|
||||||
float fRatioLimit;
|
float fRatioLimit;
|
||||||
BOOL fFinishedSeeding;
|
BOOL fFinishedSeeding, fWaitToStart;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithPath: (NSString *) path lib: (tr_handle_t *) lib;
|
- (id) initWithPath: (NSString *) path lib: (tr_handle_t *) lib;
|
||||||
@@ -74,6 +74,9 @@
|
|||||||
- (float) ratioLimit;
|
- (float) ratioLimit;
|
||||||
- (void) setRatioLimit: (float) limit;
|
- (void) setRatioLimit: (float) limit;
|
||||||
|
|
||||||
|
- (void) setWaitToStart: (BOOL) wait;
|
||||||
|
- (BOOL) waitingToStart;
|
||||||
|
|
||||||
- (void) revealData;
|
- (void) revealData;
|
||||||
- (void) trashData;
|
- (void) trashData;
|
||||||
- (void) trashTorrent;
|
- (void) trashTorrent;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@
|
|||||||
- (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle_t *) lib
|
- (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle_t *) lib
|
||||||
privateTorrent: (NSNumber *) privateTorrent publicTorrent: (NSNumber *) publicTorrent
|
privateTorrent: (NSNumber *) privateTorrent publicTorrent: (NSNumber *) publicTorrent
|
||||||
date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
|
date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
|
||||||
ratioLimit: (NSNumber *) ratioLimit;
|
ratioLimit: (NSNumber *) ratioLimit waitToStart: (NSNumber *) waitToStart;
|
||||||
|
|
||||||
- (void) trashFile: (NSString *) path;
|
- (void) trashFile: (NSString *) path;
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
- (id) initWithPath: (NSString *) path lib: (tr_handle_t *) lib
|
- (id) initWithPath: (NSString *) path lib: (tr_handle_t *) lib
|
||||||
{
|
{
|
||||||
self = [self initWithHash: nil path: path lib: lib privateTorrent: nil publicTorrent: nil
|
self = [self initWithHash: nil path: path lib: lib privateTorrent: nil publicTorrent: nil
|
||||||
date: nil stopRatioSetting: nil ratioLimit: nil];
|
date: nil stopRatioSetting: nil ratioLimit: nil waitToStart: nil];
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
@@ -60,7 +60,8 @@
|
|||||||
publicTorrent: [history objectForKey: @"PublicCopy"]
|
publicTorrent: [history objectForKey: @"PublicCopy"]
|
||||||
date: [history objectForKey: @"Date"]
|
date: [history objectForKey: @"Date"]
|
||||||
stopRatioSetting: [history objectForKey: @"StopRatioSetting"]
|
stopRatioSetting: [history objectForKey: @"StopRatioSetting"]
|
||||||
ratioLimit: [history objectForKey: @"RatioLimit"]];
|
ratioLimit: [history objectForKey: @"RatioLimit"]
|
||||||
|
waitToStart: [history objectForKey: @"WaitToStart"]];
|
||||||
|
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
@@ -85,7 +86,8 @@
|
|||||||
[self isActive] ? @"NO" : @"YES", @"Paused",
|
[self isActive] ? @"NO" : @"YES", @"Paused",
|
||||||
[self date], @"Date",
|
[self date], @"Date",
|
||||||
[NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting",
|
[NSNumber numberWithInt: fStopRatioSetting], @"StopRatioSetting",
|
||||||
[NSNumber numberWithFloat: fRatioLimit], @"RatioLimit", nil];
|
[NSNumber numberWithFloat: fRatioLimit], @"RatioLimit",
|
||||||
|
[NSNumber numberWithBool: fWaitToStart], @"WaitToStart", nil];
|
||||||
|
|
||||||
if (fPrivateTorrent)
|
if (fPrivateTorrent)
|
||||||
[history setObject: [self hashString] forKey: @"TorrentHash"];
|
[history setObject: [self hashString] forKey: @"TorrentHash"];
|
||||||
@@ -158,7 +160,12 @@
|
|||||||
switch (fStat->status)
|
switch (fStat->status)
|
||||||
{
|
{
|
||||||
case TR_STATUS_PAUSE:
|
case TR_STATUS_PAUSE:
|
||||||
[fStatusString setString: fFinishedSeeding ? @"Seeding Complete" : @"Paused"];
|
if (fFinishedSeeding)
|
||||||
|
[fStatusString setString: @"Seeding complete"];
|
||||||
|
else if (fWaitToStart)
|
||||||
|
[fStatusString setString: [@"Waiting to start" stringByAppendingEllipsis]];
|
||||||
|
else
|
||||||
|
[fStatusString setString: @"Paused"];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TR_STATUS_CHECK:
|
case TR_STATUS_CHECK:
|
||||||
@@ -221,14 +228,23 @@
|
|||||||
if (![self isActive])
|
if (![self isActive])
|
||||||
{
|
{
|
||||||
tr_torrentStart(fHandle);
|
tr_torrentStart(fHandle);
|
||||||
|
|
||||||
fFinishedSeeding = NO;
|
fFinishedSeeding = NO;
|
||||||
|
fWaitToStart = NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) stopTransfer
|
- (void) stopTransfer
|
||||||
{
|
{
|
||||||
if ([self isActive])
|
if ([self isActive])
|
||||||
|
{
|
||||||
|
BOOL wasSeeding = [self isSeeding];
|
||||||
|
|
||||||
tr_torrentStop(fHandle);
|
tr_torrentStop(fHandle);
|
||||||
|
|
||||||
|
if (!wasSeeding)
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) removeForever
|
- (void) removeForever
|
||||||
@@ -240,13 +256,13 @@
|
|||||||
- (void) sleep
|
- (void) sleep
|
||||||
{
|
{
|
||||||
if ((fResumeOnWake = [self isActive]))
|
if ((fResumeOnWake = [self isActive]))
|
||||||
[self stopTransfer];
|
tr_torrentStop(fHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) wakeUp
|
- (void) wakeUp
|
||||||
{
|
{
|
||||||
if (fResumeOnWake)
|
if (fResumeOnWake)
|
||||||
[self startTransfer];
|
tr_torrentStart(fHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (float) ratio
|
- (float) ratio
|
||||||
@@ -276,6 +292,16 @@
|
|||||||
fRatioLimit = limit;
|
fRatioLimit = limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setWaitToStart: (BOOL) wait
|
||||||
|
{
|
||||||
|
fWaitToStart = wait;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (BOOL) waitingToStart
|
||||||
|
{
|
||||||
|
return fWaitToStart;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) revealData
|
- (void) revealData
|
||||||
{
|
{
|
||||||
[[NSWorkspace sharedWorkspace] selectFile: [self dataLocation] inFileViewerRootedAtPath: nil];
|
[[NSWorkspace sharedWorkspace] selectFile: [self dataLocation] inFileViewerRootedAtPath: nil];
|
||||||
@@ -424,7 +450,11 @@
|
|||||||
|
|
||||||
- (BOOL) justFinished
|
- (BOOL) justFinished
|
||||||
{
|
{
|
||||||
return tr_getFinished(fHandle);
|
BOOL finished = tr_getFinished(fHandle);
|
||||||
|
if (finished)
|
||||||
|
[[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentFinishedDownloading" object: self];
|
||||||
|
|
||||||
|
return finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString *) progressString
|
- (NSString *) progressString
|
||||||
@@ -528,7 +558,7 @@
|
|||||||
- (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle_t *) lib
|
- (id) initWithHash: (NSString *) hashString path: (NSString *) path lib: (tr_handle_t *) lib
|
||||||
privateTorrent: (NSNumber *) privateTorrent publicTorrent: (NSNumber *) publicTorrent
|
privateTorrent: (NSNumber *) privateTorrent publicTorrent: (NSNumber *) publicTorrent
|
||||||
date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
|
date: (NSDate *) date stopRatioSetting: (NSNumber *) stopRatioSetting
|
||||||
ratioLimit: (NSNumber *) ratioLimit
|
ratioLimit: (NSNumber *) ratioLimit waitToStart: (NSNumber *) waitToStart
|
||||||
{
|
{
|
||||||
if (!(self = [super init]))
|
if (!(self = [super init]))
|
||||||
return nil;
|
return nil;
|
||||||
@@ -564,6 +594,9 @@
|
|||||||
fRatioLimit = ratioLimit ? [ratioLimit floatValue] : [fDefaults floatForKey: @"RatioLimit"];
|
fRatioLimit = ratioLimit ? [ratioLimit floatValue] : [fDefaults floatForKey: @"RatioLimit"];
|
||||||
fFinishedSeeding = NO;
|
fFinishedSeeding = NO;
|
||||||
|
|
||||||
|
fWaitToStart = waitToStart ? [waitToStart boolValue]
|
||||||
|
: [[fDefaults stringForKey: @"StartSetting"] isEqualToString: @"Wait"];
|
||||||
|
|
||||||
NSString * fileType = fInfo->multifile ? NSFileTypeForHFSTypeCode('fldr') : [[self name] pathExtension];
|
NSString * fileType = fInfo->multifile ? NSFileTypeForHFSTypeCode('fldr') : [[self name] pathExtension];
|
||||||
fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: fileType];
|
fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: fileType];
|
||||||
[fIcon retain];
|
[fIcon retain];
|
||||||
|
|||||||
Reference in New Issue
Block a user