Changeset 5911


Ignore:
Timestamp:
May 22, 2008, 11:11:21 PM (14 years ago)
Author:
charles
Message:

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.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/details.c

    r5843 r5911  
    12141214
    12151215    l = page->last_scrape_time_lb;
    1216     t = torStat->trackerStat.lastScrapeTime;
     1216    t = torStat->lastScrapeTime;
    12171217    refresh_time_lb( l, t );
    12181218
    12191219    l = page->last_scrape_response_lb;
    1220     gtk_label_set_text( GTK_LABEL( l ), torStat->trackerStat.scrapeResponse );
     1220    gtk_label_set_text( GTK_LABEL( l ), torStat->scrapeResponse );
    12211221
    12221222    l = page->next_scrape_countdown_lb;
    1223     t = torStat->trackerStat.nextScrapeTime;
     1223    t = torStat->nextScrapeTime;
    12241224    refresh_countdown_lb( l, t );
    12251225
    12261226    l = page->last_announce_time_lb;
    1227     t = torStat->trackerStat.lastAnnounceTime;
     1227    t = torStat->lastAnnounceTime;
    12281228    refresh_time_lb( l, t );
    12291229
    12301230    l = page->last_announce_response_lb;
    1231     gtk_label_set_text( GTK_LABEL( l ), torStat->trackerStat.announceResponse );
     1231    gtk_label_set_text( GTK_LABEL( l ), torStat->announceResponse );
    12321232
    12331233    l = page->next_announce_countdown_lb;
    1234     t = torStat->trackerStat.nextAnnounceTime;
     1234    t = torStat->nextAnnounceTime;
    12351235    refresh_countdown_lb( l, t );
    12361236
    12371237    l = page->manual_announce_countdown_lb;
    1238     t = torStat->trackerStat.nextManualAnnounceTime;
     1238    t = torStat->manualAnnounceTime;
    12391239    refresh_countdown_lb( l, t );
    12401240}
  • trunk/libtransmission/rpc.c

    r5908 r5911  
    167167        const tr_stat * st = tr_torrentStat( tor );
    168168        const int * f = st->peersFrom;
    169         const struct tr_tracker_stat * s = &st->trackerStat;
    170         tr_benc * d = tr_bencListAddDict( list, 35 );
     169        tr_benc * d = tr_bencListAddDict( list, 40 );
    171170        tr_benc * t;
    172171
    173172        tr_bencDictAddInt( d, "activityDate", st->activityDate );
     173        tr_bencDictAddStr( d, "announceResponse", st->announceResponse );
    174174        tr_bencDictAddStr( d, "announceURL", st->announceURL );
    175175        tr_bencDictAddInt( d, "completedFromTracker", st->completedFromTracker );
     
    183183        tr_bencDictAddInt( d, "haveValid", st->haveValid );
    184184        tr_bencDictAddInt( d, "id", st->id );
     185        tr_bencDictAddInt( d, "lastAnnounceTime", st->lastAnnounceTime );
     186        tr_bencDictAddInt( d, "lastScrapeTime", st->lastScrapeTime );
    185187        tr_bencDictAddInt( d, "leechers", st->leechers );
    186188        tr_bencDictAddInt( d, "leftUntilDone", st->leftUntilDone );
    187189        tr_bencDictAddInt( d, "manualAnnounceTime", st->manualAnnounceTime );
     190        tr_bencDictAddInt( d, "nextAnnounceTime", st->nextAnnounceTime );
     191        tr_bencDictAddInt( d, "nextScrapeTime", st->nextScrapeTime );
    188192        tr_bencDictAddInt( d, "peersConnected", st->peersConnected );
    189193        t = tr_bencDictAddDict( d, "peersFrom", 4 );
     
    201205        tr_bencDictAddDouble( d, "ratio", st->ratio );
    202206        tr_bencDictAddDouble( d, "recheckProgress", st->recheckProgress );
     207        tr_bencDictAddStr( d, "scrapeResponse", st->scrapeResponse );
    203208        tr_bencDictAddStr( d, "scrapeURL", st->scrapeURL );
    204209        tr_bencDictAddInt( d, "seeders", st->seeders );
     
    207212        tr_bencDictAddInt( d, "status", st->status );
    208213        tr_bencDictAddDouble( d, "swarmSpeed", st->swarmSpeed );
    209         t = tr_bencDictAddDict( d, "trackerStat", 7 );
    210             tr_bencDictAddStr( t, "announceResponse", s->announceResponse );
    211             tr_bencDictAddInt( t, "lastAnnounceTime", s->lastAnnounceTime );
    212             tr_bencDictAddInt( t, "lastScrapeTime", s->lastScrapeTime );
    213             tr_bencDictAddInt( t, "nextAnnounceTime", s->nextAnnounceTime );
    214             tr_bencDictAddInt( t, "nextScrapeTime", s->nextScrapeTime );
    215             tr_bencDictAddInt( t, "nextScrapeTime", s->nextScrapeTime );
    216             tr_bencDictAddStr( t, "scrapeResponse", s->scrapeResponse );
    217214        tr_bencDictAddInt( d, "uploadedEver", st->uploadedEver );
    218215    }
  • trunk/libtransmission/session.h

    r5900 r5911  
    107107int  tr_globalIsLocked   ( const tr_session * );
    108108
     109
     110#define TR_ERROR_IS_IO(e) (TR_ERROR_IO_PARENT<=(e) && (e)<=TR_ERROR_IO_OTHER)
     111#define TR_ERROR_IS_TC(e) (TR_ERROR_TC_ERROR<=(e) && (e)<=TR_ERROR_TC_WARNING)
     112
     113
    109114#endif
  • trunk/libtransmission/torrent.c

    r5908 r5911  
    707707    s->announceURL = ti ? ti->announce : NULL;
    708708    s->scrapeURL   = ti ? ti->scrape   : NULL;
    709     tr_trackerStat( tc, &s->trackerStat );
     709    tr_trackerStat( tc, s );
    710710    tr_trackerGetCounts( tc, &s->completedFromTracker,
    711711                             &s->leechers,
    712712                             &s->seeders );
    713 
    714713    tr_peerMgrTorrentStats( tor->handle->peerMgr,
    715714                            tor->info.hash,
     
    719718                            &s->peersGettingFromUs,
    720719                             s->peersFrom );
    721 
    722     s->manualAnnounceTime = tr_trackerGetManualAnnounceTime( tor->tracker );
    723720
    724721    s->percentComplete = tr_cpPercentComplete ( tor->completion );
     
    914911}
    915912
    916 void
    917 tr_torrentRemoveSaved( tr_torrent * tor )
    918 {
    919     tr_metainfoRemoveSaved( tor->handle, &tor->info );
    920 
    921     tr_torrentRemoveResume( tor );
    922 }
    923 
    924913/***
    925914****
     
    11141103    tor->isRunning = 0;
    11151104    stopTorrent( tor );
    1116     if( tor->isDeleting )
    1117         tr_torrentRemoveSaved( tor );
     1105    if( tor->isDeleting ) {
     1106        tr_metainfoRemoveSaved( tor->handle, &tor->info );
     1107        tr_torrentRemoveResume( tor );
     1108    }
    11181109    freeTorrent( tor );
    11191110}
  • trunk/libtransmission/tracker.c

    r5859 r5911  
    987987
    988988void
    989 tr_trackerStat( const tr_tracker       * t,
    990                 struct tr_tracker_stat * setme)
     989tr_trackerStat( const tr_tracker * t,
     990                struct tr_stat  * setme)
    991991{
    992992    assert( t );
     
    997997    setme->lastAnnounceTime = t->lastAnnounceTime;
    998998    setme->nextAnnounceTime = t->reannounceAt;
    999     setme->nextManualAnnounceTime = t->manualAnnounceAllowedAt;
     999    setme->manualAnnounceTime = t->manualAnnounceAllowedAt;
    10001000
    10011001    if( t->lastScrapeResponse == -1 ) /* never been scraped */
  • trunk/libtransmission/tracker.h

    r5647 r5911  
    7373
    7474void tr_trackerStat                         ( const tr_tracker       * tracker,
    75                                               struct tr_tracker_stat * setme);
     75                                              struct tr_stat        * setme);
    7676
    7777void tr_trackerStart                        ( struct tr_tracker * );
  • trunk/libtransmission/transmission.h

    r5908 r5911  
    8989 *                  "resume", and "blocklists".
    9090 *                  TR_DEFAULT_CONFIG_DIR can be used as a default.
    91  * @param downloadDir the default directory to save torrents that are added.
    92  *                    This can be changed per-session with tr_sessionSetDownloadDir()
    93  *                    and per-torrent with tr_ctorSetDownloadDir().
    94  * @param tag currently only used for locating legacy versions of
    95  *            fastresume files.  valid tags: beos, cli, daemon, gtk, macos, wx
     91 * @param downloadDir The default directory to save added torrents.
     92 *                    This can be changed per-session with
     93 *                    tr_sessionSetDownloadDir() and per-torrent with
     94 *                    tr_ctorSetDownloadDir().
     95 * @param tag   Obsolete.  Only used now for locating legacy fastresume files.
     96 *              Valid tags: beos, cli, daemon, gtk, macos, wx
    9697 * @param isPexEnabled whether or not PEX is allowed for non-private torrents.
    97  *                     This can be changed per-session  with tr_sessionSetPexEnabled().
    98  *                     TR_DEFAULT_PEX_ENABLED can be used as a default.
    99  * @param isPortForwardingEnabled If true, libtransmission will attempt to find a local
    100  *                                UPnP-enabled or NATPMP-enabled router and forward a
    101  *                                port from there to the local machine.  This is so that
    102  *                                remote peers can initiate connections with us.
    103  *                                TR_DEFAULT_PORT_FORWARDING_ENABLED can be used as a default.
    104  * @param publicPort Port number to open for listening to incoming peer connections.
    105  *                   TR_DEFAULT_PORT can be used as a default.
     98 *                     This can be changed per-session with
     99 *                     tr_sessionSetPexEnabled().
     100 *                     TR_DEFAULT_PEX_ENABLED is the default.
     101 * @param isPortForwardingEnabled If true, libtransmission will attempt
     102 *                       to find a local UPnP-enabled or NATPMP-enabled
     103 *                       router and forward a port from there to the local
     104 *                       machine.  This is so remote peers can initiate
     105 *                       connections with us.
     106 *                       TR_DEFAULT_PORT_FORWARDING_ENABLED is the default.
     107 * @param publicPort Port number to open for incoming peer connections.
     108 *                   TR_DEFAULT_PORT is the default.
    106109 * @param encryptionMode must be one of TR_PLAINTEXT_PREFERRED,
    107110 *                       TR_ENCRYPTION_PREFERRED, or TR_ENCRYPTION_REQUIRED.
    108111 * @param isUploadLimitEnabled If true, libtransmission will limit the entire
    109  *                             session's upload speed based on `uploadLimit'.
     112 *                             session's upload speed from `uploadLimit'.
    110113 * @param uploadLimit The speed limit to use for the entire session when
    111114 *                    isUploadLimitEnabled is true.
    112115 * @param isDownloadLimitEnabled If true, libtransmission will limit the entire
    113  *                               session's download speed based on `downloadLimit'.
     116 *                               session's download speed from `downloadLimit'.
    114117 * @param downloadLimit The speed limit to use for the entire session when
    115118 *                      isDownloadLimitEnabled is true.
     
    156159
    157160/**
    158  * Set the per-session default download folder for torrents that haven't been added yet.
     161 * Returns the configuration directory passed into tr_sessionInitFull().
     162 * This is where transmission stores its .torrent files, .resume files,
     163 * blocklists, etc.
     164 */
     165const char * tr_sessionGetConfigDir( const tr_handle * );
     166
     167/**
     168 * Set the per-session default download folder for new torrents.
    159169 * @see tr_sessionInitFull()
    160170 * @see tr_ctorSetDownloadDir()
     
    174184/**
    175185 * Specify access control list (ACL). ACL is a comma separated list
    176  * of IP subnets, each subnet is prepended by ’-’ or ’+’ sign. Plus
    177  * means allow, minus means deny. If subnet mask is omitted, like
    178  * "-1.2.3.4", then it means single IP address. Mask may vary from 0
    179  * to 32 inclusive.
     186 * of IP subnets, each subnet is prepended by a '-' or '+' sign.
     187 * Plus means allow, minus means deny. If the subnet mask is omitted,
     188 * like * "-1.2.3.4", it means a single IP address. The mask may vary
     189 * from 0 to 32 inclusive.
    180190 *
    181191 * The default string is "+127.0.0.1"
     
    259269void tr_sessionSetEncryption( tr_handle * handle, tr_encryption_mode mode );
    260270
    261 /***********************************************************************
    262  * tr_getPrefsDirectory
    263  ***********************************************************************
    264  * Returns the full path to a directory which can be used to store
    265  * preferences. The string belongs to libtransmission, do not free it.
    266  **********************************************************************/
    267 const char * tr_sessionGetConfigDir( const tr_handle * );
    268 
    269271
    270272/***********************************************************************
     
    486488typedef int8_t tr_priority_t;
    487489
    488 /* set a batch of files to a particular priority.
    489  * priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW */
     490/**
     491 * Set a batch of files to a particular priority.
     492 * Priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW
     493 */
    490494void tr_torrentSetFilePriorities( tr_torrent        * tor,
    491495                                  tr_file_index_t   * files,
     
    493497                                  tr_priority_t       priority );
    494498
    495 /* returns a malloc()ed array of tor->info.fileCount items,
    496  * each holding a value of TR_PRI_NORMAL, _HIGH, or _LOW.
    497    free the array when done. */
     499/**
     500 * Get this torrent's file priorities.
     501 *
     502 * @return A malloc()ed array of tor->info.fileCount items,
     503 *         each holding a value of TR_PRI_NORMAL, _HIGH, or _LOW.
     504 *         The caller must free() the array when done.
     505 */
    498506tr_priority_t* tr_torrentGetFilePriorities( const tr_torrent * );
    499507
    500 /* single-file form of tr_torrentGetFilePriorities.
    501  * returns one of TR_PRI_NORMAL, _HIGH, or _LOW. */
    502 tr_priority_t tr_torrentGetFilePriority( const tr_torrent *, tr_file_index_t file );
    503 
    504 /* returns true if the file's `download' flag is set */
     508/**
     509 * Single-file form of tr_torrentGetFilePriorities.
     510 * returns one of TR_PRI_NORMAL, _HIGH, or _LOW.
     511 */
     512tr_priority_t tr_torrentGetFilePriority( const tr_torrent *,
     513                                         tr_file_index_t file );
     514
     515/**
     516 * Returns true if the file's `download' flag is set.
     517 */
    505518int tr_torrentGetFileDL( const tr_torrent *, tr_file_index_t file );
    506519
    507 /* set a batch of files to be downloaded or not. */
     520/**
     521 * Set a batch of files to be downloaded or not.
     522 */
    508523void tr_torrentSetFileDLs ( tr_torrent      * tor,
    509524                            tr_file_index_t * files,
     
    774789void tr_torrentAmountFinished( const tr_torrent * tor, float * tab, int size );
    775790
    776 /***********************************************************************
    777  * tr_torrentRemoveSaved
    778  ***********************************************************************
    779  * delete's Transmission's copy of the torrent's metadata from
    780  * tr_getTorrentDir().
    781  **********************************************************************/
    782 void tr_torrentRemoveSaved( tr_torrent * );
    783 
    784791void tr_torrentVerify( tr_torrent * );
    785792
     
    905912tr_errno;
    906913
    907 #define TR_ERROR_IS_IO(e) (TR_ERROR_IO_PARENT<=(e) && (e)<=TR_ERROR_IO_OTHER)
    908 #define TR_ERROR_IS_TC(e) (TR_ERROR_TC_ERROR<=(e) && (e)<=TR_ERROR_TC_WARNING)
    909 
    910 struct tr_tracker_stat
    911 {
    912     /* This is the unmodified string returned by the tracker in response
    913      * to the torrent's most recent scrape request.  If no request was
    914      * sent or there was no response, this string is empty. */
    915     char scrapeResponse[256];
    916 
    917     /* The unmodified string returned by the tracker in response
    918      * to the torrent's most recent scrape request.  If no request was
    919      * sent or there was no response, this string is empty. */
    920     char announceResponse[256];
    921 
    922     /* Time the most recent scrape request was sent,
    923      * or zero if one hasn't been sent yet. */
    924     time_t lastScrapeTime;
    925 
    926     /* Time when the next scrape request will be sent.
    927      * This value is always a valid time. */
    928     time_t nextScrapeTime;
    929 
    930     /* Time the most recent announce request was sent,
    931      * or zero if one hasn't been sent yet. */
    932     time_t lastAnnounceTime;
    933 
    934     /* Time when the next reannounce request will be sent,
    935      * or zero if the torrent is stopped. */
    936     time_t nextAnnounceTime;
    937 
    938     /* When the tracker will allow a human-driven "manual" announce to be sent,
    939      * derived from the "min interval" field given by the tracker.
    940      * This value is 0 when the torrent is stopped.
    941      * This value is ~(time_t)0 if the tracker returned a serious error.
    942      * Otherwise, the value is a valid time.
    943      * @see tr_torrentManualUpdate( tr_torrent * );
    944      * @see tr_torrentCanManualUpdate( const tr_torrent * ); */
    945     time_t nextManualAnnounceTime;
    946 };
    947 
    948914tr_torrent_status tr_torrentGetStatus( tr_torrent * );
    949915
     
    962928
    963929    tr_torrent_status status;
    964 
    965     struct tr_tracker_stat trackerStat;
    966930
    967931    char * announceURL;
     
    1000964    int completedFromTracker;
    1001965
     966    /* Byte count of all the piece data we'll have downloaded when we're done.
     967     * whether or not we have it yet. [0...tr_info.totalSize] */
     968    uint64_t sizeWhenDone;
     969
     970    /* Byte count of how much data is left to be downloaded until
     971     * we're done -- that is, until we've got all the pieces we wanted.
     972     * [0...tr_info.sizeWhenDone] */
     973    uint64_t leftUntilDone;
     974
     975    /* Byte count of all the piece data we want and don't have yet,
     976     * but that a connected peer does have. [0...leftUntilDone] */
     977    uint64_t desiredAvailable;
     978
     979    /* Byte count of all the corrupt data you've ever downloaded for
     980     * this torrent.  If you're on a poisoned torrent, this number can
     981     * grow very large. */
     982    uint64_t corruptEver;
     983
     984    /* Byte count of all data you've ever uploaded for this torrent. */
     985    uint64_t uploadedEver;
     986
     987    /* Byte count of all the non-corrupt data you've ever downloaded
     988     * for this torrent.  If you deleted the files and downloaded a second time,
     989     * this will be 2*totalSize.. */
     990    uint64_t downloadedEver;
     991
     992    /* Byte count of all the checksum-verified data we have for this torrent. */
     993    uint64_t haveValid;
     994
     995    /* Byte count of all the partial piece data we have for this torrent.
     996     * As pieces become complete, this value may decrease as portions of it are
     997     * moved to `corrupt' or `haveValid'. */
     998    uint64_t haveUnchecked;
     999
     1000    /* This is the unmodified string returned by the tracker in response
     1001     * to the torrent's most recent scrape request.  If no request was
     1002     * sent or there was no response, this string is empty. */
     1003    char scrapeResponse[256];
     1004
     1005    /* The unmodified string returned by the tracker in response
     1006     * to the torrent's most recent scrape request.  If no request was
     1007     * sent or there was no response, this string is empty. */
     1008    char announceResponse[256];
     1009
     1010    /* Time the most recent scrape request was sent,
     1011     * or zero if one hasn't been sent yet. */
     1012    time_t lastScrapeTime;
     1013
     1014    /* Time when the next scrape request will be sent.
     1015     * This value is always a valid time. */
     1016    time_t nextScrapeTime;
     1017
     1018    /* Time the most recent announce request was sent,
     1019     * or zero if one hasn't been sent yet. */
     1020    time_t lastAnnounceTime;
     1021
     1022    /* Time when the next reannounce request will be sent,
     1023     * or zero if the torrent is stopped. */
     1024    time_t nextAnnounceTime;
     1025
    10021026    /* if the torrent is running, this is the time at which
    10031027     * the client can manually ask the torrent's tracker
    10041028     * for more peers.  otherwise, the value is zero. */
    10051029    time_t manualAnnounceTime;
    1006 
    1007     /* Byte count of all the piece data we'll have downloaded when we're done.
    1008      * whether or not we have it yet. [0...tr_info.totalSize] */
    1009     uint64_t sizeWhenDone;
    1010 
    1011     /* Byte count of how much data is left to be downloaded until
    1012      * we're done -- that is, until we've got all the pieces we wanted.
    1013      * [0...tr_info.sizeWhenDone] */
    1014     uint64_t leftUntilDone;
    1015 
    1016     /* Byte count of all the piece data we want and don't have yet,
    1017      * but that a connected peer does have. [0...leftUntilDone] */
    1018     uint64_t desiredAvailable;
    1019 
    1020     /* Byte count of all the corrupt data you've ever downloaded for
    1021      * this torrent.  If you're on a poisoned torrent, this number can
    1022      * grow very large. */
    1023     uint64_t corruptEver;
    1024 
    1025     /* Byte count of all data you've ever uploaded for this torrent. */
    1026     uint64_t uploadedEver;
    1027 
    1028     /* Byte count of all the non-corrupt data you've ever downloaded
    1029      * for this torrent.  If you deleted the files and downloaded a second time,
    1030      * this will be 2*totalSize.. */
    1031     uint64_t downloadedEver;
    1032 
    1033     /* Byte count of all the checksum-verified data we have for this torrent. */
    1034     uint64_t haveValid;
    1035 
    1036     /* Byte count of all the partial piece data we have for this torrent.
    1037      * As pieces become complete, this value may decrease as portions of it are
    1038      * moved to `corrupt' or `haveValid'. */
    1039     uint64_t haveUnchecked;
    10401030
    10411031    float swarmSpeed;
  • trunk/macosx/Torrent.m

    r5910 r5911  
    729729- (NSDate *) lastAnnounceTime
    730730{
    731     int date = fStat->trackerStat.lastAnnounceTime;
     731    int date = fStat->lastAnnounceTime;
    732732    return date > 0 ? [NSDate dateWithTimeIntervalSince1970: date] : nil;
    733733}
     
    735735- (int) nextAnnounceTime
    736736{
    737     int date = fStat->trackerStat.nextAnnounceTime;
     737    int date = fStat->nextAnnounceTime;
    738738    if (date <= 0)
    739739        return -1;
     
    745745- (NSString *) announceResponse
    746746{
    747     return [NSString stringWithUTF8String: fStat->trackerStat.announceResponse];
     747    return [NSString stringWithUTF8String: fStat->announceResponse];
    748748}
    749749
     
    755755- (NSDate *) lastScrapeTime
    756756{
    757     int date = fStat->trackerStat.lastScrapeTime;
     757    int date = fStat->lastScrapeTime;
    758758    return date > 0 ? [NSDate dateWithTimeIntervalSince1970: date] : nil;
    759759}
     
    761761- (int) nextScrapeTime
    762762{
    763     int date = fStat->trackerStat.nextScrapeTime;
     763    int date = fStat->nextScrapeTime;
    764764    if (date <= 0)
    765765        return -1;
     
    771771- (NSString *) scrapeResponse
    772772{
    773     return [NSString stringWithUTF8String: fStat->trackerStat.scrapeResponse];
     773    return [NSString stringWithUTF8String: fStat->scrapeResponse];
    774774}
    775775
Note: See TracChangeset for help on using the changeset viewer.