more cleanup work:

(1) kill the pointless "tr_tracker_stat" struct.
(2) kill the unused "tr_torrentRemoveSaved()" function.
(3) kill the redundant "nextManualAnnounceTime" variable.
(4) make the TR_ERROR_IS_* macros private.
This commit is contained in:
Charles Kerr 2008-05-22 23:11:21 +00:00
parent 29729d35e7
commit 0621c67c41
8 changed files with 119 additions and 136 deletions

View File

@ -1213,29 +1213,29 @@ refresh_tracker( GtkWidget * w )
const tr_stat * torStat = tr_torrent_stat( page->gtor );
l = page->last_scrape_time_lb;
t = torStat->trackerStat.lastScrapeTime;
t = torStat->lastScrapeTime;
refresh_time_lb( l, t );
l = page->last_scrape_response_lb;
gtk_label_set_text( GTK_LABEL( l ), torStat->trackerStat.scrapeResponse );
gtk_label_set_text( GTK_LABEL( l ), torStat->scrapeResponse );
l = page->next_scrape_countdown_lb;
t = torStat->trackerStat.nextScrapeTime;
t = torStat->nextScrapeTime;
refresh_countdown_lb( l, t );
l = page->last_announce_time_lb;
t = torStat->trackerStat.lastAnnounceTime;
t = torStat->lastAnnounceTime;
refresh_time_lb( l, t );
l = page->last_announce_response_lb;
gtk_label_set_text( GTK_LABEL( l ), torStat->trackerStat.announceResponse );
gtk_label_set_text( GTK_LABEL( l ), torStat->announceResponse );
l = page->next_announce_countdown_lb;
t = torStat->trackerStat.nextAnnounceTime;
t = torStat->nextAnnounceTime;
refresh_countdown_lb( l, t );
l = page->manual_announce_countdown_lb;
t = torStat->trackerStat.nextManualAnnounceTime;
t = torStat->manualAnnounceTime;
refresh_countdown_lb( l, t );
}

View File

@ -166,11 +166,11 @@ torrentStatus( tr_handle * handle, tr_benc * args_in, tr_benc * args_out )
tr_torrent * tor = torrents[i];
const tr_stat * st = tr_torrentStat( tor );
const int * f = st->peersFrom;
const struct tr_tracker_stat * s = &st->trackerStat;
tr_benc * d = tr_bencListAddDict( list, 35 );
tr_benc * d = tr_bencListAddDict( list, 40 );
tr_benc * t;
tr_bencDictAddInt( d, "activityDate", st->activityDate );
tr_bencDictAddStr( d, "announceResponse", st->announceResponse );
tr_bencDictAddStr( d, "announceURL", st->announceURL );
tr_bencDictAddInt( d, "completedFromTracker", st->completedFromTracker );
tr_bencDictAddInt( d, "corruptEver", st->corruptEver );
@ -182,9 +182,13 @@ torrentStatus( tr_handle * handle, tr_benc * args_in, tr_benc * args_out )
tr_bencDictAddInt( d, "haveUnchecked", st->haveUnchecked );
tr_bencDictAddInt( d, "haveValid", st->haveValid );
tr_bencDictAddInt( d, "id", st->id );
tr_bencDictAddInt( d, "lastAnnounceTime", st->lastAnnounceTime );
tr_bencDictAddInt( d, "lastScrapeTime", st->lastScrapeTime );
tr_bencDictAddInt( d, "leechers", st->leechers );
tr_bencDictAddInt( d, "leftUntilDone", st->leftUntilDone );
tr_bencDictAddInt( d, "manualAnnounceTime", st->manualAnnounceTime );
tr_bencDictAddInt( d, "nextAnnounceTime", st->nextAnnounceTime );
tr_bencDictAddInt( d, "nextScrapeTime", st->nextScrapeTime );
tr_bencDictAddInt( d, "peersConnected", st->peersConnected );
t = tr_bencDictAddDict( d, "peersFrom", 4 );
tr_bencDictAddInt( t, "cache", f[TR_PEER_FROM_CACHE] );
@ -200,20 +204,13 @@ torrentStatus( tr_handle * handle, tr_benc * args_in, tr_benc * args_out )
tr_bencDictAddDouble( d, "rateUpload", st->rateUpload );
tr_bencDictAddDouble( d, "ratio", st->ratio );
tr_bencDictAddDouble( d, "recheckProgress", st->recheckProgress );
tr_bencDictAddStr( d, "scrapeResponse", st->scrapeResponse );
tr_bencDictAddStr( d, "scrapeURL", st->scrapeURL );
tr_bencDictAddInt( d, "seeders", st->seeders );
tr_bencDictAddInt( d, "sizeWhenDone", st->sizeWhenDone );
tr_bencDictAddInt( d, "startDate", st->startDate );
tr_bencDictAddInt( d, "status", st->status );
tr_bencDictAddDouble( d, "swarmSpeed", st->swarmSpeed );
t = tr_bencDictAddDict( d, "trackerStat", 7 );
tr_bencDictAddStr( t, "announceResponse", s->announceResponse );
tr_bencDictAddInt( t, "lastAnnounceTime", s->lastAnnounceTime );
tr_bencDictAddInt( t, "lastScrapeTime", s->lastScrapeTime );
tr_bencDictAddInt( t, "nextAnnounceTime", s->nextAnnounceTime );
tr_bencDictAddInt( t, "nextScrapeTime", s->nextScrapeTime );
tr_bencDictAddInt( t, "nextScrapeTime", s->nextScrapeTime );
tr_bencDictAddStr( t, "scrapeResponse", s->scrapeResponse );
tr_bencDictAddInt( d, "uploadedEver", st->uploadedEver );
}

