Fix RsIdentity API to get own identities

This commit is contained in:
Gioacchino Mazzurco 2019-07-19 13:54:46 +02:00
parent c559a26224
commit d9979ca183
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
3 changed files with 17 additions and 39 deletions

View File

@ -380,6 +380,7 @@ struct RsIdentity : RsGxsIfaceHelper
/**
* @brief Get identity details, from the cache
* @jsonapi{development}
* @param[in] id Id of the identity
* @param[out] details Storage for the identity details
* @return false on error, true otherwise
@ -400,7 +401,7 @@ struct RsIdentity : RsGxsIfaceHelper
* @param[out] ids storage for the ids
* @return false on error, true otherwise
*/
virtual bool getOwnSignedIds(std::vector<RsGxsId> ids) = 0;
virtual bool getOwnSignedIds(std::vector<RsGxsId>& ids) = 0;
/**
* @brief Get own pseudonimous (unsigned) ids
@ -408,7 +409,7 @@ struct RsIdentity : RsGxsIfaceHelper
* @param[out] ids storage for the ids
* @return false on error, true otherwise
*/
virtual bool getOwnPseudonimousIds(std::vector<RsGxsId> ids) = 0;
virtual bool getOwnPseudonimousIds(std::vector<RsGxsId>& ids) = 0;
/**
* @brief Check if an id is own

View File

@ -757,7 +757,7 @@ bool p3IdService::isOwnId(const RsGxsId& id)
}
bool p3IdService::getOwnSignedIds(std::vector<RsGxsId> ids)
bool p3IdService::getOwnSignedIds(std::vector<RsGxsId>& ids)
{
ids.clear();
@ -769,27 +769,29 @@ bool p3IdService::getOwnSignedIds(std::vector<RsGxsId> ids)
if(ownIdsAreLoaded())
{
RS_STACK_MUTEX(mIdMtx);
ids.reserve(mOwnSignedIds.size());
ids.insert(ids.end(), mOwnSignedIds.begin(), mOwnSignedIds.end());
ids.resize(mOwnSignedIds.size());
std::copy(mOwnSignedIds.begin(), mOwnSignedIds.end(), ids.begin());
return true;
}
return false;
}
bool p3IdService::getOwnPseudonimousIds(std::vector<RsGxsId> ids)
bool p3IdService::getOwnPseudonimousIds(std::vector<RsGxsId>& ids)
{
ids.clear();
std::vector<RsGxsId> signedV;
// this implicitely ensure ids are already loaded ;)
if(!getOwnSignedIds(signedV)) return false;
std::set<RsGxsId> signedS(signedV.begin(), signedV.end());
{
RS_STACK_MUTEX(mIdMtx);
std::copy_if(mOwnIds.begin(), mOwnIds.end(), ids.end(),
[&](const RsGxsId& id) {return !signedS.count(id);});
ids.resize(mOwnIds.size() - signedV.size());
std::copy_if( mOwnIds.begin(), mOwnIds.end(), ids.begin(),
[&](const RsGxsId& id) {return !signedS.count(id);} );
}
return true;

View File

@ -19,8 +19,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
#ifndef P3_IDENTITY_SERVICE_HEADER
#define P3_IDENTITY_SERVICE_HEADER
#pragma once
#include "retroshare/rsidentity.h" // External Interfaces.
@ -36,34 +35,13 @@
#include "util/rsmemcache.h"
#include "util/rstickevent.h"
#include "util/rsrecogn.h"
#include "util/rsdebug.h"
#include "pqi/authgpg.h"
#include "rsitems/rsgxsrecognitems.h"
class PgpAuxUtils;
/*
* Identity Service
*
*/
#if 0
class GxsReputation
{
public:
GxsReputation();
bool updateIdScore(bool pgpLinked, bool pgpKnown);
bool update(); // checks ranges and calculates overall score.
int mOverallScore;
int mIdScore; // PGP, Known, etc.
int mOwnOpinion;
int mPeerOpinion;
};
#endif
class OpinionRequest
{
public:
@ -312,10 +290,10 @@ public:
/**************** RsGixs Implementation ***************/
/// @see RsIdentity
bool getOwnSignedIds(std::vector<RsGxsId> ids) override;
bool getOwnSignedIds(std::vector<RsGxsId>& ids) override;
/// @see RsIdentity
bool getOwnPseudonimousIds(std::vector<RsGxsId> ids) override;
bool getOwnPseudonimousIds(std::vector<RsGxsId>& ids) override;
virtual bool getOwnIds(std::list<RsGxsId> &ownIds, bool signed_only = false);
@ -641,9 +619,6 @@ private:
bool mAutoAddFriendsIdentitiesAsContacts;
uint32_t mMaxKeepKeysBanned ;
RS_SET_CONTEXT_DEBUG_LEVEL(4);
};
#endif // P3_IDENTITY_SERVICE_HEADER