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.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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));