Merge pull request #19 from RetroShare/master

update to master
This commit is contained in:
defnax 2019-10-06 23:28:44 +02:00 committed by GitHub
commit 05b0a4703f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 41 additions and 45 deletions

View File

@ -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.

View File

@ -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<RsPeerId>& 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<RsPgpId>& 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<RsPgpId> &gpg_ids) = 0;
virtual bool getGPGSignedList(std::list<RsPgpId> &gpg_ids) = 0;// keys signed by our own PGP key.
virtual bool getGPGValidList(std::list<RsPgpId> &gpg_ids) = 0;// all PGP keys without filtering
@ -706,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
@ -740,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;
@ -847,4 +853,6 @@ public:
RS_DEPRECATED_FOR(isPgpFriend)
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend) = 0;
virtual ~RsPeers();
};

View File

@ -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)
@ -647,6 +635,18 @@ bool p3Peers::getGPGSignedList(std::list<RsPgpId> &ids)
return true;
}
bool p3Peers::getPgpFriendList(std::vector<RsPgpId>& pgpIds)
{
std::list<RsPgpId> 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<RsPgpId> &ids)
{
#ifdef P3PEERS_DEBUG
@ -1665,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
@ -1873,3 +1857,5 @@ void p3Peers::setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermi
RsPeerStateChangedEvent::RsPeerStateChangedEvent(RsPeerId sslId) :
RsEvent(RsEventType::PEER_STATE_CHANGED), mSslId(sslId) {}
RsPeers::~RsPeers() = default;

View File

@ -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<RsPgpId>& pgpIds) override;
RS_DEPRECATED_FOR(getPgpFriendList)
virtual bool getGPGAcceptedList(std::list<RsPgpId> &ids);
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
@ -154,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);

View File

@ -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;

View File

@ -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<QRgb> &palette)
{
int bits = 4; // bits/pixel
int bits = 8; // bits/pixel
int samplesize = 100000; //only take this many color samples
rstime::RsScopeTimer st("Quantization");