Browse Source

Use cached SessionStatus and CacheStatus

adaptive-webui-19844
Vladimir Golovnev (Glassez) 8 years ago
parent
commit
8a6d8f3953
  1. 2
      src/base/base.pri
  2. 69
      src/base/bittorrent/cachestatus.cpp
  3. 21
      src/base/bittorrent/cachestatus.h
  4. 10
      src/base/bittorrent/private/statistics.cpp
  5. 54
      src/base/bittorrent/session.cpp
  6. 17
      src/base/bittorrent/session.h
  7. 136
      src/base/bittorrent/sessionstatus.cpp
  8. 55
      src/base/bittorrent/sessionstatus.h
  9. 14
      src/gui/mainwindow.cpp
  10. 25
      src/gui/properties/speedwidget.cpp
  11. 34
      src/gui/statsdialog.cpp
  12. 2
      src/gui/statsdialog.h
  13. 39
      src/gui/statusbar.cpp
  14. 19
      src/gui/statusbar.h
  15. 34
      src/webui/btjson.cpp

2
src/base/base.pri

@ -89,8 +89,6 @@ SOURCES += \
$$PWD/net/private/geoipdatabase.cpp \ $$PWD/net/private/geoipdatabase.cpp \
$$PWD/bittorrent/infohash.cpp \ $$PWD/bittorrent/infohash.cpp \
$$PWD/bittorrent/session.cpp \ $$PWD/bittorrent/session.cpp \
$$PWD/bittorrent/sessionstatus.cpp \
$$PWD/bittorrent/cachestatus.cpp \
$$PWD/bittorrent/magneturi.cpp \ $$PWD/bittorrent/magneturi.cpp \
$$PWD/bittorrent/torrentinfo.cpp \ $$PWD/bittorrent/torrentinfo.cpp \
$$PWD/bittorrent/torrenthandle.cpp \ $$PWD/bittorrent/torrenthandle.cpp \

69
src/base/bittorrent/cachestatus.cpp

@ -1,69 +0,0 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#include <libtorrent/version.hpp>
#include "cachestatus.h"
using namespace BitTorrent;
CacheStatus::CacheStatus(const libtorrent::cache_status &nativeStatus)
: m_nativeStatus(nativeStatus)
{
}
int CacheStatus::totalUsedBuffers() const
{
return m_nativeStatus.total_used_buffers;
}
qreal CacheStatus::readRatio() const
{
if (m_nativeStatus.blocks_read > 0)
return (static_cast<qreal>(m_nativeStatus.blocks_read_hit) / m_nativeStatus.blocks_read);
else
return -1;
}
int CacheStatus::jobQueueLength() const
{
#if LIBTORRENT_VERSION_NUM < 10100
return m_nativeStatus.job_queue_length;
#else
return m_nativeStatus.queued_jobs;
#endif
}
int CacheStatus::averageJobTime() const
{
return m_nativeStatus.average_job_time;
}
qlonglong CacheStatus::queuedBytes() const
{
return m_nativeStatus.queued_bytes;
}

21
src/base/bittorrent/cachestatus.h

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru> * Copyright (C) 2015, 2017 Vladimir Golovnev <glassez@yandex.ru>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -30,23 +30,16 @@
#define BITTORRENT_CACHESTATUS_H #define BITTORRENT_CACHESTATUS_H
#include <QtGlobal> #include <QtGlobal>
#include <libtorrent/disk_io_thread.hpp>
namespace BitTorrent namespace BitTorrent
{ {
class CacheStatus struct CacheStatus
{ {
public: quint64 totalUsedBuffers = 0;
CacheStatus(const libtorrent::cache_status &nativeStatus); quint64 jobQueueLength = 0;
quint64 averageJobTime = 0;
int totalUsedBuffers() const; quint64 queuedBytes = 0;
qreal readRatio() const; qreal readRatio = 0.0;
int jobQueueLength() const;
int averageJobTime() const;
qlonglong queuedBytes() const;
private:
libtorrent::cache_status m_nativeStatus;
}; };
} }

10
src/base/bittorrent/private/statistics.cpp

