mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -05:00
display session traffic
This commit is contained in:
parent
c19919962d
commit
7504964899
@ -192,7 +192,7 @@ class NetInterface;
|
||||
class PQInterface: public RateInterface
|
||||
{
|
||||
public:
|
||||
explicit PQInterface(const RsPeerId &id) :peerId(id) { return; }
|
||||
explicit PQInterface(const RsPeerId &id) :peerId(id), traf_in(0), traf_out(0) { return; }
|
||||
virtual ~PQInterface() { return; }
|
||||
|
||||
/*!
|
||||
@ -234,6 +234,22 @@ class PQInterface: public RateInterface
|
||||
const sockaddr_storage & /*remote_peer_address*/)
|
||||
{ return 0; }
|
||||
|
||||
virtual uint64_t getTraffic(bool in)
|
||||
{
|
||||
uint64_t ret = 0;
|
||||
if (in)
|
||||
{
|
||||
ret = traf_in;
|
||||
traf_in = 0;
|
||||
return ret;
|
||||
}
|
||||
ret = traf_out;
|
||||
traf_out = 0;
|
||||
return ret;
|
||||
}
|
||||
uint64_t traf_in;
|
||||
uint64_t traf_out;
|
||||
|
||||
private:
|
||||
|
||||
RsPeerId peerId;
|
||||
|
@ -87,6 +87,8 @@ pqihandler::pqihandler() : coreMtx("pqihandler")
|
||||
rateMax_in = 0.01;
|
||||
rateTotal_in = 0.0 ;
|
||||
rateTotal_out = 0.0 ;
|
||||
traffInSum = 0;
|
||||
traffOutSum = 0;
|
||||
last_m = time(NULL) ;
|
||||
nb_ticks = 0 ;
|
||||
mLastRateCapUpdate = 0 ;
|
||||
@ -375,6 +377,9 @@ int pqihandler::UpdateRates()
|
||||
{
|
||||
SearchModule *mod = (it -> second);
|
||||
float crate_in = mod -> pqi -> getRate(true);
|
||||
|
||||
traffInSum += mod -> pqi -> getTraffic(true);
|
||||
traffOutSum += mod -> pqi -> getTraffic(false);
|
||||
|
||||
#ifdef PQI_HDL_DEBUG_UR
|
||||
if(crate_in > 0.0)
|
||||
@ -544,4 +549,8 @@ void pqihandler::locked_StoreCurrentRates(float in, float out)
|
||||
rateTotal_out = out;
|
||||
}
|
||||
|
||||
|
||||
void pqihandler::GetTraffic(uint64_t &in, uint64_t &out)
|
||||
{
|
||||
in = traffInSum;
|
||||
out = traffOutSum;
|
||||
}
|
||||
|
@ -91,6 +91,10 @@ class pqihandler: public P3Interface, public pqiPublisher
|
||||
int ExtractRates(std::map<RsPeerId, RsBwRates> &ratemap, RsBwRates &totals);
|
||||
int ExtractTrafficInfo(std::list<RSTrafficClue> &out_lst, std::list<RSTrafficClue> &in_lst);
|
||||
|
||||
uint64_t traffInSum;
|
||||
uint64_t traffOutSum;
|
||||
void GetTraffic(uint64_t &in, uint64_t &out);
|
||||
|
||||
protected:
|
||||
/* check to be overloaded by those that can
|
||||
* generates warnings otherwise
|
||||
|
@ -647,6 +647,13 @@ float pqiperson::getRate(bool in)
|
||||
return activepqi -> getRate(in);
|
||||
}
|
||||
|
||||
uint64_t pqiperson::getTraffic(bool in)
|
||||
{
|
||||
if ((!active) || (activepqi == NULL))
|
||||
return 0;
|
||||
return activepqi -> getTraffic(in);
|
||||
}
|
||||
|
||||
void pqiperson::setMaxRate(bool in, float val)
|
||||
{
|
||||
RS_STACK_MUTEX(mPersonMtx);
|
||||
|
@ -149,6 +149,7 @@ public:
|
||||
virtual int getQueueSize(bool in);
|
||||
virtual void getRates(RsBwRates &rates);
|
||||
virtual float getRate(bool in);
|
||||
virtual uint64_t getTraffic(bool in);
|
||||
virtual void setMaxRate(bool in, float val);
|
||||
virtual void setRateCap(float val_in, float val_out);
|
||||
virtual int gatherStatistics(std::list<RSTrafficClue>& outqueue_lst,
|
||||
|
@ -221,6 +221,7 @@ float pqistreamer::getRate(bool b)
|
||||
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||
return RateInterface::getRate(b) ;
|
||||
}
|
||||
|
||||
void pqistreamer::setMaxRate(bool b,float f)
|
||||
{
|
||||
RsStackMutex stack(mStreamerMtx); /**** LOCKED MUTEX ****/
|
||||
@ -1231,7 +1232,7 @@ void pqistreamer::outSentBytes_locked(uint32_t outb)
|
||||
mTotalSent += outb;
|
||||
mCurrSent += outb;
|
||||
mAvgSentCount += outb;
|
||||
|
||||
PQInterface::traf_out += outb;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1248,7 +1249,7 @@ void pqistreamer::inReadBytes_locked(uint32_t inb)
|
||||
mTotalRead += inb;
|
||||
mCurrRead += inb;
|
||||
mAvgReadCount += inb;
|
||||
|
||||
PQInterface::traf_in += inb;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -564,4 +564,8 @@ int p3ServerConfig::GetCurrentDataRates( float &inKb, float &outKb )
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
int p3ServerConfig::GetTrafficSum(uint64_t &inb, uint64_t &outb )
|
||||
{
|
||||
mPqiHandler->GetTraffic(inb, outb);
|
||||
return 1;
|
||||
}
|
||||
|
@ -96,6 +96,7 @@ virtual bool setOperatingMode(const std::string &opModeStr);
|
||||
virtual int SetMaxDataRates( int downKb, int upKb );
|
||||
virtual int GetMaxDataRates( int &downKb, int &upKb );
|
||||
virtual int GetCurrentDataRates( float &inKb, float &outKb );
|
||||
virtual int GetTrafficSum( uint64_t &inb, uint64_t &outb );
|
||||
|
||||
/********************* ABOVE is RsConfig Interface *******/
|
||||
|
||||
|
@ -726,9 +726,12 @@ void MainWindow::updateStatus()
|
||||
float downKb = 0;
|
||||
float upKb = 0;
|
||||
rsConfig->GetCurrentDataRates(downKb, upKb);
|
||||
uint64_t down = 0;
|
||||
uint64_t up = 0;
|
||||
rsConfig->GetTrafficSum(down, up);
|
||||
|
||||
if (ratesstatus)
|
||||
ratesstatus->getRatesStatus(downKb, upKb);
|
||||
ratesstatus->getRatesStatus(downKb, down, upKb, up);
|
||||
|
||||
if(torstatus)
|
||||
torstatus->getTorStatus();
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "ratesstatus.h"
|
||||
#include <retroshare/rsiface.h>
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
@ -48,13 +49,13 @@ RatesStatus::RatesStatus(QWidget *parent)
|
||||
setLayout(hbox);
|
||||
}
|
||||
|
||||
void RatesStatus::getRatesStatus(float downKb, float upKb)
|
||||
void RatesStatus::getRatesStatus(float downKb, uint64_t down, float upKb, uint64_t upl)
|
||||
{
|
||||
/* set users/friends/network */
|
||||
|
||||
QString normalText = QString("<strong>%1:</strong> %2 (kB/s) | <strong>%3:</strong> %4 (kB/s) ")
|
||||
.arg(tr("Down")).arg(downKb, 0, 'f', 2)
|
||||
.arg(tr("Up")).arg(upKb, 0, 'f', 2);
|
||||
QString normalText = QString("<strong>%1:</strong> %2 kB/s (%3) | <strong>%4:</strong> %5 kB/s (%6)")
|
||||
.arg(tr("Down")).arg(downKb, 0, 'f', 2).arg(misc::friendlyUnit(down))
|
||||
.arg(tr("Up")).arg(upKb, 0, 'f', 2).arg(misc::friendlyUnit(upl));
|
||||
QString compactText = QString("%1|%2").arg(downKb, 0, 'f', 2).arg(upKb, 0, 'f', 2);
|
||||
|
||||
if (statusRates) {
|
||||
|
@ -32,7 +32,7 @@ class RatesStatus : public QWidget
|
||||
public:
|
||||
RatesStatus(QWidget *parent = 0);
|
||||
|
||||
void getRatesStatus(float downKb, float upKb);
|
||||
void getRatesStatus(float downKb, uint64_t down, float upKb, uint64_t upl);
|
||||
void setCompactMode(bool compact) {_compactMode = compact; }
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user