View File

@ -106,4 +106,9 @@ void tr_globalLock ( tr_session * );
void tr_globalUnlock ( tr_session * );
int tr_globalIsLocked ( const tr_session * );
#define TR_ERROR_IS_IO(e) (TR_ERROR_IO_PARENT<=(e) && (e)<=TR_ERROR_IO_OTHER)
#define TR_ERROR_IS_TC(e) (TR_ERROR_TC_ERROR<=(e) && (e)<=TR_ERROR_TC_WARNING)
#endif

View File

@ -706,11 +706,10 @@ tr_torrentStat( tr_torrent * tor )
ti = tr_trackerGetAddress( tor->tracker );
s->announceURL = ti ? ti->announce : NULL;
s->scrapeURL = ti ? ti->scrape : NULL;
tr_trackerStat( tc, &s->trackerStat );
tr_trackerStat( tc, s );
tr_trackerGetCounts( tc, &s->completedFromTracker,
&s->leechers,
&s->seeders );
tr_peerMgrTorrentStats( tor->handle->peerMgr,
tor->info.hash,
&s->peersKnown,
@ -719,8 +718,6 @@ tr_torrentStat( tr_torrent * tor )
&s->peersGettingFromUs,
s->peersFrom );
s->manualAnnounceTime = tr_trackerGetManualAnnounceTime( tor->tracker );
s->percentComplete = tr_cpPercentComplete ( tor->completion );
s->percentDone = tr_cpPercentDone( tor->completion );
@ -913,14 +910,6 @@ tr_torrentSetHasPiece( tr_torrent * tor, tr_piece_index_t pieceIndex, int has )
tr_torrentUnlock( tor );
}
void
tr_torrentRemoveSaved( tr_torrent * tor )
{
tr_metainfoRemoveSaved( tor->handle, &tor->info );
tr_torrentRemoveResume( tor );
}
/***
****
***/
@ -1113,8 +1102,10 @@ closeTorrent( void * vtor )
tr_torrentSaveResume( tor );
tor->isRunning = 0;
stopTorrent( tor );
if( tor->isDeleting )
tr_torrentRemoveSaved( tor );
if( tor->isDeleting ) {
tr_metainfoRemoveSaved( tor->handle, &tor->info );
tr_torrentRemoveResume( tor );
}
freeTorrent( tor );
}

View File

