Ignore:
Timestamp:
Apr 18, 2009, 11:17:30 PM (13 years ago)
Author:
charles
Message:

(trunk) experimental support for tr_torrentSetPriority()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/resume.c

    r8110 r8254  
    2626#include "utils.h" /* tr_buildPath */
    2727
    28 #define KEY_ACTIVITY_DATE   "activity-date"
    29 #define KEY_ADDED_DATE      "added-date"
    30 #define KEY_CORRUPT         "corrupt"
    31 #define KEY_DONE_DATE       "done-date"
    32 #define KEY_DOWNLOAD_DIR    "destination"
    33 #define KEY_DND             "dnd"
    34 #define KEY_DOWNLOADED      "downloaded"
    35 #define KEY_MAX_PEERS       "max-peers"
    36 #define KEY_PAUSED          "paused"
    37 #define KEY_PEERS           "peers"
    38 #define KEY_PEERS6          "peers6"
    39 #define KEY_PRIORITY        "priority"
    40 #define KEY_PROGRESS        "progress"
    41 #define KEY_SPEEDLIMIT_OLD  "speed-limit"
    42 #define KEY_SPEEDLIMIT_UP   "speed-limit-up"
    43 #define KEY_SPEEDLIMIT_DOWN "speed-limit-down"
    44 #define KEY_RATIOLIMIT      "ratio-limit"
    45 #define KEY_UPLOADED        "uploaded"
     28#define KEY_ACTIVITY_DATE       "activity-date"
     29#define KEY_ADDED_DATE          "added-date"
     30#define KEY_CORRUPT             "corrupt"
     31#define KEY_DONE_DATE           "done-date"
     32#define KEY_DOWNLOAD_DIR        "destination"
     33#define KEY_DND                 "dnd"
     34#define KEY_DOWNLOADED          "downloaded"
     35#define KEY_MAX_PEERS           "max-peers"
     36#define KEY_PAUSED              "paused"
     37#define KEY_PEERS               "peers"
     38#define KEY_PEERS6              "peers6"
     39#define KEY_FILE_PRIORITIES     "priority"
     40#define KEY_BANDWIDTH_PRIORITY  "bandwidth-priority"
     41#define KEY_PROGRESS            "progress"
     42#define KEY_SPEEDLIMIT_OLD      "speed-limit"
     43#define KEY_SPEEDLIMIT_UP       "speed-limit-up"
     44#define KEY_SPEEDLIMIT_DOWN     "speed-limit-down"
     45#define KEY_RATIOLIMIT          "ratio-limit"
     46#define KEY_UPLOADED            "uploaded"
    4647
    4748#define KEY_SPEED                  "speed"
     
    190191        tr_free( dnd );
    191192        tr_free( dl );
    192         ret = TR_FR_PRIORITY;
     193        ret = TR_FR_DND;
    193194    }
    194195    else
     
    208209
    209210static void
    210 savePriorities( tr_benc *          dict,
    211                 const tr_torrent * tor )
     211saveFilePriorities( tr_benc * dict, const tr_torrent * tor )
    212212{
    213213    const tr_info *       inf = tr_torrentInfo( tor );
     
    216216    tr_benc *             list;
    217217
    218     list = tr_bencDictAddList( dict, KEY_PRIORITY, n );
     218    list = tr_bencDictAddList( dict, KEY_FILE_PRIORITIES, n );
    219219    for( i = 0; i < n; ++i )
    220220        tr_bencListAddInt( list, inf->files[i].priority );
     
    222222
    223223static uint64_t
    224 loadPriorities( tr_benc *    dict,
    225                 tr_torrent * tor )
     224loadFilePriorities( tr_benc * dict, tr_torrent * tor )
    226225{
    227226    uint64_t              ret = 0;
     
    230229    tr_benc *             list;
    231230
    232     if( tr_bencDictFindList( dict, KEY_PRIORITY, &list )
     231    if( tr_bencDictFindList( dict, KEY_FILE_PRIORITIES, &list )
    233232      && ( tr_bencListSize( list ) == n ) )
    234233    {
     
    238237            if( tr_bencGetInt( tr_bencListChild( list, i ), &priority ) )
    239238                tr_torrentInitFilePriority( tor, i, priority );
    240         ret = TR_FR_PRIORITY;
     239        ret = TR_FR_FILE_PRIORITIES;
    241240    }
    242241
     
    503502    tr_bencDictAddInt( &top, KEY_MAX_PEERS,
    504503                       tor->maxConnectedPeers );
     504    tr_bencDictAddInt( &top, KEY_BANDWIDTH_PRIORITY,
     505                       tr_torrentGetPriority( tor ) );
    505506    tr_bencDictAddBool( &top, KEY_PAUSED, !tor->isRunning );
    506507    savePeers( &top, tor );
    507     savePriorities( &top, tor );
     508    saveFilePriorities( &top, tor );
    508509    saveDND( &top, tor );
    509510    saveProgress( &top, tor );
     
    615616    }
    616617
     618    if( ( fieldsToLoad & TR_FR_BANDWIDTH_PRIORITY )
     619      && tr_bencDictFindInt( &top, KEY_BANDWIDTH_PRIORITY, &i )
     620      && tr_isPriority( i ) )
     621    {
     622        tr_torrentSetPriority( tor, i );
     623        fieldsLoaded |= TR_FR_BANDWIDTH_PRIORITY;
     624    }
     625
    617626    if( fieldsToLoad & TR_FR_PEERS )
    618627        fieldsLoaded |= loadPeers( &top, tor );
    619628
    620     if( fieldsToLoad & TR_FR_PRIORITY )
    621         fieldsLoaded |= loadPriorities( &top, tor );
     629    if( fieldsToLoad & TR_FR_FILE_PRIORITIES )
     630        fieldsLoaded |= loadFilePriorities( &top, tor );
    622631
    623632    if( fieldsToLoad & TR_FR_PROGRESS )
Note: See TracChangeset for help on using the changeset viewer.