Changeset 764 for trunk/libtransmission


Ignore:
Timestamp:
Aug 13, 2006, 7:43:15 PM (15 years ago)
Author:
livings124
Message:

Some changes to getting peers in libtransmission. Now it uses a separate structure for the GUI accessing peers.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer.h

    r754 r764  
    2525#ifndef TR_PEER_H
    2626#define TR_PEER_H 1
     27
     28typedef struct tr_peer_s tr_peer_t;
    2729
    2830void        tr_peerAddOld        ( tr_torrent_t *, char *, int );
  • trunk/libtransmission/transmission.c

    r763 r764  
    406406}
    407407
    408 tr_peer_t * tr_getPeer( tr_torrent_t * tor, int peerNum)
    409 {
    410     tr_peer_t * peer;
    411 
    412     tr_lockLock( &tor->lock );
    413    
    414     if (peerNum < 0 || peerNum >= tor->peerCount)
    415         peer = NULL;
    416     else
    417         peer = tor->peers[peerNum];
    418        
    419     tr_lockUnlock( &tor->lock );
    420    
    421     return peer;
    422 }
    423 
    424408tr_stat_t * tr_torrentStat( tr_torrent_t * tor )
    425409{
     
    449433    s->peersUploading   = 0;
    450434    s->peersDownloading = 0;
     435   
     436    tr_peer_t * peer;
     437    s->peers = (tr_peer_stat_t *) calloc( tor->peerCount, sizeof( tr_peer_stat_t ) );
    451438
    452439    for( i = 0; i < tor->peerCount; i++ )
    453440    {
    454         if( tr_peerIsConnected( tor->peers[i] ) )
     441        peer = tor->peers[i];
     442       
     443        char * client = tr_clientForId(tr_peerId(peer));
     444        char clientChar;
     445        int j = 0;
     446        while (j < 25 && (clientChar = client[j]) != 0)
     447        {
     448            s->peers[i].client[j] = clientChar;
     449            j++;
     450        }
     451       
     452        s->peers[i].isDownloading = tr_peerIsDownloading(peer);
     453        s->peers[i].isUploading = tr_peerIsUploading(peer);
     454   
     455        if( tr_peerIsConnected( peer ) )
    455456        {
    456457            (s->peersTotal)++;
    457             if( tr_peerIsUploading( tor->peers[i] ) )
     458            if( tr_peerIsUploading( peer ) )
    458459            {
    459460                (s->peersUploading)++;
    460461            }
    461             if( tr_peerIsDownloading( tor->peers[i] ) )
     462            if( tr_peerIsDownloading( peer ) )
    462463            {
    463464                (s->peersDownloading)++;
  • trunk/libtransmission/transmission.h

    r754 r764  
    199199
    200200/***********************************************************************
    201  * tr_getPeer
    202  ***********************************************************************
    203  * Returns the peer at peerNum. Returns NULL if peerNum is not greater
    204  * than 0 and less than peerCount.
    205  **********************************************************************/
    206 typedef struct tr_peer_s tr_peer_t;
    207 tr_peer_t * tr_getPeer( tr_torrent_t *, int peerNum );
    208 
    209 /***********************************************************************
    210201 * tr_torrentStat
    211202 ***********************************************************************
     
    289280 * tr_stat_s
    290281 **********************************************************************/
     282typedef struct tr_peer_stat_s
     283{
     284    char    client[25];
     285   
     286    int     isDownloading;
     287    int     isUploading;
     288}
     289tr_peer_stat_t;
    291290struct tr_stat_s
    292291{
     
    301300#define TR_STATUS_ACTIVE   (TR_STATUS_CHECK|TR_STATUS_DOWNLOAD|TR_STATUS_SEED)
    302301#define TR_STATUS_INACTIVE (TR_STATUS_STOPPING|TR_STATUS_STOPPED|TR_STATUS_PAUSE)
    303     int         status;
     302    int                 status;
    304303
    305304#define TR_ETRACKER 1
    306305#define TR_EINOUT   2
    307     int         error;
    308     char        trackerError[128];
    309 
    310     float       progress;
    311     float       rateDownload;
    312     float       rateUpload;
    313     int         eta;
    314     int         peersTotal;
    315     int         peersUploading;
    316     int         peersDownloading;
    317     int         seeders;
    318     int         leechers;
    319 
    320     uint64_t    downloaded;
    321     uint64_t    uploaded;
     306    int                 error;
     307    char                trackerError[128];
     308
     309    float               progress;
     310    float               rateDownload;
     311    float               rateUpload;
     312    int                 eta;
     313    int                 peersTotal;
     314    tr_peer_stat_t *    peers;
     315    int                 peersUploading;
     316    int                 peersDownloading;
     317    int                 seeders;
     318    int                 leechers;
     319
     320    uint64_t            downloaded;
     321    uint64_t            uploaded;
    322322};
    323323
Note: See TracChangeset for help on using the changeset viewer.