From fb8e49ee66b73c68c25d39ba22c072f425b78f05 Mon Sep 17 00:00:00 2001 From: sehraf Date: Fri, 7 Sep 2018 12:58:30 +0200 Subject: [PATCH 1/9] jsonjy rsConfig --- libretroshare/src/retroshare/rsconfig.h | 192 ++++++++++++++++++++---- 1 file changed, 161 insertions(+), 31 deletions(-) diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index 962519ad9..f977ec8a4 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -30,6 +30,11 @@ /* The New Config Interface Class */ class RsServerConfig; + +/** + * Pointer to global instance of RsServerConfig service implementation + * @jsonapi{development} + */ extern RsServerConfig *rsConfig; #define RSNET_NETWORK_UNKNOWN 1 @@ -129,9 +134,8 @@ int promptAtBoot; /* popup the password prompt */ }; -class RsConfigDataRates +struct RsConfigDataRates : RsSerializable { - public: RsConfigDataRates() { mRateIn = 0; @@ -151,25 +155,43 @@ class RsConfigDataRates } /* all in kB/s */ - float mRateIn; - float mRateMaxIn; - float mAllocIn; + float mRateIn; + float mRateMaxIn; + float mAllocIn; - time_t mAllocTs; + time_t mAllocTs; - float mRateOut; - float mRateMaxOut; - float mAllowedOut; + float mRateOut; + float mRateMaxOut; + float mAllowedOut; - time_t mAllowedTs; + time_t mAllowedTs; - int mQueueIn; + int mQueueIn; int mQueueOut; + + // RsSerializable interface +public: + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(mRateIn); + RS_SERIAL_PROCESS(mRateMaxIn); + RS_SERIAL_PROCESS(mAllocIn); + + RS_SERIAL_PROCESS(mAllocTs); + + RS_SERIAL_PROCESS(mRateOut); + RS_SERIAL_PROCESS(mRateMaxOut); + RS_SERIAL_PROCESS(mAllowedOut); + + RS_SERIAL_PROCESS(mAllowedTs); + + RS_SERIAL_PROCESS(mQueueIn); + RS_SERIAL_PROCESS(mQueueOut); + } }; -class RSTrafficClue +struct RSTrafficClue : RsSerializable { -public: time_t TS ; uint32_t size ; uint8_t priority ; @@ -180,11 +202,22 @@ public: RSTrafficClue() { TS=0;size=0;service_id=0;service_sub_id=0; count=0; } RSTrafficClue& operator+=(const RSTrafficClue& tc) { size += tc.size; count += tc.count ; return *this ;} + + // RsSerializable interface +public: + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(TS); + RS_SERIAL_PROCESS(size); + RS_SERIAL_PROCESS(priority); + RS_SERIAL_PROCESS(service_id); + RS_SERIAL_PROCESS(service_sub_id); + RS_SERIAL_PROCESS(peer_id); + RS_SERIAL_PROCESS(count); + } }; -class RsConfigNetStatus +struct RsConfigNetStatus : RsSerializable { - public: RsConfigNetStatus() { localPort = extPort = 0 ; @@ -195,33 +228,63 @@ class RsConfigNetStatus netDhtNetSize = netDhtRsNetSize = 0; } - RsPeerId ownId; - std::string ownName; + RsPeerId ownId; + std::string ownName; - std::string localAddr; + std::string localAddr; int localPort; - std::string extAddr; + std::string extAddr; int extPort; - std::string extDynDns; + std::string extDynDns; - bool firewalled; - bool forwardPort; + bool firewalled; + bool forwardPort; /* older data types */ - bool DHTActive; - bool uPnPActive; + bool DHTActive; + bool uPnPActive; int uPnPState; /* Flags for Network Status */ - bool netLocalOk; /* That we've talked to someone! */ - bool netUpnpOk; /* upnp is enabled and active */ - bool netDhtOk; /* response from dht */ - bool netStunOk; /* recvd stun / udp packets */ - bool netExtAddressOk; /* from Dht/Stun or External IP Finder */ + bool netLocalOk; /* That we've talked to someone! */ + bool netUpnpOk; /* upnp is enabled and active */ + bool netDhtOk; /* response from dht */ + bool netStunOk; /* recvd stun / udp packets */ + bool netExtAddressOk;/* from Dht/Stun or External IP Finder */ - uint32_t netDhtNetSize; /* response from dht */ - uint32_t netDhtRsNetSize; /* response from dht */ + uint32_t netDhtNetSize; /* response from dht */ + uint32_t netDhtRsNetSize;/* response from dht */ + + // RsSerializable interface +public: + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(ownId); + RS_SERIAL_PROCESS(ownName); + + RS_SERIAL_PROCESS(localAddr); + RS_SERIAL_PROCESS(localPort); + RS_SERIAL_PROCESS(extAddr); + RS_SERIAL_PROCESS(extPort); + RS_SERIAL_PROCESS(extDynDns); + + RS_SERIAL_PROCESS(firewalled); + RS_SERIAL_PROCESS(forwardPort); + + RS_SERIAL_PROCESS(DHTActive); + RS_SERIAL_PROCESS(uPnPActive); + + RS_SERIAL_PROCESS(uPnPState); + + RS_SERIAL_PROCESS(netLocalOk); + RS_SERIAL_PROCESS(netUpnpOk); + RS_SERIAL_PROCESS(netDhtOk); + RS_SERIAL_PROCESS(netStunOk); + RS_SERIAL_PROCESS(netExtAddressOk); + + RS_SERIAL_PROCESS(netDhtNetSize); + RS_SERIAL_PROCESS(netDhtRsNetSize); + } }; @@ -243,13 +306,40 @@ public: /* From RsIface::RsConfig */ // Implemented Only this one! + /** + * @brief getConfigNetStatus return the net status + * @jsonapi{development} + * @param[out] status network status + * @return returns 1 on succes and 0 otherwise + */ virtual int getConfigNetStatus(RsConfigNetStatus &status) = 0; // NOT IMPLEMENTED YET! //virtual int getConfigStartup(RsConfigStartup ¶ms) = 0; + /** + * @brief getTotalBandwidthRates returns the current bandwidths rates + * @jsonapi{development} + * @param[out] rates + * @return returns 1 on succes and 0 otherwise + */ virtual int getTotalBandwidthRates(RsConfigDataRates &rates) = 0; + + /** + * @brief getAllBandwidthRates get the bandwidth rates for all peers + * @jsonapi{development} + * @param[out] ratemap map with peers->rates + * @return returns 1 on succes and 0 otherwise + */ virtual int getAllBandwidthRates(std::map &ratemap) = 0; + + /** + * @brief getTrafficInfo returns a list of all tracked traffic clues + * @jsonapi{development} + * @param[out] out_lst outgoing traffic clues + * @param[out] in_lst incomming traffic clues + * @return returns 1 on succes and 0 otherwise + */ virtual int getTrafficInfo(std::list& out_lst,std::list& in_lst) = 0 ; /* From RsInit */ @@ -283,14 +373,54 @@ public: /* Operating Mode */ + /** + * @brief getOperatingMode get current operating mode + * @jsonapi{development} + * @return return the current operating mode + */ virtual uint32_t getOperatingMode() = 0; + + /** + * @brief setOperatingMode set the current oprating mode + * @jsonapi{development} + * @param[in] opMode new opearting mode + * @return + */ virtual bool setOperatingMode(uint32_t opMode) = 0; + + /** + * @brief setOperatingMode set the current operating mode from string + * @param[in] opModeStr new operating mode as string + * @return + */ virtual bool setOperatingMode(const std::string &opModeStr) = 0; /* Data Rate Control - to be moved here */ + /** + * @brief SetMaxDataRates set maximum upload and download rates + * @jsonapi{development} + * @param[in] downKb download rate in kB + * @param[in] upKb upload rate in kB + * @return returns 1 on succes and 0 otherwise + */ virtual int SetMaxDataRates( int downKb, int upKb ) = 0; + + /** + * @brief GetMaxDataRates get maximum upload and download rates + * @jsonapi{development} + * @param[out] inKb download rate in kB + * @param[out] outKb upload rate in kB + * @return returns 1 on succes and 0 otherwise + */ virtual int GetMaxDataRates( int &inKb, int &outKb ) = 0; + /** + * @brief GetCurrentDataRates get current upload and download rates + * @jsonapi{development} + * @param[out] inKb download rate in kB + * @param[out] outKb upload rate in kB + * @return returns 1 on succes and 0 otherwise + */ virtual int GetCurrentDataRates( float &inKb, float &outKb ) = 0; }; From be50400114e207b307de02dd58719a77270063c7 Mon Sep 17 00:00:00 2001 From: sehraf Date: Fri, 7 Sep 2018 14:17:44 +0200 Subject: [PATCH 2/9] jsonfy rsDisc --- libretroshare/src/retroshare/rsdisc.h | 45 ++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/libretroshare/src/retroshare/rsdisc.h b/libretroshare/src/retroshare/rsdisc.h index b81e03c3c..a31764817 100644 --- a/libretroshare/src/retroshare/rsdisc.h +++ b/libretroshare/src/retroshare/rsdisc.h @@ -30,6 +30,11 @@ /* The Main Interface Class - for information about your Peers */ class RsDisc; + +/** + * Pointer to global instance of RsDisc service implementation + * @jsonapi{development} + */ extern RsDisc *rsDisc; class RsDisc @@ -37,13 +42,43 @@ class RsDisc public: RsDisc() { return; } -virtual ~RsDisc() { return; } + virtual ~RsDisc() { return; } -virtual bool getDiscFriends(const RsPeerId &id, std::list& friends) = 0; -virtual bool getDiscPgpFriends(const RsPgpId &pgpid, std::list& gpg_friends) = 0; -virtual bool getPeerVersion(const RsPeerId &id, std::string &versions) = 0; -virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount) = 0; + /** + * @brief getDiscFriends get a list with all friends (ssl id) to a given friend (ssl id) + * @jsonapi{development} + * @param[in] id peer to get the friends of + * @param[out] friends list of friends (ssl id) + * @return true on success false otherwise + */ + virtual bool getDiscFriends(const RsPeerId &id, std::list& friends) = 0; + /** + * @brief getDiscPgpFriends get a list with all friends (pgp id) to a given friend (pgp id) + * @jsonapi{development} + * @param[in] pgpid peer to get the friends of + * @param[out] gpg_friends list of friends (gpg id) + * @return true on success false otherwise + */ + virtual bool getDiscPgpFriends(const RsPgpId &pgpid, std::list& gpg_friends) = 0; + + /** + * @brief getPeerVersion get the version string of a peer. + * @jsonapi{development} + * @param[in] id peer to get the version string of + * @param[out] versions version string sent by the peer + * @return true on success false otherwise + */ + virtual bool getPeerVersion(const RsPeerId &id, std::string &versions) = 0; + + /** + * @brief getWaitingDiscCount get the number of queued discovery packets. + * @param[out] sendCount number of queued outgoing packets + * @param[out] recvCount number of queued incoming packets + * @return true on success false otherwise + */ + RS_DEPRECATED + virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount) = 0; }; #endif From ae14a01d585c2dcfdf92f89659b33cb4122967b5 Mon Sep 17 00:00:00 2001 From: sehraf Date: Fri, 7 Sep 2018 14:19:06 +0200 Subject: [PATCH 3/9] add json support to getWaitingDiscCount --- libretroshare/src/retroshare/rsdisc.h | 9 +++++++++ libretroshare/src/services/p3discovery2.cc | 18 ++++++++++++++---- libretroshare/src/services/p3discovery2.h | 9 +++++---- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/libretroshare/src/retroshare/rsdisc.h b/libretroshare/src/retroshare/rsdisc.h index a31764817..2e1420908 100644 --- a/libretroshare/src/retroshare/rsdisc.h +++ b/libretroshare/src/retroshare/rsdisc.h @@ -71,6 +71,15 @@ class RsDisc */ virtual bool getPeerVersion(const RsPeerId &id, std::string &versions) = 0; + /** + * @brief getWaitingDiscCount get the number of queued discovery packets. + * @jsonapi{development} + * @param[out] sendCount number of queued outgoing packets + * @param[out] recvCount number of queued incoming packets + * @return true on success false otherwise + */ + virtual bool getWaitingDiscCount(size_t &sendCount, size_t &recvCount) = 0; + /** * @brief getWaitingDiscCount get the number of queued discovery packets. * @param[out] sendCount number of queued outgoing packets diff --git a/libretroshare/src/services/p3discovery2.cc b/libretroshare/src/services/p3discovery2.cc index cf4bc28dd..05fa7a982 100644 --- a/libretroshare/src/services/p3discovery2.cc +++ b/libretroshare/src/services/p3discovery2.cc @@ -1174,7 +1174,16 @@ bool p3discovery2::getDiscFriends(const RsPeerId& id, std::list &proxy } } return true; - + +} + +bool p3discovery2::getWaitingDiscCount(size_t &sendCount, size_t &recvCount) +{ + RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ + sendCount = mPendingDiscPgpCertOutList.size(); + recvCount = mPendingDiscPgpCertInList.size(); + + return true; } @@ -1245,14 +1254,15 @@ bool p3discovery2::getWaitingDiscCount(unsigned int *sendCount, unsigned int *re return false; } - RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ + size_t send, recv; + getWaitingDiscCount(send, recv); if (sendCount) { - *sendCount = mPendingDiscPgpCertOutList.size(); + *sendCount = send; } if (recvCount) { - *recvCount = mPendingDiscPgpCertInList.size(); + *recvCount = recv; } return true; } diff --git a/libretroshare/src/services/p3discovery2.h b/libretroshare/src/services/p3discovery2.h index a4b127553..a31137f5a 100644 --- a/libretroshare/src/services/p3discovery2.h +++ b/libretroshare/src/services/p3discovery2.h @@ -87,10 +87,11 @@ virtual RsServiceInfo getServiceInfo(); int tick(); /* external interface */ -virtual bool getDiscFriends(const RsPeerId &id, std::list &friends); -virtual bool getDiscPgpFriends(const RsPgpId &pgpid, std::list &gpg_friends); -virtual bool getPeerVersion(const RsPeerId &id, std::string &version); -virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount); + bool getDiscFriends(const RsPeerId &id, std::list &friends); + bool getDiscPgpFriends(const RsPgpId &pgpid, std::list &gpg_friends); + bool getPeerVersion(const RsPeerId &id, std::string &version); + bool getWaitingDiscCount(size_t &sendCount, size_t &recvCount); + bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount); /************* from AuthGPService ****************/ virtual AuthGPGOperation *getGPGOperation(); From f34d021387b924ddfb9ba4aee024638be0c60493 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sat, 8 Sep 2018 08:57:07 +0200 Subject: [PATCH 4/9] make rs use the new function --- retroshare-gui/src/gui/statusbar/discstatus.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/retroshare-gui/src/gui/statusbar/discstatus.cpp b/retroshare-gui/src/gui/statusbar/discstatus.cpp index a64528c0b..32ee8c777 100644 --- a/retroshare-gui/src/gui/statusbar/discstatus.cpp +++ b/retroshare-gui/src/gui/statusbar/discstatus.cpp @@ -66,10 +66,10 @@ void DiscStatus::update() return; } - unsigned int sendCount = 0; - unsigned int recvCount = 0; + size_t sendCount = 0; + size_t recvCount = 0; - rsDisc->getWaitingDiscCount(&sendCount, &recvCount); + rsDisc->getWaitingDiscCount(sendCount, recvCount); sendLabel->setText(QString::number(sendCount)); recvLabel->setText(QString::number(recvCount)); From 9306d8ccc8a2754089cc3d60a02595b5670c4eb9 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sat, 8 Sep 2018 08:58:42 +0200 Subject: [PATCH 5/9] drop deprecated function --- libretroshare/src/retroshare/rsdisc.h | 9 --------- libretroshare/src/services/p3discovery2.cc | 22 ---------------------- libretroshare/src/services/p3discovery2.h | 2 -- 3 files changed, 33 deletions(-) diff --git a/libretroshare/src/retroshare/rsdisc.h b/libretroshare/src/retroshare/rsdisc.h index 2e1420908..04af7165c 100644 --- a/libretroshare/src/retroshare/rsdisc.h +++ b/libretroshare/src/retroshare/rsdisc.h @@ -79,15 +79,6 @@ class RsDisc * @return true on success false otherwise */ virtual bool getWaitingDiscCount(size_t &sendCount, size_t &recvCount) = 0; - - /** - * @brief getWaitingDiscCount get the number of queued discovery packets. - * @param[out] sendCount number of queued outgoing packets - * @param[out] recvCount number of queued incoming packets - * @return true on success false otherwise - */ - RS_DEPRECATED - virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount) = 0; }; #endif diff --git a/libretroshare/src/services/p3discovery2.cc b/libretroshare/src/services/p3discovery2.cc index 05fa7a982..ea659bd0d 100644 --- a/libretroshare/src/services/p3discovery2.cc +++ b/libretroshare/src/services/p3discovery2.cc @@ -1247,28 +1247,6 @@ bool p3discovery2::setPeerVersion(const SSLID &peerId, const std::string &versio } -bool p3discovery2::getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount) -{ - if (sendCount == NULL && recvCount == NULL) { - /* Nothing to do */ - return false; - } - - size_t send, recv; - getWaitingDiscCount(send, recv); - - if (sendCount) { - *sendCount = send; - } - - if (recvCount) { - *recvCount = recv; - } - return true; -} - - - /*************************************************************************************/ /* AuthGPGService */ /*************************************************************************************/ diff --git a/libretroshare/src/services/p3discovery2.h b/libretroshare/src/services/p3discovery2.h index a31137f5a..8b9d1e7ff 100644 --- a/libretroshare/src/services/p3discovery2.h +++ b/libretroshare/src/services/p3discovery2.h @@ -91,8 +91,6 @@ virtual RsServiceInfo getServiceInfo(); bool getDiscPgpFriends(const RsPgpId &pgpid, std::list &gpg_friends); bool getPeerVersion(const RsPeerId &id, std::string &version); bool getWaitingDiscCount(size_t &sendCount, size_t &recvCount); - bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount); - /************* from AuthGPService ****************/ virtual AuthGPGOperation *getGPGOperation(); virtual void setGPGOperation(AuthGPGOperation *operation); From 31b0f67e946a1f7c06f5d1a4699d40df1f899308 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sat, 8 Sep 2018 09:47:45 +0200 Subject: [PATCH 6/9] jsonfy RsServiceControl --- .../src/retroshare/rsservicecontrol.h | 131 +++++++++++++++--- 1 file changed, 108 insertions(+), 23 deletions(-) diff --git a/libretroshare/src/retroshare/rsservicecontrol.h b/libretroshare/src/retroshare/rsservicecontrol.h index 1e22449ae..22aff5084 100644 --- a/libretroshare/src/retroshare/rsservicecontrol.h +++ b/libretroshare/src/retroshare/rsservicecontrol.h @@ -31,11 +31,15 @@ /* The Main Interface Class - for information about your Peers */ class RsServiceControl; + +/** + * Pointer to global instance of RsServiceControl service implementation + * @jsonapi{development} + */ extern RsServiceControl *rsServiceControl; -class RsServiceInfo +struct RsServiceInfo : RsSerializable { - public: RsServiceInfo(); RsServiceInfo( const uint16_t service_type, @@ -45,6 +49,8 @@ class RsServiceInfo const uint16_t min_version_major, const uint16_t min_version_minor); + static unsigned int RsServiceInfoUIn16ToFullServiceId(uint16_t serviceType); + std::string mServiceName; uint32_t mServiceType; // current version, we running. @@ -54,32 +60,42 @@ class RsServiceInfo uint16_t mMinVersionMajor; uint16_t mMinVersionMinor; - static unsigned int RsServiceInfoUIn16ToFullServiceId(uint16_t serviceType); + // RsSerializable interface +public: + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(mServiceName); + RS_SERIAL_PROCESS(mServiceType); + RS_SERIAL_PROCESS(mVersionMajor); + RS_SERIAL_PROCESS(mVersionMinor); + RS_SERIAL_PROCESS(mMinVersionMajor); + RS_SERIAL_PROCESS(mMinVersionMinor); + } }; - bool ServiceInfoCompatible(const RsServiceInfo &info1, const RsServiceInfo &info2); - - /* this is what is transmitted to peers */ -class RsPeerServiceInfo +struct RsPeerServiceInfo : RsSerializable { - public: - RsPeerServiceInfo() - :mPeerId(), mServiceList() { return; } + RsPeerServiceInfo() : mPeerId(), mServiceList() {} - RsPeerId mPeerId; + RsPeerId mPeerId; std::map mServiceList; + + // RsSerializable interface +public: + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(mPeerId); + RS_SERIAL_PROCESS(mServiceList); + } }; std::ostream &operator<<(std::ostream &out, const RsPeerServiceInfo &info); std::ostream &operator<<(std::ostream &out, const RsServiceInfo &info); -class RsServicePermissions +struct RsServicePermissions : RsSerializable { -public: RsServicePermissions(); bool peerHasPermission(const RsPeerId &peerId) const; @@ -96,26 +112,95 @@ public: // if DefaultAllowed = false, then only PeersAllowed is checked. std::set mPeersAllowed; std::set mPeersDenied; + + // RsSerializable interface +public: + void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { + RS_SERIAL_PROCESS(mServiceId); + RS_SERIAL_PROCESS(mServiceName); + + RS_SERIAL_PROCESS(mDefaultAllowed); + + RS_SERIAL_PROCESS(mPeersAllowed); + RS_SERIAL_PROCESS(mPeersDenied); + } }; class RsServiceControl { - public: +public: RsServiceControl() { return; } -virtual ~RsServiceControl() { return; } + virtual ~RsServiceControl() { return; } -virtual bool getOwnServices(RsPeerServiceInfo &info) = 0; -virtual std::string getServiceName(uint32_t service_id) = 0; -virtual bool getServiceItemNames(uint32_t service_id,std::map& names) = 0; + /** + * @brief getOwnServices return a map off all services. + * @jsonapi{development} + * @param[out] info + * @return always true + */ + virtual bool getOwnServices(RsPeerServiceInfo &info) = 0; -virtual bool getServicesAllowed(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0; -virtual bool getServicesProvided(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0; -virtual bool getServicePermissions(uint32_t serviceId, RsServicePermissions &permissions) = 0; -virtual bool updateServicePermissions(uint32_t serviceId, const RsServicePermissions &permissions) = 0; + /** + * @brief getServiceName lookup the name of a service. + * @jsonapi{development} + * @param[in] service_id service to look up + * @return name of service + */ + virtual std::string getServiceName(uint32_t service_id) = 0; -virtual void getPeersConnected(const uint32_t serviceId, std::set &peerSet) = 0; + /** + * @brief getServiceItemNames return a map of service item names. + * @jsonapi{development} + * @param[in] service_id service to look up + * @param[out] names names of items + * @return true on success false otherwise + */ + virtual bool getServiceItemNames(uint32_t service_id,std::map& names) = 0; + /** + * @brief getServicesAllowed return a mpa with allowed service information. + * @jsonapi{development} + * @param[in] peerId peer to look up + * @param[out] info map with infomration + * @return always true + */ + virtual bool getServicesAllowed(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0; + + /** + * @brief getServicesProvided return services provided by a peer. + * @jsonapi{development} + * @param[in] peerId peer to look up + * @param[out] info + * @return true on success false otherwise. + */ + virtual bool getServicesProvided(const RsPeerId &peerId, RsPeerServiceInfo &info) = 0; + + /** + * @brief getServicePermissions return permissions of one service. + * @jsonapi{development} + * @param[in] serviceId service id to look up + * @param[out] permissions + * @return true on success false otherwise. + */ + virtual bool getServicePermissions(uint32_t serviceId, RsServicePermissions &permissions) = 0; + + /** + * @brief updateServicePermissions update service permissions of one service. + * @jsonapi{development} + * @param[in] serviceId service to update + * @param[in] permissions new permissions + * @return true on success false otherwise. + */ + virtual bool updateServicePermissions(uint32_t serviceId, const RsServicePermissions &permissions) = 0; + + /** + * @brief getPeersConnected return peers using a service. + * @jsonapi{development} + * @param[in] serviceId service to look up. + * @param[out] peerSet set of peers using this service. + */ + virtual void getPeersConnected(const uint32_t serviceId, std::set &peerSet) = 0; }; #endif From 5a961179f3519e91e668234f344f49fb071a2dd2 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sat, 8 Sep 2018 09:48:27 +0200 Subject: [PATCH 7/9] unify parameter names --- libretroshare/src/retroshare/rsservicecontrol.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/retroshare/rsservicecontrol.h b/libretroshare/src/retroshare/rsservicecontrol.h index 22aff5084..3dcff5f70 100644 --- a/libretroshare/src/retroshare/rsservicecontrol.h +++ b/libretroshare/src/retroshare/rsservicecontrol.h @@ -147,7 +147,7 @@ public: * @param[in] service_id service to look up * @return name of service */ - virtual std::string getServiceName(uint32_t service_id) = 0; + virtual std::string getServiceName(uint32_t serviceId) = 0; /** * @brief getServiceItemNames return a map of service item names. @@ -156,7 +156,7 @@ public: * @param[out] names names of items * @return true on success false otherwise */ - virtual bool getServiceItemNames(uint32_t service_id,std::map& names) = 0; + virtual bool getServiceItemNames(uint32_t serviceId, std::map& names) = 0; /** * @brief getServicesAllowed return a mpa with allowed service information. From ae6a5c74d2bae5fc867f37c53cbc9af504667659 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sat, 8 Sep 2018 16:46:28 +0200 Subject: [PATCH 8/9] add rsPeer groups to jsonapi --- libretroshare/src/retroshare/rspeers.h | 64 +++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index 2fc26046f..bd1dbf357 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -600,14 +600,76 @@ public: virtual bool trustGPGCertificate(const RsPgpId &gpg_id, uint32_t trustlvl) = 0; /* Group Stuff */ + /** + * @brief addGroup create a new group + * @jsonapi{development} + * @param[in] groupInfo + * @return + */ virtual bool addGroup(RsGroupInfo& groupInfo) = 0; + + /** + * @brief editGroup edit an existing group + * @jsonapi{development} + * @param[in] groupId + * @param[in] groupInfo + * @return + */ virtual bool editGroup(const RsNodeGroupId& groupId, RsGroupInfo& groupInfo) = 0; + + /** + * @brief removeGroup remove a group + * @jsonapi{development} + * @param[in] groupId + * @return + */ virtual bool removeGroup(const RsNodeGroupId& groupId) = 0; + + /** + * @brief getGroupInfo get group information to one group + * @jsonapi{development} + * @param[in] groupId + * @param[out] groupInfo + * @return + */ virtual bool getGroupInfo(const RsNodeGroupId& groupId, RsGroupInfo& groupInfo) = 0; - virtual bool getGroupInfoByName(const std::string& groupId, RsGroupInfo& groupInfo) = 0; + + /** + * @brief getGroupInfoByName get group information by group name + * @jsonapi{development} + * @param[in] groupName + * @param[out] groupInfo + * @return + */ + virtual bool getGroupInfoByName(const std::string& groupName, RsGroupInfo& groupInfo) = 0; + + /** + * @brief getGroupInfoList get list of all groups + * @jsonapi{development} + * @param[out] groupInfoList + * @return + */ virtual bool getGroupInfoList(std::list& groupInfoList) = 0; + // groupId == "" && assign == false -> remove from all groups + /** + * @brief assignPeerToGroup add a peer to a group + * @jsonapi{development} + * @param[in] groupId + * @param[in] peerId + * @param[in] assign true to assign a peer, false to remove a peer + * @return + */ virtual bool assignPeerToGroup(const RsNodeGroupId& groupId, const RsPgpId& peerId, bool assign) = 0; + + /** + * @brief assignPeersToGroup add a list of peers to a group + * @jsonapi{development} + * @param[in] groupId + * @param[in] peerIds + * @param[in] assign true to assign a peer, false to remove a peer + * @return + */ virtual bool assignPeersToGroup(const RsNodeGroupId& groupId, const std::list& peerIds, bool assign) = 0; /* Group sharing permission */ From 247c368279f3df7bc9cd39952462ec4384231f62 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sun, 9 Sep 2018 22:21:18 +0200 Subject: [PATCH 9/9] incorporated requested changes --- libretroshare/src/retroshare/rsconfig.h | 27 +++++-------------- libretroshare/src/retroshare/rsdisc.h | 4 +-- .../src/retroshare/rsservicecontrol.h | 7 ++--- libretroshare/src/services/p3discovery2.cc | 2 +- 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/libretroshare/src/retroshare/rsconfig.h b/libretroshare/src/retroshare/rsconfig.h index f977ec8a4..f81ff780a 100644 --- a/libretroshare/src/retroshare/rsconfig.h +++ b/libretroshare/src/retroshare/rsconfig.h @@ -136,23 +136,13 @@ int promptAtBoot; /* popup the password prompt */ struct RsConfigDataRates : RsSerializable { - RsConfigDataRates() - { - mRateIn = 0; - mRateMaxIn = 0; - mAllocIn = 0; - - mAllocTs = 0; - - mRateOut = 0; - mRateMaxOut = 0; - mAllowedOut = 0; - - mAllowedTs = 0; - - mQueueIn = 0; - mQueueOut = 0; - } + RsConfigDataRates() : + mRateIn(0), mRateMaxIn(0), mAllocIn(0), + mAllocTs(0), + mRateOut(0), mRateMaxOut(0), mAllowedOut(0), + mAllowedTs(0), + mQueueIn(0), mQueueOut(0) + {} /* all in kB/s */ float mRateIn; @@ -171,7 +161,6 @@ struct RsConfigDataRates : RsSerializable int mQueueOut; // RsSerializable interface -public: void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { RS_SERIAL_PROCESS(mRateIn); RS_SERIAL_PROCESS(mRateMaxIn); @@ -204,7 +193,6 @@ struct RSTrafficClue : RsSerializable RSTrafficClue& operator+=(const RSTrafficClue& tc) { size += tc.size; count += tc.count ; return *this ;} // RsSerializable interface -public: void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { RS_SERIAL_PROCESS(TS); RS_SERIAL_PROCESS(size); @@ -257,7 +245,6 @@ struct RsConfigNetStatus : RsSerializable uint32_t netDhtRsNetSize;/* response from dht */ // RsSerializable interface -public: void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { RS_SERIAL_PROCESS(ownId); RS_SERIAL_PROCESS(ownName); diff --git a/libretroshare/src/retroshare/rsdisc.h b/libretroshare/src/retroshare/rsdisc.h index 04af7165c..aedb5f9f7 100644 --- a/libretroshare/src/retroshare/rsdisc.h +++ b/libretroshare/src/retroshare/rsdisc.h @@ -41,8 +41,8 @@ class RsDisc { public: - RsDisc() { return; } - virtual ~RsDisc() { return; } + RsDisc() {} + virtual ~RsDisc() {} /** * @brief getDiscFriends get a list with all friends (ssl id) to a given friend (ssl id) diff --git a/libretroshare/src/retroshare/rsservicecontrol.h b/libretroshare/src/retroshare/rsservicecontrol.h index 3dcff5f70..57511be4c 100644 --- a/libretroshare/src/retroshare/rsservicecontrol.h +++ b/libretroshare/src/retroshare/rsservicecontrol.h @@ -61,7 +61,6 @@ struct RsServiceInfo : RsSerializable uint16_t mMinVersionMinor; // RsSerializable interface -public: void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { RS_SERIAL_PROCESS(mServiceName); RS_SERIAL_PROCESS(mServiceType); @@ -83,7 +82,6 @@ struct RsPeerServiceInfo : RsSerializable std::map mServiceList; // RsSerializable interface -public: void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { RS_SERIAL_PROCESS(mPeerId); RS_SERIAL_PROCESS(mServiceList); @@ -114,7 +112,6 @@ struct RsServicePermissions : RsSerializable std::set mPeersDenied; // RsSerializable interface -public: void serial_process(RsGenericSerializer::SerializeJob j, RsGenericSerializer::SerializeContext &ctx) { RS_SERIAL_PROCESS(mServiceId); RS_SERIAL_PROCESS(mServiceName); @@ -130,8 +127,8 @@ class RsServiceControl { public: - RsServiceControl() { return; } - virtual ~RsServiceControl() { return; } + RsServiceControl() {} + virtual ~RsServiceControl(){} /** * @brief getOwnServices return a map off all services. diff --git a/libretroshare/src/services/p3discovery2.cc b/libretroshare/src/services/p3discovery2.cc index ea659bd0d..7642fb4d3 100644 --- a/libretroshare/src/services/p3discovery2.cc +++ b/libretroshare/src/services/p3discovery2.cc @@ -1179,7 +1179,7 @@ bool p3discovery2::getDiscFriends(const RsPeerId& id, std::list &proxy bool p3discovery2::getWaitingDiscCount(size_t &sendCount, size_t &recvCount) { - RsStackMutex stack(mDiscMtx); /********** STACK LOCKED MTX ******/ + RS_STACK_MUTEX(mDiscMtx); sendCount = mPendingDiscPgpCertOutList.size(); recvCount = mPendingDiscPgpCertInList.size();