add special profile item for not yet validated peer from short invite

This commit is contained in:
csoler 2019-09-10 09:52:37 +02:00
parent c8064e1ddc
commit 3a58aa468f
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
5 changed files with 62 additions and 3 deletions

View File

@ -505,6 +505,8 @@ public:
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId>& ids) = 0;
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason = "") = 0;
virtual RsPgpId pgpIdFromFingerprint(const RsPgpFingerprint& fpr) = 0;
// Note: the two methods below could be unified. The fact that one of them can take an optional RsPeerDetails struct as parameter
// seems quite inconsistent.

View File

@ -670,6 +670,11 @@ bool p3Peers::gpgSignData(const void *data, const uint32_t len, unsigned char
return AuthGPG::getAuthGPG()->SignDataBin(data,len,sign,signlen, reason);
}
RsPgpId p3Peers::pgpIdFromFingerprint(const RsPgpFingerprint& fpr)
{
return PGPHandler::pgpIdFromFingerprint(fpr);
}
bool p3Peers::getGPGDetails(const RsPgpId &pgp_id, RsPeerDetails &d)
{
#ifdef P3PEERS_DEBUG

View File

@ -91,6 +91,8 @@ public:
virtual bool getAssociatedSSLIds(const RsPgpId& gpg_id, std::list<RsPeerId> &ids);
virtual bool gpgSignData(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, std::string reason = "") ;
virtual RsPgpId pgpIdFromFingerprint(const RsPgpFingerprint& fpr) override;
/* Add/Remove Friends */
virtual bool addFriend(const RsPeerId &ssl_id, const RsPgpId &gpg_id,ServicePermissionFlags flags = RS_NODE_PERM_DEFAULT);

View File

@ -36,7 +36,7 @@
#include "retroshare/rsexpr.h"
#include "retroshare/rsmsgs.h"
//#define DEBUG_MESSAGE_MODEL
#define DEBUG_MODEL
#define IS_MESSAGE_UNREAD(flags) (flags & (RS_MSG_NEW | RS_MSG_UNREAD_BY_USER))
@ -728,7 +728,7 @@ void RsFriendListModel::checkInternalData(bool force)
if(mLocations[i].last_update_ts + NODE_DETAILS_UPDATE_DELAY < now)
{
#ifdef DEBUG_MODEL
std::cerr << "Updating ID " << node.node_info.id << std::endl;
std::cerr << "Updating ID " << mLocations[i].node_info.id << std::endl;
#endif
RsPeerId id(mLocations[i].node_info.id); // this avoids zeroing the id field when writing the node data
rsPeers->getPeerDetails(id,mLocations[i].node_info);
@ -973,6 +973,48 @@ RsFriendListModel::EntryType RsFriendListModel::getType(const QModelIndex& i) co
return e.type;
}
std::map<RsPgpId,uint32_t>::const_iterator RsFriendListModel::createInvalidatedProfile(const RsPgpFingerprint& fpr,std::map<RsPgpId,uint32_t>& pgp_indices,std::vector<HierarchicalProfileInformation>& mProfiles)
{
RsPgpId pgp_id = rsPeers->pgpIdFromFingerprint(fpr);
auto it2 = pgp_indices.find(pgp_id);
if(it2 != pgp_indices.end())
{
std::cerr << "(EE) asked to create an invalidated profile that already exists!" << std::endl;
return it2;
}
HierarchicalProfileInformation hprof ;
if(rsPeers->getGPGDetails(pgp_id,hprof.profile_info))
{
std::cerr << "(EE) asked to create an invalidated profile that already exists!" << std::endl;
return it2;
}
hprof.profile_info.isOnlyGPGdetail = true;
hprof.profile_info.gpg_id = pgp_id;
hprof.profile_info.name = tr("Profile ID ").toStdString() + pgp_id.toStdString() + tr(" (Not yet validated)").toStdString();
hprof.profile_info.issuer = pgp_id;
hprof.profile_info.fpr = fpr; /* pgp fingerprint */
hprof.profile_info.trustLvl = 0;
hprof.profile_info.validLvl = 0;
pgp_indices[pgp_id] = mProfiles.size();
mProfiles.push_back(hprof);
it2 = pgp_indices.find(pgp_id);
#ifdef DEBUG_MODEL
RsDbg() << " Creating invalidated profile pgp id = " << pgp_id << " (" << hprof.profile_info.name << ") and fingerprint " << fpr << std::endl;
#endif
return it2;
}
std::map<RsPgpId,uint32_t>::const_iterator RsFriendListModel::checkProfileIndex(const RsPgpId& pgp_id,std::map<RsPgpId,uint32_t>& pgp_indices,std::vector<HierarchicalProfileInformation>& mProfiles,bool create)
{
auto it2 = pgp_indices.find(pgp_id);
@ -1042,7 +1084,11 @@ void RsFriendListModel::updateInternalData()
auto it2 = checkProfileIndex(hnode.node_info.gpg_id,pgp_indices,mProfiles,hnode.node_info.gpg_id == rsPeers->getGPGOwnId());
if(it2 == pgp_indices.end())
continue;
{
// This peer's pgp key hasn't been validated yet. We list such peers at the end.
it2 = createInvalidatedProfile(hnode.node_info.fpr,pgp_indices,mProfiles);
}
mProfiles[it2->second].child_node_indices.push_back(mLocations.size());
mLocations.push_back(hnode);

View File

@ -164,6 +164,10 @@ private:
std::vector<HierarchicalProfileInformation>& mProfiles,
bool create);
std::map<RsPgpId,uint32_t>::const_iterator createInvalidatedProfile(const RsPgpFingerprint& pgp_id,
std::map<RsPgpId,uint32_t>& pgp_indices,
std::vector<HierarchicalProfileInformation>& mProfiles);
QVariant sizeHintRole (const EntryIndex& e, int col) const;
QVariant displayRole (const EntryIndex& e, int col) const;
QVariant decorationRole(const EntryIndex& e, int col) const;