@ -986,8 +986,8 @@ tr_trackerChangeMyPort( tr_tracker * t )
}
void
tr_trackerStat( const tr_tracker * t,
struct tr_tracker_stat * setme)
tr_trackerStat( const tr_tracker * t,
struct tr_stat * setme)
{
assert( t );
assert( setme );
@ -996,7 +996,7 @@ tr_trackerStat( const tr_tracker * t,
setme->nextScrapeTime = t->scrapeAt;
setme->lastAnnounceTime = t->lastAnnounceTime;
setme->nextAnnounceTime = t->reannounceAt;
setme->nextManualAnnounceTime = t->manualAnnounceAllowedAt;
setme->manualAnnounceTime = t->manualAnnounceAllowedAt;
if( t->lastScrapeResponse == -1 ) /* never been scraped */
*setme->scrapeResponse = '\0';

View File

@ -72,7 +72,7 @@ void tr_trackerUnsubscribe ( struct tr_tracker * tracker,
***/
void tr_trackerStat ( const tr_tracker * tracker,
struct tr_tracker_stat * setme);
struct tr_stat * setme);
void tr_trackerStart ( struct tr_tracker * );

View File

@ -88,29 +88,32 @@ typedef struct tr_ctor tr_ctor;
* subdirectories will be found, such as "torrents",
* "resume", and "blocklists".
* TR_DEFAULT_CONFIG_DIR can be used as a default.
* @param downloadDir the default directory to save torrents that are added.
* This can be changed per-session with tr_sessionSetDownloadDir()
* and per-torrent with tr_ctorSetDownloadDir().
* @param tag currently only used for locating legacy versions of
* fastresume files. valid tags: beos, cli, daemon, gtk, macos, wx
* @param downloadDir The default directory to save added torrents.
* This can be changed per-session with
* tr_sessionSetDownloadDir() and per-torrent with
* tr_ctorSetDownloadDir().
* @param tag Obsolete. Only used now for locating legacy fastresume files.
* Valid tags: beos, cli, daemon, gtk, macos, wx
* @param isPexEnabled whether or not PEX is allowed for non-private torrents.
* This can be changed per-session with tr_sessionSetPexEnabled().
* TR_DEFAULT_PEX_ENABLED can be used as a default.
* @param isPortForwardingEnabled If true, libtransmission will attempt to find a local
* UPnP-enabled or NATPMP-enabled router and forward a
* port from there to the local machine. This is so that
* remote peers can initiate connections with us.
* TR_DEFAULT_PORT_FORWARDING_ENABLED can be used as a default.
* @param publicPort Port number to open for listening to incoming peer connections.
* TR_DEFAULT_PORT can be used as a default.
* This can be changed per-session with
* tr_sessionSetPexEnabled().
* TR_DEFAULT_PEX_ENABLED is the default.
* @param isPortForwardingEnabled If true, libtransmission will attempt
* to find a local UPnP-enabled or NATPMP-enabled
* router and forward a port from there to the local
* machine. This is so remote peers can initiate
* connections with us.
* TR_DEFAULT_PORT_FORWARDING_ENABLED is the default.
* @param publicPort Port number to open for incoming peer connections.
* TR_DEFAULT_PORT is the default.
* @param encryptionMode must be one of TR_PLAINTEXT_PREFERRED,
* TR_ENCRYPTION_PREFERRED, or TR_ENCRYPTION_REQUIRED.
* @param isUploadLimitEnabled If true, libtransmission will limit the entire
* session's upload speed based on `uploadLimit'.
* session's upload speed from `uploadLimit'.
* @param uploadLimit The speed limit to use for the entire session when
* isUploadLimitEnabled is true.
* @param isDownloadLimitEnabled If true, libtransmission will limit the entire
* session's download speed based on `downloadLimit'.
* session's download speed from `downloadLimit'.
* @param downloadLimit The speed limit to use for the entire session when
* isDownloadLimitEnabled is true.
* @param peerLimit The maximum number of peer connections allowed in a session.
@ -155,7 +158,14 @@ tr_handle * tr_sessionInit( const char * configDir,
void tr_sessionClose( tr_handle * );
/**
* Set the per-session default download folder for torrents that haven't been added yet.
* Returns the configuration directory passed into tr_sessionInitFull().
* This is where transmission stores its .torrent files, .resume files,
* blocklists, etc.
*/
const char * tr_sessionGetConfigDir( const tr_handle * );
/**
* Set the per-session default download folder for new torrents.
* @see tr_sessionInitFull()
* @see tr_ctorSetDownloadDir()
*/
@ -173,10 +183,10 @@ int tr_sessionGetRPCPort( const tr_handle * );
/**
* Specify access control list (ACL). ACL is a comma separated list
* of IP subnets, each subnet is prepended by - or + sign. Plus
* means allow, minus means deny. If subnet mask is omitted, like
* "-1.2.3.4", then it means single IP address. Mask may vary from 0
* to 32 inclusive.
* of IP subnets, each subnet is prepended by a '-' or '+' sign.
* Plus means allow, minus means deny. If the subnet mask is omitted,
* like * "-1.2.3.4", it means a single IP address. The mask may vary
* from 0 to 32 inclusive.
*
* The default string is "+127.0.0.1"
*
@ -258,14 +268,6 @@ tr_encryption_mode tr_sessionGetEncryption( tr_handle * handle );
void tr_sessionSetEncryption( tr_handle * handle, tr_encryption_mode mode );
/***********************************************************************
* tr_getPrefsDirectory
***********************************************************************
* Returns the full path to a directory which can be used to store
* preferences. The string belongs to libtransmission, do not free it.
**********************************************************************/
const char * tr_sessionGetConfigDir( const tr_handle * );
/***********************************************************************
** Incoming Peer Connections Port
@ -485,26 +487,39 @@ enum
typedef int8_t tr_priority_t;
/* set a batch of files to a particular priority.
* priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW */
/**
* Set a batch of files to a particular priority.
* Priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW
*/
void tr_torrentSetFilePriorities( tr_torrent * tor,
tr_file_index_t * files,
tr_file_index_t fileCount,
tr_priority_t priority );
/* returns a malloc()ed array of tor->info.fileCount items,
* each holding a value of TR_PRI_NORMAL, _HIGH, or _LOW.
free the array when done. */
/**
* Get this torrent's file priorities.
*
* @return A malloc()ed array of tor->info.fileCount items,
* each holding a value of TR_PRI_NORMAL, _HIGH, or _LOW.
* The caller must free() the array when done.
*/
tr_priority_t* tr_torrentGetFilePriorities( const tr_torrent * );
/* single-file form of tr_torrentGetFilePriorities.
* returns one of TR_PRI_NORMAL, _HIGH, or _LOW. */
tr_priority_t tr_torrentGetFilePriority( const tr_torrent *, tr_file_index_t file );
/**
* Single-file form of tr_torrentGetFilePriorities.
* returns one of TR_PRI_NORMAL, _HIGH, or _LOW.
*/
tr_priority_t tr_torrentGetFilePriority( const tr_torrent *,
tr_file_index_t file );
/* returns true if the file's `download' flag is set */
/**
* Returns true if the file's `download' flag is set.
*/
int tr_torrentGetFileDL( const tr_torrent *, tr_file_index_t file );
/* set a batch of files to be downloaded or not. */
/**
* Set a batch of files to be downloaded or not.
*/
void tr_torrentSetFileDLs ( tr_torrent * tor,
tr_file_index_t * files,
tr_file_index_t fileCount,
@ -773,14 +788,6 @@ void tr_torrentAvailability( const tr_torrent *, int8_t * tab, int size );
void tr_torrentAmountFinished( const tr_torrent * tor, float * tab, int size );
/***********************************************************************
* tr_torrentRemoveSaved
***********************************************************************
* delete's Transmission's copy of the torrent's metadata from
* tr_getTorrentDir().
**********************************************************************/
void tr_torrentRemoveSaved( tr_torrent * );
void tr_torrentVerify( tr_torrent * );
/**
@ -904,47 +911,6 @@ typedef enum tr_errno
}
tr_errno;
#define TR_ERROR_IS_IO(e) (TR_ERROR_IO_PARENT<=(e) && (e)<=TR_ERROR_IO_OTHER)
#define TR_ERROR_IS_TC(e) (TR_ERROR_TC_ERROR<=(e) && (e)<=TR_ERROR_TC_WARNING)
struct tr_tracker_stat
{
/* This is the unmodified string returned by the tracker in response
* to the torrent's most recent scrape request. If no request was
* sent or there was no response, this string is empty. */
char scrapeResponse[256];
/* The unmodified string returned by the tracker in response
* to the torrent's most recent scrape request. If no request was
* sent or there was no response, this string is empty. */
char announceResponse[256];
/* Time the most recent scrape request was sent,
* or zero if one hasn't been sent yet. */
time_t lastScrapeTime;
/* Time when the next scrape request will be sent.
* This value is always a valid time. */
time_t nextScrapeTime;
/* Time the most recent announce request was sent,
* or zero if one hasn't been sent yet. */
time_t lastAnnounceTime;
/* Time when the next reannounce request will be sent,
* or zero if the torrent is stopped. */
time_t nextAnnounceTime;
/* When the tracker will allow a human-driven "manual" announce to be sent,
* derived from the "min interval" field given by the tracker.
* This value is 0 when the torrent is stopped.
* This value is ~(time_t)0 if the tracker returned a serious error.
* Otherwise, the value is a valid time.
* @see tr_torrentManualUpdate( tr_torrent * );
* @see tr_torrentCanManualUpdate( const tr_torrent * ); */
time_t nextManualAnnounceTime;
};
tr_torrent_status tr_torrentGetStatus( tr_torrent * );
enum
@ -962,8 +928,6 @@ struct tr_stat
tr_torrent_status status;
struct tr_tracker_stat trackerStat;
char * announceURL;
char * scrapeURL;
@ -999,11 +963,6 @@ struct tr_stat
int leechers;
int completedFromTracker;
/* if the torrent is running, this is the time at which
* the client can manually ask the torrent's tracker
* for more peers. otherwise, the value is zero. */
time_t manualAnnounceTime;
/* Byte count of all the piece data we'll have downloaded when we're done.
* whether or not we have it yet. [0...tr_info.totalSize] */
uint64_t sizeWhenDone;
@ -1038,6 +997,37 @@ struct tr_stat
* moved to `corrupt' or `haveValid'. */
uint64_t haveUnchecked;
/* This is the unmodified string returned by the tracker in response
* to the torrent's most recent scrape request. If no request was
* sent or there was no response, this string is empty. */
char scrapeResponse[256];
/* The unmodified string returned by the tracker in response
* to the torrent's most recent scrape request. If no request was
* sent or there was no response, this string is empty. */
char announceResponse[256];
/* Time the most recent scrape request was sent,
* or zero if one hasn't been sent yet. */
time_t lastScrapeTime;
/* Time when the next scrape request will be sent.
* This value is always a valid time. */
time_t nextScrapeTime;
/* Time the most recent announce request was sent,
* or zero if one hasn't been sent yet. */
time_t lastAnnounceTime;
/* Time when the next reannounce request will be sent,
* or zero if the torrent is stopped. */
time_t nextAnnounceTime;
/* if the torrent is running, this is the time at which
* the client can manually ask the torrent's tracker
* for more peers. otherwise, the value is zero. */
time_t manualAnnounceTime;
float swarmSpeed;
#define TR_RATIO_NA -1

View File

@ -728,13 +728,13 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
- (NSDate *) lastAnnounceTime
{
int date = fStat->trackerStat.lastAnnounceTime;
int date = fStat->lastAnnounceTime;
return date > 0 ? [NSDate dateWithTimeIntervalSince1970: date] : nil;
}
- (int) nextAnnounceTime
{
int date = fStat->trackerStat.nextAnnounceTime;
int date = fStat->nextAnnounceTime;
if (date <= 0)
return -1;
@ -744,7 +744,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
- (NSString *) announceResponse
{
return [NSString stringWithUTF8String: fStat->trackerStat.announceResponse];
return [NSString stringWithUTF8String: fStat->announceResponse];
}
- (NSString *) trackerAddressScrape
@ -754,13 +754,13 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
- (NSDate *) lastScrapeTime
{
int date = fStat->trackerStat.lastScrapeTime;
int date = fStat->lastScrapeTime;
return date > 0 ? [NSDate dateWithTimeIntervalSince1970: date] : nil;
}
- (int) nextScrapeTime
{
int date = fStat->trackerStat.nextScrapeTime;
int date = fStat->nextScrapeTime;
if (date <= 0)
return -1;
@ -770,7 +770,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
- (NSString *) scrapeResponse
{
return [NSString stringWithUTF8String: fStat->trackerStat.scrapeResponse];
return [NSString stringWithUTF8String: fStat->scrapeResponse];
}
- (NSArray *) allTrackers: (BOOL) separators