@ -45,13 +45,13 @@ quint64 Statistics::getAlltimeUL() const
void Statistics::gather() void Statistics::gather()
{ {
SessionStatus ss = m_session->status(); const SessionStatus &ss = m_session->status();
if (ss.totalDownload() > m_sessionDL) { if (ss.totalDownload > m_sessionDL) {
m_sessionDL = ss.totalDownload(); m_sessionDL = ss.totalDownload;
m_dirty = true; m_dirty = true;
} }
if (ss.totalUpload() > m_sessionUL) { if (ss.totalUpload > m_sessionUL) {
m_sessionUL = ss.totalUpload(); m_sessionUL = ss.totalUpload;
m_dirty = true; m_dirty = true;
} }

54
src/base/bittorrent/session.cpp

@ -52,6 +52,7 @@
#include <libtorrent/bdecode.hpp> #include <libtorrent/bdecode.hpp>
#endif #endif
#include <libtorrent/bencode.hpp> #include <libtorrent/bencode.hpp>
#include <libtorrent/disk_io_thread.hpp>
#include <libtorrent/error_code.hpp> #include <libtorrent/error_code.hpp>
#include <libtorrent/extensions/ut_metadata.hpp> #include <libtorrent/extensions/ut_metadata.hpp>
#include <libtorrent/extensions/ut_pex.hpp> #include <libtorrent/extensions/ut_pex.hpp>
@ -63,6 +64,7 @@
#endif #endif
#include <libtorrent/magnet_uri.hpp> #include <libtorrent/magnet_uri.hpp>
#include <libtorrent/session.hpp> #include <libtorrent/session.hpp>
#include <libtorrent/session_status.hpp>
#include <libtorrent/torrent_info.hpp> #include <libtorrent/torrent_info.hpp>
#include "base/logger.h" #include "base/logger.h"
@ -79,13 +81,11 @@
#include "base/utils/fs.h" #include "base/utils/fs.h"
#include "base/utils/random.h" #include "base/utils/random.h"
#include "base/utils/string.h" #include "base/utils/string.h"
#include "cachestatus.h"
#include "magneturi.h" #include "magneturi.h"
#include "private/filterparserthread.h" #include "private/filterparserthread.h"
#include "private/statistics.h" #include "private/statistics.h"
#include "private/bandwidthscheduler.h" #include "private/bandwidthscheduler.h"
#include "private/resumedatasavingmanager.h" #include "private/resumedatasavingmanager.h"
#include "sessionstatus.h"
#include "torrenthandle.h" #include "torrenthandle.h"
#include "tracker.h" #include "tracker.h"
#include "trackerentry.h" #include "trackerentry.h"
@ -3088,14 +3088,14 @@ void Session::recursiveTorrentDownload(const InfoHash &hash)
} }
} }
SessionStatus Session::status() const const SessionStatus &Session::status() const
{ {
return m_nativeSession->status(); return m_status;
} }
CacheStatus Session::cacheStatus() const const CacheStatus &Session::cacheStatus() const
{ {
return m_nativeSession->get_cache_status(); return m_cacheStatus;
} }
// Will resume torrents in backup directory // Will resume torrents in backup directory
@ -3581,8 +3581,50 @@ void Session::handleExternalIPAlert(libt::external_ip_alert *p)
Logger::instance()->addMessage(tr("External IP: %1", "e.g. External IP: 192.168.0.1").arg(p->external_address.to_string(ec).c_str()), Log::INFO); Logger::instance()->addMessage(tr("External IP: %1", "e.g. External IP: 192.168.0.1").arg(p->external_address.to_string(ec).c_str()), Log::INFO);
} }
void Session::updateStats()
{
libt::session_status ss = m_nativeSession->status();
m_status.hasIncomingConnections = ss.has_incoming_connections;
m_status.payloadDownloadRate = ss.payload_download_rate;
m_status.payloadUploadRate = ss.payload_upload_rate;
m_status.downloadRate = ss.download_rate;
m_status.uploadRate = ss.upload_rate;
m_status.ipOverheadDownloadRate = ss.ip_overhead_download_rate;
m_status.ipOverheadUploadRate = ss.ip_overhead_upload_rate;
m_status.dhtDownloadRate = ss.dht_download_rate;
m_status.dhtUploadRate = ss.dht_upload_rate;
m_status.trackerDownloadRate = ss.tracker_download_rate;
m_status.trackerUploadRate = ss.tracker_upload_rate;
m_status.totalDownload = ss.total_download;
m_status.totalUpload = ss.total_upload;
m_status.totalPayloadDownload = ss.total_payload_download;
m_status.totalPayloadUpload = ss.total_payload_upload;
m_status.totalWasted = ss.total_redundant_bytes + ss.total_failed_bytes;
m_status.diskReadQueue = ss.disk_read_queue;
m_status.diskWriteQueue = ss.disk_write_queue;
m_status.dhtNodes = ss.dht_nodes;
m_status.peersCount = ss.num_peers;
libt::cache_status cs = m_nativeSession->get_cache_status();
m_cacheStatus.totalUsedBuffers = cs.total_used_buffers;
m_cacheStatus.readRatio = cs.blocks_read > 0
? static_cast<qreal>(cs.blocks_read_hit) / cs.blocks_read
: -1;
#if LIBTORRENT_VERSION_NUM < 10100
m_cacheStatus.jobQueueLength = cs.job_queue_length;
#else
m_cacheStatus.jobQueueLength = cs.queued_jobs;
#endif
m_cacheStatus.averageJobTime = cs.average_job_time;
m_cacheStatus.queuedBytes = cs.queued_bytes;
emit statsUpdated();
}
void Session::handleStateUpdateAlert(libt::state_update_alert *p) void Session::handleStateUpdateAlert(libt::state_update_alert *p)
{ {
updateStats();
foreach (const libt::torrent_status &status, p->status) { foreach (const libt::torrent_status &status, p->status) {
TorrentHandle *const torrent = m_torrents.value(status.info_hash); TorrentHandle *const torrent = m_torrents.value(status.info_hash);
if (torrent) if (torrent)

17
src/base/bittorrent/session.h

@ -49,6 +49,8 @@
#include "base/tristatebool.h" #include "base/tristatebool.h"
#include "base/types.h" #include "base/types.h"
#include "addtorrentparams.h" #include "addtorrentparams.h"
#include "cachestatus.h"
#include "sessionstatus.h"
#include "torrentinfo.h" #include "torrentinfo.h"
namespace libtorrent namespace libtorrent
@ -56,15 +58,12 @@ namespace libtorrent
class session; class session;
struct torrent_handle; struct torrent_handle;
class entry; class entry;
struct add_torrent_params;
struct ip_filter; struct ip_filter;
struct pe_settings;
#if LIBTORRENT_VERSION_NUM < 10100 #if LIBTORRENT_VERSION_NUM < 10100
struct session_settings; struct session_settings;
#else #else
struct settings_pack; struct settings_pack;
#endif #endif
struct session_status;
class alert; class alert;
struct torrent_alert; struct torrent_alert;
@ -127,8 +126,6 @@ enum TorrentExportFolder
namespace BitTorrent namespace BitTorrent
{ {
class InfoHash; class InfoHash;
class CacheStatus;
class SessionStatus;
class TorrentHandle; class TorrentHandle;
class Tracker; class Tracker;
class MagnetUri; class MagnetUri;
@ -324,8 +321,8 @@ namespace BitTorrent
TorrentStatusReport torrentStatusReport() const; TorrentStatusReport torrentStatusReport() const;
bool hasActiveTorrents() const; bool hasActiveTorrents() const;
bool hasUnfinishedTorrents() const; bool hasUnfinishedTorrents() const;
SessionStatus status() const; const SessionStatus &status() const;
CacheStatus cacheStatus() const; const CacheStatus &cacheStatus() const;
quint64 getAlltimeDL() const; quint64 getAlltimeDL() const;
quint64 getAlltimeUL() const; quint64 getAlltimeUL() const;
bool isListening() const; bool isListening() const;
@ -371,6 +368,7 @@ namespace BitTorrent
void handleTorrentTrackerAuthenticationRequired(TorrentHandle *const torrent, const QString &trackerUrl); void handleTorrentTrackerAuthenticationRequired(TorrentHandle *const torrent, const QString &trackerUrl);
signals: signals:
void statsUpdated();
void torrentsUpdated(); void torrentsUpdated();
void addTorrentFailed(const QString &error); void addTorrentFailed(const QString &error);
void torrentAdded(BitTorrent::TorrentHandle *const torrent); void torrentAdded(BitTorrent::TorrentHandle *const torrent);
@ -485,6 +483,8 @@ namespace BitTorrent
#endif #endif
void getPendingAlerts(std::vector<libtorrent::alert *> &out, ulong time = 0); void getPendingAlerts(std::vector<libtorrent::alert *> &out, ulong time = 0);
void updateStats();
// BitTorrent // BitTorrent
libtorrent::session *m_nativeSession; libtorrent::session *m_nativeSession;
@ -600,6 +600,9 @@ namespace BitTorrent
std::vector<libtorrent::alert *> m_alerts; std::vector<libtorrent::alert *> m_alerts;
#endif #endif
SessionStatus m_status;
CacheStatus m_cacheStatus;
QNetworkConfigurationManager m_networkManager; QNetworkConfigurationManager m_networkManager;
static Session *m_instance; static Session *m_instance;

136
src/base/bittorrent/sessionstatus.cpp

@ -1,136 +0,0 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#include "sessionstatus.h"
using namespace BitTorrent;
SessionStatus::SessionStatus(const libtorrent::session_status &nativeStatus)
: m_nativeStatus(nativeStatus)
{
}
bool SessionStatus::hasIncomingConnections() const
{
return m_nativeStatus.has_incoming_connections;
}
int SessionStatus::payloadDownloadRate() const
{
return m_nativeStatus.payload_download_rate;
}
int SessionStatus::payloadUploadRate() const
{
return m_nativeStatus.payload_upload_rate;
}
int SessionStatus::downloadRate() const
{
return m_nativeStatus.download_rate;
}
int SessionStatus::uploadRate() const
{
return m_nativeStatus.upload_rate;
}
int SessionStatus::ipOverheadDownloadRate() const
{
return m_nativeStatus.ip_overhead_download_rate;
}
int SessionStatus::ipOverheadUploadRate() const
{
return m_nativeStatus.ip_overhead_upload_rate;
}
int SessionStatus::dhtDownloadRate() const
{
return m_nativeStatus.dht_download_rate;
}
int SessionStatus::dhtUploadRate() const
{
return m_nativeStatus.dht_upload_rate;
}
int SessionStatus::trackerDownloadRate() const
{
return m_nativeStatus.tracker_download_rate;
}
int SessionStatus::trackerUploadRate() const
{
return m_nativeStatus.tracker_upload_rate;
}
qlonglong SessionStatus::totalDownload() const
{
return m_nativeStatus.total_download;
}
qlonglong SessionStatus::totalUpload() const
{
return m_nativeStatus.total_upload;
}
qlonglong SessionStatus::totalPayloadDownload() const
{
return m_nativeStatus.total_payload_download;
}
qlonglong SessionStatus::totalPayloadUpload() const
{
return m_nativeStatus.total_payload_upload;
}
qlonglong SessionStatus::totalWasted() const
{
return (m_nativeStatus.total_redundant_bytes + m_nativeStatus.total_failed_bytes);
}
int SessionStatus::diskReadQueue() const
{
return m_nativeStatus.disk_read_queue;
}
int SessionStatus::diskWriteQueue() const
{
return m_nativeStatus.disk_write_queue;
}
int SessionStatus::dhtNodes() const
{
return m_nativeStatus.dht_nodes;
}
int SessionStatus::peersCount() const
{
return m_nativeStatus.num_peers;
}

55
src/base/bittorrent/sessionstatus.h

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2015 Vladimir Golovnev <glassez@yandex.ru> * Copyright (C) 2015, 2017 Vladimir Golovnev <glassez@yandex.ru>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -29,50 +29,43 @@
#ifndef BITTORRENT_SESSIONSTATUS_H #ifndef BITTORRENT_SESSIONSTATUS_H
#define BITTORRENT_SESSIONSTATUS_H #define BITTORRENT_SESSIONSTATUS_H
#include <libtorrent/session_status.hpp>
#include <QtGlobal> #include <QtGlobal>
namespace BitTorrent namespace BitTorrent
{ {
class SessionStatus struct SessionStatus
{ {
public: bool hasIncomingConnections = false;
SessionStatus(const libtorrent::session_status &nativeStatus);
bool hasIncomingConnections() const; // Current download rate for the BT
// Return current download rate for the BT
// session. Payload means that it only take into // session. Payload means that it only take into
// account "useful" part of the rate // account "useful" part of the rate
int payloadDownloadRate() const; quint64 payloadDownloadRate = 0;
// Return current upload rate for the BT // Current upload rate for the BT
// session. Payload means that it only take into // session. Payload means that it only take into
// account "useful" part of the rate // account "useful" part of the rate
int payloadUploadRate() const; quint64 payloadUploadRate = 0;
// Additional download/upload rates // Additional download/upload rates
int uploadRate() const; quint64 uploadRate = 0;
int downloadRate() const; quint64 downloadRate = 0;
int ipOverheadUploadRate() const; quint64 ipOverheadUploadRate = 0;
int ipOverheadDownloadRate() const; quint64 ipOverheadDownloadRate = 0;
int dhtUploadRate() const; quint64 dhtUploadRate = 0;
int dhtDownloadRate() const; quint64 dhtDownloadRate = 0;
int trackerUploadRate() const; quint64 trackerUploadRate = 0;
int trackerDownloadRate() const; quint64 trackerDownloadRate = 0;
qlonglong totalDownload() const;
qlonglong totalUpload() const;
qlonglong totalPayloadDownload() const;
qlonglong totalPayloadUpload() const;
qlonglong totalWasted() const;
int diskReadQueue() const;
int diskWriteQueue() const;
int dhtNodes() const;
int peersCount() const;
private: quint64 totalDownload = 0;
libtorrent::session_status m_nativeStatus; quint64 totalUpload = 0;
quint64 totalPayloadDownload = 0;
quint64 totalPayloadUpload = 0;
quint64 totalWasted = 0;
quint64 diskReadQueue = 0;
quint64 diskWriteQueue = 0;
quint64 dhtNodes = 0;
quint64 peersCount = 0;
}; };
} }

14
src/gui/mainwindow.cpp

@ -1319,7 +1319,7 @@ void MainWindow::trackerAuthenticationRequired(BitTorrent::TorrentHandle *const
// Check connection status and display right icon // Check connection status and display right icon
void MainWindow::updateGUI() void MainWindow::updateGUI()
{ {
BitTorrent::SessionStatus status = BitTorrent::Session::instance()->status(); const BitTorrent::SessionStatus &status = BitTorrent::Session::instance()->status();
// update global informations // update global informations
if (m_systrayIcon) { if (m_systrayIcon) {
@ -1328,24 +1328,24 @@ void MainWindow::updateGUI()
html += "qBittorrent"; html += "qBittorrent";
html += "</div>"; html += "</div>";
html += "<div style='vertical-align: baseline; height: 18px;'>"; html += "<div style='vertical-align: baseline; height: 18px;'>";
html += "<img src=':/icons/skin/download.png' height='14'/>&nbsp;" + tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate(), true)); html += "<img src=':/icons/skin/download.png' height='14'/>&nbsp;" + tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true));
html += "</div>"; html += "</div>";
html += "<div style='vertical-align: baseline; height: 18px;'>"; html += "<div style='vertical-align: baseline; height: 18px;'>";
html += "<img src=':/icons/skin/seeding.png' height='14'/>&nbsp;" + tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate(), true)); html += "<img src=':/icons/skin/seeding.png' height='14'/>&nbsp;" + tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true));
html += "</div>"; html += "</div>";
#else #else
// OSes such as Windows do not support html here // OSes such as Windows do not support html here
QString html = tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate(), true)); QString html = tr("DL speed: %1", "e.g: Download speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true));
html += "\n"; html += "\n";
html += tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate(), true)); html += tr("UP speed: %1", "e.g: Upload speed: 10 KiB/s").arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true));
#endif #endif
m_systrayIcon->setToolTip(html); // tray icon m_systrayIcon->setToolTip(html); // tray icon
} }
if (m_displaySpeedInTitle) { if (m_displaySpeedInTitle) {
setWindowTitle(tr("[D: %1, U: %2] qBittorrent %3", "D = Download; U = Upload; %3 is qBittorrent version") setWindowTitle(tr("[D: %1, U: %2] qBittorrent %3", "D = Download; U = Upload; %3 is qBittorrent version")
.arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate(), true)) .arg(Utils::Misc::friendlyUnit(status.payloadDownloadRate, true))
.arg(Utils::Misc::friendlyUnit(status.payloadUploadRate(), true)) .arg(Utils::Misc::friendlyUnit(status.payloadUploadRate, true))
.arg(QBT_VERSION)); .arg(QBT_VERSION));
} }
} }

