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

« back to all changes in this revision

Viewing changes to src/download/download_manager.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:
48
48
DownloadManager::iterator
49
49
DownloadManager::insert(DownloadWrapper* d) {
50
50
  if (find(d->info()->hash()) != end())
51
 
    throw client_error("Could not add torrent as it already exists.");
 
51
    throw internal_error("Could not add torrent as it already exists.");
52
52
 
53
53
  return base_type::insert(end(), d);
54
54
}
58
58
  iterator itr = std::find(begin(), end(), d);
59
59
 
60
60
  if (itr == end())
61
 
    throw client_error("Tried to remove a torrent that doesn't exist");
 
61
    throw internal_error("Tried to remove a torrent that doesn't exist");
62
62
    
63
63
  delete *itr;
64
64
  return base_type::erase(itr);
74
74
 
75
75
DownloadManager::iterator
76
76
DownloadManager::find(const std::string& hash) {
 
77
  return std::find_if(begin(), end(), rak::equal(*HashString::cast_from(hash),
 
78
                                                 rak::on(std::mem_fun(&DownloadWrapper::info), std::mem_fun(&DownloadInfo::hash))));
 
79
}
 
80
 
 
81
DownloadManager::iterator
 
82
DownloadManager::find(const HashString& hash) {
77
83
  return std::find_if(begin(), end(), rak::equal(hash, rak::on(std::mem_fun(&DownloadWrapper::info), std::mem_fun(&DownloadInfo::hash))));
78
84
}
79
85
 
83
89
}
84
90
 
85
91
DownloadMain*
86
 
DownloadManager::find_main(const std::string& hash) {
87
 
  iterator itr = std::find_if(begin(), end(), rak::equal(hash, rak::on(std::mem_fun(&DownloadWrapper::info), std::mem_fun(&DownloadInfo::hash))));
88
 
 
89
 
  // TODO: Move these checks somewhere else.
90
 
  if (itr == end() || !(*itr)->info()->is_active())
 
92
DownloadManager::find_main(const char* hash) {
 
93
  iterator itr = std::find_if(begin(), end(), rak::equal(*HashString::cast_from(hash),
 
94
                                                         rak::on(std::mem_fun(&DownloadWrapper::info), std::mem_fun(&DownloadInfo::hash))));
 
95
 
 
96
  if (itr == end())
 
97
    return NULL;
 
98
  else
 
99
    return (*itr)->main();
 
100
}
 
101
 
 
102
DownloadMain*
 
103
DownloadManager::find_main_obfuscated(const char* hash) {
 
104
  iterator itr = std::find_if(begin(), end(), rak::equal(*HashString::cast_from(hash),
 
105
                                                         rak::on(std::mem_fun(&DownloadWrapper::info), std::mem_fun(&DownloadInfo::hash_obfuscated))));
 
106
 
 
107
  if (itr == end())
91
108
    return NULL;
92
109
  else
93
110
    return (*itr)->main();