From 923c383a1312735a9e73580acf4242ec2ba140fc Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Fri, 2 Mar 2018 19:20:56 +0100 Subject: [PATCH 01/50] Add naif URL manipulation class RsUrl Use RsUrl to convert sockaddre_storage from/to string --- libretroshare/src/libretroshare.pro | 6 +- libretroshare/src/util/rsnet.h | 1 + libretroshare/src/util/rsnet_ss.cc | 31 ++-- libretroshare/src/util/rsurl.cc | 258 ++++++++++++++++++++++++++++ libretroshare/src/util/rsurl.h | 101 +++++++++++ 5 files changed, 383 insertions(+), 14 deletions(-) create mode 100644 libretroshare/src/util/rsurl.cc create mode 100644 libretroshare/src/util/rsurl.h diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index c2604fa4a..5ec795d3d 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -550,7 +550,8 @@ HEADERS += util/folderiterator.h \ util/rstime.h \ util/stacktrace.h \ util/rsdeprecate.h \ - util/cxx11retrocompat.h + util/cxx11retrocompat.h \ + util/rsurl.h SOURCES += ft/ftchunkmap.cc \ ft/ftcontroller.cc \ @@ -695,7 +696,8 @@ SOURCES += util/folderiterator.cc \ util/rsrandom.cc \ util/rstickevent.cc \ util/rsrecogn.cc \ - util/rstime.cc + util/rstime.cc \ + util/rsurl.cc upnp_miniupnpc { diff --git a/libretroshare/src/util/rsnet.h b/libretroshare/src/util/rsnet.h index 1d028e991..95887e61a 100644 --- a/libretroshare/src/util/rsnet.h +++ b/libretroshare/src/util/rsnet.h @@ -133,6 +133,7 @@ bool sockaddr_storage_sameip(const struct sockaddr_storage &addr, const struct s // string, std::string sockaddr_storage_tostring(const struct sockaddr_storage &addr); +bool sockaddr_storage_fromString(const std::string& str, sockaddr_storage &addr); std::string sockaddr_storage_familytostring(const struct sockaddr_storage &addr); std::string sockaddr_storage_iptostring(const struct sockaddr_storage &addr); std::string sockaddr_storage_porttostring(const struct sockaddr_storage &addr); diff --git a/libretroshare/src/util/rsnet_ss.cc b/libretroshare/src/util/rsnet_ss.cc index 581fd06e9..65f2f3ee7 100644 --- a/libretroshare/src/util/rsnet_ss.cc +++ b/libretroshare/src/util/rsnet_ss.cc @@ -24,6 +24,8 @@ * */ +#include "util/rsurl.h" + #include #include #include @@ -491,27 +493,32 @@ bool sockaddr_storage_sameip(const struct sockaddr_storage &addr, const struct s std::string sockaddr_storage_tostring(const struct sockaddr_storage &addr) { - std::string output; - output += sockaddr_storage_familytostring(addr); + RsUrl url; switch(addr.ss_family) { case AF_INET: - output += "="; - output += sockaddr_storage_iptostring(addr); - output += ":"; - output += sockaddr_storage_porttostring(addr); + url.setScheme("ipv4"); break; case AF_INET6: - output += "=["; - output += sockaddr_storage_iptostring(addr); - output += "]:"; - output += sockaddr_storage_porttostring(addr); + url.setScheme("ipv6"); break; default: - break; + return "INVALID_IP"; } - return output; + + url.setHost(sockaddr_storage_iptostring(addr)) + .setPort(sockaddr_storage_port(addr)); + + return url.toString(); +} + +bool sockaddr_storage_fromString(const std::string& str, sockaddr_storage &addr) +{ + RsUrl url(str); + bool valid = sockaddr_storage_inet_pton(addr, url.host()); + if(url.hasPort()) sockaddr_storage_setport(addr, url.port()); + return valid; } void sockaddr_storage_dump(const sockaddr_storage & addr, std::string * outputString) diff --git a/libretroshare/src/util/rsurl.cc b/libretroshare/src/util/rsurl.cc new file mode 100644 index 000000000..31922abbf --- /dev/null +++ b/libretroshare/src/util/rsurl.cc @@ -0,0 +1,258 @@ +/* + * RetroShare + * Copyright (C) 2018 Gioacchino Mazzurco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +//#include "util/rsurl.h" +#include "rsurl.h" + +#include +#include +#include +#include +#include + +using namespace std; + +RsUrl::RsUrl() : mPort(0), mHasPort(false) {} + +RsUrl::RsUrl(const std::string& urlStr) : mPort(0), mHasPort(false) +{ fromString(urlStr); } + +RsUrl& RsUrl::fromString(const std::string& urlStr) +{ + size_t urlSize = urlStr.size(); + + size_t schemeEndI = urlStr.find(schemeSeparator); + if(schemeEndI == string::npos) + { + mScheme = urlStr; + return *this; + } + + mScheme = urlStr.substr(0, schemeEndI); + + size_t hostBeginI = schemeEndI + 3; + if(hostBeginI >= urlSize) return *this; + + bool hasSquareBr = (urlStr[hostBeginI] == ipv6WrapOpen[0]); + size_t hostEndI; + if(hasSquareBr) + { + if(++hostBeginI >= urlSize) return *this; + hostEndI = urlStr.find(ipv6WrapClose, hostBeginI); + mHost = urlStr.substr(hostBeginI, hostEndI - hostBeginI - 1); + } + else + { + hostEndI = urlStr.find(pathSeparator, hostBeginI); + hostEndI = min(hostEndI, urlStr.find(portSeparator, hostBeginI)); + hostEndI = min(hostEndI, urlStr.find(querySeparator, hostBeginI)); + hostEndI = min(hostEndI, urlStr.find(fragmentSeparator, hostBeginI)); + + mHost = urlStr.substr(hostBeginI, hostEndI - hostBeginI); + if(hostEndI == string::npos) return *this; + } + + mHasPort = (sscanf(&urlStr[hostEndI], ":%hu", &mPort) == 1); + + size_t pathBeginI = urlStr.find(pathSeparator, hostEndI); + size_t pathEndI = string::npos; + if(pathBeginI != string::npos) + { + pathEndI = urlStr.find(querySeparator, pathBeginI); + pathEndI = min(pathEndI, urlStr.find(fragmentSeparator, pathBeginI)); + mPath = UrlDecode(urlStr.substr(pathBeginI, pathEndI - pathBeginI)); + if(pathEndI == string::npos) return *this; + } + + size_t queryBeginI = urlStr.find(querySeparator, schemeEndI); + size_t queryEndI = urlStr.find(fragmentSeparator, schemeEndI); + if(queryBeginI != string::npos) + { + string qStr = urlStr.substr(queryBeginI+1, queryEndI-queryBeginI-1); + + size_t kPos = 0; + size_t assPos = qStr.find(queryAssign); + do + { + size_t vEndPos = qStr.find(queryFieldSep, assPos); + mQuery.insert( std::make_pair( qStr.substr(kPos, assPos-kPos), + UrlDecode(qStr.substr(assPos+1, vEndPos-assPos-1)) + ) ); + kPos = vEndPos+1; + assPos = qStr.find(queryAssign, vEndPos); + } + while(assPos != string::npos); + + if(queryEndI == string::npos) return *this; + } + + size_t fragmentBeginI = urlStr.find(fragmentSeparator, schemeEndI); + if(fragmentBeginI != string::npos) + mFragment = UrlDecode(urlStr.substr(++fragmentBeginI)); +} + +std::string RsUrl::toString() const +{ + std::string urlStr(mScheme); + urlStr += schemeSeparator; + + if(!mHost.empty()) + { + if(mHost.find(ipv6Separator) != string::npos && + mHost[0] != ipv6WrapOpen[0] ) + urlStr += ipv6WrapOpen + mHost + ipv6WrapClose; + else urlStr += mHost; + } + + if(mHasPort) urlStr += portSeparator + std::to_string(mPort); + + urlStr += UrlEncode(mPath, pathSeparator); + + bool hasQuery = !mQuery.empty(); + if(hasQuery) urlStr += querySeparator; + for(auto&& kv : mQuery) + { + urlStr += kv.first; + urlStr += queryAssign; + urlStr += UrlEncode(kv.second); + urlStr += queryFieldSep; + } + if(hasQuery) urlStr.pop_back(); + + if(!mFragment.empty()) urlStr += fragmentSeparator + UrlEncode(mFragment); + + return urlStr; +} + +const std::string& RsUrl::scheme() const { return mScheme; } +RsUrl& RsUrl::setScheme(const std::string& scheme) +{ + mScheme = scheme; + return *this; +} + +const std::string& RsUrl::host() const { return mHost; } +RsUrl& RsUrl::setHost(const std::string& host) +{ + mHost = host; + return *this; +} + +bool RsUrl::hasPort() const { return mHasPort; } + +uint16_t RsUrl::port(uint16_t def) const +{ + if(mHasPort) return mPort; + return def; +} + +RsUrl& RsUrl::setPort(uint16_t port) +{ + mPort = port; + return *this; +} + +const std::string& RsUrl::path() const { return mPath; } +RsUrl& RsUrl::setPath(const std::string& path) +{ + mPath = path; + return *this; +} + +const std::map& RsUrl::query() const +{ return mQuery; } +RsUrl& RsUrl::setQuery(const std::map& query) +{ + mQuery = query; + return *this; +} +RsUrl& RsUrl::setQueryKV(const std::string& key, const std::string& value) +{ + mQuery.insert(std::make_pair(key, value)); + return *this; +} +RsUrl& RsUrl::delQueryK(const std::string& key) +{ + mQuery.erase(key); + return *this; +} + +const std::string& RsUrl::fragment() const { return mFragment; } +RsUrl& RsUrl::setFragment(const std::string& fragment) +{ + mFragment = fragment; + return *this; +} + +/*static*/ std::string RsUrl::UrlEncode( const std::string& str, + const std::string& ignore ) +{ + ostringstream escaped; + escaped.fill('0'); + escaped << hex; + + for (string::value_type c : str) + { + // Keep alphanumeric and other accepted characters intact + if ( isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~' + || ignore.find(c) != string::npos ) + { + escaped << c; + continue; + } + + // Any other characters are percent-encoded + escaped << uppercase; + escaped << '%' << setw(2) << int((unsigned char) c); + escaped << nouppercase; + } + + return escaped.str(); +} + +/*static*/ std::string RsUrl::UrlDecode(const std::string& str) +{ + ostringstream decoded; + + size_t len = str.size(); + size_t boundary = len-2; // % Encoded char must be at least 2 hex char + for (size_t i = 0; i < len; ++i) + { + + if(str[i] == '%' && i < boundary) + { + decoded << static_cast(stoi(str.substr(++i, 2), 0, 16)); + ++i; + } + else decoded << str[i]; + } + + return decoded.str(); +} + +/*static*/ const std::string RsUrl::schemeSeparator("://"); +/*static*/ const std::string RsUrl::ipv6WrapOpen("["); +/*static*/ const std::string RsUrl::ipv6Separator(":"); +/*static*/ const std::string RsUrl::ipv6WrapClose("]"); +/*static*/ const std::string RsUrl::portSeparator(":"); +/*static*/ const std::string RsUrl::pathSeparator("/"); +/*static*/ const std::string RsUrl::querySeparator("?"); +/*static*/ const std::string RsUrl::queryAssign("="); +/*static*/ const std::string RsUrl::queryFieldSep("&"); +/*static*/ const std::string RsUrl::fragmentSeparator("#"); + diff --git a/libretroshare/src/util/rsurl.h b/libretroshare/src/util/rsurl.h new file mode 100644 index 000000000..fc9d2992b --- /dev/null +++ b/libretroshare/src/util/rsurl.h @@ -0,0 +1,101 @@ +#pragma once +/* + * RetroShare + * Copyright (C) 2018 Gioacchino Mazzurco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include +#include + +/** + * Very simplistic and minimal URL helper class for RetroShare, after looking + * for a small and self-contained C/C++ URL parsing and manipulation library, + * haven't found nothing satisfactory except for implementation like QUrl that + * rely on bigger library. + * ATM this implementation is not standard compliant and doesn't aim to be. + * Improvements to this are welcome. + * + * Anyway this should support most common URLs of the form + * scheme://host[:port][/path][?query][#fragment] + */ +struct RsUrl +{ + RsUrl(); + RsUrl(const std::string& urlStr); + + RsUrl& fromString(const std::string& urlStr); + std::string toString() const; + + const std::string& scheme() const; + RsUrl& setScheme(const std::string& scheme); + + const std::string& host() const; + RsUrl& setHost(const std::string& host); + + bool hasPort() const; + uint16_t port(uint16_t def = 0) const; + RsUrl& setPort(uint16_t port); + + const std::string& path() const; + RsUrl& setPath(const std::string& path); + + const std::map& query() const; + RsUrl& setQuery(const std::map& query); + RsUrl& setQueryKV(const std::string& key, const std::string& value); + RsUrl& delQueryK(const std::string& key); + + const std::string& fragment() const; + RsUrl& setFragment(const std::string& fragment); + + static std::string UrlEncode(const std::string& str, + const std::string& ignoreChars = ""); + static std::string UrlDecode(const std::string& str); + + inline bool operator<(const RsUrl& rhs) + { return toString() < rhs.toString(); } + inline bool operator>(const RsUrl& rhs) + { return toString() > rhs.toString(); } + inline bool operator<=(const RsUrl& rhs) + { return toString() <= rhs.toString(); } + inline bool operator>=(const RsUrl& rhs) + { return toString() >= rhs.toString(); } + inline bool operator==(const RsUrl& rhs) + { return toString() == rhs.toString(); } + inline bool operator!=(const RsUrl& rhs) + { return toString() != rhs.toString(); } + + static const std::string schemeSeparator; + static const std::string ipv6WrapOpen; + static const std::string ipv6Separator; + static const std::string ipv6WrapClose; + static const std::string portSeparator; + static const std::string pathSeparator; + static const std::string querySeparator; + static const std::string queryAssign; + static const std::string queryFieldSep; + static const std::string fragmentSeparator; + +private: + + std::string mScheme; + std::string mHost; + uint16_t mPort; + bool mHasPort; + std::string mPath; + std::map mQuery; + std::string mFragment; +}; + From 8542abd4f09e0f63bee6a06ef0b4ad64f6e45b80 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Fri, 2 Mar 2018 20:08:50 +0100 Subject: [PATCH 02/50] Few fixes in RsUrl --- libretroshare/src/util/rsurl.cc | 9 +++++++-- libretroshare/src/util/rsurl.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/util/rsurl.cc b/libretroshare/src/util/rsurl.cc index 31922abbf..3f28a607d 100644 --- a/libretroshare/src/util/rsurl.cc +++ b/libretroshare/src/util/rsurl.cc @@ -154,16 +154,21 @@ RsUrl& RsUrl::setHost(const std::string& host) } bool RsUrl::hasPort() const { return mHasPort; } - uint16_t RsUrl::port(uint16_t def) const { if(mHasPort) return mPort; return def; } - RsUrl& RsUrl::setPort(uint16_t port) { mPort = port; + mHasPort = true; + return *this; +} +RsUrl& RsUrl::unsetPort() +{ + mPort = 0; + mHasPort = false; return *this; } diff --git a/libretroshare/src/util/rsurl.h b/libretroshare/src/util/rsurl.h index fc9d2992b..6125efba5 100644 --- a/libretroshare/src/util/rsurl.h +++ b/libretroshare/src/util/rsurl.h @@ -48,6 +48,7 @@ struct RsUrl bool hasPort() const; uint16_t port(uint16_t def = 0) const; RsUrl& setPort(uint16_t port); + RsUrl& unsetPort(); const std::string& path() const; RsUrl& setPath(const std::string& path); From bed856425fbfe83e0c3dc3e372d73dc3b32d6031 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sat, 3 Mar 2018 00:08:56 +0100 Subject: [PATCH 03/50] Share additional addresses via RsCertificate --- libresapi/src/api/PeersHandler.cpp | 5 + libretroshare/src/pgp/rscertificate.cc | 235 ++++++++++-------- libretroshare/src/pgp/rscertificate.h | 25 +- libretroshare/src/pqi/p3peermgr.cc | 62 ++++- libretroshare/src/pqi/p3peermgr.h | 2 + libretroshare/src/retroshare/rspeers.h | 2 + libretroshare/src/rsserver/p3peers.cc | 16 +- libretroshare/src/rsserver/p3peers.h | 4 +- libretroshare/src/util/rsnet_ss.cc | 11 +- libretroshare/src/util/rsurl.cc | 34 +-- libretroshare/src/util/rsurl.h | 12 +- retroshare-gui/src/gui/common/FriendList.cpp | 4 + .../src/gui/connect/ConnectFriendWizard.cpp | 4 + 13 files changed, 267 insertions(+), 149 deletions(-) diff --git a/libresapi/src/api/PeersHandler.cpp b/libresapi/src/api/PeersHandler.cpp index 66def7eab..f812a54f4 100644 --- a/libresapi/src/api/PeersHandler.cpp +++ b/libresapi/src/api/PeersHandler.cpp @@ -727,6 +727,11 @@ void PeersHandler::handleWildcard(Request &req, Response &resp) peerDetails.localPort ); if (!peerDetails.dyndns.empty()) mRsPeers->setDynDNS(peerDetails.id, peerDetails.dyndns); + for(auto&& ipr : peerDetails.ipAddressList) + mRsPeers->addPeerLocator( + peerDetails.id, + RsUrl(ipr.substr(0, ipr.find(' '))) ); + } } while(false); diff --git a/libretroshare/src/pgp/rscertificate.cc b/libretroshare/src/pgp/rscertificate.cc index 70a00328f..08ea78a31 100644 --- a/libretroshare/src/pgp/rscertificate.cc +++ b/libretroshare/src/pgp/rscertificate.cc @@ -1,3 +1,23 @@ +/* + * RetroShare + * + * Copyright (C) 2012-2014 Cyril Soler + * Copyright (C) 2018 Gioacchino Mazzurco + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + #include #include #include @@ -11,25 +31,21 @@ //#define DEBUG_RSCERTIFICATE -static const std::string PGP_CERTIFICATE_START ( "-----BEGIN PGP PUBLIC KEY BLOCK-----" ); -static const std::string PGP_CERTIFICATE_END ( "-----END PGP PUBLIC KEY BLOCK-----" ); -static const std::string EXTERNAL_IP_BEGIN_SECTION ( "--EXT--" ); -static const std::string LOCAL_IP_BEGIN_SECTION ( "--LOCAL--" ); -static const std::string SSLID_BEGIN_SECTION ( "--SSLID--" ); -static const std::string LOCATION_BEGIN_SECTION ( "--LOCATION--" ); -static const std::string HIDDEN_NODE_BEGIN_SECTION ( "--HIDDEN--" ); +static const uint8_t CERTIFICATE_VERSION_06 = 0x06; -static const uint8_t CERTIFICATE_PTAG_PGP_SECTION = 0x01 ; -static const uint8_t CERTIFICATE_PTAG_EXTIPANDPORT_SECTION = 0x02 ; -static const uint8_t CERTIFICATE_PTAG_LOCIPANDPORT_SECTION = 0x03 ; -static const uint8_t CERTIFICATE_PTAG_DNS_SECTION = 0x04 ; -static const uint8_t CERTIFICATE_PTAG_SSLID_SECTION = 0x05 ; -static const uint8_t CERTIFICATE_PTAG_NAME_SECTION = 0x06 ; -static const uint8_t CERTIFICATE_PTAG_CHECKSUM_SECTION = 0x07 ; -static const uint8_t CERTIFICATE_PTAG_HIDDENNODE_SECTION = 0x08 ; -static const uint8_t CERTIFICATE_PTAG_VERSION_SECTION = 0x09 ; - -static const uint8_t CERTIFICATE_VERSION_06 = 0x06 ; +enum CertificatePtag : uint8_t +{ + CERTIFICATE_PTAG_PGP_SECTION = 0x01, + CERTIFICATE_PTAG_EXTIPANDPORT_SECTION = 0x02, + CERTIFICATE_PTAG_LOCIPANDPORT_SECTION = 0x03, + CERTIFICATE_PTAG_DNS_SECTION = 0x04, + CERTIFICATE_PTAG_SSLID_SECTION = 0x05, + CERTIFICATE_PTAG_NAME_SECTION = 0x06, + CERTIFICATE_PTAG_CHECKSUM_SECTION = 0x07, + CERTIFICATE_PTAG_HIDDENNODE_SECTION = 0x08, + CERTIFICATE_PTAG_VERSION_SECTION = 0x09, + CERTIFICATE_PTAG_EXTRA_LOCATOR = 10 +}; static bool is_acceptable_radix64Char(char c) { @@ -95,6 +111,14 @@ std::string RsCertificate::toStdString() const addPacket( CERTIFICATE_PTAG_NAME_SECTION , (unsigned char *)location_name.c_str() ,location_name.length() , buf, p, BS ) ; addPacket( CERTIFICATE_PTAG_SSLID_SECTION , location_id.toByteArray() ,location_id.SIZE_IN_BYTES, buf, p, BS ) ; + + for (const RsUrl& locator : mLocators) + { + std::string urlStr(locator.toString()); + addPacket( CERTIFICATE_PTAG_EXTRA_LOCATOR, + (unsigned char *) urlStr.c_str(), urlStr.size(), + buf, p, BS ); + } } uint32_t computed_crc = PGPKeyManagement::compute24bitsCRC(buf,p) ; @@ -195,7 +219,10 @@ RsCertificate::RsCertificate(const RsPeerDetails& Detail, const unsigned char *b memset(ipv4_external_ip_and_port,0,6) ; } - dns_name = Detail.dyndns ; + dns_name = Detail.dyndns; + + for(auto&& ipr : Detail.ipAddressList) + mLocators.insert(RsUrl(ipr.substr(0, ipr.find(' ')))); } } else @@ -254,19 +281,19 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code) std::vector bf = Radix64::decode(str) ; size_t size = bf.size(); - bool checksum_check_passed = false ; - unsigned char *buf = bf.data() ; - size_t total_s = 0 ; - only_pgp = true ; - uint8_t certificate_version = 0x00 ; + bool checksum_check_passed = false; + unsigned char *buf = bf.data(); + size_t total_s = 0; + only_pgp = true; + uint8_t certificate_version = 0x00; while(total_s < size) { uint8_t ptag = buf[0]; - buf = &buf[1] ; + buf = &buf[1]; - unsigned char *buf2 = buf ; - uint32_t s = PGPKeyParser::read_125Size(buf) ; + unsigned char *buf2 = buf; + uint32_t s = PGPKeyParser::read_125Size(buf); total_s += 1 + ((unsigned long)buf-(unsigned long)buf2) ; @@ -281,90 +308,80 @@ bool RsCertificate::initFromString(const std::string& instr,uint32_t& err_code) #endif switch(ptag) { - case CERTIFICATE_PTAG_VERSION_SECTION: certificate_version = buf[0] ; - buf = &buf[s] ; - break ; - - - case CERTIFICATE_PTAG_PGP_SECTION: binary_pgp_key = new unsigned char[s] ; - memcpy(binary_pgp_key,buf,s) ; - binary_pgp_key_size = s ; - buf = &buf[s] ; - break ; - - case CERTIFICATE_PTAG_NAME_SECTION: location_name = std::string((char *)buf,s) ; - buf = &buf[s] ; - break ; - - case CERTIFICATE_PTAG_SSLID_SECTION: - if(s != location_id.SIZE_IN_BYTES) - { - err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCATION_ID ; - return false ; - } - - location_id = RsPeerId(buf) ; - buf = &buf[s] ; - only_pgp = false ; - break ; - - case CERTIFICATE_PTAG_DNS_SECTION: dns_name = std::string((char *)buf,s) ; - buf = &buf[s] ; - break ; - - case CERTIFICATE_PTAG_HIDDENNODE_SECTION: - hidden_node_address = std::string((char *)buf,s); - hidden_node = true; - buf = &buf[s]; - - break ; - - case CERTIFICATE_PTAG_LOCIPANDPORT_SECTION: - if(s != 6) - - { - err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCAL_IP; - return false ; - } - - memcpy(ipv4_internal_ip_and_port,buf,s) ; - buf = &buf[s] ; - break ; - case CERTIFICATE_PTAG_EXTIPANDPORT_SECTION: - if(s != 6) - { - err_code = CERTIFICATE_PARSING_ERROR_INVALID_EXTERNAL_IP; - return false ; - } - - memcpy(ipv4_external_ip_and_port,buf,s) ; - buf = &buf[s] ; - break ; - case CERTIFICATE_PTAG_CHECKSUM_SECTION: - { - if(s != 3 || total_s+3 != size) - { - err_code = CERTIFICATE_PARSING_ERROR_INVALID_CHECKSUM_SECTION ; - return false ; - } - uint32_t computed_crc = PGPKeyManagement::compute24bitsCRC(bf.data(),size-5) ; - uint32_t certificate_crc = buf[0] + (buf[1] << 8) + (buf[2] << 16) ; - - if(computed_crc != certificate_crc) - { - err_code = CERTIFICATE_PARSING_ERROR_CHECKSUM_ERROR ; - return false ; - } - else - checksum_check_passed = true ; - } - break ; - default: - std::cerr << "(WW) unknwown PTAG 0x" << std::hex << ptag << std::dec << " in certificate! Ignoring it." << std::endl; - buf = &buf[s] ; - break ; + case CERTIFICATE_PTAG_VERSION_SECTION: + certificate_version = buf[0]; + break; + case CERTIFICATE_PTAG_PGP_SECTION: + binary_pgp_key = new unsigned char[s]; + memcpy(binary_pgp_key,buf,s); + binary_pgp_key_size = s; + break; + case CERTIFICATE_PTAG_NAME_SECTION: + location_name = std::string((char *)buf,s); + break; + case CERTIFICATE_PTAG_SSLID_SECTION: + if(s != location_id.SIZE_IN_BYTES) + { + err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCATION_ID; + return false; + } + location_id = RsPeerId(buf); + only_pgp = false; + break; + case CERTIFICATE_PTAG_DNS_SECTION: + dns_name = std::string((char *)buf,s); + break; + case CERTIFICATE_PTAG_HIDDENNODE_SECTION: + hidden_node_address = std::string((char *)buf,s); + hidden_node = true; + break; + case CERTIFICATE_PTAG_LOCIPANDPORT_SECTION: + if(s != 6) + { + err_code = CERTIFICATE_PARSING_ERROR_INVALID_LOCAL_IP; + return false; + } + memcpy(ipv4_internal_ip_and_port,buf,s); + break; + case CERTIFICATE_PTAG_EXTIPANDPORT_SECTION: + if(s != 6) + { + err_code = CERTIFICATE_PARSING_ERROR_INVALID_EXTERNAL_IP; + return false; + } + memcpy(ipv4_external_ip_and_port,buf,s); + break; + case CERTIFICATE_PTAG_CHECKSUM_SECTION: + { + if(s != 3 || total_s+3 != size) + { + err_code = + CERTIFICATE_PARSING_ERROR_INVALID_CHECKSUM_SECTION; + return false; + } + uint32_t computed_crc = + PGPKeyManagement::compute24bitsCRC(bf.data(),size-5); + uint32_t certificate_crc = + buf[0] + (buf[1] << 8) + (buf[2] << 16); + if(computed_crc != certificate_crc) + { + err_code = CERTIFICATE_PARSING_ERROR_CHECKSUM_ERROR; + return false; + } + else checksum_check_passed = true; + break; + } + case CERTIFICATE_PTAG_EXTRA_LOCATOR: + mLocators.insert(RsUrl(std::string((char *)buf, s))); + break; + default: + std::cerr << "(WW) unknwown PTAG 0x" << std::hex << ptag + << std::dec << " in certificate! Ignoring it." + << std::endl; + break; } + buf = &buf[s]; total_s += s ; } diff --git a/libretroshare/src/pgp/rscertificate.h b/libretroshare/src/pgp/rscertificate.h index a70a1752f..131652d0a 100644 --- a/libretroshare/src/pgp/rscertificate.h +++ b/libretroshare/src/pgp/rscertificate.h @@ -1,7 +1,28 @@ #pragma once +/* + * RetroShare + * + * Copyright (C) 2012-2014 Cyril Soler + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include "retroshare/rstypes.h" +#include "util/rsurl.h" + +#include #include -#include class RsPeerDetails ; @@ -42,6 +63,7 @@ class RsCertificate size_t pgp_key_size() const { return binary_pgp_key_size ; } static bool cleanCertificate(const std::string& input, std::string& output, RsCertificate::Format& format, int& error_code, bool check_content) ; + const std::set& locators() const { return mLocators; } private: static bool cleanCertificate(const std::string& input,std::string& output,int&) ; // new radix format @@ -69,6 +91,7 @@ class RsCertificate std::string pgp_version ; std::string dns_name ; std::string hidden_node_address; + std::set mLocators; bool only_pgp ; // does the cert contain only pgp info? bool hidden_node; // IP or hidden Node Address. diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index 1927b457e..09758c266 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -1363,16 +1363,63 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& pLocalAddr, } +bool p3PeerMgrIMPL::addPeerLocator(const RsPeerId &sslId, const RsUrl& locator) +{ + std::string host(locator.host()); + pqiIpAddress ip; + if(!locator.hasPort() || host.empty() || + !sockaddr_storage_inet_pton(ip.mAddr, host) || + !sockaddr_storage_setport(ip.mAddr, locator.port())) return false; + ip.mSeenTime = time(NULL); + bool changed = false; -bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr) + if (sslId == AuthSSL::getAuthSSL()->OwnId()) + { + RS_STACK_MUTEX(mPeerMtx); + changed = mOwnState.ipAddrs.updateLocalAddrs(ip); + } + else + { + RS_STACK_MUTEX(mPeerMtx); + auto it = mFriendList.find(sslId); + if (it == mFriendList.end()) + { + it = mOthersList.find(sslId); + if (it == mOthersList.end()) + { +#ifdef PEER_DEBUG + std::cerr << __PRETTY_FUNCTION__ << "cannot add address " + << "info, peer id: " << sslId << " not found in list" + << std::endl; +#endif + return false; + } + } + + changed = it->second.ipAddrs.updateLocalAddrs(ip); + } + + if (changed) + { +#ifdef PEER_DEBUG + std::cerr << __PRETTY_FUNCTION__ << " Added locator: " + << locator.toString() << std::endl; +#endif + IndicateConfigChanged(); + } + return changed; +} + +bool p3PeerMgrIMPL::setLocalAddress( const RsPeerId &id, + const sockaddr_storage &addr ) { bool changed = false; if (id == AuthSSL::getAuthSSL()->OwnId()) { { - RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ + RS_STACK_MUTEX(mPeerMtx); if (!sockaddr_storage_same(mOwnState.localaddr, addr)) { mOwnState.localaddr = addr; @@ -1390,7 +1437,7 @@ bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr return changed; } - RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ + RS_STACK_MUTEX(mPeerMtx); /* check if it is a friend */ std::map::iterator it; if (mFriendList.end() == (it = mFriendList.find(id))) @@ -1398,7 +1445,9 @@ bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr if (mOthersList.end() == (it = mOthersList.find(id))) { #ifdef PEER_DEBUG - std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl; + std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres " + << "info : peer id not found in friend list id: " + << id << std::endl; #endif return false; } @@ -1419,10 +1468,7 @@ bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr it->second.updateIpAddressList(ipAddressTimed); #endif - if (changed) { - IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/ - } - + if (changed) IndicateConfigChanged(); return changed; } diff --git a/libretroshare/src/pqi/p3peermgr.h b/libretroshare/src/pqi/p3peermgr.h index 8a0ac5235..390030893 100644 --- a/libretroshare/src/pqi/p3peermgr.h +++ b/libretroshare/src/pqi/p3peermgr.h @@ -163,6 +163,7 @@ virtual bool assignPeersToGroup(const RsNodeGroupId &groupId, const std::list * 3) p3disc - reasonable */ + virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator) = 0; virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr) = 0; virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr) = 0; virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns) = 0; @@ -277,6 +278,7 @@ public: * 3) p3disc - reasonable */ + virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator); virtual bool setLocalAddress(const RsPeerId &id, const struct sockaddr_storage &addr); virtual bool setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr); virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns); diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index f1b274d09..89131e8bf 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -33,6 +33,7 @@ #include #include #include +#include "util/rsurl.h" /* The Main Interface Class - for information about your Peers * A peer is another RS instance, means associated with an SSL certificate @@ -370,6 +371,7 @@ public: virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port) = 0; virtual bool isHiddenNode(const RsPeerId &id) = 0; + virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator) = 0; virtual bool setLocalAddress(const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0; virtual bool setExtAddress( const RsPeerId &ssl_id, const std::string &addr, uint16_t port) = 0; virtual bool setDynDNS(const RsPeerId &id, const std::string &addr) = 0; diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 52f6c3dba..10fa0e9e9 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -904,6 +904,9 @@ bool p3Peers::setHiddenNode(const RsPeerId &id, const std::string &address, uin return true; } +bool p3Peers::addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator) +{ return mPeerMgr->addPeerLocator(ssl_id, locator); } + bool p3Peers::setLocalAddress(const RsPeerId &id, const std::string &addr_str, uint16_t port) { @@ -1148,11 +1151,12 @@ bool p3Peers::loadCertificateFromString(const std::string& cert, RsPeerId& ssl_ return res ; } -bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetails &pd,uint32_t& error_code) +bool p3Peers::loadDetailsFromStringCert( const std::string &certstr, + RsPeerDetails &pd, + uint32_t& error_code ) { #ifdef P3PEERS_DEBUG - std::cerr << "p3Peers::LoadCertificateFromString() "; - std::cerr << std::endl; + std::cerr << "p3Peers::LoadCertificateFromString() " << std::endl; #endif //parse the text to get ip address try @@ -1192,9 +1196,11 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai pd.localPort = cert.loc_port_us(); pd.extAddr = cert.ext_ip_string(); pd.extPort = cert.ext_port_us(); - pd.dyndns = cert.dns_string() ; + pd.dyndns = cert.dns_string(); + for(const RsUrl& locator : cert.locators()) + pd.ipAddressList.push_back(locator.toString()); } - } + } catch(uint32_t e) { std::cerr << "ConnectFriendWizard : Parse ip address error :" << e << std::endl; diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index 4f9b661d7..43d45f8a7 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -36,6 +36,7 @@ #endif #include "retroshare/rspeers.h" +#include "util/rsurl.h" class p3LinkMgr; class p3PeerMgr; @@ -96,7 +97,8 @@ public: virtual bool setHiddenNode(const RsPeerId &id, const std::string &address, uint16_t port); virtual bool isHiddenNode(const RsPeerId &id); - virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port); + virtual bool addPeerLocator(const RsPeerId &ssl_id, const RsUrl& locator); + virtual bool setLocalAddress(const RsPeerId &id, const std::string &addr, uint16_t port); virtual bool setExtAddress(const RsPeerId &id, const std::string &addr, uint16_t port); virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns); virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode); diff --git a/libretroshare/src/util/rsnet_ss.cc b/libretroshare/src/util/rsnet_ss.cc index 65f2f3ee7..bc6d4bafb 100644 --- a/libretroshare/src/util/rsnet_ss.cc +++ b/libretroshare/src/util/rsnet_ss.cc @@ -192,8 +192,7 @@ bool sockaddr_storage_copyip(struct sockaddr_storage &dst, const struct sockaddr uint16_t sockaddr_storage_port(const struct sockaddr_storage &addr) { #ifdef SS_DEBUG - std::cerr << "sockaddr_storage_port()"; - std::cerr << std::endl; + std::cerr << "sockaddr_storage_port()" << std::endl; #endif switch(addr.ss_family) { @@ -203,8 +202,10 @@ uint16_t sockaddr_storage_port(const struct sockaddr_storage &addr) return sockaddr_storage_ipv6_port(addr); default: std::cerr << "sockaddr_storage_port() invalid addr.ss_family" << std::endl; +#ifdef SS_DEBUG sockaddr_storage_dump(addr); print_stacktrace(); +#endif break; } return 0; @@ -504,7 +505,7 @@ std::string sockaddr_storage_tostring(const struct sockaddr_storage &addr) url.setScheme("ipv6"); break; default: - return "INVALID_IP"; + return "AF_INVALID"; } url.setHost(sockaddr_storage_iptostring(addr)) @@ -613,9 +614,11 @@ std::string sockaddr_storage_iptostring(const struct sockaddr_storage &addr) break; default: output = "INVALID_IP"; - std::cerr << __PRETTY_FUNCTION__ << " Got invalid IP:" << std::endl; + std::cerr << __PRETTY_FUNCTION__ << " Got invalid IP!" << std::endl; +#ifdef SS_DEBUG sockaddr_storage_dump(addr); print_stacktrace(); +#endif break; } return output; diff --git a/libretroshare/src/util/rsurl.cc b/libretroshare/src/util/rsurl.cc index 3f28a607d..efaab9777 100644 --- a/libretroshare/src/util/rsurl.cc +++ b/libretroshare/src/util/rsurl.cc @@ -34,10 +34,10 @@ RsUrl::RsUrl(const std::string& urlStr) : mPort(0), mHasPort(false) RsUrl& RsUrl::fromString(const std::string& urlStr) { - size_t urlSize = urlStr.size(); + size_t endI = urlStr.size()-1; size_t schemeEndI = urlStr.find(schemeSeparator); - if(schemeEndI == string::npos) + if(schemeEndI >= endI) { mScheme = urlStr; return *this; @@ -46,15 +46,16 @@ RsUrl& RsUrl::fromString(const std::string& urlStr) mScheme = urlStr.substr(0, schemeEndI); size_t hostBeginI = schemeEndI + 3; - if(hostBeginI >= urlSize) return *this; + if(hostBeginI >= endI) return *this; bool hasSquareBr = (urlStr[hostBeginI] == ipv6WrapOpen[0]); size_t hostEndI; if(hasSquareBr) { - if(++hostBeginI >= urlSize) return *this; + if(++hostBeginI >= endI) return *this; hostEndI = urlStr.find(ipv6WrapClose, hostBeginI); mHost = urlStr.substr(hostBeginI, hostEndI - hostBeginI - 1); + ++hostEndI; } else { @@ -64,24 +65,25 @@ RsUrl& RsUrl::fromString(const std::string& urlStr) hostEndI = min(hostEndI, urlStr.find(fragmentSeparator, hostBeginI)); mHost = urlStr.substr(hostBeginI, hostEndI - hostBeginI); - if(hostEndI == string::npos) return *this; } + if( hostEndI >= endI ) return *this; + mHasPort = (sscanf(&urlStr[hostEndI], ":%hu", &mPort) == 1); - size_t pathBeginI = urlStr.find(pathSeparator, hostEndI); + size_t pathBeginI = urlStr.find(pathSeparator, hostBeginI); size_t pathEndI = string::npos; - if(pathBeginI != string::npos) + if(pathBeginI < endI) { pathEndI = urlStr.find(querySeparator, pathBeginI); pathEndI = min(pathEndI, urlStr.find(fragmentSeparator, pathBeginI)); mPath = UrlDecode(urlStr.substr(pathBeginI, pathEndI - pathBeginI)); - if(pathEndI == string::npos) return *this; + if(pathEndI >= endI) return *this; } - size_t queryBeginI = urlStr.find(querySeparator, schemeEndI); - size_t queryEndI = urlStr.find(fragmentSeparator, schemeEndI); - if(queryBeginI != string::npos) + size_t queryBeginI = urlStr.find(querySeparator, hostBeginI); + size_t queryEndI = urlStr.find(fragmentSeparator, hostBeginI); + if(queryBeginI < endI) { string qStr = urlStr.substr(queryBeginI+1, queryEndI-queryBeginI-1); @@ -96,14 +98,16 @@ RsUrl& RsUrl::fromString(const std::string& urlStr) kPos = vEndPos+1; assPos = qStr.find(queryAssign, vEndPos); } - while(assPos != string::npos); + while(assPos < endI); - if(queryEndI == string::npos) return *this; + if(queryEndI >= endI) return *this; } - size_t fragmentBeginI = urlStr.find(fragmentSeparator, schemeEndI); - if(fragmentBeginI != string::npos) + size_t fragmentBeginI = urlStr.find(fragmentSeparator, hostBeginI); + if(fragmentBeginI < endI) mFragment = UrlDecode(urlStr.substr(++fragmentBeginI)); + + return *this; } std::string RsUrl::toString() const diff --git a/libretroshare/src/util/rsurl.h b/libretroshare/src/util/rsurl.h index 6125efba5..49215ffa4 100644 --- a/libretroshare/src/util/rsurl.h +++ b/libretroshare/src/util/rsurl.h @@ -65,17 +65,17 @@ struct RsUrl const std::string& ignoreChars = ""); static std::string UrlDecode(const std::string& str); - inline bool operator<(const RsUrl& rhs) + inline bool operator<(const RsUrl& rhs) const { return toString() < rhs.toString(); } - inline bool operator>(const RsUrl& rhs) + inline bool operator>(const RsUrl& rhs) const { return toString() > rhs.toString(); } - inline bool operator<=(const RsUrl& rhs) + inline bool operator<=(const RsUrl& rhs) const { return toString() <= rhs.toString(); } - inline bool operator>=(const RsUrl& rhs) + inline bool operator>=(const RsUrl& rhs) const { return toString() >= rhs.toString(); } - inline bool operator==(const RsUrl& rhs) + inline bool operator==(const RsUrl& rhs) const { return toString() == rhs.toString(); } - inline bool operator!=(const RsUrl& rhs) + inline bool operator!=(const RsUrl& rhs) const { return toString() != rhs.toString(); } static const std::string schemeSeparator; diff --git a/retroshare-gui/src/gui/common/FriendList.cpp b/retroshare-gui/src/gui/common/FriendList.cpp index 726bf61ea..fb62ff010 100644 --- a/retroshare-gui/src/gui/common/FriendList.cpp +++ b/retroshare-gui/src/gui/common/FriendList.cpp @@ -2067,6 +2067,10 @@ bool FriendList::importFriendlist(QString &fileName, bool &errorPeers, bool &err rsPeers->setDynDNS(rsPeerDetails.id, rsPeerDetails.dyndns); if (!rsPeerDetails.location.empty()) rsPeers->setLocation(rsPeerDetails.id, rsPeerDetails.location); + for(auto&& ipr : rsPeerDetails.ipAddressList) + rsPeers->addPeerLocator( + rsPeerDetails.id, + RsUrl(ipr.substr(0, ipr.find(' '))) ); } } else if (!rsPeerDetails.gpg_id.isNull()) { // only pgp id is avaiable diff --git a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp index 15b2f504f..2d994917c 100755 --- a/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp +++ b/retroshare-gui/src/gui/connect/ConnectFriendWizard.cpp @@ -974,6 +974,10 @@ void ConnectFriendWizard::accept() std::cerr << "ConnectFriendWizard::accept() : setting DynDNS." << std::endl; rsPeers->setDynDNS(peerDetails.id, peerDetails.dyndns); } + for(auto&& ipr : peerDetails.ipAddressList) + rsPeers->addPeerLocator( + peerDetails.id, + RsUrl(ipr.substr(0, ipr.find(' '))) ); } } From 9fbf56e592333d7cb364347ed0ae723ede09ace3 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sat, 3 Mar 2018 01:55:49 +0100 Subject: [PATCH 04/50] Remove outdated misleading comment --- libretroshare/src/pqi/p3netmgr.cc | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 7ca1713f7..1daf78e45 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -1119,12 +1119,7 @@ bool p3NetMgrIMPL::checkNetAddress() #ifdef NETMGR_DEBUG std::cerr << "p3NetMgrIMPL::checkNetAddress() Correcting Port to DEFAULT" << std::endl; #endif - // Generate a default port from SSL id. The port will always be the - // same, but appear random from peer to peer. - // Random port avoids clashes, improves anonymity. - // - - int new_port = htons(PQI_MIN_PORT_RNG + (RSRandom::random_u32() % (PQI_MAX_PORT - PQI_MIN_PORT_RNG))); + uint16_t new_port = htons(PQI_MIN_PORT_RNG + (RSRandom::random_u32() % (PQI_MAX_PORT - PQI_MIN_PORT_RNG))); sockaddr_storage_setport(mLocalAddr, new_port); addrChanged = true; From 186617fc2bebca7967a2e575b4a9a92cd6f04dee Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Thu, 17 May 2018 16:43:14 +0200 Subject: [PATCH 05/50] Fix missing include --- libresapi/src/api/ChannelsHandler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libresapi/src/api/ChannelsHandler.cpp b/libresapi/src/api/ChannelsHandler.cpp index 52a3527ac..3c5084578 100644 --- a/libresapi/src/api/ChannelsHandler.cpp +++ b/libresapi/src/api/ChannelsHandler.cpp @@ -22,6 +22,8 @@ #include #include #include +#include + #include "Operators.h" namespace resource_api From 5a301734a9324f31c285772d607f37479b4cbf2d Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Wed, 16 May 2018 16:13:44 +0200 Subject: [PATCH 06/50] Extend a bit filesharing JSON API v2 --- libresapi/src/api/FileSharingHandler.cpp | 54 +++++++++++++++++++++ libresapi/src/api/FileSharingHandler.h | 6 +++ libresapi/src/api/TransfersHandler.cpp | 62 ++++++++++++++++++++++++ libresapi/src/api/TransfersHandler.h | 3 ++ libretroshare/src/retroshare/rsfiles.h | 7 ++- 5 files changed, 128 insertions(+), 4 deletions(-) diff --git a/libresapi/src/api/FileSharingHandler.cpp b/libresapi/src/api/FileSharingHandler.cpp index a6296973d..44c94cfad 100644 --- a/libresapi/src/api/FileSharingHandler.cpp +++ b/libresapi/src/api/FileSharingHandler.cpp @@ -37,6 +37,16 @@ FileSharingHandler::FileSharingHandler(StateTokenServer *sts, RsFiles *files, addResourceHandler("get_dir_parent", this, &FileSharingHandler::handleGetDirectoryParent); addResourceHandler("get_dir_childs", this, &FileSharingHandler::handleGetDirectoryChilds); + addResourceHandler( "get_download_directory", this, + &FileSharingHandler::handleGetDownloadDirectory ); + addResourceHandler( "set_download_directory", this, + &FileSharingHandler::handleSetDownloadDirectory ); + + addResourceHandler( "get_partials_directory", this, + &FileSharingHandler::handleGetPartialsDirectory ); + addResourceHandler( "set_partials_directory", this, + &FileSharingHandler::handleSetPartialsDirectory ); + addResourceHandler("is_dl_dir_shared", this, &FileSharingHandler::handleIsDownloadDirShared); addResourceHandler("share_dl_dir", this, &FileSharingHandler::handleShareDownloadDirectory); @@ -513,4 +523,48 @@ void FileSharingHandler::handleDownload(Request& req, Response& resp) resp.setFail("Couldn't download file"); } +void FileSharingHandler::handleGetDownloadDirectory( Request& /*req*/, + Response& resp ) +{ + std::string dlDir = mRsFiles->getDownloadDirectory(); + resp.mDataStream << makeKeyValueReference("download_directory", dlDir); + resp.setOk(); +} + +void FileSharingHandler::handleSetDownloadDirectory( Request& req, + Response& resp ) +{ + std::string dlDir; + req.mStream << makeKeyValueReference("download_directory", dlDir); + + if(dlDir.empty()) resp.setFail("missing download_directory"); + else + { + mRsFiles->setDownloadDirectory(dlDir); + resp.setOk(); + } +} + +void FileSharingHandler::handleGetPartialsDirectory( Request& /*req*/, + Response& resp ) +{ + std::string partialsDir = mRsFiles->getPartialsDirectory(); + resp.mDataStream << makeKeyValueReference("partials_directory", partialsDir); + resp.setOk(); +} + +void FileSharingHandler::handleSetPartialsDirectory( Request& req, + Response& resp ) +{ + std::string partialsDir; + req.mStream << makeKeyValueReference("partials_directory", partialsDir); + + if(partialsDir.empty()) resp.setFail("missing partials_directory"); + else + { + mRsFiles->setPartialsDirectory(partialsDir); + resp.setOk(); + } +} + } // namespace resource_api diff --git a/libresapi/src/api/FileSharingHandler.h b/libresapi/src/api/FileSharingHandler.h index 0eb67764e..cd78f338f 100644 --- a/libresapi/src/api/FileSharingHandler.h +++ b/libresapi/src/api/FileSharingHandler.h @@ -57,6 +57,12 @@ private: void handleDownload(Request& req, Response& resp); + void handleGetDownloadDirectory(Request& req, Response& resp); + void handleSetDownloadDirectory(Request& req, Response& resp); + + void handleGetPartialsDirectory(Request& req, Response& resp); + void handleSetPartialsDirectory(Request& req, Response& resp); + /// Token indicating change in local shared files StateToken mLocalDirStateToken; diff --git a/libresapi/src/api/TransfersHandler.cpp b/libresapi/src/api/TransfersHandler.cpp index c696411da..dc28e9596 100644 --- a/libresapi/src/api/TransfersHandler.cpp +++ b/libresapi/src/api/TransfersHandler.cpp @@ -15,6 +15,14 @@ TransfersHandler::TransfersHandler(StateTokenServer *sts, RsFiles *files, RsPeer addResourceHandler("downloads", this, &TransfersHandler::handleDownloads); addResourceHandler("uploads", this, &TransfersHandler::handleUploads); addResourceHandler("control_download", this, &TransfersHandler::handleControlDownload); + + addResourceHandler( "set_file_destination_directory", this, + &TransfersHandler::handleSetFileDestinationDirectory ); + addResourceHandler( "set_file_destination_name", this, + &TransfersHandler::handleSetFileDestinationName ); + addResourceHandler( "set_file_chunk_strategy", this, + &TransfersHandler::handleSetFileChunkStrategy ); + mStateToken = mStateTokenServer->getNewToken(); mStateTokenServer->registerTickClient(this); mNotify.registerNotifyClient(this); @@ -288,4 +296,58 @@ void TransfersHandler::handleUploads(Request & /* req */, Response &resp) resp.setOk(); } +void TransfersHandler::handleSetFileDestinationDirectory( Request& req, + Response& resp ) +{ + mStateTokenServer->replaceToken(mStateToken); + + std::string hashString; + std::string newPath; + req.mStream << makeKeyValueReference("path", newPath); + req.mStream << makeKeyValueReference("hash", hashString); + RsFileHash hash(hashString); + + if (mFiles->setDestinationDirectory(hash, newPath)) resp.setOk(); + else resp.setFail(); +} + +void TransfersHandler::handleSetFileDestinationName( Request& req, + Response& resp ) +{ + mStateTokenServer->replaceToken(mStateToken); + + std::string hashString; + std::string newName; + req.mStream << makeKeyValueReference("name", newName); + req.mStream << makeKeyValueReference("hash", hashString); + RsFileHash hash(hashString); + + if (mFiles->setDestinationName(hash, newName)) resp.setOk(); + else resp.setFail(); +} + +void TransfersHandler::handleSetFileChunkStrategy(Request& req, Response& resp) +{ + mStateTokenServer->replaceToken(mStateToken); + + std::string hashString; + std::string newChunkStrategyStr; + req.mStream << makeKeyValueReference("chuck_stategy", newChunkStrategyStr); + req.mStream << makeKeyValueReference("hash", hashString); + + RsFileHash hash(hashString); + FileChunksInfo::ChunkStrategy newStrategy = + FileChunksInfo::CHUNK_STRATEGY_PROGRESSIVE; + + if ( newChunkStrategyStr == "streaming" ) + newStrategy = FileChunksInfo::CHUNK_STRATEGY_STREAMING; + else if ( newChunkStrategyStr == "random" ) + newStrategy = FileChunksInfo::CHUNK_STRATEGY_RANDOM; + else if ( newChunkStrategyStr == "progressive" ) + newStrategy = FileChunksInfo::CHUNK_STRATEGY_PROGRESSIVE; + + if (mFiles->setChunkStrategy(hash, newStrategy)) resp.setOk(); + else resp.setFail(); +} + } // namespace resource_api diff --git a/libresapi/src/api/TransfersHandler.h b/libresapi/src/api/TransfersHandler.h index 7d07a7198..7e43c3614 100644 --- a/libresapi/src/api/TransfersHandler.h +++ b/libresapi/src/api/TransfersHandler.h @@ -30,6 +30,9 @@ private: void handleControlDownload(Request& req, Response& resp); void handleDownloads(Request& req, Response& resp); void handleUploads(Request& req, Response& resp); + void handleSetFileDestinationDirectory(Request& req, Response& resp); + void handleSetFileDestinationName(Request& req, Response& resp); + void handleSetFileChunkStrategy(Request& req, Response& resp); StateTokenServer* mStateTokenServer; RsFiles* mFiles; diff --git a/libretroshare/src/retroshare/rsfiles.h b/libretroshare/src/retroshare/rsfiles.h index ccd4428be..83301de98 100644 --- a/libretroshare/src/retroshare/rsfiles.h +++ b/libretroshare/src/retroshare/rsfiles.h @@ -168,10 +168,9 @@ public: class RsFiles { - public: - - RsFiles() { return; } - virtual ~RsFiles() { return; } +public: + RsFiles() {} + virtual ~RsFiles() {} /** * Provides file data for the gui: media streaming or rpc clients. From 8f107cca31bc64625dff3d70e5258cdef9c7fb87 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 19 May 2018 16:37:29 +0200 Subject: [PATCH 07/50] Add Never Ask Me For External Link Activated Need to remove [General] NeverAskMeForExternalLinkActivated key in RetroShare.conf to revert. --- retroshare-gui/src/gui/MainWindow.cpp | 34 +++++++++++++++++---------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 116b9637f..e00417080 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -733,16 +733,16 @@ void MainWindow::updateStatus() if (ratesstatus) ratesstatus->getRatesStatus(downKb, upKb); - if(torstatus) - torstatus->getTorStatus(); + if(torstatus) + torstatus->getTorStatus(); if(!hiddenmode) { - if (natstatus) - natstatus->getNATStatus(); - - if (dhtstatus) - dhtstatus->getDHTStatus(); + if (natstatus) + natstatus->getNATStatus(); + + if (dhtstatus) + dhtstatus->getDHTStatus(); } if (discstatus) { @@ -1434,27 +1434,37 @@ void MainWindow::settingsChanged() void MainWindow::externalLinkActivated(const QUrl &url) { static bool already_warned = false ; + bool never_ask_me = Settings->value("NeverAskMeForExternalLinkActivated",false).toBool(); - if(!already_warned) + if(!already_warned && !never_ask_me) { QMessageBox mb(QObject::tr("Confirmation"), QObject::tr("Do you want this link to be handled by your system?")+"

"+ url.toString()+"

"+tr("Make sure this link has not been forged to drag you to a malicious website."), QMessageBox::Question, QMessageBox::Yes,QMessageBox::No, 0); - QCheckBox *checkbox = new QCheckBox(tr("Don't ask me again")) ; + QCheckBox *dontAsk_CB = new QCheckBox(tr("Don't ask me again")); + QCheckBox *neverAsk_CB = new QCheckBox(tr("Never ask me again")); + dontAsk_CB->setToolTip(tr("This will be saved only for this session.")); + neverAsk_CB->setToolTip(tr("This will be saved permanently. You'll need to clean RetroShare.conf to revert.")); QGridLayout* layout = qobject_cast(mb.layout()); if (layout) { - layout->addWidget(checkbox,layout->rowCount(),0,1, layout->columnCount(), Qt::AlignLeft); + layout->addWidget(dontAsk_CB,layout->rowCount(),0,1, layout->columnCount(), Qt::AlignLeft); + layout->addWidget(neverAsk_CB,layout->rowCount(),0,1, layout->columnCount(), Qt::AlignLeft); } else { //Not QGridLayout so add at end - mb.layout()->addWidget(checkbox) ; + mb.layout()->addWidget(dontAsk_CB); + mb.layout()->addWidget(neverAsk_CB); } int res = mb.exec() ; if (res == QMessageBox::No) return ; - else if(checkbox->isChecked()) + + if(dontAsk_CB->isChecked()) already_warned = true ; + + if(neverAsk_CB->isChecked()) + Settings->setValue("NeverAskMeForExternalLinkActivated",true); } QDesktopServices::openUrl(url) ; From 92b21d73326359403ec399578af5387c05ed0d11 Mon Sep 17 00:00:00 2001 From: sehraf Date: Mon, 21 May 2018 14:26:46 +0200 Subject: [PATCH 08/50] compile fix wikipoos --- libretroshare/src/rsserver/rsinit.cc | 10 +++++----- retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 0d9300202..095dbaeaf 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -1351,11 +1351,11 @@ int RsServer::StartupRetroShare() p3Wiki *mWiki = new p3Wiki(wiki_ds, NULL, mGxsIdService); // create GXS wiki service - RsGxsNetService* wiki_ns = new RsGxsNetService( - RS_SERVICE_GXS_TYPE_WIKI, wiki_ds, nxsMgr, - mWiki, mWiki->getServiceInfo(), - mGxsIdService, mGxsCircles, - pgpAuxUtils); + RsGxsNetService* wiki_ns = new RsGxsNetService( + RS_SERVICE_GXS_TYPE_WIKI, wiki_ds, nxsMgr, + mWiki, mWiki->getServiceInfo(), + mReputations, mGxsCircles, mGxsIdService, + pgpAuxUtils); mWiki->setNetworkExchangeService(wiki_ns) ; #endif diff --git a/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp index 709d0262c..667e55fa7 100644 --- a/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp +++ b/retroshare-gui/src/gui/WikiPoos/WikiEditDialog.cpp @@ -715,7 +715,7 @@ void WikiEditDialog::loadBaseHistory(const uint32_t &token) std::cerr << " ParentId: " << page.mMeta.mParentId; std::cerr << std::endl; - GxsIdRSTreeWidgetItem *modItem = new GxsIdRSTreeWidgetItem(mThreadCompareRole); + GxsIdRSTreeWidgetItem *modItem = new GxsIdRSTreeWidgetItem(mThreadCompareRole, GxsIdDetails::ICON_TYPE_AVATAR); modItem->setData(WET_DATA_COLUMN, WET_ROLE_ORIGPAGEID, QString::fromStdString(page.mMeta.mOrigMsgId.toStdString())); modItem->setData(WET_DATA_COLUMN, WET_ROLE_PAGEID, QString::fromStdString(page.mMeta.mMsgId.toStdString())); @@ -830,7 +830,7 @@ void WikiEditDialog::loadEditTreeData(const uint32_t &token) } /* create an Entry */ - GxsIdRSTreeWidgetItem *modItem = new GxsIdRSTreeWidgetItem(mThreadCompareRole); + GxsIdRSTreeWidgetItem *modItem = new GxsIdRSTreeWidgetItem(mThreadCompareRole, GxsIdDetails::ICON_TYPE_AVATAR); modItem->setData(WET_DATA_COLUMN, WET_ROLE_ORIGPAGEID, QString::fromStdString(snapshot.mMeta.mOrigMsgId.toStdString())); modItem->setData(WET_DATA_COLUMN, WET_ROLE_PAGEID, QString::fromStdString(snapshot.mMeta.mMsgId.toStdString())); modItem->setData(WET_DATA_COLUMN, WET_ROLE_PARENTID, QString::fromStdString(snapshot.mMeta.mParentId.toStdString())); From 0c19a5640ec12ef7845e1da222247dfc727aa6d8 Mon Sep 17 00:00:00 2001 From: sehraf Date: Mon, 21 May 2018 14:55:10 +0200 Subject: [PATCH 09/50] compile fix gxsphoto --- libretroshare/src/rsitems/rsphotoitems.cc | 27 +++++++++++------------ libretroshare/src/rsitems/rsphotoitems.h | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/libretroshare/src/rsitems/rsphotoitems.cc b/libretroshare/src/rsitems/rsphotoitems.cc index 9c9ff2d02..3a5ad1ead 100644 --- a/libretroshare/src/rsitems/rsphotoitems.cc +++ b/libretroshare/src/rsitems/rsphotoitems.cc @@ -61,24 +61,23 @@ void RsGxsPhotoAlbumItem::serial_process(RsGenericSerializer::SerializeJob j,RsG RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_LOCATION, album.mWhere, "mWhere"); RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_PIC_TYPE, album.mThumbnail.type,"mThumbnail.type"); - RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, album.mThumbnail.data,album.mThumbnail.size); - - RsTypeSerializer::serial_process(j,ctx,b,"thumbnail binary data") ; + RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, album.mThumbnail.data, album.mThumbnail.size); + RsTypeSerializer::serial_process(j, ctx, b, "thumbnail binary data") ; } void RsGxsPhotoPhotoItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { - RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_CAPTION, photo.mCaption); - RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory); - RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_DESCR, photo.mDescription); - RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags); - RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_MSG, photo.mOther); - RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer); - RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_DATE, photo.mWhen); - RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_LOCATION, photo.mWhere); - RsTypeSerializer::serial_process(j,ctx, TLV_TYPE_STR_PIC_TYPE, photo.mThumbnail.type); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CAPTION, photo.mCaption, "mCaption"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_CATEGORY, photo.mCategory, "mCategory"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DESCR, photo.mDescription, "mDescription"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_HASH_TAG, photo.mHashTags, "mHashTags"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_MSG, photo.mOther, "mOther"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_AUTH, photo.mPhotographer, "mPhotographer"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_DATE, photo.mWhen, "mWhen"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_LOCATION, photo.mWhere, "mWhere"); + RsTypeSerializer::serial_process(j, ctx, TLV_TYPE_STR_PIC_TYPE, photo.mThumbnail.type, "mThumbnail.type"); - RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO,photo.mThumbnail.data, photo.mThumbnail.size); - RsTypeSerializer::serial_process(j,ctx, b, "mThumbnail") ; + RsTlvBinaryDataRef b(RS_SERVICE_GXS_TYPE_PHOTO, photo.mThumbnail.data, photo.mThumbnail.size); + RsTypeSerializer::serial_process(j, ctx, b, "mThumbnail") ; } void RsGxsPhotoCommentItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx) { diff --git a/libretroshare/src/rsitems/rsphotoitems.h b/libretroshare/src/rsitems/rsphotoitems.h index 3819edb88..cf809ce8e 100644 --- a/libretroshare/src/rsitems/rsphotoitems.h +++ b/libretroshare/src/rsitems/rsphotoitems.h @@ -50,7 +50,7 @@ public: virtual ~RsGxsPhotoAlbumItem() { return;} void clear(); - std::ostream &print(std::ostream &out, uint16_t indent = 0); +// std::ostream &print(std::ostream &out, uint16_t indent = 0); virtual void serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx); From 0bf02e2bc39b1cc43b282a913e8f128fb7e2ff39 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Tue, 22 May 2018 19:14:25 +0200 Subject: [PATCH 10/50] pqissludp::Initiate_Connection() check remote_addr to be IPv4 before use --- libretroshare/src/pqi/pqissludp.cc | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/libretroshare/src/pqi/pqissludp.cc b/libretroshare/src/pqi/pqissludp.cc index 8d7e45fd1..dbde145df 100644 --- a/libretroshare/src/pqi/pqissludp.cc +++ b/libretroshare/src/pqi/pqissludp.cc @@ -227,6 +227,15 @@ int pqissludp::Initiate_Connection() return -1; } + if(!sockaddr_storage_ipv6_to_ipv4(remote_addr)) + { + std::cerr << __PRETTY_FUNCTION__ << "Error: remote_addr is not " + << "valid IPv4!" << std::endl; + sockaddr_storage_dump(remote_addr); + print_stacktrace(); + return -EINVAL; + } + mTimeoutTS = time(NULL) + mConnectTimeout; //std::cerr << "Setting Connect Timeout " << mConnectTimeout << " Seconds into Future " << std::endl; //std::cerr << " Connect Period is:" << mConnectPeriod << std::endl; @@ -254,32 +263,22 @@ int pqissludp::Initiate_Connection() struct sockaddr_in proxyaddr; struct sockaddr_in remoteaddr; - bool nonIpV4 = false; - if(!sockaddr_storage_ipv6_to_ipv4(remote_addr)) - { - nonIpV4 = true; - std::cerr << __PRETTY_FUNCTION__ << "Error: remote_addr is not " - << "valid IPv4!" << std::endl; - sockaddr_storage_dump(remote_addr); - } if(!sockaddr_storage_ipv6_to_ipv4(mConnectSrcAddr)) { - nonIpV4 = true; std::cerr << __PRETTY_FUNCTION__ << "Error: mConnectSrcAddr is " << "not valid IPv4!" << std::endl; sockaddr_storage_dump(mConnectSrcAddr); + print_stacktrace(); + return -EINVAL; } if(!sockaddr_storage_ipv6_to_ipv4(mConnectProxyAddr)) { - nonIpV4 = true; std::cerr << __PRETTY_FUNCTION__ << "Error: mConnectProxyAddr " << "is not valid IPv4!" << std::endl; sockaddr_storage_dump(mConnectProxyAddr); - } - if(!nonIpV4) - { print_stacktrace(); return -EINVAL; + } struct sockaddr_in *rap = (struct sockaddr_in *) &remote_addr; @@ -301,7 +300,6 @@ int pqissludp::Initiate_Connection() err = tou_connect_via_relay(sockfd, &srcaddr, &proxyaddr, &remoteaddr); } - /*** It seems that the UDP Layer sees x 1.2 the traffic of the SSL layer. * We need to compensate somewhere... we drop the maximum traffic to 75% of limit From 1ad1fdc7bee356bf9502989842639f5e41376eda Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Tue, 22 May 2018 19:17:37 +0200 Subject: [PATCH 11/50] p3NetMgrIMPL::checkNetAddress() notify if port change Plus cleanups and proper sockaddr_storage copy --- libretroshare/src/pqi/p3netmgr.cc | 15 +++++---- libretroshare/src/pqi/p3peermgr.cc | 32 +++++++++++-------- libretroshare/src/rsserver/p3peers.cc | 4 +-- .../src/gui/settings/ServerPage.cpp | 13 +++++--- 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 7ca1713f7..3381705cd 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -987,8 +987,8 @@ bool p3NetMgrIMPL::checkNetAddress() bool addrChanged = false; bool validAddr = false; - struct sockaddr_storage prefAddr; - struct sockaddr_storage oldAddr; + sockaddr_storage prefAddr; + sockaddr_storage oldAddr; if (mNetMode & RS_NET_MODE_TRY_LOOPBACK) { @@ -996,7 +996,7 @@ bool p3NetMgrIMPL::checkNetAddress() std::cerr << "p3NetMgrIMPL::checkNetAddress() LOOPBACK ... forcing to 127.0.0.1"; std::cerr << std::endl; #endif - sockaddr_storage_ipv4_aton(prefAddr, "127.0.0.1"); + sockaddr_storage_ipv4_aton(prefAddr, "127.0.0.1"); validAddr = true; } else @@ -1012,7 +1012,7 @@ bool p3NetMgrIMPL::checkNetAddress() std::vector addrs; if (getLocalAddresses(addrs)) { - for (auto it = addrs.begin(); it!=addrs.end(); ++it) + for (auto it = addrs.begin(); it != addrs.end(); ++it) { sockaddr_storage& addr(*it); if( sockaddr_storage_isValidNet(addr) && @@ -1060,8 +1060,8 @@ bool p3NetMgrIMPL::checkNetAddress() { RS_STACK_MUTEX(mNetMtx); - - oldAddr = mLocalAddr; + + sockaddr_storage_copy(mLocalAddr, oldAddr); addrChanged = !sockaddr_storage_sameip(prefAddr, mLocalAddr); #ifdef NETMGR_DEBUG_TICK @@ -1087,7 +1087,7 @@ bool p3NetMgrIMPL::checkNetAddress() // update address. sockaddr_storage_copyip(mLocalAddr, prefAddr); - mNetFlags.mLocalAddr = mLocalAddr; + sockaddr_storage_copy(mLocalAddr, mNetFlags.mLocalAddr); if(sockaddr_storage_isLoopbackNet(mLocalAddr)) { @@ -1137,6 +1137,7 @@ bool p3NetMgrIMPL::checkNetAddress() if (sockaddr_storage_sameip(mLocalAddr, mExtAddr)) { sockaddr_storage_setport(mExtAddr, sockaddr_storage_port(mLocalAddr)); + addrChanged = true; } // ensure that address family is set, otherwise windows Barfs. diff --git a/libretroshare/src/pqi/p3peermgr.cc b/libretroshare/src/pqi/p3peermgr.cc index ba3ecbf84..d1e9e4e97 100644 --- a/libretroshare/src/pqi/p3peermgr.cc +++ b/libretroshare/src/pqi/p3peermgr.cc @@ -1239,11 +1239,11 @@ bool p3PeerMgrIMPL::UpdateOwnAddress( const sockaddr_storage& pLocalAddr, sockaddr_storage_copy(pExtAddr, extAddr); sockaddr_storage_ipv6_to_ipv4(extAddr); -#ifdef PEER_DEBUG +//#ifdef PEER_DEBUG std::cerr << "p3PeerMgrIMPL::UpdateOwnAddress(" << sockaddr_storage_tostring(localAddr) << ", " << sockaddr_storage_tostring(extAddr) << ")" << std::endl; -#endif +//#endif if( rsBanList && !rsBanList->isAddressAccepted(localAddr, @@ -1428,21 +1428,25 @@ bool p3PeerMgrIMPL::setLocalAddress(const RsPeerId &id, const struct sockaddr return changed; } -bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_storage &addr) +bool p3PeerMgrIMPL::setExtAddress( const RsPeerId &id, + const sockaddr_storage &addr ) { - bool changed = false; - uint32_t check_res = 0 ; + bool changed = false; + uint32_t check_res = 0; - if(rsBanList!=NULL && !rsBanList->isAddressAccepted(addr,RSBANLIST_CHECKING_FLAGS_BLACKLIST,&check_res)) - { - std::cerr << "(SS) trying to set external contact address for peer " << id << " to a banned address " << sockaddr_storage_iptostring(addr )<< std::endl; - return false ; - } + if( rsBanList!=NULL && !rsBanList->isAddressAccepted( + addr, RSBANLIST_CHECKING_FLAGS_BLACKLIST, &check_res) ) + { + std::cerr << "(SS) trying to set external contact address for peer " + << id << " to a banned address " + << sockaddr_storage_iptostring(addr) << std::endl; + return false; + } if (id == AuthSSL::getAuthSSL()->OwnId()) { { - RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ + RS_STACK_MUTEX(mPeerMtx); if (!sockaddr_storage_same(mOwnState.serveraddr, addr)) { mOwnState.serveraddr = addr; @@ -1455,7 +1459,7 @@ bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_s return changed; } - RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/ + RS_STACK_MUTEX(mPeerMtx); /* check if it is a friend */ std::map::iterator it; if (mFriendList.end() == (it = mFriendList.find(id))) @@ -1463,7 +1467,9 @@ bool p3PeerMgrIMPL::setExtAddress(const RsPeerId &id, const struct sockaddr_s if (mOthersList.end() == (it = mOthersList.find(id))) { #ifdef PEER_DEBUG - std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres info : peer id not found in friend list id: " << id << std::endl; + std::cerr << "p3PeerMgrIMPL::setLocalAddress() cannot add addres " + << "info : peer id not found in friend list id: " << id + << std::endl; #endif return false; } diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 52f6c3dba..c6d686469 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -336,8 +336,8 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d) if(!sockaddr_storage_isnull(ps.localaddr)) { sockaddr_storage_ipv6_to_ipv4(ps.localaddr); - d.localAddr = sockaddr_storage_iptostring(ps.localaddr); - d.localPort = sockaddr_storage_port(ps.localaddr); + d.localAddr = sockaddr_storage_iptostring(ps.localaddr); + d.localPort = sockaddr_storage_port(ps.localaddr); } else { diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index 042a379cb..dcfe29426 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -846,10 +846,15 @@ void ServerPage::updateStatus() return; } - /* load up configuration from rsPeers */ - RsPeerDetails detail; - if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail)) - return; + /* load up configuration from rsPeers */ + RsPeerDetails detail; + if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail)) + { + std::cerr << __PRETTY_FUNCTION__ << " getPeerDetails(...) failed!" + << " This is unexpected report to developers please." + << std::endl; + return; + } /* only update if can't edit */ if (!ui.localPort->isEnabled()) From 7c77e93ff4ebbc7c826de44b54cac8704b408605 Mon Sep 17 00:00:00 2001 From: Phenom Date: Fri, 25 May 2018 17:32:36 +0200 Subject: [PATCH 12/50] Fix AppVeyor Compilation --- appveyor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 4878efe71..47b3c1ef3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -63,7 +63,8 @@ clone_depth: 1 # clone entire repository history if not de environment: global: #Qt: https://www.appveyor.com/docs/installed-software#qt - QTDIR: C:\Qt\5.4\mingw491_32 + # (C:\Qt\5.10 mapped to C:\Qt\5.10.1 for backward compatibility) + QTDIR: C:\Qt\5.10\mingw53_32 MSYS2_ARCH: i686 TARGET: i686_32-pc-msys From 428b331d8efede1e2f39f2fc49216c675d081030 Mon Sep 17 00:00:00 2001 From: sehraf Date: Fri, 25 May 2018 23:12:35 +0200 Subject: [PATCH 13/50] fix for Qt 5.11 Quote from Arch mailing list: - there's been a huge header cleanup in Qt modules. Expect build failures for applications that rely on transitive includes instead of declaring all required headers. Those need to be fixed upstream by explicitely adding the missing includes. --- retroshare-gui/src/gui/Posted/PostedItem.cpp | 1 + retroshare-gui/src/gui/chat/ChatTabWidget.cpp | 2 ++ retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp | 1 + retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp | 1 + 4 files changed, 5 insertions(+) diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index 7d70b3e15..8fc1cc686 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -22,6 +22,7 @@ */ #include +#include #include "rshare.h" #include "PostedItem.h" diff --git a/retroshare-gui/src/gui/chat/ChatTabWidget.cpp b/retroshare-gui/src/gui/chat/ChatTabWidget.cpp index a965bbb32..6dd9c2757 100644 --- a/retroshare-gui/src/gui/chat/ChatTabWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatTabWidget.cpp @@ -20,6 +20,8 @@ * Boston, MA 02110-1301, USA. ****************************************************************/ +#include + #include "ChatTabWidget.h" #include "ui_ChatTabWidget.h" #include "ChatDialog.h" diff --git a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp index d154408b7..72317640c 100644 --- a/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsChannelPostItem.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "rshare.h" #include "GxsChannelPostItem.h" diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index 97ac9dd75..e9773aba9 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -23,6 +23,7 @@ #include #include +#include #include "rshare.h" #include "GxsForumMsgItem.h" From f53e5e8468e1f59a08dac6a1d71f0fb859be6c99 Mon Sep 17 00:00:00 2001 From: sehraf Date: Fri, 25 May 2018 23:59:02 +0200 Subject: [PATCH 14/50] Fix displayed chat link name in id dialog before (decimal): Message in chat room 5327517029776505601 after (proper id): Message in chat room LFD6E08C33A98C658 --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 71bf7be40..17e62d3ca 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1994,7 +1994,8 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const } case RsIdentityUsage::CHAT_LOBBY_MSG_VALIDATION: // Chat lobby msgs are signed, so each time one comes, or a chat lobby event comes, a signature verificaiton happens. { - RetroShareLink l = RetroShareLink::createChatRoom(ChatId(ChatLobbyId(u.mAdditionalId)),QString::number(u.mAdditionalId)); + ChatId id = ChatId(ChatLobbyId(u.mAdditionalId)); + RetroShareLink l = RetroShareLink::createChatRoom(id, QString::fromStdString(id.toStdString())); return tr("Message in chat room %1").arg(l.toHtml()) ; } case RsIdentityUsage::GLOBAL_ROUTER_SIGNATURE_CHECK: // Global router message validation From 9b16e3338f7a3e144dfb66919ed962a6783ce5f7 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 11 May 2018 20:53:29 +0200 Subject: [PATCH 15/50] removed conflicts to retroshare06 in debian control file --- build_scripts/Debian+Ubuntu/debian/control | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build_scripts/Debian+Ubuntu/debian/control b/build_scripts/Debian+Ubuntu/debian/control index 68b7e8a68..f93af67e9 100644 --- a/build_scripts/Debian+Ubuntu/debian/control +++ b/build_scripts/Debian+Ubuntu/debian/control @@ -8,7 +8,7 @@ Homepage: http://retroshare.sourceforge.net Package: retroshare-voip-plugin Architecture: any -Conflicts: retroshare06-voip-plugin +Conflicts: Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare, libspeex1, libspeexdsp1, libqt5multimedia5 Description: RetroShare VOIP plugin This package provides a plugin for RetroShare, a secured Friend-to-Friend communication @@ -17,7 +17,7 @@ Description: RetroShare VOIP plugin Package: retroshare-feedreader-plugin Architecture: any -Conflicts: retroshare06-feedreader-plugin +Conflicts: Depends: ${shlibs:Depends}, ${misc:Depends}, retroshare Description: RetroShare FeedReader plugin Plugin for Retroshare, adding a RSS feed reader tab to retroshare. @@ -25,14 +25,14 @@ Description: RetroShare FeedReader plugin Package: retroshare-nogui Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring -Conflicts: retroshare,retroshare06-nogui +Conflicts: retroshare Description: headless version of Retroshare Headless version of the Retroshare platform. Package: retroshare Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, gnome-keyring -Conflicts: retroshare-nogui,retroshare06 +Conflicts: retroshare-nogui Description: Secure communication with friends RetroShare is a Open Source, private and secure decentralised commmunication platform. It creates mesh of computers linked with TLS connections, From f663600be55cf49e3d8b5d517f0b48babb0f91d4 Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 1 Jun 2018 22:27:59 +0200 Subject: [PATCH 16/50] fixed makeSourcePackage.sh --- build_scripts/Debian+Ubuntu/makeSourcePackage.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build_scripts/Debian+Ubuntu/makeSourcePackage.sh b/build_scripts/Debian+Ubuntu/makeSourcePackage.sh index 2cb83425d..007a52790 100755 --- a/build_scripts/Debian+Ubuntu/makeSourcePackage.sh +++ b/build_scripts/Debian+Ubuntu/makeSourcePackage.sh @@ -2,8 +2,8 @@ ###################### PARAMETERS #################### gitpath="https://github.com/RetroShare/RetroShare.git" -#branch="master" -branch="v0.6.4-official_release" +branch="master" +#branch="v0.6.4-official_release" #bubba3="Y" # comment out to compile for bubba3 ###################################################### @@ -33,7 +33,7 @@ gpgkey="0932399B" date=`git log --pretty=format:"%ai" | head -1 | cut -d\ -f1 | sed -e s/-//g` time=`git log --pretty=format:"%aD" | head -1 | cut -d\ -f5 | sed -e s/://g` -hhsh=`git log --pretty=format:"%H" | head -1 | cut -c1-8` +hhsh=`git log --pretty=format:"%H" | head -1 | cut -c1-8` rev=${date}.${hhsh} useretrotor="false" From 6bb1d3c509aa6bbbdb7e8322118de8c39330f98b Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 1 Jun 2018 22:35:06 +0200 Subject: [PATCH 17/50] updated ubuntu changelog --- build_scripts/Debian+Ubuntu/changelog | 77 +++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/build_scripts/Debian+Ubuntu/changelog b/build_scripts/Debian+Ubuntu/changelog index 4886eb5f0..7bdac642a 100644 --- a/build_scripts/Debian+Ubuntu/changelog +++ b/build_scripts/Debian+Ubuntu/changelog @@ -1,5 +1,82 @@ retroshare (ZZZZZZ-1.XXXXXX~YYYYYY) YYYYYY; urgency=low + f663600 csoler Fri, 1 Jun 2018 22:27:59 +0200 fixed makeSourcePackage.sh + 9b16e33 csoler Fri, 11 May 2018 20:53:29 +0200 removed conflicts to retroshare06 in debian control file + 57dde55 csoler Sat, 26 May 2018 11:23:33 +0200 Merge pull request #1269 from PhenomRetroShare/Add_NeverAskMeForExternalLinkActivated + 33fe823 csoler Sat, 26 May 2018 11:22:47 +0200 Merge pull request #1271 from sehraf/pr_compile-fix-unused-services + 65beb2c csoler Sat, 26 May 2018 11:09:41 +0200 Merge pull request #1275 from sehraf/pr_fix-IDdialog-chat-link + d8b3fc0 csoler Sat, 26 May 2018 11:08:46 +0200 Merge pull request #1274 from PhenomRetroShare/Fix_AppVeyorCompil + f53e5e8 sehraf Fri, 25 May 2018 23:59:02 +0200 Fix displayed chat link name in id dialog before (decimal): Message in chat room 5327517029776505601 after (proper id): Message in chat room LFD6E08C33A98C658 + 428b331 sehraf Fri, 25 May 2018 23:12:35 +0200 fix for Qt 5.11 + 7c77e93 Phenom Fri, 25 May 2018 17:32:36 +0200 Fix AppVeyor Compilation + de65cb6 csoler Tue, 22 May 2018 23:59:26 +0200 Merge pull request #1272 from G10h4ck/net_little_fixes + 1ad1fdc Gioacc Tue, 22 May 2018 19:17:37 +0200 p3NetMgrIMPL::checkNetAddress() notify if port change + 0bf02e2 Gioacc Tue, 22 May 2018 19:14:25 +0200 pqissludp::Initiate_Connection() check remote_addr to be IPv4 before use + 0c19a56 sehraf Mon, 21 May 2018 14:55:10 +0200 compile fix gxsphoto + 92b21d7 sehraf Mon, 21 May 2018 14:26:46 +0200 compile fix wikipoos + 8f107cc Phenom Sat, 19 May 2018 16:37:29 +0200 Add Never Ask Me For External Link Activated + 186617f Gioacc Thu, 17 May 2018 16:43:14 +0200 Fix missing include + 28981b6 csoler Wed, 16 May 2018 13:37:02 +0200 Merge pull request #1251 from PhenomRetroShare/Fix_Cppcheck(duplInheritedMember)InRsItem + d11f88c csoler Wed, 16 May 2018 13:33:25 +0200 Merge pull request #1252 from PhenomRetroShare/Fix_Cppcheck(duplInheritedMember)InbdNode + 2145911 csoler Wed, 16 May 2018 13:30:56 +0200 Merge pull request #1262 from PhenomRetroShare/Fix_PartialDirCheck + e232000 csoler Wed, 16 May 2018 13:28:23 +0200 Merge pull request #1266 from csoler/v0.6-FT + 3f88e3e csoler Wed, 16 May 2018 13:24:52 +0200 added check to avoid hashing files that are currently being modified + 8451550 csoler Wed, 16 May 2018 11:40:39 +0200 added missing licence to file_tree.h + 291c86e csoler Wed, 16 May 2018 11:17:22 +0200 Merge pull request #1265 from csoler/v0.6-GxsFix + 4661329 csoler Wed, 16 May 2018 11:15:18 +0200 fixed bug causing new forums and identities to not show up immediately + 9f37b63 G10h4c Wed, 16 May 2018 10:49:28 +0200 Merge pull request #1264 from G10h4ck/channel_json_api_v2 + 181d99e Gioacc Wed, 16 May 2018 10:38:47 +0200 Give proper error message if Qt version is too old + f12cd57 Phenom Sat, 12 May 2018 14:31:17 +0200 Fix Partial Dir Check + 57cff61 csoler Fri, 11 May 2018 20:28:53 +0200 fixed merge + ecbd115 csoler Fri, 11 May 2018 20:24:24 +0200 added missing include path for libretroshare/src in libresapi + fe5ea9e csoler Fri, 11 May 2018 17:37:15 +0200 additional fixes to debian packaging files + 2173aab csoler Fri, 11 May 2018 17:02:58 +0200 fixed rules file again + 84a02cb csoler Fri, 11 May 2018 16:39:49 +0200 added missing targets in rules file + 4b6304e csoler Fri, 11 May 2018 16:33:19 +0200 few fixes according to lintian complaints + c2492fe csoler Thu, 10 May 2018 23:10:16 +0200 fixed a few lintian errors in debian/control + 9f5409b csoler Thu, 10 May 2018 22:04:11 +0200 fixed email to match mentors login + 45fdbb4 csoler Thu, 10 May 2018 22:03:39 +0200 fixed email to match mentors login + b4ada80 csoler Wed, 9 May 2018 13:54:40 +0200 removed > 3.4.1 in debian/control, because pbuilder would not build + e81c82e csoler Wed, 9 May 2018 13:37:25 +0200 added notes file for debian release + 4d287d6 csoler Wed, 9 May 2018 13:27:16 +0200 fixed weird mistake in grouter which causes an issue only in gcc > 8 + 889c277 csoler Wed, 9 May 2018 10:15:32 +0200 fixed packaging script for debian release + f406d9a csoler Wed, 9 May 2018 10:15:02 +0200 updated debian/control to be the control file for stretch. Updated copyright notice + 186ff0f csoler Wed, 9 May 2018 10:12:34 +0200 created proper debian changelog using dch and updated project url + 6d67936 csoler Tue, 8 May 2018 15:34:44 +0200 Merge pull request #1253 from PhenomRetroShare/Add_LastPostColInGroupTreeWidget + 2ebacf3 Phenom Tue, 8 May 2018 12:08:08 +0200 Add Last Post Column in GroupTreeWidget. + 4d748bd Phenom Mon, 7 May 2018 18:05:07 +0200 Fix CppCheck duplInheritedMember warning in bdNode + f39fd06 Phenom Mon, 7 May 2018 17:29:11 +0200 Fix CppCheck duplInheritedMember warning in RsItem + 1352631 thunde Mon, 7 May 2018 06:42:52 +0200 Updated Windows build environment + 38ac234 thunde Mon, 7 May 2018 07:30:29 +0200 Fixed Windows compile with pre-compiled libraries Added new variable EXTERNAL_LIB_DIR to specify path of external libraries + d9a75a9 thunde Sun, 29 Apr 2018 20:40:05 +0200 Added RapidJSON to Windows build environment + 5b607ad csoler Sun, 6 May 2018 23:53:45 +0200 Merge pull request #1245 from PhenomRetroShare/AddContextMenuForGxsIdInTextChatBrowser + a6821f4 csoler Sun, 6 May 2018 23:02:18 +0200 Merge pull request #1249 from sehraf/pr_libsecret + c20436e csoler Sun, 6 May 2018 22:59:20 +0200 Merge pull request #1250 from PhenomRetroShare/Fix_CppCheckerWarningInFtController + d8dc2a8 csoler Sun, 6 May 2018 22:57:57 +0200 Merge pull request #1246 from PhenomRetroShare/Add_GxsIdInRestoredChatMsg + dca33da Phenom Sun, 6 May 2018 18:53:29 +0200 Fix CppCheck in ftcontroller.cc + c89e36a sehraf Fri, 4 May 2018 20:52:31 +0200 add auto selection of libsecret with fallback to libgnome-keyring + 1129bcb sehraf Fri, 4 May 2018 20:47:41 +0200 Add support for libsecret + 10badf5 sehraf Fri, 4 May 2018 20:43:40 +0200 fix retroshare-nogui.pro autologin + 676c070 csoler Thu, 3 May 2018 15:55:21 +0200 extended the rapid_json trick to plugins + 5f12b60 csoler Thu, 3 May 2018 15:22:39 +0200 added -lgnome-keyring to unix LIBS when rs_autologin is set + bfe8e40 csoler Thu, 3 May 2018 15:22:03 +0200 updated ubuntu changelog + 98f0052 Phenom Thu, 3 May 2018 15:04:22 +0200 Add GxsId in Restored Chat Message. + ecba4c2 Phenom Wed, 2 May 2018 20:31:52 +0200 Add Context Menu for GxsId in lobby textBrowser. + 91ed367 csoler Thu, 3 May 2018 13:45:44 +0200 added packaging for ubuntu bionic + 56e8134 cyril soler Thu, 3 May 2018 11:32:24 +0200 removed sqlite3 lib from ld when using sqlcipher. + 1366f61 csoler Wed, 2 May 2018 23:51:46 +0200 Merge pull request #1241 from RetroPooh/chatimgattprev1 + 8e111c2 csoler Wed, 2 May 2018 22:46:27 +0200 added rapidjson-1.1.0 code hard-coded in the source directory to allow everyone to compile without the need to tweak too much. When v1.1.0 is mainstream (espcially on ubuntu) we can revert back to an external dependency + 48c4b4c G10h4c Sat, 28 Apr 2018 09:34:14 +0200 Merge pull request #1242 from beardog108/master + ccede9d G10h4c Sat, 28 Apr 2018 09:33:14 +0200 Merge pull request #1243 from sehraf/pr_fix-make-install + 10daf3b sehraf Sat, 28 Apr 2018 09:06:10 +0200 Fix 'make install' + 82a00c2 KevinF Fri, 27 Apr 2018 15:34:43 -0500 added rapidjson to package installation command on Debian/OpenSUSE/Arch + be75e89 Gioacc Fri, 27 Apr 2018 20:55:38 +0200 Fix compialtion after merge + f3ae61b Gioacc Fri, 27 Apr 2018 18:17:09 +0200 Merge branch 'json_experiments' + + -- Retroshare Dev Team Thu, 03 May 2018 12:00:00 +0100 + +retroshare (0.6.4-1.20180503.676c0701~xenial) xenial; urgency=low + 2dc69cb RetroP Fri, 27 Apr 2018 16:50:00 +0300 embed preview for images on file attach in chat c199199 Gioacc Sun, 8 Apr 2018 12:37:41 +0200 pqissl silence extra debug message 8245d74 csoler Sat, 7 Apr 2018 14:33:58 +0200 Merge pull request #1230 from csoler/master From 9a64f80182f8c03fe65586f4bc098f65decdd268 Mon Sep 17 00:00:00 2001 From: sehraf Date: Sun, 3 Jun 2018 17:11:11 +0200 Subject: [PATCH 18/50] handle backspace when entering password --- retroshare-nogui/src/TerminalApiClient.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/retroshare-nogui/src/TerminalApiClient.cpp b/retroshare-nogui/src/TerminalApiClient.cpp index f4ffa4af1..b90ed7dbc 100644 --- a/retroshare-nogui/src/TerminalApiClient.cpp +++ b/retroshare-nogui/src/TerminalApiClient.cpp @@ -103,6 +103,15 @@ static std::string readStringFromKeyboard(bool passwd_mode) while((c=getchar()) != '\n') { + // handle backspace + if (c == 127) { + if(s.length()!=0) { + std::cout << "\b \b"; + s.resize(s.length()-1); + } + continue; + } + if(passwd_mode) putchar('*') ; else From d7b366de2315a70a614faca326f49ce1b65acb75 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Thu, 7 Jun 2018 14:54:58 +0200 Subject: [PATCH 19/50] RS-gui Solve unused parameter warning --- retroshare-gui/src/gui/RemoteDirModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/RemoteDirModel.cpp b/retroshare-gui/src/gui/RemoteDirModel.cpp index 6f7608e77..22fb0af5b 100644 --- a/retroshare-gui/src/gui/RemoteDirModel.cpp +++ b/retroshare-gui/src/gui/RemoteDirModel.cpp @@ -374,7 +374,7 @@ const QIcon& RetroshareDirModel::getFlagsIcon(FileStorageFlags flags) return *static_icons[n] ; } -QVariant RetroshareDirModel::filterRole(const DirDetails& details,int coln) const +QVariant RetroshareDirModel::filterRole(const DirDetails& details, int /*coln*/) const { if(mFilteredPointers.empty() || mFilteredPointers.find(details.ref) != mFilteredPointers.end()) return QString(RETROSHARE_DIR_MODEL_FILTER_STRING); From 3eff851cdb8a738a9ebda9c180a569a3ec9a4ad9 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Thu, 7 Jun 2018 14:57:31 +0200 Subject: [PATCH 20/50] Improve deprecation of RS_TOKREQ_ANSTYPE_* --- libretroshare/src/retroshare/rstokenservice.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libretroshare/src/retroshare/rstokenservice.h b/libretroshare/src/retroshare/rstokenservice.h index bcb273dd5..079f34023 100644 --- a/libretroshare/src/retroshare/rstokenservice.h +++ b/libretroshare/src/retroshare/rstokenservice.h @@ -61,14 +61,17 @@ /* TODO CLEANUP: RS_TOKREQ_ANSTYPE_* values are meaningless and not used by * RsTokenService or its implementation, and may be arbitrarly defined by each - * GXS client as they are of no usage, their use is deprecated */ + * GXS client as they are of no usage, their use is deprecated, up until the + * definitive cleanup is done new code must use RS_DEPRECATED_TOKREQ_ANSTYPE for + * easier cleanup. */ #ifndef RS_NO_WARN_DEPRECATED # warning RS_TOKREQ_ANSTYPE_* macros are deprecated! #endif -#define RS_TOKREQ_ANSTYPE_LIST 0x0001 -#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002 -#define RS_TOKREQ_ANSTYPE_DATA 0x0003 -#define RS_TOKREQ_ANSTYPE_ACK 0x0004 +#define RS_DEPRECATED_TOKREQ_ANSTYPE 0x0000 +#define RS_TOKREQ_ANSTYPE_LIST 0x0001 +#define RS_TOKREQ_ANSTYPE_SUMMARY 0x0002 +#define RS_TOKREQ_ANSTYPE_DATA 0x0003 +#define RS_TOKREQ_ANSTYPE_ACK 0x0004 /*! From e81b81dff137e468cbf164811a736863074f00aa Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Thu, 7 Jun 2018 14:59:00 +0200 Subject: [PATCH 21/50] libresapi improve qmake optional builds --- libresapi/src/libresapi.pro | 2 -- libresapi/src/use_libresapi.pri | 5 +++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/libresapi/src/libresapi.pro b/libresapi/src/libresapi.pro index 885d430f5..6f6db46a4 100644 --- a/libresapi/src/libresapi.pro +++ b/libresapi/src/libresapi.pro @@ -16,8 +16,6 @@ INCLUDEPATH += ../../rapidjson-1.1.0 INCLUDEPATH += ../../libretroshare/src libresapilocalserver { - CONFIG *= qt - QT *= network SOURCES *= api/ApiServerLocal.cpp HEADERS *= api/ApiServerLocal.h } diff --git a/libresapi/src/use_libresapi.pri b/libresapi/src/use_libresapi.pri index e9b1753a2..c84103f1b 100644 --- a/libresapi/src/use_libresapi.pri +++ b/libresapi/src/use_libresapi.pri @@ -10,6 +10,11 @@ sLibs = mLibs = dLibs = +libresapilocalserver { + CONFIG *= qt + QT *= network +} + libresapihttpserver { mLibs *= microhttpd } From 508951d26f502fdd7265871df9a77629d1ec3be3 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Thu, 7 Jun 2018 15:00:11 +0200 Subject: [PATCH 22/50] Improve channels JSON API v2 list_channels return only with metadata (including the data produced very big JSON saturating some client buffer implementation) add get_channel_info to get full channel data with optional thumbnail thumbnail is sent by default but can be avoided adding "want_thumbnail":false to the JSON query rename get_channel to get_channel_content --- libresapi/src/api/ChannelsHandler.cpp | 117 ++++++++++++++++++++------ libresapi/src/api/ChannelsHandler.h | 3 +- 2 files changed, 94 insertions(+), 26 deletions(-) diff --git a/libresapi/src/api/ChannelsHandler.cpp b/libresapi/src/api/ChannelsHandler.cpp index 3c5084578..c79d693b1 100644 --- a/libresapi/src/api/ChannelsHandler.cpp +++ b/libresapi/src/api/ChannelsHandler.cpp @@ -51,7 +51,8 @@ ChannelsHandler::ChannelsHandler(RsGxsChannels& channels): mChannels(channels) { addResourceHandler("list_channels", this, &ChannelsHandler::handleListChannels); - addResourceHandler("get_channel", this, &ChannelsHandler::handleGetChannel); + addResourceHandler("get_channel_info", this, &ChannelsHandler::handleGetChannelInfo); + addResourceHandler("get_channel_content", this, &ChannelsHandler::handleGetChannelContent); addResourceHandler("toggle_subscribe", this, &ChannelsHandler::handleToggleSubscription); addResourceHandler("toggle_auto_download", this, &ChannelsHandler::handleToggleAutoDownload); addResourceHandler("toggle_read", this, &ChannelsHandler::handleTogglePostRead); @@ -62,12 +63,77 @@ ChannelsHandler::ChannelsHandler(RsGxsChannels& channels): mChannels(channels) void ChannelsHandler::handleListChannels(Request& /*req*/, Response& resp) { RsTokReqOptions opts; - opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_META; uint32_t token; RsTokenService& tChannels = *mChannels.getTokenService(); - tChannels.requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts); + tChannels.requestGroupInfo(token, RS_DEPRECATED_TOKREQ_ANSTYPE, opts); + + time_t start = time(NULL); + while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) + &&(tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_FAILED) + &&((time(NULL) < (start+10)))) rstime::rs_usleep(500*1000); + + std::list grps; + if( tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE + && mChannels.getGroupSummary(token, grps) ) + { + for( RsGroupMetaData& grp : grps ) + { + KeyValueReference id("channel_id", grp.mGroupId); + KeyValueReference vis_msg("visible_msg_count", grp.mVisibleMsgCount); + bool own = (grp.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); + bool subscribed = IS_GROUP_SUBSCRIBED(grp.mSubscribeFlags); + std::string lastPostTsStr = std::to_string(grp.mLastPost); + std::string publishTsStr = std::to_string(grp.mPublishTs); + resp.mDataStream.getStreamToMember() + << id + << makeKeyValueReference("name", grp.mGroupName) + << makeKeyValueReference("last_post_ts", lastPostTsStr) + << makeKeyValueReference("popularity", grp.mPop) + << makeKeyValueReference("publish_ts", publishTsStr) + << vis_msg + << makeKeyValueReference("group_status", grp.mGroupStatus) + << makeKeyValueReference("author_id", grp.mAuthorId) + << makeKeyValueReference("parent_grp_id", grp.mParentGrpId) + << makeKeyValueReference("own", own) + << makeKeyValueReference("subscribed", subscribed); + } + + resp.setOk(); + } + else resp.setFail("Cant get data from GXS!"); +} + +void ChannelsHandler::handleGetChannelInfo(Request& req, Response& resp) +{ + std::string chanIdStr; + req.mStream << makeKeyValueReference("channel_id", chanIdStr); + if(chanIdStr.empty()) + { + resp.setFail("channel_id required!"); + return; + } + + RsGxsGroupId chanId(chanIdStr); + if(chanId.isNull()) + { + resp.setFail("Invalid channel_id:" + chanIdStr); + return; + } + + bool wantThumbnail = true; + req.mStream << makeKeyValueReference("want_thumbnail", wantThumbnail); + + std::list groupIds; groupIds.push_back(chanId); + RsTokReqOptions opts; + opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA; + uint32_t token; + + RsTokenService& tChannels = *mChannels.getTokenService(); + tChannels.requestGroupInfo( token, RS_DEPRECATED_TOKREQ_ANSTYPE, + opts, groupIds ); time_t start = time(NULL); while((tChannels.requestStatus(token) != RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE) @@ -78,33 +144,35 @@ void ChannelsHandler::handleListChannels(Request& /*req*/, Response& resp) if( tChannels.requestStatus(token) == RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE && mChannels.getGroupData(token, grps) ) { - for( std::vector::iterator vit = grps.begin(); - vit != grps.end(); ++vit ) + for( RsGxsChannelGroup& grp : grps ) { - RsGxsChannelGroup& grp = *vit; KeyValueReference id("channel_id", grp.mMeta.mGroupId); KeyValueReference vis_msg("visible_msg_count", grp.mMeta.mVisibleMsgCount); bool own = (grp.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN); bool subscribed = IS_GROUP_SUBSCRIBED(grp.mMeta.mSubscribeFlags); std::string lastPostTsStr = std::to_string(grp.mMeta.mLastPost); std::string publishTsStr = std::to_string(grp.mMeta.mPublishTs); - std::string thumbnail_base64; - Radix64::encode(grp.mImage.mData, grp.mImage.mSize, thumbnail_base64); - resp.mDataStream.getStreamToMember() - << id - << makeKeyValueReference("name", grp.mMeta.mGroupName) - << makeKeyValueReference("last_post_ts", lastPostTsStr) - << makeKeyValueReference("popularity", grp.mMeta.mPop) - << makeKeyValueReference("publish_ts", publishTsStr) - << vis_msg - << makeKeyValueReference("group_status", grp.mMeta.mGroupStatus) - << makeKeyValueReference("author_id", grp.mMeta.mAuthorId) - << makeKeyValueReference("parent_grp_id", grp.mMeta.mParentGrpId) - << makeKeyValueReference("description", grp.mDescription) - << makeKeyValueReference("own", own) - << makeKeyValueReference("subscribed", subscribed) - << makeKeyValueReference("thumbnail_base64_png", thumbnail_base64) - << makeKeyValueReference("auto_download", grp.mAutoDownload); + StreamBase& rgrp(resp.mDataStream.getStreamToMember()); + rgrp << id + << makeKeyValueReference("name", grp.mMeta.mGroupName) + << makeKeyValueReference("last_post_ts", lastPostTsStr) + << makeKeyValueReference("popularity", grp.mMeta.mPop) + << makeKeyValueReference("publish_ts", publishTsStr) + << vis_msg + << makeKeyValueReference("group_status", grp.mMeta.mGroupStatus) + << makeKeyValueReference("author_id", grp.mMeta.mAuthorId) + << makeKeyValueReference("parent_grp_id", grp.mMeta.mParentGrpId) + << makeKeyValueReference("description", grp.mDescription) + << makeKeyValueReference("own", own) + << makeKeyValueReference("subscribed", subscribed) + << makeKeyValueReference("auto_download", grp.mAutoDownload); + + if(wantThumbnail) + { + std::string thumbnail_base64; + Radix64::encode(grp.mImage.mData, grp.mImage.mSize, thumbnail_base64); + rgrp << makeKeyValueReference("thumbnail_base64_png", thumbnail_base64); + } } resp.setOk(); @@ -112,7 +180,7 @@ void ChannelsHandler::handleListChannels(Request& /*req*/, Response& resp) else resp.setFail("Cant get data from GXS!"); } -void ChannelsHandler::handleGetChannel(Request& req, Response& resp) +void ChannelsHandler::handleGetChannelContent(Request& req, Response& resp) { std::string chanIdStr; req.mStream << makeKeyValueReference("channel_id", chanIdStr); @@ -120,7 +188,6 @@ void ChannelsHandler::handleGetChannel(Request& req, Response& resp) { resp.setFail("channel_id required!"); return; - } RsGxsGroupId chanId(chanIdStr); diff --git a/libresapi/src/api/ChannelsHandler.h b/libresapi/src/api/ChannelsHandler.h index b40f23b73..55c5fec2d 100644 --- a/libresapi/src/api/ChannelsHandler.h +++ b/libresapi/src/api/ChannelsHandler.h @@ -30,7 +30,8 @@ struct ChannelsHandler : ResourceRouter private: void handleListChannels(Request& req, Response& resp); - void handleGetChannel(Request& req, Response& resp); + void handleGetChannelInfo(Request& req, Response& resp); + void handleGetChannelContent(Request& req, Response& resp); void handleToggleSubscription(Request& req, Response& resp); void handleCreateChannel(Request& req, Response& resp); void handleToggleAutoDownload(Request& req, Response& resp); From 8edb1f7535f13f359f11b11089cfa1fd6f12d0d8 Mon Sep 17 00:00:00 2001 From: cyril soler Date: Fri, 8 Jun 2018 14:32:25 +0200 Subject: [PATCH 23/50] fixed problem causing infinite loop of net reset in p3NetMgr --- libretroshare/src/pqi/p3netmgr.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/pqi/p3netmgr.cc b/libretroshare/src/pqi/p3netmgr.cc index 3381705cd..be119fd45 100644 --- a/libretroshare/src/pqi/p3netmgr.cc +++ b/libretroshare/src/pqi/p3netmgr.cc @@ -1134,8 +1134,11 @@ bool p3NetMgrIMPL::checkNetAddress() * are the same (modify server)... this mismatch can * occur when the local port is changed.... */ - if (sockaddr_storage_sameip(mLocalAddr, mExtAddr)) + if (sockaddr_storage_sameip(mLocalAddr, mExtAddr) && sockaddr_storage_port(mLocalAddr) != sockaddr_storage_port(mExtAddr)) { +#ifdef NETMGR_DEBUG_RESET + std::cerr << "p3NetMgrIMPL::checkNetAddress() local and external ports are not the same. Setting external port to " << sockaddr_storage_port(mLocalAddr) << std::endl; +#endif sockaddr_storage_setport(mExtAddr, sockaddr_storage_port(mLocalAddr)); addrChanged = true; } From 4eda2779222812d3ffedaacf1fc5b6e526e6b8e5 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Thu, 31 May 2018 17:59:55 +0200 Subject: [PATCH 24/50] Added missing declare of metatype --- retroshare-gui/src/gui/chat/ChatLobbyDialog.h | 1 + 1 file changed, 1 insertion(+) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h index f70eb27a6..6f3f52096 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.h +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.h @@ -28,6 +28,7 @@ #include "ChatDialog.h" Q_DECLARE_METATYPE(RsGxsId) +Q_DECLARE_METATYPE(QList) class GxsIdChooser ; class QToolButton; From 5953e7bbe892654fd96fdd77d9d0c998cff8fb7a Mon Sep 17 00:00:00 2001 From: thunder2 Date: Thu, 31 May 2018 19:19:41 +0200 Subject: [PATCH 25/50] Windows build environment - Added "-spec win32-g++" to build.bat - Added "--no-check-certificate" to download-file.bat - Fixed build installer --- build_scripts/Windows/build/build-installer.bat | 2 +- build_scripts/Windows/build/build.bat | 2 +- build_scripts/Windows/tools/download-file.bat | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build_scripts/Windows/build/build-installer.bat b/build_scripts/Windows/build/build-installer.bat index 1063d8680..c986adbba 100644 --- a/build_scripts/Windows/build/build-installer.bat +++ b/build_scripts/Windows/build/build-installer.bat @@ -9,7 +9,7 @@ call "%EnvPath%\env.bat" if errorlevel 1 goto error_env :: Initialize environment -call "%~dp0env.bat" %* +call "%~dp0env.bat" standard if errorlevel 2 exit /B 2 if errorlevel 1 goto error_env diff --git a/build_scripts/Windows/build/build.bat b/build_scripts/Windows/build/build.bat index 30d20c59d..3fa8fb49a 100644 --- a/build_scripts/Windows/build/build.bat +++ b/build_scripts/Windows/build/build.bat @@ -52,7 +52,7 @@ title Build - %SourceName%%RsType%-%RsBuildConfig% [qmake] set RS_QMAKE_CONFIG=%RsBuildConfig% version_detail_bash_script rs_autologin retroshare_plugins if "%RsRetroTor%"=="1" set RS_QMAKE_CONFIG=%RS_QMAKE_CONFIG% retrotor -qmake "%SourcePath%\RetroShare.pro" -r "CONFIG+=%RS_QMAKE_CONFIG%" "EXTERNAL_LIB_DIR=%BuildLibsPath%\libs" +qmake "%SourcePath%\RetroShare.pro" -r -spec win32-g++ "CONFIG+=%RS_QMAKE_CONFIG%" "EXTERNAL_LIB_DIR=%BuildLibsPath%\libs" if errorlevel 1 goto error echo. diff --git a/build_scripts/Windows/tools/download-file.bat b/build_scripts/Windows/tools/download-file.bat index d42349ccb..b0e93be5f 100644 --- a/build_scripts/Windows/tools/download-file.bat +++ b/build_scripts/Windows/tools/download-file.bat @@ -8,6 +8,6 @@ if "%~2"=="" ( ) ::"%EnvCurlExe%" -L -k "%~1" -o "%~2" -"%EnvWgetExe%" --continue "%~1" --output-document="%~2" +"%EnvWgetExe%" --no-check-certificate --continue "%~1" --output-document="%~2" exit /B %ERRORLEVEL% From 5d237c8753d94443e5f8e715b077e8500ef26640 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sat, 9 Jun 2018 17:08:13 +0200 Subject: [PATCH 26/50] Improve libresapi qmake files --- libresapi/src/libresapi.pro | 3 --- libresapi/src/use_libresapi.pri | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libresapi/src/libresapi.pro b/libresapi/src/libresapi.pro index 6f6db46a4..161ce9bf7 100644 --- a/libresapi/src/libresapi.pro +++ b/libresapi/src/libresapi.pro @@ -21,9 +21,6 @@ libresapilocalserver { } libresapi_settings { - CONFIG *= qt - QT *= core - SOURCES += api/SettingsHandler.cpp HEADERS += api/SettingsHandler.h } diff --git a/libresapi/src/use_libresapi.pri b/libresapi/src/use_libresapi.pri index c84103f1b..ee4c87d46 100644 --- a/libresapi/src/use_libresapi.pri +++ b/libresapi/src/use_libresapi.pri @@ -15,6 +15,11 @@ libresapilocalserver { QT *= network } +libresapi_settings { + CONFIG *= qt + QT *= core +} + libresapihttpserver { mLibs *= microhttpd } From 1825b263f00eef69f39616e1cf13a4c1c35d8d0c Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sat, 9 Jun 2018 17:21:59 +0200 Subject: [PATCH 27/50] ChunkMap::reAskPendingChunk fix unused parameter warning --- libretroshare/src/ft/ftchunkmap.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libretroshare/src/ft/ftchunkmap.cc b/libretroshare/src/ft/ftchunkmap.cc index 64411ac58..800408ec6 100644 --- a/libretroshare/src/ft/ftchunkmap.cc +++ b/libretroshare/src/ft/ftchunkmap.cc @@ -257,7 +257,9 @@ void ChunkMap::setChunkCheckingResult(uint32_t chunk_number,bool check_succeeded } } -bool ChunkMap::reAskPendingChunk(const RsPeerId& peer_id,uint32_t size_hint,uint64_t& offset,uint32_t& size) +bool ChunkMap::reAskPendingChunk( const RsPeerId& peer_id, + uint32_t /*size_hint*/, + uint64_t& offset, uint32_t& size) { // make sure that we're at the end of the file. No need to be too greedy in the middle of it. From 9886840b79d617a32764ad52ef4747f5fd999250 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sat, 9 Jun 2018 17:59:11 +0200 Subject: [PATCH 28/50] Provide proper constructor for SerializeContext Deprecate constructor that depends on deprecated declarations. --- libretroshare/src/serialiser/rsserializer.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libretroshare/src/serialiser/rsserializer.h b/libretroshare/src/serialiser/rsserializer.h index dcc4d089f..9640694e0 100644 --- a/libretroshare/src/serialiser/rsserializer.h +++ b/libretroshare/src/serialiser/rsserializer.h @@ -225,6 +225,13 @@ struct RsGenericSerializer : RsSerialType /** Allow shared allocator usage to avoid costly JSON deepcopy for * nested RsSerializable */ SerializeContext( + uint8_t *data, uint32_t size, + SerializationFlags flags = SERIALIZATION_FLAG_NONE, + RsJson::AllocatorType* allocator = nullptr) : + mData(data), mSize(size), mOffset(0), mOk(true), mFlags(flags), + mJson(rapidjson::kObjectType, allocator) {} + + RS_DEPRECATED SerializeContext( uint8_t *data, uint32_t size, SerializationFormat format, SerializationFlags flags, RsJson::AllocatorType* allocator = nullptr) : From 6805875333fe4c2e64457b89f193fbf27c84c816 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sun, 10 Jun 2018 15:10:13 +0200 Subject: [PATCH 29/50] Finally get rid of the annoying MASQUARADING typo --- libbitdht/src/bitdht/bdnode.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libbitdht/src/bitdht/bdnode.cc b/libbitdht/src/bitdht/bdnode.cc index f7ae5e220..95d1d1c7e 100644 --- a/libbitdht/src/bitdht/bdnode.cc +++ b/libbitdht/src/bitdht/bdnode.cc @@ -518,7 +518,7 @@ void bdNode::checkPotentialPeer(bdId *id, bdId *src) #ifndef DISABLE_BAD_PEER_FILTER std::cerr << "bdNode::checkPotentialPeer("; mFns->bdPrintId(std::cerr, id); - std::cerr << ") MASQARADING AS KNOWN PEER - FLAGGING AS BAD"; + std::cerr << ") MASQUERADING AS KNOWN PEER - FLAGGING AS BAD"; std::cerr << std::endl; // Stores in queue for later callback and desemination around the network. @@ -603,7 +603,7 @@ void bdNode::addPeer(const bdId *id, uint32_t peerflags) std::cerr << "bdNode::addPeer("; mFns->bdPrintId(std::cerr, id); std::cerr << ", " << std::hex << peerflags << std::dec; - std::cerr << ") MASQARADING AS KNOWN PEER - FLAGGING AS BAD"; + std::cerr << ") MASQUERADING AS KNOWN PEER - FLAGGING AS BAD"; std::cerr << std::endl; From 1f76108a9e3ec5dacc1cd107ed57848f1a92eb0e Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 11 Jun 2018 14:21:28 +0200 Subject: [PATCH 30/50] Remove some cruft from build files --- libretroshare/src/libretroshare.pro | 14 -------------- retroshare-gui/src/gui/settings/rsharesettings.cpp | 4 ++-- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index e401ed8ee..729c9186d 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -267,8 +267,6 @@ win32-g++ { DEFINES += USE_CMD_ARGS - CONFIG += upnp_miniupnpc - wLibs = ws2_32 gdi32 uuid iphlpapi crypt32 ole32 winmm LIBS += $$linkDynamicLibs(wLibs) } @@ -279,22 +277,10 @@ mac { QMAKE_CC = $${QMAKE_CXX} OBJECTS_DIR = temp/obj MOC_DIR = temp/moc - #DEFINES = WINDOWS_SYS WIN32 STATICLIB MINGW - #DEFINES *= MINIUPNPC_VERSION=13 - - CONFIG += upnp_miniupnpc - CONFIG += c++11 - - # zeroconf disabled at the end of libretroshare.pro (but need the code) - #CONFIG += zeroconf - #CONFIG += zcnatassist # Beautiful Hack to fix 64bit file access. QMAKE_CXXFLAGS *= -Dfseeko64=fseeko -Dftello64=ftello -Dfopen64=fopen -Dvstatfs64=vstatfs - #GPG_ERROR_DIR = ../../../../libgpg-error-1.7 - #GPGME_DIR = ../../../../gpgme-1.1.8 - for(lib, LIB_DIR):LIBS += -L"$$lib" for(bin, BIN_DIR):LIBS += -L"$$bin" diff --git a/retroshare-gui/src/gui/settings/rsharesettings.cpp b/retroshare-gui/src/gui/settings/rsharesettings.cpp index 91b306cc0..e37216e39 100644 --- a/retroshare-gui/src/gui/settings/rsharesettings.cpp +++ b/retroshare-gui/src/gui/settings/rsharesettings.cpp @@ -34,8 +34,8 @@ #include #include -#if defined(Q_OS_WIN) -#include +#ifdef Q_OS_WIN +# include #endif /* Retroshare's Settings */ From 8a901e658cd42a27a5738e08fe51528e2090b717 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 11 Jun 2018 14:29:07 +0200 Subject: [PATCH 31/50] Improve appveyor CI --- appveyor.yml | 155 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 117 insertions(+), 38 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 47b3c1ef3..6f26a1c67 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -52,7 +52,7 @@ on_finish: #- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) # clone directory -clone_folder: c:\projects\RetroShare +clone_folder: C:\projects\RetroShare # fetch repository as zip archive #shallow_clone: true # default is "false" @@ -62,20 +62,18 @@ clone_depth: 1 # clone entire repository history if not de environment: global: - #Qt: https://www.appveyor.com/docs/installed-software#qt - # (C:\Qt\5.10 mapped to C:\Qt\5.10.1 for backward compatibility) - QTDIR: C:\Qt\5.10\mingw53_32 +## Qt: https://www.appveyor.com/docs/installed-software#qt +# QTDIR: C:\Qt\5.10.1\mingw53_32 MSYS2_ARCH: i686 TARGET: i686_32-pc-msys + MINGW_PREFIX: C:\msys64\mingw32 + RS_DEPLOY: RetroShare_deploy # build cache to preserve files/folders between builds -cache: - - c:\projects\libs -# - packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified -# - projectA\libs -# - node_modules # local npm modules -# - %APPDATA%\npm-cache # npm cache +#cache: +# Disabled because it's bigger then supported by appveyor free plan +# - C:\msys64\var\cache\pacman\pkg # scripts that run after cloning repository #install: @@ -90,24 +88,12 @@ install: # Configuring MSys2 - set PATH=C:\msys64\usr\bin;%PATH% - set PATH=C:\msys64\mingw32\bin;%PATH% + - pacman --noconfirm -S mingw-w64-i686-qt5 mingw-w64-i686-miniupnpc mingw-w64-i686-sqlcipher mingw-w64-i686-libmicrohttpd + #- pacman --noconfirm -S mingw-w64-i686-qt5-static mingw-w64-i686-miniupnpc mingw-w64-i686-sqlcipher mingw-w64-i686-libmicrohttpd + #- set PATH=C:\msys64\mingw32\qt5-static\bin\;%PATH% + # Configuring Qt - - set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw491_32\bin;%PATH% - # Install all default programms - #- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy base-devel git mercurial cvs wget p7zip gcc perl ruby python2" #Already installed - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -Sy openssl-devel" - # Install toolchain - #- C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain" #Already installed - # Install other binutils - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-curl mingw-w64-x86_64-curl" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-miniupnpc mingw-w64-x86_64-miniupnpc" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-sqlite3 mingw-w64-x86_64-sqlite3" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-speex mingw-w64-x86_64-speex" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-speexdsp mingw-w64-x86_64-speexdsp" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-opencv mingw-w64-x86_64-opencv" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-ffmpeg mingw-w64-x86_64-ffmpeg" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-libmicrohttpd mingw-w64-x86_64-libmicrohttpd" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-libxslt mingw-w64-x86_64-libxslt" - - C:\msys64\usr\bin\bash -lc "pacman --noconfirm -S mingw-w64-i686-rapidjson mingw-w64-x86_64-rapidjson" +# - set PATH=%QTDIR%\bin;C:\Qt\Tools\mingw491_32\bin;%PATH% # Hack for new MSys2 - copy C:\msys64\mingw32\i686-w64-mingw32\bin\ar.exe C:\msys64\mingw32\bin\i686-w64-mingw32-ar.exe @@ -116,10 +102,6 @@ install: - copy C:\msys64\mingw64\x86_64-w64-mingw32\bin\ar.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-ar.exe - copy C:\msys64\mingw64\x86_64-w64-mingw32\bin\ranlib.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-ranlib.exe - copy C:\msys64\mingw64\bin\windres.exe C:\msys64\mingw64\bin\x86_64-w64-mingw32-windres.exe - # Build missing Libs - #- C:\msys64\mingw32.exe -lc "cd /c/projects/RetroShare/msys2_build_libs/ && make" - # Clone RetroShare - #- git clone -q --branch={branch} https://github.com/RetroShare/RetroShare.git C:\projects\RetroShare #---------------------------------# @@ -144,18 +126,112 @@ configuration: Release # scripts to run before build before_build: + - cd C:\projects\RetroShare +# - find C:\ > filelist.txt # scripts to run *after* solution is built and *before* automatic packaging occurs (web apps, NuGet packages, Azure Cloud Services) before_package: -# scripts to run after build -after_build: - # to run your custom scripts instead of automatic MSBuild build_script: - - cd C:\projects\RetroShare - - qmake CONFIG+=no_sqlcipher - - make + - qmake -Wall -spec win32-g++ "CONFIG=debug" + - mingw32-make -j3 + +# scripts to run after build +after_build: + - mkdir %RS_DEPLOY% + - copy retroshare-nogui\src\retroshare-nogui.exe %RS_DEPLOY%\ + - copy retroshare-gui\src\retroshare.exe %RS_DEPLOY%\ + +## In Debug build winedeplyqt forget the non debug Qt libs + - copy C:\msys64\mingw32\bin\Qt5Svg.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\Qt5Core.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\Qt5Multimedia.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\Qt5Widgets.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\Qt5Xml.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\Qt5PrintSupport.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\Qt5Gui.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\Qt5Network.dll %RS_DEPLOY%\ + + - mkdir %RS_DEPLOY%\playlistformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\playlistformats\qtmultimedia_m3u.dll %RS_DEPLOY%\playlistformats + + - mkdir %RS_DEPLOY%\printsupport\ + - copy C:\msys64\mingw32\share\qt5\plugins\printsupport\windowsprintersupport.dll %RS_DEPLOY%\printsupport\ + + - mkdir %RS_DEPLOY%\iconengines\ + - copy C:\msys64\mingw32\share\qt5\plugins\iconengines\qsvgicon.dll %RS_DEPLOY%\iconengines\ + + - mkdir %RS_DEPLOY%\bearer\ + - copy C:\msys64\mingw32\share\qt5\plugins\bearer\qgenericbearer.dll %RS_DEPLOY%\bearer\ + + - mkdir %RS_DEPLOY%\mediaservice\ + - copy C:\msys64\mingw32\share\qt5\plugins\mediaservice\qtmedia_audioengine.dll %RS_DEPLOY%\mediaservice\ + - copy C:\msys64\mingw32\share\qt5\plugins\mediaservice\dsengine.dll %RS_DEPLOY%\mediaservice\ + + - mkdir %RS_DEPLOY%\styles\ + - copy C:\msys64\mingw32\share\qt5\plugins\styles\qwindowsvistastyle.dll %RS_DEPLOY%\styles\ + + - mkdir %RS_DEPLOY%\imageformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qwebp.dll %RS_DEPLOY%\imageformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qicns.dll %RS_DEPLOY%\imageformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qjpeg.dll %RS_DEPLOY%\imageformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qtiff.dll %RS_DEPLOY%\imageformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qtga.dll %RS_DEPLOY%\imageformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qjp2.dll %RS_DEPLOY%\imageformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qico.dll %RS_DEPLOY%\imageformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qwbmp.dll %RS_DEPLOY%\imageformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qicns.dll %RS_DEPLOY%\imageformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qgif.dll %RS_DEPLOY%\imageformats\ + - copy C:\msys64\mingw32\share\qt5\plugins\imageformats\qsvg.dll %RS_DEPLOY%\imageformats\ + + - mkdir %RS_DEPLOY%\platforms\ + - copy C:\msys64\mingw32\share\qt5\plugins\platforms\qwindows.dll %RS_DEPLOY%\platforms\ + + - mkdir %RS_DEPLOY%\audio\ + - copy C:\msys64\mingw32\share\qt5\plugins\audio\qtaudio_windows.dll %RS_DEPLOY%\audio\ + + - windeployqt %RS_DEPLOY%\retroshare.exe + + - copy C:\msys64\mingw32\bin\libbz2*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libeay32.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libminiupnpc.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libsqlcipher*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libsqlite3*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\ssleay32.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\zlib*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libgcc_s_dw2*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libstdc*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libwinpthread*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libicu*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libpcre*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libharfbuzz*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libpng*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libfreetype*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libglib*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libgraphite2.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libintl*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libiconv*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libjasper*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libjpeg*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libtiff*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libwebp*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libwebpdemux*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\liblzma*.dll %RS_DEPLOY%\ + +## Needed for libresapi http + - copy C:\msys64\mingw32\bin\libmicrohttpd*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libgnutls*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libgmp*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libhogweed*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libidn2*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libnettle*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libp11-kit*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libtasn1*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libunistring*.dll %RS_DEPLOY%\ + - copy C:\msys64\mingw32\bin\libffi*.dll %RS_DEPLOY%\ + + - find C:\projects\RetroShare >> filelist.txt # to disable automatic builds #build: off @@ -164,7 +240,10 @@ build_script: # artifacts configuration # #---------------------------------# -#artifacts: +artifacts: + - path: $(RS_DEPLOY) + - path: '**\*.exe' + - path: filelist.txt # # # pushing a single file # - path: test.zip From 3c678f2a282c9356741e4e1337bd8adf2b83074b Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 11 Jun 2018 16:05:25 +0200 Subject: [PATCH 32/50] Fix windows build if MINGW_PREFIX is defined --- retroshare.pri | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/retroshare.pri b/retroshare.pri index 6b8fdd870..111530a39 100644 --- a/retroshare.pri +++ b/retroshare.pri @@ -400,13 +400,11 @@ win32-g++ { PREFIX_MSYS2=$${TEMPTATIVE_MSYS2} } - !isEmpty(PREFIX_MSYS2) { - message(Found MSYS2: $${PREFIX_MSYS2}) + !isEmpty(PREFIX_MSYS2):message(Found MSYS2: $${PREFIX_MSYS2}) + } - isEmpty(PREFIX) { - PREFIX = $$system_path($${PREFIX_MSYS2}) - } - } + isEmpty(PREFIX):!isEmpty(PREFIX_MSYS2) { + PREFIX = $$system_path($${PREFIX_MSYS2}) } isEmpty(PREFIX) { From 79e676edbe646ea3c8f3257ffbbd335437310208 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 18 Jun 2018 22:27:05 +0200 Subject: [PATCH 33/50] fixed re-load of GXS groups (forums/channels) when the read flag is changed --- libretroshare/src/gxs/rsgenexchange.cc | 2 +- libretroshare/src/services/p3gxschannels.cc | 3 +-- .../src/gui/gxs/RsGxsUpdateBroadcastBase.cpp | 8 +++++++- retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp | 13 +++++++------ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index 15d0aa9e9..e219821f2 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -2010,7 +2010,7 @@ void RsGenExchange::processMsgMetaChanges() if (!msgIds.empty()) { RS_STACK_MUTEX(mGenMtx); - RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, true); + RsGxsMsgChange* c = new RsGxsMsgChange(RsGxsNotify::TYPE_PROCESSED, false); c->msgChangeMap = msgIds; mNotifications.push_back(c); } diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index e70769c7a..beb828fdf 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -218,8 +218,7 @@ RsGenExchange::ServiceCreate_Return p3GxsChannels::service_CreateGroup(RsGxsGrpI void p3GxsChannels::notifyChanges(std::vector &changes) { #ifdef GXSCHANNELS_DEBUG - std::cerr << "p3GxsChannels::notifyChanges()"; - std::cerr << std::endl; + std::cerr << "p3GxsChannels::notifyChanges() : " << changes.size() << "changes to notify" << std::endl; #endif p3Notify *notify = NULL; diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp index bf092c3cc..a657959a9 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp @@ -68,7 +68,13 @@ void RsGxsUpdateBroadcastBase::updateBroadcastChanged() /* Update only update when the widget is visible. */ if (mUpdateWhenInvisible || !widget || widget->isVisible()) { - if (!mGrpIds.empty() || !mGrpIdsMeta.empty() || !mMsgIds.empty() || !mMsgIdsMeta.empty()) + // (cyril) Re-load the entire group is new messages are here, or if group metadata has changed (e.g. visibility permissions, admin rights, etc). + // Do not re-load if Msg data has changed, which means basically the READ flag has changed, because this action is done in the UI in the + // first place so there's no need to re-update the UI once this is done. + // + // The question to whether we should re=load when mGrpIds is not empty is still open. It's not harmful anyway. + + if (!mGrpIds.empty() || !mGrpIdsMeta.empty() /*|| !mMsgIds.empty()*/ || !mMsgIdsMeta.empty()) mFillComplete = true ; securedUpdateDisplay(); diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp index cbda167cb..35da468da 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -45,20 +45,21 @@ RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl) void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes) { -#ifdef DEBUG_GXS_BROADCAST +#ifndef DEBUG_GXS_BROADCAST std::cerr << "onChangesReceived()" << std::endl; { std::cerr << "Received changes for service " << (void*)changes.mService << ", expecting service " << (void*)mIfaceImpl->getTokenService() << std::endl; - std::cerr << " changes content: " << std::endl; - for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) std::cerr << " grp id: " << *it << std::endl; - for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) std::cerr << " grp meta: " << *it << std::endl; + for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) + std::cerr << "[GRP CHANGE] grp id: " << *it << std::endl; + for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) + std::cerr << "[GRP CHANGE] grp meta: " << *it << std::endl; for(std::map >::const_iterator it(changes.mMsgs.begin());it!=changes.mMsgs.end();++it) for(uint32_t i=0;isecond.size();++i) - std::cerr << " grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; for(std::map >::const_iterator it(changes.mMsgsMeta.begin());it!=changes.mMsgsMeta.end();++it) for(uint32_t i=0;isecond.size();++i) - std::cerr << " grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; } #endif if(changes.mService != mIfaceImpl->getTokenService()) From 2e7398ac9bbbf94aad1df46a53dcd304a039cbe7 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 18 Jun 2018 22:35:22 +0200 Subject: [PATCH 34/50] removed debug info --- .../src/util/RsGxsUpdateBroadcast.cpp | 166 +++++++++--------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp index 35da468da..48c13d6db 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -1,83 +1,83 @@ -#include - -#include "RsGxsUpdateBroadcast.h" -#include "gui/notifyqt.h" - -#include - -//#define DEBUG_GXS_BROADCAST 1 - -// previously gxs allowed only one event consumer to poll for changes -// this required a single broadcast instance per service -// now the update notify works through rsnotify and notifyqt -// so the single instance per service is not really needed anymore - -QMap updateBroadcastMap; - -RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) : - QObject(NULL), mIfaceImpl(ifaceImpl) -{ - connect(NotifyQt::getInstance(), SIGNAL(gxsChange(RsGxsChanges)), this, SLOT(onChangesReceived(RsGxsChanges))); -} - -void RsGxsUpdateBroadcast::cleanup() -{ - QMap::iterator it; - for (it = updateBroadcastMap.begin(); it != updateBroadcastMap.end(); ++it) { - delete(it.value()); - } - - updateBroadcastMap.clear(); -} - -RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl) -{ - QMap::iterator it = updateBroadcastMap.find(ifaceImpl); - if (it != updateBroadcastMap.end()) { - return it.value(); - } - - RsGxsUpdateBroadcast *updateBroadcast = new RsGxsUpdateBroadcast(ifaceImpl); - updateBroadcastMap.insert(ifaceImpl, updateBroadcast); - - return updateBroadcast; -} - -void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes) -{ -#ifndef DEBUG_GXS_BROADCAST - std::cerr << "onChangesReceived()" << std::endl; - - { - std::cerr << "Received changes for service " << (void*)changes.mService << ", expecting service " << (void*)mIfaceImpl->getTokenService() << std::endl; - for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) - std::cerr << "[GRP CHANGE] grp id: " << *it << std::endl; - for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) - std::cerr << "[GRP CHANGE] grp meta: " << *it << std::endl; - for(std::map >::const_iterator it(changes.mMsgs.begin());it!=changes.mMsgs.end();++it) - for(uint32_t i=0;isecond.size();++i) - std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; - for(std::map >::const_iterator it(changes.mMsgsMeta.begin());it!=changes.mMsgsMeta.end();++it) - for(uint32_t i=0;isecond.size();++i) - std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; - } -#endif - if(changes.mService != mIfaceImpl->getTokenService()) - { - // std::cerr << "(EE) Incorrect service. Dropping." << std::endl; - - return; - } - - if (!changes.mMsgs.empty() || !changes.mMsgsMeta.empty()) - { - emit msgsChanged(changes.mMsgs, changes.mMsgsMeta); - } - - if (!changes.mGrps.empty() || !changes.mGrpsMeta.empty()) - { - emit grpsChanged(changes.mGrps, changes.mGrpsMeta); - } - - emit changed(); -} +#include + +#include "RsGxsUpdateBroadcast.h" +#include "gui/notifyqt.h" + +#include + +//#define DEBUG_GXS_BROADCAST 1 + +// previously gxs allowed only one event consumer to poll for changes +// this required a single broadcast instance per service +// now the update notify works through rsnotify and notifyqt +// so the single instance per service is not really needed anymore + +QMap updateBroadcastMap; + +RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) : + QObject(NULL), mIfaceImpl(ifaceImpl) +{ + connect(NotifyQt::getInstance(), SIGNAL(gxsChange(RsGxsChanges)), this, SLOT(onChangesReceived(RsGxsChanges))); +} + +void RsGxsUpdateBroadcast::cleanup() +{ + QMap::iterator it; + for (it = updateBroadcastMap.begin(); it != updateBroadcastMap.end(); ++it) { + delete(it.value()); + } + + updateBroadcastMap.clear(); +} + +RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl) +{ + QMap::iterator it = updateBroadcastMap.find(ifaceImpl); + if (it != updateBroadcastMap.end()) { + return it.value(); + } + + RsGxsUpdateBroadcast *updateBroadcast = new RsGxsUpdateBroadcast(ifaceImpl); + updateBroadcastMap.insert(ifaceImpl, updateBroadcast); + + return updateBroadcast; +} + +void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes) +{ +#ifdef DEBUG_GXS_BROADCAST + std::cerr << "onChangesReceived()" << std::endl; + + { + std::cerr << "Received changes for service " << (void*)changes.mService << ", expecting service " << (void*)mIfaceImpl->getTokenService() << std::endl; + for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) + std::cerr << "[GRP CHANGE] grp id: " << *it << std::endl; + for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) + std::cerr << "[GRP CHANGE] grp meta: " << *it << std::endl; + for(std::map >::const_iterator it(changes.mMsgs.begin());it!=changes.mMsgs.end();++it) + for(uint32_t i=0;isecond.size();++i) + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; + for(std::map >::const_iterator it(changes.mMsgsMeta.begin());it!=changes.mMsgsMeta.end();++it) + for(uint32_t i=0;isecond.size();++i) + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; + } +#endif + if(changes.mService != mIfaceImpl->getTokenService()) + { + // std::cerr << "(EE) Incorrect service. Dropping." << std::endl; + + return; + } + + if (!changes.mMsgs.empty() || !changes.mMsgsMeta.empty()) + { + emit msgsChanged(changes.mMsgs, changes.mMsgsMeta); + } + + if (!changes.mGrps.empty() || !changes.mGrpsMeta.empty()) + { + emit grpsChanged(changes.mGrps, changes.mGrpsMeta); + } + + emit changed(); +} From 6139632378b59091ef67ec4438b748d718f0c77d Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 18 Jun 2018 22:37:31 +0200 Subject: [PATCH 35/50] changed back RsGxsUpdateBroadCast.cpp to dos line ending --- .../src/util/RsGxsUpdateBroadcast.cpp | 166 +++++++++--------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp index 48c13d6db..0fdf63d65 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.cpp @@ -1,83 +1,83 @@ -#include - -#include "RsGxsUpdateBroadcast.h" -#include "gui/notifyqt.h" - -#include - -//#define DEBUG_GXS_BROADCAST 1 - -// previously gxs allowed only one event consumer to poll for changes -// this required a single broadcast instance per service -// now the update notify works through rsnotify and notifyqt -// so the single instance per service is not really needed anymore - -QMap updateBroadcastMap; - -RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) : - QObject(NULL), mIfaceImpl(ifaceImpl) -{ - connect(NotifyQt::getInstance(), SIGNAL(gxsChange(RsGxsChanges)), this, SLOT(onChangesReceived(RsGxsChanges))); -} - -void RsGxsUpdateBroadcast::cleanup() -{ - QMap::iterator it; - for (it = updateBroadcastMap.begin(); it != updateBroadcastMap.end(); ++it) { - delete(it.value()); - } - - updateBroadcastMap.clear(); -} - -RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl) -{ - QMap::iterator it = updateBroadcastMap.find(ifaceImpl); - if (it != updateBroadcastMap.end()) { - return it.value(); - } - - RsGxsUpdateBroadcast *updateBroadcast = new RsGxsUpdateBroadcast(ifaceImpl); - updateBroadcastMap.insert(ifaceImpl, updateBroadcast); - - return updateBroadcast; -} - -void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes) -{ -#ifdef DEBUG_GXS_BROADCAST - std::cerr << "onChangesReceived()" << std::endl; - - { - std::cerr << "Received changes for service " << (void*)changes.mService << ", expecting service " << (void*)mIfaceImpl->getTokenService() << std::endl; - for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) - std::cerr << "[GRP CHANGE] grp id: " << *it << std::endl; - for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) - std::cerr << "[GRP CHANGE] grp meta: " << *it << std::endl; - for(std::map >::const_iterator it(changes.mMsgs.begin());it!=changes.mMsgs.end();++it) - for(uint32_t i=0;isecond.size();++i) - std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; - for(std::map >::const_iterator it(changes.mMsgsMeta.begin());it!=changes.mMsgsMeta.end();++it) - for(uint32_t i=0;isecond.size();++i) - std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; - } -#endif - if(changes.mService != mIfaceImpl->getTokenService()) - { - // std::cerr << "(EE) Incorrect service. Dropping." << std::endl; - - return; - } - - if (!changes.mMsgs.empty() || !changes.mMsgsMeta.empty()) - { - emit msgsChanged(changes.mMsgs, changes.mMsgsMeta); - } - - if (!changes.mGrps.empty() || !changes.mGrpsMeta.empty()) - { - emit grpsChanged(changes.mGrps, changes.mGrpsMeta); - } - - emit changed(); -} +#include + +#include "RsGxsUpdateBroadcast.h" +#include "gui/notifyqt.h" + +#include + +//#define DEBUG_GXS_BROADCAST 1 + +// previously gxs allowed only one event consumer to poll for changes +// this required a single broadcast instance per service +// now the update notify works through rsnotify and notifyqt +// so the single instance per service is not really needed anymore + +QMap updateBroadcastMap; + +RsGxsUpdateBroadcast::RsGxsUpdateBroadcast(RsGxsIfaceHelper *ifaceImpl) : + QObject(NULL), mIfaceImpl(ifaceImpl) +{ + connect(NotifyQt::getInstance(), SIGNAL(gxsChange(RsGxsChanges)), this, SLOT(onChangesReceived(RsGxsChanges))); +} + +void RsGxsUpdateBroadcast::cleanup() +{ + QMap::iterator it; + for (it = updateBroadcastMap.begin(); it != updateBroadcastMap.end(); ++it) { + delete(it.value()); + } + + updateBroadcastMap.clear(); +} + +RsGxsUpdateBroadcast *RsGxsUpdateBroadcast::get(RsGxsIfaceHelper *ifaceImpl) +{ + QMap::iterator it = updateBroadcastMap.find(ifaceImpl); + if (it != updateBroadcastMap.end()) { + return it.value(); + } + + RsGxsUpdateBroadcast *updateBroadcast = new RsGxsUpdateBroadcast(ifaceImpl); + updateBroadcastMap.insert(ifaceImpl, updateBroadcast); + + return updateBroadcast; +} + +void RsGxsUpdateBroadcast::onChangesReceived(const RsGxsChanges& changes) +{ +#ifdef DEBUG_GXS_BROADCAST + std::cerr << "onChangesReceived()" << std::endl; + + { + std::cerr << "Received changes for service " << (void*)changes.mService << ", expecting service " << (void*)mIfaceImpl->getTokenService() << std::endl; + for(std::list::const_iterator it(changes.mGrps.begin());it!=changes.mGrps.end();++it) + std::cerr << "[GRP CHANGE] grp id: " << *it << std::endl; + for(std::list::const_iterator it(changes.mGrpsMeta.begin());it!=changes.mGrpsMeta.end();++it) + std::cerr << "[GRP CHANGE] grp meta: " << *it << std::endl; + for(std::map >::const_iterator it(changes.mMsgs.begin());it!=changes.mMsgs.end();++it) + for(uint32_t i=0;isecond.size();++i) + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg ID " << it->second[i] << std::endl; + for(std::map >::const_iterator it(changes.mMsgsMeta.begin());it!=changes.mMsgsMeta.end();++it) + for(uint32_t i=0;isecond.size();++i) + std::cerr << "[MSG CHANGE] grp id: " << it->first << ". Msg Meta " << it->second[i] << std::endl; + } +#endif + if(changes.mService != mIfaceImpl->getTokenService()) + { + // std::cerr << "(EE) Incorrect service. Dropping." << std::endl; + + return; + } + + if (!changes.mMsgs.empty() || !changes.mMsgsMeta.empty()) + { + emit msgsChanged(changes.mMsgs, changes.mMsgsMeta); + } + + if (!changes.mGrps.empty() || !changes.mGrpsMeta.empty()) + { + emit grpsChanged(changes.mGrps, changes.mGrpsMeta); + } + + emit changed(); +} From 84699db744abcf67842aeface3880fdfaffe00b6 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 21 Jun 2018 15:46:59 +0200 Subject: [PATCH 36/50] changed std::vector into std::set in notification system, hence removing lots of std::find(std::vector::begin(),std::vector::end(),T), causing quadratic costs in multiple places. --- libretroshare/src/gxs/rsdataservice.cc | 18 ++--- libretroshare/src/gxs/rsdataservice.h | 2 +- libretroshare/src/gxs/rsgds.h | 2 +- libretroshare/src/gxs/rsgenexchange.cc | 53 ++++++------ libretroshare/src/gxs/rsgxsdataaccess.cc | 28 +++---- libretroshare/src/gxs/rsgxsnetservice.cc | 8 +- libretroshare/src/gxs/rsgxsutil.cc | 14 ++-- libretroshare/src/gxs/rsgxsutil.h | 4 +- libretroshare/src/gxstrans/p3gxstrans.cc | 2 +- libretroshare/src/retroshare/rsgxsiface.h | 4 +- .../src/retroshare/rsgxsifacetypes.h | 6 +- libretroshare/src/retroshare/rsgxsservice.h | 2 +- libretroshare/src/services/p3gxschannels.cc | 20 ++--- libretroshare/src/services/p3gxscircles.cc | 6 +- libretroshare/src/services/p3gxscommon.cc | 4 +- libretroshare/src/services/p3gxsforums.cc | 11 +-- libretroshare/src/services/p3idservice.cc | 4 +- libretroshare/src/services/p3postbase.cc | 16 ++-- retroshare-gui/src/gui/Identity/IdDialog.cpp | 4 +- retroshare-gui/src/gui/NewsFeed.cpp | 4 +- .../src/gui/feeds/GxsForumMsgItem.cpp | 4 +- retroshare-gui/src/gui/gxs/GxsFeedItem.cpp | 16 ++-- .../src/gui/gxs/GxsGroupFeedItem.cpp | 5 +- .../src/gui/gxs/GxsGroupFrameDialog.cpp | 5 +- .../src/gui/gxs/GxsMessageFramePostWidget.cpp | 19 ++--- .../src/gui/gxs/GxsMessageFramePostWidget.h | 2 +- .../src/gui/gxs/RsGxsUpdateBroadcastBase.cpp | 81 +++++-------------- .../src/gui/gxs/RsGxsUpdateBroadcastBase.h | 22 ++--- .../src/gui/gxs/RsGxsUpdateBroadcastPage.cpp | 12 +-- .../src/gui/gxs/RsGxsUpdateBroadcastPage.h | 12 +-- .../gui/gxs/RsGxsUpdateBroadcastWidget.cpp | 12 +-- .../src/gui/gxs/RsGxsUpdateBroadcastWidget.h | 12 +-- .../gui/gxschannels/CreateGxsChannelMsg.cpp | 2 +- .../src/gui/gxsforums/CreateGxsForumMsg.cpp | 8 +- .../gui/gxsforums/GxsForumThreadWidget.cpp | 54 ++++++------- .../src/util/RsGxsUpdateBroadcast.h | 2 +- 36 files changed, 208 insertions(+), 272 deletions(-) diff --git a/libretroshare/src/gxs/rsdataservice.cc b/libretroshare/src/gxs/rsdataservice.cc index bebcee21d..0b4d0f1da 100644 --- a/libretroshare/src/gxs/rsdataservice.cc +++ b/libretroshare/src/gxs/rsdataservice.cc @@ -1217,7 +1217,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b const RsGxsGroupId& grpId = mit->first; // if vector empty then request all messages - const std::vector& msgIdV = mit->second; + const std::set& msgIdV = mit->second; std::vector msgSet; if(msgIdV.empty()){ @@ -1235,7 +1235,7 @@ int RsDataService::retrieveNxsMsgs(const GxsMsgReq &reqIds, GxsMsgResult &msg, b }else{ // request each grp - std::vector::const_iterator sit = msgIdV.begin(); + std::set::const_iterator sit = msgIdV.begin(); for(; sit!=msgIdV.end();++sit){ const RsGxsMessageId& msgId = *sit; @@ -1305,7 +1305,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes const RsGxsGroupId& grpId = mit->first; // if vector empty then request all messages - const std::vector& msgIdV = mit->second; + const std::set& msgIdV = mit->second; std::vector metaSet; if(msgIdV.empty()){ @@ -1321,7 +1321,7 @@ int RsDataService::retrieveGxsMsgMetaData(const GxsMsgReq& reqIds, GxsMsgMetaRes }else{ // request each grp - std::vector::const_iterator sit = msgIdV.begin(); + std::set::const_iterator sit = msgIdV.begin(); for(; sit!=msgIdV.end(); ++sit){ const RsGxsMessageId& msgId = *sit; @@ -1561,7 +1561,7 @@ int RsDataService::removeMsgs(const GxsMsgReq& msgIds) for(; mit != msgIds.end(); ++mit) { - const std::vector& msgIdV = mit->second; + const std::set& msgIdV = mit->second; const RsGxsGroupId& grpId = mit->first; // delete messages @@ -1622,7 +1622,7 @@ int RsDataService::retrieveGroupIds(std::vector &grpIds) return 1; } -int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgIds) +int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgIds) { #ifdef RS_DATA_SERVICE_DEBUG_TIME rstime::RsScopeTimer timer(""); @@ -1643,7 +1643,7 @@ int RsDataService::retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std if(c->columnCount() != 1) std::cerr << "(EE) ********* not retrieving all columns!!" << std::endl; - msgIds.push_back(RsGxsMessageId(msgId)); + msgIds.insert(RsGxsMessageId(msgId)); valid = c->moveToNext(); #ifdef RS_DATA_SERVICE_DEBUG_TIME @@ -1674,8 +1674,8 @@ bool RsDataService::locked_removeMessageEntries(const GxsMsgReq& msgIds) for(; mit != msgIds.end(); ++mit) { const RsGxsGroupId& grpId = mit->first; - const std::vector& msgsV = mit->second; - std::vector::const_iterator vit = msgsV.begin(); + const std::set& msgsV = mit->second; + std::set::const_iterator vit = msgsV.begin(); for(; vit != msgsV.end(); ++vit) { diff --git a/libretroshare/src/gxs/rsdataservice.h b/libretroshare/src/gxs/rsdataservice.h index c669ee016..cc137b320 100644 --- a/libretroshare/src/gxs/rsdataservice.h +++ b/libretroshare/src/gxs/rsdataservice.h @@ -110,7 +110,7 @@ public: * @param msgId msgsids retrieved * @return error code */ - int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId); + int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgId); /*! * @return the cache size set for this RsGeneralDataService in bytes diff --git a/libretroshare/src/gxs/rsgds.h b/libretroshare/src/gxs/rsgds.h index e20d0ed04..78987ac66 100644 --- a/libretroshare/src/gxs/rsgds.h +++ b/libretroshare/src/gxs/rsgds.h @@ -208,7 +208,7 @@ public: * @param msgId msgsids retrieved * @return error code */ - virtual int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_vector& msgId) = 0; + virtual int retrieveMsgIds(const RsGxsGroupId& grpId, RsGxsMessageId::std_set& msgId) = 0; /*! * @return the cache size set for this RsGeneralDataService in bytes diff --git a/libretroshare/src/gxs/rsgenexchange.cc b/libretroshare/src/gxs/rsgenexchange.cc index e219821f2..ad7e02dcb 100644 --- a/libretroshare/src/gxs/rsgenexchange.cc +++ b/libretroshare/src/gxs/rsgenexchange.cc @@ -217,7 +217,7 @@ void RsGenExchange::tick() RS_STACK_MUTEX(mGenMtx) ; std::list grpIds; - std::map > msgIds; + std::map > msgIds; mIntegrityCheck->getDeletedIds(grpIds, msgIds); if (!grpIds.empty()) @@ -1078,23 +1078,19 @@ bool RsGenExchange::checkAuthenFlag(const PrivacyBitPos& pos, const uint8_t& fla } } -static void addMessageChanged(std::map > &msgs, const std::map > &msgChanged) +static void addMessageChanged(std::map > &msgs, const std::map > &msgChanged) { if (msgs.empty()) { msgs = msgChanged; } else { - std::map >::const_iterator mapIt; - for (mapIt = msgChanged.begin(); mapIt != msgChanged.end(); ++mapIt) { + for (auto mapIt = msgChanged.begin(); mapIt != msgChanged.end(); ++mapIt) + { const RsGxsGroupId &grpId = mapIt->first; - const std::vector &srcMsgIds = mapIt->second; - std::vector &destMsgIds = msgs[grpId]; + const std::set &srcMsgIds = mapIt->second; + std::set &destMsgIds = msgs[grpId]; - std::vector::const_iterator msgIt; - for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) { - if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) { - destMsgIds.push_back(*msgIt); - } - } + for (auto msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) + destMsgIds.insert(*msgIt) ; } } } @@ -1789,8 +1785,8 @@ void RsGenExchange::deleteMsgs(uint32_t& token, const GxsMsgReq& msgs) if(mNetService != NULL) for(GxsMsgReq::const_iterator it(msgs.begin());it!=msgs.end();++it) - for(uint32_t i=0;isecond.size();++i) - mNetService->rejectMessage(it->second[i]) ; + for(auto it2(it->second.begin());it2!=it->second.end();++it2) + mNetService->rejectMessage(*it2); } void RsGenExchange::publishMsg(uint32_t& token, RsGxsMsgItem *msgItem) @@ -1961,8 +1957,8 @@ void RsGenExchange::processMsgMetaChanges() if(m.val.getAsInt32(RsGeneralDataService::MSG_META_STATUS+GXS_MASK, mask)) { GxsMsgReq req; - std::vector msgIdV; - msgIdV.push_back(m.msgId.second); + std::set msgIdV; + msgIdV.insert(m.msgId.second); req.insert(std::make_pair(m.msgId.first, msgIdV)); GxsMsgMetaResult result; mDataStore->retrieveGxsMsgMetaData(req, result); @@ -1994,7 +1990,7 @@ void RsGenExchange::processMsgMetaChanges() mDataAccess->updatePublicRequestStatus(token, RsTokenService::GXS_REQUEST_V2_STATUS_COMPLETE); if (changed) { - msgIds[m.msgId.first].push_back(m.msgId.second); + msgIds[m.msgId.first].insert(m.msgId.second); } } else @@ -2145,7 +2141,7 @@ void RsGenExchange::publishMsgs() mMsgsToPublish.insert(std::make_pair(sign_it->first, item.mItem)); } - std::map > msgChangeMap; + std::map > msgChangeMap; std::map::iterator mit = mMsgsToPublish.begin(); for(; mit != mMsgsToPublish.end(); ++mit) @@ -2273,7 +2269,7 @@ void RsGenExchange::publishMsgs() mDataAccess->addMsgData(msg); delete msg ; - msgChangeMap[grpId].push_back(msgId); + msgChangeMap[grpId].insert(msgId); delete[] metaDataBuff; @@ -2972,10 +2968,10 @@ void RsGenExchange::processRecvdMessages() msg->metaData->mMsgStatus = GXS_SERV::GXS_MSG_STATUS_UNPROCESSED | GXS_SERV::GXS_MSG_STATUS_GUI_NEW | GXS_SERV::GXS_MSG_STATUS_GUI_UNREAD; msgs_to_store.push_back(msg); - std::vector &msgv = msgIds[msg->grpId]; - - if (std::find(msgv.begin(), msgv.end(), msg->msgId) == msgv.end()) - msgv.push_back(msg->msgId); + msgIds[msg->grpId].insert(msg->msgId); + // std::vector &msgv = msgIds[msg->grpId]; + // if (std::find(msgv.begin(), msgv.end(), msg->msgId) == msgv.end()) + // msgv.push_back(msg->msgId); computeHash(msg->msg, msg->metaData->mHash); msg->metaData->recvTS = time(NULL); @@ -3330,7 +3326,7 @@ void RsGenExchange::removeDeleteExistingMessages( std::list& msgs, Gx //RsGxsGroupId::std_list grpIds(mGrpIdsUnique.begin(), mGrpIdsUnique.end()); //RsGxsGroupId::std_list::const_iterator it = grpIds.begin(); - typedef std::map MsgIdReq; + typedef std::map MsgIdReq; MsgIdReq msgIdReq; // now get a list of all msgs ids for each group @@ -3350,7 +3346,7 @@ void RsGenExchange::removeDeleteExistingMessages( std::list& msgs, Gx // now for each msg to be stored that exist in the retrieved msg/grp "index" delete and erase from map for(std::list::iterator cit2 = msgs.begin(); cit2 != msgs.end();) { - const RsGxsMessageId::std_vector& msgIds = msgIdReq[(*cit2)->metaData->mGroupId]; + const RsGxsMessageId::std_set& msgIds = msgIdReq[(*cit2)->metaData->mGroupId]; #ifdef GEN_EXCH_DEBUG std::cerr << " grpid=" << (*cit2)->grpId << ", msgid=" << (*cit2)->msgId ; @@ -3358,12 +3354,13 @@ void RsGenExchange::removeDeleteExistingMessages( std::list& msgs, Gx // Avoid storing messages that are already in the database, as well as messages that are too old (or generally do not pass the database storage test) // - if(std::find(msgIds.begin(), msgIds.end(), (*cit2)->metaData->mMsgId) != msgIds.end() || !messagePublicationTest( *(*cit2)->metaData)) + if(msgIds.find((*cit2)->metaData->mMsgId) != msgIds.end() || !messagePublicationTest( *(*cit2)->metaData)) { // msg exist in retrieved index. We should use a std::set here instead of a vector. - RsGxsMessageId::std_vector& notifyIds = msgIdsNotify[ (*cit2)->metaData->mGroupId]; - RsGxsMessageId::std_vector::iterator it2 = std::find(notifyIds.begin(), notifyIds.end(), (*cit2)->metaData->mMsgId); + RsGxsMessageId::std_set& notifyIds = msgIdsNotify[ (*cit2)->metaData->mGroupId]; + RsGxsMessageId::std_set::iterator it2 = notifyIds.find((*cit2)->metaData->mMsgId); + if(it2 != notifyIds.end()) { notifyIds.erase(it2); diff --git a/libretroshare/src/gxs/rsgxsdataaccess.cc b/libretroshare/src/gxs/rsgxsdataaccess.cc index 5d36bd909..77c0d05d9 100644 --- a/libretroshare/src/gxs/rsgxsdataaccess.cc +++ b/libretroshare/src/gxs/rsgxsdataaccess.cc @@ -225,7 +225,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType, MsgMetaReq* mmr = new MsgMetaReq(); for(; lit != grpIds.end(); ++lit) - mmr->mMsgIds[*lit] = std::vector(); + mmr->mMsgIds[*lit] = std::set(); req = mmr; }else if(reqType & GXS_REQUEST_TYPE_MSG_DATA) @@ -233,7 +233,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType, MsgDataReq* mdr = new MsgDataReq(); for(; lit != grpIds.end(); ++lit) - mdr->mMsgIds[*lit] = std::vector(); + mdr->mMsgIds[*lit] = std::set(); req = mdr; }else if(reqType & GXS_REQUEST_TYPE_MSG_IDS) @@ -241,7 +241,7 @@ bool RsGxsDataAccess::requestMsgInfo(uint32_t &token, uint32_t ansType, MsgIdReq* mir = new MsgIdReq(); for(; lit != grpIds.end(); ++lit) - mir->mMsgIds[*lit] = std::vector(); + mir->mMsgIds[*lit] = std::set(); req = mir; } @@ -1191,7 +1191,7 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions& // Add the discovered Latest Msgs. for(oit = origMsgTs.begin(); oit != origMsgTs.end(); ++oit) { - msgIdsOut[grpId].push_back(oit->second.first); + msgIdsOut[grpId].insert(oit->second.first); } } @@ -1228,7 +1228,7 @@ bool RsGxsDataAccess::getMsgList(const GxsMsgReq& msgIds, const RsTokReqOptions& if (add) { - msgIdsOut[grpId].push_back(msgMeta->mMsgId); + msgIdsOut[grpId].insert(msgMeta->mMsgId); metaFilter[grpId].insert(std::make_pair(msgMeta->mMsgId, msgMeta)); } @@ -1373,7 +1373,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req) // get meta data for all in group GxsMsgMetaResult result; GxsMsgReq msgIds; - msgIds.insert(std::make_pair(grpMsgIdPair.first, std::vector())); + msgIds.insert(std::make_pair(grpMsgIdPair.first, std::set())); mDataStore->retrieveGxsMsgMetaData(msgIds, result); std::vector& metaV = result[grpMsgIdPair.first]; std::vector::iterator vit_meta; @@ -1382,7 +1382,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req) const RsGxsMessageId& msgId = grpMsgIdPair.second; const RsGxsGroupId& grpId = grpMsgIdPair.first; - std::vector outMsgIds; + std::set outMsgIds; RsGxsMsgMetaData* origMeta = NULL; for(vit_meta = metaV.begin(); vit_meta != metaV.end(); ++vit_meta) @@ -1477,7 +1477,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req) // Add the discovered Latest Msgs. for(oit = origMsgTs.begin(); oit != origMsgTs.end(); ++oit) { - outMsgIds.push_back(oit->second.first); + outMsgIds.insert(oit->second.first); } } else @@ -1502,7 +1502,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req) } } } - outMsgIds.push_back(latestMsgId); + outMsgIds.insert(latestMsgId); metaMap.insert(std::make_pair(latestMsgId, latestMeta)); } } @@ -1514,7 +1514,7 @@ bool RsGxsDataAccess::getMsgRelatedInfo(MsgRelatedInfoReq *req) if (meta->mOrigMsgId == origMsgId) { - outMsgIds.push_back(meta->mMsgId); + outMsgIds.insert(meta->mMsgId); metaMap.insert(std::make_pair(meta->mMsgId, meta)); } } @@ -1556,7 +1556,7 @@ bool RsGxsDataAccess::getGroupStatistic(GroupStatisticRequest *req) { // filter based on options GxsMsgIdResult metaReq; - metaReq[req->mGrpId] = std::vector(); + metaReq[req->mGrpId] = std::set(); GxsMsgMetaResult metaResult; mDataStore->retrieveGxsMsgMetaData(metaReq, metaResult); @@ -1672,7 +1672,7 @@ bool RsGxsDataAccess::getMsgList(MsgIdReq* req) for(; vit != vit_end; ++vit) { RsGxsMsgMetaData* meta = *vit; - req->mMsgIdResult[grpId].push_back(meta->mMsgId); + req->mMsgIdResult[grpId].insert(meta->mMsgId); delete meta; // discard meta data mem } } @@ -1718,8 +1718,8 @@ void RsGxsDataAccess::filterMsgList(GxsMsgIdResult& msgIds, const RsTokReqOption if(cit == msgMetas.end()) continue; - std::vector& msgs = mit->second; - std::vector::iterator vit = msgs.begin(); + std::set& msgs = mit->second; + std::set::iterator vit = msgs.begin(); const std::map& meta = cit->second; std::map::const_iterator cit2; diff --git a/libretroshare/src/gxs/rsgxsnetservice.cc b/libretroshare/src/gxs/rsgxsnetservice.cc index 48a9e9234..0f61c5a74 100644 --- a/libretroshare/src/gxs/rsgxsnetservice.cc +++ b/libretroshare/src/gxs/rsgxsnetservice.cc @@ -784,7 +784,7 @@ void RsGxsNetService::handleRecvSyncGrpStatistics(RsNxsSyncGrpStatsItem *grs) // now count available messages GxsMsgReq reqIds; - reqIds[grs->grpId] = std::vector(); + reqIds[grs->grpId] = std::set(); GxsMsgMetaResult result; #ifdef NXS_NET_DEBUG_6 @@ -2757,7 +2757,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr) #endif GxsMsgReq reqIds; - reqIds[grpId] = std::vector(); + reqIds[grpId] = std::set(); GxsMsgMetaResult result; mDataStore->retrieveGxsMsgMetaData(reqIds, result); std::vector &msgMetaV = result[grpId]; @@ -3296,7 +3296,7 @@ void RsGxsNetService::locked_genSendMsgsTransaction(NxsTransaction* tr) RsNxsSyncMsgItem* item = dynamic_cast(*lit); if (item) { - msgIds[item->grpId].push_back(item->msgId); + msgIds[item->grpId].insert(item->msgId); if(grpId.isNull()) grpId = item->grpId; @@ -4127,7 +4127,7 @@ void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsgReqItem *item,bool item_ } GxsMsgReq req; - req[item->grpId] = std::vector(); + req[item->grpId] = std::set(); GxsMsgMetaResult metaResult; mDataStore->retrieveGxsMsgMetaData(req, metaResult); diff --git a/libretroshare/src/gxs/rsgxsutil.cc b/libretroshare/src/gxs/rsgxsutil.cc index abf02aef2..bb0b1fb05 100644 --- a/libretroshare/src/gxs/rsgxsutil.cc +++ b/libretroshare/src/gxs/rsgxsutil.cc @@ -67,7 +67,7 @@ bool RsGxsMessageCleanUp::clean() GxsMsgReq req; GxsMsgMetaResult result; - req[grpId] = std::vector(); + req[grpId] = std::set(); mDs->retrieveGxsMsgMetaData(req, result); GxsMsgMetaResult::iterator mit = result.begin(); @@ -117,7 +117,7 @@ bool RsGxsMessageCleanUp::clean() if( remove ) { - req[grpId].push_back(meta->mMsgId); + req[grpId].insert(meta->mMsgId); #ifdef DEBUG_GXSUTIL std::cerr << " Scheduling for removal." << std::endl; @@ -241,9 +241,9 @@ bool RsGxsIntegrityCheck::check() for (msgIdsIt = msgIds.begin(); msgIdsIt != msgIds.end(); ++msgIdsIt) { const RsGxsGroupId& grpId = msgIdsIt->first; - std::vector &msgIdV = msgIdsIt->second; + std::set &msgIdV = msgIdsIt->second; - std::vector::iterator msgIdIt; + std::set::iterator msgIdIt; for (msgIdIt = msgIdV.begin(); msgIdIt != msgIdV.end(); ++msgIdIt) { const RsGxsMessageId& msgId = *msgIdIt; @@ -261,7 +261,7 @@ bool RsGxsIntegrityCheck::check() if (nxsMsgIt == nxsMsgV.end()) { - msgsToDel[grpId].push_back(msgId); + msgsToDel[grpId].insert(msgId); } } } @@ -284,7 +284,7 @@ bool RsGxsIntegrityCheck::check() if(msg->metaData == NULL || currHash != msg->metaData->mHash) { std::cerr << "(EE) deleting message data with wrong hash or null meta data. meta=" << (void*)msg->metaData << std::endl; - msgsToDel[msg->grpId].push_back(msg->msgId); + msgsToDel[msg->grpId].insert(msg->msgId); } else if(!msg->metaData->mAuthorId.isNull() && subscribed_groups.find(msg->metaData->mGroupId)!=subscribed_groups.end()) { @@ -377,7 +377,7 @@ bool RsGxsIntegrityCheck::isDone() return mDone; } -void RsGxsIntegrityCheck::getDeletedIds(std::list& grpIds, std::map >& msgIds) +void RsGxsIntegrityCheck::getDeletedIds(std::list& grpIds, std::map >& msgIds) { RsStackMutex stack(mIntegrityMutex); diff --git a/libretroshare/src/gxs/rsgxsutil.h b/libretroshare/src/gxs/rsgxsutil.h index b169e00b5..70e832c3e 100644 --- a/libretroshare/src/gxs/rsgxsutil.h +++ b/libretroshare/src/gxs/rsgxsutil.h @@ -208,7 +208,7 @@ public: void run(); - void getDeletedIds(std::list& grpIds, std::map >& msgIds); + void getDeletedIds(std::list& grpIds, std::map > &msgIds); private: @@ -217,7 +217,7 @@ private: bool mDone; RsMutex mIntegrityMutex; std::list mDeletedGrps; - std::map > mDeletedMsgs; + std::map > mDeletedMsgs; RsGixs *mGixs ; }; diff --git a/libretroshare/src/gxstrans/p3gxstrans.cc b/libretroshare/src/gxstrans/p3gxstrans.cc index d0dbb61b0..5b3834ea8 100644 --- a/libretroshare/src/gxstrans/p3gxstrans.cc +++ b/libretroshare/src/gxstrans/p3gxstrans.cc @@ -455,7 +455,7 @@ void p3GxsTrans::GxsTransIntegrityCleanupThread::run() if(stored_msgs.end() != it2) { - msgsToDel[it2->second.first].push_back(it2->second.second); + msgsToDel[it2->second.first].insert(it2->second.second); #ifdef DEBUG_GXSTRANS std::cerr << " scheduling msg " << std::hex << it2->second.first << "," << it2->second.second << " for deletion." << std::endl; diff --git a/libretroshare/src/retroshare/rsgxsiface.h b/libretroshare/src/retroshare/rsgxsiface.h index 3e2ae55ae..36c660ef8 100644 --- a/libretroshare/src/retroshare/rsgxsiface.h +++ b/libretroshare/src/retroshare/rsgxsiface.h @@ -40,8 +40,8 @@ class RsGxsChanges public: RsGxsChanges(): mService(0){} RsTokenService *mService; - std::map > mMsgs; - std::map > mMsgsMeta; + std::map > mMsgs; + std::map > mMsgsMeta; std::list mGrps; std::list mGrpsMeta; }; diff --git a/libretroshare/src/retroshare/rsgxsifacetypes.h b/libretroshare/src/retroshare/rsgxsifacetypes.h index 18637f1b1..071b6bd46 100644 --- a/libretroshare/src/retroshare/rsgxsifacetypes.h +++ b/libretroshare/src/retroshare/rsgxsifacetypes.h @@ -43,10 +43,10 @@ typedef Sha1CheckSum RsGxsMessageId; typedef GXSId RsGxsId; typedef GXSCircleId RsGxsCircleId; -typedef std::map > GxsMsgIdResult; +typedef std::map > GxsMsgIdResult; typedef std::pair RsGxsGrpMsgIdPair; -typedef std::map > MsgRelatedIdResult; -typedef std::map > GxsMsgReq; +typedef std::map > MsgRelatedIdResult; +typedef std::map > GxsMsgReq; struct RsMsgMetaData; diff --git a/libretroshare/src/retroshare/rsgxsservice.h b/libretroshare/src/retroshare/rsgxsservice.h index 6afed31c6..b8b98940a 100644 --- a/libretroshare/src/retroshare/rsgxsservice.h +++ b/libretroshare/src/retroshare/rsgxsservice.h @@ -46,7 +46,7 @@ class RsGxsMsgChange : public RsGxsNotify { public: RsGxsMsgChange(NotifyType type, bool metaChange) : NOTIFY_TYPE(type), mMetaChange(metaChange) {} - std::map > msgChangeMap; + std::map > msgChangeMap; NotifyType getType(){ return NOTIFY_TYPE;} bool metaChange() { return mMetaChange; } private: diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index beb828fdf..dd284a4f1 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -241,16 +241,12 @@ void p3GxsChannels::notifyChanges(std::vector &changes) /* message received */ if (notify) { - std::map > &msgChangeMap = msgChange->msgChangeMap; - std::map >::iterator mit; - for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit) - { - std::vector::iterator mit1; - for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1) + std::map > &msgChangeMap = msgChange->msgChangeMap; + for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit) + for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1) { notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_MSG, mit->first.toStdString(), mit1->toStdString()); } - } } } @@ -261,9 +257,8 @@ void p3GxsChannels::notifyChanges(std::vector &changes) std::cerr << std::endl; #endif - std::map > &msgChangeMap = msgChange->msgChangeMap; - std::map >::iterator mit; - for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit) + std::map > &msgChangeMap = msgChange->msgChangeMap; + for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit) { #ifdef GXSCHANNELS_DEBUG std::cerr << "p3GxsChannels::notifyChanges() Msgs for Group: " << mit->first; @@ -807,10 +802,7 @@ void p3GxsChannels::request_SpecificUnprocessedPosts(std::list >::iterator it; for(it = ids.begin(); it != ids.end(); ++it) - { - std::vector &vect_msgIds = msgIds[it->first]; - vect_msgIds.push_back(it->second); - } + msgIds[it->first].insert(it->second); RsGenExchange::getTokenService()->requestMsgInfo(token, ansType, opts, msgIds); GxsTokenQueue::queueRequest(token, GXSCHANNELS_UNPROCESSED_SPECIFIC); diff --git a/libretroshare/src/services/p3gxscircles.cc b/libretroshare/src/services/p3gxscircles.cc index 5e27e378d..063361121 100644 --- a/libretroshare/src/services/p3gxscircles.cc +++ b/libretroshare/src/services/p3gxscircles.cc @@ -212,14 +212,14 @@ void p3GxsCircles::notifyChanges(std::vector &changes) #ifdef DEBUG_CIRCLES std::cerr << " Found circle Message Change Notification" << std::endl; #endif - for(std::map >::iterator mit = msgChange->msgChangeMap.begin(); mit != msgChange->msgChangeMap.end(); ++mit) + for(auto mit = msgChange->msgChangeMap.begin(); mit != msgChange->msgChangeMap.end(); ++mit) { #ifdef DEBUG_CIRCLES std::cerr << " Msgs for Group: " << mit->first << std::endl; #endif force_cache_reload(RsGxsCircleId(mit->first)); if (notify && (c->getType() == RsGxsNotify::TYPE_RECEIVE) ) - for (std::vector::const_iterator msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt) + for (auto msgIdIt(mit->second.begin()), end(mit->second.end()); msgIdIt != end; ++msgIdIt) { const RsGxsMessageId& msgId = *msgIdIt; notify->AddFeedItem(RS_FEED_ITEM_CIRCLE_MEMB_REQ,RsGxsCircleId(mit->first).toStdString(),msgId.toStdString()); @@ -2120,7 +2120,7 @@ bool p3GxsCircles::processMembershipRequests(uint32_t token) #ifdef DEBUG_CIRCLES std::cerr << " Older than last known (" << time(NULL)-info.last_subscription_TS << " seconds ago): deleting." << std::endl; #endif - messages_to_delete[RsGxsGroupId(cid)].push_back(it->second[i]->meta.mMsgId) ; + messages_to_delete[RsGxsGroupId(cid)].insert(it->second[i]->meta.mMsgId) ; } } diff --git a/libretroshare/src/services/p3gxscommon.cc b/libretroshare/src/services/p3gxscommon.cc index 5793e58ff..e1db6750d 100644 --- a/libretroshare/src/services/p3gxscommon.cc +++ b/libretroshare/src/services/p3gxscommon.cc @@ -502,8 +502,8 @@ bool p3GxsCommentService::createGxsVote(uint32_t &token, RsGxsVote &vote) opts.mReqType = GXS_REQUEST_TYPE_MSG_META; GxsMsgReq msgIds; - std::vector &vect_msgIds = msgIds[parentId.first]; - vect_msgIds.push_back(parentId.second); + std::set &vect_msgIds = msgIds[parentId.first]; + vect_msgIds.insert(parentId.second); uint32_t int_token; mExchange->getTokenService()->requestMsgInfo(int_token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, msgIds); diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index 7f1e8dfcf..1be91dc00 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -205,15 +205,12 @@ void p3GxsForums::notifyChanges(std::vector &changes) RsGxsMsgChange *msgChange = dynamic_cast(c); if (msgChange) { - std::map > &msgChangeMap = msgChange->msgChangeMap; - std::map >::iterator mit; - for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit) + std::map > &msgChangeMap = msgChange->msgChangeMap; + + for (auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit) { - std::vector::iterator mit1; - for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1) - { + for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1) notify->AddFeedItem(RS_FEED_ITEM_FORUM_MSG, mit->first.toStdString(), mit1->toStdString()); - } } break; } diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index 5ea8f898e..8a3f08195 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -562,8 +562,8 @@ void p3IdService::notifyChanges(std::vector &changes) std::cerr << std::endl; #endif - std::map > &msgChangeMap = msgChange->msgChangeMap; - std::map >::iterator mit; + std::map > &msgChangeMap = msgChange->msgChangeMap; + std::map >::iterator mit; for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit) { #ifdef DEBUG_IDS diff --git a/libretroshare/src/services/p3postbase.cc b/libretroshare/src/services/p3postbase.cc index 0c37db1f1..9d1df6bdc 100644 --- a/libretroshare/src/services/p3postbase.cc +++ b/libretroshare/src/services/p3postbase.cc @@ -110,9 +110,8 @@ void p3PostBase::notifyChanges(std::vector &changes) std::cerr << std::endl; #endif - std::map > &msgChangeMap = msgChange->msgChangeMap; - std::map >::iterator mit; - for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit) + std::map > &msgChangeMap = msgChange->msgChangeMap; + for(auto mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit) { #ifdef POSTBASE_DEBUG std::cerr << "p3PostBase::notifyChanges() Msgs for Group: " << mit->first; @@ -125,8 +124,7 @@ void p3PostBase::notifyChanges(std::vector &changes) if (notify && msgChange->getType() == RsGxsNotify::TYPE_RECEIVE) { - std::vector::iterator mit1; - for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1) + for (auto mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1) { notify->AddFeedItem(RS_FEED_ITEM_POSTED_MSG, mit->first.toStdString(), mit1->toStdString()); } @@ -431,7 +429,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed) mBgIncremental = unprocessed; } - std::map > postMap; + std::map > postMap; // generate vector of changes to push to the GUI. std::vector changes; @@ -487,7 +485,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed) #endif /* but we need to notify GUI about them */ - msgChanges->msgChangeMap[mit->first].push_back((*vit)->meta.mMsgId); + msgChanges->msgChangeMap[mit->first].insert((*vit)->meta.mMsgId); } else if (NULL != (commentItem = dynamic_cast(*vit))) { @@ -546,7 +544,7 @@ void p3PostBase::background_loadMsgs(const uint32_t &token, bool unprocessed) if (sit == mBgStatsMap.end()) { // add to map of ones to update. - postMap[groupId].push_back(threadId); + postMap[groupId].insert(threadId); mBgStatsMap[threadId] = PostStats(0,0,0); sit = mBgStatsMap.find(threadId); @@ -704,7 +702,7 @@ void p3PostBase::background_updateVoteCounts(const uint32_t &token) #endif stats.increment(it->second); - msgChanges->msgChangeMap[mit->first].push_back(vit->mMsgId); + msgChanges->msgChangeMap[mit->first].insert(vit->mMsgId); } else { diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 17e62d3ca..7f644be5f 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -2132,12 +2132,12 @@ void IdDialog::updateDisplay(bool complete) } requestCircleGroupMeta(); - std::list grpIds; + std::set grpIds; getAllGrpIds(grpIds); if (!getGrpIds().empty()) { requestIdList(); - if (!mId.isNull() && std::find(grpIds.begin(), grpIds.end(), mId) != grpIds.end()) { + if (!mId.isNull() && grpIds.find(mId)!=grpIds.end()) { requestIdDetails(); requestRepList(); } diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index 45c8c1cb6..a9c599389 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -366,8 +366,8 @@ void NewsFeed::updateDisplay() opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; GxsMsgReq msgIds; - std::vector &vect_msgIds = msgIds[grpId]; - vect_msgIds.push_back(msgId); + std::set &vect_msgIds = msgIds[grpId]; + vect_msgIds.insert(msgId); uint32_t token; mTokenQueueCircle->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, TOKEN_TYPE_MESSAGE); diff --git a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp index e9773aba9..b02afa336 100644 --- a/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp +++ b/retroshare-gui/src/gui/feeds/GxsForumMsgItem.cpp @@ -438,8 +438,8 @@ void GxsForumMsgItem::requestParentMessage(const RsGxsMessageId &msgId) opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; GxsMsgReq msgIds; - std::vector &vect_msgIds = msgIds[groupId()]; - vect_msgIds.push_back(msgId); + std::set &vect_msgIds = msgIds[groupId()]; + vect_msgIds.insert(msgId); uint32_t token; mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeParentMessage); diff --git a/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp b/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp index f795768f6..2f036f900 100644 --- a/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsFeedItem.cpp @@ -93,19 +93,15 @@ void GxsFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, boo { GxsGroupFeedItem::fillDisplay(updateBroadcastBase, complete); - std::map > msgs; + std::map > msgs; updateBroadcastBase->getAllMsgIds(msgs); if (!msgs.empty()) { - std::map >::const_iterator mit = msgs.find(groupId()); - if (mit != msgs.end()) - { - const std::vector &msgIds = mit->second; - if (std::find(msgIds.begin(), msgIds.end(), messageId()) != msgIds.end()) { + std::map >::const_iterator mit = msgs.find(groupId()); + + if (mit != msgs.end() && mit->second.find(messageId()) != mit->second.end()) requestMessage(); - } - } } } @@ -129,8 +125,8 @@ void GxsFeedItem::requestMessage() opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; GxsMsgReq msgIds; - std::vector &vect_msgIds = msgIds[groupId()]; - vect_msgIds.push_back(mMessageId); + std::set &vect_msgIds = msgIds[groupId()]; + vect_msgIds.insert(mMessageId); uint32_t token; mLoadQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeMessage); diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp index 9682ab987..1b3d0990e 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFeedItem.cpp @@ -170,12 +170,11 @@ void GxsGroupFeedItem::fillDisplaySlot(bool complete) void GxsGroupFeedItem::fillDisplay(RsGxsUpdateBroadcastBase *updateBroadcastBase, bool /*complete*/) { - std::list grpIds; + std::set grpIds; updateBroadcastBase->getAllGrpIds(grpIds); - if (std::find(grpIds.begin(), grpIds.end(), groupId()) != grpIds.end()) { + if (grpIds.find(groupId()) != grpIds.end()) requestGroup(); - } } /***********************************************************/ diff --git a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp index 3bae96cfd..33c6a04e5 100644 --- a/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsGroupFrameDialog.cpp @@ -236,11 +236,10 @@ void GxsGroupFrameDialog::updateDisplay(bool complete) requestGroupSummary(); } else { /* Update all groups of changed messages */ - std::map > msgIds; + std::map > msgIds; getAllMsgIds(msgIds); - std::map >::iterator msgIt; - for (msgIt = msgIds.begin(); msgIt != msgIds.end(); ++msgIt) { + for (auto msgIt = msgIds.begin(); msgIt != msgIds.end(); ++msgIt) { updateMessageSummaryList(msgIt->first); } } diff --git a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp index df5442bcd..f23dc83f2 100644 --- a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.cpp @@ -109,21 +109,22 @@ void GxsMessageFramePostWidget::updateDisplay(bool complete) } bool updateGroup = false; - const std::list &grpIdsMeta = getGrpIdsMeta(); - if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), groupId()) != grpIdsMeta.end()) { - updateGroup = true; - } + const std::set &grpIdsMeta = getGrpIdsMeta(); - const std::list &grpIds = getGrpIds(); - if (!groupId().isNull() && std::find(grpIds.begin(), grpIds.end(), groupId()) != grpIds.end()) { + if(grpIdsMeta.find(groupId())!=grpIdsMeta.end()) + updateGroup = true; + + const std::set &grpIds = getGrpIds(); + if (!groupId().isNull() && grpIds.find(groupId())!=grpIds.end()) + { updateGroup = true; /* Do we need to fill all posts? */ requestAllPosts(); } else { - std::map > msgs; + std::map > msgs; getAllMsgIds(msgs); if (!msgs.empty()) { - std::map >::const_iterator mit = msgs.find(groupId()); + auto mit = msgs.find(groupId()); if (mit != msgs.end()) { requestPosts(mit->second); } @@ -341,7 +342,7 @@ void GxsMessageFramePostWidget::loadAllPosts(const uint32_t &token) emit groupChanged(this); } -void GxsMessageFramePostWidget::requestPosts(const std::vector &msgIds) +void GxsMessageFramePostWidget::requestPosts(const std::set &msgIds) { #ifdef ENABLE_DEBUG std::cerr << "GxsMessageFramePostWidget::requestPosts()"; diff --git a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h index d01a0ca42..2a42cb772 100644 --- a/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h +++ b/retroshare-gui/src/gui/gxs/GxsMessageFramePostWidget.h @@ -72,7 +72,7 @@ protected: void loadAllPosts(const uint32_t &token); virtual void insertAllPosts(const uint32_t &token, GxsMessageFramePostThread *thread) = 0; - void requestPosts(const std::vector &msgIds); + void requestPosts(const std::set &msgIds); void loadPosts(const uint32_t &token); virtual void insertPosts(const uint32_t &token) = 0; diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp index a657959a9..8d4bc0fc3 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp @@ -15,7 +15,7 @@ RsGxsUpdateBroadcastBase::RsGxsUpdateBroadcastBase(RsGxsIfaceHelper *ifaceImpl, mUpdateBroadcast = RsGxsUpdateBroadcast::get(ifaceImpl); connect(mUpdateBroadcast, SIGNAL(changed()), this, SLOT(updateBroadcastChanged())); connect(mUpdateBroadcast, SIGNAL(grpsChanged(std::list, std::list)), this, SLOT(updateBroadcastGrpsChanged(std::list,std::list))); - connect(mUpdateBroadcast, SIGNAL(msgsChanged(std::map >, std::map >)), this, SLOT(updateBroadcastMsgsChanged(std::map >,std::map >))); + connect(mUpdateBroadcast, SIGNAL(msgsChanged(std::map >, std::map >)), this, SLOT(updateBroadcastMsgsChanged(std::map >,std::map >))); } RsGxsUpdateBroadcastBase::~RsGxsUpdateBroadcastBase() @@ -84,79 +84,36 @@ void RsGxsUpdateBroadcastBase::updateBroadcastChanged() void RsGxsUpdateBroadcastBase::updateBroadcastGrpsChanged(const std::list &grpIds, const std::list &grpIdsMeta) { std::list::const_iterator it; - for (it = grpIds.begin(); it != grpIds.end(); ++it) { - if (std::find(mGrpIds.begin(), mGrpIds.end(), *it) == mGrpIds.end()) { - mGrpIds.push_back(*it); - } - } - for (it = grpIdsMeta.begin(); it != grpIdsMeta.end(); ++it) { - if (std::find(mGrpIdsMeta.begin(), mGrpIdsMeta.end(), *it) == mGrpIdsMeta.end()) { - mGrpIdsMeta.push_back(*it); - } - } + for (it = grpIds.begin(); it != grpIds.end(); ++it) + mGrpIds.insert(*it) ; + + for (it = grpIdsMeta.begin(); it != grpIdsMeta.end(); ++it) + mGrpIdsMeta.insert(*it); } -void RsGxsUpdateBroadcastBase::updateBroadcastMsgsChanged(const std::map > &msgIds, const std::map > &msgIdsMeta) +template void merge(std::set& dst,const std::set& src) { for(auto it(src.begin());it!=src.end();++it) dst.insert(*it) ; } + +void RsGxsUpdateBroadcastBase::updateBroadcastMsgsChanged(const std::map > &msgIds, const std::map > &msgIdsMeta) { - std::map >::const_iterator mapIt; - for (mapIt = msgIds.begin(); mapIt != msgIds.end(); ++mapIt) { - const RsGxsGroupId &grpId = mapIt->first; - const std::vector &srcMsgIds = mapIt->second; - std::vector &destMsgIds = mMsgIds[grpId]; + for (auto mapIt = msgIds.begin(); mapIt != msgIds.end(); ++mapIt) + merge(mMsgIds[mapIt->first],mapIt->second) ; - std::vector::const_iterator msgIt; - for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) { - if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) { - destMsgIds.push_back(*msgIt); - } - } - } - for (mapIt = msgIdsMeta.begin(); mapIt != msgIdsMeta.end(); ++mapIt) { - const RsGxsGroupId &grpId = mapIt->first; - const std::vector &srcMsgIds = mapIt->second; - std::vector &destMsgIds = mMsgIdsMeta[grpId]; - - std::vector::const_iterator msgIt; - for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) { - if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) { - destMsgIds.push_back(*msgIt); - } - } - } + for (auto mapIt = msgIdsMeta.begin(); mapIt != msgIdsMeta.end(); ++mapIt) + merge(mMsgIdsMeta[mapIt->first],mapIt->second) ; } -void RsGxsUpdateBroadcastBase::getAllGrpIds(std::list &grpIds) +void RsGxsUpdateBroadcastBase::getAllGrpIds(std::set &grpIds) { - std::list::const_iterator it; - for (it = mGrpIds.begin(); it != mGrpIds.end(); ++it) { - if (std::find(grpIds.begin(), grpIds.end(), *it) == grpIds.end()) { - grpIds.push_back(*it); - } - } - for (it = mGrpIdsMeta.begin(); it != mGrpIdsMeta.end(); ++it) { - if (std::find(grpIds.begin(), grpIds.end(), *it) == grpIds.end()) { - grpIds.push_back(*it); - } - } + grpIds = mGrpIds; + merge(grpIds,mGrpIdsMeta) ; } -void RsGxsUpdateBroadcastBase::getAllMsgIds(std::map > &msgIds) +void RsGxsUpdateBroadcastBase::getAllMsgIds(std::map > &msgIds) { /* Copy first map */ msgIds = mMsgIds; /* Append second map */ - std::map >::const_iterator mapIt; - for (mapIt = mMsgIdsMeta.begin(); mapIt != mMsgIdsMeta.end(); ++mapIt) { - const RsGxsGroupId &grpId = mapIt->first; - const std::vector &srcMsgIds = mapIt->second; - std::vector &destMsgIds = msgIds[grpId]; - - std::vector::const_iterator msgIt; - for (msgIt = srcMsgIds.begin(); msgIt != srcMsgIds.end(); ++msgIt) { - if (std::find(destMsgIds.begin(), destMsgIds.end(), *msgIt) == destMsgIds.end()) { - destMsgIds.push_back(*msgIt); - } - } - } + for (auto mapIt = mMsgIdsMeta.begin(); mapIt != mMsgIdsMeta.end(); ++mapIt) + merge(msgIds[mapIt->first],mapIt->second); } diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h index 9ffa8ff72..90dd3f507 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.h @@ -19,12 +19,12 @@ public: RsGxsUpdateBroadcastBase(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL); virtual ~RsGxsUpdateBroadcastBase(); - const std::list &getGrpIds() { return mGrpIds; } - const std::list &getGrpIdsMeta() { return mGrpIdsMeta; } - void getAllGrpIds(std::list &grpIds); - const std::map > &getMsgIds() { return mMsgIds; } - const std::map > &getMsgIdsMeta() { return mMsgIdsMeta; } - void getAllMsgIds(std::map > &msgIds); + const std::set &getGrpIds() { return mGrpIds; } + const std::set &getGrpIdsMeta() { return mGrpIdsMeta; } + void getAllGrpIds(std::set &grpIds); + const std::map > &getMsgIds() { return mMsgIds; } + const std::map > &getMsgIdsMeta() { return mMsgIdsMeta; } + void getAllMsgIds(std::map > &msgIds); protected: void fillComplete(); @@ -38,15 +38,15 @@ signals: private slots: void updateBroadcastChanged(); void updateBroadcastGrpsChanged(const std::list& grpIds, const std::list &grpIdsMeta); - void updateBroadcastMsgsChanged(const std::map >& msgIds, const std::map >& msgIdsMeta); + void updateBroadcastMsgsChanged(const std::map >& msgIds, const std::map >& msgIdsMeta); void securedUpdateDisplay(); private: RsGxsUpdateBroadcast *mUpdateBroadcast; bool mFillComplete; bool mUpdateWhenInvisible; // Update also when not visible - std::list mGrpIds; - std::list mGrpIdsMeta; - std::map > mMsgIds; - std::map > mMsgIdsMeta; + std::set mGrpIds; + std::set mGrpIdsMeta; + std::map > mMsgIds; + std::map > mMsgIdsMeta; }; diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp index 5eba14b89..629148688 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.cpp @@ -22,32 +22,32 @@ void RsGxsUpdateBroadcastPage::setUpdateWhenInvisible(bool update) mBase->setUpdateWhenInvisible(update); } -const std::list &RsGxsUpdateBroadcastPage::getGrpIdsMeta() +const std::set &RsGxsUpdateBroadcastPage::getGrpIdsMeta() { return mBase->getGrpIdsMeta(); } -void RsGxsUpdateBroadcastPage::getAllGrpIds(std::list &grpIds) +void RsGxsUpdateBroadcastPage::getAllGrpIds(std::set &grpIds) { mBase->getAllGrpIds(grpIds); } -const std::list &RsGxsUpdateBroadcastPage::getGrpIds() +const std::set &RsGxsUpdateBroadcastPage::getGrpIds() { return mBase->getGrpIds(); } -const std::map > &RsGxsUpdateBroadcastPage::getMsgIdsMeta() +const std::map > &RsGxsUpdateBroadcastPage::getMsgIdsMeta() { return mBase->getMsgIdsMeta(); } -void RsGxsUpdateBroadcastPage::getAllMsgIds(std::map > &msgIds) +void RsGxsUpdateBroadcastPage::getAllMsgIds(std::map > &msgIds) { mBase->getAllMsgIds(msgIds); } -const std::map > &RsGxsUpdateBroadcastPage::getMsgIds() +const std::map > &RsGxsUpdateBroadcastPage::getMsgIds() { return mBase->getMsgIds(); } diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h index ed03bb15c..0c67f58ff 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastPage.h @@ -24,12 +24,12 @@ public: void fillComplete(); void setUpdateWhenInvisible(bool update); - const std::list &getGrpIds(); - const std::list &getGrpIdsMeta(); - void getAllGrpIds(std::list &grpIds); - const std::map > &getMsgIds(); - const std::map > &getMsgIdsMeta(); - void getAllMsgIds(std::map > &msgIds); + const std::set &getGrpIds(); + const std::set &getGrpIdsMeta(); + void getAllGrpIds(std::set &grpIds); + const std::map > &getMsgIds(); + const std::map > &getMsgIdsMeta(); + void getAllMsgIds(std::map > &msgIds); protected: virtual void showEvent(QShowEvent *event); diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp index d2450e719..a6e3e5705 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp @@ -24,32 +24,32 @@ void RsGxsUpdateBroadcastWidget::setUpdateWhenInvisible(bool update) mBase->setUpdateWhenInvisible(update); } -const std::list &RsGxsUpdateBroadcastWidget::getGrpIds() +const std::set &RsGxsUpdateBroadcastWidget::getGrpIds() { return mBase->getGrpIds(); } -const std::list &RsGxsUpdateBroadcastWidget::getGrpIdsMeta() +const std::set &RsGxsUpdateBroadcastWidget::getGrpIdsMeta() { return mBase->getGrpIdsMeta(); } -void RsGxsUpdateBroadcastWidget::getAllGrpIds(std::list &grpIds) +void RsGxsUpdateBroadcastWidget::getAllGrpIds(std::set &grpIds) { mBase->getAllGrpIds(grpIds); } -const std::map > &RsGxsUpdateBroadcastWidget::getMsgIds() +const std::map > &RsGxsUpdateBroadcastWidget::getMsgIds() { return mBase->getMsgIds(); } -const std::map > &RsGxsUpdateBroadcastWidget::getMsgIdsMeta() +const std::map > &RsGxsUpdateBroadcastWidget::getMsgIdsMeta() { return mBase->getMsgIdsMeta(); } -void RsGxsUpdateBroadcastWidget::getAllMsgIds(std::map > &msgIds) +void RsGxsUpdateBroadcastWidget::getAllMsgIds(std::map > &msgIds) { mBase->getAllMsgIds(msgIds); } diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h index 33fcd06bf..f0ab07742 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.h @@ -24,12 +24,12 @@ public: void fillComplete(); void setUpdateWhenInvisible(bool update); - const std::list &getGrpIds(); - const std::list &getGrpIdsMeta(); - void getAllGrpIds(std::list &grpIds); - const std::map > &getMsgIds(); - const std::map > &getMsgIdsMeta(); - void getAllMsgIds(std::map > &msgIds); + const std::set &getGrpIds(); + const std::set &getGrpIdsMeta(); + void getAllGrpIds(std::set &grpIds); + const std::map > &getMsgIds(); + const std::map > &getMsgIdsMeta(); + void getAllMsgIds(std::map > &msgIds); RsGxsIfaceHelper *interfaceHelper() { return mInterfaceHelper; } diff --git a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp index cc93d5627..b4470ac5c 100644 --- a/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp +++ b/retroshare-gui/src/gui/gxschannels/CreateGxsChannelMsg.cpp @@ -604,7 +604,7 @@ void CreateGxsChannelMsg::newChannelMsg() GxsMsgReq message_ids; opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; - message_ids[mChannelId].push_back(mOrigPostId); + message_ids[mChannelId].insert(mOrigPostId); mChannelQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, message_ids, CREATEMSG_CHANNEL_POST_INFO); } } diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index 60f34221f..23d827ac3 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -185,8 +185,8 @@ void CreateGxsForumMsg::newMsg() opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; GxsMsgReq msgIds; - std::vector &vect = msgIds[mForumId]; - vect.push_back(mParentId); + std::set &vect = msgIds[mForumId]; + vect.insert(mParentId); //std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")"; //std::cerr << std::endl; @@ -205,8 +205,8 @@ void CreateGxsForumMsg::newMsg() opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA; GxsMsgReq msgIds; - std::vector &vect = msgIds[mForumId]; - vect.push_back(mOrigMsgId); + std::set &vect = msgIds[mForumId]; + vect.insert(mOrigMsgId); //std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")"; //std::cerr << std::endl; diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp index 5209ca184..7b9ff9183 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumThreadWidget.cpp @@ -404,25 +404,25 @@ void GxsForumThreadWidget::changeEvent(QEvent *e) } } -static void removeMessages(std::map > &msgIds, QList &removeMsgId) +static void removeMessages(std::map > &msgIds, QList &removeMsgId) { QList removedMsgId; - std::map >::iterator grpIt; - for (grpIt = msgIds.begin(); grpIt != msgIds.end(); ) { - std::vector &msgs = grpIt->second; + for (auto grpIt = msgIds.begin(); grpIt != msgIds.end(); ) + { + std::set &msgs = grpIt->second; QList::const_iterator removeMsgIt; for (removeMsgIt = removeMsgId.begin(); removeMsgIt != removeMsgId.end(); ++removeMsgIt) { - std::vector::iterator msgIt = std::find(msgs.begin(), msgs.end(), *removeMsgIt); - if (msgIt != msgs.end()) { + if(msgs.find(*removeMsgIt) != msgs.end()) + { removedMsgId.push_back(*removeMsgIt); - msgs.erase(msgIt); + msgs.erase(*removeMsgIt); } } if (msgs.empty()) { - std::map >::iterator grpItErase = grpIt++; + std::map >::iterator grpItErase = grpIt++; msgIds.erase(grpItErase); } else { ++grpIt; @@ -452,18 +452,18 @@ void GxsForumThreadWidget::updateDisplay(bool complete) } bool updateGroup = false; - const std::list &grpIdsMeta = getGrpIdsMeta(); - if (std::find(grpIdsMeta.begin(), grpIdsMeta.end(), groupId()) != grpIdsMeta.end()) { - updateGroup = true; - } + const std::set &grpIdsMeta = getGrpIdsMeta(); - const std::list &grpIds = getGrpIds(); - if (std::find(grpIds.begin(), grpIds.end(), groupId()) != grpIds.end()) { + if(grpIdsMeta.find(groupId())!=grpIdsMeta.end()) + updateGroup = true; + + const std::set &grpIds = getGrpIds(); + if (grpIds.find(groupId())!=grpIds.end()){ updateGroup = true; /* Update threads */ insertThreads(); } else { - std::map > msgIds; + std::map > msgIds; getAllMsgIds(msgIds); if (!mIgnoredMsgId.empty()) { @@ -2111,8 +2111,8 @@ void GxsForumThreadWidget::flagperson() #endif GxsMsgReq msgIds; - std::vector &vect = msgIds[postId.first]; - vect.push_back(postId.second); + std::set &vect = msgIds[postId.first]; + vect.insert(postId.second); uint32_t token; mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, token_type); @@ -2413,8 +2413,8 @@ void GxsForumThreadWidget::requestMessageData(const RsGxsGrpMsgIdPair &msgId) #endif GxsMsgReq msgIds; - std::vector &vect = msgIds[msgId.first]; - vect.push_back(msgId.second); + std::set &vect = msgIds[msgId.first]; + vect.insert(msgId.second); uint32_t token; mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeMessageData); @@ -2464,8 +2464,8 @@ void GxsForumThreadWidget::requestMsgData_ReplyWithPrivateMessage(const RsGxsGrp #endif GxsMsgReq msgIds; - std::vector &vect = msgIds[msgId.first]; - vect.push_back(msgId.second); + std::set &vect = msgIds[msgId.first]; + vect.insert(msgId.second); uint32_t token; mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeReplyMessage); @@ -2482,8 +2482,8 @@ void GxsForumThreadWidget::requestMsgData_ShowAuthorInPeople(const RsGxsGrpMsgId #endif GxsMsgReq msgIds; - std::vector &vect = msgIds[msgId.first]; - vect.push_back(msgId.second); + std::set &vect = msgIds[msgId.first]; + vect.insert(msgId.second); uint32_t token; mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeShowAuthorInPeople); @@ -2499,8 +2499,8 @@ void GxsForumThreadWidget::requestMsgData_EditForumMessage(const RsGxsGrpMsgIdPa #endif GxsMsgReq msgIds; - std::vector &vect = msgIds[msgId.first]; - vect.push_back(msgId.second); + std::set &vect = msgIds[msgId.first]; + vect.insert(msgId.second); uint32_t token; mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeEditForumMessage); @@ -2516,8 +2516,8 @@ void GxsForumThreadWidget::requestMsgData_ReplyForumMessage(const RsGxsGrpMsgIdP #endif GxsMsgReq msgIds; - std::vector &vect = msgIds[msgId.first]; - vect.push_back(msgId.second); + std::set &vect = msgIds[msgId.first]; + vect.insert(msgId.second); uint32_t token; mTokenQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, mTokenTypeReplyForumMessage); diff --git a/retroshare-gui/src/util/RsGxsUpdateBroadcast.h b/retroshare-gui/src/util/RsGxsUpdateBroadcast.h index d9d90db1f..1622ca606 100644 --- a/retroshare-gui/src/util/RsGxsUpdateBroadcast.h +++ b/retroshare-gui/src/util/RsGxsUpdateBroadcast.h @@ -19,7 +19,7 @@ public: signals: void changed(); - void msgsChanged(const std::map >& msgIds, const std::map >& msgIdsMeta); + void msgsChanged(const std::map >& msgIds, const std::map >& msgIdsMeta); void grpsChanged(const std::list& grpIds, const std::list& grpIdsMeta); private slots: From cadc6978825c65009bd337da4dbccd620de25470 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 21 Jun 2018 17:27:15 +0200 Subject: [PATCH 37/50] removed reload of currently selected identity during full reload of Id list in People as it caused some blinking --- retroshare-gui/src/gui/Identity/IdDialog.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 7f644be5f..5c9bce46b 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -2125,7 +2125,7 @@ void IdDialog::updateDisplay(bool complete) if (complete) { /* Fill complete */ requestIdList(); - requestIdDetails(); + //requestIdDetails(); requestRepList(); return; From a7f1adc49adc9d2f1ed625d410e0ea8b0fe69c91 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 21 Jun 2018 18:55:29 +0200 Subject: [PATCH 38/50] added comment --- retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp index 8d4bc0fc3..ffbd6147e 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastBase.cpp @@ -73,6 +73,7 @@ void RsGxsUpdateBroadcastBase::updateBroadcastChanged() // first place so there's no need to re-update the UI once this is done. // // The question to whether we should re=load when mGrpIds is not empty is still open. It's not harmful anyway. + // This should probably be decided by the service itself. if (!mGrpIds.empty() || !mGrpIdsMeta.empty() /*|| !mMsgIds.empty()*/ || !mMsgIdsMeta.empty()) mFillComplete = true ; From 502459a25a01e3136c0e8c1b05fb3b8dd72f8f4d Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Tue, 26 Jun 2018 15:12:16 +0200 Subject: [PATCH 39/50] Cleanup rapidjson inclusion Fix compilation error of android service --- libresapi/src/libresapi.pro | 4 ---- libretroshare/src/libretroshare.pro | 5 ----- libretroshare/src/use_libretroshare.pri | 5 +++++ retroshare-gui/src/retroshare-gui.pro | 5 ----- retroshare-nogui/src/retroshare-nogui.pro | 4 ---- 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/libresapi/src/libresapi.pro b/libresapi/src/libresapi.pro index 161ce9bf7..5f4c973e9 100644 --- a/libresapi/src/libresapi.pro +++ b/libresapi/src/libresapi.pro @@ -9,10 +9,6 @@ DESTDIR = lib !include(use_libresapi.pri):error("Including") -# when rapidjson is mainstream on all distribs, we will not need the sources anymore -# in the meantime, they are part of the RS directory so that it is always possible to find them - -INCLUDEPATH += ../../rapidjson-1.1.0 INCLUDEPATH += ../../libretroshare/src libresapilocalserver { diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index 729c9186d..999cf30eb 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -17,11 +17,6 @@ DESTDIR = lib #QMAKE_CFLAGS += -Werror #QMAKE_CXXFLAGS += -Werror -# when rapidjson is mainstream on all distribs, we will not need the sources anymore -# in the meantime, they are part of the RS directory so that it is always possible to find them - -INCLUDEPATH += ../../rapidjson-1.1.0 - debug { # DEFINES *= DEBUG # DEFINES *= OPENDHT_DEBUG DHT_DEBUG CONN_DEBUG DEBUG_UDP_SORTER P3DISC_DEBUG DEBUG_UDP_LAYER FT_DEBUG EXTADDRSEARCH_DEBUG diff --git a/libretroshare/src/use_libretroshare.pri b/libretroshare/src/use_libretroshare.pri index d17e36739..3a3d1acb7 100644 --- a/libretroshare/src/use_libretroshare.pri +++ b/libretroshare/src/use_libretroshare.pri @@ -13,6 +13,11 @@ bitdht { !include("../../libbitdht/src/use_libbitdht.pri"):error("Including") } +# when rapidjson is mainstream on all distribs, we will not need the sources +# anymore in the meantime, they are part of the RS directory so that it is +# always possible to find them +INCLUDEPATH *= $$system_path($$clean_path($${PWD}/../../rapidjson-1.1.0)) + sLibs = mLibs = $$RS_SQL_LIB ssl crypto $$RS_THREAD_LIB $$RS_UPNP_LIB dLibs = diff --git a/retroshare-gui/src/retroshare-gui.pro b/retroshare-gui/src/retroshare-gui.pro index 48e10a377..30b2af946 100644 --- a/retroshare-gui/src/retroshare-gui.pro +++ b/retroshare-gui/src/retroshare-gui.pro @@ -10,11 +10,6 @@ DEFINES += TARGET=\\\"$${TARGET}\\\" DEPENDPATH *= $${PWD} $${RS_INCLUDE_DIR} retroshare-gui INCLUDEPATH *= $${PWD} retroshare-gui -# when rapidjson is mainstream on all distribs, we will not need the sources anymore -# in the meantime, they are part of the RS directory so that it is always possible to find them - -INCLUDEPATH += ../../rapidjson-1.1.0 - libresapihttpserver { !include("../../libresapi/src/use_libresapi.pri"):error("Including") HEADERS *= gui/settings/WebuiPage.h diff --git a/retroshare-nogui/src/retroshare-nogui.pro b/retroshare-nogui/src/retroshare-nogui.pro index 6c95d278c..05f5e99e1 100644 --- a/retroshare-nogui/src/retroshare-nogui.pro +++ b/retroshare-nogui/src/retroshare-nogui.pro @@ -16,10 +16,6 @@ libresapihttpserver { !include("../../libretroshare/src/use_libretroshare.pri"):error("Including") -# when rapidjson is mainstream on all distribs, we will not need the sources anymore -# in the meantime, they are part of the RS directory so that it is always possible to find them - -INCLUDEPATH += ../../rapidjson-1.1.0 ################################# Linux ########################################## linux-* { From f7625e35261b11e8ce3f391a9963fb0ec69802e5 Mon Sep 17 00:00:00 2001 From: sehraf Date: Thu, 28 Jun 2018 20:25:10 +0200 Subject: [PATCH 40/50] fix json uint64 --- libretroshare/src/serialiser/rstypeserializer.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libretroshare/src/serialiser/rstypeserializer.cc b/libretroshare/src/serialiser/rstypeserializer.cc index e7faa5b52..72d20ecc2 100644 --- a/libretroshare/src/serialiser/rstypeserializer.cc +++ b/libretroshare/src/serialiser/rstypeserializer.cc @@ -291,8 +291,8 @@ bool RsTypeSerializer::from_JSON( const std::string& memberName, uint64_t& member, RsJson& jDoc ) { SAFE_GET_JSON_V(); - ret = ret && v.IsUint(); - if(ret) member = v.GetUint(); + ret = ret && v.IsUint64(); + if(ret) member = v.GetUint64(); return ret; } From abc5b840d265e6316d2d3efb5b3ef1dbf42629de Mon Sep 17 00:00:00 2001 From: cyril soler Date: Mon, 2 Jul 2018 09:36:21 +0200 Subject: [PATCH 41/50] added queuedConnection type in fillDisplay() between RsGxsBroadcastWidget and RsGxsBroadCastBase. --- retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp index a6e3e5705..2f1ddf4d6 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp @@ -4,8 +4,9 @@ RsGxsUpdateBroadcastWidget::RsGxsUpdateBroadcastWidget(RsGxsIfaceHelper *ifaceImpl, QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags) { - mBase = new RsGxsUpdateBroadcastBase(ifaceImpl, this); - connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool))); + mBase = new RsGxsUpdateBroadcastBase(ifaceImpl, this); + // The Queued connection is here to circumvent an apparent mutex problem in Qt + connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool)),Qt::QueuedConnection); mInterfaceHelper = ifaceImpl; } @@ -14,6 +15,7 @@ RsGxsUpdateBroadcastWidget::~RsGxsUpdateBroadcastWidget() { } + void RsGxsUpdateBroadcastWidget::fillComplete() { mBase->fillComplete(); From e6db04e2b538b7e6ef01013beaf0aae1a8ce0132 Mon Sep 17 00:00:00 2001 From: cyril soler Date: Mon, 2 Jul 2018 09:45:17 +0200 Subject: [PATCH 42/50] cancelled previous commit, because it sort of breaks the update of forum lists. --- .../gui/gxs/RsGxsUpdateBroadcastWidget.cpp | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp index 2f1ddf4d6..19ae2c3d0 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp @@ -2,68 +2,66 @@ #include "RsGxsUpdateBroadcastBase.h" RsGxsUpdateBroadcastWidget::RsGxsUpdateBroadcastWidget(RsGxsIfaceHelper *ifaceImpl, QWidget *parent, Qt::WindowFlags flags) - : QWidget(parent, flags) + : QWidget(parent, flags) { mBase = new RsGxsUpdateBroadcastBase(ifaceImpl, this); - // The Queued connection is here to circumvent an apparent mutex problem in Qt - connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool)),Qt::QueuedConnection); + connect(mBase, SIGNAL(fillDisplay(bool)), this, SLOT(fillDisplay(bool))); - mInterfaceHelper = ifaceImpl; + mInterfaceHelper = ifaceImpl; } RsGxsUpdateBroadcastWidget::~RsGxsUpdateBroadcastWidget() { } - void RsGxsUpdateBroadcastWidget::fillComplete() { - mBase->fillComplete(); + mBase->fillComplete(); } void RsGxsUpdateBroadcastWidget::setUpdateWhenInvisible(bool update) { - mBase->setUpdateWhenInvisible(update); + mBase->setUpdateWhenInvisible(update); } -const std::set &RsGxsUpdateBroadcastWidget::getGrpIds() +const std::list &RsGxsUpdateBroadcastWidget::getGrpIds() { - return mBase->getGrpIds(); + return mBase->getGrpIds(); } -const std::set &RsGxsUpdateBroadcastWidget::getGrpIdsMeta() +const std::list &RsGxsUpdateBroadcastWidget::getGrpIdsMeta() { - return mBase->getGrpIdsMeta(); + return mBase->getGrpIdsMeta(); } -void RsGxsUpdateBroadcastWidget::getAllGrpIds(std::set &grpIds) +void RsGxsUpdateBroadcastWidget::getAllGrpIds(std::list &grpIds) { - mBase->getAllGrpIds(grpIds); + mBase->getAllGrpIds(grpIds); } -const std::map > &RsGxsUpdateBroadcastWidget::getMsgIds() +const std::map > &RsGxsUpdateBroadcastWidget::getMsgIds() { - return mBase->getMsgIds(); + return mBase->getMsgIds(); } -const std::map > &RsGxsUpdateBroadcastWidget::getMsgIdsMeta() +const std::map > &RsGxsUpdateBroadcastWidget::getMsgIdsMeta() { - return mBase->getMsgIdsMeta(); + return mBase->getMsgIdsMeta(); } -void RsGxsUpdateBroadcastWidget::getAllMsgIds(std::map > &msgIds) +void RsGxsUpdateBroadcastWidget::getAllMsgIds(std::map > &msgIds) { - mBase->getAllMsgIds(msgIds); + mBase->getAllMsgIds(msgIds); } void RsGxsUpdateBroadcastWidget::fillDisplay(bool complete) { - updateDisplay(complete); - update(); // Qt flush + updateDisplay(complete); + update(); // Qt flush } void RsGxsUpdateBroadcastWidget::showEvent(QShowEvent *event) { - mBase->showEvent(event); - QWidget::showEvent(event); + mBase->showEvent(event); + QWidget::showEvent(event); } From 1b2b3113ca80cfb8b6dff648928f9a4a42f25542 Mon Sep 17 00:00:00 2001 From: cyril soler Date: Mon, 2 Jul 2018 10:21:38 +0200 Subject: [PATCH 43/50] fixed previous commit caused by an apparent bug in qtcreator when updating code --- .../src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp index 19ae2c3d0..c20809937 100644 --- a/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp +++ b/retroshare-gui/src/gui/gxs/RsGxsUpdateBroadcastWidget.cpp @@ -24,32 +24,32 @@ void RsGxsUpdateBroadcastWidget::setUpdateWhenInvisible(bool update) mBase->setUpdateWhenInvisible(update); } -const std::list &RsGxsUpdateBroadcastWidget::getGrpIds() +const std::set &RsGxsUpdateBroadcastWidget::getGrpIds() { return mBase->getGrpIds(); } -const std::list &RsGxsUpdateBroadcastWidget::getGrpIdsMeta() +const std::set &RsGxsUpdateBroadcastWidget::getGrpIdsMeta() { return mBase->getGrpIdsMeta(); } -void RsGxsUpdateBroadcastWidget::getAllGrpIds(std::list &grpIds) +void RsGxsUpdateBroadcastWidget::getAllGrpIds(std::set &grpIds) { mBase->getAllGrpIds(grpIds); } -const std::map > &RsGxsUpdateBroadcastWidget::getMsgIds() +const std::map > &RsGxsUpdateBroadcastWidget::getMsgIds() { return mBase->getMsgIds(); } -const std::map > &RsGxsUpdateBroadcastWidget::getMsgIdsMeta() +const std::map > &RsGxsUpdateBroadcastWidget::getMsgIdsMeta() { return mBase->getMsgIdsMeta(); } -void RsGxsUpdateBroadcastWidget::getAllMsgIds(std::map > &msgIds) +void RsGxsUpdateBroadcastWidget::getAllMsgIds(std::map > &msgIds) { mBase->getAllMsgIds(msgIds); } From 418c42bd1108b79cf9ad297d3d096858a7f47733 Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Mon, 2 Jul 2018 13:50:02 +0200 Subject: [PATCH 44/50] Extra locators in cert invite made optional --- libretroshare/src/retroshare/rspeers.h | 23 +++++++++++++-- libretroshare/src/rsserver/p3peers.cc | 41 +++++++++++++++----------- libretroshare/src/rsserver/p3peers.h | 10 +++++-- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index 89131e8bf..7824daa11 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -386,11 +386,30 @@ public: virtual bool resetOwnExternalAddressList() = 0; virtual bool getAllowServerIPDetermination() = 0 ; + /** + * @brief Get RetroShare invite of the given peer + * @param[in] sslId Id of the peer of which we want to generate an invite + * @param[in] includeSignatures true to add key signatures to the invite + * @param[in] includeExtraLocators false to avoid to add extra locators + * @return invite string + */ + virtual std::string GetRetroshareInvite( + const RsPeerId& sslId, bool includeSignatures = false, + bool includeExtraLocators = true ) = 0; + + /** + * @brief Get RetroShare invite of our own peer + * @param[in] includeSignatures true to add key signatures to the invite + * @param[in] includeExtraLocators false to avoid to add extra locators + * @return invite string + */ + virtual std::string GetRetroshareInvite( + bool includeSignatures = false, + bool includeExtraLocators = true ) = 0; + /* Auth Stuff */ - virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures) = 0; virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) = 0; virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) = 0; - virtual std::string GetRetroshareInvite(bool include_signatures) = 0; virtual bool hasExportMinimal() = 0; // Add keys to the keyring diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 60d724179..36509c33b 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -1048,9 +1048,11 @@ bool p3Peers::setProxyServer(const uint32_t type, const std::string &addr_str, c //=========================================================================== /* Auth Stuff */ -std::string p3Peers::GetRetroshareInvite(bool include_signatures) +std::string p3Peers::GetRetroshareInvite( + bool include_signatures, bool includeExtraLocators ) { - return GetRetroshareInvite(getOwnId(),include_signatures); + return GetRetroshareInvite( + getOwnId(), include_signatures, includeExtraLocators ); } std::string p3Peers::getPGPKey(const RsPgpId& pgp_id,bool include_signatures) { @@ -1101,37 +1103,42 @@ bool p3Peers::GetPGPBase64StringAndCheckSum( const RsPgpId& gpg_id, return true ; } -std::string p3Peers::GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures) +std::string p3Peers::GetRetroshareInvite( + const RsPeerId& ssl_id, bool include_signatures, + bool includeExtraLocators ) { #ifdef P3PEERS_DEBUG - std::cerr << "p3Peers::GetRetroshareInvite()" << std::endl; + std::cerr << __PRETTY_FUNCTION__ << std::endl; #endif //add the sslid, location, ip local and external address after the signature - RsPeerDetails Detail; - std::string invite ; + RsPeerDetails detail; + std::string invite; - if (getPeerDetails(ssl_id, Detail)) + if (getPeerDetails(ssl_id, detail)) { - unsigned char *mem_block = NULL; + if(!includeExtraLocators) detail.ipAddressList.clear(); + + unsigned char *mem_block = nullptr; size_t mem_block_size = 0; - if(!AuthGPG::getAuthGPG()->exportPublicKey(RsPgpId(Detail.gpg_id),mem_block,mem_block_size,false,include_signatures)) + if(!AuthGPG::getAuthGPG()->exportPublicKey( + RsPgpId(detail.gpg_id), mem_block, mem_block_size, false, + include_signatures )) { - std::cerr << "Cannot output certificate for id \"" << Detail.gpg_id << "\". Sorry." << std::endl; - return "" ; + std::cerr << "Cannot output certificate for id \"" << detail.gpg_id + << "\". Sorry." << std::endl; + return ""; } - RsCertificate cert( Detail,mem_block,mem_block_size ) ; - - delete[] mem_block ; - - return cert.toStdString() ; + RsCertificate cert(detail, mem_block, mem_block_size); + delete[] mem_block; + return cert.toStdString(); } #ifdef P3PEERS_DEBUG - std::cerr << "p3Peers::GetRetroshareInvite() returns : \n" << invite << std::endl; + std::cerr << __PRETTY_FUNCTION__ << " returns : \n" << invite << std::endl; #endif return invite; } diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index 43d45f8a7..d2333c420 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -115,11 +115,15 @@ public: /* Auth Stuff */ // Get the invitation (GPG cert + local/ext address + SSL id for the given peer) - virtual std::string GetRetroshareInvite(const RsPeerId& ssl_id,bool include_signatures); - virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures) ; + virtual std::string GetRetroshareInvite( + const RsPeerId& ssl_id, bool include_signatures = false, + bool includeExtraLocators = true ); + virtual std::string getPGPKey(const RsPgpId& pgp_id,bool include_signatures); // same but for own id - virtual std::string GetRetroshareInvite(bool include_signatures); + virtual std::string GetRetroshareInvite( + bool include_signatures = false, + bool includeExtraLocators = true ); virtual bool GetPGPBase64StringAndCheckSum(const RsPgpId& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum); virtual bool hasExportMinimal(); From 4eb060e1545c14293c9169e770a6d0e97c6ec89d Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Mon, 2 Jul 2018 17:41:26 +0900 Subject: [PATCH 45/50] gui: do not attempt to create context menu if idlist is empty ...and other side effects --- .../src/gui/chat/ChatLobbyDialog.cpp | 79 +++++++++---------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index e490af1b8..1f7b20ac6 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -2,7 +2,7 @@ * * RetroShare is distributed under the following license: * - * Copyright (C) 2011, csoler + * Copyright (C) 2011, csoler * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -16,7 +16,7 @@ * * 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, + * Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * ****************************************************************/ @@ -87,7 +87,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi ui.participantsList->setColumnWidth(COLUMN_ICON, 1.7*S); ui.participantsList->setColumnHidden(COLUMN_ACTIVITY,true); ui.participantsList->setColumnHidden(COLUMN_ID,true); - + /* Set header resize modes and initial section sizes */ QHeaderView * header = ui.participantsList->header(); QHeaderView_setSectionResizeModeColumn(header, COLUMN_NAME, QHeaderView::Stretch); @@ -99,16 +99,16 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi distantChatAct = new QAction(QIcon(":/images/chat_24.png"), tr("Start private chat"), this); sendMessageAct = new QAction(QIcon(":/images/mail_new.png"), tr("Send Message"), this); showInPeopleAct = new QAction(QIcon(), tr("Show author in people tab"), this); - + QActionGroup *sortgrp = new QActionGroup(this); actionSortByName = new QAction(QIcon(), tr("Sort by Name"), this); actionSortByName->setCheckable(true); - actionSortByName->setChecked(true); + actionSortByName->setChecked(true); actionSortByName->setActionGroup(sortgrp); actionSortByActivity = new QAction(QIcon(), tr("Sort by Activity"), this); actionSortByActivity->setCheckable(true); - actionSortByActivity->setChecked(false); + actionSortByActivity->setChecked(false); actionSortByActivity->setActionGroup(sortgrp); @@ -122,7 +122,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi connect(actionSortByName, SIGNAL(triggered()), this, SLOT(sortParcipants())); connect(actionSortByActivity, SIGNAL(triggered()), this, SLOT(sortParcipants())); - + /* Add filter actions */ QTreeWidgetItem *headerItem = ui.participantsList->headerItem(); QString headerText = headerItem->text(COLUMN_NAME ); @@ -163,7 +163,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi } ownIdChooser = new GxsIdChooser() ; ownIdChooser->loadIds(idChooserFlag, current_id) ; - + QWidgetAction *checkableAction = new QWidgetAction(this); checkableAction->setDefaultWidget(ownIdChooser); @@ -246,8 +246,8 @@ void ChatLobbyDialog::participantsTreeWidgetCustomPopupMenu(QPoint) void ChatLobbyDialog::textBrowserAskContextMenu(QMenu* contextMnu, QString anchorForPosition, const QPoint /*point*/) { - if (anchorForPosition.startsWith(PERSONID)){ - QString strId = anchorForPosition.replace(PERSONID,""); + if (anchorForPosition.startsWith(PERSONID)) { + QString strId = anchorForPosition.replace(PERSONID, ""); if (strId.contains(" ")) strId.truncate(strId.indexOf(" ")); @@ -263,6 +263,8 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QListaddAction(distantChatAct); contextMnu->addAction(sendMessageAct); @@ -281,7 +283,7 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QListsetEnabled(false); voteNeutralAct->setEnabled(false); voteNegativeAct->setEnabled(false); - showInPeopleAct->setEnabled(idList.count()==1); + showInPeopleAct->setEnabled(idList.count() == 1); distantChatAct->setData(QVariant::fromValue(idList)); sendMessageAct->setData(QVariant::fromValue(idList)); @@ -291,19 +293,16 @@ void ChatLobbyDialog::initParticipantsContextMenu(QMenu *contextMnu, QListsetData(QVariant::fromValue(idList)); showInPeopleAct->setData(QVariant::fromValue(idList)); - if(idList.count()==1) - { - RsGxsId gxsid = idList.at(0); + RsGxsId gxsid = idList.at(0); - if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid)) - { - distantChatAct->setEnabled(true); - votePositiveAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_POSITIVE); - voteNeutralAct->setEnabled((rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_POSITIVE) || (rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) ); - voteNegativeAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_NEGATIVE); - muteAct->setEnabled(true); - muteAct->setChecked(isParticipantMuted(gxsid)); - } + if(!gxsid.isNull() && !rsIdentity->isOwnId(gxsid)) + { + distantChatAct->setEnabled(true); + votePositiveAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_POSITIVE); + voteNeutralAct->setEnabled((rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_POSITIVE) || (rsReputations->overallReputationLevel(gxsid) == RsReputations::REPUTATION_LOCALLY_NEGATIVE) ); + voteNegativeAct->setEnabled(rsReputations->overallReputationLevel(gxsid) != RsReputations::REPUTATION_LOCALLY_NEGATIVE); + muteAct->setEnabled(true); + muteAct->setChecked(isParticipantMuted(gxsid)); } } @@ -443,17 +442,17 @@ void ChatLobbyDialog::processSettings(bool load) // state of splitter ui.splitter->restoreState(Settings->value("splitter").toByteArray()); - + // load sorting actionSortByActivity->setChecked(Settings->value("sortbyActivity", QVariant(false)).toBool()); actionSortByName->setChecked(Settings->value("sortbyName", QVariant(true)).toBool()); - + } else { // save settings // state of splitter Settings->setValue("splitter", ui.splitter->saveState()); - + //save sorting Settings->setValue("sortbyActivity", actionSortByActivity->isChecked()); Settings->setValue("sortbyName", actionSortByName->isChecked()); @@ -464,7 +463,7 @@ void ChatLobbyDialog::processSettings(bool load) /** * Change your Nickname - * + * * - send a Message to all Members => later: send hidden message to clients, so they can actualize there mutedParticipants list */ void ChatLobbyDialog::setIdentity(const RsGxsId& gxs_id) @@ -500,7 +499,7 @@ void ChatLobbyDialog::changeNickname() /** * We get a new Message from a chat participant - * + * * - Ignore Messages from muted chat participants */ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) @@ -509,7 +508,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) QDateTime recvTime = QDateTime::fromTime_t(msg.recvTime); QString message = QString::fromUtf8(msg.msg.c_str()); RsGxsId gxs_id = msg.lobby_peer_gxs_id ; - + if(!isParticipantMuted(gxs_id)) { // We could change addChatMsg to display the peers icon, passing a ChatId @@ -551,7 +550,7 @@ void ChatLobbyDialog::addChatMsg(const ChatMessage& msg) /** * Regenerate the QTreeWidget participant list of a Chat Lobby - * + * * Show yellow icon for muted Participants */ void ChatLobbyDialog::updateParticipantsList() @@ -602,7 +601,7 @@ void ChatLobbyDialog::updateParticipantsList() time_t tLastAct=widgetitem->text(COLUMN_ACTIVITY).toInt(); time_t now = time(NULL); - + widgetitem->setSizeHint(COLUMN_ICON, QSize(20,20)); @@ -619,7 +618,7 @@ void ChatLobbyDialog::updateParticipantsList() if (RsGxsId(participant.toStdString()) == gxs_id) widgetitem->setIcon(COLUMN_ICON, bullet_yellow_128); widgetitem->updateBannedState(); - + QTime qtLastAct=QTime(0,0,0).addSecs(now-tLastAct); widgetitem->setToolTip(COLUMN_ICON,tr("Right click to mute/unmute participants
Double click to address this person
") +tr("This participant is not active since:") @@ -635,7 +634,7 @@ void ChatLobbyDialog::updateParticipantsList() /** * Called when a Participant get Clicked / Changed - * + * * Check if the Checkbox altered and Mute User */ void ChatLobbyDialog::changeParticipationState() @@ -787,15 +786,15 @@ bool ChatLobbyDialog::isNicknameInLobby(const RsGxsId& nickname) return clinfo.gxs_ids.find(nickname) != clinfo.gxs_ids.end() ; } -/** +/** * Should Messages from this Nickname be muted? - * + * * At the moment it is not possible to 100% know which peer sendet the message, and only - * the nickname is available. So this couldn't work for 100%. So, for example, if a peer - * change his name to the name of a other peer, we couldn't block him. A real implementation + * the nickname is available. So this couldn't work for 100%. So, for example, if a peer + * change his name to the name of a other peer, we couldn't block him. A real implementation * will be possible if we transfer a temporary Session ID from the sending Retroshare client * version 0.6 - * + * * @param QString nickname to check */ bool ChatLobbyDialog::isParticipantMuted(const RsGxsId& participant) @@ -901,7 +900,7 @@ bool ChatLobbyDialog::canClose() void ChatLobbyDialog::showDialog(uint chatflags) { - if (chatflags & RS_CHAT_FOCUS) + if (chatflags & RS_CHAT_FOCUS) { MainWindow::showWindow(MainWindow::ChatLobby); dynamic_cast(MainWindow::getPage(MainWindow::ChatLobby))->setCurrentChatPage(this) ; @@ -916,7 +915,7 @@ void ChatLobbyDialog::sortParcipants() } else if (actionSortByName->isChecked()) { ui.participantsList->sortItems(COLUMN_NAME, Qt::AscendingOrder); } - + } void ChatLobbyDialog::filterChanged(const QString& /*text*/) From 5925aa06fed41e770630811dd4d5d021882b7ae7 Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Mon, 2 Jul 2018 21:22:22 +0900 Subject: [PATCH 46/50] gui: anchor not only first word of nickname, if any --- .../src/gui/common/RSTextBrowser.cpp | 55 +++++++++++++++---- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/common/RSTextBrowser.cpp b/retroshare-gui/src/gui/common/RSTextBrowser.cpp index 03fbfe3de..8c59c815c 100644 --- a/retroshare-gui/src/gui/common/RSTextBrowser.cpp +++ b/retroshare-gui/src/gui/common/RSTextBrowser.cpp @@ -251,22 +251,53 @@ bool RSTextBrowser::checkImage(QPoint pos, QString &imageStr) */ QString RSTextBrowser::anchorForPosition(const QPoint &pos) const { + // Many calls when time label shows up QTextCursor cursor = cursorForPosition(pos); cursor.select(QTextCursor::WordUnderCursor); + QString word = cursor.selectedText(); QString anchor = ""; - if (!cursor.selectedText().isEmpty()){ - QRegExp rx(" Date: Wed, 4 Jul 2018 00:19:36 +0900 Subject: [PATCH 47/50] gui: disable quote option if no text is selected in chat --- retroshare-gui/src/gui/chat/ChatWidget.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 3ed194789..48e4b63a6 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -1096,6 +1096,10 @@ void ChatWidget::contextMenuTextBrowser(QPoint point) contextMnu->addSeparator(); contextMnu->addAction(ui->actionClearChatHistory); contextMnu->addAction(ui->actionQuote); + if (ui->textBrowser->textCursor().selection().toPlainText().length() == 0) + ui->actionQuote->setEnabled(false); + else + ui->actionQuote->setEnabled(true); contextMnu->addAction(ui->actionDropPlacemark); if(ui->textBrowser->checkImage(point)) From 77c3eae976f9733906729b48c7dade17b617c7ca Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Wed, 4 Jul 2018 00:34:45 +0900 Subject: [PATCH 48/50] gui: check for show "is typing" before time call --- retroshare-gui/src/gui/chat/ChatWidget.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 48e4b63a6..674204d16 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -110,7 +110,7 @@ ChatWidget::ChatWidget(QWidget *parent) : ui->searchButton->setIconSize(iconSize); ui->sendButton->setFixedHeight(iconHeight); ui->sendButton->setIconSize(iconSize); - + //Initialize search iCharToStartSearch=Settings->getChatSearchCharToStartSearch(); bFindCaseSensitively=Settings->getChatSearchCaseSensitively(); @@ -177,7 +177,7 @@ ChatWidget::ChatWidget(QWidget *parent) : ui->infoFrame->setVisible(false); ui->statusMessageLabel->hide(); - + setAcceptDrops(true); ui->chatTextEdit->setAcceptDrops(false); ui->hashBox->setDropWidget(this); @@ -197,7 +197,7 @@ ChatWidget::ChatWidget(QWidget *parent) : menu->addAction(ui->actionMessageHistory); ui->pushtoolsButton->setMenu(menu); menu->addMenu(fontmenu); - + ui->actionSendAsPlainText->setChecked(Settings->getChatSendAsPlainTextByDef()); ui->chatTextEdit->setOnlyPlainText(ui->actionSendAsPlainText->isChecked()); connect(ui->actionSendAsPlainText, SIGNAL(toggled(bool)), ui->chatTextEdit, SLOT(setOnlyPlainText(bool)) ); @@ -357,12 +357,12 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title) ui->titleBarFrame->setVisible(false); } - if (rsHistory->getEnable(hist_chat_type)) + if (rsHistory->getEnable(hist_chat_type)) { // get chat messages from history std::list historyMsgs; - if (messageCount > 0) + if (messageCount > 0) { rsHistory->getMessages(chatId, historyMsgs, messageCount); @@ -376,7 +376,7 @@ void ChatWidget::init(const ChatId &chat_id, const QString &title) continue; QString name; - if (chatId.isLobbyId() || chatId.isDistantChatId()) + if (chatId.isLobbyId() || chatId.isDistantChatId()) { RsIdentityDetails details; if (rsIdentity->getIdDetails(RsGxsId(historyIt->peerName), details)) @@ -962,7 +962,7 @@ void ChatWidget::addChatMsg(bool incoming, const QString &name, const RsGxsId gx unsigned int formatFlag = 0; bool addDate = false; - if (QDate::currentDate()>lastMsgDate) + if (QDate::currentDate()>lastMsgDate) { addDate=true; } @@ -1165,13 +1165,14 @@ void ChatWidget::resetStatusBar() void ChatWidget::updateStatusTyping() { + if(Settings->getChatDoNotSendIsTyping()) + return; if (time(NULL) - lastStatusSendTime > 5) // limit 'peer is typing' packets to at most every 10 sec { #ifdef ONLY_FOR_LINGUIST tr("is typing..."); #endif - if(!Settings->getChatDoNotSendIsTyping()) - rsMsgs->sendStatusString(chatId, "is typing..."); + rsMsgs->sendStatusString(chatId, "is typing..."); lastStatusSendTime = time(NULL) ; } } @@ -1677,7 +1678,7 @@ void ChatWidget::updateStatus(const QString &peer_id, int status) vpid = chatId.toPeerId(); /* set font size for status */ - if (peer_id.toStdString() == vpid.toStdString()) + if (peer_id.toStdString() == vpid.toStdString()) { // the peers status has changed From b3fb7abf9925634b7f565668f0eeeef32625937a Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Wed, 4 Jul 2018 22:46:01 +0900 Subject: [PATCH 49/50] gui: reduce size of icons in chat for font.height lesser than 26 --- .../src/gui/chat/ChatLobbyDialog.cpp | 24 +++++++++++-------- retroshare-gui/src/gui/chat/ChatWidget.cpp | 20 +++++++++++----- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp index 1f7b20ac6..35a6f0f54 100644 --- a/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp +++ b/retroshare-gui/src/gui/chat/ChatLobbyDialog.cpp @@ -80,7 +80,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi connect(ui.filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterChanged(QString))); - int S = QFontMetricsF(font()).height() ; + int S = QFontMetricsF(font()).height() ; ui.participantsList->setIconSize(QSize(1.4*S,1.4*S)); ui.participantsList->setColumnCount(COLUMN_COUNT); @@ -128,23 +128,27 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi QString headerText = headerItem->text(COLUMN_NAME ); ui.filterLineEdit->addFilter(QIcon(), headerText, COLUMN_NAME , QString("%1 %2").arg(tr("Search"), headerText)); + // just empiric values + double scaler_factor = S > 25 ? 2.4 : 1.8; + QSize icon_size(scaler_factor * S, scaler_factor * S); + // Add a button to invite friends. // inviteFriendsButton = new QToolButton ; - inviteFriendsButton->setMinimumSize(QSize(2.4*S,2.4*S)) ; - inviteFriendsButton->setMaximumSize(QSize(2.4*S,2.4*S)) ; + inviteFriendsButton->setMinimumSize(icon_size); + inviteFriendsButton->setMaximumSize(icon_size); inviteFriendsButton->setText(QString()) ; inviteFriendsButton->setAutoRaise(true) ; inviteFriendsButton->setToolTip(tr("Invite friends to this lobby")); - mParticipantCompareRole = new RSTreeWidgetItemCompareRole; - mParticipantCompareRole->setRole(COLUMN_ACTIVITY, ROLE_SORT); + mParticipantCompareRole = new RSTreeWidgetItemCompareRole; + mParticipantCompareRole->setRole(COLUMN_ACTIVITY, ROLE_SORT); { QIcon icon ; icon.addPixmap(QPixmap(":/icons/png/invite.png")) ; inviteFriendsButton->setIcon(icon) ; - inviteFriendsButton->setIconSize(QSize(2.4*S,2.4*S)) ; + inviteFriendsButton->setIconSize(icon_size); } connect(inviteFriendsButton, SIGNAL(clicked()), this , SLOT(inviteFriends())); @@ -175,9 +179,9 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi connect(ownIdChooser,SIGNAL(currentIndexChanged(int)),this,SLOT(changeNickname())) ; - unsubscribeButton = new QToolButton ; - unsubscribeButton->setMinimumSize(QSize(2.4*S,2.4*S)) ; - unsubscribeButton->setMaximumSize(QSize(2.4*S,2.4*S)) ; + unsubscribeButton = new QToolButton; + unsubscribeButton->setMinimumSize(icon_size); + unsubscribeButton->setMaximumSize(icon_size); unsubscribeButton->setText(QString()) ; unsubscribeButton->setAutoRaise(true) ; unsubscribeButton->setToolTip(tr("Leave this chat room (Unsubscribe)")); @@ -186,7 +190,7 @@ ChatLobbyDialog::ChatLobbyDialog(const ChatLobbyId& lid, QWidget *parent, Qt::Wi QIcon icon ; icon.addPixmap(QPixmap(":/icons/png/leave.png")) ; unsubscribeButton->setIcon(icon) ; - unsubscribeButton->setIconSize(QSize(2.4*S,2.4*S)) ; + unsubscribeButton->setIconSize(icon_size); } /* Initialize splitter */ diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 674204d16..016d87d49 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -65,6 +65,8 @@ #include #define FMM 2.5//fontMetricsMultiplicator +#define FMM_SMALLER 1.8 +#define FMM_THRESHOLD 25 /***** * #define CHAT_DEBUG 1 @@ -75,9 +77,12 @@ ChatWidget::ChatWidget(QWidget *parent) : { ui->setupUi(this); - int iconHeight = FMM*QFontMetricsF(font()).height() ; - QSize iconSize = QSize(iconHeight,iconHeight); - QSize buttonSize = QSize(iconSize + QSize((int)FMM,(int)FMM)); + int iconHeight = QFontMetricsF(font()).height(); + double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER; + iconHeight *= fmm; + QSize iconSize = QSize(iconHeight, iconHeight); + int butt_size(iconSize.height() + fmm); + QSize buttonSize = QSize(butt_size, butt_size); newMessages = false; typing = false; @@ -259,9 +264,12 @@ void ChatWidget::addChatHorizontalWidget(QWidget *w) void ChatWidget::addChatBarWidget(QWidget *w) { - int iconHeight = FMM*QFontMetricsF(font()).height() ; - QSize iconSize = QSize(iconHeight,iconHeight); - QSize buttonSize = QSize(iconSize + QSize((int)FMM,(int)FMM)); + int iconHeight = QFontMetricsF(font()).height(); + double fmm = iconHeight > FMM_THRESHOLD ? FMM : FMM_SMALLER; + iconHeight *= fmm; + QSize iconSize = QSize(iconHeight, iconHeight); + int butt_size(iconSize.height() + fmm); + QSize buttonSize = QSize(butt_size, butt_size); w->setFixedSize(buttonSize); ui->pluginButtonFrame->layout()->addWidget(w) ; } From 74075fddedc70e6fe3c83be72ca22df82afded69 Mon Sep 17 00:00:00 2001 From: chelovechishko Date: Wed, 4 Jul 2018 23:18:21 +0900 Subject: [PATCH 50/50] gui: do not show the quote section of context menu in chat if no text selected --- retroshare-gui/src/gui/chat/ChatWidget.cpp | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index 016d87d49..f35c0425d 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -1103,11 +1103,8 @@ void ChatWidget::contextMenuTextBrowser(QPoint point) contextMnu->addSeparator(); contextMnu->addAction(ui->actionClearChatHistory); - contextMnu->addAction(ui->actionQuote); - if (ui->textBrowser->textCursor().selection().toPlainText().length() == 0) - ui->actionQuote->setEnabled(false); - else - ui->actionQuote->setEnabled(true); + if (ui->textBrowser->textCursor().selection().toPlainText().length()) + contextMnu->addAction(ui->actionQuote); contextMnu->addAction(ui->actionDropPlacemark); if(ui->textBrowser->checkImage(point)) @@ -1829,13 +1826,10 @@ bool ChatWidget::setStyle() void ChatWidget::quote() { QString text = ui->textBrowser->textCursor().selection().toPlainText(); - if(text.length() > 0) - { - QStringList sl = text.split(QRegExp("[\r\n]"),QString::SkipEmptyParts); - text = sl.join("\n> "); - text.replace(QChar(-4)," ");//Char used when image on text. - emit ui->chatTextEdit->append(QString("> ") + text); - } + QStringList sl = text.split(QRegExp("[\r\n]"), QString::SkipEmptyParts); + text = sl.join("\n> "); + text.replace(QChar(-4), " "); // Char used when image on text. + emit ui->chatTextEdit->append(QString("> ") + text); } void ChatWidget::dropPlacemark()