25
src/gui/properties/speedwidget.cpp

@ -45,7 +45,8 @@
ComboBoxMenuButton::ComboBoxMenuButton(QWidget *parent, QMenu *menu) ComboBoxMenuButton::ComboBoxMenuButton(QWidget *parent, QMenu *menu)
: QComboBox(parent) : QComboBox(parent)
, m_menu(menu) , m_menu(menu)
{} {
}
void ComboBoxMenuButton::showPopup() void ComboBoxMenuButton::showPopup()
{ {
@ -134,20 +135,20 @@ void SpeedWidget::update()
{ {
while (m_isUpdating) { while (m_isUpdating) {
BitTorrent::SessionStatus btStatus = BitTorrent::Session::instance()->status(); const BitTorrent::SessionStatus &btStatus = BitTorrent::Session::instance()->status();
SpeedPlotView::PointData point; SpeedPlotView::PointData point;
point.x = QDateTime::currentDateTime().toTime_t(); point.x = QDateTime::currentDateTime().toTime_t();
point.y[SpeedPlotView::UP] = btStatus.uploadRate(); point.y[SpeedPlotView::UP] = btStatus.uploadRate;
point.y[SpeedPlotView::DOWN] = btStatus.downloadRate(); point.y[SpeedPlotView::DOWN] = btStatus.downloadRate;
point.y[SpeedPlotView::PAYLOAD_UP] = btStatus.payloadUploadRate(); point.y[SpeedPlotView::PAYLOAD_UP] = btStatus.payloadUploadRate;
point.y[SpeedPlotView::PAYLOAD_DOWN] = btStatus.payloadDownloadRate(); point.y[SpeedPlotView::PAYLOAD_DOWN] = btStatus.payloadDownloadRate;
point.y[SpeedPlotView::OVERHEAD_UP] = btStatus.ipOverheadUploadRate(); point.y[SpeedPlotView::OVERHEAD_UP] = btStatus.ipOverheadUploadRate;
point.y[SpeedPlotView::OVERHEAD_DOWN] = btStatus.ipOverheadDownloadRate(); point.y[SpeedPlotView::OVERHEAD_DOWN] = btStatus.ipOverheadDownloadRate;
point.y[SpeedPlotView::DHT_UP] = btStatus.dhtUploadRate(); point.y[SpeedPlotView::DHT_UP] = btStatus.dhtUploadRate;
point.y[SpeedPlotView::DHT_DOWN] = btStatus.dhtDownloadRate(); point.y[SpeedPlotView::DHT_DOWN] = btStatus.dhtDownloadRate;
point.y[SpeedPlotView::TRACKER_UP] = btStatus.trackerUploadRate(); point.y[SpeedPlotView::TRACKER_UP] = btStatus.trackerUploadRate;
point.y[SpeedPlotView::TRACKER_DOWN] = btStatus.trackerDownloadRate(); point.y[SpeedPlotView::TRACKER_DOWN] = btStatus.trackerDownloadRate;
m_plot->pushPoint(point); m_plot->pushPoint(point);

34
src/gui/statsdialog.cpp

@ -45,25 +45,21 @@ StatsDialog::StatsDialog(QWidget *parent)
connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &StatsDialog::close); connect(m_ui->buttonBox, &QDialogButtonBox::accepted, this, &StatsDialog::close);
update(); update();
m_timer = new QTimer(this); connect(BitTorrent::Session::instance(), &BitTorrent::Session::statsUpdated
m_timer->setInterval(1500); , this, &StatsDialog::update);
connect(m_timer, &QTimer::timeout, this, &StatsDialog::update);
m_timer->start();
show(); show();
} }
StatsDialog::~StatsDialog() StatsDialog::~StatsDialog()
{ {
m_timer->stop();
delete m_timer;
delete m_ui; delete m_ui;
} }
void StatsDialog::update() void StatsDialog::update()
{ {
BitTorrent::SessionStatus ss = BitTorrent::Session::instance()->status(); const BitTorrent::SessionStatus &ss = BitTorrent::Session::instance()->status();
BitTorrent::CacheStatus cs = BitTorrent::Session::instance()->cacheStatus(); const BitTorrent::CacheStatus &cs = BitTorrent::Session::instance()->cacheStatus();
// Alltime DL/UL // Alltime DL/UL
quint64 atd = BitTorrent::Session::instance()->getAlltimeDL(); quint64 atd = BitTorrent::Session::instance()->getAlltimeDL();
@ -71,17 +67,17 @@ void StatsDialog::update()
m_ui->labelAlltimeDL->setText(Utils::Misc::friendlyUnit(atd)); m_ui->labelAlltimeDL->setText(Utils::Misc::friendlyUnit(atd));
m_ui->labelAlltimeUL->setText(Utils::Misc::friendlyUnit(atu)); m_ui->labelAlltimeUL->setText(Utils::Misc::friendlyUnit(atu));
// Total waste (this session) // Total waste (this session)
m_ui->labelWaste->setText(Utils::Misc::friendlyUnit(ss.totalWasted())); m_ui->labelWaste->setText(Utils::Misc::friendlyUnit(ss.totalWasted));
// Global ratio // Global ratio
m_ui->labelGlobalRatio->setText( m_ui->labelGlobalRatio->setText(
((atd > 0) && (atu > 0)) ((atd > 0) && (atu > 0))
? Utils::String::fromDouble((qreal)atu / (qreal)atd, 2) ? Utils::String::fromDouble((qreal)atu / (qreal)atd, 2)
: "-"); : "-");
// Cache hits // Cache hits
qreal readRatio = cs.readRatio(); qreal readRatio = cs.readRatio;
m_ui->labelCacheHits->setText((readRatio >= 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "-"); m_ui->labelCacheHits->setText((readRatio >= 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "-");
// Buffers size // Buffers size
m_ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers() * 16 * 1024)); m_ui->labelTotalBuf->setText(Utils::Misc::friendlyUnit(cs.totalUsedBuffers * 16 * 1024));
// Disk overload (100%) equivalent // Disk overload (100%) equivalent
// From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read // From lt manual: disk_write_queue and disk_read_queue are the number of peers currently waiting on a disk write or disk read
// to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are. // to complete before it receives or sends any more data on the socket. It's a metric of how disk bound you are.
@ -92,18 +88,18 @@ void StatsDialog::update()
peers += torrent->peersCount(); peers += torrent->peersCount();
m_ui->labelWriteStarve->setText(QString("%1%") m_ui->labelWriteStarve->setText(QString("%1%")
.arg(((ss.diskWriteQueue() > 0) && (peers > 0)) .arg(((ss.diskWriteQueue > 0) && (peers > 0))
? Utils::String::fromDouble((100. * ss.diskWriteQueue()) / peers, 2) ? Utils::String::fromDouble((100. * ss.diskWriteQueue) / peers, 2)
: "0")); : "0"));
m_ui->labelReadStarve->setText(QString("%1%") m_ui->labelReadStarve->setText(QString("%1%")
.arg(((ss.diskReadQueue() > 0) && (peers > 0)) .arg(((ss.diskReadQueue > 0) && (peers > 0))
? Utils::String::fromDouble((100. * ss.diskReadQueue()) / peers, 2) ? Utils::String::fromDouble((100. * ss.diskReadQueue) / peers, 2)
: "0")); : "0"));
// Disk queues // Disk queues
m_ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength())); m_ui->labelQueuedJobs->setText(QString::number(cs.jobQueueLength));
m_ui->labelJobsTime->setText(tr("%1 ms", "18 milliseconds").arg(cs.averageJobTime())); m_ui->labelJobsTime->setText(tr("%1 ms", "18 milliseconds").arg(cs.averageJobTime));
m_ui->labelQueuedBytes->setText(Utils::Misc::friendlyUnit(cs.queuedBytes())); m_ui->labelQueuedBytes->setText(Utils::Misc::friendlyUnit(cs.queuedBytes));
// Total connected peers // Total connected peers
m_ui->labelPeers->setText(QString::number(ss.peersCount())); m_ui->labelPeers->setText(QString::number(ss.peersCount));
} }

2
src/gui/statsdialog.h

@ -30,7 +30,6 @@
#define STATSDIALOG_H #define STATSDIALOG_H
#include <QDialog> #include <QDialog>
#include <QTimer>
namespace Ui namespace Ui
{ {
@ -50,7 +49,6 @@ private slots:
private: private:
Ui::StatsDialog *m_ui; Ui::StatsDialog *m_ui;
QTimer *m_timer;
}; };
#endif // STATSDIALOG_H #endif // STATSDIALOG_H

39
src/gui/statusbar.cpp

@ -34,7 +34,6 @@
#include <QStatusBar> #include <QStatusBar>
#include <QFrame> #include <QFrame>
#include <QLabel> #include <QLabel>
#include <QTimer>
#include <QPushButton> #include <QPushButton>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QFontMetrics> #include <QFontMetrics>
@ -135,10 +134,9 @@ StatusBar::StatusBar(QStatusBar *bar)
bar->adjustSize(); bar->adjustSize();
// Is DHT enabled // Is DHT enabled
m_DHTLbl->setVisible(session->isDHTEnabled()); m_DHTLbl->setVisible(session->isDHTEnabled());
m_refreshTimer = new QTimer(bar);
refreshStatusBar(); refreshStatusBar();
connect(m_refreshTimer, SIGNAL(timeout()), this, SLOT(refreshStatusBar())); connect(BitTorrent::Session::instance(), &BitTorrent::Session::statsUpdated
m_refreshTimer->start(1500); , this, &StatusBar::refreshStatusBar);
} }
StatusBar::~StatusBar() StatusBar::~StatusBar()
@ -167,19 +165,16 @@ void StatusBar::showRestartRequired()
Logger::instance()->addMessage(tr("qBittorrent was just updated and needs to be restarted for the changes to be effective."), Log::CRITICAL); Logger::instance()->addMessage(tr("qBittorrent was just updated and needs to be restarted for the changes to be effective."), Log::CRITICAL);
} }
void StatusBar::stopTimer() void StatusBar::updateConnectionStatus()
{ {
m_refreshTimer->stop(); const BitTorrent::SessionStatus &sessionStatus = BitTorrent::Session::instance()->status();
}
void StatusBar::updateConnectionStatus(const BitTorrent::SessionStatus &sessionStatus)
{
if (!BitTorrent::Session::instance()->isListening()) { if (!BitTorrent::Session::instance()->isListening()) {
m_connecStatusLblIcon->setIcon(QIcon(QLatin1String(":/icons/skin/disconnected.png"))); m_connecStatusLblIcon->setIcon(QIcon(QLatin1String(":/icons/skin/disconnected.png")));
m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection Status:") + QLatin1String("</b><br>") + tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections.")); m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection Status:") + QLatin1String("</b><br>") + tr("Offline. This usually means that qBittorrent failed to listen on the selected port for incoming connections."));
} }
else { else {
if (sessionStatus.hasIncomingConnections()) { if (sessionStatus.hasIncomingConnections) {
// Connection OK // Connection OK
m_connecStatusLblIcon->setIcon(QIcon(QLatin1String(":/icons/skin/connected.png"))); m_connecStatusLblIcon->setIcon(QIcon(QLatin1String(":/icons/skin/connected.png")));
m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection Status:") + QLatin1String("</b><br>") + tr("Online")); m_connecStatusLblIcon->setToolTip(QLatin1String("<b>") + tr("Connection Status:") + QLatin1String("</b><br>") + tr("Online"));
@ -191,39 +186,41 @@ void StatusBar::updateConnectionStatus(const BitTorrent::SessionStatus &sessionS
} }
} }
void StatusBar::updateDHTNodesNumber(const BitTorrent::SessionStatus &sessionStatus) void StatusBar::updateDHTNodesNumber()
{ {
if (BitTorrent::Session::instance()->isDHTEnabled()) { if (BitTorrent::Session::instance()->isDHTEnabled()) {
m_DHTLbl->setVisible(true); m_DHTLbl->setVisible(true);
m_DHTLbl->setText(tr("DHT: %1 nodes").arg(QString::number(sessionStatus.dhtNodes()))); m_DHTLbl->setText(tr("DHT: %1 nodes")
.arg(QString::number(BitTorrent::Session::instance()->status().dhtNodes)));
} }
else { else {
m_DHTLbl->setVisible(false); m_DHTLbl->setVisible(false);
} }
} }
void StatusBar::updateSpeedLabels(const BitTorrent::SessionStatus &sessionStatus) void StatusBar::updateSpeedLabels()
{ {
QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate(), true); const BitTorrent::SessionStatus &sessionStatus = BitTorrent::Session::instance()->status();
QString speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadDownloadRate, true);
int speedLimit = BitTorrent::Session::instance()->downloadSpeedLimit(); int speedLimit = BitTorrent::Session::instance()->downloadSpeedLimit();
if (speedLimit) if (speedLimit)
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]"; speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]";
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload()) + ")"; speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadDownload) + ")";
m_dlSpeedLbl->setText(speedLbl); m_dlSpeedLbl->setText(speedLbl);
speedLimit = BitTorrent::Session::instance()->uploadSpeedLimit(); speedLimit = BitTorrent::Session::instance()->uploadSpeedLimit();
speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate(), true); speedLbl = Utils::Misc::friendlyUnit(sessionStatus.payloadUploadRate, true);
if (speedLimit) if (speedLimit)
speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]"; speedLbl += " [" + Utils::Misc::friendlyUnit(speedLimit, true) + "]";
speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload()) + ")"; speedLbl += " (" + Utils::Misc::friendlyUnit(sessionStatus.totalPayloadUpload) + ")";
m_upSpeedLbl->setText(speedLbl); m_upSpeedLbl->setText(speedLbl);
} }
void StatusBar::refreshStatusBar() void StatusBar::refreshStatusBar()
{ {
const BitTorrent::SessionStatus sessionStatus = BitTorrent::Session::instance()->status(); updateConnectionStatus();
updateConnectionStatus(sessionStatus); updateDHTNodesNumber();
updateDHTNodesNumber(sessionStatus); updateSpeedLabels();
updateSpeedLabels(sessionStatus);
} }
void StatusBar::updateAltSpeedsBtn(bool alternative) void StatusBar::updateAltSpeedsBtn(bool alternative)

