Changeset 1146


Ignore:
Timestamp:
03/15/10 19:31:58 (4 years ago)
Author:
rakshasa
Message:
  • Cleaned up torrent/download.h.
  • Removed raw_value as it is redundant.
  • Fixed 'greater' command and added 'equal'. Patch by Josef Drexler.
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtorrent/src/download/download_main.h

    r1144 r1146  
    149149  void                update_endgame(); 
    150150 
     151  rak::priority_item& delay_download_done() { return m_delayDownloadDone; } 
     152 
    151153private: 
    152154  // Disable copy ctor and assignment. 
     
    190192  SlotHashCheckAdd    m_slotHashCheckAdd; 
    191193 
     194  rak::priority_item  m_delayDownloadDone; 
    192195  rak::priority_item  m_taskTrackerRequest; 
    193196}; 
  • trunk/libtorrent/src/download/download_wrapper.cc

    r1145 r1146  
    6464 
    6565DownloadWrapper::DownloadWrapper() : 
     66  m_main(new DownloadMain), 
     67 
    6668  m_bencode(NULL), 
    6769  m_hashChecker(NULL), 
    6870  m_connectionType(0) { 
    6971 
    70   m_delayDownloadDone.set_slot(rak::mem_fn(&m_signalDownloadDone, &Signal::operator())); 
    71  
    72   m_main.tracker_manager()->set_info(info()); 
    73   m_main.tracker_manager()->slot_success(rak::make_mem_fun(this, &DownloadWrapper::receive_tracker_success)); 
    74   m_main.tracker_manager()->slot_failed(rak::make_mem_fun(this, &DownloadWrapper::receive_tracker_failed)); 
    75  
    76   m_main.chunk_list()->slot_storage_error(rak::make_mem_fun(this, &DownloadWrapper::receive_storage_error)); 
     72  m_main->delay_download_done().set_slot(rak::mem_fn(&info()->signal_download_done(), &Signal::operator())); 
     73 
     74  m_main->tracker_manager()->set_info(info()); 
     75  m_main->tracker_manager()->slot_success(rak::make_mem_fun(this, &DownloadWrapper::receive_tracker_success)); 
     76  m_main->tracker_manager()->slot_failed(rak::make_mem_fun(this, &DownloadWrapper::receive_tracker_failed)); 
     77 
     78  m_main->chunk_list()->slot_storage_error(rak::make_mem_fun(this, &DownloadWrapper::receive_storage_error)); 
    7779} 
    7880 
    7981DownloadWrapper::~DownloadWrapper() { 
    8082  if (info()->is_active()) 
    81     m_main.stop(); 
     83    m_main->stop(); 
    8284 
    8385  if (info()->is_open()) 
     
    8688  // If the client wants to do a quick cleanup after calling close, it 
    8789  // will need to manually cancel the tracker requests. 
    88   m_main.tracker_manager()->close(); 
     90  m_main->tracker_manager()->close(); 
    8991 
    9092  delete m_hashChecker; 
    9193  delete m_bencode; 
     94  delete m_main; 
    9295} 
    9396 
     
    102105  info()->mutable_local_id().assign(id.c_str()); 
    103106 
    104   info()->slot_left() = sigc::mem_fun(m_main.file_list(), &FileList::left_bytes); 
    105   info()->slot_completed() = sigc::mem_fun(m_main.file_list(), &FileList::completed_bytes); 
    106  
    107   m_main.slot_hash_check_add(rak::make_mem_fun(this, &DownloadWrapper::check_chunk_hash)); 
     107  info()->slot_left() = sigc::mem_fun(m_main->file_list(), &FileList::left_bytes); 
     108  info()->slot_completed() = sigc::mem_fun(m_main->file_list(), &FileList::completed_bytes); 
     109 
     110  m_main->slot_hash_check_add(rak::make_mem_fun(this, &DownloadWrapper::check_chunk_hash)); 
    108111 
    109112  // Info hash must be calculate from here on. 
    110   m_hashChecker = new HashTorrent(m_main.chunk_list()); 
     113  m_hashChecker = new HashTorrent(m_main->chunk_list()); 
    111114 
    112115  // Connect various signals and slots. 
     
    130133  // succeeds or not, any chunks not included in that last 
    131134  // hash_resume_save get ignored anyway. 
    132   m_main.chunk_list()->sync_chunks(ChunkList::sync_all | ChunkList::sync_force | ChunkList::sync_sloppy | ChunkList::sync_ignore_error); 
    133  
    134   m_main.close(); 
     135  m_main->chunk_list()->sync_chunks(ChunkList::sync_all | ChunkList::sync_force | ChunkList::sync_sloppy | ChunkList::sync_ignore_error); 
     136 
     137  m_main->close(); 
    135138 
    136139  // Should this perhaps be in stop? 
    137   priority_queue_erase(&taskScheduler, &m_delayDownloadDone); 
     140  priority_queue_erase(&taskScheduler, &m_main->delay_download_done()); 
    138141} 
    139142 
    140143bool 
    141144DownloadWrapper::is_stopped() const { 
    142   return !m_main.tracker_manager()->is_active() && !m_main.tracker_manager()->is_busy(); 
     145  return !m_main->tracker_manager()->is_active() && !m_main->tracker_manager()->is_busy(); 
    143146} 
    144147 
     
    159162    // Initialize the ChunkSelector here so that no chunks will be 
    160163    // marked by HashTorrent that are not accounted for. 
    161     m_main.chunk_selector()->initialize(m_main.file_list()->mutable_bitfield(), m_main.chunk_statistics()); 
     164    m_main->chunk_selector()->initialize(m_main->file_list()->mutable_bitfield(), m_main->chunk_statistics()); 
    162165    receive_update_priorities(); 
    163166  } 
    164167 
    165   m_signalInitialHash.emit(); 
     168  info()->signal_initial_hash().emit(); 
    166169}     
    167170 
     
    181184    } else { 
    182185      if (std::memcmp(hash, chunk_hash(handle.index()), 20) == 0) 
    183         m_main.file_list()->mark_completed(handle.index()); 
     186        m_main->file_list()->mark_completed(handle.index()); 
    184187 
    185188      m_hashChecker->receive_chunkdone(); 
     
    197200      // safe. 
    198201 
    199       if (m_main.chunk_selector()->bitfield()->get(handle.index())) 
     202      if (m_main->chunk_selector()->bitfield()->get(handle.index())) 
    200203        throw internal_error("DownloadWrapper::receive_hash_done(...) received a chunk that isn't set in ChunkSelector."); 
    201204 
    202205      if (std::memcmp(hash, chunk_hash(handle.index()), 20) == 0) { 
    203         m_main.file_list()->mark_completed(handle.index()); 
    204         m_main.delegator()->transfer_list()->hash_succeeded(handle.index(), handle.chunk()); 
    205         m_main.update_endgame(); 
    206  
    207         if (m_main.file_list()->is_done()) 
     206        m_main->file_list()->mark_completed(handle.index()); 
     207        m_main->delegator()->transfer_list()->hash_succeeded(handle.index(), handle.chunk()); 
     208        m_main->update_endgame(); 
     209 
     210        if (m_main->file_list()->is_done()) 
    208211          finished_download(); 
    209212     
    210         if (!m_main.have_queue()->empty() && m_main.have_queue()->front().first >= cachedTime) 
    211           m_main.have_queue()->push_front(DownloadMain::have_queue_type::value_type(m_main.have_queue()->front().first + 1, handle.index())); 
     213        if (!m_main->have_queue()->empty() && m_main->have_queue()->front().first >= cachedTime) 
     214          m_main->have_queue()->push_front(DownloadMain::have_queue_type::value_type(m_main->have_queue()->front().first + 1, handle.index())); 
    212215        else 
    213           m_main.have_queue()->push_front(DownloadMain::have_queue_type::value_type(cachedTime, handle.index())); 
    214  
    215         signal_chunk_passed().emit(handle.index()); 
     216          m_main->have_queue()->push_front(DownloadMain::have_queue_type::value_type(cachedTime, handle.index())); 
     217 
     218        info()->signal_chunk_passed().emit(handle.index()); 
    216219 
    217220      } else { 
    218221        // This needs to ensure the chunk is still valid. 
    219         m_main.delegator()->transfer_list()->hash_failed(handle.index(), handle.chunk()); 
    220         signal_chunk_failed().emit(handle.index()); 
     222        m_main->delegator()->transfer_list()->hash_failed(handle.index(), handle.chunk()); 
     223        info()->signal_chunk_failed().emit(handle.index()); 
    221224      } 
    222225    } 
    223226  } 
    224227 
    225   m_main.chunk_list()->release(&handle); 
     228  m_main->chunk_list()->release(&handle); 
    226229 
    227230 
     
    234237void 
    235238DownloadWrapper::receive_storage_error(const std::string& str) { 
    236   m_main.stop(); 
     239  m_main->stop(); 
    237240  close(); 
    238241 
    239   m_main.tracker_manager()->set_active(false); 
    240   m_main.tracker_manager()->close(); 
     242  m_main->tracker_manager()->set_active(false); 
     243  m_main->tracker_manager()->close(); 
    241244 
    242245  info()->signal_storage_error().emit(str); 
     
    245248void 
    246249DownloadWrapper::receive_tracker_success(AddressList* l) { 
    247   m_main.peer_list()->insert_available(l); 
    248   m_main.receive_connect_peers(); 
    249   m_main.receive_tracker_success(); 
    250  
    251   m_signalTrackerSuccess.emit(); 
     250  m_main->peer_list()->insert_available(l); 
     251  m_main->receive_connect_peers(); 
     252  m_main->receive_tracker_success(); 
     253 
     254  info()->signal_tracker_success().emit(); 
    252255} 
    253256 
    254257void 
    255258DownloadWrapper::receive_tracker_failed(const std::string& msg) { 
    256   m_signalTrackerFailed.emit(msg); 
     259  info()->signal_tracker_failed().emit(msg); 
    257260} 
    258261 
     
    264267  if (ticks % 120 == 0) 
    265268//   if (ticks % 1 == 0) 
    266     m_main.peer_list()->cull_peers(PeerList::cull_old | PeerList::cull_keep_interesting); 
     269    m_main->peer_list()->cull_peers(PeerList::cull_old | PeerList::cull_keep_interesting); 
    267270 
    268271  if (!info()->is_open()) 
     
    273276    if (info()->is_active()) { 
    274277      if (info()->is_pex_enabled()) { 
    275         m_main.do_peer_exchange(); 
     278        m_main->do_peer_exchange(); 
    276279 
    277280      // If PEX was disabled since the last peer exchange, deactivate it now. 
     
    279282        info()->unset_flags(DownloadInfo::flag_pex_active); 
    280283 
    281         for (ConnectionList::iterator itr = m_main.connection_list()->begin(); itr != m_main.connection_list()->end(); ++itr) 
     284        for (ConnectionList::iterator itr = m_main->connection_list()->begin(); itr != m_main->connection_list()->end(); ++itr) 
    282285          (*itr)->m_ptr()->set_peer_exchange(false); 
    283286      } 
    284287    } 
    285288 
    286     for (ConnectionList::iterator itr = m_main.connection_list()->begin(); itr != m_main.connection_list()->end(); ) 
     289    for (ConnectionList::iterator itr = m_main->connection_list()->begin(); itr != m_main->connection_list()->end(); ) 
    287290      if (!(*itr)->m_ptr()->receive_keepalive()) 
    288         itr = m_main.connection_list()->erase(itr, ConnectionList::disconnect_available); 
     291        itr = m_main->connection_list()->erase(itr, ConnectionList::disconnect_available); 
    289292      else 
    290293        itr++; 
    291294  } 
    292295 
    293   DownloadMain::have_queue_type* haveQueue = m_main.have_queue(); 
     296  DownloadMain::have_queue_type* haveQueue = m_main->have_queue(); 
    294297  haveQueue->erase(std::find_if(haveQueue->rbegin(), haveQueue->rend(), 
    295298                                rak::less(cachedTime - rak::timer::from_seconds(600), 
     
    297300                   haveQueue->end()); 
    298301 
    299   m_main.receive_connect_peers(); 
     302  m_main->receive_connect_peers(); 
    300303} 
    301304 
    302305void 
    303306DownloadWrapper::receive_update_priorities() { 
    304   if (m_main.chunk_selector()->empty()) 
     307  if (m_main->chunk_selector()->empty()) 
    305308    return; 
    306309 
    307   m_main.chunk_selector()->high_priority()->clear(); 
    308   m_main.chunk_selector()->normal_priority()->clear(); 
    309  
    310   for (FileList::iterator itr = m_main.file_list()->begin(); itr != m_main.file_list()->end(); ++itr) { 
     310  m_main->chunk_selector()->high_priority()->clear(); 
     311  m_main->chunk_selector()->normal_priority()->clear(); 
     312 
     313  for (FileList::iterator itr = m_main->file_list()->begin(); itr != m_main->file_list()->end(); ++itr) { 
    311314    if ((*itr)->priority() == 1) 
    312       m_main.chunk_selector()->normal_priority()->insert((*itr)->range().first, (*itr)->range().second); 
     315      m_main->chunk_selector()->normal_priority()->insert((*itr)->range().first, (*itr)->range().second); 
    313316 
    314317    else if ((*itr)->priority() == 2) 
    315       m_main.chunk_selector()->high_priority()->insert((*itr)->range().first, (*itr)->range().second); 
     318      m_main->chunk_selector()->high_priority()->insert((*itr)->range().first, (*itr)->range().second); 
    316319  } 
    317320 
    318   m_main.chunk_selector()->update_priorities(); 
    319  
    320   std::for_each(m_main.connection_list()->begin(), m_main.connection_list()->end(), 
     321  m_main->chunk_selector()->update_priorities(); 
     322 
     323  std::for_each(m_main->connection_list()->begin(), m_main->connection_list()->end(), 
    321324                rak::on(std::mem_fun(&Peer::m_ptr), std::mem_fun(&PeerConnectionBase::update_interested))); 
    322325} 
     
    331334  // 
    332335  // This needs to be seperated into a new function. 
    333   if (!m_delayDownloadDone.is_queued()) 
    334     priority_queue_insert(&taskScheduler, &m_delayDownloadDone, cachedTime); 
    335  
    336   m_main.connection_list()->erase_seeders(); 
     336  if (!m_main->delay_download_done().is_queued()) 
     337    priority_queue_insert(&taskScheduler, &m_main->delay_download_done(), cachedTime); 
     338 
     339  m_main->connection_list()->erase_seeders(); 
    337340  info()->mutable_down_rate()->reset_rate(); 
    338341} 
  • trunk/libtorrent/src/download/download_wrapper.h

    r1144 r1146  
    3838#define LIBTORRENT_DOWNLOAD_WRAPPER_H 
    3939 
    40 #include <rak/socket_address.h> 
    4140#include <sigc++/connection.h> 
    4241#include <sigc++/signal.h> 
     
    6867  ~DownloadWrapper(); 
    6968 
     69  DownloadInfo*       info()                                  { return m_main->info(); } 
     70 
    7071  // Initialize hash checker and various download stuff. 
    7172  void                initialize(const std::string& hash, const std::string& id); 
     
    7374  void                close(); 
    7475 
    75 //   bool                is_open() const                         { return m_main.is_open(); } 
    7676  bool                is_stopped() const; 
    7777 
    78   DownloadMain*       main()                                  { return &m_main; } 
    79   const DownloadMain* main() const                            { return &m_main; } 
     78  DownloadMain*       main()                                  { return m_main; } 
     79  const DownloadMain* main() const                            { return m_main; } 
    8080  HashTorrent*        hash_checker()                          { return m_hashChecker; } 
    8181 
     
    9090  void                set_complete_hash(const std::string& hash) { m_hash = hash; } 
    9191 
    92   DownloadInfo*       info()                                  { return m_main.info(); } 
    93  
    9492  int                 connection_type() const                 { return m_connectionType; } 
    9593  void                set_connection_type(int t)              { m_connectionType = t; } 
     94 
     95  // 
     96  // Internal: 
     97  // 
    9698 
    9799  void                receive_initial_hash(); 
     
    108110  void                receive_update_priorities(); 
    109111 
    110   Signal&             signal_initial_hash()          { return m_signalInitialHash; } 
    111   Signal&             signal_download_done()         { return m_signalDownloadDone; } 
    112  
    113   // The list of addresses is guaranteed to be sorted and unique. 
    114   Signal&             signal_tracker_success()       { return m_signalTrackerSuccess; } 
    115   SignalString&       signal_tracker_failed()        { return m_signalTrackerFailed; } 
    116  
    117   SignalChunk&        signal_chunk_passed()          { return m_signalChunkPassed; } 
    118   SignalChunk&        signal_chunk_failed()          { return m_signalChunkFailed; } 
    119  
    120112private: 
    121113  DownloadWrapper(const DownloadWrapper&); 
     
    124116  void                finished_download(); 
    125117 
    126   DownloadMain        m_main; 
     118  DownloadMain*       m_main; 
    127119  Object*             m_bencode; 
    128120  HashTorrent*        m_hashChecker; 
     
    133125  int                 m_connectionType; 
    134126 
    135   rak::priority_item  m_delayDownloadDone; 
    136  
    137   Signal              m_signalInitialHash; 
    138   Signal              m_signalDownloadDone; 
    139  
    140   Signal              m_signalTrackerSuccess; 
    141   SignalString        m_signalTrackerFailed; 
    142  
    143   SignalChunk         m_signalChunkPassed; 
    144   SignalChunk         m_signalChunkFailed; 
    145  
    146127  sigc::connection    m_connectionChunkPassed; 
    147128  sigc::connection    m_connectionChunkFailed; 
  • trunk/libtorrent/src/torrent/download.cc

    r1145 r1146  
    446446} 
    447447 
    448 sigc::connection 
    449 Download::signal_download_done(Download::slot_void_type s) { 
    450   return m_ptr->signal_download_done().connect(s); 
    451 } 
    452  
    453 sigc::connection 
    454 Download::signal_hash_done(Download::slot_void_type s) { 
    455   return m_ptr->signal_initial_hash().connect(s); 
    456 } 
    457  
    458 sigc::connection 
    459 Download::signal_tracker_succeeded(Download::slot_void_type s) { 
    460   return m_ptr->signal_tracker_success().connect(s); 
    461 } 
    462  
    463 sigc::connection 
    464 Download::signal_tracker_failed(Download::slot_string_type s) { 
    465   return m_ptr->signal_tracker_failed().connect(s); 
    466 } 
    467  
    468 sigc::connection 
    469 Download::signal_tracker_dump(Download::slot_dump_type s) { 
    470   return m_ptr->info()->signal_tracker_dump().connect(s); 
    471 } 
    472  
    473 sigc::connection 
    474 Download::signal_chunk_passed(Download::slot_chunk_type s) { 
    475   return m_ptr->signal_chunk_passed().connect(s); 
    476 } 
    477  
    478 sigc::connection 
    479 Download::signal_chunk_failed(Download::slot_chunk_type s) { 
    480   return m_ptr->signal_chunk_failed().connect(s); 
    481 } 
    482  
    483 sigc::connection 
    484 Download::signal_network_log(slot_string_type s) { 
    485   return m_ptr->info()->signal_network_log().connect(s); 
    486 } 
    487  
    488 sigc::connection 
    489 Download::signal_storage_error(slot_string_type s) { 
    490   return m_ptr->info()->signal_storage_error().connect(s); 
    491 } 
    492  
    493 } 
     448} 
  • trunk/libtorrent/src/torrent/download.h

    r1145 r1146  
    172172  void                add_peer(const sockaddr* addr, int port); 
    173173 
    174   typedef sigc::slot0<void>                                          slot_void_type; 
    175   typedef sigc::slot1<void, const std::string&>                      slot_string_type; 
    176  
    177   typedef sigc::slot1<void, uint32_t>                                slot_chunk_type; 
    178   typedef sigc::slot3<void, const std::string&, const char*, size_t> slot_dump_type; 
    179  
    180   // signal_download_done is a delayed signal so it is safe to 
    181   // stop/close the torrent when received. The signal is only emitted 
    182   // when the torrent is active, so hash checking will not trigger it. 
    183   sigc::connection    signal_download_done(slot_void_type s); 
    184   sigc::connection    signal_hash_done(slot_void_type s); 
    185  
    186   sigc::connection    signal_tracker_succeeded(slot_void_type s); 
    187   sigc::connection    signal_tracker_failed(slot_string_type s); 
    188   sigc::connection    signal_tracker_dump(slot_dump_type s); 
    189  
    190   sigc::connection    signal_chunk_passed(slot_chunk_type s); 
    191   sigc::connection    signal_chunk_failed(slot_chunk_type s); 
    192  
    193   // Various network log message signals. 
    194   sigc::connection    signal_network_log(slot_string_type s); 
    195  
    196   // Emits error messages if there are problems opening files for 
    197   // read/write when the download is active. The client should stop 
    198   // the download if it receive any of these as it will not be able to 
    199   // continue. 
    200   sigc::connection    signal_storage_error(slot_string_type s); 
    201  
    202174  DownloadWrapper*    ptr() { return m_ptr; } 
    203175 
  • trunk/libtorrent/src/torrent/download_info.h

    r1145 r1146  
    5757public: 
    5858  typedef sigc::slot0<uint64_t>                                        slot_stat_type; 
     59  typedef sigc::signal0<void>                                          signal_void_type; 
    5960  typedef sigc::signal1<void, const std::string&>                      signal_string_type; 
    6061  typedef sigc::signal1<void, uint32_t>                                signal_chunk_type; 
     
    142143  uint32_t            udp_tries() const                            { return 2; } 
    143144 
    144   slot_stat_type&     slot_left()                                  { return m_slotStatLeft; } 
    145   slot_stat_type&     slot_completed()                             { return m_slotStatCompleted; } 
    146  
    147   signal_string_type& signal_network_log()                         { return m_signalNetworkLog; } 
    148   signal_string_type& signal_storage_error()                       { return m_signalStorageError; } 
    149   signal_dump_type&   signal_tracker_dump()                        { return m_signalTrackerDump; } 
     145  // These signals are also used internally, so do not clear them or 
     146  // trigger them. 
     147  signal_void_type&   signal_initial_hash() const                  { return m_signalInitialHash; } 
     148  signal_void_type&   signal_download_done() const                 { return m_signalDownloadDone; } 
     149 
     150  signal_string_type& signal_network_log() const                   { return m_signalNetworkLog; } 
     151  signal_string_type& signal_storage_error() const                 { return m_signalStorageError; } 
     152  signal_dump_type&   signal_tracker_dump() const                  { return m_signalTrackerDump; } 
     153 
     154  // The list of addresses is guaranteed to be sorted and unique. 
     155  signal_void_type&   signal_tracker_success() const               { return m_signalTrackerSuccess; } 
     156  signal_string_type& signal_tracker_failed() const                { return m_signalTrackerFailed; } 
     157 
     158  signal_chunk_type&  signal_chunk_passed() const                  { return m_signalChunkPassed; } 
     159  signal_chunk_type&  signal_chunk_failed() const                  { return m_signalChunkFailed; } 
    150160 
    151161  // 
     
    154164 
    155165  void                set_creation_date(uint32_t d)                { m_creationDate = d; } 
     166 
     167  slot_stat_type&     slot_left()                                  { return m_slotStatLeft; } 
     168  slot_stat_type&     slot_completed()                             { return m_slotStatCompleted; } 
    156169 
    157170private: 
     
    179192  slot_stat_type      m_slotStatCompleted; 
    180193 
    181   signal_string_type  m_signalNetworkLog; 
    182   signal_string_type  m_signalStorageError; 
    183   signal_dump_type    m_signalTrackerDump; 
     194  mutable signal_void_type    m_signalInitialHash; 
     195  mutable signal_void_type    m_signalDownloadDone; 
     196 
     197  mutable signal_string_type  m_signalNetworkLog; 
     198  mutable signal_string_type  m_signalStorageError; 
     199  mutable signal_dump_type    m_signalTrackerDump; 
     200 
     201  mutable signal_void_type    m_signalTrackerSuccess; 
     202  mutable signal_string_type  m_signalTrackerFailed; 
     203 
     204  mutable signal_chunk_type   m_signalChunkPassed; 
     205  mutable signal_chunk_type   m_signalChunkFailed; 
    184206}; 
    185207 
  • trunk/libtorrent/test/torrent/object_static_map_test.cc

    r1141 r1146  
    260260  CPPUNIT_ASSERT(static_map_read_bencode(map_raw, "d1:bi1ee")); 
    261261  CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_a].as_raw_bencode(), "i1e")); 
    262   CPPUNIT_ASSERT(torrent::raw_bencode_equal_c_str(map_raw[key_raw_a].as_raw_bencode().as_raw_value(), "1")); 
    263262 
    264263  CPPUNIT_ASSERT(static_map_read_bencode(map_raw, "d1:b2:abe")); 
     
    310309  CPPUNIT_ASSERT(static_map_read_bencode(map_normal, "d1:ai1e1:bi2e1:ci3ee")); 
    311310  CPPUNIT_ASSERT(map_normal[key_multiple_a].as_value() == 1); 
    312   CPPUNIT_ASSERT(map_normal[key_multiple_b].as_raw_bencode().as_raw_value().size() == 1); 
    313   CPPUNIT_ASSERT(map_normal[key_multiple_b].as_raw_bencode().as_raw_value().data()[0] == '2'); 
     311//   CPPUNIT_ASSERT(map_normal[key_multiple_b].as_raw_bencode().as_raw_value().size() == 1); 
     312//   CPPUNIT_ASSERT(map_normal[key_multiple_b].as_raw_bencode().as_raw_value().data()[0] == '2'); 
    314313  CPPUNIT_ASSERT(map_normal[key_multiple_c].as_value() == 3); 
    315314} 
     
    355354  CPPUNIT_ASSERT(static_map_write_bencode(map_value, "d1:bi1ee")); 
    356355 
    357   map_value[key_single_a] = torrent::raw_value("1", 1); 
    358   CPPUNIT_ASSERT(static_map_write_bencode(map_value, "d1:bi1ee")); 
     356//   map_value[key_single_a] = torrent::raw_value("1", 1); 
     357//   CPPUNIT_ASSERT(static_map_write_bencode(map_value, "d1:bi1ee")); 
    359358 
    360359  map_value[key_single_a] = torrent::raw_string("test", 4); 
  • trunk/rtorrent/src/command_download.cc

    r1145 r1146  
    308308torrent::Object 
    309309cmd_d_initialize_logs(core::Download* download) { 
    310   download->download()->signal_network_log(sigc::mem_fun(control->core(), &core::Manager::push_log_complete)); 
    311   download->download()->signal_storage_error(sigc::mem_fun(control->core(), &core::Manager::push_log_complete)); 
     310  download->info()->signal_network_log().connect(sigc::mem_fun(control->core(), &core::Manager::push_log_complete)); 
     311  download->info()->signal_storage_error().connect(sigc::mem_fun(control->core(), &core::Manager::push_log_complete)); 
    312312 
    313313  if (!rpc::call_command_string("log.tracker").empty()) 
    314     download->download()->signal_tracker_dump(sigc::ptr_fun(&core::receive_tracker_dump)); 
     314    download->info()->signal_tracker_dump().connect(sigc::ptr_fun(&core::receive_tracker_dump)); 
    315315 
    316316  return torrent::Object(); 
  • trunk/rtorrent/src/command_ui.cc

    r1128 r1146  
    213213 
    214214torrent::Object 
    215 apply_less(rpc::target_type target, const torrent::Object& rawArgs) { 
     215apply_cmp(rpc::target_type target, const torrent::Object& rawArgs) { 
    216216  const torrent::Object::list_type& args = rawArgs.as_list(); 
    217217   
     
    240240     
    241241  switch (result1.type()) { 
    242   case torrent::Object::TYPE_VALUE:  return result1.as_value() < result2.as_value(); 
    243   case torrent::Object::TYPE_STRING: return result1.as_string() < result2.as_string(); 
    244   default: return (int64_t)false; 
     242  case torrent::Object::TYPE_VALUE:  return result1.as_value() - result2.as_value(); 
     243  case torrent::Object::TYPE_STRING: return result1.as_string().compare(result2.as_string()); 
     244  default: return torrent::Object(); 
    245245  } 
    246246} 
    247247 
    248 // Fixme. 
    249 torrent::Object 
    250 apply_greater(rpc::target_type target, const torrent::Object& rawArgs) { 
    251   return (int64_t)!apply_less(target, rawArgs).as_value(); 
     248torrent::Object apply_less(rpc::target_type target, const torrent::Object& rawArgs) { 
     249  torrent::Object result = apply_cmp(target, rawArgs); 
     250  return result.is_value() ? result.as_value() <  0 : (int64_t)false; 
     251} 
     252 
     253torrent::Object apply_greater(rpc::target_type target, const torrent::Object& rawArgs) { 
     254  torrent::Object result = apply_cmp(target, rawArgs); 
     255  return result.is_value() ? result.as_value() >  0 : (int64_t)false; 
     256} 
     257 
     258torrent::Object apply_equal(rpc::target_type target, const torrent::Object& rawArgs) { 
     259  torrent::Object result = apply_cmp(target, rawArgs); 
     260  return result.is_value() ? result.as_value() == 0 : (int64_t)false; 
    252261} 
    253262 
     
    506515  ADD_ANY_LIST("less",                  rak::ptr_fn(&apply_less)); 
    507516  ADD_ANY_LIST("greater",               rak::ptr_fn(&apply_greater)); 
     517  ADD_ANY_LIST("equal",                 rak::ptr_fn(&apply_equal)); 
    508518 
    509519  // A temporary command for handling stuff until we get proper 
  • trunk/rtorrent/src/core/download.cc

    r1144 r1146  
    6464  m_resumeFlags(~uint32_t()) { 
    6565 
    66   m_connTrackerSucceeded = m_download.signal_tracker_succeeded(sigc::bind(sigc::mem_fun(*this, &Download::receive_tracker_msg), "")); 
    67   m_connTrackerFailed   = m_download.signal_tracker_failed(sigc::mem_fun(*this, &Download::receive_tracker_msg)); 
    68   m_connStorageError    = m_download.signal_storage_error(sigc::mem_fun(*this, &Download::receive_storage_error)); 
     66  m_connTrackerSucceeded = m_download.info()->signal_tracker_success().connect(sigc::bind(sigc::mem_fun(*this, &Download::receive_tracker_msg), "")); 
     67  m_connTrackerFailed   = m_download.info()->signal_tracker_failed().connect(sigc::mem_fun(*this, &Download::receive_tracker_msg)); 
     68  m_connStorageError    = m_download.info()->signal_storage_error().connect(sigc::mem_fun(*this, &Download::receive_storage_error)); 
    6969 
    70   m_download.signal_chunk_failed(sigc::mem_fun(*this, &Download::receive_chunk_failed)); 
     70  m_download.info()->signal_chunk_failed().connect(sigc::mem_fun(*this, &Download::receive_chunk_failed)); 
    7171} 
    7272 
  • trunk/rtorrent/src/core/download_list.cc

    r1145 r1146  
    176176 
    177177  try { 
    178     (*itr)->download()->signal_download_done(sigc::bind(sigc::mem_fun(*this, &DownloadList::received_finished), download)); 
    179     (*itr)->download()->signal_hash_done(sigc::bind(sigc::mem_fun(*this, &DownloadList::hash_done), download)); 
     178    (*itr)->info()->signal_download_done().connect(sigc::bind(sigc::mem_fun(*this, &DownloadList::received_finished), download)); 
     179    (*itr)->info()->signal_initial_hash().connect(sigc::bind(sigc::mem_fun(*this, &DownloadList::hash_done), download)); 
    180180 
    181181    // This needs to be separated into two different calls to ensure 
Note: See TracChangeset for help on using the changeset viewer.