Changeset 1145

Show
Ignore:
Timestamp:
03/15/10 14:31:50 (2 years ago)
Author:
rakshasa
Message:

* Cleaned up torrent/download.h.

* Removed raw_value as it is redundant.

Location:
trunk
Files:
21 modified

Legend:

Unmodified
Added
Removed
  • trunk/libtorrent/src/download/download_constructor.cc

    r1144 r1145  
    8989    m_defaultEncoding = b.get_key_string("encoding"); 
    9090 
     91  if (b.has_key_value("creation date")) 
     92    m_download->info()->set_creation_date(b.get_key_value("creation date")); 
     93 
    9194  m_download->info()->change_flags(DownloadInfo::flag_private, 
    9295                                   b.get_key("info").has_key_value("private") &&  
  • trunk/libtorrent/src/download/download_main.cc

    r1144 r1145  
    7878  m_metadataSize(0), 
    7979   
     80  m_creationDate(0), 
    8081  m_loadDate(rak::timer::current_seconds()) { 
    8182} 
  • trunk/libtorrent/src/download/download_wrapper.cc

    r1144 r1145  
    335335 
    336336  m_main.connection_list()->erase_seeders(); 
    337   info()->down_rate()->reset_rate(); 
    338 } 
    339  
    340 } 
     337  info()->mutable_down_rate()->reset_rate(); 
     338} 
     339 
     340} 
  • trunk/libtorrent/src/protocol/peer_connection_base.cc

    r1144 r1145  
    428428 
    429429  m_down->throttle()->node_used(m_peerChunks.download_throttle(), bytesTransfered); 
    430   m_download->info()->down_rate()->insert(bytesTransfered); 
     430  m_download->info()->mutable_down_rate()->insert(bytesTransfered); 
    431431 
    432432  return transfer->is_finished(); 
     
    498498 
    499499  m_down->throttle()->node_used(m_peerChunks.download_throttle(), length); 
    500   m_download->info()->down_rate()->insert(length); 
     500  m_download->info()->mutable_down_rate()->insert(length); 
    501501 
    502502  return length; 
     
    517517  // counted. 
    518518  m_down->throttle()->node_used(m_peerChunks.download_throttle(), length); 
    519   m_download->info()->down_rate()->insert(length); 
    520   m_download->info()->skip_rate()->insert(length); 
     519  m_download->info()->mutable_down_rate()->insert(length); 
     520  m_download->info()->mutable_skip_rate()->insert(length); 
    521521 
    522522  if (!transfer->is_valid()) { 
     
    663663 
    664664  m_up->throttle()->node_used(m_peerChunks.upload_throttle(), bytesTransfered); 
    665   m_download->info()->up_rate()->insert(bytesTransfered); 
     665  m_download->info()->mutable_up_rate()->insert(bytesTransfered); 
    666666 
    667667  // Just modifying the piece to cover the remaining data ends up 
  • trunk/libtorrent/src/torrent/data/transfer_list.h

    r1129 r1145  
    7575  uint32_t            failed_count() const { return m_failedCount; } 
    7676 
     77  // 
    7778  // Internal to libTorrent: 
     79  // 
    7880 
    7981  void                clear(); 
  • trunk/libtorrent/src/torrent/download.cc

    r1144 r1145  
    189189} 
    190190 
    191 // bool 
    192 // Download::is_open() const { 
    193 //   return m_ptr->info()->is_open(); 
    194 // } 
    195  
    196 // bool 
    197 // Download::is_active() const { 
    198 //   return m_ptr->info()->is_active(); 
    199 // } 
    200  
    201191bool 
    202192Download::is_hash_checked() const { 
     
    209199} 
    210200 
    211 // bool 
    212 // Download::is_private() const { 
    213 //   return m_ptr->info()->is_private(); 
    214 // } 
    215  
    216 // bool 
    217 // Download::is_pex_active() const { 
    218 //   return m_ptr->info()->is_pex_active(); 
    219 // } 
    220  
    221 // bool 
    222 // Download::is_pex_enabled() const { 
    223 //   return m_ptr->info()->is_pex_enabled(); 
    224 // } 
    225  
    226201void 
    227202Download::set_pex_enabled(bool enabled) { 
    228203  m_ptr->info()->change_flags(DownloadInfo::flag_pex_enabled, enabled); 
    229 } 
    230  
    231 // bool 
    232 // Download::is_meta_download() const { 
    233 //   return m_ptr->info()->is_meta_download(); 
    234 // } 
    235  
    236 const std::string& 
    237 Download::name() const { 
    238   if (m_ptr == NULL) 
    239     throw internal_error("Download::name() m_ptr == NULL."); 
    240  
    241   return m_ptr->info()->name(); 
    242 } 
    243  
    244 const HashString& 
    245 Download::info_hash() const { 
    246   return m_ptr->info()->hash(); 
    247 } 
    248  
    249 const HashString& 
    250 Download::info_hash_obfuscated() const { 
    251   return m_ptr->info()->hash_obfuscated(); 
    252 } 
    253  
    254 const HashString& 
    255 Download::local_id() const { 
    256   return m_ptr->info()->local_id(); 
    257 } 
    258  
    259 uint32_t 
    260 Download::creation_date() const { 
    261   if (m_ptr->bencode()->has_key_value("creation date")) 
    262     return m_ptr->bencode()->get_key_value("creation date"); 
    263   else 
    264     return 0; 
    265 } 
    266  
    267 uint32_t 
    268 Download::load_date() const { 
    269   return m_ptr->info()->load_date(); 
    270204} 
    271205 
     
    313247Download::connection_list() const { 
    314248  return m_ptr->main()->connection_list(); 
    315 } 
    316  
    317 Rate* 
    318 Download::down_rate() { 
    319   return m_ptr->info()->down_rate(); 
    320 } 
    321  
    322 const Rate* 
    323 Download::down_rate() const { 
    324   return m_ptr->info()->down_rate(); 
    325 } 
    326  
    327 Rate* 
    328 Download::mutable_down_rate() { 
    329   return m_ptr->info()->down_rate(); 
    330 } 
    331  
    332 Rate* 
    333 Download::up_rate() { 
    334   return m_ptr->info()->up_rate(); 
    335 } 
    336  
    337 const Rate* 
    338 Download::up_rate() const { 
    339   return m_ptr->info()->up_rate(); 
    340 } 
    341  
    342 Rate* 
    343 Download::mutable_up_rate() { 
    344   return m_ptr->info()->up_rate(); 
    345 } 
    346  
    347 Rate* 
    348 Download::skip_rate() { 
    349   return m_ptr->info()->skip_rate(); 
    350 } 
    351  
    352 const Rate* 
    353 Download::skip_rate() const { 
    354   return m_ptr->info()->skip_rate(); 
    355 } 
    356  
    357 Rate* 
    358 Download::mutable_skip_rate() { 
    359   return m_ptr->info()->skip_rate(); 
    360249} 
    361250 
  • trunk/libtorrent/src/torrent/download.h

    r1144 r1145  
    9393  bool                is_valid() const { return m_ptr; } 
    9494 
    95 //   bool                is_open() const; 
    96 //   bool                is_active() const; 
    97  
    9895  bool                is_hash_checked() const; 
    9996  bool                is_hash_checking() const; 
    10097 
    101 //   bool                is_private() const; 
    102 //   bool                is_pex_active() const; 
    103 //   bool                is_pex_enabled() const; 
    10498  void                set_pex_enabled(bool enabled); 
    105  
    106 //   bool                is_meta_download() const; 
    107  
    108   // Returns "" if the object is not valid. 
    109   const std::string&  name() const; 
    110  
    111   const HashString&   info_hash() const; 
    112   const HashString&   info_hash_obfuscated() const; 
    113   const HashString&   local_id() const; 
    114  
    115   // Unix epoche, 0 == unknown. 
    116   uint32_t            creation_date() const; 
    117   uint32_t            load_date() const; 
    11899 
    119100  Object*             bencode(); 
     
    129110  ConnectionList*       connection_list(); 
    130111  const ConnectionList* connection_list() const; 
    131  
    132   // Remove the old non-const versions. 
    133   Rate*               down_rate(); 
    134   const Rate*         down_rate() const; 
    135   Rate*               mutable_down_rate(); 
    136  
    137   Rate*               up_rate(); 
    138   const Rate*         up_rate() const; 
    139   Rate*               mutable_up_rate(); 
    140  
    141   Rate*               skip_rate(); 
    142   const Rate*         skip_rate() const; 
    143   Rate*               mutable_skip_rate(); 
    144112 
    145113  // Bytes completed. 
  • trunk/libtorrent/src/torrent/download_info.h

    r1144 r1145  
    107107  void                set_pex_enabled()                            { if (!is_private()) set_flags(flag_pex_enabled); } 
    108108 
    109   Rate*               up_rate()                                    { return &m_upRate; } 
    110   Rate*               down_rate()                                  { return &m_downRate; } 
    111   Rate*               skip_rate()                                  { return &m_skipRate; } 
     109  const Rate*         up_rate() const                              { return &m_upRate; } 
     110  const Rate*         down_rate() const                            { return &m_downRate; } 
     111  const Rate*         skip_rate() const                            { return &m_skipRate; } 
     112 
     113  Rate*               mutable_up_rate() const                      { return &m_upRate; } 
     114  Rate*               mutable_down_rate() const                    { return &m_downRate; } 
     115  Rate*               mutable_skip_rate() const                    { return &m_skipRate; } 
    112116 
    113117  uint64_t            uploaded_baseline() const                    { return m_uploadedBaseline; } 
     
    130134  uint32_t            max_size_pex_list() const                    { return 200; } 
    131135 
     136  // Unix epoche, 0 == unknown. 
     137  uint32_t            creation_date() const                        { return m_creationDate; } 
    132138  uint32_t            load_date() const                            { return m_loadDate; } 
    133139 
     
    143149  signal_dump_type&   signal_tracker_dump()                        { return m_signalTrackerDump; } 
    144150 
     151  // 
     152  // Libtorrent internal: 
     153  // 
     154 
     155  void                set_creation_date(uint32_t d)                { m_creationDate = d; } 
     156 
    145157private: 
    146158  std::string         m_name; 
     
    151163  int                 m_flags; 
    152164 
    153   Rate                m_upRate; 
    154   Rate                m_downRate; 
    155   Rate                m_skipRate; 
     165  mutable Rate        m_upRate; 
     166  mutable Rate        m_downRate; 
     167  mutable Rate        m_skipRate; 
    156168 
    157169  uint64_t            m_uploadedBaseline; 
     
    161173  size_t              m_metadataSize; 
    162174 
     175  uint32_t            m_creationDate; 
    163176  uint32_t            m_loadDate; 
    164177 
  • trunk/libtorrent/src/torrent/object.h

    r1138 r1145  
    8282    TYPE_NONE, 
    8383    TYPE_RAW_BENCODE, 
    84     TYPE_RAW_VALUE, 
    8584    TYPE_RAW_STRING, 
    8685    TYPE_RAW_LIST, 
     
    9796  Object(const string_type& s) : m_flags(TYPE_STRING) { new (&_string()) string_type(s); } 
    9897  Object(const raw_bencode& r) : m_flags(TYPE_RAW_BENCODE) { new (&_raw_bencode()) raw_bencode(r); } 
    99   Object(const raw_value& r)   : m_flags(TYPE_RAW_VALUE) { new (&_raw_value()) raw_value(r); } 
    10098  Object(const raw_string& r)  : m_flags(TYPE_RAW_STRING) { new (&_raw_string()) raw_string(r); } 
    10199  Object(const raw_list& r)    : m_flags(TYPE_RAW_LIST) { new (&_raw_list()) raw_list(r); } 
     
    115113  static Object       create_raw_bencode(raw_bencode obj = raw_bencode()) { 
    116114    Object tmp; tmp.m_flags = TYPE_RAW_BENCODE; new (&tmp._raw_bencode()) raw_bencode(); return tmp; 
    117   } 
    118   static Object       create_raw_value(raw_value obj = raw_value()) { 
    119     Object tmp; tmp.m_flags = TYPE_RAW_VALUE; new (&tmp._raw_value()) raw_value(); return tmp; 
    120115  } 
    121116  static Object       create_raw_string(raw_string obj = raw_string()) { 
     
    165160  raw_bencode&       as_raw_bencode()                    { check_throw(TYPE_RAW_BENCODE); return _raw_bencode(); } 
    166161  const raw_bencode& as_raw_bencode() const              { check_throw(TYPE_RAW_BENCODE); return _raw_bencode(); } 
    167   raw_value&         as_raw_value()                      { check_throw(TYPE_RAW_VALUE); return _raw_value(); } 
    168   const raw_value&   as_raw_value() const                { check_throw(TYPE_RAW_VALUE); return _raw_value(); } 
    169162  raw_string&        as_raw_string()                     { check_throw(TYPE_RAW_STRING); return _raw_string(); } 
    170163  const raw_string&  as_raw_string() const               { check_throw(TYPE_RAW_STRING); return _raw_string(); } 
     
    180173  bool                has_key_map(const key_type& k) const    { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_MAP); } 
    181174  bool                has_key_raw_bencode(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_RAW_BENCODE); } 
    182   bool                has_key_raw_value(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_RAW_VALUE); } 
    183175  bool                has_key_raw_string(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_RAW_STRING); } 
    184176  bool                has_key_raw_list(const key_type& k) const { check_throw(TYPE_MAP); return check(_map().find(k), TYPE_RAW_LIST); } 
     
    258250  raw_bencode&        _raw_bencode()       { return reinterpret_cast<raw_bencode&>(t_pod); } 
    259251  const raw_bencode&  _raw_bencode() const { return reinterpret_cast<const raw_bencode&>(t_pod); } 
    260   raw_value&          _raw_value()         { return reinterpret_cast<raw_value&>(t_pod); } 
    261   const raw_value&    _raw_value() const   { return reinterpret_cast<const raw_value&>(t_pod); } 
    262252  raw_string&         _raw_string()        { return reinterpret_cast<raw_string&>(t_pod); } 
    263253  const raw_string&   _raw_string() const  { return reinterpret_cast<const raw_string&>(t_pod); } 
     
    287277  case TYPE_NONE: 
    288278  case TYPE_RAW_BENCODE: 
    289   case TYPE_RAW_VALUE:  
    290279  case TYPE_RAW_STRING:  
    291280  case TYPE_RAW_LIST:  
     
    302291  switch (t) { 
    303292  case TYPE_RAW_BENCODE: return create_raw_bencode(); 
    304   case TYPE_RAW_VALUE:   return create_raw_value(); 
    305293  case TYPE_RAW_STRING:  return create_raw_string(); 
    306294  case TYPE_RAW_LIST:    return create_raw_list(); 
  • trunk/libtorrent/src/torrent/object_raw_bencode.h

    r1141 r1145  
    4646 
    4747class raw_bencode; 
    48 class raw_value; 
    4948class raw_string; 
    5049class raw_list; 
     
    104103 
    105104  bool       is_empty() const      { return m_size == 0; } 
    106   bool       is_raw_value() const  { return m_size && m_data[0] >= 'i'; } 
     105  bool       is_value() const      { return m_size && m_data[0] >= 'i'; } 
    107106  bool       is_raw_string() const { return m_size && m_data[0] >= '0' && m_data[0] <= '9'; } 
    108107  bool       is_raw_list() const   { return m_size && m_data[0] >= 'l'; } 
    109108  bool       is_raw_map() const    { return m_size && m_data[0] >= 'd'; } 
    110109 
    111   raw_value  as_raw_value() const; 
    112110  raw_string as_raw_string() const; 
    113111  raw_list   as_raw_list() const; 
     
    117115}; 
    118116 
    119 class raw_value : protected raw_object { 
    120 public: 
    121   typedef raw_value this_type; 
    122   RAW_BENCODE_SET_USING 
    123  
    124   raw_value() {} 
    125   raw_value(value_type* src_data, size_type src_size) : raw_object(src_data, src_size) {} 
    126  
    127 //   int64_t as_value() const; 
    128 }; 
    129  
    130117class raw_string : protected raw_object { 
    131118public: 
     
    164151// 
    165152// 
    166  
    167 inline raw_value 
    168 raw_bencode::as_raw_value() const { 
    169   if (!is_raw_value()) 
    170     throw bencode_error("Wrong object type."); 
    171  
    172   return raw_value(m_data + 1, m_size - 2); 
    173 } 
    174153 
    175154inline raw_string 
     
    202181} 
    203182 
    204 // inline int64_t 
    205 // raw_value::as_value() const { 
    206 //   int64_t value = strtoll( 
    207 // } 
    208  
    209  
    210183// 
    211184// Redo... 
  • trunk/libtorrent/src/torrent/object_stream.cc

    r1144 r1145  
    500500    break; 
    501501  } 
    502   case Object::TYPE_RAW_VALUE: 
    503   { 
    504     raw_value raw = object->as_raw_value(); 
    505     object_write_bencode_c_char(output, 'i'); 
    506     object_write_bencode_c_string(output, raw.begin(), raw.size()); 
    507     object_write_bencode_c_char(output, 'e'); 
    508     break; 
    509   } 
    510502  case Object::TYPE_RAW_STRING:  
    511503  { 
  • trunk/libtorrent/src/torrent/resume.cc

    r1144 r1145  
    265265  if (!object.has_key_string("uncertain_pieces") || 
    266266      !object.has_key_value("uncertain_pieces.timestamp") || 
    267       object.get_key_value("uncertain_pieces.timestamp") >= (int64_t)download.load_date()) 
     267      object.get_key_value("uncertain_pieces.timestamp") >= (int64_t)download.info()->load_date()) 
    268268    return; 
    269269 
  • trunk/rtorrent/src/command_download.cc

    r1144 r1145  
    108108 
    109109  if (type == "base_path") { 
    110     target = rpc::call_command_string("d.get_base_path", rpc::make_target(download)); 
    111     link = rak::path_expand(prefix + rpc::call_command_string("d.get_base_path", rpc::make_target(download)) + postfix); 
     110    target = rpc::call_command_string("d.base_path", rpc::make_target(download)); 
     111    link = rak::path_expand(prefix + rpc::call_command_string("d.base_path", rpc::make_target(download)) + postfix); 
    112112 
    113113  } else if (type == "base_filename") { 
    114     target = rpc::call_command_string("d.get_base_path", rpc::make_target(download)); 
     114    target = rpc::call_command_string("d.base_path", rpc::make_target(download)); 
    115115    link = rak::path_expand(prefix + rpc::call_command_string("d.get_base_filename", rpc::make_target(download)) + postfix); 
    116116 
    117117//   } else if (type == "directory_path") { 
    118118//     target = rpc::call_command_string("d.get_directory", rpc::make_target(download)); 
    119 //     link = rak::path_expand(prefix + rpc::call_command_string("d.get_base_path", rpc::make_target(download)) + postfix); 
     119//     link = rak::path_expand(prefix + rpc::call_command_string("d.base_path", rpc::make_target(download)) + postfix); 
    120120 
    121121  } else if (type == "tied") { 
     
    126126 
    127127    link = rak::path_expand(prefix + link + postfix); 
    128     target = rpc::call_command_string("d.get_base_path", rpc::make_target(download)); 
     128    target = rpc::call_command_string("d.base_path", rpc::make_target(download)); 
    129129 
    130130  } else { 
     
    192192    download->set_root_directory(name); 
    193193  else if (name.empty() || *name.rbegin() == '/') 
    194     download->set_root_directory(name + download->download()->name()); 
     194    download->set_root_directory(name + download->info()->name()); 
    195195  else 
    196     download->set_root_directory(name + "/" + download->download()->name()); 
     196    download->set_root_directory(name + "/" + download->info()->name()); 
    197197} 
    198198 
     
    233233 
    234234  int64_t bytesDone = download->download()->bytes_done(); 
    235   int64_t upTotal   = download->download()->up_rate()->total(); 
     235  int64_t upTotal   = download->info()->up_rate()->total(); 
    236236 
    237237  return bytesDone > 0 ? (1000 * upTotal) / bytesDone : 0; 
     
    240240torrent::Object 
    241241retrieve_d_hash(core::Download* download) { 
    242   const torrent::HashString* hashString = &download->download()->info_hash(); 
     242  const torrent::HashString* hashString = &download->info()->hash(); 
    243243 
    244244  return torrent::Object(rak::transform_hex(hashString->begin(), hashString->end())); 
     
    247247torrent::Object 
    248248retrieve_d_local_id(core::Download* download) { 
    249   const torrent::HashString* hashString = &download->download()->local_id(); 
     249  const torrent::HashString* hashString = &download->info()->local_id(); 
    250250 
    251251  return torrent::Object(rak::transform_hex(hashString->begin(), hashString->end())); 
     
    254254torrent::Object 
    255255retrieve_d_local_id_html(core::Download* download) { 
    256   const torrent::HashString* hashString = &download->download()->local_id(); 
     256  const torrent::HashString* hashString = &download->info()->local_id(); 
    257257 
    258258  return torrent::Object(rak::copy_escape_html(hashString->begin(), hashString->end())); 
     
    563563} 
    564564 
     565#define CMD_ON_INFO(func) \ 
     566  rak::on(std::mem_fun(&core::Download::info), std::mem_fun(&torrent::DownloadInfo::func)) 
     567 
    565568void 
    566569initialize_command_download() { 
    567   ADD_CD_VOID("hash",          &retrieve_d_hash); 
    568   ADD_CD_VOID("local_id",      &retrieve_d_local_id); 
    569   ADD_CD_VOID("local_id_html", &retrieve_d_local_id_html); 
    570   ADD_CD_VOID("bitfield",      &retrieve_d_bitfield); 
    571   ADD_CD_VOID("base_path",     &retrieve_d_base_path); 
    572   ADD_CD_VOID("base_filename", &retrieve_d_base_filename); 
    573   ADD_CD_STRING_UNI("name",    rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::name))); 
     570  CMD_D_VOID("d.hash",          &retrieve_d_hash); 
     571  CMD_D_VOID("d.local_id",      &retrieve_d_local_id); 
     572  CMD_D_VOID("d.local_id_html", &retrieve_d_local_id_html); 
     573  CMD_D_VOID("d.bitfield",      &retrieve_d_bitfield); 
     574  CMD_D_VOID("d.base_path",     &retrieve_d_base_path); 
     575  CMD_D_VOID("d.base_filename", &retrieve_d_base_filename); 
     576 
     577  CMD_D_VOID_SLOT("d.name",          CMD_ON_INFO(name)); 
     578 
     579  CMD_D_VOID_SLOT("d.creation_date", CMD_ON_INFO(creation_date)); 
     580  CMD_D_VOID_SLOT("d.load_date",     CMD_ON_INFO(load_date)); 
    574581 
    575582  // ????? 
     
    677684  ADD_CD_VALUE_UNI("peers_accounted",     rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::peers_accounted))); 
    678685 
    679   ADD_CD_VALUE_MEM_UNI("up_rate",      &torrent::Download::mutable_up_rate, &torrent::Rate::rate); 
    680   ADD_CD_VALUE_MEM_UNI("up_total",     &torrent::Download::mutable_up_rate, &torrent::Rate::total); 
    681   ADD_CD_VALUE_MEM_UNI("down_rate",    &torrent::Download::mutable_down_rate, &torrent::Rate::rate); 
    682   ADD_CD_VALUE_MEM_UNI("down_total",   &torrent::Download::mutable_down_rate, &torrent::Rate::total); 
    683   ADD_CD_VALUE_MEM_UNI("skip_rate",    &torrent::Download::mutable_skip_rate, &torrent::Rate::rate); 
    684   ADD_CD_VALUE_MEM_UNI("skip_total",   &torrent::Download::mutable_skip_rate, &torrent::Rate::total); 
     686  // 
     687  CMD_D_VOID_SLOT("d.up.rate",    rak::on(CMD_ON_INFO(up_rate), std::mem_fun(&torrent::Rate::rate))); 
     688  CMD_D_VOID_SLOT("d.up.total",   rak::on(CMD_ON_INFO(up_rate), std::mem_fun(&torrent::Rate::total))); 
     689  CMD_D_VOID_SLOT("d.down.rate",  rak::on(CMD_ON_INFO(down_rate), std::mem_fun(&torrent::Rate::rate))); 
     690  CMD_D_VOID_SLOT("d.down.total", rak::on(CMD_ON_INFO(down_rate), std::mem_fun(&torrent::Rate::total))); 
     691  CMD_D_VOID_SLOT("d.skip.rate",  rak::on(CMD_ON_INFO(skip_rate), std::mem_fun(&torrent::Rate::rate))); 
     692  CMD_D_VOID_SLOT("d.skip.total", rak::on(CMD_ON_INFO(skip_rate), std::mem_fun(&torrent::Rate::total))); 
     693  // 
    685694 
    686695  ADD_CD_STRING("set_throttle_name",      std::mem_fun(&core::Download::set_throttle_name)); 
    687696  ADD_CD_SLOT_PUBLIC("d.get_throttle_name", call_unknown, rpc::get_variable_d_fn("rtorrent", "throttle_name"), "i:", ""); 
    688697 
    689   ADD_CD_VALUE_UNI("creation_date",       rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::creation_date))); 
    690698  ADD_CD_VALUE_UNI("bytes_done",          rak::on(std::mem_fun(&core::Download::download), std::mem_fun(&torrent::Download::bytes_done))); 
    691699  ADD_CD_VALUE_UNI("ratio",               std::ptr_fun(&retrieve_d_ratio)); 
  • trunk/rtorrent/src/command_events.cc

    r1139 r1145  
    9595 
    9696    int64_t totalDone   = (*itr)->download()->bytes_done(); 
    97     int64_t totalUpload = (*itr)->download()->up_rate()->total(); 
     97    int64_t totalUpload = (*itr)->info()->up_rate()->total(); 
    9898 
    9999    if (!(totalUpload >= minUpload && totalUpload * 100 >= totalDone * minRatio) && 
     
    265265 
    266266  for (core::View::const_iterator itr = (*viewItr)->begin_visible(), last = (*viewItr)->end_visible(); itr != last; itr++) { 
    267     const torrent::HashString* hashString = &(*itr)->download()->info_hash(); 
     267    const torrent::HashString* hashString = &(*itr)->info()->hash(); 
    268268 
    269269    resultList.push_back(rak::transform_hex(hashString->begin(), hashString->end())); 
  • trunk/rtorrent/src/core/download.h

    r1144 r1145  
    153153inline bool 
    154154Download::operator == (const std::string& str) const { 
    155   return str.size() == torrent::HashString::size_data && *torrent::HashString::cast_from(str) == m_download.info_hash(); 
     155  return str.size() == torrent::HashString::size_data && *torrent::HashString::cast_from(str) == m_download.info()->hash(); 
    156156} 
    157157 
  • trunk/rtorrent/src/core/download_factory.cc

    r1144 r1145  
    305305 
    306306  // Save the info-hash just in case the commands decide to delete it. 
    307   torrent::HashString infohash = download->download()->info_hash(); 
     307  torrent::HashString infohash = download->info()->hash(); 
    308308 
    309309  try { 
     
    383383 
    384384  if (rtorrent->has_key_value("total_uploaded")) 
    385     download->download()->up_rate()->set_total(rtorrent->get_key_value("total_uploaded")); 
     385    download->info()->mutable_up_rate()->set_total(rtorrent->get_key_value("total_uploaded")); 
    386386 
    387387  if (rtorrent->has_key_value("chunks_done")) 
  • trunk/rtorrent/src/core/download_list.cc

    r1144 r1145  
    9595DownloadList::iterator 
    9696DownloadList::find(const torrent::HashString& hash) { 
    97   return std::find_if(begin(), end(), rak::equal(hash, rak::on(std::mem_fun(&Download::download), std::mem_fun(&torrent::Download::info_hash)))); 
     97  return std::find_if(begin(), end(), rak::equal(hash, rak::on(std::mem_fun(&Download::info), std::mem_fun(&torrent::DownloadInfo::hash)))); 
    9898} 
    9999 
     
    105105    *itr = (rak::hexchar_to_value(*hash) << 4) + rak::hexchar_to_value(*(hash + 1)); 
    106106 
    107   return std::find_if(begin(), end(), rak::equal(key, rak::on(std::mem_fun(&Download::download), std::mem_fun(&torrent::Download::info_hash)))); 
     107  return std::find_if(begin(), end(), rak::equal(key, rak::on(std::mem_fun(&Download::info), std::mem_fun(&torrent::DownloadInfo::hash)))); 
    108108} 
    109109 
  • trunk/rtorrent/src/core/download_store.cc

    r1126 r1145  
    139139  // Move this somewhere else? 
    140140  rtorrent_base->insert_key("chunks_done", d->download()->file_list()->completed_chunks()); 
    141   rtorrent_base->insert_key("total_uploaded", d->download()->up_rate()->total()); 
     141  rtorrent_base->insert_key("total_uploaded", d->info()->up_rate()->total()); 
    142142 
    143143  // Don't save for completed torrents when we've cleared the uncertain_pieces. 
     
    215215std::string 
    216216DownloadStore::create_filename(Download* d) { 
    217   return m_path + rak::transform_hex(d->download()->info_hash().begin(), d->download()->info_hash().end()) + ".torrent"; 
    218 } 
    219  
    220 } 
     217  return m_path + rak::transform_hex(d->info()->hash().begin(), d->info()->hash().end()) + ".torrent"; 
     218} 
     219 
     220} 
  • trunk/rtorrent/src/display/utils.cc

    r1144 r1145  
    128128char* 
    129129print_download_title(char* first, char* last, core::Download* d) { 
    130   return print_buffer(first, last, " %s", d->download()->name().c_str()); 
     130  return print_buffer(first, last, " %s", d->info()->name().c_str()); 
    131131} 
    132132 
     
    148148   
    149149  first = print_buffer(first, last, " Rate: %5.1f / %5.1f KB Uploaded: %7.1f MB", 
    150                        (double)d->download()->up_rate()->rate() / (1 << 10), 
    151                        (double)d->download()->down_rate()->rate() / (1 << 10), 
    152                        (double)d->download()->up_rate()->total() / (1 << 20)); 
     150                       (double)d->info()->up_rate()->rate() / (1 << 10), 
     151                       (double)d->info()->down_rate()->rate() / (1 << 10), 
     152                       (double)d->info()->up_rate()->total() / (1 << 20)); 
    153153 
    154154  if (d->download()->info()->is_active() && !d->is_done()) { 
     
    217217char* 
    218218print_download_time_left(char* first, char* last, core::Download* d) { 
    219   uint32_t rate = d->download()->down_rate()->rate(); 
     219  uint32_t rate = d->info()->down_rate()->rate(); 
    220220 
    221221  if (rate < 512) 
  • trunk/rtorrent/src/main.cc

    r1144 r1145  
    250250 
    251251       "view_add = name\n" 
    252        "view_sort_new     = name,less=d.get_name=\n" 
    253        "view_sort_current = name,less=d.get_name=\n" 
     252       "view_sort_new     = name,less=d.name=\n" 
     253       "view_sort_current = name,less=d.name=\n" 
    254254 
    255255       "view_add = active\n" 
     
    352352       "method.insert = set_max_memory_usage,redirect|const,pieces.memory.max.set\n" 
    353353 
     354       "method.insert = d.get_hash,redirect|const,d.hash\n" 
     355       "method.insert = d.get_local_id,redirect|const,d.local_id\n" 
     356       "method.insert = d.get_local_id_html,redirect|const,d.local_id_html\n" 
     357       "method.insert = d.get_bitfield,redirect|const,d.bitfield\n" 
     358       "method.insert = d.get_base_path,redirect|const,d.base_path\n" 
     359 
     360       "method.insert = d.get_name,redirect|const,d.name\n" 
     361       "method.insert = d.get_creation_date,redirect|const,d.creation_date\n" 
     362 
    354363       "method.insert = d.get_peer_exchange,redirect|const,d.peer_exchange\n" 
     364 
     365       "method.insert = d.get_up_rate,redirect|const,d.up.rate\n" 
     366       "method.insert = d.get_up_total,redirect|const,d.up.total\n" 
     367       "method.insert = d.get_down_rate,redirect|const,d.down.rate\n" 
     368       "method.insert = d.get_down_total,redirect|const,d.down.total\n" 
     369       "method.insert = d.get_skip_rate,redirect|const,d.skip.rate\n" 
     370       "method.insert = d.get_skip_total,redirect|const,d.skip.total\n" 
    355371    ); 
    356372 
  • trunk/rtorrent/src/ui/download.cc

    r1144 r1145  
    150150  // Get these bindings with some kind of string map. 
    151151 
    152   element->push_column("Name:",             te_command("d.get_name=")); 
    153   element->push_column("Local id:",         te_command("d.get_local_id_html=")); 
    154   element->push_column("Info hash:",        te_command("d.get_hash=")); 
    155   element->push_column("Created:",          te_command("cat=$to_date=$d.get_creation_date=,\" \",$to_time=$d.get_creation_date=")); 
     152  element->push_column("Name:",             te_command("d.name=")); 
     153  element->push_column("Local id:",         te_command("d.local_id_html=")); 
     154  element->push_column("Info hash:",        te_command("d.hash=")); 
     155  element->push_column("Created:",          te_command("cat=$to_date=$d.creation_date=,\" \",$to_time=$d.creation_date=")); 
    156156 
    157157  element->push_back(""); 
    158158  element->push_column("Directory:",        te_command("d.get_directory=")); 
    159   element->push_column("Base Path:",        te_command("d.get_base_path=")); 
     159  element->push_column("Base Path:",        te_command("d.base_path=")); 
    160160  element->push_column("Tied to file:",     te_command("d.get_tied_to_file=")); 
    161161  element->push_column("File stats:",       te_command("cat=$if=$d.is_multi_file=\\,multi\\,single,\" \",$d.get_size_files=,\" files\"")); 
     
    192192 
    193193  element->push_back(""); 
    194   element->push_column("Upload:",           te_command("cat=$to_kb=$d.get_up_rate=,\" KB / \",$to_xb=$d.get_up_total=")); 
    195   element->push_column("Download:",         te_command("cat=$to_kb=$d.get_down_rate=,\" KB / \",$to_xb=$d.get_down_total=")); 
    196   element->push_column("Skipped:",          te_command("cat=$to_kb=$d.get_skip_rate=,\" KB / \",$to_xb=$d.get_skip_total=")); 
     194  element->push_column("Upload:",           te_command("cat=$to_kb=$d.up.rate=,\" KB / \",$to_xb=$d.up.total=")); 
     195  element->push_column("Download:",         te_command("cat=$to_kb=$d.down.rate=,\" KB / \",$to_xb=$d.down.total=")); 
     196  element->push_column("Skipped:",          te_command("cat=$to_kb=$d.skip.rate=,\" KB / \",$to_xb=$d.skip.total=")); 
    197197  element->push_column("Preload:",          te_command("cat=$pieces.preload.type=,\" / \",$pieces.stats_preloaded=,\" / \",$pieces.stats_preloaded=")); 
    198198 
     
    290290  switch (displayType) { 
    291291  case DISPLAY_MAX_SIZE: break; 
    292   default: control->ui()->window_title()->set_title(m_download->download()->name()); break; 
     292  default: control->ui()->window_title()->set_title(m_download->info()->name()); break; 
    293293  } 
    294294