19
src/gui/statusbar.h

@ -1,6 +1,6 @@
/* /*
* Bittorrent Client using Qt4 and libtorrent. * Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2006 Christophe Dumez * Copyright (C) 2006 Christophe Dumez <chris@qbittorrent.org>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -24,8 +24,6 @@
* modify file(s), you may extend this exception to your version of the file(s), * modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this * but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version. * exception statement from your version.
*
* Contact : chris@qbittorrent.org
*/ */
#ifndef STATUSBAR_H #ifndef STATUSBAR_H
@ -36,13 +34,12 @@
class QStatusBar; class QStatusBar;
class QFrame; class QFrame;
class QLabel; class QLabel;
class QTimer;
class QPushButton; class QPushButton;
class QHBoxLayout; class QHBoxLayout;
namespace BitTorrent namespace BitTorrent
{ {
class SessionStatus; struct SessionStatus;
} }
class StatusBar: public QObject class StatusBar: public QObject
@ -57,7 +54,6 @@ public:
public slots: public slots:
void showRestartRequired(); void showRestartRequired();
void stopTimer();
void refreshStatusBar(); void refreshStatusBar();
void updateAltSpeedsBtn(bool alternative); void updateAltSpeedsBtn(bool alternative);
void toggleAlternativeSpeeds(); void toggleAlternativeSpeeds();
@ -65,6 +61,10 @@ public slots:
void capUploadSpeed(); void capUploadSpeed();
private: private:
void updateConnectionStatus();
void updateDHTNodesNumber();
void updateSpeedLabels();
QStatusBar *m_bar; QStatusBar *m_bar;
QPushButton *m_dlSpeedLbl; QPushButton *m_dlSpeedLbl;
QPushButton *m_upSpeedLbl; QPushButton *m_upSpeedLbl;
@ -75,13 +75,8 @@ private:
QFrame *m_statusSep4; QFrame *m_statusSep4;
QPushButton *m_connecStatusLblIcon; QPushButton *m_connecStatusLblIcon;
QPushButton *m_altSpeedsBtn; QPushButton *m_altSpeedsBtn;
QTimer *m_refreshTimer;
QWidget *m_container; QWidget *m_container;
QHBoxLayout *m_layout; QHBoxLayout *m_layout;
void updateConnectionStatus(const BitTorrent::SessionStatus &sessionStatus);
void updateDHTNodesNumber(const BitTorrent::SessionStatus &sessionStatus);
void updateSpeedLabels(const BitTorrent::SessionStatus &sessionStatus);
}; };
#endif // STATUSBAR_H #endif // STATUSBAR_H

