From 9a884b7bf77471c324bb27ea9e57ea224e1b42b4 Mon Sep 17 00:00:00 2001 From: hunbernd Date: Fri, 5 Jul 2019 13:41:30 +0200 Subject: [PATCH 1/4] Rise max public chat message size to 31000 bytes Rise color palette size from 16 to 256 colors Note: Max chat item size is 32000 without splitting the message. 31000 = 32000 - some place left for other fields --- libretroshare/src/chat/p3chatservice.cc | 2 +- retroshare-gui/src/util/imageutil.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libretroshare/src/chat/p3chatservice.cc b/libretroshare/src/chat/p3chatservice.cc index 482120940..e446bfdef 100644 --- a/libretroshare/src/chat/p3chatservice.cc +++ b/libretroshare/src/chat/p3chatservice.cc @@ -47,7 +47,7 @@ * #define CHAT_DEBUG 1 ****/ -static const uint32_t MAX_MESSAGE_SECURITY_SIZE = 6000 ; // Max message size to forward other friends +static const uint32_t MAX_MESSAGE_SECURITY_SIZE = 31000 ; // Max message size to forward other friends static const uint32_t MAX_AVATAR_JPEG_SIZE = 32767; // Maximum size in bytes for an avatar. Too large packets // don't transfer correctly and can kill the system. // Images are 96x96, which makes approx. 27000 bytes uncompressed. diff --git a/retroshare-gui/src/util/imageutil.cpp b/retroshare-gui/src/util/imageutil.cpp index cefa22906..648fe392c 100644 --- a/retroshare-gui/src/util/imageutil.cpp +++ b/retroshare-gui/src/util/imageutil.cpp @@ -99,9 +99,9 @@ bool ImageUtil::optimizeSize(QString &html, const QImage& original, QImage &opti } //Use binary search to find a suitable image size + linear regression to guess the file size - double maxsize = (double)checkSize(html, optimized = original.scaledToWidth(maxwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct), maxBytes); + double maxsize = (double)checkSize(html, optimized = original.scaledToWidth(maxwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct, Qt::ThresholdDither), maxBytes); if(maxsize <= maxBytes) return true; //success - double minsize = (double)checkSize(html, optimized = original.scaledToWidth(minwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct), maxBytes); + double minsize = (double)checkSize(html, optimized = original.scaledToWidth(minwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct, Qt::ThresholdDither), maxBytes); if(minsize > maxBytes) return false; //impossible // std::cout << "maxS: " << maxsize << " minS: " << minsize << std::endl; @@ -114,7 +114,7 @@ bool ImageUtil::optimizeSize(QString &html, const QImage& original, QImage &opti double b = maxsize - m * ((double)maxwidth * (double)maxwidth / whratio); double a = ((double)(maxBytes - region/2) - b) / m; //maxBytes - region/2 target the center of the accepted region int nextwidth = (int)sqrt(a * whratio); - int nextsize = checkSize(html, optimized = original.scaledToWidth(nextwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct), maxBytes); + int nextsize = checkSize(html, optimized = original.scaledToWidth(nextwidth, Qt::SmoothTransformation).convertToFormat(QImage::Format_Indexed8, ct, Qt::ThresholdDither), maxBytes); if(nextsize <= maxBytes) { minsize = nextsize; minwidth = nextwidth; @@ -188,7 +188,7 @@ bool blueLessThan(const QRgb &c1, const QRgb &c2) //median cut algoritmh void ImageUtil::quantization(const QImage &img, QVector &palette) { - int bits = 4; // bits/pixel + int bits = 8; // bits/pixel int samplesize = 100000; //only take this many color samples rstime::RsScopeTimer st("Quantization"); From 398c943f4090b6d6f95611f04f944fcb7e0acd81 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 6 Oct 2019 00:12:28 +0200 Subject: [PATCH 2/4] fixed bug causing crash when forum being displayed is deleted --- retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp index 38495f204..c032e87ad 100644 --- a/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp +++ b/retroshare-gui/src/gui/gxsforums/GxsForumModel.cpp @@ -744,7 +744,7 @@ void RsGxsForumModel::update_posts(const RsGxsGroupId& group_id) forumIds.push_back(group_id); - if(!rsGxsForums->getForumsInfo(forumIds,groups)) + if(!rsGxsForums->getForumsInfo(forumIds,groups) || groups.size() != 1) { std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve forum group info for forum " << group_id << std::endl; return; From 89819dd945c1ba1cce9c59e619a429a85401948e Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sun, 6 Oct 2019 23:03:14 +0200 Subject: [PATCH 3/4] Add JSON API to list PGP friends --- libretroshare/src/retroshare/rspeers.h | 16 ++++++++++++---- libretroshare/src/rsserver/p3peers.cc | 14 ++++++++++++++ libretroshare/src/rsserver/p3peers.h | 5 +++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index b4b0a64d0..9d04968a0 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -396,10 +396,6 @@ struct RsPeerStateChangedEvent : RsEvent class RsPeers { public: - - RsPeers() {} - virtual ~RsPeers() {} - /** * @brief Get own SSL peer id * @return own peer id @@ -416,6 +412,14 @@ public: */ virtual bool getFriendList(std::list& sslIds) = 0; + /** + * @brief Get trusted PGP ids list + * @jsonapi{development} + * @param[out] pgpIds storage for the trusted PGP ids + * @return false if error occurred, true otherwise + */ + virtual bool getPgpFriendList(std::vector& pgpIds) = 0; + /** * @brief Get connected peers list * @jsonapi{development} @@ -498,6 +502,8 @@ public: */ virtual RsPgpId getGPGId(const RsPeerId& sslId) = 0; virtual bool isKeySupported(const RsPgpId& gpg_ids) = 0; + + RS_DEPRECATED_FOR(getPgpFriendList) virtual bool getGPGAcceptedList(std::list &gpg_ids) = 0; virtual bool getGPGSignedList(std::list &gpg_ids) = 0;// keys signed by our own PGP key. virtual bool getGPGValidList(std::list &gpg_ids) = 0;// all PGP keys without filtering @@ -847,4 +853,6 @@ public: RS_DEPRECATED_FOR(isPgpFriend) virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend) = 0; + + virtual ~RsPeers(); }; diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 1924b69dd..1e74a5eb9 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -647,6 +647,18 @@ bool p3Peers::getGPGSignedList(std::list &ids) return true; } +bool p3Peers::getPgpFriendList(std::vector& pgpIds) +{ + std::list ids; + if(AuthGPG::getAuthGPG()->getGPGAcceptedList(ids)) + { + pgpIds.clear(); + std::copy(ids.begin(), ids.end(), std::back_inserter(pgpIds)); + return true; + } + return false; +} + bool p3Peers::getGPGAcceptedList(std::list &ids) { #ifdef P3PEERS_DEBUG @@ -1873,3 +1885,5 @@ void p3Peers::setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermi RsPeerStateChangedEvent::RsPeerStateChangedEvent(RsPeerId sslId) : RsEvent(RsEventType::PEER_STATE_CHANGED), mSslId(sslId) {} + +RsPeers::~RsPeers() = default; diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index e44e7d23a..a814aec34 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -83,6 +83,11 @@ public: virtual const RsPgpId& getGPGOwnId(); virtual RsPgpId getGPGId(const RsPeerId &ssl_id); virtual bool isKeySupported(const RsPgpId& ids); + + /// @see RsPeers + bool getPgpFriendList(std::vector& pgpIds) override; + + RS_DEPRECATED_FOR(getPgpFriendList) virtual bool getGPGAcceptedList(std::list &ids); virtual bool getGPGSignedList(std::list &ids); virtual bool getGPGValidList(std::list &ids); From ab93d31d17a2939887a7eb411a28d5d47a53731a Mon Sep 17 00:00:00 2001 From: Gioacchino Mazzurco Date: Sun, 6 Oct 2019 23:20:18 +0200 Subject: [PATCH 4/4] Remove some RsPeers related dead code --- libretroshare/src/retroshare/rspeers.h | 6 +++--- libretroshare/src/rsserver/p3peers.cc | 30 +------------------------- libretroshare/src/rsserver/p3peers.h | 3 --- 3 files changed, 4 insertions(+), 35 deletions(-) diff --git a/libretroshare/src/retroshare/rspeers.h b/libretroshare/src/retroshare/rspeers.h index 9d04968a0..bc1254658 100644 --- a/libretroshare/src/retroshare/rspeers.h +++ b/libretroshare/src/retroshare/rspeers.h @@ -712,7 +712,6 @@ public: /* Auth Stuff */ 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 bool hasExportMinimal() = 0; /** * @brief Import certificate into the keyring @@ -746,8 +745,9 @@ public: std::string& error_string )=0; // Certificate utils - virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,bool& is_short_format,uint32_t& error_code) = 0; - virtual bool saveCertificateToFile(const RsPeerId& id, const std::string &fname) = 0; + virtual bool cleanCertificate( + const std::string& certstr, std::string& cleanCert, + bool& is_short_format, uint32_t& error_code ) = 0; virtual std::string saveCertificateToString(const RsPeerId &id) = 0; virtual bool signGPGCertificate(const RsPgpId &gpg_id) = 0; diff --git a/libretroshare/src/rsserver/p3peers.cc b/libretroshare/src/rsserver/p3peers.cc index 1e74a5eb9..0ea163f35 100644 --- a/libretroshare/src/rsserver/p3peers.cc +++ b/libretroshare/src/rsserver/p3peers.cc @@ -115,19 +115,7 @@ std::string RsPeerNetModeString(uint32_t netModel) p3Peers::p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm) - :mLinkMgr(lm), mPeerMgr(pm), mNetMgr(nm) -{ - return; -} - -bool p3Peers::hasExportMinimal() -{ -#ifdef GPGME_EXPORT_MODE_MINIMAL - return true ; -#else - return false ; -#endif -} + :mLinkMgr(lm), mPeerMgr(pm), mNetMgr(nm) {} /* Updates ... */ bool p3Peers::FriendsChanged(bool add) @@ -1677,22 +1665,6 @@ bool p3Peers::cleanCertificate(const std::string &certstr, std::string &cleanCer return res; } -bool p3Peers::saveCertificateToFile(const RsPeerId &id, const std::string &/*fname*/) -{ - /* remove unused parameter warnings */ - (void) id; - -#ifdef P3PEERS_DEBUG - std::cerr << "p3Peers::SaveCertificateToFile() not implemented yet " << id; - std::cerr << std::endl; -#endif - -// ensureExtension(fname, "pqi"); -// -// return AuthSSL::getAuthSSL()->SaveCertificateToFile(id, fname); - return false; -} - std::string p3Peers::saveCertificateToString(const RsPeerId &id) { #ifdef P3PEERS_DEBUG diff --git a/libretroshare/src/rsserver/p3peers.h b/libretroshare/src/rsserver/p3peers.h index a814aec34..86e878192 100644 --- a/libretroshare/src/rsserver/p3peers.h +++ b/libretroshare/src/rsserver/p3peers.h @@ -159,14 +159,11 @@ public: const std::string& invite, ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT ); - virtual bool hasExportMinimal(); - virtual bool loadCertificateFromString(const std::string& cert, RsPeerId& ssl_id,RsPgpId& pgp_id, std::string& error_string); virtual bool loadPgpKeyFromBinaryData( const unsigned char *bin_key_data,uint32_t bin_key_len, RsPgpId& gpg_id, std::string& error_string ); virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, uint32_t& error_code); virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert, bool &is_short_format, uint32_t& error_code) override; - virtual bool saveCertificateToFile(const RsPeerId &id, const std::string &fname); virtual std::string saveCertificateToString(const RsPeerId &id); virtual bool signGPGCertificate(const RsPgpId &id);