@ -62,11 +62,11 @@
@@ -62,11 +62,11 @@
enum ProxyType { HTTP = 1 , SOCKS5 = 2 , HTTP_PW = 3 , SOCKS5_PW = 4 } ;
// Main constructor
bittorrent : : b ittorrent( ) : preAllocateAll ( false ) , addInPause ( false ) , ratio_limit ( - 1 ) , UPnPEnabled ( false ) , NATPMPEnabled ( false ) , LSDEnabled ( false ) , DHTEnabled ( false ) , queueingEnabled ( false ) , geoipDBLoaded ( false ) {
Bittorrent : : B ittorrent( ) : preAllocateAll ( false ) , addInPause ( false ) , ratio_limit ( - 1 ) , UPnPEnabled ( false ) , NATPMPEnabled ( false ) , LSDEnabled ( false ) , DHTEnabled ( false ) , queueingEnabled ( false ) , geoipDBLoaded ( false ) {
resolve_countries = false ;
// To avoid some exceptions
fs : : path : : default_name_check ( fs : : no_check ) ;
// Creating b ittorrent session
// Creating B ittorrent session
// Check if we should spoof utorrent
if ( Preferences : : isUtorrentSpoofingEnabled ( ) ) {
s = new session ( fingerprint ( " UT " , 1 , 8 , 5 , 0 ) , 0 ) ;
@ -102,7 +102,7 @@ bittorrent::bittorrent() : preAllocateAll(false), addInPause(false), ratio_limit
@@ -102,7 +102,7 @@ bittorrent::bittorrent() : preAllocateAll(false), addInPause(false), ratio_limit
}
// Main destructor
b ittorrent: : ~ b ittorrent( ) {
B ittorrent: : ~ B ittorrent( ) {
qDebug ( " BTSession deletion " ) ;
// Do some BT related saving
saveDHTEntry ( ) ;
@ -131,7 +131,7 @@ bittorrent::~bittorrent() {
@@ -131,7 +131,7 @@ bittorrent::~bittorrent() {
qDebug ( " Session deleted " ) ;
}
void b ittorrent: : preAllocateAllFiles ( bool b ) {
void B ittorrent: : preAllocateAllFiles ( bool b ) {
bool change = ( preAllocateAll ! = b ) ;
if ( change ) {
qDebug ( " PreAllocateAll changed, reloading all torrents! " ) ;
@ -139,7 +139,7 @@ void bittorrent::preAllocateAllFiles(bool b) {
@@ -139,7 +139,7 @@ void bittorrent::preAllocateAllFiles(bool b) {
}
}
void b ittorrent: : deleteBigRatios ( ) {
void B ittorrent: : deleteBigRatios ( ) {
if ( ratio_limit = = - 1 ) return ;
std : : vector < torrent_handle > torrents = getTorrents ( ) ;
std : : vector < torrent_handle > : : iterator torrentIT ;
@ -159,18 +159,18 @@ void bittorrent::deleteBigRatios() {
@@ -159,18 +159,18 @@ void bittorrent::deleteBigRatios() {
}
}
void b ittorrent: : setDownloadLimit ( QString hash , long val ) {
void B ittorrent: : setDownloadLimit ( QString hash , long val ) {
QTorrentHandle h = getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) ) {
h . set_download_limit ( val ) ;
}
}
bool b ittorrent: : isQueueingEnabled ( ) const {
bool B ittorrent: : isQueueingEnabled ( ) const {
return queueingEnabled ;
}
void b ittorrent: : setUploadLimit ( QString hash , long val ) {
void B ittorrent: : setUploadLimit ( QString hash , long val ) {
qDebug ( " Set upload limit rate to %ld " , val ) ;
QTorrentHandle h = getTorrentHandle ( hash ) ;
if ( h . is_valid ( ) ) {
@ -178,7 +178,7 @@ void bittorrent::setUploadLimit(QString hash, long val) {
@@ -178,7 +178,7 @@ void bittorrent::setUploadLimit(QString hash, long val) {
}
}
void b ittorrent: : handleDownloadFailure ( QString url , QString reason ) {
void B ittorrent: : handleDownloadFailure ( QString url , QString reason ) {
emit downloadFromUrlFailure ( url , reason ) ;
// Clean up
int index = url_skippingDlg . indexOf ( url ) ;
@ -188,11 +188,11 @@ void bittorrent::handleDownloadFailure(QString url, QString reason) {
@@ -188,11 +188,11 @@ void bittorrent::handleDownloadFailure(QString url, QString reason) {
savepath_fromurl . remove ( url ) ;
}
void b ittorrent: : startTorrentsInPause ( bool b ) {
void B ittorrent: : startTorrentsInPause ( bool b ) {
addInPause = b ;
}
void b ittorrent: : setQueueingEnabled ( bool enable ) {
void B ittorrent: : setQueueingEnabled ( bool enable ) {
if ( queueingEnabled ! = enable ) {
qDebug ( " Queueing system is changing state... " ) ;
queueingEnabled = enable ;
@ -200,7 +200,7 @@ void bittorrent::setQueueingEnabled(bool enable) {
@@ -200,7 +200,7 @@ void bittorrent::setQueueingEnabled(bool enable) {
}
// Set BT session configuration
void b ittorrent: : configureSession ( ) {
void B ittorrent: : configureSession ( ) {
qDebug ( " Configuring session " ) ;
// Downloads
// * Save path
@ -293,7 +293,7 @@ void bittorrent::configureSession() {
@@ -293,7 +293,7 @@ void bittorrent::configureSession() {
sessionSettings . use_dht_as_fallback = false ;
//sessionSettings.announce_to_all_trackers = true;
sessionSettings . announce_to_all_tiers = true ; //uTorrent behavior
// To keep same behavior as in qb ittorrent v1.2.0
// To keep same behavior as in qB ittorrent v1.2.0
sessionSettings . rate_limit_ip_overhead = false ;
// Queueing System
if ( Preferences : : isQueueingSystemEnabled ( ) ) {
@ -453,7 +453,7 @@ void bittorrent::configureSession() {
@@ -453,7 +453,7 @@ void bittorrent::configureSession() {
qDebug ( " Session configured " ) ;
}
bool b ittorrent: : initWebUi ( QString username , QString password , int port ) {
bool B ittorrent: : initWebUi ( QString username , QString password , int port ) {
if ( httpServer )
httpServer - > close ( ) ;
else
@ -467,7 +467,7 @@ bool bittorrent::initWebUi(QString username, QString password, int port) {
@@ -467,7 +467,7 @@ bool bittorrent::initWebUi(QString username, QString password, int port) {
return success ;
}
void b ittorrent: : takeETASamples ( ) {
void B ittorrent: : takeETASamples ( ) {
bool change = false ; ;
foreach ( const QString & hash , ETA_samples . keys ( ) ) {
QTorrentHandle h = getTorrentHandle ( hash ) ;
@ -492,7 +492,7 @@ void bittorrent::takeETASamples() {
@@ -492,7 +492,7 @@ void bittorrent::takeETASamples() {
// GASA: Global Average Speed Algorithm
// CSA: Current Speed Algorithm
// WINX: Window of X Algorithm
qlonglong b ittorrent: : getETA ( QString hash ) {
qlonglong B ittorrent: : getETA ( QString hash ) {
QTorrentHandle h = getTorrentHandle ( hash ) ;
if ( ! h . is_valid ( ) | | h . state ( ) ! = torrent_status : : downloading | | ! h . active_time ( ) )
return - 1 ;
@ -527,16 +527,16 @@ qlonglong bittorrent::getETA(QString hash) {
@@ -527,16 +527,16 @@ qlonglong bittorrent::getETA(QString hash) {
return ( qlonglong ) floor ( ( double ) ( bytes_left ) / avg_speed ) ;
}
std : : vector < torrent_handle > b ittorrent: : getTorrents ( ) const {
std : : vector < torrent_handle > B ittorrent: : getTorrents ( ) const {
return s - > get_torrents ( ) ;
}
// Return the torrent handle, given its hash
QTorrentHandle b ittorrent: : getTorrentHandle ( QString hash ) const {
QTorrentHandle B ittorrent: : getTorrentHandle ( QString hash ) const {
return QTorrentHandle ( s - > find_torrent ( misc : : fromString < sha1_hash > ( ( hash . toStdString ( ) ) ) ) ) ;
}
bool b ittorrent: : hasActiveTorrents ( ) const {
bool B ittorrent: : hasActiveTorrents ( ) const {
std : : vector < torrent_handle > torrents = getTorrents ( ) ;
std : : vector < torrent_handle > : : iterator torrentIT ;
for ( torrentIT = torrents . begin ( ) ; torrentIT ! = torrents . end ( ) ; torrentIT + + ) {
@ -547,14 +547,14 @@ bool bittorrent::hasActiveTorrents() const {
@@ -547,14 +547,14 @@ bool bittorrent::hasActiveTorrents() const {
return false ;
}
void b ittorrent: : banIP ( QString ip ) {
void B ittorrent: : banIP ( QString ip ) {
FilterParserThread : : processFilterList ( s , QStringList ( ip ) ) ;
Preferences : : banIP ( ip ) ;
}
// Delete a torrent from the session, given its hash
// permanent = true means that the torrent will be removed from the hard-drive too
void b ittorrent: : deleteTorrent ( QString hash , bool delete_local_files ) {
void B ittorrent: : deleteTorrent ( QString hash , bool delete_local_files ) {
qDebug ( " Deleting torrent with hash: %s " , hash . toLocal8Bit ( ) . data ( ) ) ;
QTorrentHandle h = getTorrentHandle ( hash ) ;
if ( ! h . is_valid ( ) ) {
@ -586,7 +586,7 @@ void bittorrent::deleteTorrent(QString hash, bool delete_local_files) {
@@ -586,7 +586,7 @@ void bittorrent::deleteTorrent(QString hash, bool delete_local_files) {
emit deletedTorrent ( hash ) ;
}
void b ittorrent: : pauseAllTorrents ( ) {
void B ittorrent: : pauseAllTorrents ( ) {
std : : vector < torrent_handle > torrents = getTorrents ( ) ;
std : : vector < torrent_handle > : : iterator torrentIT ;
for ( torrentIT = torrents . begin ( ) ; torrentIT ! = torrents . end ( ) ; torrentIT + + ) {
@ -599,7 +599,7 @@ void bittorrent::pauseAllTorrents() {
@@ -599,7 +599,7 @@ void bittorrent::pauseAllTorrents() {
}
}
void b ittorrent: : resumeAllTorrents ( ) {
void B ittorrent: : resumeAllTorrents ( ) {
std : : vector < torrent_handle > torrents = getTorrents ( ) ;
std : : vector < torrent_handle > : : iterator torrentIT ;
for ( torrentIT = torrents . begin ( ) ; torrentIT ! = torrents . end ( ) ; torrentIT + + ) {
@ -612,7 +612,7 @@ void bittorrent::resumeAllTorrents() {
@@ -612,7 +612,7 @@ void bittorrent::resumeAllTorrents() {
}
}
void b ittorrent: : pauseTorrent ( QString hash ) {
void B ittorrent: : pauseTorrent ( QString hash ) {
QTorrentHandle h = getTorrentHandle ( hash ) ;
if ( ! h . is_paused ( ) ) {
h . pause ( ) ;
@ -620,7 +620,7 @@ void bittorrent::pauseTorrent(QString hash) {
@@ -620,7 +620,7 @@ void bittorrent::pauseTorrent(QString hash) {
}
}
void b ittorrent: : resumeTorrent ( QString hash ) {
void B ittorrent: : resumeTorrent ( QString hash ) {
QTorrentHandle h = getTorrentHandle ( hash ) ;
if ( h . is_paused ( ) ) {
h . resume ( ) ;
@ -628,7 +628,7 @@ void bittorrent::resumeTorrent(QString hash) {
@@ -628,7 +628,7 @@ void bittorrent::resumeTorrent(QString hash) {
}
}
void b ittorrent: : loadWebSeeds ( QString hash ) {
void B ittorrent: : loadWebSeeds ( QString hash ) {
QVariantList url_seeds = TorrentPersistentData : : getUrlSeeds ( hash ) ;
QTorrentHandle h = getTorrentHandle ( hash ) ;
// First remove from the torrent the url seeds that were deleted
@ -654,7 +654,7 @@ void bittorrent::loadWebSeeds(QString hash) {
@@ -654,7 +654,7 @@ void bittorrent::loadWebSeeds(QString hash) {
}
}
QTorrentHandle b ittorrent: : addMagnetUri ( QString magnet_uri , bool resumed ) {
QTorrentHandle B ittorrent: : addMagnetUri ( QString magnet_uri , bool resumed ) {
QTorrentHandle h ;
QString hash = misc : : magnetUriToHash ( magnet_uri ) ;
if ( hash . isEmpty ( ) ) {
@ -714,7 +714,7 @@ QTorrentHandle bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
@@ -714,7 +714,7 @@ QTorrentHandle bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
p . paused = false ;
p . duplicate_is_error = false ; // Already checked
p . auto_managed = false ; // Because it is added in paused state
// Adding torrent to b ittorrent session
// Adding torrent to B ittorrent session
try {
h = QTorrentHandle ( add_magnet_uri ( * s , magnet_uri . toStdString ( ) , p ) ) ;
} catch ( std : : exception e ) {
@ -771,8 +771,8 @@ QTorrentHandle bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
@@ -771,8 +771,8 @@ QTorrentHandle bittorrent::addMagnetUri(QString magnet_uri, bool resumed) {
return h ;
}
// Add a torrent to the b ittorrent session
QTorrentHandle b ittorrent: : addTorrent ( QString path , bool fromScanDir , QString from_url , bool resumed ) {
// Add a torrent to the B ittorrent session
QTorrentHandle B ittorrent: : addTorrent ( QString path , bool fromScanDir , QString from_url , bool resumed ) {
QTorrentHandle h ;
bool fastResume = false ;
QDir torrentBackup ( misc : : qBittorrentPath ( ) + " BT_backup " ) ;
@ -886,7 +886,7 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
@@ -886,7 +886,7 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
p . paused = true ;
p . duplicate_is_error = false ; // Already checked
p . auto_managed = false ; // Because it is added in paused state
// Adding torrent to b ittorrent session
// Adding torrent to B ittorrent session
try {
h = QTorrentHandle ( s - > add_torrent ( p ) ) ;
} catch ( std : : exception e ) {
@ -965,7 +965,7 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
@@ -965,7 +965,7 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
// Check if the user filtered files in this torrent.
bool b ittorrent: : has_filtered_files ( QString hash ) const {
bool B ittorrent: : has_filtered_files ( QString hash ) const {
QVariantList files_priority = TorrentPersistentData : : getFilesPriority ( hash ) ;
foreach ( QVariant var_prio , files_priority ) {
int priority = var_prio . toInt ( ) ;
@ -979,11 +979,11 @@ bool bittorrent::has_filtered_files(QString hash) const{
@@ -979,11 +979,11 @@ bool bittorrent::has_filtered_files(QString hash) const{
}
// Set the maximum number of opened connections
void b ittorrent: : setMaxConnections ( int maxConnec ) {
void B ittorrent: : setMaxConnections ( int maxConnec ) {
s - > set_max_connections ( maxConnec ) ;
}
void b ittorrent: : setMaxConnectionsPerTorrent ( int max ) {
void B ittorrent: : setMaxConnectionsPerTorrent ( int max ) {
// Apply this to all session torrents
std : : vector < torrent_handle > handles = s - > get_torrents ( ) ;
unsigned int nbHandles = handles . size ( ) ;
@ -997,7 +997,7 @@ void bittorrent::setMaxConnectionsPerTorrent(int max) {
@@ -997,7 +997,7 @@ void bittorrent::setMaxConnectionsPerTorrent(int max) {
}
}
void b ittorrent: : setMaxUploadsPerTorrent ( int max ) {
void B ittorrent: : setMaxUploadsPerTorrent ( int max ) {
// Apply this to all session torrents
std : : vector < torrent_handle > handles = s - > get_torrents ( ) ;
unsigned int nbHandles = handles . size ( ) ;
@ -1012,11 +1012,11 @@ void bittorrent::setMaxUploadsPerTorrent(int max) {
@@ -1012,11 +1012,11 @@ void bittorrent::setMaxUploadsPerTorrent(int max) {
}
// Return DHT state
bool b ittorrent: : isDHTEnabled ( ) const {
bool B ittorrent: : isDHTEnabled ( ) const {
return DHTEnabled ;
}
void b ittorrent: : enableUPnP ( bool b ) {
void B ittorrent: : enableUPnP ( bool b ) {
if ( b ) {
if ( ! UPnPEnabled ) {
qDebug ( " Enabling UPnP " ) ;
@ -1032,7 +1032,7 @@ void bittorrent::enableUPnP(bool b) {
@@ -1032,7 +1032,7 @@ void bittorrent::enableUPnP(bool b) {
}
}
void b ittorrent: : enableNATPMP ( bool b ) {
void B ittorrent: : enableNATPMP ( bool b ) {
if ( b ) {
if ( ! NATPMPEnabled ) {
qDebug ( " Enabling NAT-PMP " ) ;
@ -1048,7 +1048,7 @@ void bittorrent::enableNATPMP(bool b) {
@@ -1048,7 +1048,7 @@ void bittorrent::enableNATPMP(bool b) {
}
}
void b ittorrent: : enableLSD ( bool b ) {
void B ittorrent: : enableLSD ( bool b ) {
if ( b ) {
if ( ! LSDEnabled ) {
qDebug ( " Enabling LSD " ) ;
@ -1064,7 +1064,7 @@ void bittorrent::enableLSD(bool b) {
@@ -1064,7 +1064,7 @@ void bittorrent::enableLSD(bool b) {
}
}
void b ittorrent: : loadSessionState ( ) {
void B ittorrent: : loadSessionState ( ) {
boost : : filesystem : : ifstream ses_state_file ( ( misc : : qBittorrentPath ( ) + QString : : fromUtf8 ( " ses_state " ) ) . toLocal8Bit ( ) . data ( )
, std : : ios_base : : binary ) ;
ses_state_file . unsetf ( std : : ios_base : : skipws ) ;
@ -1073,7 +1073,7 @@ void bittorrent::loadSessionState() {
@@ -1073,7 +1073,7 @@ void bittorrent::loadSessionState() {
, std : : istream_iterator < char > ( ) ) ) ;
}
void b ittorrent: : saveSessionState ( ) {
void B ittorrent: : saveSessionState ( ) {
qDebug ( " Saving session state to disk... " ) ;
entry session_state = s - > state ( ) ;
boost : : filesystem : : ofstream out ( ( misc : : qBittorrentPath ( ) + QString : : fromUtf8 ( " ses_state " ) ) . toLocal8Bit ( ) . data ( )
@ -1083,7 +1083,7 @@ void bittorrent::saveSessionState() {
@@ -1083,7 +1083,7 @@ void bittorrent::saveSessionState() {
}
// Enable DHT
bool b ittorrent: : enableDHT ( bool b ) {
bool B ittorrent: : enableDHT ( bool b ) {
if ( b ) {
if ( ! DHTEnabled ) {
entry dht_state ;
@ -1119,7 +1119,7 @@ bool bittorrent::enableDHT(bool b) {
@@ -1119,7 +1119,7 @@ bool bittorrent::enableDHT(bool b) {
// Read pieces priorities from hard disk
// and ask QTorrentHandle to consider them
void b ittorrent: : loadFilesPriorities ( QTorrentHandle & h ) {
void B ittorrent: : loadFilesPriorities ( QTorrentHandle & h ) {
qDebug ( " Applying files priority " ) ;
if ( ! h . is_valid ( ) ) {
qDebug ( " /! \\ Error: Invalid handle " ) ;
@ -1144,7 +1144,7 @@ void bittorrent::loadFilesPriorities(QTorrentHandle &h) {
@@ -1144,7 +1144,7 @@ void bittorrent::loadFilesPriorities(QTorrentHandle &h) {
h . prioritize_files ( v ) ;
}
float b ittorrent: : getRealRatio ( QString hash ) const {
float B ittorrent: : getRealRatio ( QString hash ) const {
QTorrentHandle h = getTorrentHandle ( hash ) ;
Q_ASSERT ( h . all_time_download ( ) > = 0 ) ;
Q_ASSERT ( h . all_time_upload ( ) > = 0 ) ;
@ -1162,7 +1162,7 @@ float bittorrent::getRealRatio(QString hash) const{
@@ -1162,7 +1162,7 @@ float bittorrent::getRealRatio(QString hash) const{
// Only save fast resume data for unfinished and unpaused torrents (Optimization)
// Called periodically and on exit
void b ittorrent: : saveFastResumeData ( ) {
void B ittorrent: : saveFastResumeData ( ) {
// Stop listening for alerts
timerAlerts - > stop ( ) ;
int num_resume_data = 0 ;
@ -1218,22 +1218,22 @@ void bittorrent::saveFastResumeData() {
@@ -1218,22 +1218,22 @@ void bittorrent::saveFastResumeData() {
}
}
QStringList b ittorrent: : getConsoleMessages ( ) const {
QStringList B ittorrent: : getConsoleMessages ( ) const {
return consoleMessages ;
}
QStringList b ittorrent: : getPeerBanMessages ( ) const {
QStringList B ittorrent: : getPeerBanMessages ( ) const {
return peerBanMessages ;
}
void b ittorrent: : addConsoleMessage ( QString msg , QColor color ) {
void B ittorrent: : addConsoleMessage ( QString msg , QColor color ) {
if ( consoleMessages . size ( ) > 100 ) {
consoleMessages . removeFirst ( ) ;
}
consoleMessages . append ( QString : : fromUtf8 ( " <font color='grey'> " ) + QDateTime : : currentDateTime ( ) . toString ( QString : : fromUtf8 ( " dd/MM/yyyy hh:mm:ss " ) ) + QString : : fromUtf8 ( " </font> - <font color=' " ) + color . name ( ) + QString : : fromUtf8 ( " '><i> " ) + msg + QString : : fromUtf8 ( " </i></font> " ) ) ;
}
void b ittorrent: : addPeerBanMessage ( QString ip , bool from_ipfilter ) {
void B ittorrent: : addPeerBanMessage ( QString ip , bool from_ipfilter ) {
if ( peerBanMessages . size ( ) > 100 ) {
peerBanMessages . removeFirst ( ) ;
}
@ -1243,7 +1243,7 @@ void bittorrent::addPeerBanMessage(QString ip, bool from_ipfilter) {
@@ -1243,7 +1243,7 @@ void bittorrent::addPeerBanMessage(QString ip, bool from_ipfilter) {
peerBanMessages . append ( QString : : fromUtf8 ( " <font color='grey'> " ) + QDateTime : : currentDateTime ( ) . toString ( QString : : fromUtf8 ( " dd/MM/yyyy hh:mm:ss " ) ) + QString : : fromUtf8 ( " </font> - " ) + tr ( " <font color='red'>%1</font> <i>was banned due to corrupt pieces</i> " , " x.y.z.w was banned " ) . arg ( ip ) ) ;
}
bool b ittorrent: : isFilePreviewPossible ( QString hash ) const {
bool B ittorrent: : isFilePreviewPossible ( QString hash ) const {
// See if there are supported files in the torrent
QTorrentHandle h = getTorrentHandle ( hash ) ;
if ( ! h . is_valid ( ) ) {
@ -1260,7 +1260,7 @@ bool bittorrent::isFilePreviewPossible(QString hash) const{
@@ -1260,7 +1260,7 @@ bool bittorrent::isFilePreviewPossible(QString hash) const{
return false ;
}
void b ittorrent: : addTorrentsFromScanFolder ( QStringList & pathList ) {
void B ittorrent: : addTorrentsFromScanFolder ( QStringList & pathList ) {
QString dir_path = FSWatcher - > directories ( ) . first ( ) ;
foreach ( const QString & file , pathList ) {
QString fullPath = dir_path + QDir : : separator ( ) + file ;
@ -1273,15 +1273,15 @@ void bittorrent::addTorrentsFromScanFolder(QStringList &pathList) {
@@ -1273,15 +1273,15 @@ void bittorrent::addTorrentsFromScanFolder(QStringList &pathList) {
}
}
QString b ittorrent: : getDefaultSavePath ( ) const {
QString B ittorrent: : getDefaultSavePath ( ) const {
return defaultSavePath ;
}
bool b ittorrent: : useTemporaryFolder ( ) const {
bool B ittorrent: : useTemporaryFolder ( ) const {
return ! defaultTempPath . isEmpty ( ) ;
}
void b ittorrent: : setDefaultTempPath ( QString temppath ) {
void B ittorrent: : setDefaultTempPath ( QString temppath ) {
if ( defaultTempPath = = temppath )
return ;
if ( temppath . isEmpty ( ) ) {
@ -1308,13 +1308,13 @@ void bittorrent::setDefaultTempPath(QString temppath) {
@@ -1308,13 +1308,13 @@ void bittorrent::setDefaultTempPath(QString temppath) {
defaultTempPath = temppath ;
}
void b ittorrent: : saveTrackerFile ( QString hash ) {
void B ittorrent: : saveTrackerFile ( QString hash ) {
QTorrentHandle h = getTorrentHandle ( hash ) ;
TorrentPersistentData : : saveTrackers ( h ) ;
}
// Enable directory scanning
void b ittorrent: : enableDirectoryScanning ( QString scan_dir ) {
void B ittorrent: : enableDirectoryScanning ( QString scan_dir ) {
if ( ! scan_dir . isEmpty ( ) ) {
QDir newDir ( scan_dir ) ;
if ( ! newDir . exists ( ) ) {
@ -1339,40 +1339,40 @@ void bittorrent::enableDirectoryScanning(QString scan_dir) {
@@ -1339,40 +1339,40 @@ void bittorrent::enableDirectoryScanning(QString scan_dir) {
}
// Disable directory scanning
void b ittorrent: : disableDirectoryScanning ( ) {
void B ittorrent: : disableDirectoryScanning ( ) {
if ( FSWatcher ) {
delete FSWatcher ;
}
}
// Set the ports range in which is chosen the port the b ittorrent
// Set the ports range in which is chosen the port the B ittorrent
// session will listen to
void b ittorrent: : setListeningPort ( int port ) {
void B ittorrent: : setListeningPort ( int port ) {
std : : pair < int , int > ports ( port , port ) ;
s - > listen_on ( ports ) ;
}
// Set download rate limit
// -1 to disable
void b ittorrent: : setDownloadRateLimit ( long rate ) {
void B ittorrent: : setDownloadRateLimit ( long rate ) {
qDebug ( " Setting a global download rate limit at %ld " , rate ) ;
s - > set_download_rate_limit ( rate ) ;
}
session * b ittorrent: : getSession ( ) const {
session * B ittorrent: : getSession ( ) const {
return s ;
}
// Set upload rate limit
// -1 to disable
void b ittorrent: : setUploadRateLimit ( long rate ) {
void B ittorrent: : setUploadRateLimit ( long rate ) {
qDebug ( " set upload_limit to %fkb/s " , rate / 1024. ) ;
s - > set_upload_rate_limit ( rate ) ;
}
// libtorrent allow to adjust ratio for each torrent
// This function will apply to same ratio to all torrents
void b ittorrent: : setGlobalRatio ( float ratio ) {
void B ittorrent: : setGlobalRatio ( float ratio ) {
if ( ratio ! = - 1 & & ratio < 1. ) ratio = 1. ;
if ( ratio = = - 1 ) {
// 0 means unlimited for libtorrent
@ -1392,7 +1392,7 @@ void bittorrent::setGlobalRatio(float ratio) {
@@ -1392,7 +1392,7 @@ void bittorrent::setGlobalRatio(float ratio) {
// Torrents will a ratio superior to the given value will
// be automatically deleted
void b ittorrent: : setDeleteRatio ( float ratio ) {
void B ittorrent: : setDeleteRatio ( float ratio ) {
if ( ratio ! = - 1 & & ratio < 1. ) ratio = 1. ;
if ( ratio_limit = = - 1 & & ratio ! = - 1 ) {
Q_ASSERT ( ! BigRatioTimer ) ;
@ -1411,7 +1411,7 @@ void bittorrent::setDeleteRatio(float ratio) {
@@ -1411,7 +1411,7 @@ void bittorrent::setDeleteRatio(float ratio) {
}
}
void b ittorrent: : loadTrackerFile ( QString hash ) {
void B ittorrent: : loadTrackerFile ( QString hash ) {
QHash < QString , QVariant > tiers = TorrentPersistentData : : getTrackers ( hash ) ;
std : : vector < announce_entry > trackers ;
foreach ( const QString tracker_url , tiers . keys ( ) ) {
@ -1427,7 +1427,7 @@ void bittorrent::loadTrackerFile(QString hash) {
@@ -1427,7 +1427,7 @@ void bittorrent::loadTrackerFile(QString hash) {
}
// Set DHT port (>= 1000 or 0 if same as BT)
void b ittorrent: : setDHTPort ( int dht_port ) {
void B ittorrent: : setDHTPort ( int dht_port ) {
if ( dht_port = = 0 or dht_port > = 1000 ) {
struct dht_settings DHTSettings ;
DHTSettings . service_port = dht_port ;
@ -1437,7 +1437,7 @@ void bittorrent::setDHTPort(int dht_port) {
@@ -1437,7 +1437,7 @@ void bittorrent::setDHTPort(int dht_port) {
}
// Enable IP Filtering
void b ittorrent: : enableIPFilter ( QString filter ) {
void B ittorrent: : enableIPFilter ( QString filter ) {
qDebug ( " Enabling IPFiler " ) ;
if ( ! filterParser ) {
filterParser = new FilterParserThread ( this , s ) ;
@ -1449,7 +1449,7 @@ void bittorrent::enableIPFilter(QString filter) {
@@ -1449,7 +1449,7 @@ void bittorrent::enableIPFilter(QString filter) {
}
// Disable IP Filtering
void b ittorrent: : disableIPFilter ( ) {
void B ittorrent: : disableIPFilter ( ) {
qDebug ( " Disabling IPFilter " ) ;
s - > set_ip_filter ( ip_filter ( ) ) ;
if ( filterParser ) {
@ -1459,13 +1459,13 @@ void bittorrent::disableIPFilter() {
@@ -1459,13 +1459,13 @@ void bittorrent::disableIPFilter() {
}
// Set BT session settings (user_agent)
void b ittorrent: : setSessionSettings ( session_settings sessionSettings ) {
void B ittorrent: : setSessionSettings ( session_settings sessionSettings ) {
qDebug ( " Set session settings " ) ;
s - > set_settings ( sessionSettings ) ;
}
// Set Proxy
void b ittorrent: : setProxySettings ( proxy_settings proxySettings , bool trackers , bool peers , bool web_seeds , bool dht ) {
void B ittorrent: : setProxySettings ( proxy_settings proxySettings , bool trackers , bool peers , bool web_seeds , bool dht ) {
qDebug ( " Set Proxy settings " ) ;
proxy_settings ps_null ;
ps_null . type = proxy_settings : : none ;
@ -1493,8 +1493,8 @@ void bittorrent::setProxySettings(proxy_settings proxySettings, bool trackers, b
@@ -1493,8 +1493,8 @@ void bittorrent::setProxySettings(proxy_settings proxySettings, bool trackers, b
}
}
// Read alerts sent by the b ittorrent session
void b ittorrent: : readAlerts ( ) {
// Read alerts sent by the B ittorrent session
void B ittorrent: : readAlerts ( ) {
// look at session alerts and display some infos
std : : auto_ptr < alert > a = s - > pop_alert ( ) ;
while ( a . get ( ) ) {
@ -1695,19 +1695,19 @@ void bittorrent::readAlerts() {
@@ -1695,19 +1695,19 @@ void bittorrent::readAlerts() {
}
}
QHash < QString , TrackerInfos > b ittorrent: : getTrackersInfo ( QString hash ) const {
QHash < QString , TrackerInfos > B ittorrent: : getTrackersInfo ( QString hash ) const {
return trackersInfos . value ( hash , QHash < QString , TrackerInfos > ( ) ) ;
}
int b ittorrent: : getListenPort ( ) const {
int B ittorrent: : getListenPort ( ) const {
return s - > listen_port ( ) ;
}
session_status b ittorrent: : getSessionStatus ( ) const {
session_status B ittorrent: : getSessionStatus ( ) const {
return s - > status ( ) ;
}
QString b ittorrent: : getSavePath ( QString hash ) {
QString B ittorrent: : getSavePath ( QString hash ) {
QString savePath ;
if ( TorrentTempData : : hasTempData ( hash ) ) {
savePath = TorrentTempData : : getSavePath ( hash ) ;
@ -1737,24 +1737,24 @@ QString bittorrent::getSavePath(QString hash) {
@@ -1737,24 +1737,24 @@ QString bittorrent::getSavePath(QString hash) {
// Take an url string to a torrent file,
// download the torrent file to a tmp location, then
// add it to download list
void b ittorrent: : downloadFromUrl ( QString url ) {
void B ittorrent: : downloadFromUrl ( QString url ) {
addConsoleMessage ( tr ( " Downloading '%1', please wait... " , " e.g: Downloading 'xxx.torrent', please wait... " ) . arg ( url ) , QPalette : : WindowText ) ;
//emit aboutToDownloadFromUrl(url);
// Launch downloader thread
downloader - > downloadUrl ( url ) ;
}
void b ittorrent: : downloadFromURLList ( const QStringList & urls ) {
void B ittorrent: : downloadFromURLList ( const QStringList & urls ) {
foreach ( const QString & url , urls ) {
downloadFromUrl ( url ) ;
}
}
void b ittorrent: : addMagnetSkipAddDlg ( QString uri ) {
void B ittorrent: : addMagnetSkipAddDlg ( QString uri ) {
addMagnetUri ( uri , false ) ;
}
void b ittorrent: : downloadUrlAndSkipDialog ( QString url , QString save_path ) {
void B ittorrent: : downloadUrlAndSkipDialog ( QString url , QString save_path ) {
//emit aboutToDownloadFromUrl(url);
if ( ! save_path . isEmpty ( ) )
savepath_fromurl [ url ] = save_path ;
@ -1763,8 +1763,8 @@ void bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) {
@@ -1763,8 +1763,8 @@ void bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) {
downloader - > downloadUrl ( url ) ;
}
// Add to b ittorrent session the downloaded torrent file
void b ittorrent: : processDownloadedFile ( QString url , QString file_path ) {
// Add to B ittorrent session the downloaded torrent file
void B ittorrent: : processDownloadedFile ( QString url , QString file_path ) {
int index = url_skippingDlg . indexOf ( url ) ;
if ( index < 0 ) {
// Add file to torrent download list
@ -1778,7 +1778,7 @@ void bittorrent::processDownloadedFile(QString url, QString file_path) {
@@ -1778,7 +1778,7 @@ void bittorrent::processDownloadedFile(QString url, QString file_path) {
// Return current download rate for the BT
// session. Payload means that it only take into
// account "useful" part of the rate
float b ittorrent: : getPayloadDownloadRate ( ) const {
float B ittorrent: : getPayloadDownloadRate ( ) const {
session_status sessionStatus = s - > status ( ) ;
return sessionStatus . payload_download_rate ;
}
@ -1786,13 +1786,13 @@ float bittorrent::getPayloadDownloadRate() const{
@@ -1786,13 +1786,13 @@ float bittorrent::getPayloadDownloadRate() const{
// Return current upload rate for the BT
// session. Payload means that it only take into
// account "useful" part of the rate
float b ittorrent: : getPayloadUploadRate ( ) const {
float B ittorrent: : getPayloadUploadRate ( ) const {
session_status sessionStatus = s - > status ( ) ;
return sessionStatus . payload_upload_rate ;
}
// Save DHT entry to hard drive
void b ittorrent: : saveDHTEntry ( ) {
void B ittorrent: : saveDHTEntry ( ) {
// Save DHT entry
if ( DHTEnabled ) {
try {
@ -1807,14 +1807,14 @@ void bittorrent::saveDHTEntry() {
@@ -1807,14 +1807,14 @@ void bittorrent::saveDHTEntry() {
}
}
void b ittorrent: : applyEncryptionSettings ( pe_settings se ) {
void B ittorrent: : applyEncryptionSettings ( pe_settings se ) {
qDebug ( " Applying encryption settings " ) ;
s - > set_pe_settings ( se ) ;
}
// Will fast resume torrents in
// backup directory
void b ittorrent: : startUpTorrents ( ) {
void B ittorrent: : startUpTorrents ( ) {
qDebug ( " Resuming unfinished torrents " ) ;
QSettings settings ( QString : : fromUtf8 ( " qBittorrent " ) , QString : : fromUtf8 ( " qBittorrent " ) ) ;
QDir torrentBackup ( misc : : qBittorrentPath ( ) + " BT_backup " ) ;
@ -1880,7 +1880,7 @@ void bittorrent::startUpTorrents() {
@@ -1880,7 +1880,7 @@ void bittorrent::startUpTorrents() {
// Import torrents temp data from v1.4.0 or earlier: save_path, filtered pieces
// TODO: Remove in qBittorrent v1.6.0
void b ittorrent: : importOldTempData ( QString torrent_path ) {
void B ittorrent: : importOldTempData ( QString torrent_path ) {
// Create torrent hash
boost : : intrusive_ptr < torrent_info > t ;
try {
@ -1930,7 +1930,7 @@ void bittorrent::importOldTempData(QString torrent_path) {
@@ -1930,7 +1930,7 @@ void bittorrent::importOldTempData(QString torrent_path) {
// Trackers, web seeds, speed limits
// TODO: Remove in qBittorrent v1.6.0
void b ittorrent: : applyFormerAttributeFiles ( QTorrentHandle h ) {
void B ittorrent: : applyFormerAttributeFiles ( QTorrentHandle h ) {
// Load trackers
QDir torrentBackup ( misc : : qBittorrentPath ( ) + " BT_backup " ) ;
QFile tracker_file ( torrentBackup . path ( ) + QDir : : separator ( ) + h . hash ( ) + " .trackers " ) ;
@ -1999,7 +1999,7 @@ void bittorrent::applyFormerAttributeFiles(QTorrentHandle h) {
@@ -1999,7 +1999,7 @@ void bittorrent::applyFormerAttributeFiles(QTorrentHandle h) {
// Import torrents from v1.4.0 or earlier
// TODO: Remove in qBittorrent v1.6.0
void b ittorrent: : importOldTorrents ( ) {
void B ittorrent: : importOldTorrents ( ) {
QSettings settings ( QString : : fromUtf8 ( " qBittorrent " ) , QString : : fromUtf8 ( " qBittorrent " ) ) ;
Q_ASSERT ( ! settings . value ( " v1_4_x_torrent_imported " , false ) . toBool ( ) ) ;
// Import old torrent