mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-06 05:14:21 -04:00
commit
05b0a4703f
6 changed files with 41 additions and 45 deletions
|
@ -47,7 +47,7 @@
|
||||||
* #define CHAT_DEBUG 1
|
* #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
|
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.
|
// don't transfer correctly and can kill the system.
|
||||||
// Images are 96x96, which makes approx. 27000 bytes uncompressed.
|
// Images are 96x96, which makes approx. 27000 bytes uncompressed.
|
||||||
|
|
|
@ -396,10 +396,6 @@ struct RsPeerStateChangedEvent : RsEvent
|
||||||
class RsPeers
|
class RsPeers
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
RsPeers() {}
|
|
||||||
virtual ~RsPeers() {}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get own SSL peer id
|
* @brief Get own SSL peer id
|
||||||
* @return own peer id
|
* @return own peer id
|
||||||
|
@ -416,6 +412,14 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool getFriendList(std::list<RsPeerId>& sslIds) = 0;
|
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
|
* @brief Get connected peers list
|
||||||
* @jsonapi{development}
|
* @jsonapi{development}
|
||||||
|
@ -498,6 +502,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual RsPgpId getGPGId(const RsPeerId& sslId) = 0;
|
virtual RsPgpId getGPGId(const RsPeerId& sslId) = 0;
|
||||||
virtual bool isKeySupported(const RsPgpId& gpg_ids) = 0;
|
virtual bool isKeySupported(const RsPgpId& gpg_ids) = 0;
|
||||||
|
|
||||||
|
RS_DEPRECATED_FOR(getPgpFriendList)
|
||||||
virtual bool getGPGAcceptedList(std::list<RsPgpId> &gpg_ids) = 0;
|
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 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
|
virtual bool getGPGValidList(std::list<RsPgpId> &gpg_ids) = 0;// all PGP keys without filtering
|
||||||
|
@ -706,7 +712,6 @@ public:
|
||||||
/* Auth Stuff */
|
/* Auth Stuff */
|
||||||
virtual std::string getPGPKey(const RsPgpId& pgp_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 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
|
* @brief Import certificate into the keyring
|
||||||
|
@ -740,8 +745,9 @@ public:
|
||||||
std::string& error_string )=0;
|
std::string& error_string )=0;
|
||||||
|
|
||||||
// Certificate utils
|
// Certificate utils
|
||||||
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert,bool& is_short_format,uint32_t& error_code) = 0;
|
virtual bool cleanCertificate(
|
||||||
virtual bool saveCertificateToFile(const RsPeerId& id, const std::string &fname) = 0;
|
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 std::string saveCertificateToString(const RsPeerId &id) = 0;
|
||||||
|
|
||||||
virtual bool signGPGCertificate(const RsPgpId &gpg_id) = 0;
|
virtual bool signGPGCertificate(const RsPgpId &gpg_id) = 0;
|
||||||
|
@ -847,4 +853,6 @@ public:
|
||||||
|
|
||||||
RS_DEPRECATED_FOR(isPgpFriend)
|
RS_DEPRECATED_FOR(isPgpFriend)
|
||||||
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend) = 0;
|
virtual bool isGPGAccepted(const RsPgpId &gpg_id_is_friend) = 0;
|
||||||
|
|
||||||
|
virtual ~RsPeers();
|
||||||
};
|
};
|
||||||
|
|
|
@ -115,19 +115,7 @@ std::string RsPeerNetModeString(uint32_t netModel)
|
||||||
|
|
||||||
|
|
||||||
p3Peers::p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm)
|
p3Peers::p3Peers(p3LinkMgr *lm, p3PeerMgr *pm, p3NetMgr *nm)
|
||||||
:mLinkMgr(lm), mPeerMgr(pm), mNetMgr(nm)
|
:mLinkMgr(lm), mPeerMgr(pm), mNetMgr(nm) {}
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool p3Peers::hasExportMinimal()
|
|
||||||
{
|
|
||||||
#ifdef GPGME_EXPORT_MODE_MINIMAL
|
|
||||||
return true ;
|
|
||||||
#else
|
|
||||||
return false ;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Updates ... */
|
/* Updates ... */
|
||||||
bool p3Peers::FriendsChanged(bool add)
|
bool p3Peers::FriendsChanged(bool add)
|
||||||
|
@ -647,6 +635,18 @@ bool p3Peers::getGPGSignedList(std::list<RsPgpId> &ids)
|
||||||
return true;
|
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)
|
bool p3Peers::getGPGAcceptedList(std::list<RsPgpId> &ids)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
|
@ -1665,22 +1665,6 @@ bool p3Peers::cleanCertificate(const std::string &certstr, std::string &cleanCer
|
||||||
return res;
|
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)
|
std::string p3Peers::saveCertificateToString(const RsPeerId &id)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
|
@ -1873,3 +1857,5 @@ void p3Peers::setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermi
|
||||||
|
|
||||||
RsPeerStateChangedEvent::RsPeerStateChangedEvent(RsPeerId sslId) :
|
RsPeerStateChangedEvent::RsPeerStateChangedEvent(RsPeerId sslId) :
|
||||||
RsEvent(RsEventType::PEER_STATE_CHANGED), mSslId(sslId) {}
|
RsEvent(RsEventType::PEER_STATE_CHANGED), mSslId(sslId) {}
|
||||||
|
|
||||||
|
RsPeers::~RsPeers() = default;
|
||||||
|
|
|
@ -83,6 +83,11 @@ public:
|
||||||
virtual const RsPgpId& getGPGOwnId();
|
virtual const RsPgpId& getGPGOwnId();
|
||||||
virtual RsPgpId getGPGId(const RsPeerId &ssl_id);
|
virtual RsPgpId getGPGId(const RsPeerId &ssl_id);
|
||||||
virtual bool isKeySupported(const RsPgpId& ids);
|
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 getGPGAcceptedList(std::list<RsPgpId> &ids);
|
||||||
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
|
virtual bool getGPGSignedList(std::list<RsPgpId> &ids);
|
||||||
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
|
virtual bool getGPGValidList(std::list<RsPgpId> &ids);
|
||||||
|
@ -154,14 +159,11 @@ public:
|
||||||
const std::string& invite,
|
const std::string& invite,
|
||||||
ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT );
|
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 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 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 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 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 std::string saveCertificateToString(const RsPeerId &id);
|
||||||
|
|
||||||
virtual bool signGPGCertificate(const RsPgpId &id);
|
virtual bool signGPGCertificate(const RsPgpId &id);
|
||||||
|
|
|
@ -744,7 +744,7 @@ void RsGxsForumModel::update_posts(const RsGxsGroupId& group_id)
|
||||||
|
|
||||||
forumIds.push_back(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;
|
std::cerr << __PRETTY_FUNCTION__ << " failed to retrieve forum group info for forum " << group_id << std::endl;
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -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
|
//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
|
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
|
if(minsize > maxBytes) return false; //impossible
|
||||||
|
|
||||||
// std::cout << "maxS: " << maxsize << " minS: " << minsize << std::endl;
|
// 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 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
|
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 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) {
|
if(nextsize <= maxBytes) {
|
||||||
minsize = nextsize;
|
minsize = nextsize;
|
||||||
minwidth = nextwidth;
|
minwidth = nextwidth;
|
||||||
|
@ -188,7 +188,7 @@ bool blueLessThan(const QRgb &c1, const QRgb &c2)
|
||||||
//median cut algoritmh
|
//median cut algoritmh
|
||||||
void ImageUtil::quantization(const QImage &img, QVector<QRgb> &palette)
|
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
|
int samplesize = 100000; //only take this many color samples
|
||||||
|
|
||||||
rstime::RsScopeTimer st("Quantization");
|
rstime::RsScopeTimer st("Quantization");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue