diff --git a/src/GUI.cpp b/src/GUI.cpp index e2d7b2292..aeb2183c9 100644 --- a/src/GUI.cpp +++ b/src/GUI.cpp @@ -101,7 +101,7 @@ GUI::GUI(QWidget *parent, QStringList torrentCmdLine) : QMainWindow(parent), dis // Fix Tool bar layout toolBar->layout()->setSpacing(7); // Creating Bittorrent session - BTSession = new bittorrent(); + BTSession = new Bittorrent(); connect(BTSession, SIGNAL(fullDiskError(QTorrentHandle&, QString)), this, SLOT(fullDiskError(QTorrentHandle&, QString))); connect(BTSession, SIGNAL(finishedTorrent(QTorrentHandle&)), this, SLOT(finishedTorrent(QTorrentHandle&))); connect(BTSession, SIGNAL(trackerAuthenticationRequired(QTorrentHandle&)), this, SLOT(trackerAuthenticationRequired(QTorrentHandle&))); diff --git a/src/GUI.h b/src/GUI.h index c61e36f53..18c9c475d 100644 --- a/src/GUI.h +++ b/src/GUI.h @@ -37,7 +37,7 @@ #include "ui_MainWindow.h" #include "qtorrenthandle.h" -class bittorrent; +class Bittorrent; class QTimer; class downloadFromURL; class SearchEngine; @@ -59,7 +59,7 @@ class GUI : public QMainWindow, private Ui::MainWindow{ private: // Bittorrent - bittorrent *BTSession; + Bittorrent *BTSession; QList > unauthenticated_trackers; // Still needed? // GUI related QTimer *guiUpdater; diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index 482b38dfa..9c89930dc 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -62,11 +62,11 @@ enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4}; // Main constructor -bittorrent::bittorrent() : preAllocateAll(false), addInPause(false), ratio_limit(-1), UPnPEnabled(false), NATPMPEnabled(false), LSDEnabled(false), DHTEnabled(false), queueingEnabled(false), geoipDBLoaded(false) { +Bittorrent::Bittorrent() : 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 bittorrent session + // Creating Bittorrent 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 } // Main destructor -bittorrent::~bittorrent() { +Bittorrent::~Bittorrent() { qDebug("BTSession deletion"); // Do some BT related saving saveDHTEntry(); @@ -131,7 +131,7 @@ bittorrent::~bittorrent() { qDebug("Session deleted"); } -void bittorrent::preAllocateAllFiles(bool b) { +void Bittorrent::preAllocateAllFiles(bool b) { bool change = (preAllocateAll != b); if(change) { qDebug("PreAllocateAll changed, reloading all torrents!"); @@ -139,7 +139,7 @@ void bittorrent::preAllocateAllFiles(bool b) { } } -void bittorrent::deleteBigRatios() { +void Bittorrent::deleteBigRatios() { if(ratio_limit == -1) return; std::vector torrents = getTorrents(); std::vector::iterator torrentIT; @@ -159,18 +159,18 @@ void bittorrent::deleteBigRatios() { } } -void bittorrent::setDownloadLimit(QString hash, long val) { +void Bittorrent::setDownloadLimit(QString hash, long val) { QTorrentHandle h = getTorrentHandle(hash); if(h.is_valid()) { h.set_download_limit(val); } } -bool bittorrent::isQueueingEnabled() const { +bool Bittorrent::isQueueingEnabled() const { return queueingEnabled; } -void bittorrent::setUploadLimit(QString hash, long val) { +void Bittorrent::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) { } } -void bittorrent::handleDownloadFailure(QString url, QString reason) { +void Bittorrent::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) { savepath_fromurl.remove(url); } -void bittorrent::startTorrentsInPause(bool b) { +void Bittorrent::startTorrentsInPause(bool b) { addInPause = b; } -void bittorrent::setQueueingEnabled(bool enable) { +void Bittorrent::setQueueingEnabled(bool enable) { if(queueingEnabled != enable) { qDebug("Queueing system is changing state..."); queueingEnabled = enable; @@ -200,7 +200,7 @@ void bittorrent::setQueueingEnabled(bool enable) { } // Set BT session configuration -void bittorrent::configureSession() { +void Bittorrent::configureSession() { qDebug("Configuring session"); // Downloads // * Save path @@ -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 qbittorrent v1.2.0 + // To keep same behavior as in qBittorrent v1.2.0 sessionSettings.rate_limit_ip_overhead = false; // Queueing System if(Preferences::isQueueingSystemEnabled()) { @@ -453,7 +453,7 @@ void bittorrent::configureSession() { qDebug("Session configured"); } -bool bittorrent::initWebUi(QString username, QString password, int port) { +bool Bittorrent::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) { return success; } -void bittorrent::takeETASamples() { +void Bittorrent::takeETASamples() { bool change = false;; foreach(const QString &hash, ETA_samples.keys()) { QTorrentHandle h = getTorrentHandle(hash); @@ -492,7 +492,7 @@ void bittorrent::takeETASamples() { // GASA: Global Average Speed Algorithm // CSA: Current Speed Algorithm // WINX: Window of X Algorithm -qlonglong bittorrent::getETA(QString hash) { +qlonglong Bittorrent::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) { return (qlonglong) floor((double) (bytes_left) / avg_speed); } -std::vector bittorrent::getTorrents() const { +std::vector Bittorrent::getTorrents() const { return s->get_torrents(); } // Return the torrent handle, given its hash -QTorrentHandle bittorrent::getTorrentHandle(QString hash) const{ +QTorrentHandle Bittorrent::getTorrentHandle(QString hash) const{ return QTorrentHandle(s->find_torrent(misc::fromString((hash.toStdString())))); } -bool bittorrent::hasActiveTorrents() const { +bool Bittorrent::hasActiveTorrents() const { std::vector torrents = getTorrents(); std::vector::iterator torrentIT; for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { @@ -547,14 +547,14 @@ bool bittorrent::hasActiveTorrents() const { return false; } -void bittorrent::banIP(QString ip) { +void Bittorrent::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 bittorrent::deleteTorrent(QString hash, bool delete_local_files) { +void Bittorrent::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) { emit deletedTorrent(hash); } -void bittorrent::pauseAllTorrents() { +void Bittorrent::pauseAllTorrents() { std::vector torrents = getTorrents(); std::vector::iterator torrentIT; for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { @@ -599,7 +599,7 @@ void bittorrent::pauseAllTorrents() { } } -void bittorrent::resumeAllTorrents() { +void Bittorrent::resumeAllTorrents() { std::vector torrents = getTorrents(); std::vector::iterator torrentIT; for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) { @@ -612,7 +612,7 @@ void bittorrent::resumeAllTorrents() { } } -void bittorrent::pauseTorrent(QString hash) { +void Bittorrent::pauseTorrent(QString hash) { QTorrentHandle h = getTorrentHandle(hash); if(!h.is_paused()) { h.pause(); @@ -620,7 +620,7 @@ void bittorrent::pauseTorrent(QString hash) { } } -void bittorrent::resumeTorrent(QString hash) { +void Bittorrent::resumeTorrent(QString hash) { QTorrentHandle h = getTorrentHandle(hash); if(h.is_paused()) { h.resume(); @@ -628,7 +628,7 @@ void bittorrent::resumeTorrent(QString hash) { } } -void bittorrent::loadWebSeeds(QString hash) { +void Bittorrent::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) { } } -QTorrentHandle bittorrent::addMagnetUri(QString magnet_uri, bool resumed) { +QTorrentHandle Bittorrent::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) { p.paused = false; p.duplicate_is_error = false; // Already checked p.auto_managed = false; // Because it is added in paused state - // Adding torrent to bittorrent session + // Adding torrent to Bittorrent 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) { return h; } -// Add a torrent to the bittorrent session -QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString from_url, bool resumed) { +// Add a torrent to the Bittorrent session +QTorrentHandle Bittorrent::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 p.paused = true; p.duplicate_is_error = false; // Already checked p.auto_managed = false; // Because it is added in paused state - // Adding torrent to bittorrent session + // Adding torrent to Bittorrent 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 // Check if the user filtered files in this torrent. -bool bittorrent::has_filtered_files(QString hash) const{ +bool Bittorrent::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{ } // Set the maximum number of opened connections -void bittorrent::setMaxConnections(int maxConnec) { +void Bittorrent::setMaxConnections(int maxConnec) { s->set_max_connections(maxConnec); } -void bittorrent::setMaxConnectionsPerTorrent(int max) { +void Bittorrent::setMaxConnectionsPerTorrent(int max) { // Apply this to all session torrents std::vector handles = s->get_torrents(); unsigned int nbHandles = handles.size(); @@ -997,7 +997,7 @@ void bittorrent::setMaxConnectionsPerTorrent(int max) { } } -void bittorrent::setMaxUploadsPerTorrent(int max) { +void Bittorrent::setMaxUploadsPerTorrent(int max) { // Apply this to all session torrents std::vector handles = s->get_torrents(); unsigned int nbHandles = handles.size(); @@ -1012,11 +1012,11 @@ void bittorrent::setMaxUploadsPerTorrent(int max) { } // Return DHT state -bool bittorrent::isDHTEnabled() const{ +bool Bittorrent::isDHTEnabled() const{ return DHTEnabled; } -void bittorrent::enableUPnP(bool b) { +void Bittorrent::enableUPnP(bool b) { if(b) { if(!UPnPEnabled) { qDebug("Enabling UPnP"); @@ -1032,7 +1032,7 @@ void bittorrent::enableUPnP(bool b) { } } -void bittorrent::enableNATPMP(bool b) { +void Bittorrent::enableNATPMP(bool b) { if(b) { if(!NATPMPEnabled) { qDebug("Enabling NAT-PMP"); @@ -1048,7 +1048,7 @@ void bittorrent::enableNATPMP(bool b) { } } -void bittorrent::enableLSD(bool b) { +void Bittorrent::enableLSD(bool b) { if(b) { if(!LSDEnabled) { qDebug("Enabling LSD"); @@ -1064,7 +1064,7 @@ void bittorrent::enableLSD(bool b) { } } -void bittorrent::loadSessionState() { +void Bittorrent::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() { , std::istream_iterator())); } -void bittorrent::saveSessionState() { +void Bittorrent::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() { } // Enable DHT -bool bittorrent::enableDHT(bool b) { +bool Bittorrent::enableDHT(bool b) { if(b) { if(!DHTEnabled) { entry dht_state; @@ -1119,7 +1119,7 @@ bool bittorrent::enableDHT(bool b) { // Read pieces priorities from hard disk // and ask QTorrentHandle to consider them -void bittorrent::loadFilesPriorities(QTorrentHandle &h) { +void Bittorrent::loadFilesPriorities(QTorrentHandle &h) { qDebug("Applying files priority"); if(!h.is_valid()) { qDebug("/!\\ Error: Invalid handle"); @@ -1144,7 +1144,7 @@ void bittorrent::loadFilesPriorities(QTorrentHandle &h) { h.prioritize_files(v); } -float bittorrent::getRealRatio(QString hash) const{ +float Bittorrent::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{ // Only save fast resume data for unfinished and unpaused torrents (Optimization) // Called periodically and on exit -void bittorrent::saveFastResumeData() { +void Bittorrent::saveFastResumeData() { // Stop listening for alerts timerAlerts->stop(); int num_resume_data = 0; @@ -1218,22 +1218,22 @@ void bittorrent::saveFastResumeData() { } } -QStringList bittorrent::getConsoleMessages() const { +QStringList Bittorrent::getConsoleMessages() const { return consoleMessages; } -QStringList bittorrent::getPeerBanMessages() const { +QStringList Bittorrent::getPeerBanMessages() const { return peerBanMessages; } -void bittorrent::addConsoleMessage(QString msg, QColor color) { +void Bittorrent::addConsoleMessage(QString msg, QColor color) { if(consoleMessages.size() > 100) { consoleMessages.removeFirst(); } consoleMessages.append(QString::fromUtf8("")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8(" - ") + msg + QString::fromUtf8("")); } -void bittorrent::addPeerBanMessage(QString ip, bool from_ipfilter) { +void Bittorrent::addPeerBanMessage(QString ip, bool from_ipfilter) { if(peerBanMessages.size() > 100) { peerBanMessages.removeFirst(); } @@ -1243,7 +1243,7 @@ void bittorrent::addPeerBanMessage(QString ip, bool from_ipfilter) { peerBanMessages.append(QString::fromUtf8("")+ QDateTime::currentDateTime().toString(QString::fromUtf8("dd/MM/yyyy hh:mm:ss")) + QString::fromUtf8(" - ")+tr("%1 was banned due to corrupt pieces", "x.y.z.w was banned").arg(ip)); } -bool bittorrent::isFilePreviewPossible(QString hash) const{ +bool Bittorrent::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{ return false; } -void bittorrent::addTorrentsFromScanFolder(QStringList &pathList) { +void Bittorrent::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) { } } -QString bittorrent::getDefaultSavePath() const { +QString Bittorrent::getDefaultSavePath() const { return defaultSavePath; } -bool bittorrent::useTemporaryFolder() const { +bool Bittorrent::useTemporaryFolder() const { return !defaultTempPath.isEmpty(); } -void bittorrent::setDefaultTempPath(QString temppath) { +void Bittorrent::setDefaultTempPath(QString temppath) { if(defaultTempPath == temppath) return; if(temppath.isEmpty()) { @@ -1308,13 +1308,13 @@ void bittorrent::setDefaultTempPath(QString temppath) { defaultTempPath = temppath; } -void bittorrent::saveTrackerFile(QString hash) { +void Bittorrent::saveTrackerFile(QString hash) { QTorrentHandle h = getTorrentHandle(hash); TorrentPersistentData::saveTrackers(h); } // Enable directory scanning -void bittorrent::enableDirectoryScanning(QString scan_dir) { +void Bittorrent::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) { } // Disable directory scanning -void bittorrent::disableDirectoryScanning() { +void Bittorrent::disableDirectoryScanning() { if(FSWatcher) { delete FSWatcher; } } -// Set the ports range in which is chosen the port the bittorrent +// Set the ports range in which is chosen the port the Bittorrent // session will listen to -void bittorrent::setListeningPort(int port) { +void Bittorrent::setListeningPort(int port) { std::pair ports(port, port); s->listen_on(ports); } // Set download rate limit // -1 to disable -void bittorrent::setDownloadRateLimit(long rate) { +void Bittorrent::setDownloadRateLimit(long rate) { qDebug("Setting a global download rate limit at %ld", rate); s->set_download_rate_limit(rate); } -session* bittorrent::getSession() const{ +session* Bittorrent::getSession() const{ return s; } // Set upload rate limit // -1 to disable -void bittorrent::setUploadRateLimit(long rate) { +void Bittorrent::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 bittorrent::setGlobalRatio(float ratio) { +void Bittorrent::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) { // Torrents will a ratio superior to the given value will // be automatically deleted -void bittorrent::setDeleteRatio(float ratio) { +void Bittorrent::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) { } } -void bittorrent::loadTrackerFile(QString hash) { +void Bittorrent::loadTrackerFile(QString hash) { QHash tiers = TorrentPersistentData::getTrackers(hash); std::vector trackers; foreach(const QString tracker_url, tiers.keys()) { @@ -1427,7 +1427,7 @@ void bittorrent::loadTrackerFile(QString hash) { } // Set DHT port (>= 1000 or 0 if same as BT) -void bittorrent::setDHTPort(int dht_port) { +void Bittorrent::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) { } // Enable IP Filtering -void bittorrent::enableIPFilter(QString filter) { +void Bittorrent::enableIPFilter(QString filter) { qDebug("Enabling IPFiler"); if(!filterParser) { filterParser = new FilterParserThread(this, s); @@ -1449,7 +1449,7 @@ void bittorrent::enableIPFilter(QString filter) { } // Disable IP Filtering -void bittorrent::disableIPFilter() { +void Bittorrent::disableIPFilter() { qDebug("Disabling IPFilter"); s->set_ip_filter(ip_filter()); if(filterParser) { @@ -1459,13 +1459,13 @@ void bittorrent::disableIPFilter() { } // Set BT session settings (user_agent) -void bittorrent::setSessionSettings(session_settings sessionSettings) { +void Bittorrent::setSessionSettings(session_settings sessionSettings) { qDebug("Set session settings"); s->set_settings(sessionSettings); } // Set Proxy -void bittorrent::setProxySettings(proxy_settings proxySettings, bool trackers, bool peers, bool web_seeds, bool dht) { +void Bittorrent::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 } } -// Read alerts sent by the bittorrent session -void bittorrent::readAlerts() { +// Read alerts sent by the Bittorrent session +void Bittorrent::readAlerts() { // look at session alerts and display some infos std::auto_ptr a = s->pop_alert(); while (a.get()) { @@ -1695,19 +1695,19 @@ void bittorrent::readAlerts() { } } -QHash bittorrent::getTrackersInfo(QString hash) const{ +QHash Bittorrent::getTrackersInfo(QString hash) const{ return trackersInfos.value(hash, QHash()); } -int bittorrent::getListenPort() const{ +int Bittorrent::getListenPort() const{ return s->listen_port(); } -session_status bittorrent::getSessionStatus() const{ +session_status Bittorrent::getSessionStatus() const{ return s->status(); } -QString bittorrent::getSavePath(QString hash) { +QString Bittorrent::getSavePath(QString hash) { QString savePath; if(TorrentTempData::hasTempData(hash)) { savePath = TorrentTempData::getSavePath(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 bittorrent::downloadFromUrl(QString url) { +void Bittorrent::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 bittorrent::downloadFromURLList(const QStringList& urls) { +void Bittorrent::downloadFromURLList(const QStringList& urls) { foreach(const QString &url, urls) { downloadFromUrl(url); } } -void bittorrent::addMagnetSkipAddDlg(QString uri) { +void Bittorrent::addMagnetSkipAddDlg(QString uri) { addMagnetUri(uri, false); } -void bittorrent::downloadUrlAndSkipDialog(QString url, QString save_path) { +void Bittorrent::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) { downloader->downloadUrl(url); } -// Add to bittorrent session the downloaded torrent file -void bittorrent::processDownloadedFile(QString url, QString file_path) { +// Add to Bittorrent session the downloaded torrent file +void Bittorrent::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) { // Return current download rate for the BT // session. Payload means that it only take into // account "useful" part of the rate -float bittorrent::getPayloadDownloadRate() const{ +float Bittorrent::getPayloadDownloadRate() const{ session_status sessionStatus = s->status(); return sessionStatus.payload_download_rate; } @@ -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 bittorrent::getPayloadUploadRate() const{ +float Bittorrent::getPayloadUploadRate() const{ session_status sessionStatus = s->status(); return sessionStatus.payload_upload_rate; } // Save DHT entry to hard drive -void bittorrent::saveDHTEntry() { +void Bittorrent::saveDHTEntry() { // Save DHT entry if(DHTEnabled) { try{ @@ -1807,14 +1807,14 @@ void bittorrent::saveDHTEntry() { } } -void bittorrent::applyEncryptionSettings(pe_settings se) { +void Bittorrent::applyEncryptionSettings(pe_settings se) { qDebug("Applying encryption settings"); s->set_pe_settings(se); } // Will fast resume torrents in // backup directory -void bittorrent::startUpTorrents() { +void Bittorrent::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() { // Import torrents temp data from v1.4.0 or earlier: save_path, filtered pieces // TODO: Remove in qBittorrent v1.6.0 -void bittorrent::importOldTempData(QString torrent_path) { +void Bittorrent::importOldTempData(QString torrent_path) { // Create torrent hash boost::intrusive_ptr t; try { @@ -1930,7 +1930,7 @@ void bittorrent::importOldTempData(QString torrent_path) { // Trackers, web seeds, speed limits // TODO: Remove in qBittorrent v1.6.0 -void bittorrent::applyFormerAttributeFiles(QTorrentHandle h) { +void Bittorrent::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) { // Import torrents from v1.4.0 or earlier // TODO: Remove in qBittorrent v1.6.0 -void bittorrent::importOldTorrents() { +void Bittorrent::importOldTorrents() { QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); Q_ASSERT(!settings.value("v1_4_x_torrent_imported", false).toBool()); // Import old torrent diff --git a/src/bittorrent.h b/src/bittorrent.h index 4c7a2a178..a156593dd 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -67,7 +67,7 @@ public: } }; -class bittorrent : public QObject { +class Bittorrent : public QObject { Q_OBJECT private: @@ -115,8 +115,8 @@ protected: public: // Constructor / Destructor - bittorrent(); - ~bittorrent(); + Bittorrent(); + ~Bittorrent(); QTorrentHandle getTorrentHandle(QString hash) const; std::vector getTorrents() const; bool isFilePreviewPossible(QString fileHash) const; diff --git a/src/console_imp.h b/src/console_imp.h index 7296e7c4b..0d70eae47 100644 --- a/src/console_imp.h +++ b/src/console_imp.h @@ -40,10 +40,10 @@ class consoleDlg : public QDialog, private Ui_ConsoleDlg{ Q_OBJECT private: - bittorrent *BTSession; + Bittorrent *BTSession; public: - consoleDlg(QWidget *parent, bittorrent* _BTSession) : QDialog(parent) { + consoleDlg(QWidget *parent, Bittorrent* _BTSession) : QDialog(parent) { setupUi(this); setAttribute(Qt::WA_DeleteOnClose); BTSession = _BTSession; diff --git a/src/eventmanager.cpp b/src/eventmanager.cpp index c0bfefe04..c7df0791f 100644 --- a/src/eventmanager.cpp +++ b/src/eventmanager.cpp @@ -33,7 +33,7 @@ #include "bittorrent.h" #include -EventManager::EventManager(QObject *parent, bittorrent *BTSession) +EventManager::EventManager(QObject *parent, Bittorrent *BTSession) : QObject(parent), BTSession(BTSession) { } diff --git a/src/eventmanager.h b/src/eventmanager.h index afb97b4c9..9d80b4e72 100644 --- a/src/eventmanager.h +++ b/src/eventmanager.h @@ -36,20 +36,20 @@ #include #include -struct bittorrent; +class Bittorrent; class EventManager : public QObject { Q_OBJECT private: QHash event_list; - bittorrent* BTSession; + Bittorrent* BTSession; protected: void update(QVariantMap event); public: - EventManager(QObject *parent, bittorrent* BTSession); + EventManager(QObject *parent, Bittorrent* BTSession); QList getEventList() const; public slots: diff --git a/src/feeddownloader.h b/src/feeddownloader.h index 70b94b40f..171cf0de1 100644 --- a/src/feeddownloader.h +++ b/src/feeddownloader.h @@ -228,11 +228,11 @@ private: QString feed_url; QString feed_name; FeedFilters filters; - bittorrent *BTSession; + Bittorrent *BTSession; QString selected_filter; // name public: - FeedDownloaderDlg(QWidget *parent, QString feed_url, QString feed_name, bittorrent* BTSession): QDialog(parent), feed_url(feed_url), feed_name(feed_name), BTSession(BTSession), selected_filter(QString::null){ + FeedDownloaderDlg(QWidget *parent, QString feed_url, QString feed_name, Bittorrent* BTSession): QDialog(parent), feed_url(feed_url), feed_name(feed_name), BTSession(BTSession), selected_filter(QString::null){ setupUi(this); setAttribute(Qt::WA_DeleteOnClose); Q_ASSERT(!feed_name.isEmpty()); diff --git a/src/httpconnection.cpp b/src/httpconnection.cpp index 912e86208..c2a5c480f 100644 --- a/src/httpconnection.cpp +++ b/src/httpconnection.cpp @@ -43,7 +43,7 @@ #include #include -HttpConnection::HttpConnection(QTcpSocket *socket, bittorrent *BTSession, HttpServer *parent) +HttpConnection::HttpConnection(QTcpSocket *socket, Bittorrent *BTSession, HttpServer *parent) : QObject(parent), socket(socket), parent(parent), BTSession(BTSession) { socket->setParent(this); diff --git a/src/httpconnection.h b/src/httpconnection.h index d14122591..5054f1e15 100644 --- a/src/httpconnection.h +++ b/src/httpconnection.h @@ -38,7 +38,7 @@ class QTcpSocket; class HttpServer; -class bittorrent; +class Bittorrent; class HttpConnection : public QObject { @@ -46,7 +46,7 @@ class HttpConnection : public QObject private: QTcpSocket *socket; HttpServer *parent; - bittorrent *BTSession; + Bittorrent *BTSession; protected: HttpRequestParser parser; @@ -64,7 +64,7 @@ class HttpConnection : public QObject void recheckAllTorrents(); public: - HttpConnection(QTcpSocket *socket, bittorrent* BTSession, HttpServer *parent); + HttpConnection(QTcpSocket *socket, Bittorrent* BTSession, HttpServer *parent); ~HttpConnection(); private slots: diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 54e7bfa15..375787149 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -35,7 +35,7 @@ #include "bittorrent.h" #include -HttpServer::HttpServer(bittorrent *_BTSession, int msec, QObject* parent) : QTcpServer(parent) +HttpServer::HttpServer(Bittorrent *_BTSession, int msec, QObject* parent) : QTcpServer(parent) { base64 = QByteArray(":").toBase64(); connect(this, SIGNAL(newConnection()), this, SLOT(newHttpConnection())); diff --git a/src/httpserver.h b/src/httpserver.h index b23a753cc..922824288 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -36,7 +36,7 @@ #include #include -class bittorrent; +class Bittorrent; class QTimer; class EventManager; @@ -46,12 +46,12 @@ class HttpServer : public QTcpServer private: QByteArray base64; - bittorrent *BTSession; + Bittorrent *BTSession; EventManager *manager; QTimer *timer; public: - HttpServer(bittorrent *BTSession, int msec, QObject* parent = 0); + HttpServer(Bittorrent *BTSession, int msec, QObject* parent = 0); ~HttpServer(); void setAuthorization(QString username, QString password); bool isAuthorized(QByteArray auth) const; diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index 019bb8996..256e9873f 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -57,7 +57,7 @@ #define SELECTED_BUTTON_CSS "QPushButton {border: 1px solid rgb(85, 81, 91);border-radius: 3px;padding: 2px;background-color: rgb(255, 208, 105); margin-left: 3px; margin-right: 3px;}" #endif -PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession): QWidget(parent), transferList(transferList), BTSession(BTSession) { +PropertiesWidget::PropertiesWidget(QWidget *parent, TransferListWidget *transferList, Bittorrent* BTSession): QWidget(parent), transferList(transferList), BTSession(BTSession) { setupUi(this); state = VISIBLE; @@ -184,7 +184,7 @@ const QTorrentHandle& PropertiesWidget::getCurrentTorrent() const { return h; } -bittorrent* PropertiesWidget::getBTSession() const { +Bittorrent* PropertiesWidget::getBTSession() const { return BTSession; } diff --git a/src/propertieswidget.h b/src/propertieswidget.h index 781422974..fb40a6e05 100644 --- a/src/propertieswidget.h +++ b/src/propertieswidget.h @@ -40,7 +40,7 @@ class TransferListWidget; class QTimer; class RealProgressBar; class RealProgressBarThread; -class bittorrent; +class Bittorrent; class TorrentFilesModel; class PropListDelegate; class QAction; @@ -60,7 +60,7 @@ private: QTimer *refreshTimer; RealProgressBar *progressBar; RealProgressBarThread *progressBarUpdater; - bittorrent* BTSession; + Bittorrent* BTSession; SlideState state; TorrentFilesModel *PropListModel; PropListDelegate *PropDelegate; @@ -105,10 +105,10 @@ public slots: void reloadPreferences(); public: - PropertiesWidget(QWidget *parent, TransferListWidget *transferList, bittorrent* BTSession); + PropertiesWidget(QWidget *parent, TransferListWidget *transferList, Bittorrent* BTSession); ~PropertiesWidget(); const QTorrentHandle& getCurrentTorrent() const; - bittorrent* getBTSession() const; + Bittorrent* getBTSession() const; }; #endif // PROPERTIESWIDGET_H diff --git a/src/rss.cpp b/src/rss.cpp index 235451955..89420c54a 100644 --- a/src/rss.cpp +++ b/src/rss.cpp @@ -34,7 +34,7 @@ /** RssFolder **/ -RssFolder::RssFolder(RssFolder *parent, RssManager *rssmanager, bittorrent *BTSession, QString name): parent(parent), rssmanager(rssmanager), BTSession(BTSession), name(name) { +RssFolder::RssFolder(RssFolder *parent, RssManager *rssmanager, Bittorrent *BTSession, QString name): parent(parent), rssmanager(rssmanager), BTSession(BTSession), name(name) { downloader = new downloadThread(this); connect(downloader, SIGNAL(downloadFinished(QString, QString)), this, SLOT(processFinishedDownload(QString, QString))); connect(downloader, SIGNAL(downloadFailure(QString, QString)), this, SLOT(handleDownloadFailure(QString, QString))); @@ -277,7 +277,7 @@ void RssFolder::addFile(RssFile * item) { /** RssManager **/ -RssManager::RssManager(bittorrent *BTSession): RssFolder(0, this, BTSession, QString::null) { +RssManager::RssManager(Bittorrent *BTSession): RssFolder(0, this, BTSession, QString::null) { loadStreamList(); connect(&newsRefresher, SIGNAL(timeout()), this, SLOT(refreshAll())); QSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent")); @@ -368,7 +368,7 @@ void RssManager::saveStreamList(){ /** RssStream **/ -RssStream::RssStream(RssFolder* parent, RssManager *rssmanager, bittorrent *BTSession, QString _url): parent(parent), rssmanager(rssmanager), BTSession(BTSession), alias(""), iconPath(":/Icons/rss16.png"), refreshed(false), downloadFailure(false), currently_loading(false) { +RssStream::RssStream(RssFolder* parent, RssManager *rssmanager, Bittorrent *BTSession, QString _url): parent(parent), rssmanager(rssmanager), BTSession(BTSession), alias(""), iconPath(":/Icons/rss16.png"), refreshed(false), downloadFailure(false), currently_loading(false) { has_attachments = false; qDebug("RSSStream constructed"); QSettings qBTRSS("qBittorrent", "qBittorrent-rss"); diff --git a/src/rss.h b/src/rss.h index b12c3a1fc..1d54782df 100644 --- a/src/rss.h +++ b/src/rss.h @@ -372,7 +372,7 @@ class RssStream: public RssFile, public QHash { private: RssFolder *parent; RssManager *rssmanager; - bittorrent *BTSession; + Bittorrent *BTSession; QString title; QString link; QString description; @@ -392,7 +392,7 @@ public slots: void setDownloadFailed(); public: - RssStream(RssFolder* parent, RssManager *rssmanager, bittorrent *BTSession, QString _url); + RssStream(RssFolder* parent, RssManager *rssmanager, Bittorrent *BTSession, QString _url); ~RssStream(); RssFolder* getParent() const { return parent; } void setParent(RssFolder* _parent) { parent = _parent; } @@ -436,11 +436,11 @@ private: RssFolder *parent; RssManager *rssmanager; downloadThread *downloader; - bittorrent *BTSession; + Bittorrent *BTSession; QString name; public: - RssFolder(RssFolder *parent, RssManager *rssmanager, bittorrent *BTSession, QString name); + RssFolder(RssFolder *parent, RssManager *rssmanager, Bittorrent *BTSession, QString name); ~RssFolder(); RssFolder* getParent() const { return parent; } void setParent(RssFolder* _parent) { parent = _parent; } @@ -476,7 +476,7 @@ class RssManager: public RssFolder{ private: QTimer newsRefresher; unsigned int refreshInterval; - bittorrent *BTSession; + Bittorrent *BTSession; signals: void feedInfosChanged(QString url, QString aliasOrUrl, unsigned int nbUnread); @@ -491,7 +491,7 @@ public slots: void updateRefreshInterval(unsigned int val); public: - RssManager(bittorrent *BTSession); + RssManager(Bittorrent *BTSession); ~RssManager(); static void insertSortElem(QList &list, RssItem *item) { int i = 0; diff --git a/src/rss_imp.cpp b/src/rss_imp.cpp index 8bd2c0c66..ede039c53 100644 --- a/src/rss_imp.cpp +++ b/src/rss_imp.cpp @@ -565,7 +565,7 @@ void RSSImp::updateRefreshInterval(unsigned int val) { rssmanager->updateRefreshInterval(val); } -RSSImp::RSSImp(bittorrent *BTSession) : QWidget(), BTSession(BTSession){ +RSSImp::RSSImp(Bittorrent *BTSession) : QWidget(), BTSession(BTSession){ setupUi(this); rssmanager = new RssManager(BTSession); diff --git a/src/rss_imp.h b/src/rss_imp.h index ee5a830a7..3873d11a3 100644 --- a/src/rss_imp.h +++ b/src/rss_imp.h @@ -37,7 +37,7 @@ #include "ui_rss.h" #include "rss.h" -class bittorrent; +class Bittorrent; class FeedList; class QTreeWidgetItem; @@ -46,7 +46,7 @@ class RSSImp : public QWidget, public Ui::RSS{ private: RssManager *rssmanager; - bittorrent *BTSession; + Bittorrent *BTSession; FeedList *listStreams; QTreeWidgetItem* previous_news; @@ -81,7 +81,7 @@ protected slots: void displayOverwriteError(QString filename); public: - RSSImp(bittorrent *BTSession); + RSSImp(Bittorrent *BTSession); ~RSSImp(); }; diff --git a/src/searchengine.cpp b/src/searchengine.cpp index 152f2184f..9ad24cefc 100644 --- a/src/searchengine.cpp +++ b/src/searchengine.cpp @@ -53,7 +53,7 @@ #define SEARCHHISTORY_MAXSIZE 50 /*SEARCH ENGINE START*/ -SearchEngine::SearchEngine(bittorrent *BTSession, QSystemTrayIcon *systrayIcon) : QWidget(), BTSession(BTSession), systrayIcon(systrayIcon) { +SearchEngine::SearchEngine(Bittorrent *BTSession, QSystemTrayIcon *systrayIcon) : QWidget(), BTSession(BTSession), systrayIcon(systrayIcon) { setupUi(this); // new qCompleter to the search pattern startSearchHistory(); diff --git a/src/searchengine.h b/src/searchengine.h index 01c050007..1af8be3ba 100644 --- a/src/searchengine.h +++ b/src/searchengine.h @@ -43,7 +43,7 @@ #include "searchtab.h" #include "supportedengines.h" -class bittorrent; +class Bittorrent; class QSystemTrayIcon; class downloadThread; class QTimer; @@ -62,7 +62,7 @@ private: unsigned long nb_search_results; QPointer searchCompleter; QStringListModel searchHistory; - bittorrent *BTSession; + Bittorrent *BTSession; QSystemTrayIcon *systrayIcon; SupportedEngines *supported_engines; QTimer *searchTimeout; @@ -71,7 +71,7 @@ private: QList all_tab; // To store all tabs const SearchCategories full_cat_names; public: - SearchEngine(bittorrent *BTSession, QSystemTrayIcon *systrayIcon); + SearchEngine(Bittorrent *BTSession, QSystemTrayIcon *systrayIcon); ~SearchEngine(); float getPluginVersion(QString filePath) const; QString selectedCategory() const; diff --git a/src/statusbar.h b/src/statusbar.h index 2cbb41e69..1aad73b8d 100644 --- a/src/statusbar.h +++ b/src/statusbar.h @@ -58,10 +58,10 @@ private: QTimer *refreshTimer; QWidget *container; QGridLayout *layout; - bittorrent *BTSession; + Bittorrent *BTSession; public: - StatusBar(QStatusBar *bar, bittorrent *BTSession): bar(bar), BTSession(BTSession) { + StatusBar(QStatusBar *bar, Bittorrent *BTSession): bar(bar), BTSession(BTSession) { container = new QWidget(); layout = new QGridLayout(container); layout->setVerticalSpacing(0); diff --git a/src/torrentadditiondlg.h b/src/torrentadditiondlg.h index 7ebcfb6d8..42f606d98 100644 --- a/src/torrentadditiondlg.h +++ b/src/torrentadditiondlg.h @@ -55,7 +55,7 @@ class torrentAdditionDialog : public QDialog, private Ui_addTorrentDialog{ Q_OBJECT private: - bittorrent *BTSession; + Bittorrent *BTSession; QString fileName; QString hash; QString filePath; @@ -66,7 +66,7 @@ private: boost::intrusive_ptr t; public: - torrentAdditionDialog(QWidget *parent, bittorrent* _BTSession) : QDialog(parent) { + torrentAdditionDialog(QWidget *parent, Bittorrent* _BTSession) : QDialog(parent) { setupUi(this); setAttribute(Qt::WA_DeleteOnClose); BTSession = _BTSession; diff --git a/src/transferlistwidget.cpp b/src/transferlistwidget.cpp index ca578ca04..7c287a8a7 100644 --- a/src/transferlistwidget.cpp +++ b/src/transferlistwidget.cpp @@ -48,7 +48,7 @@ #include #include -TransferListWidget::TransferListWidget(QWidget *parent, bittorrent *_BTSession): QTreeView(parent) { +TransferListWidget::TransferListWidget(QWidget *parent, Bittorrent *_BTSession): QTreeView(parent) { QSettings settings("qBittorrent", "qBittorrent"); BTSession = _BTSession; diff --git a/src/transferlistwidget.h b/src/transferlistwidget.h index 0b009782f..0823a298d 100644 --- a/src/transferlistwidget.h +++ b/src/transferlistwidget.h @@ -36,7 +36,7 @@ class QStandardItemModel; class QSortFilterProxyModel; -class bittorrent; +class Bittorrent; class QTimer; class TransferListDelegate; @@ -49,11 +49,11 @@ private: TransferListDelegate *listDelegate; QStandardItemModel *listModel; QSortFilterProxyModel *proxyModel; - bittorrent* BTSession; + Bittorrent* BTSession; QTimer *refreshTimer; public: - TransferListWidget(QWidget *parent, bittorrent* BTSession); + TransferListWidget(QWidget *parent, Bittorrent* BTSession); ~TransferListWidget(); protected: