Ignore:
Timestamp:
Feb 2, 2010, 10:45:22 PM (12 years ago)
Author:
charles
Message:

(trunk) #2802, #2716, #2717 -- remember magnet links and their settings between sessions, and allow their trackers to be modified

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/magnet.c

    r9979 r10084  
    1515
    1616#include "transmission.h"
     17#include "bencode.h"
    1718#include "magnet.h"
    1819#include "utils.h"
     
    194195    }
    195196}
     197
     198void
     199tr_magnetCreateMetainfo( const tr_magnet_info * info, tr_benc * top )
     200{
     201    int i;
     202    tr_benc * d;
     203    tr_bencInitDict( top, 4 );
     204
     205    /* announce list */
     206    if( info->trackerCount == 1 )
     207        tr_bencDictAddStr( top, "announce", info->trackers[0] );
     208    else {
     209        tr_benc * trackers = tr_bencDictAddList( top, "announce-list", info->trackerCount );
     210        for( i=0; i<info->trackerCount; ++i )
     211            tr_bencListAddStr( tr_bencListAddList( trackers, 1 ), info->trackers[i] );
     212    }
     213
     214    /* webseeds */
     215    if( info->webseedCount > 0 ) {
     216        tr_benc * urls = tr_bencDictAddList( top, "url-list", info->webseedCount );
     217        for( i=0; i<info->webseedCount; ++i )
     218            tr_bencListAddStr( urls, info->webseeds[i] );
     219    }
     220
     221    /* nonstandard keys */
     222    d = tr_bencDictAddDict( top, "magnet-info", 2 );
     223    tr_bencDictAddRaw( d, "info_hash", info->hash, 20 );
     224    if( info->displayName != NULL )
     225        tr_bencDictAddStr( d, "display-name", info->displayName );
     226}
     227
     228
Note: See TracChangeset for help on using the changeset viewer.