34
src/webui/btjson.cpp

@ -676,12 +676,12 @@ QByteArray btjson::getTransferInfo()
QVariantMap getTranserInfoMap() QVariantMap getTranserInfoMap()
{ {
QVariantMap map; QVariantMap map;
BitTorrent::SessionStatus sessionStatus = BitTorrent::Session::instance()->status(); const BitTorrent::SessionStatus &sessionStatus = BitTorrent::Session::instance()->status();
BitTorrent::CacheStatus cacheStatus = BitTorrent::Session::instance()->cacheStatus(); const BitTorrent::CacheStatus &cacheStatus = BitTorrent::Session::instance()->cacheStatus();
map[KEY_TRANSFER_DLSPEED] = sessionStatus.payloadDownloadRate(); map[KEY_TRANSFER_DLSPEED] = sessionStatus.payloadDownloadRate;
map[KEY_TRANSFER_DLDATA] = sessionStatus.totalPayloadDownload(); map[KEY_TRANSFER_DLDATA] = sessionStatus.totalPayloadDownload;
map[KEY_TRANSFER_UPSPEED] = sessionStatus.payloadUploadRate(); map[KEY_TRANSFER_UPSPEED] = sessionStatus.payloadUploadRate;
map[KEY_TRANSFER_UPDATA] = sessionStatus.totalPayloadUpload(); map[KEY_TRANSFER_UPDATA] = sessionStatus.totalPayloadUpload;
map[KEY_TRANSFER_DLRATELIMIT] = BitTorrent::Session::instance()->downloadSpeedLimit(); map[KEY_TRANSFER_DLRATELIMIT] = BitTorrent::Session::instance()->downloadSpeedLimit();
map[KEY_TRANSFER_UPRATELIMIT] = BitTorrent::Session::instance()->uploadSpeedLimit(); map[KEY_TRANSFER_UPRATELIMIT] = BitTorrent::Session::instance()->uploadSpeedLimit();
@ -689,30 +689,30 @@ QVariantMap getTranserInfoMap()
quint64 atu = BitTorrent::Session::instance()->getAlltimeUL(); quint64 atu = BitTorrent::Session::instance()->getAlltimeUL();
map[KEY_TRANSFER_ALLTIME_DL] = atd; map[KEY_TRANSFER_ALLTIME_DL] = atd;
map[KEY_TRANSFER_ALLTIME_UL] = atu; map[KEY_TRANSFER_ALLTIME_UL] = atu;
map[KEY_TRANSFER_TOTAL_WASTE_SESSION] = sessionStatus.totalWasted(); map[KEY_TRANSFER_TOTAL_WASTE_SESSION] = sessionStatus.totalWasted;
map[KEY_TRANSFER_GLOBAL_RATIO] = ( atd > 0 && atu > 0 ) ? Utils::String::fromDouble((qreal)atu / (qreal)atd, 2) : "-"; map[KEY_TRANSFER_GLOBAL_RATIO] = ( atd > 0 && atu > 0 ) ? Utils::String::fromDouble((qreal)atu / (qreal)atd, 2) : "-";
map[KEY_TRANSFER_TOTAL_PEER_CONNECTIONS] = sessionStatus.peersCount(); map[KEY_TRANSFER_TOTAL_PEER_CONNECTIONS] = sessionStatus.peersCount;
qreal readRatio = cacheStatus.readRatio(); qreal readRatio = cacheStatus.readRatio;
map[KEY_TRANSFER_READ_CACHE_HITS] = (readRatio >= 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "-"; map[KEY_TRANSFER_READ_CACHE_HITS] = (readRatio >= 0) ? Utils::String::fromDouble(100 * readRatio, 2) : "-";
map[KEY_TRANSFER_TOTAL_BUFFERS_SIZE] = cacheStatus.totalUsedBuffers() * 16 * 1024; map[KEY_TRANSFER_TOTAL_BUFFERS_SIZE] = cacheStatus.totalUsedBuffers * 16 * 1024;
// num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake) // num_peers is not reliable (adds up peers, which didn't even overcome tcp handshake)
quint32 peers = 0; quint32 peers = 0;
foreach (BitTorrent::TorrentHandle *const torrent, BitTorrent::Session::instance()->torrents()) foreach (BitTorrent::TorrentHandle *const torrent, BitTorrent::Session::instance()->torrents())
peers += torrent->peersCount(); peers += torrent->peersCount();
map[KEY_TRANSFER_WRITE_CACHE_OVERLOAD] = ((sessionStatus.diskWriteQueue() > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskWriteQueue()) / peers, 2) : "0"; map[KEY_TRANSFER_WRITE_CACHE_OVERLOAD] = ((sessionStatus.diskWriteQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskWriteQueue) / peers, 2) : "0";
map[KEY_TRANSFER_READ_CACHE_OVERLOAD] = ((sessionStatus.diskReadQueue() > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskReadQueue()) / peers, 2) : "0"; map[KEY_TRANSFER_READ_CACHE_OVERLOAD] = ((sessionStatus.diskReadQueue > 0) && (peers > 0)) ? Utils::String::fromDouble((100. * sessionStatus.diskReadQueue) / peers, 2) : "0";
map[KEY_TRANSFER_QUEUED_IO_JOBS] = cacheStatus.jobQueueLength(); map[KEY_TRANSFER_QUEUED_IO_JOBS] = cacheStatus.jobQueueLength;
map[KEY_TRANSFER_AVERAGE_TIME_QUEUE] = cacheStatus.averageJobTime(); map[KEY_TRANSFER_AVERAGE_TIME_QUEUE] = cacheStatus.averageJobTime;
map[KEY_TRANSFER_TOTAL_QUEUED_SIZE] = cacheStatus.queuedBytes(); map[KEY_TRANSFER_TOTAL_QUEUED_SIZE] = cacheStatus.queuedBytes;
map[KEY_TRANSFER_DHT_NODES] = sessionStatus.dhtNodes(); map[KEY_TRANSFER_DHT_NODES] = sessionStatus.dhtNodes;
if (!BitTorrent::Session::instance()->isListening()) if (!BitTorrent::Session::instance()->isListening())
map[KEY_TRANSFER_CONNECTION_STATUS] = "disconnected"; map[KEY_TRANSFER_CONNECTION_STATUS] = "disconnected";
else else
map[KEY_TRANSFER_CONNECTION_STATUS] = sessionStatus.hasIncomingConnections() ? "connected" : "firewalled"; map[KEY_TRANSFER_CONNECTION_STATUS] = sessionStatus.hasIncomingConnections ? "connected" : "firewalled";
return map; return map;
} }

Loading…
Cancel
Save