From ee5dcd1a8cab55cee7841190a9e88011f7b55f63 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 19 Feb 2012 15:03:07 +0000 Subject: [PATCH] - moved RsAutoUpdatePage into retroshare-gui/ directory, to allow plugins to use it - removed VOIP code from main executable. Moved it into VOIP plugin (c.f next commit) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4963 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/libretroshare.pro | 11 - libretroshare/src/retroshare/rsvoip.h | 63 --- libretroshare/src/rsserver/rsinit.cc | 9 +- libretroshare/src/serialiser/rsvoipitems.cc | 373 -------------- libretroshare/src/serialiser/rsvoipitems.h | 108 ---- libretroshare/src/services/p3vors.cc | 487 ------------------ libretroshare/src/services/p3vors.h | 126 ----- retroshare-gui/src/RetroShare.pro | 9 +- retroshare-gui/src/gui/FriendsDialog.h | 4 +- retroshare-gui/src/gui/GetStartedDialog.cpp | 2 +- retroshare-gui/src/gui/RemoteDirModel.cpp | 2 +- retroshare-gui/src/gui/SearchDialog.cpp | 2 +- retroshare-gui/src/gui/TrustView.h | 2 +- retroshare-gui/src/gui/VoipStatistics.cpp | 393 -------------- retroshare-gui/src/gui/VoipStatistics.h | 68 --- retroshare-gui/src/gui/VoipStatistics.ui | 55 -- retroshare-gui/src/gui/bwgraph/bwgraph.cpp | 2 +- retroshare-gui/src/gui/common/FriendList.cpp | 2 +- retroshare-gui/src/gui/common/FriendList.h | 2 +- retroshare-gui/src/gui/dht/DhtWindow.cpp | 2 +- retroshare-gui/src/gui/feeds/ChatMsgItem.cpp | 2 +- retroshare-gui/src/gui/feeds/PeerItem.cpp | 2 +- retroshare-gui/src/gui/feeds/SecurityItem.cpp | 2 +- retroshare-gui/src/gui/mainpagestack.h | 2 +- .../RsAutoUpdatePage.h | 0 .../src/{gui => retroshare-gui}/mainpage.h | 0 26 files changed, 18 insertions(+), 1712 deletions(-) delete mode 100644 libretroshare/src/retroshare/rsvoip.h delete mode 100644 libretroshare/src/serialiser/rsvoipitems.cc delete mode 100644 libretroshare/src/serialiser/rsvoipitems.h delete mode 100644 libretroshare/src/services/p3vors.cc delete mode 100644 libretroshare/src/services/p3vors.h delete mode 100644 retroshare-gui/src/gui/VoipStatistics.cpp delete mode 100644 retroshare-gui/src/gui/VoipStatistics.h delete mode 100644 retroshare-gui/src/gui/VoipStatistics.ui rename retroshare-gui/src/{gui => retroshare-gui}/RsAutoUpdatePage.h (100%) rename retroshare-gui/src/{gui => retroshare-gui}/mainpage.h (100%) diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 994514cee..8bf3450d9 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -630,17 +630,6 @@ SOURCES += util/folderiterator.cc \ util/pgpkey.cc \ util/pugixml.cc - -# VOIP TEST STUFF -HEADERS += retroshare/rsvoip.h \ - serialiser/rsvoipitems.h \ - services/p3vors.h - -SOURCES += serialiser/rsvoipitems.cc \ - services/p3vors.cc - - - minimal { SOURCES -= rsserver/p3msgs.cc \ rsserver/p3status.cc \ diff --git a/libretroshare/src/retroshare/rsvoip.h b/libretroshare/src/retroshare/rsvoip.h deleted file mode 100644 index 2ee7b3b01..000000000 --- a/libretroshare/src/retroshare/rsvoip.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef RETROSHARE_VOIP_INTERFACE_H -#define RETROSHARE_VOIP_INTERFACE_H - -/* - * libretroshare/src/retroshare: rsvoip.h - * - * RetroShare C++ Interface. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - -#include -#include -#include - -/* The Main Interface Class - for information about your Peers */ -class RsVoip; -extern RsVoip *rsVoip; - - -class RsVoipPongResult -{ - public: - RsVoipPongResult() - :mTS(0), mRTT(0), mOffset(0) { return; } - - RsVoipPongResult(double ts, double rtt, double offset) - :mTS(ts), mRTT(rtt), mOffset(offset) { return; } - - double mTS; - double mRTT; - double mOffset; -}; - -class RsVoip -{ - public: - - RsVoip() { return; } -virtual ~RsVoip() { return; } - -virtual uint32_t getPongResults(std::string id, int n, std::list &results) = 0; - -}; - -#endif diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 7a15ab023..fe4a2a441 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1818,16 +1818,9 @@ RsTurtle *rsTurtle = NULL ; /**** * #define RS_RELEASE 1 - * #define RS_VOIPTEST 1 ****/ #define RS_RELEASE 1 -#define RS_VOIPTEST 1 - - -#ifdef RS_VOIPTEST -#include "services/p3vors.h" -#endif #include "services/p3banlist.h" #include "services/p3dsdv.h" @@ -2152,7 +2145,7 @@ int RsServer::StartupRetroShare() // mPluginsManager->setCacheDirectories(localcachedir,remotecachedir) ; mPluginsManager->setFileServer(ftserver) ; - mPluginsManager->setLinkMgr(mLinkMgr) ; + mPluginsManager->setLinkMgr(mLinkMgr) ; // Now load the plugins. This parses the available SO/DLL files for known symbols. // diff --git a/libretroshare/src/serialiser/rsvoipitems.cc b/libretroshare/src/serialiser/rsvoipitems.cc deleted file mode 100644 index 258afbe81..000000000 --- a/libretroshare/src/serialiser/rsvoipitems.cc +++ /dev/null @@ -1,373 +0,0 @@ - -/* - * libretroshare/src/serialiser: rsvoipitems.cc - * - * RetroShare Serialiser. - * - * Copyright 2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - -#include "serialiser/rsbaseserial.h" -#include "serialiser/rsvoipitems.h" -#include "serialiser/rstlvbase.h" - -/*** -#define RSSERIAL_DEBUG 1 -***/ - -#include - -/*************************************************************************/ - - -RsVoipPingItem::~RsVoipPingItem() -{ - return; -} - -void RsVoipPingItem::clear() -{ - mSeqNo = 0; - mPingTS = 0; -} - -std::ostream& RsVoipPingItem::print(std::ostream &out, uint16_t indent) -{ - printRsItemBase(out, "RsVoipPingItem", indent); - uint16_t int_Indent = indent + 2; - printIndent(out, int_Indent); - out << "SeqNo: " << mSeqNo << std::endl; - - printIndent(out, int_Indent); - out << "PingTS: " << std::hex << mPingTS << std::dec << std::endl; - - printRsItemEnd(out, "RsVoipPingItem", indent); - return out; -} - - - - - -RsVoipPongItem::~RsVoipPongItem() -{ - return; -} - -void RsVoipPongItem::clear() -{ - mSeqNo = 0; - mPingTS = 0; - mPongTS = 0; -} - - -std::ostream& RsVoipPongItem::print(std::ostream &out, uint16_t indent) -{ - printRsItemBase(out, "RsVoipPongItem", indent); - uint16_t int_Indent = indent + 2; - printIndent(out, int_Indent); - out << "SeqNo: " << mSeqNo << std::endl; - - printIndent(out, int_Indent); - out << "PingTS: " << std::hex << mPingTS << std::dec << std::endl; - - printIndent(out, int_Indent); - out << "PongTS: " << std::hex << mPongTS << std::dec << std::endl; - - printRsItemEnd(out, "RsVoipPongItem", indent); - return out; -} - - -/*************************************************************************/ - - -uint32_t RsVoipSerialiser::sizeVoipPingItem(RsVoipPingItem */*item*/) -{ - uint32_t s = 8; /* header */ - s += 4; /* seqno */ - s += 8; /* pingTS */ - - return s; -} - -/* serialise the data to the buffer */ -bool RsVoipSerialiser::serialiseVoipPingItem(RsVoipPingItem *item, void *data, uint32_t *pktsize) -{ - uint32_t tlvsize = sizeVoipPingItem(item); - uint32_t offset = 0; - - if (*pktsize < tlvsize) - return false; /* not enough space */ - - *pktsize = tlvsize; - - bool ok = true; - - ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize); - -#ifdef RSSERIAL_DEBUG - std::cerr << "RsVoipSerialiser::serialiseVoipPingItem() Header: " << ok << std::endl; - std::cerr << "RsVoipSerialiser::serialiseVoipPingItem() Size: " << tlvsize << std::endl; -#endif - - /* skip the header */ - offset += 8; - - /* add mandatory parts first */ - ok &= setRawUInt32(data, tlvsize, &offset, item->mSeqNo); - ok &= setRawUInt64(data, tlvsize, &offset, item->mPingTS); - - if (offset != tlvsize) - { - ok = false; - std::cerr << "RsVoipSerialiser::serialiseVoipPingItem() Size Error! " << std::endl; - } - - return ok; -} - -RsVoipPingItem *RsVoipSerialiser::deserialiseVoipPingItem(void *data, uint32_t *pktsize) -{ - /* get the type and size */ - uint32_t rstype = getRsItemId(data); - uint32_t rssize = getRsItemSize(data); - - uint32_t offset = 0; - - - if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || - (RS_SERVICE_TYPE_VOIP != getRsItemService(rstype)) || - (RS_PKT_SUBTYPE_VOIP_PING != getRsItemSubType(rstype))) - { - return NULL; /* wrong type */ - } - - if (*pktsize < rssize) /* check size */ - return NULL; /* not enough data */ - - /* set the packet length */ - *pktsize = rssize; - - bool ok = true; - - /* ready to load */ - RsVoipPingItem *item = new RsVoipPingItem(); - item->clear(); - - /* skip the header */ - offset += 8; - - /* get mandatory parts first */ - ok &= getRawUInt32(data, rssize, &offset, &(item->mSeqNo)); - ok &= getRawUInt64(data, rssize, &offset, &(item->mPingTS)); - - if (offset != rssize) - { - /* error */ - delete item; - return NULL; - } - - if (!ok) - { - delete item; - return NULL; - } - - return item; -} - -/*************************************************************************/ -/*************************************************************************/ - - -uint32_t RsVoipSerialiser::sizeVoipPongItem(RsVoipPongItem */*item*/) -{ - uint32_t s = 8; /* header */ - s += 4; /* seqno */ - s += 8; /* pingTS */ - s += 8; /* pongTS */ - - return s; -} - -/* serialise the data to the buffer */ -bool RsVoipSerialiser::serialiseVoipPongItem(RsVoipPongItem *item, void *data, uint32_t *pktsize) -{ - uint32_t tlvsize = sizeVoipPongItem(item); - uint32_t offset = 0; - - if (*pktsize < tlvsize) - return false; /* not enough space */ - - *pktsize = tlvsize; - - bool ok = true; - - ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize); - -#ifdef RSSERIAL_DEBUG - std::cerr << "RsVoipSerialiser::serialiseVoipPongItem() Header: " << ok << std::endl; - std::cerr << "RsVoipSerialiser::serialiseVoipPongItem() Size: " << tlvsize << std::endl; -#endif - - /* skip the header */ - offset += 8; - - /* add mandatory parts first */ - ok &= setRawUInt32(data, tlvsize, &offset, item->mSeqNo); - ok &= setRawUInt64(data, tlvsize, &offset, item->mPingTS); - ok &= setRawUInt64(data, tlvsize, &offset, item->mPongTS); - - if (offset != tlvsize) - { - ok = false; - std::cerr << "RsVoipSerialiser::serialiseVoipPongItem() Size Error! " << std::endl; - } - - return ok; -} - -RsVoipPongItem *RsVoipSerialiser::deserialiseVoipPongItem(void *data, uint32_t *pktsize) -{ - /* get the type and size */ - uint32_t rstype = getRsItemId(data); - uint32_t rssize = getRsItemSize(data); - - uint32_t offset = 0; - - - if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || - (RS_SERVICE_TYPE_VOIP != getRsItemService(rstype)) || - (RS_PKT_SUBTYPE_VOIP_PONG != getRsItemSubType(rstype))) - { - return NULL; /* wrong type */ - } - - if (*pktsize < rssize) /* check size */ - return NULL; /* not enough data */ - - /* set the packet length */ - *pktsize = rssize; - - bool ok = true; - - /* ready to load */ - RsVoipPongItem *item = new RsVoipPongItem(); - item->clear(); - - /* skip the header */ - offset += 8; - - /* get mandatory parts first */ - ok &= getRawUInt32(data, rssize, &offset, &(item->mSeqNo)); - ok &= getRawUInt64(data, rssize, &offset, &(item->mPingTS)); - ok &= getRawUInt64(data, rssize, &offset, &(item->mPongTS)); - - if (offset != rssize) - { - /* error */ - delete item; - return NULL; - } - - if (!ok) - { - delete item; - return NULL; - } - - return item; -} - -/*************************************************************************/ - -uint32_t RsVoipSerialiser::size(RsItem *i) -{ - RsVoipPingItem *ping; - RsVoipPongItem *pong; - - if (NULL != (ping = dynamic_cast(i))) - { - return sizeVoipPingItem(ping); - } - else if (NULL != (pong = dynamic_cast(i))) - { - return sizeVoipPongItem(pong); - } - return 0; -} - -bool RsVoipSerialiser::serialise(RsItem *i, void *data, uint32_t *pktsize) -{ -#ifdef RSSERIAL_DEBUG - std::cerr << "RsMsgSerialiser::serialise()" << std::endl; -#endif - - RsVoipPingItem *ping; - RsVoipPongItem *pong; - - if (NULL != (ping = dynamic_cast(i))) - { - return serialiseVoipPingItem(ping, data, pktsize); - } - else if (NULL != (pong = dynamic_cast(i))) - { - return serialiseVoipPongItem(pong, data, pktsize); - } - return false; -} - -RsItem* RsVoipSerialiser::deserialise(void *data, uint32_t *pktsize) -{ -#ifdef RSSERIAL_DEBUG - std::cerr << "RsVoipSerialiser::deserialise()" << std::endl; -#endif - - /* get the type and size */ - uint32_t rstype = getRsItemId(data); - - if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || - (RS_SERVICE_TYPE_VOIP != getRsItemService(rstype))) - { - return NULL; /* wrong type */ - } - - switch(getRsItemSubType(rstype)) - { - case RS_PKT_SUBTYPE_VOIP_PING: - return deserialiseVoipPingItem(data, pktsize); - break; - case RS_PKT_SUBTYPE_VOIP_PONG: - return deserialiseVoipPongItem(data, pktsize); - break; - default: - return NULL; - break; - } - - return NULL; -} - - -/*************************************************************************/ - diff --git a/libretroshare/src/serialiser/rsvoipitems.h b/libretroshare/src/serialiser/rsvoipitems.h deleted file mode 100644 index f62f21479..000000000 --- a/libretroshare/src/serialiser/rsvoipitems.h +++ /dev/null @@ -1,108 +0,0 @@ -#ifndef RS_VOIP_ITEMS_H -#define RS_VOIP_ITEMS_H - -/* - * libretroshare/src/serialiser: rsvoipitems.h - * - * RetroShare Serialiser. - * - * Copyright 2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - -#include - -#include "serialiser/rsserviceids.h" -#include "serialiser/rsserial.h" -#include "serialiser/rstlvtypes.h" - -/**************************************************************************/ - -const uint8_t RS_PKT_SUBTYPE_VOIP_PING = 0x01; -const uint8_t RS_PKT_SUBTYPE_VOIP_PONG = 0x02; - -class RsVoipItem: public RsItem -{ - public: - RsVoipItem(uint8_t chat_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_VOIP,chat_subtype) - { setPriorityLevel(QOS_PRIORITY_RS_VOIP_PING) ;} // should be refined later. - - virtual ~RsVoipItem() {}; - virtual void clear() {}; - virtual std::ostream& print(std::ostream &out, uint16_t indent = 0) = 0 ; -}; - -class RsVoipPingItem: public RsVoipItem -{ - public: - RsVoipPingItem() :RsVoipItem(RS_PKT_SUBTYPE_VOIP_PING) {} - - virtual ~RsVoipPingItem(); - virtual void clear(); - virtual std::ostream& print(std::ostream &out, uint16_t indent = 0); - - uint32_t mSeqNo; - uint64_t mPingTS; -}; - -class RsVoipPongItem: public RsVoipItem -{ - public: - RsVoipPongItem() :RsVoipItem(RS_PKT_SUBTYPE_VOIP_PONG) {} - - virtual ~RsVoipPongItem(); - virtual void clear(); - virtual std::ostream& print(std::ostream &out, uint16_t indent = 0); - - uint32_t mSeqNo; - uint64_t mPingTS; - uint64_t mPongTS; -}; - - -class RsVoipSerialiser: public RsSerialType -{ - public: - RsVoipSerialiser() - :RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_VOIP) - { return; } - -virtual ~RsVoipSerialiser() { return; } - -virtual uint32_t size(RsItem *); -virtual bool serialise (RsItem *item, void *data, uint32_t *size); -virtual RsItem * deserialise(void *data, uint32_t *size); - - private: - -virtual uint32_t sizeVoipPingItem(RsVoipPingItem *); -virtual bool serialiseVoipPingItem (RsVoipPingItem *item, void *data, uint32_t *size); -virtual RsVoipPingItem *deserialiseVoipPingItem(void *data, uint32_t *size); - -virtual uint32_t sizeVoipPongItem(RsVoipPongItem *); -virtual bool serialiseVoipPongItem (RsVoipPongItem *item, void *data, uint32_t *size); -virtual RsVoipPongItem *deserialiseVoipPongItem(void *data, uint32_t *size); - -}; - -/**************************************************************************/ - -#endif /* RS_VOIP_ITEMS_H */ - - diff --git a/libretroshare/src/services/p3vors.cc b/libretroshare/src/services/p3vors.cc deleted file mode 100644 index 1bec880f8..000000000 --- a/libretroshare/src/services/p3vors.cc +++ /dev/null @@ -1,487 +0,0 @@ -/* - * libretroshare/src/services p3vors.cc - * - * Voice Over Retroshare Service for RetroShare. - * - * Copyright 2011-2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - -#include "util/rsdir.h" -#include "retroshare/rsiface.h" -#include "pqi/pqibin.h" -#include "pqi/pqinotify.h" -#include "pqi/pqistore.h" -#include "pqi/p3linkmgr.h" - -#include "services/p3vors.h" -#include "serialiser/rsvoipitems.h" - -#include - -/**** - * #define DEBUG_VORS 1 - ****/ - - -/* DEFINE INTERFACE POINTER! */ -RsVoip *rsVoip = NULL; - - -#define MAX_PONG_RESULTS 150 -#define VORS_PING_PERIOD 10 - -/************ IMPLEMENTATION NOTES ********************************* - * - * Voice over Retroshare ;) - * - * This will be a simple test VoIP system aimed at testing out the possibilities. - * - * Important things to test: - * 1) lag, and variability in data rate - * - To do this we time tag every packet..., the destination can use this info to calculate the results. - * - Like imixitup. Dt = clock_diff + lag. - * we expect clock_diff to be relatively constant, but lag to vary. - * lag cannot be negative, so minimal Dt is ~clock_diff, and delays on this are considered +lag. - * - * 2) we could directly measure lag. ping back and forth with Timestamps. - * - * 3) we also want to measure bandwidth... - * - not sure the best method? - * one way: send a ping, then a large amount of data (5 seconds worth), then another ping. - * the delta in timestamps should be a decent indication of bandwidth. - * say we have a 100kb/s connection... need 500kb. - * actually the amount of data should be based on a reasonable maximum that we require. - * what does decent video require? - * Audio we can test for 64kb/s - which seems like a decent rate: e.g. mono, 16bit 22k = 1 x 2 x 22k = 44 kilobytes/sec - * best to do this without a VoIP call going on ;) - * - * - */ - - - -#if 0 -class RsVorsLagItem: public RsItem -{ - public: - - uint32_t seqno; - uint32_t type; // REQUEST, RESPONSE. - double peerTs; - -}; - -class RsVorsDatatem: public RsItem -{ - public: - - uint32_t seqno; - uint32_t encoding; - uint32_t audiolength; // in 44.1 kbs samples. - uint32_t datalength; - void *data; -}; - -#endif - - -#ifdef WINDOWS_SYS -#include -#include -#endif - -static double getCurrentTS() -{ - -#ifndef WINDOWS_SYS - struct timeval cts_tmp; - gettimeofday(&cts_tmp, NULL); - double cts = (cts_tmp.tv_sec) + ((double) cts_tmp.tv_usec) / 1000000.0; -#else - struct _timeb timebuf; - _ftime( &timebuf); - double cts = (timebuf.time) + ((double) timebuf.millitm) / 1000.0; -#endif - return cts; -} - -static uint64_t convertTsTo64bits(double ts) -{ - uint32_t secs = (uint32_t) ts; - uint32_t usecs = (uint32_t) ((ts - (double) secs) * 1000000); - uint64_t bits = (((uint64_t) secs) << 32) + usecs; - return bits; -} - - -static double convert64bitsToTs(uint64_t bits) -{ - uint32_t usecs = (uint32_t) (bits & 0xffffffff); - uint32_t secs = (uint32_t) ((bits >> 32) & 0xffffffff); - double ts = (secs) + ((double) usecs) / 1000000.0; - - return ts; -} - - - - -p3VoRS::p3VoRS(p3LinkMgr *lm) - :p3Service(RS_SERVICE_TYPE_VOIP), /* p3Config(CONFIG_TYPE_VOIP), */ mVorsMtx("p3VoRS"), mLinkMgr(lm) -{ - addSerialType(new RsVoipSerialiser()); - - mSentPingTime = 0; - mCounter = 0; - -} - - -int p3VoRS::tick() -{ - processIncoming(); - sendPackets(); - - return 0; -} - -int p3VoRS::status() -{ - return 1; -} - - - -int p3VoRS::sendPackets() -{ - time_t now = time(NULL); - time_t pt; - { - RsStackMutex stack(mVorsMtx); /****** LOCKED MUTEX *******/ - pt = mSentPingTime; - } - - if (now - pt > VORS_PING_PERIOD) - { - sendPingMeasurements(); - - RsStackMutex stack(mVorsMtx); /****** LOCKED MUTEX *******/ - mSentPingTime = now; - } - return true ; -} - - - -void p3VoRS::sendPingMeasurements() -{ - - - /* we ping our peers */ - /* who is online? */ - std::list idList; - - mLinkMgr->getOnlineList(idList); - - double ts = getCurrentTS(); - -#ifdef DEBUG_VORS - std::cerr << "p3VoRS::sendPingMeasurements() @ts: " << ts; - std::cerr << std::endl; -#endif - - /* prepare packets */ - std::list::iterator it; - for(it = idList.begin(); it != idList.end(); it++) - { -#ifdef DEBUG_VORS - std::cerr << "p3VoRS::sendPingMeasurements() Pinging: " << *it; - std::cerr << std::endl; -#endif - - /* create the packet */ - RsVoipPingItem *pingPkt = new RsVoipPingItem(); - pingPkt->PeerId(*it); - pingPkt->mSeqNo = mCounter; - pingPkt->mPingTS = convertTsTo64bits(ts); - - storePingAttempt(*it, ts, mCounter); - -#ifdef DEBUG_VORS - std::cerr << "p3VoRS::sendPingMeasurements() With Packet:"; - std::cerr << std::endl; - pingPkt->print(std::cerr, 10); -#endif - - sendItem(pingPkt); - } - - RsStackMutex stack(mVorsMtx); /****** LOCKED MUTEX *******/ - mCounter++; -} - - - - -int p3VoRS::processIncoming() -{ - /* for each packet - pass to specific handler */ - RsItem *item = NULL; - while(NULL != (item = recvItem())) - { - switch(item->PacketSubType()) - { - default: - break; - case RS_PKT_SUBTYPE_VOIP_PING: - { - handlePing(item); - } - break; - case RS_PKT_SUBTYPE_VOIP_PONG: - { - handlePong(item); - } - break; - -#if 0 - /* THESE ARE ALL FUTURISTIC DATA TYPES */ - case RS_DATA_ITEM: - { - handleData(item); - } - break; - - case RS_BANDWIDTH_PING_ITEM: - { - handleBandwidthPing(item); - } - break; - - case RS_BANDWIDTH_PONG_ITEM: - { - handleBandwidthPong(item); - } - break; -#endif - } - - /* clean up */ - delete item; - } - return true ; -} - -int p3VoRS::handlePing(RsItem *item) -{ - /* cast to right type */ - RsVoipPingItem *ping = (RsVoipPingItem *) item; - -#ifdef DEBUG_VORS - std::cerr << "p3VoRS::handlePing() Recvd Packet from: " << ping->PeerId(); - std::cerr << std::endl; -#endif - - /* with a ping, we just respond as quickly as possible - they do all the analysis */ - RsVoipPongItem *pong = new RsVoipPongItem(); - - - pong->PeerId(ping->PeerId()); - pong->mPingTS = ping->mPingTS; - pong->mSeqNo = ping->mSeqNo; - - // add our timestamp. - double ts = getCurrentTS(); - pong->mPongTS = convertTsTo64bits(ts); - - -#ifdef DEBUG_VORS - std::cerr << "p3VoRS::handlePing() With Packet:"; - std::cerr << std::endl; - pong->print(std::cerr, 10); -#endif - - sendItem(pong); - return true ; -} - - -int p3VoRS::handlePong(RsItem *item) -{ - /* cast to right type */ - RsVoipPongItem *pong = (RsVoipPongItem *) item; - -#ifdef DEBUG_VORS - std::cerr << "p3VoRS::handlePong() Recvd Packet from: " << pong->PeerId(); - std::cerr << std::endl; - pong->print(std::cerr, 10); -#endif - - /* with a pong, we do the maths! */ - double recvTS = getCurrentTS(); - double pingTS = convert64bitsToTs(pong->mPingTS); - double pongTS = convert64bitsToTs(pong->mPongTS); - - double rtt = recvTS - pingTS; - double offset = pongTS - (recvTS - rtt / 2.0); // so to get to their time, we go ourTS + offset. - -#ifdef DEBUG_VORS - std::cerr << "p3VoRS::handlePong() Timing:"; - std::cerr << std::endl; - std::cerr << "\tpingTS: " << pingTS; - std::cerr << std::endl; - std::cerr << "\tpongTS: " << pongTS; - std::cerr << std::endl; - std::cerr << "\trecvTS: " << recvTS; - std::cerr << std::endl; - std::cerr << "\t ==> rtt: " << rtt; - std::cerr << std::endl; - std::cerr << "\t ==> offset: " << offset; - std::cerr << std::endl; -#endif - - storePongResult(pong->PeerId(), pong->mSeqNo, pingTS, rtt, offset); - return true ; -} - - - - -int p3VoRS::storePingAttempt(std::string id, double ts, uint32_t seqno) -{ - RsStackMutex stack(mVorsMtx); /****** LOCKED MUTEX *******/ - - /* find corresponding local data */ - VorsPeerInfo *peerInfo = locked_GetPeerInfo(id); - - peerInfo->mCurrentPingTS = ts; - peerInfo->mCurrentPingCounter = seqno; - - peerInfo->mSentPings++; - if (!peerInfo->mCurrentPongRecvd) - { - peerInfo->mLostPongs++; - } - - peerInfo->mCurrentPongRecvd = true; - - return 1; -} - - - -int p3VoRS::storePongResult(std::string id, uint32_t counter, double ts, double rtt, double offset) -{ - RsStackMutex stack(mVorsMtx); /****** LOCKED MUTEX *******/ - - /* find corresponding local data */ - VorsPeerInfo *peerInfo = locked_GetPeerInfo(id); - - if (peerInfo->mCurrentPingCounter != counter) - { -#ifdef DEBUG_VORS - std::cerr << "p3VoRS::storePongResult() ERROR Severly Delayed Measurements!" << std::endl; -#endif - } - else - { - peerInfo->mCurrentPongRecvd = true; - } - - peerInfo->mPongResults.push_back(RsVoipPongResult(ts, rtt, offset)); - - - while(peerInfo->mPongResults.size() > MAX_PONG_RESULTS) - { - peerInfo->mPongResults.pop_front(); - } - - /* should do calculations */ - return 1; -} - - -uint32_t p3VoRS::getPongResults(std::string id, int n, std::list &results) -{ - RsStackMutex stack(mVorsMtx); /****** LOCKED MUTEX *******/ - - VorsPeerInfo *peer = locked_GetPeerInfo(id); - - std::list::reverse_iterator it; - int i = 0; - for(it = peer->mPongResults.rbegin(); (it != peer->mPongResults.rend()) && (i < n); it++, i++) - { - /* reversing order - so its easy to trim later */ - results.push_back(*it); - } - return i ; -} - - - -VorsPeerInfo *p3VoRS::locked_GetPeerInfo(std::string id) -{ - std::map::iterator it; - it = mPeerInfo.find(id); - if (it == mPeerInfo.end()) - { - /* add it in */ - VorsPeerInfo pinfo; - - /* initialise entry */ - pinfo.initialisePeerInfo(id); - - mPeerInfo[id] = pinfo; - - it = mPeerInfo.find(id); - - } - - return &(it->second); -} - - - -bool VorsPeerInfo::initialisePeerInfo(std::string id) -{ - mId = id; - - /* reset variables */ - mCurrentPingTS = 0; - mCurrentPingCounter = 0; - mCurrentPongRecvd = true; - - mSentPings = 0; - mLostPongs = 0; - - mPongResults.clear(); - - return true; -} - - - - - - - - - - diff --git a/libretroshare/src/services/p3vors.h b/libretroshare/src/services/p3vors.h deleted file mode 100644 index 1db9e80d1..000000000 --- a/libretroshare/src/services/p3vors.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * libretroshare/src/services/p3vors.h - * - * Tests for VoIP for RetroShare. - * - * Copyright 2011 by Robert Fernie. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License Version 2 as published by the Free Software Foundation. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA. - * - * Please report all bugs and problems to "retroshare@lunamutt.com". - * - */ - - -#ifndef SERVICE_RSVOIP_HEADER -#define SERVICE_RSVOIP_HEADER - -#include -#include - -#include "serialiser/rsvoipitems.h" -#include "services/p3service.h" -#include "retroshare/rsvoip.h" - -class p3LinkMgr; - -class VorsPeerInfo -{ - public: - - bool initialisePeerInfo(std::string id); - - std::string mId; - double mCurrentPingTS; - double mCurrentPingCounter; - bool mCurrentPongRecvd; - - uint32_t mLostPongs; - uint32_t mSentPings; - - std::list mPongResults; -}; - - -//!The RS VoIP Test service. - /** - * - * This is only used to test Latency for the moment. - */ - -class p3VoRS: public RsVoip, public p3Service -// Maybe we inherit from these later - but not needed for now. -//, public p3Config, public pqiMonitor -{ - public: - p3VoRS(p3LinkMgr *cm); - - /***** overloaded from rsVoip *****/ - -virtual uint32_t getPongResults(std::string id, int n, std::list &results); - - /***** overloaded from p3Service *****/ - /*! - * This retrieves all chat msg items and also (important!) - * processes chat-status items that are in service item queue. chat msg item requests are also processed and not returned - * (important! also) notifications sent to notify base on receipt avatar, immediate status and custom status - * : notifyCustomState, notifyChatStatus, notifyPeerHasNewAvatar - * @see NotifyBase - */ - virtual int tick(); - virtual int status(); - - - int sendPackets(); - void sendPingMeasurements(); - int processIncoming(); - - int handlePing(RsItem *item); - int handlePong(RsItem *item); - - int storePingAttempt(std::string id, double ts, uint32_t mCounter); - int storePongResult(std::string id, uint32_t counter, double ts, double rtt, double offset); - - - /*! - * This retrieves all public chat msg items - */ - //bool getPublicChatQueue(std::list &chats); - - /*************** pqiMonitor callback ***********************/ - //virtual void statusChange(const std::list &plist); - - - /************* from p3Config *******************/ - //virtual RsSerialiser *setupSerialiser() ; - //virtual bool saveList(bool& cleanup, std::list&) ; - //virtual void saveDone(); - //virtual bool loadList(std::list& load) ; - - private: - RsMutex mVorsMtx; - - VorsPeerInfo *locked_GetPeerInfo(std::string id); - - std::map mPeerInfo; - time_t mSentPingTime; - uint32_t mCounter; - - p3LinkMgr *mLinkMgr; - -}; - -#endif // SERVICE_RSVOIP_HEADER - diff --git a/retroshare-gui/src/RetroShare.pro b/retroshare-gui/src/RetroShare.pro index 168420e3b..4c3b6797a 100644 --- a/retroshare-gui/src/RetroShare.pro +++ b/retroshare-gui/src/RetroShare.pro @@ -22,6 +22,8 @@ minimal { DEFINES += MINIMAL_RSGUI } +INCLUDEPATH *= retroshare-gui + # treat warnings as error for better removing #QMAKE_CFLAGS += -Werror #QMAKE_CXXFLAGS += -Werror @@ -203,6 +205,8 @@ INCLUDEPATH += ../../libretroshare/src/ # Input HEADERS += rshare.h \ retroshare-gui/configpage.h \ + retroshare-gui/RsAutoUpdatePage.h \ + retroshare-gui/mainpage.h \ gui/notifyqt.h \ control/bandwidthevent.h \ control/eventtype.h \ @@ -216,13 +220,11 @@ HEADERS += rshare.h \ gui/TransfersDialog.h \ gui/graphframe.h \ gui/linetypes.h \ - gui/mainpage.h \ gui/mainpagestack.h \ gui/MainWindow.h \ gui/RSHumanReadableDelegate.h \ gui/TurtleRouterDialog.h \ gui/TurtleRouterStatistics.h \ - gui/VoipStatistics.h \ gui/AboutDialog.h \ gui/ForumsDialog.h \ gui/forums/ForumDetails.h \ @@ -244,7 +246,6 @@ HEADERS += rshare.h \ gui/SFListDelegate.h \ gui/SoundManager.h \ gui/FileTransferInfoWidget.h \ - gui/RsAutoUpdatePage.h \ gui/HelpDialog.h \ gui/InfoDialog.h \ gui/LogoBar.h \ @@ -397,7 +398,6 @@ FORMS += gui/StartDialog.ui \ gui/MainWindow.ui \ gui/TurtleRouterDialog.ui \ gui/TurtleRouterStatistics.ui \ - gui/VoipStatistics.ui \ gui/forums/CreateForum.ui \ gui/forums/CreateForumMsg.ui \ gui/forums/ForumDetails.ui \ @@ -498,7 +498,6 @@ SOURCES += main.cpp \ gui/mainpagestack.cpp \ gui/TurtleRouterDialog.cpp \ gui/TurtleRouterStatistics.cpp \ - gui/VoipStatistics.cpp \ gui/MainWindow.cpp \ gui/ForumsDialog.cpp \ gui/forums/ForumDetails.cpp \ diff --git a/retroshare-gui/src/gui/FriendsDialog.h b/retroshare-gui/src/gui/FriendsDialog.h index 17924b467..5a1695520 100644 --- a/retroshare-gui/src/gui/FriendsDialog.h +++ b/retroshare-gui/src/gui/FriendsDialog.h @@ -23,9 +23,7 @@ #define _FRIENDSDIALOG_H #include "chat/ChatStyle.h" -#include "RsAutoUpdatePage.h" - -#include "mainpage.h" +#include "retroshare-gui/RsAutoUpdatePage.h" #ifndef MINIMAL_RSGUI #include "ui_FriendsDialog.h" diff --git a/retroshare-gui/src/gui/GetStartedDialog.cpp b/retroshare-gui/src/gui/GetStartedDialog.cpp index 9d29c4961..91f24032f 100644 --- a/retroshare-gui/src/gui/GetStartedDialog.cpp +++ b/retroshare-gui/src/gui/GetStartedDialog.cpp @@ -25,7 +25,7 @@ #include "retroshare/rsdisc.h" #include "retroshare/rsconfig.h" -#include "gui/RsAutoUpdatePage.h" +#include "retroshare-gui/RsAutoUpdatePage.h" #include diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 6cba4fe71..3ee796e88 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include #include diff --git a/retroshare-gui/src/gui/SearchDialog.cpp b/retroshare-gui/src/gui/SearchDialog.cpp index 07ac54e47..4d380eb92 100644 --- a/retroshare-gui/src/gui/SearchDialog.cpp +++ b/retroshare-gui/src/gui/SearchDialog.cpp @@ -28,7 +28,7 @@ #include "RetroShareLink.h" #include "msgs/MessageComposer.h" #include "gui/RSHumanReadableDelegate.h" -#include "gui/RsAutoUpdatePage.h" +#include "retroshare-gui/RsAutoUpdatePage.h" #include "gui/common/RsCollectionFile.h" #include "gui/common/FilesDefs.h" #include "settings/rsharesettings.h" diff --git a/retroshare-gui/src/gui/TrustView.h b/retroshare-gui/src/gui/TrustView.h index 1ebc3b630..25176057c 100644 --- a/retroshare-gui/src/gui/TrustView.h +++ b/retroshare-gui/src/gui/TrustView.h @@ -1,5 +1,5 @@ #include "ui_TrustView.h" -#include +#include class QWheelEvent ; class QShowEvent ; diff --git a/retroshare-gui/src/gui/VoipStatistics.cpp b/retroshare-gui/src/gui/VoipStatistics.cpp deleted file mode 100644 index d8080a55a..000000000 --- a/retroshare-gui/src/gui/VoipStatistics.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 20011, RetroShare Team - * - * 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. - ****************************************************************/ - -#include -#include -#include - -#include -#include - -#include -#include -#include "VoipStatistics.h" -#include "time.h" - -#include "gui/settings/rsharesettings.h" - -#define PLOT_HEIGHT 100 -#define PLOT_WIDTH 500 - -#define MAX_DISPLAY_PERIOD 300 - -double convertDtToPixels(double refTs, double minTs, double ts) -{ - double dt = refTs - ts; - double maxdt = refTs - minTs; - double pix = PLOT_WIDTH - dt / maxdt * PLOT_WIDTH; - return pix; -} - - -double convertRttToPixels(double maxRTT, double rtt) -{ - double pix = rtt / maxRTT * PLOT_HEIGHT; - return PLOT_HEIGHT - pix; -} - -class VoipLagPlot -{ - public: - VoipLagPlot(const std::map > &info, - double refTS, double maxRTT, double minTS, double maxTS) - :mInfo(info), mRefTS(refTS), mMaxRTT(maxRTT), mMinTS(minTS), mMaxTS(maxTS) {} - - - QColor colorScale(float f) - { - if(f == 0) - return QColor::fromHsv(0,0,192) ; - else - return QColor::fromHsv((int)((1.0-f)*280),200,255) ; - } - - virtual void draw(QPainter *painter,int& ox,int& oy,const QString& title) - { - //static const int MaxTime = 61 ; - //static const int MaxDepth = 8 ; - static const int cellx = 7 ; - static const int celly = 12 ; - - //int save_ox = ox ; - painter->setPen(QColor::fromRgb(0,0,0)) ; - painter->drawText(2+ox,celly+oy,title) ; - oy+=2+2*celly ; - - //std::cerr << "VoipLagPlot::draw()"; - //std::cerr << std::endl; - - painter->drawRect(ox, oy, PLOT_WIDTH, PLOT_HEIGHT); - - if(mInfo.empty()) - return ; - - double maxdt = mRefTS - mMinTS; - if (maxdt > MAX_DISPLAY_PERIOD) - { - mMinTS = mRefTS - MAX_DISPLAY_PERIOD; - } - - /* draw a different line for each peer */ - std::map >::const_iterator mit; - int i = 0; - int nLines = mInfo.size(); - for(mit = mInfo.begin(); mit != mInfo.end(); mit++, i++) - { - //std::cerr << "VoipLagPlot::draw() Line of " << mit->second.size(); - //std::cerr << " Elements for: " << mit->first; - //std::cerr << std::endl; - - QPainterPath path; - std::list::const_iterator it = mit->second.begin(); - if (it != mit->second.end()) - { - double x = convertDtToPixels(mRefTS, mMinTS, it->mTS); - double y = convertRttToPixels(mMaxRTT, it->mRTT); - path.moveTo(ox + x, oy + y); - it++; - } - - for(; it != mit->second.end(); it++) - { - /* skip old elements */ - if (it->mTS < mMinTS) - { - continue; - } - - double x = convertDtToPixels(mRefTS, mMinTS, it->mTS); - double y = convertRttToPixels(mMaxRTT, it->mRTT); - - path.lineTo(ox + x, oy + y); - - //std::cerr << "VoipLagPlot::draw() Point: (" << x << "," << y << ")"; - //std::cerr << std::endl; - - //painter->drawLine(ox,oy, ox + x, oy + y); - } - - /* draw line */ - painter->setPen(QColor::fromRgb(((255.0 * i) / (nLines-1)),0, 255 - (255.0 * i) / (nLines-1))) ; - painter->drawPath(path); - - /* draw name */ - } - - painter->setPen(QColor::fromRgb(0,0,0)) ; - painter->drawText(ox+PLOT_WIDTH + cellx ,oy + celly / 2, QString::number(mMaxRTT)+" "+QObject::tr("secs")) ; - oy += PLOT_HEIGHT / 2; - painter->drawText(ox+PLOT_WIDTH + cellx ,oy + celly / 2, QString::number(mMaxRTT / 2.0)+" "+QObject::tr("secs")) ; - oy += PLOT_HEIGHT / 2; - painter->drawText(ox+PLOT_WIDTH + cellx ,oy + celly / 2, QString::number(0.0)+" "+QObject::tr("secs")) ; - oy += celly; - painter->drawText(ox ,oy, QObject::tr("Old")); - painter->drawText(ox + PLOT_WIDTH - cellx ,oy, QObject::tr("Now")); - oy += celly; - - // Now do names. - i = 0; - for(mit = mInfo.begin(); mit != mInfo.end(); mit++, i++) - { - painter->fillRect(ox,oy,cellx,celly, - QColor::fromRgb(((255.0 * i) / (nLines-1)),0, 255 - (255.0 * i) / (nLines-1))) ; - - painter->setPen(QColor::fromRgb(0,0,0)) ; - painter->drawRect(ox,oy,cellx,celly) ; - painter->drawText(ox + cellx + 4,oy + celly / 2,VoipStatistics::getPeerName(mit->first)); - - oy += 2 * celly; - } - } - - private: - const std::map > &mInfo; - double mRefTS; - double mMaxRTT; - double mMinTS; - double mMaxTS; - -}; - -VoipStatistics::VoipStatistics(QWidget *parent) - : RsAutoUpdatePage(2000,parent) -{ - setupUi(this) ; - - m_bProcessSettings = false; - - _tunnel_statistics_F->setWidget( _tst_CW = new VoipStatisticsWidget() ) ; - _tunnel_statistics_F->setWidgetResizable(true); - _tunnel_statistics_F->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - _tunnel_statistics_F->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); - _tunnel_statistics_F->viewport()->setBackgroundRole(QPalette::NoRole); - _tunnel_statistics_F->setFrameStyle(QFrame::NoFrame); - _tunnel_statistics_F->setFocusPolicy(Qt::NoFocus); - - // load settings - processSettings(true); -} - -VoipStatistics::~VoipStatistics() -{ - - // save settings - processSettings(false); -} - -void VoipStatistics::processSettings(bool bLoad) -{ - m_bProcessSettings = true; - - Settings->beginGroup(QString("VoipStatistics")); - - if (bLoad) { - // load settings - - // state of splitter - //splitter->restoreState(Settings->value("Splitter").toByteArray()); - } else { - // save settings - - // state of splitter - //Settings->setValue("Splitter", splitter->saveState()); - - } - - Settings->endGroup(); - - m_bProcessSettings = false; - -} - - -void VoipStatistics::updateDisplay() -{ - std::map > info; - - if (!rsVoip) - { - return; - } - - std::list idList; - std::list::iterator it; - - rsPeers->getOnlineList(idList); - - time_t now = time(NULL); - time_t minTS = now; - time_t maxTS = 0; - double maxRTT = 0; - - for(it = idList.begin(); it != idList.end(); it++) - { - std::list results; - std::list::iterator rit; - -#define MAX_RESULTS 60 - rsVoip->getPongResults(*it, MAX_RESULTS, results); - - for(rit = results.begin(); rit != results.end(); rit++) - { - /* only want maxRTT to include plotted bit */ - double dt = now - rit->mTS; - if (dt < MAX_DISPLAY_PERIOD) - { - if (maxRTT < rit->mRTT) - { - maxRTT = rit->mRTT; - } - } - if (minTS > rit->mTS) - { - minTS = rit->mTS; - } - if (maxTS < rit->mTS) - { - maxTS = rit->mTS; - } - } - - info[*it] = results; - } - - - _tst_CW->updateVoipStatistics(info, maxRTT, minTS, maxTS); - _tst_CW->update(); -} - -QString VoipStatistics::getPeerName(const std::string& peer_id) -{ - static std::map names ; - - std::map::const_iterator it = names.find(peer_id) ; - - if( it != names.end()) - return it->second ; - else - { - RsPeerDetails detail ; - if(!rsPeers->getPeerDetails(peer_id,detail)) - return "unknown peer"; - - return (names[peer_id] = QString::fromUtf8(detail.name.c_str())) ; - } -} - -VoipStatisticsWidget::VoipStatisticsWidget(QWidget *parent) - : QWidget(parent) -{ - maxWidth = 200 ; - maxHeight = 0 ; -} - -void VoipStatisticsWidget::updateVoipStatistics(const std::map >& info, - double maxRTT, double minTS, double maxTS) -{ - //static const int cellx = 6 ; - //static const int celly = 10+4 ; - - QPixmap tmppixmap(maxWidth, maxHeight); - tmppixmap.fill(this, 0, 0); - setFixedHeight(maxHeight); - - QPainter painter(&tmppixmap); - painter.initFrom(this); - - maxHeight = 500 ; - - //std::cerr << "Drawing into pixmap of size " << maxWidth << "x" << maxHeight << std::endl; - // draw... - int ox=5,oy=5 ; - - double refTS = time(NULL); - - //painter.setPen(QColor::fromRgb(70,70,70)) ; - //painter.drawLine(0,oy,maxWidth,oy) ; - //oy += celly ; - //painter.setPen(QColor::fromRgb(0,0,0)) ; - - // round up RTT to nearest - double roundedRTT = maxRTT; - if (maxRTT < 0.15) - { - roundedRTT = 0.2; - } - else if (maxRTT < 0.4) - { - roundedRTT = 0.5; - } - else if (maxRTT < 0.8) - { - roundedRTT = 1.0; - } - else if (maxRTT < 1.8) - { - roundedRTT = 2.0; - } - else if (maxRTT < 4.5) - { - roundedRTT = 5.0; - } - - VoipLagPlot(info, refTS, roundedRTT, minTS, maxTS).draw(&painter,ox,oy,QObject::tr("Round Trip Time:")) ; - - // update the pixmap - pixmap = tmppixmap; - maxHeight = oy; // + PLOT_HEIGHT * 2; -} - -QString VoipStatisticsWidget::speedString(float f) -{ - if(f < 1.0f) - return QString("0 B/s") ; - if(f < 1024.0f) - return QString::number((int)f)+" B/s" ; - - return QString::number(f/1024.0,'f',2) + " KB/s"; -} - -void VoipStatisticsWidget::paintEvent(QPaintEvent */*event*/) -{ - QStylePainter(this).drawPixmap(0, 0, pixmap); -} - -void VoipStatisticsWidget::resizeEvent(QResizeEvent *event) -{ - QRect TaskGraphRect = geometry(); - maxWidth = TaskGraphRect.width(); - maxHeight = TaskGraphRect.height() ; - - QWidget::resizeEvent(event); - update(); -} - - diff --git a/retroshare-gui/src/gui/VoipStatistics.h b/retroshare-gui/src/gui/VoipStatistics.h deleted file mode 100644 index 83b2c38bb..000000000 --- a/retroshare-gui/src/gui/VoipStatistics.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************** - * RetroShare is distributed under the following license: - * - * Copyright (C) 20011, RetroShare Team - * - * 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. - ****************************************************************/ - -#pragma once - -#include -#include -#include "ui_VoipStatistics.h" -#include "RsAutoUpdatePage.h" - -class VoipStatisticsWidget ; - -class VoipStatistics: public RsAutoUpdatePage, public Ui::VoipStatistics -{ - public: - VoipStatistics(QWidget *parent = NULL) ; - ~VoipStatistics(); - - // Cache for peer names. - static QString getPeerName(const std::string& peer_id) ; - - private: - - void processSettings(bool bLoad); - bool m_bProcessSettings; - - virtual void updateDisplay() ; - - VoipStatisticsWidget *_tst_CW ; -} ; - -class VoipStatisticsWidget: public QWidget -{ - public: - VoipStatisticsWidget(QWidget *parent = NULL) ; - - virtual void paintEvent(QPaintEvent *event) ; - virtual void resizeEvent(QResizeEvent *event); - - - void updateVoipStatistics(const std::map >& info, - double maxRTT, double minTS, double maxTS); - - private: - static QString speedString(float f) ; - - QPixmap pixmap ; - int maxWidth,maxHeight ; -}; - diff --git a/retroshare-gui/src/gui/VoipStatistics.ui b/retroshare-gui/src/gui/VoipStatistics.ui deleted file mode 100644 index ae1c3c650..000000000 --- a/retroshare-gui/src/gui/VoipStatistics.ui +++ /dev/null @@ -1,55 +0,0 @@ - - - VoipStatistics - - - - 0 - 0 - 611 - 408 - - - - VoipTest Statistics - - - - :/images/rstray3.png:/images/rstray3.png - - - - - - Qt::Vertical - - - - QFrame::NoFrame - - - Qt::ScrollBarAlwaysOff - - - true - - - - - 0 - 0 - 587 - 384 - - - - - - - - - - - - - diff --git a/retroshare-gui/src/gui/bwgraph/bwgraph.cpp b/retroshare-gui/src/gui/bwgraph/bwgraph.cpp index 9319f698f..3a5a7b189 100644 --- a/retroshare-gui/src/gui/bwgraph/bwgraph.cpp +++ b/retroshare-gui/src/gui/bwgraph/bwgraph.cpp @@ -24,7 +24,7 @@ #include #include #include "bwgraph.h" -#include +#include #include #include diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index b06e7a7db..381b30011 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -40,7 +40,7 @@ #include "gui/msgs/MessageComposer.h" #include "gui/notifyqt.h" #include "gui/RetroShareLink.h" -#include "gui/RsAutoUpdatePage.h" +#include "retroshare-gui/RsAutoUpdatePage.h" #ifdef UNFINISHED #include "gui/unfinished/profile/ProfileView.h" #endif diff --git a/retroshare-gui/src/gui/common/FriendList.h b/retroshare-gui/src/gui/common/FriendList.h index 330b76cc3..4bab78c32 100644 --- a/retroshare-gui/src/gui/common/FriendList.h +++ b/retroshare-gui/src/gui/common/FriendList.h @@ -26,7 +26,7 @@ #include -#include "gui/RsAutoUpdatePage.h" +#include "retroshare-gui/RsAutoUpdatePage.h" namespace Ui { class FriendList; diff --git a/retroshare-gui/src/gui/dht/DhtWindow.cpp b/retroshare-gui/src/gui/dht/DhtWindow.cpp index 42ab919af..0c513e9a1 100644 --- a/retroshare-gui/src/gui/dht/DhtWindow.cpp +++ b/retroshare-gui/src/gui/dht/DhtWindow.cpp @@ -30,7 +30,7 @@ #include #include -#include "gui/RsAutoUpdatePage.h" +#include "retroshare-gui/RsAutoUpdatePage.h" #include "retroshare/rsdht.h" #include "retroshare/rsconfig.h" #include "retroshare/rspeers.h" diff --git a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp index d61f64dcb..c5d4269a7 100644 --- a/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/ChatMsgItem.cpp @@ -24,7 +24,7 @@ #include "ChatMsgItem.h" #include "FeedHolder.h" -#include "../RsAutoUpdatePage.h" +#include "retroshare-gui/RsAutoUpdatePage.h" #include "gui/msgs/MessageComposer.h" #include "gui/chat/HandleRichText.h" #include "gui/common/AvatarDefs.h" diff --git a/retroshare-gui/src/gui/feeds/PeerItem.cpp b/retroshare-gui/src/gui/feeds/PeerItem.cpp index a3eb7a0da..20d7a5b3c 100644 --- a/retroshare-gui/src/gui/feeds/PeerItem.cpp +++ b/retroshare-gui/src/gui/feeds/PeerItem.cpp @@ -24,7 +24,7 @@ #include "PeerItem.h" #include "FeedHolder.h" -#include "../RsAutoUpdatePage.h" +#include "retroshare-gui/RsAutoUpdatePage.h" #include "gui/msgs/MessageComposer.h" #include "gui/common/StatusDefs.h" #include "gui/common/AvatarDefs.h" diff --git a/retroshare-gui/src/gui/feeds/SecurityItem.cpp b/retroshare-gui/src/gui/feeds/SecurityItem.cpp index 88c162059..3c560ea66 100644 --- a/retroshare-gui/src/gui/feeds/SecurityItem.cpp +++ b/retroshare-gui/src/gui/feeds/SecurityItem.cpp @@ -25,7 +25,7 @@ #include "SecurityItem.h" #include "FeedHolder.h" -#include "../RsAutoUpdatePage.h" +#include "retroshare-gui/RsAutoUpdatePage.h" #include "gui/msgs/MessageComposer.h" #include "gui/common/StatusDefs.h" #include "gui/connect/ConfCertDialog.h" diff --git a/retroshare-gui/src/gui/mainpagestack.h b/retroshare-gui/src/gui/mainpagestack.h index f8e9949da..53988f50e 100644 --- a/retroshare-gui/src/gui/mainpagestack.h +++ b/retroshare-gui/src/gui/mainpagestack.h @@ -26,7 +26,7 @@ #include #include -#include "mainpage.h" +#include "retroshare-gui/mainpage.h" class MainPageStack : public QStackedWidget diff --git a/retroshare-gui/src/gui/RsAutoUpdatePage.h b/retroshare-gui/src/retroshare-gui/RsAutoUpdatePage.h similarity index 100% rename from retroshare-gui/src/gui/RsAutoUpdatePage.h rename to retroshare-gui/src/retroshare-gui/RsAutoUpdatePage.h diff --git a/retroshare-gui/src/gui/mainpage.h b/retroshare-gui/src/retroshare-gui/mainpage.h similarity index 100% rename from retroshare-gui/src/gui/mainpage.h rename to retroshare-gui/src/retroshare-gui/mainpage.h