Browse Source

- Manage country resolution on libtorrent side. The flags are not displayed in the peer list yet though

adaptive-webui-19844
Christophe Dumez 15 years ago
parent
commit
12106c308e
  1. 18
      src/bittorrent.cpp
  2. 1
      src/bittorrent.h
  3. 10
      src/qtorrenthandle.cpp
  4. 2
      src/qtorrenthandle.h

18
src/bittorrent.cpp

@ -59,6 +59,7 @@ enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4};
// Main constructor // Main constructor
bittorrent::bittorrent() : DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), ratio_limit(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), queueingEnabled(false) { bittorrent::bittorrent() : DHTEnabled(false), preAllocateAll(false), addInPause(false), maxConnecsPerTorrent(500), maxUploadsPerTorrent(4), ratio_limit(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), queueingEnabled(false) {
resolve_countries = false;
// To avoid some exceptions // To avoid some exceptions
fs::path::default_name_check(fs::no_check); fs::path::default_name_check(fs::no_check);
// Creating bittorrent session // Creating bittorrent session
@ -262,6 +263,19 @@ void bittorrent::configureSession() {
// Enabled // Enabled
setUploadRateLimit(up_limit*1024); setUploadRateLimit(up_limit*1024);
} }
// Resolve countries
bool new_resolv_countries = Preferences::resolvePeerCountries();
if(resolve_countries != new_resolv_countries) {
resolve_countries = new_resolv_countries;
// Update torrent handles
std::vector<torrent_handle> torrents = getTorrents();
std::vector<torrent_handle>::iterator torrentIT;
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
if(h.is_valid())
h.resolve_countries(resolve_countries);
}
}
// * UPnP // * UPnP
if(Preferences::isUPnPEnabled()) { if(Preferences::isUPnPEnabled()) {
enableUPnP(true); enableUPnP(true);
@ -653,6 +667,8 @@ QTorrentHandle bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
h.set_max_connections(maxConnecsPerTorrent); h.set_max_connections(maxConnecsPerTorrent);
// Uploads limit per torrent // Uploads limit per torrent
h.set_max_uploads(maxUploadsPerTorrent); h.set_max_uploads(maxUploadsPerTorrent);
// Resolve countries
h.resolve_countries(resolve_countries);
// Load filtered files // Load filtered files
if(resumed) { if(resumed) {
// Load custom url seeds // Load custom url seeds
@ -825,6 +841,8 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
h.set_max_connections(maxConnecsPerTorrent); h.set_max_connections(maxConnecsPerTorrent);
// Uploads limit per torrent // Uploads limit per torrent
h.set_max_uploads(maxUploadsPerTorrent); h.set_max_uploads(maxUploadsPerTorrent);
// Resolve countries
h.resolve_countries(resolve_countries);
// Load filtered files // Load filtered files
loadFilesPriorities(h); loadFilesPriorities(h);
if(resumed) { if(resumed) {

1
src/bittorrent.h

@ -75,6 +75,7 @@ class bittorrent : public QObject {
bool queueingEnabled; bool queueingEnabled;
QStringList url_skippingDlg; QStringList url_skippingDlg;
QHash<QString, QString> savepath_fromurl; QHash<QString, QString> savepath_fromurl;
bool resolve_countries;
protected: protected:
QString getSavePath(QString hash); QString getSavePath(QString hash);

10
src/qtorrenthandle.cpp

@ -374,6 +374,11 @@ bool QTorrentHandle::is_sequential_download() const {
return h.is_sequential_download(); return h.is_sequential_download();
} }
bool QTorrentHandle::resolve_countries() const {
Q_ASSERT(h.is_valid());
return h.resolve_countries();
}
// //
// Setters // Setters
// //
@ -487,6 +492,11 @@ void QTorrentHandle::super_seeding(bool on) const {
h.super_seeding(on); h.super_seeding(on);
} }
void QTorrentHandle::resolve_countries(bool r) {
Q_ASSERT(h.is_valid());
h.resolve_countries(r);
}
// //
// Operators // Operators
// //

2
src/qtorrenthandle.h

@ -117,6 +117,7 @@ class QTorrentHandle {
bool super_seeding() const; bool super_seeding() const;
QString creation_date() const; QString creation_date() const;
void get_peer_info(std::vector<peer_info>&) const; void get_peer_info(std::vector<peer_info>&) const;
bool resolve_countries() const;
// //
// Setters // Setters
@ -143,6 +144,7 @@ class QTorrentHandle {
void force_recheck() const; void force_recheck() const;
void move_storage(QString path) const; void move_storage(QString path) const;
void super_seeding(bool on) const; void super_seeding(bool on) const;
void resolve_countries(bool r);
// //
// Operators // Operators

Loading…
Cancel
Save