mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-29 01:16:20 -05:00
Merge pull request #1509 from RetroPooh/trafcount
display session traffic
This commit is contained in:
commit
43a5312194
@ -186,7 +186,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; }
|
||||
|
||||
/*!
|
||||
@ -228,6 +228,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;
|
||||
|
@ -83,6 +83,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 ;
|
||||
@ -371,6 +373,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)
|
||||
@ -540,4 +545,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;
|
||||
}
|
||||
|
@ -87,6 +87,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
|
||||
|
@ -637,6 +637,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);
|
||||
|
@ -143,6 +143,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,
|
||||
|
@ -216,6 +216,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 ****/
|
||||
@ -1226,7 +1227,7 @@ void pqistreamer::outSentBytes_locked(uint32_t outb)
|
||||
mTotalSent += outb;
|
||||
mCurrSent += outb;
|
||||
mAvgSentCount += outb;
|
||||
|
||||
PQInterface::traf_out += outb;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1243,7 +1244,7 @@ void pqistreamer::inReadBytes_locked(uint32_t inb)
|
||||
mTotalRead += inb;
|
||||
mCurrRead += inb;
|
||||
mAvgReadCount += inb;
|
||||
|
||||
PQInterface::traf_in += inb;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -409,6 +409,7 @@ public:
|
||||
* @return returns 1 on succes and 0 otherwise
|
||||
*/
|
||||
virtual int GetCurrentDataRates( float &inKb, float &outKb ) = 0;
|
||||
virtual int GetTrafficSum( uint64_t &inb, uint64_t &outb ) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -560,4 +560,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;
|
||||
}
|
||||
|
@ -91,6 +91,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 *******/
|
||||
|
||||
|
@ -730,9 +730,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();
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include "ratesstatus.h"
|
||||
#include <retroshare/rsiface.h>
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
@ -47,13 +48,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