~ubuntu-branches/debian/experimental/libtorrent/experimental

« back to all changes in this revision

Viewing changes to src/download/connection_list.cc

  • Committer: Bazaar Package Importer
  • Author(s): Jose Luis Rivas
  • Date: 2007-03-31 10:31:05 UTC
  • mto: (4.1.4 gutsy) (6.2.1 squeeze) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20070331103105-jzpp1rml6ud0ff75
Tags: upstream-0.11.4
ImportĀ upstreamĀ versionĀ 0.11.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
#include "download/download_main.h"
43
43
#include "protocol/peer_connection_base.h"
44
44
#include "torrent/exceptions.h"
45
 
#include "torrent/peer_info.h"
 
45
#include "torrent/peer/peer_info.h"
46
46
 
47
47
#include "connection_list.h"
48
48
 
55
55
}
56
56
 
57
57
PeerConnectionBase*
58
 
ConnectionList::insert(PeerInfo* peerInfo, const SocketFd& fd, Bitfield* bitfield) {
 
58
ConnectionList::insert(PeerInfo* peerInfo, const SocketFd& fd, Bitfield* bitfield, EncryptionInfo* encryptionInfo) {
59
59
  if (size() >= m_maxSize)
60
60
    return NULL;
61
61
 
62
 
  PeerConnectionBase* peerConnection = m_slotNewConnection();
 
62
  PeerConnectionBase* peerConnection = m_slotNewConnection(encryptionInfo->is_encrypted());
63
63
 
64
64
  if (peerConnection == NULL || bitfield == NULL)
65
65
    throw internal_error("ConnectionList::insert(...) received a NULL pointer.");
66
66
 
67
 
  peerConnection->initialize(m_download, peerInfo, fd, bitfield);
 
67
  peerInfo->set_connection(peerConnection);
 
68
  peerConnection->initialize(m_download, peerInfo, fd, bitfield, encryptionInfo);
68
69
 
69
70
  base_type::push_back(peerConnection);
 
71
 
70
72
  m_download->info()->set_accepting_new_peers(size() < m_maxSize);
71
 
 
72
73
  m_slotConnected(peerConnection);
73
74
 
74
75
  return peerConnection;
91
92
 
92
93
  // Before of after the signal?
93
94
  peerConnection->cleanup();
 
95
  peerConnection->peer_info()->set_connection(NULL);
 
96
 
94
97
  m_download->peer_list()->disconnected(peerConnection->peer_info(), 0);
95
98
 
96
99
  // Delete after the signal to ensure the address of 'v' doesn't get
106
109
 
107
110
void
108
111
ConnectionList::erase(PeerInfo* peerInfo, int flags) {
109
 
  iterator itr = std::find_if(begin(), end(), rak::equal(peerInfo, std::mem_fun(&PeerConnectionBase::peer_info)));
 
112
//   iterator itr = std::find_if(begin(), end(), rak::equal(peerInfo, std::mem_fun(&PeerConnectionBase::peer_info)));
 
113
  iterator itr = std::find(begin(), end(), peerInfo->connection());
110
114
 
111
115
  if (itr == end())
112
116
    return;
165
169
}
166
170
 
167
171
void
168
 
ConnectionList::send_finished_chunk(uint32_t index) {
169
 
  std::for_each(begin(), end(), std::bind2nd(std::mem_fun(&PeerConnectionBase::receive_finished_chunk), index));
170
 
}
171
 
 
172
 
void
173
172
ConnectionList::set_max_size(size_type v) { 
174
173
  m_maxSize = v;
175
174
  m_download->info()->set_accepting_new_peers(size() < m_maxSize);