Changeset 5975


Ignore:
Timestamp:
May 30, 2008, 3:19:07 PM (14 years ago)
Author:
charles
Message:

API cleanup: s/tr_torrentRates/tr_sessionGetSpeed/

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/tr-core.c

    r5955 r5975  
    633633    if( !isDisposed( core ) )
    634634    {
    635         tr_torrentRates( core->priv->handle,
    636                          &setme->clientDownloadSpeed,
    637                          &setme->clientUploadSpeed );
     635        tr_sessionGetSpeed( core->priv->handle,
     636                            &setme->clientDownloadSpeed,
     637                            &setme->clientUploadSpeed );
    638638
    639639        gtk_tree_model_foreach( core->priv->model,
  • trunk/gtk/tr-window.c

    r5908 r5975  
    650650    tr_handle * handle = tr_core_handle( p->core );
    651651
    652     tr_torrentRates( handle, &d, &u );
     652    tr_sessionGetSpeed( handle, &d, &u );
    653653    tr_strlspeed( buf, d, sizeof( buf ) );
    654654    gtk_label_set_text( GTK_LABEL( p->dl_lb ), buf );
  • trunk/libtransmission/session.c

    r5913 r5975  
    382382
    383383void
    384 tr_torrentRates( tr_handle * h, float * toClient, float * toPeer )
    385 {
    386     if( h )
    387     {
    388         tr_globalLock( h );
    389 
    390         if( toClient )
    391             *toClient = tr_rcRate( h->download );
    392         if( toPeer )
    393             *toPeer = tr_rcRate( h->upload );
    394 
    395         tr_globalUnlock( h );
    396     }
     384tr_sessionGetSpeed( const tr_handle  * session,
     385                    float            * toClient,
     386                    float            * toPeer )
     387{
     388    if( session && toClient )
     389        *toClient = tr_rcRate( session->download );
     390    if( session && toPeer )
     391        *toPeer = tr_rcRate( session->upload );
    397392}
    398393
  • trunk/libtransmission/transmission.h

    r5969 r5975  
    2323 *****************************************************************************/
    2424
     25/*
     26 * This file defines the public API for the libtransmission library.
     27 *
     28 * Other headers suitable for public consumption are bencode.h
     29 * and utils.h.  Most of the remaining headers in libtransmission
     30 * should be considered private to libtransmission.
     31 */
    2532#ifndef TR_TRANSMISSION_H
    2633#define TR_TRANSMISSION_H 1
     
    4249
    4350#define SHA_DIGEST_LENGTH 20
     51
    4452#ifdef __BEOS__
    4553# include <StorageDefs.h>
     
    7280typedef struct tr_handle tr_handle;
    7381typedef struct tr_info tr_info;
    74 typedef struct tr_stat tr_stat;
    7582typedef struct tr_torrent tr_torrent;
    7683
     
    8895
    8996/** @see tr_sessionInitFull */
    90 #define TR_DEFAULT_CONFIG_DIR                  tr_getDefaultConfigDir()
     97#define TR_DEFAULT_CONFIG_DIR               tr_getDefaultConfigDir()
    9198/** @see tr_sessionInitFull */
    92 #define TR_DEFAULT_PEX_ENABLED                 1
     99#define TR_DEFAULT_PEX_ENABLED              1
    93100/** @see tr_sessionInitFull */
    94 #define TR_DEFAULT_PORT_FORWARDING_ENABLED     0
     101#define TR_DEFAULT_PORT_FORWARDING_ENABLED  0
    95102/** @see tr_sessionInitFull */
    96 #define TR_DEFAULT_PORT                        51413
     103#define TR_DEFAULT_PORT                     51413
    97104/** @see tr_sessionInitFull */
    98 #define TR_DEFAULT_GLOBAL_PEER_LIMIT           200
     105#define TR_DEFAULT_GLOBAL_PEER_LIMIT        200
    99106/** @see tr_sessionInitFull */
    100 #define TR_DEFAULT_PEER_SOCKET_TOS             8
     107#define TR_DEFAULT_PEER_SOCKET_TOS          8
    101108/** @see tr_sessionInitFull */
    102 #define TR_DEFAULT_BLOCKLIST_ENABLED           0
     109#define TR_DEFAULT_BLOCKLIST_ENABLED        0
    103110/** @see tr_sessionInitFull */
    104 #define TR_DEFAULT_RPC_ENABLED                 0
     111#define TR_DEFAULT_RPC_ENABLED              0
    105112/** @see tr_sessionInitFull */
    106 #define TR_DEFAULT_RPC_PORT                    9091
     113#define TR_DEFAULT_RPC_PORT                 9091
    107114/** @see tr_sessionInitFull */
    108 #define TR_DEFAULT_RPC_PORT_STR                "9091"
     115#define TR_DEFAULT_RPC_PORT_STR             "9091"
    109116/** @see tr_sessionInitFull */
    110 #define TR_DEFAULT_RPC_ACL                     "+127.0.0.1"
     117#define TR_DEFAULT_RPC_ACL                  "+127.0.0.1"
    111118
    112119/**
     
    225232                                const char * rpcAccessControlList );
    226233
    227 /**
    228  * @brief shorter form of tr_sessionInitFull()
    229  *
    230  * @deprecated Use tr_sessionInitFull() instead.
    231  */
     234/** @brief Shorter form of tr_sessionInitFull()
     235    @deprecated Use tr_sessionInitFull() instead. */
    232236tr_handle * tr_sessionInit( const char * configDir,
    233237                            const char * downloadDir,
    234238                            const char * tag );
    235239
    236 /**
    237  * @brief end a libtransmission session
    238  * @see tr_sessionInitFull()
    239  */
     240/** @brief End a libtransmission session
     241    @see tr_sessionInitFull() */
    240242void tr_sessionClose( tr_handle * );
    241243
    242244/**
    243  * Returns the configuration directory passed into tr_sessionInitFull().
     245 * @brief Return the session's configuration directory
     246 *
    244247 * This is where transmission stores its .torrent files, .resume files,
    245248 * blocklists, etc.
     
    248251
    249252/**
    250  * Set the per-session default download folder for new torrents.
     253 * @brief Set the per-session default download folder for new torrents.
    251254 * @see tr_sessionInitFull()
    252255 * @see tr_sessionGetDownloadDir()
     
    255258void tr_sessionSetDownloadDir( tr_handle *, const char * downloadDir );
    256259
    257 /**
    258  * Get the default download folder for new torrents.
     260/** 
     261 * @brief Get the default download folder for new torrents.
    259262 *
    260263 * This is set by tr_sessionInitFull() or tr_sessionSetDownloadDir(),
     
    324327tr_rpc_callback_type;
    325328
    326 struct tr_torrent;
    327 
    328329typedef void ( *tr_rpc_func )( tr_handle            * handle,
    329330                               tr_rpc_callback_type   type,
     
    415416enum { TR_UP, TR_DOWN };
    416417
     418void tr_sessionGetSpeed( const tr_handle * session,
     419                         float           * overall_down_KiBs,
     420                         float           * overall_up_KiBs );
     421
    417422int tr_sessionIsSpeedLimitEnabled( const tr_handle   * session,
    418423                                   int                 up_or_down );
     
    429434
    430435uint16_t tr_sessionGetPeerLimit( const tr_handle * handle );
     436
    431437
    432438/**
     
    674680    @{ */
    675681
    676 /** Iterate through the torrents.
    677     Pass in a NULL pointer to get the first torrent.  */
    678 tr_torrent* tr_torrentNext( tr_handle *, tr_torrent * );
    679 
    680 /** Returns this torrent's unique ID.
    681     IDs are good as simple lookup keys, but are not persistent
    682     between sessions.  If you need that, use tr_info.hash or
    683     tr_info.hashString. */
     682/** @brief Frees memory allocated by tr_torrentNew().
     683           Running torrents are stopped first.  */
     684void tr_torrentFree( tr_torrent * );
     685
     686/** @brief Removes our .torrent and .resume files for
     687           this torrent, then calls tr_torrentFree(). */
     688void tr_torrentRemove( tr_torrent * );
     689
     690/** @brief Start a torrent */
     691void tr_torrentStart( tr_torrent * );
     692
     693/** @brief Stop (pause) a torrent */
     694void tr_torrentStop( tr_torrent * );
     695
     696/**
     697 * @brief Iterate through the torrents.
     698 *
     699 * Pass in a NULL pointer to get the first torrent.
     700 */
     701tr_torrent* tr_torrentNext( tr_handle * session, tr_torrent * );
     702
     703/**
     704 * @brief Returns this torrent's unique ID.
     705 *
     706 * IDs are good as simple lookup keys, but are not persistent
     707 * between sessions.  If you need that, use tr_info.hash or
     708 * tr_info.hashString.
     709 */
    684710int tr_torrentId( const tr_torrent * );
    685711
    686 /***********************************************************************
    687 *** Speed Limits
    688 **/
     712/****
     713***** Speed Limits
     714****/
    689715
    690716typedef enum
     
    710736                             int                 up_or_down );
    711737
    712 
    713 /***********************************************************************
    714 ***  Peer Limits
    715 **/
     738/****
     739*****  Peer Limits
     740****/
    716741
    717742void tr_torrentSetPeerLimit( tr_torrent  * tor,
     
    720745uint16_t tr_torrentGetPeerLimit( const tr_torrent  * tor );
    721746
    722 
    723 /***********************************************************************
    724  * Torrent Priorities
    725  **********************************************************************/
     747/****
     748*****  File Priorities
     749****/
    726750
    727751enum
     
    735759
    736760/**
    737  * Set a batch of files to a particular priority.
    738  * Priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW
     761 * @brief Set a batch of files to a particular priority.
     762 *
     763 * @param priority must be one of TR_PRI_NORMAL, _HIGH, or _LOW
    739764 */
    740765void tr_torrentSetFilePriorities( tr_torrent        * tor,
     
    744769
    745770/**
    746  * Get this torrent's file priorities.
     771 * @brief Get this torrent's file priorities.
    747772 *
    748773 * @return A malloc()ed array of tor->info.fileCount items,
    749  *         each holding a value of TR_PRI_NORMAL, _HIGH, or _LOW.
    750  *         The caller must free() the array when done.
     774 *         each holding a TR_PRI_NORMAL, TR_PRI_HIGH, or TR_PRI_LOW.
     775 *         It's the caller's responsibility to free() this.
    751776 */
    752777tr_priority_t* tr_torrentGetFilePriorities( const tr_torrent * );
    753778
    754779/**
    755  * Single-file form of tr_torrentGetFilePriorities.
    756  * returns one of TR_PRI_NORMAL, _HIGH, or _LOW.
     780 * @brief Single-file form of tr_torrentGetFilePriorities.
     781 * @return TR_PRI_NORMAL, TR_PRI_HIGH, or TR_PRI_LOW.
    757782 */
    758783tr_priority_t tr_torrentGetFilePriority( const tr_torrent *,
     
    760785
    761786/**
    762  * Returns true if the file's `download' flag is set.
     787 * @brief See if a file's `download' flag is set.
     788 * @return true if the file's `download' flag is set.
    763789 */
    764790int tr_torrentGetFileDL( const tr_torrent *, tr_file_index_t file );
    765791
    766 /**
    767  * Set a batch of files to be downloaded or not.
    768  */
     792/** @brief Set a batch of files to be downloaded or not. */
    769793void tr_torrentSetFileDLs ( tr_torrent      * tor,
    770794                            tr_file_index_t * files,
     
    772796                            int               do_download );
    773797
    774 /***********************************************************************
    775  * tr_torrentRates
    776  ***********************************************************************
    777  * Gets the total download and upload rates
    778  **********************************************************************/
    779 void tr_torrentRates( tr_handle *, float *, float * );
    780 
    781 
    782798
    783799const tr_info * tr_torrentInfo( const tr_torrent * );
     
    786802
    787803const char * tr_torrentGetDownloadDir( const tr_torrent * );
    788 
    789 void tr_torrentStart( tr_torrent * );
    790 
    791 void tr_torrentStop( tr_torrent * );
    792804
    793805
     
    840852int tr_torrentCanManualUpdate( const tr_torrent * );
    841853
    842 /** Return a pointer to an tr_stat structure with updated information
    843     on the torrent.  This is typically called by the GUI clients every
    844     second or so to get a new snapshot of the torrent's status. */
    845 const tr_stat * tr_torrentStat( tr_torrent * );
    846 
    847 /** Like tr_torrentStat(), but only recalculates the statistics if it's
    848     been longer than a second since they were last calculated.  This can
    849     reduce the CPU load if you're calling tr_torrentStat() frequently. */
    850 const tr_stat * tr_torrentStatCached( tr_torrent * );
    851 
    852854/***********************************************************************
    853855 * tr_torrentPeers
    854856 ***********************************************************************/
    855 typedef struct tr_peer_stat tr_peer_stat;
    856 tr_peer_stat * tr_torrentPeers( const tr_torrent *, int * peerCount );
    857 void tr_torrentPeersFree( tr_peer_stat *, int peerCount );
     857
     858typedef struct tr_peer_stat
     859{
     860    unsigned int isEncrypted : 1;
     861    unsigned int isDownloadingFrom : 1;
     862    unsigned int isUploadingTo : 1;
     863
     864    unsigned int peerIsChoked : 1;
     865    unsigned int peerIsInterested : 1;
     866    unsigned int clientIsChoked : 1;
     867    unsigned int clientIsInterested : 1;
     868    unsigned int isIncoming : 1;
     869
     870    uint8_t  from;
     871    uint16_t port;
     872
     873    char addr[16];
     874    char client[80];
     875    char flagStr[32];
     876   
     877    float progress;
     878    float downloadFromRate;
     879    float uploadToRate;
     880}
     881tr_peer_stat;
     882
     883tr_peer_stat * tr_torrentPeers( const tr_torrent * torrent,
     884                                int              * peerCount );
     885
     886void tr_torrentPeersFree( tr_peer_stat *  peerStats,
     887                          int             peerCount );
    858888
    859889typedef struct tr_file_stat
     
    885915void tr_torrentVerify( tr_torrent * );
    886916
    887 /**
    888  * Frees memory allocated by tr_torrentNew().
    889  * Running torrents are stopped first.
    890  */
    891 void tr_torrentFree( tr_torrent * );
    892 
    893 /**
    894  * Removes our .torrent and .resume files for this
    895  * torrent, then calls tr_torrentFree()
    896  */
    897 void tr_torrentRemove( tr_torrent * );
    898 
    899917/***********************************************************************
    900918 * tr_info
     
    10211039 * @see tr_torrentStat()
    10221040 */
    1023 struct tr_stat
     1041typedef struct tr_stat
    10241042{
    10251043    /** The torrent's unique Id.
     
    11821200    /** The last time we uploaded or downloaded piece data on this torrent. */
    11831201    time_t activityDate;
    1184 };
    1185 
    1186 struct tr_peer_stat
    1187 {
    1188     char addr[16];
    1189     char client[80];
    1190    
    1191     unsigned int isEncrypted : 1;
    1192     unsigned int isDownloadingFrom : 1;
    1193     unsigned int isUploadingTo : 1;
    1194 
    1195     unsigned int peerIsChoked : 1;
    1196     unsigned int peerIsInterested : 1;
    1197     unsigned int clientIsChoked : 1;
    1198     unsigned int clientIsInterested : 1;
    1199     unsigned int isIncoming : 1;
    1200 
    1201     char flagStr[32];
    1202 
    1203     uint8_t  from;
    1204     uint16_t port;
    1205    
    1206     float progress;
    1207     float downloadFromRate;
    1208     float uploadToRate;
    1209 };
     1202}
     1203tr_stat;
     1204
     1205/** Return a pointer to an tr_stat structure with updated information
     1206    on the torrent.  This is typically called by the GUI clients every
     1207    second or so to get a new snapshot of the torrent's status. */
     1208const tr_stat * tr_torrentStat( tr_torrent * );
     1209
     1210/** Like tr_torrentStat(), but only recalculates the statistics if it's
     1211    been longer than a second since they were last calculated.  This can
     1212    reduce the CPU load if you're calling tr_torrentStat() frequently. */
     1213const tr_stat * tr_torrentStatCached( tr_torrent * );
    12101214
    12111215/** @} */
  • trunk/macosx/Badger.m

    r5693 r5975  
    9191            badgeUpload = [[NSUserDefaults standardUserDefaults] boolForKey: @"BadgeUploadRate"];
    9292        if (badgeDownload || badgeUpload)
    93             tr_torrentRates(fLib, badgeDownload ? &downloadRate : NULL, badgeUpload ? &uploadRate : NULL);
     93            tr_sessionGetSpeed(fLib, badgeDownload ? &downloadRate : NULL, badgeUpload ? &uploadRate : NULL);
    9494       
    9595        //only update if the badged values change
     
    155155       
    156156        float downloadRate, uploadRate;
    157         tr_torrentRates(fLib, &downloadRate, &uploadRate);
     157        tr_sessionGetSpeed(fLib, &downloadRate, &uploadRate);
    158158       
    159159        if (checkDownload && downloadRate >= 0.1)
  • trunk/macosx/Controller.m

    r5973 r5975  
    14481448                //set rates
    14491449                float downloadRate, uploadRate;
    1450                 tr_torrentRates(fLib, & downloadRate, & uploadRate);
     1450                tr_sessionGetSpeed(fLib, & downloadRate, & uploadRate);
    14511451               
    14521452                [fTotalDLField setStringValue: [NSString stringForSpeed: downloadRate]];
  • trunk/wx/speed-stats.cc

    r3109 r5975  
    215215    // add a new record
    216216    float allUp, allDown;
    217     tr_torrentRates( handle, &allDown, &allUp );
     217    tr_sessionGetSpeed( handle, &allDown, &allUp );
    218218    Speed s;
    219219    s.time = time( NULL );
  • trunk/wx/xmission.cc

    r5908 r5975  
    470470
    471471    float down, up;
    472     tr_torrentRates( handle, &down, &up );
     472    tr_sessionGetSpeed( handle, &down, &up );
    473473    wxString xstr = _("Total DL: ");
    474474    xstr += getReadableSpeed( down );
Note: See TracChangeset for help on using the changeset viewer.