manual announce in mac gui...only useable once per minute for each torrent

This commit is contained in:
Mitchell Livingston 2006-12-26 21:02:00 +00:00
parent 804b04a41b
commit 4471ce12c5
8 changed files with 70 additions and 12 deletions

View File

@ -139,6 +139,8 @@
- (void) revealFile: (id) sender;
- (void) announceSelectedTorrents: (id) sender;
- (void) showPreferenceWindow: (id) sender;
- (void) makeWindowKey;

View File

@ -61,6 +61,8 @@
#define UPDATE_UI_SECONDS 1.0
#define AUTO_SPEED_LIMIT_SECONDS 5.0
#define ANNOUNCE_WAIT_INTERVAL_SECONDS -60.0
#define WEBSITE_URL @"http://transmission.m0k.org/"
#define FORUM_URL @"http://transmission.m0k.org/forum/"
@ -1064,10 +1066,23 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
- (void) revealFile: (id) sender
{
NSIndexSet * indexSet = [fTableView selectedRowIndexes];
unsigned int i;
for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
[[fDisplayedTorrents objectAtIndex: i] revealData];
NSEnumerator * enumerator = [[fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]] objectEnumerator];
Torrent * torrent;
while ((torrent = [enumerator nextObject]))
[torrent revealData];
}
- (void) announceSelectedTorrents: (id) sender
{
NSEnumerator * enumerator = [[fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]] objectEnumerator];
Torrent * torrent;
NSDate * date;
while ((torrent = [enumerator nextObject]))
{
//time interval returned will be negative
if (!(date = [torrent announceDate]) || [date timeIntervalSinceNow] <= ANNOUNCE_WAIT_INTERVAL_SECONDS)
[torrent announce];
}
}
- (void) showPreferenceWindow: (id) sender
@ -2472,6 +2487,25 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
return NO;
}
//enable announce item
if (action == @selector(announceSelectedTorrents:))
{
if (!canUseTable)
return NO;
NSEnumerator * enumerator = [[fDisplayedTorrents objectsAtIndexes: [fTableView selectedRowIndexes]] objectEnumerator];
Torrent * torrent;
NSDate * date;
while ((torrent = [enumerator nextObject]))
{
//time interval returned will be negative
if ([torrent isActive] &&
(!(date = [torrent announceDate]) || [date timeIntervalSinceNow] <= ANNOUNCE_WAIT_INTERVAL_SECONDS))
return YES;
}
return NO;
}
//enable copy torrent file item
if (action == @selector(copyTorrentFile:))
return canUseTable && [fTableView numberOfSelectedRows] > 0;

View File

@ -3,6 +3,7 @@
{CLASS = BarButton; LANGUAGE = ObjC; SUPERCLASS = NSButton; },
{
ACTIONS = {
announceSelectedTorrents = id;
applyFilter = id;
applySpeedLimit = id;
copyTorrentFile = id;

View File

@ -32,8 +32,6 @@
<key>IBOpenObjects</key>
<array>
<integer>21</integer>
<integer>1848</integer>
<integer>29</integer>
</array>
<key>IBSystem Version</key>
<string>8L127</string>

Binary file not shown.

View File

@ -293,7 +293,7 @@
return;
Torrent * torrent = [fTorrents objectAtIndex: 0];
NSString * tracker = [[torrent tracker] stringByAppendingString: [torrent announce]];
NSString * tracker = [[torrent trackerAddress] stringByAppendingString: [torrent trackerAddressAnnounce]];
[fTrackerField setStringValue: tracker];
[fTrackerField setToolTip: tracker];
}

View File

@ -37,7 +37,7 @@
tr_stat_t * fStat;
BOOL fResumeOnWake;
NSDate * fDate;
NSDate * fDate, * fAnnounceDate;
BOOL fUseIncompleteFolder;
NSString * fDownloadFolder, * fIncompleteFolder;
@ -81,6 +81,9 @@
- (void) sleep;
- (void) wakeUp;
- (void) announce;
- (NSDate *) announceDate;
- (float) ratio;
- (int) stopRatioSetting;
- (void) setStopRatioSetting: (int) setting;
@ -105,8 +108,8 @@
- (NSString *) name;
- (uint64_t) size;
- (NSString *) tracker;
- (NSString *) announce;
- (NSString *) trackerAddress;
- (NSString *) trackerAddressAnnounce;
- (NSString *) comment;
- (NSString *) creator;

View File

@ -160,6 +160,9 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
[fDate release];
if (fAnnounceDate)
[fAnnounceDate release];
[fIcon release];
[fIconFlipped release];
[fIconSmall release];
@ -462,6 +465,23 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
tr_torrentStart(fHandle);
}
- (void) announce
{
if (![self isActive])
return;
tr_manualUpdate(fHandle);
if (fAnnounceDate)
[fAnnounceDate release];
fAnnounceDate = [[NSDate date] retain];
}
- (NSDate *) announceDate
{
return fAnnounceDate;
}
- (float) ratio
{
float downloaded = [self downloadedTotal];
@ -698,12 +718,12 @@ static uint32_t kRed = BE(0xFF6450FF), //255, 100, 80
return fInfo->totalSize;
}
- (NSString *) tracker
- (NSString *) trackerAddress
{
return [NSString stringWithFormat: @"http://%s:%d", fStat->trackerAddress, fStat->trackerPort];
}
- (NSString *) announce
- (NSString *) trackerAddressAnnounce
{
return [NSString stringWithUTF8String: fStat->trackerAnnounce];
}