Changeset 5900


Ignore:
Timestamp:
May 22, 2008, 12:31:47 PM (14 years ago)
Author:
charles
Message:

more janitorial cleanup on the "tr_session*" namespace. Today's victim: tr_handle_status.

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/cli/transmissioncli.c

    r5880 r5900  
    360360    fprintf( stderr, "\n" );
    361361
    362     /* Try for 5 seconds to delete any port mappings for nat traversal */
     362    /* try for 5 seconds to delete any port mappings for nat traversal */
    363363    tr_sessionSetPortForwardingEnabled( h, 0 );
    364     for( i = 0; i < 10; i++ )
    365     {
    366         const tr_handle_status * hstat = tr_handleStatus( h );
    367         if( TR_NAT_TRAVERSAL_UNMAPPED == hstat->natTraversalStatus )
    368         {
    369             /* Port mappings were deleted */
    370             break;
    371         }
     364    for( i=0; i<10; ++i ) {
     365        const tr_port_forwarding f = tr_sessionGetPortForwarding( h );
     366        if( f == TR_PORT_UNMAPPED )
     367            break;
    372368        tr_wait( 500 );
    373369    }
  • trunk/libtransmission/natpmp.c

    r5620 r5900  
    197197
    198198    switch( nat->state ) {
    199         case TR_NATPMP_IDLE:        ret = nat->isMapped ? TR_NAT_TRAVERSAL_MAPPED : TR_NAT_TRAVERSAL_UNMAPPED; break;
    200         case TR_NATPMP_DISCOVER:    ret = TR_NAT_TRAVERSAL_UNMAPPED; break;
     199        case TR_NATPMP_IDLE:        ret = nat->isMapped ? TR_PORT_MAPPED : TR_PORT_UNMAPPED; break;
     200        case TR_NATPMP_DISCOVER:    ret = TR_PORT_UNMAPPED; break;
    201201        case TR_NATPMP_RECV_PUB:
    202202        case TR_NATPMP_SEND_MAP:
    203         case TR_NATPMP_RECV_MAP:    ret = TR_NAT_TRAVERSAL_MAPPING; break;
     203        case TR_NATPMP_RECV_MAP:    ret = TR_PORT_MAPPING; break;
    204204        case TR_NATPMP_SEND_UNMAP:
    205         case TR_NATPMP_RECV_UNMAP:  ret = TR_NAT_TRAVERSAL_UNMAPPING; break;
    206         default:                    ret = TR_NAT_TRAVERSAL_ERROR; break;
     205        case TR_NATPMP_RECV_UNMAP:  ret = TR_PORT_UNMAPPING; break;
     206        default:                    ret = TR_PORT_ERROR; break;
    207207    }
    208208    return ret;
  • trunk/libtransmission/port-forwarding.c

    r5819 r5900  
    4646    unsigned int isShuttingDown : 1;
    4747
    48     tr_nat_traversal_status natpmpStatus;
    49     tr_nat_traversal_status upnpStatus;
     48    tr_port_forwarding natpmpStatus;
     49    tr_port_forwarding upnpStatus;
    5050
    5151    int bindPort;
     
    7070    {
    7171        /* we're in the process of trying to set up port forwarding */
    72         case TR_NAT_TRAVERSAL_MAPPING:   return _( "Starting" );
     72        case TR_PORT_MAPPING:   return _( "Starting" );
    7373        /* we've successfully forwarded the port */
    74         case TR_NAT_TRAVERSAL_MAPPED:    return _( "Forwarded" );
     74        case TR_PORT_MAPPED:    return _( "Forwarded" );
    7575        /* we're cancelling the port forwarding */
    76         case TR_NAT_TRAVERSAL_UNMAPPING: return _( "Stopping" );
     76        case TR_PORT_UNMAPPING: return _( "Stopping" );
    7777        /* the port isn't forwarded */
    78         case TR_NAT_TRAVERSAL_UNMAPPED:  return _( "Not forwarded" );
    79         case TR_NAT_TRAVERSAL_ERROR:     return "???";
     78        case TR_PORT_UNMAPPED:  return _( "Not forwarded" );
     79        case TR_PORT_ERROR:     return "???";
    8080    }
    8181
     
    191191    s->pulseTimer   = tr_timerNew( h, sharedPulse, s, 1000 );
    192192    s->isEnabled    = isEnabled ? 1 : 0;
    193     s->upnpStatus   = TR_NAT_TRAVERSAL_UNMAPPED;
    194     s->natpmpStatus = TR_NAT_TRAVERSAL_UNMAPPED;
     193    s->upnpStatus   = TR_PORT_UNMAPPED;
     194    s->natpmpStatus = TR_PORT_UNMAPPED;
    195195
    196196    return s;
  • trunk/libtransmission/session.c

    r5880 r5900  
    316316}
    317317
    318 const tr_handle_status *
    319 tr_handleStatus( tr_handle * h )
    320 {
    321     tr_handle_status * s;
    322 
    323     h->statCur = ( h->statCur + 1 ) % 2;
    324     s = &h->stats[h->statCur];
    325 
    326     tr_globalLock( h );
    327 
    328     s->natTraversalStatus = tr_sharedTraversalStatus( h->shared );
    329     s->publicPort = tr_sharedGetPublicPort( h->shared );
    330 
    331     tr_globalUnlock( h );
    332 
    333     return s;
     318tr_port_forwarding
     319tr_sessionGetPortForwarding( const tr_handle * h )
     320{
     321    return tr_sharedTraversalStatus( h->shared );
    334322}
    335323
  • trunk/libtransmission/session.h

    r5845 r5900  
    8787    void                       * rpc_func_user_data;
    8888
    89     tr_handle_status             stats[2];
    90     int                          statCur;
    91 
    9289    struct tr_stats_handle     * sessionStats;
    9390    struct tr_tracker_handle   * tracker;
  • trunk/libtransmission/transmission.h

    r5880 r5900  
    200200void tr_clearSessionStats( tr_handle * handle );
    201201
    202 
    203 /**
    204 ***
    205 **/
     202/**
     203 * Set whether or not torrents are allowed to do peer exchanges.
     204 * PEX is always disabled in private torrents regardless of this.
     205 * In public torrents, PEX is enabled by default.
     206 */
     207void tr_sessionSetPexEnabled( tr_handle *, int isEnabled );
     208
     209int tr_sessionIsPexEnabled( const tr_handle * );
    206210
    207211typedef enum
     
    226230
    227231
     232/***********************************************************************
     233** Incoming Peer Connections Port
     234*/
     235
     236void tr_sessionSetPortForwardingEnabled( tr_handle *, int enable );
     237
     238int tr_sessionIsPortForwardingEnabled( const tr_handle * );
     239
     240void tr_sessionSetPublicPort( tr_handle *, int );
     241
     242int tr_sessionGetPublicPort( const tr_handle * );
     243
     244typedef enum
     245{
     246    TR_PORT_ERROR,
     247    TR_PORT_UNMAPPED,
     248    TR_PORT_UNMAPPING,
     249    TR_PORT_MAPPING,
     250    TR_PORT_MAPPED
     251}
     252tr_port_forwarding;
     253
     254tr_port_forwarding tr_sessionGetPortForwarding( const tr_handle * );
     255
     256
     257//ccccccc
     258
     259/**
     260***
     261**/
     262
    228263
    229264
     
    273308void tr_freeMessageList( tr_msg_list * freeme );
    274309
    275 /***********************************************************************
    276 ** Incoming Peer Connections Port
    277 */
    278 
    279 void tr_sessionSetPortForwardingEnabled( tr_handle *, int enable );
    280 
    281 int tr_sessionIsPortForwardingEnabled( const tr_handle * );
    282 
    283 void tr_sessionSetPublicPort( tr_handle *, int );
    284 
    285 int tr_sessionGetPublicPort( const tr_handle * );
    286 
    287 typedef enum
    288 {
    289     TR_NAT_TRAVERSAL_ERROR,
    290     TR_NAT_TRAVERSAL_UNMAPPED,
    291     TR_NAT_TRAVERSAL_UNMAPPING,
    292     TR_NAT_TRAVERSAL_MAPPING,
    293     TR_NAT_TRAVERSAL_MAPPED
    294 }
    295 tr_nat_traversal_status;
    296 
    297 typedef struct tr_handle_status
    298 {
    299     tr_nat_traversal_status natTraversalStatus;
    300     int publicPort;
    301 }
    302 tr_handle_status;
    303 
    304 const tr_handle_status * tr_handleStatus( tr_handle * );
    305 
    306310
    307311/***********************************************************************
     
    599603
    600604
    601 
    602 /**
    603  * Set whether or not torrents are allowed to do peer exchanges.
    604  * PEX is always disabled in private torrents regardless of this.
    605  * In public torrents, PEX is enabled by default.
    606  */
    607 void tr_sessionSetPexEnabled( tr_handle *, int isEnabled );
    608 
    609 int tr_sessionIsPexEnabled( const tr_handle * );
    610605
    611606const tr_info * tr_torrentInfo( const tr_torrent * );
  • trunk/libtransmission/upnp.c

    r5700 r5900  
    162162    switch( handle->state )
    163163    {
    164         case TR_UPNP_DISCOVER: ret = TR_NAT_TRAVERSAL_UNMAPPED; break;
    165         case TR_UPNP_MAP:      ret = TR_NAT_TRAVERSAL_MAPPING; break;
    166         case TR_UPNP_UNMAP:    ret = TR_NAT_TRAVERSAL_UNMAPPING; break;
    167         case TR_UPNP_IDLE:     ret = handle->isMapped ? TR_NAT_TRAVERSAL_MAPPED
    168                                                       : TR_NAT_TRAVERSAL_UNMAPPED; break;
    169         default:               ret = TR_NAT_TRAVERSAL_ERROR; break;
     164        case TR_UPNP_DISCOVER: ret = TR_PORT_UNMAPPED; break;
     165        case TR_UPNP_MAP:      ret = TR_PORT_MAPPING; break;
     166        case TR_UPNP_UNMAP:    ret = TR_PORT_UNMAPPING; break;
     167        case TR_UPNP_IDLE:     ret = handle->isMapped ? TR_PORT_MAPPED
     168                                                      : TR_PORT_UNMAPPED; break;
     169        default:               ret = TR_PORT_ERROR; break;
    170170    }
    171171
  • trunk/macosx/PrefsController.m

    r5820 r5900  
    265265- (void) updatePortStatus
    266266{
    267     const tr_handle_status * stat = tr_handleStatus(fHandle);
    268     if (fNatStatus != stat->natTraversalStatus || fPublicPort != stat->publicPort)
    269     {
    270         fNatStatus = stat->natTraversalStatus;
    271         fPublicPort = stat->publicPort;
     267    const tr_port_forwarding fwd = tr_sessionGetPortForwarding(fHandle);
     268    const int port = tr_sessionGetPublicPort(fHandle);
     269
     270    if (fNatStatus != fwd || fPublicPort != port )
     271    {
     272        fNatStatus = fwd;
     273        fPublicPort = port;
    272274       
    273275        [fPortStatusField setStringValue: [NSLocalizedString(@"Checking port status", "Preferences -> Network -> port status")
Note: See TracChangeset for help on using the changeset viewer.