Expose RsIdentity JSON API

This commit is contained in:
Gioacchino Mazzurco 2019-02-13 17:08:38 -03:00
parent ac1d24dba4
commit 6633e8bb28
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
3 changed files with 411 additions and 72 deletions

View File

@ -4,7 +4,7 @@
* libretroshare: retroshare core library * * libretroshare: retroshare core library *
* * * *
* Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> * * Copyright (C) 2012 Robert Fernie <retroshare@lunamutt.com> *
* Copyright (C) 2018 Gioacchino Mazzurco <gio@eigenlab.org> * * Copyright (C) 2019 Gioacchino Mazzurco <gio@eigenlab.org> *
* * * *
* This program is free software: you can redistribute it and/or modify * * This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -20,12 +20,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * * along with this program. If not, see <https://www.gnu.org/licenses/>. *
* * * *
*******************************************************************************/ *******************************************************************************/
#ifndef RETROSHARE_IDENTITY_GUI_INTERFACE_H #pragma once
#define RETROSHARE_IDENTITY_GUI_INTERFACE_H
#include <inttypes.h> #include <cstdint>
#include <string> #include <string>
#include <list> #include <list>
#include <vector>
#include "retroshare/rstokenservice.h" #include "retroshare/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h" #include "retroshare/rsgxsifacehelper.h"
@ -37,9 +37,13 @@
#include "serialiser/rstypeserializer.h" #include "serialiser/rstypeserializer.h"
#include "util/rsdeprecate.h" #include "util/rsdeprecate.h"
/* The Main Interface Class - for information about your Peers */
struct RsIdentity; struct RsIdentity;
extern RsIdentity *rsIdentity;
/**
* Pointer to global instance of RsIdentity service implementation
* @jsonapi{development}
*/
extern RsIdentity* rsIdentity;
// GroupFlags: Only one so far: // GroupFlags: Only one so far:
@ -106,7 +110,7 @@ struct RsGxsIdGroup : RsSerializable
{ {
RsGxsIdGroup() : RsGxsIdGroup() :
mLastUsageTS(0), mPgpKnown(false), mIsAContact(false) {} mLastUsageTS(0), mPgpKnown(false), mIsAContact(false) {}
~RsGxsIdGroup() {} virtual ~RsGxsIdGroup() {}
RsGroupMetaData mMeta; RsGroupMetaData mMeta;
@ -144,18 +148,18 @@ struct RsGxsIdGroup : RsSerializable
/// @see RsSerializable /// @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j, void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx ); RsGenericSerializer::SerializeContext& ctx ) override;
}; };
std::ostream &operator<<(std::ostream &out, const RsGxsIdGroup &group); std::ostream &operator<<(std::ostream &out, const RsGxsIdGroup &group);
// DATA TYPE FOR EXTERNAL INTERFACE. // DATA TYPE FOR EXTERNAL INTERFACE.
class RsRecognTag struct RsRecognTag
{ {
public: RsRecognTag(uint16_t tc, uint16_t tt, bool v) :
RsRecognTag(uint16_t tc, uint16_t tt, bool v) tag_class(tc), tag_type(tt), valid(v) {}
:tag_class(tc), tag_type(tt), valid(v) { return; }
uint16_t tag_class; uint16_t tag_class;
uint16_t tag_type; uint16_t tag_type;
bool valid; bool valid;
@ -268,11 +272,11 @@ struct RsIdentityUsage : RsSerializable
std::string mComment; std::string mComment;
bool operator<(const RsIdentityUsage& u) const { return mHash < u.mHash; } bool operator<(const RsIdentityUsage& u) const { return mHash < u.mHash; }
RsFileHash mHash ; RsFileHash mHash;
/// @see RsSerializable /// @see RsSerializable
void serial_process( RsGenericSerializer::SerializeJob j, void serial_process( RsGenericSerializer::SerializeJob j,
RsGenericSerializer::SerializeContext& ctx ) RsGenericSerializer::SerializeContext& ctx ) override
{ {
RS_SERIAL_PROCESS(mServiceId); RS_SERIAL_PROCESS(mServiceId);
RS_SERIAL_PROCESS(mUsageCode); RS_SERIAL_PROCESS(mUsageCode);
@ -329,7 +333,7 @@ struct RsIdentityDetails : RsSerializable
RS_SERIAL_PROCESS(mFlags); RS_SERIAL_PROCESS(mFlags);
RS_SERIAL_PROCESS(mPgpId); RS_SERIAL_PROCESS(mPgpId);
//RS_SERIAL_PROCESS(mReputation); //RS_SERIAL_PROCESS(mReputation);
//RS_SERIAL_PROCESS(mAvatar); RS_SERIAL_PROCESS(mAvatar);
RS_SERIAL_PROCESS(mPublishTS); RS_SERIAL_PROCESS(mPublishTS);
RS_SERIAL_PROCESS(mLastUsageTS); RS_SERIAL_PROCESS(mLastUsageTS);
RS_SERIAL_PROCESS(mUseCases); RS_SERIAL_PROCESS(mUseCases);
@ -338,73 +342,214 @@ struct RsIdentityDetails : RsSerializable
/** The Main Interface Class for GXS people identities */
struct RsIdentity : RsGxsIfaceHelper struct RsIdentity : RsGxsIfaceHelper
{ {
explicit RsIdentity(RsGxsIface& gxs): RsGxsIfaceHelper(gxs) {} explicit RsIdentity(RsGxsIface& gxs) : RsGxsIfaceHelper(gxs) {}
virtual ~RsIdentity() {} virtual ~RsIdentity() {}
/********************************************************************************************/ /**
/********************************************************************************************/ * @brief Create a new identity
* @jsonapi{development}
* @param[out] id storage for the created identity Id
* @param[in] name Name of the identity
* @param[in] avatar Image associated to the identity
* @param[in] pseudonimous true for unsigned identity, false otherwise
* @param[in] pgpPassword password to unlock PGP to sign identity,
* not implemented yet
* @return false on error, true otherwise
*/
virtual bool createIdentity(
RsGxsId& id,
const std::string& name, const RsGxsImage& avatar = RsGxsImage(),
bool pseudonimous = true, const std::string& pgpPassword = "" ) = 0;
// For Other Services.... /**
// It should be impossible for them to get a message which we don't have the identity. * @brief Locally delete given identity
// Its a major error if we don't have the identity. * @jsonapi{development}
* @param[in] id Id of the identity
* @return false on error, true otherwise
*/
virtual bool deleteIdentity(RsGxsId& id) = 0;
// We cache all identities, and provide alternative (instantaneous) /**
// functions to extract info, rather than the standard Token system. * @brief Update identity data (name, avatar...)
* @jsonapi{development}
* @param[in] identityData updated identiy data
* @return false on error, true otherwise
*/
virtual bool updateIdentity(RsGxsIdGroup& identityData) = 0;
//virtual bool getNickname(const RsGxsId &id, std::string &nickname) = 0; /**
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details) = 0; * @brief Get identity details, from the cache
* @param[in] id Id of the identity
* @param[out] details Storage for the identity details
* @return false on error, true otherwise
*/
virtual bool getIdDetails(const RsGxsId& id, RsIdentityDetails& details) = 0;
// Fills up list of all own ids. Returns false if ids are not yet loaded. /**
virtual bool getOwnIds(std::list<RsGxsId> &ownIds,bool only_signed_ids = false) = 0; * @brief Get last seen usage time of given identity
virtual bool isOwnId(const RsGxsId& id) = 0; * @jsonapi{development}
* @param[in] id Id of the identity
* @return timestamp of last seen usage
*/
virtual rstime_t getLastUsageTS(const RsGxsId& id) = 0;
// /**
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id, * @brief Get own signed ids
bool absOpinion, int score) = 0; * @jsonapi{development}
virtual bool createIdentity(uint32_t& token, RsIdentityParameters &params) = 0; * @param[out] ids storage for the ids
* @return false on error, true otherwise
*/
virtual bool getOwnSignedIds(std::vector<RsGxsId> ids) = 0;
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group) = 0; /**
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group) = 0; * @brief Get own pseudonimous (unsigned) ids
* @jsonapi{development}
* @param[out] ids storage for the ids
* @return false on error, true otherwise
*/
virtual bool getOwnPseudonimousIds(std::vector<RsGxsId> ids) = 0;
virtual void setDeleteBannedNodesThreshold(uint32_t days) =0; /**
virtual uint32_t deleteBannedNodesThreshold() =0; * @brief Check if an id is own
* @jsonapi{development}
* @param[in] id Id to check
* @return true if the id is own, false otherwise
*/
virtual bool isOwnId(const RsGxsId& id) = 0;
virtual bool parseRecognTag(const RsGxsId &id, const std::string &nickname, /**
const std::string &tag, RsRecognTagDetails &details) = 0; * @brief Get base64 representation of an identity
virtual bool getRecognTagRequest(const RsGxsId &id, const std::string &comment, * @jsonapi{development}
uint16_t tag_class, uint16_t tag_type, std::string &tag) = 0; * @param[in] id Id of the identity
* @param[out] base64String storage for the identity base64
* @return false on error, true otherwise
*/
virtual bool identityToBase64( const RsGxsId& id,
std::string& base64String ) = 0;
virtual bool setAsRegularContact(const RsGxsId& id,bool is_a_contact) = 0 ; /**
virtual bool isARegularContact(const RsGxsId& id) = 0 ; * @brief Import identity from base64 representation
* @jsonapi{development}
* @param[in] base64String base64 representation of the identity to import
* @param[out] id storage for the identity id
* @return false on error, true otherwise
*/
virtual bool identityFromBase64( const std::string& base64String,
RsGxsId& id ) = 0;
/**
* @brief Get identities summaries list.
* @jsonapi{development}
* @param[out] ids list where to store the identities
* @return false if something failed, true otherwhise
*/
virtual bool getIdentitiesSummaries(std::list<RsGroupMetaData>& ids) = 0;
/**
* @brief Get identities information (name, avatar...).
* Blocking API.
* @jsonapi{development}
* @param[in] ids ids of the channels of which to get the informations
* @param[out] idsInfo storage for the identities informations
* @return false if something failed, true otherwhise
*/
virtual bool getIdentitiesInfo(
const std::set<RsGxsId>& ids,
std::vector<RsGxsIdGroup>& idsInfo ) = 0;
/**
* @brief Check if an identity is contact
* @jsonapi{development}
* @param[in] id Id of the identity
* @return true if it is a conctact, false otherwise
*/
virtual bool isARegularContact(const RsGxsId& id) = 0;
/**
* @brief Set/unset identity as contact
* @param[in] id Id of the identity
* @param[in] isContact true to set, false to unset
* @return false on error, true otherwise
*/
virtual bool setAsRegularContact(const RsGxsId& id, bool isContact) = 0;
/**
* @brief Toggle automatic flagging signed by friends identity as contact
* @jsonapi{development}
* @param[in] enabled true to enable, false to disable
*/
virtual void setAutoAddFriendIdsAsContact(bool enabled) = 0;
/**
* @brief Check if automatic signed by friend identity contact flagging is
* enabled
* @jsonapi{development}
* @return true if enabled, false otherwise
*/
virtual bool autoAddFriendIdsAsContact() = 0;
/**
* @brief Get number of days after which delete a banned identities
* @jsonapi{development}
* @return number of days
*/
virtual uint32_t deleteBannedNodesThreshold() = 0;
/**
* @brief Set number of days after which delete a banned identities
* @jsonapi{development}
* @param[in] days number of days
*/
virtual void setDeleteBannedNodesThreshold(uint32_t days) = 0;
RS_DEPRECATED
virtual bool getGroupSerializedData(
const uint32_t& token,
std::map<RsGxsId,std::string>& serialized_groups ) = 0;
RS_DEPRECATED
virtual bool parseRecognTag(
const RsGxsId &id, const std::string& nickname,
const std::string& tag, RsRecognTagDetails& details) = 0;
RS_DEPRECATED
virtual bool getRecognTagRequest(
const RsGxsId& id, const std::string& comment, uint16_t tag_class,
uint16_t tag_type, std::string& tag) = 0;
RS_DEPRECATED
virtual uint32_t nbRegularContacts() =0; virtual uint32_t nbRegularContacts() =0;
virtual void setAutoAddFriendIdsAsContact(bool b) =0;
virtual bool autoAddFriendIdsAsContact() =0;
RS_DEPRECATED_FOR(identityToBase64)
virtual bool serialiseIdentityToMemory( const RsGxsId& id, virtual bool serialiseIdentityToMemory( const RsGxsId& id,
std::string& radix_string ) = 0; std::string& radix_string ) = 0;
RS_DEPRECATED_FOR(identityFromBase64)
virtual bool deserialiseIdentityFromMemory( const std::string& radix_string, virtual bool deserialiseIdentityFromMemory( const std::string& radix_string,
RsGxsId* id = nullptr ) = 0; RsGxsId* id = nullptr ) = 0;
/*! /// Fills up list of all own ids. Returns false if ids are not yet loaded.
* \brief overallReputationLevel RS_DEPRECATED_FOR("getOwnSignedIds getOwnPseudonimousIds")
* Returns the overall reputation level of the supplied identity. See rsreputations.h virtual bool getOwnIds( std::list<RsGxsId> &ownIds,
* \param id bool only_signed_ids = false ) = 0;
* \return
*/
virtual rstime_t getLastUsageTS(const RsGxsId &id) =0;
// Specific RsIdentity Functions.... RS_DEPRECATED
/* Specific Service Data */ virtual bool createIdentity(uint32_t& token, RsIdentityParameters &params) = 0;
/* We expose these initially for testing / GUI purposes.
*/
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups) = 0; RS_DEPRECATED_FOR(RsReputations)
virtual bool getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups)=0; virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
//virtual bool getMsgData(const uint32_t &token, std::vector<RsGxsIdOpinion> &opinions) = 0; bool absOpinion, int score) = 0;
RS_DEPRECATED
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
RS_DEPRECATED
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group) = 0;
RS_DEPRECATED_FOR("getIdentitiesSummaries getIdentitiesInfo")
virtual bool getGroupData( const uint32_t& token,
std::vector<RsGxsIdGroup>& groups) = 0;
}; };
#endif // RETROSHARE_IDENTITY_GUI_INTERFACE_H

View File

@ -21,6 +21,7 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#include <unistd.h> #include <unistd.h>
#include <algorithm>
#include "services/p3idservice.h" #include "services/p3idservice.h"
#include "pgp/pgpauxutils.h" #include "pgp/pgpauxutils.h"
@ -207,6 +208,29 @@ void p3IdService::setNes(RsNetworkExchangeService *nes)
mNes = nes; mNes = nes;
} }
bool p3IdService::getIdentitiesInfo(
const std::set<RsGxsId>& ids, std::vector<RsGxsIdGroup>& idsInfo )
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
std::list<RsGxsGroupId> idsList(ids.begin(), ids.end());
if( !requestGroupInfo(token, opts, idsList)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
return getGroupData(token, idsInfo);
}
bool p3IdService::getIdentitiesSummaries(std::list<RsGroupMetaData>& ids)
{
uint32_t token;
RsTokReqOptions opts;
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
if( !requestGroupInfo(token, opts)
|| waitToken(token) != RsTokenService::COMPLETE ) return false;
return getGroupSummary(token, ids);
}
uint32_t p3IdService::idAuthenPolicy() uint32_t p3IdService::idAuthenPolicy()
{ {
uint32_t policy = 0; uint32_t policy = 0;
@ -727,6 +751,46 @@ bool p3IdService::isOwnId(const RsGxsId& id)
return std::find(mOwnIds.begin(),mOwnIds.end(),id) != mOwnIds.end() ; return std::find(mOwnIds.begin(),mOwnIds.end(),id) != mOwnIds.end() ;
} }
bool p3IdService::getOwnSignedIds(std::vector<RsGxsId> ids)
{
ids.clear();
std::chrono::seconds maxWait(5);
auto timeout = std::chrono::steady_clock::now() + maxWait;
while( !ownIdsAreLoaded() && std::chrono::steady_clock::now() < timeout )
std::this_thread::sleep_for(std::chrono::milliseconds(100));
if(ownIdsAreLoaded())
{
RS_STACK_MUTEX(mIdMtx);
ids.reserve(mOwnSignedIds.size());
ids.insert(ids.end(), mOwnSignedIds.begin(), mOwnSignedIds.end());
return true;
}
return false;
}
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);});
}
return true;
}
bool p3IdService::getOwnIds(std::list<RsGxsId> &ownIds,bool signed_only) bool p3IdService::getOwnIds(std::list<RsGxsId> &ownIds,bool signed_only)
{ {
RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/ RsStackMutex stack(mIdMtx); /********** STACK LOCKED MTX ******/
@ -742,6 +806,11 @@ bool p3IdService::getOwnIds(std::list<RsGxsId> &ownIds,bool signed_only)
return true ; return true ;
} }
bool p3IdService::identityToBase64( const RsGxsId& id,
std::string& base64String )
{ return serialiseIdentityToMemory(id, base64String); }
bool p3IdService::serialiseIdentityToMemory( const RsGxsId& id, bool p3IdService::serialiseIdentityToMemory( const RsGxsId& id,
std::string& radix_string ) std::string& radix_string )
{ {
@ -803,6 +872,10 @@ void p3IdService::handle_get_serialized_grp(uint32_t token)
mSerialisedIdentities[RsGxsId(id)] = s ; mSerialisedIdentities[RsGxsId(id)] = s ;
} }
bool p3IdService::identityFromBase64(
const std::string& base64String, RsGxsId& id )
{ return deserialiseIdentityFromMemory(base64String, &id); }
bool p3IdService::deserialiseIdentityFromMemory(const std::string& radix_string, bool p3IdService::deserialiseIdentityFromMemory(const std::string& radix_string,
RsGxsId* id /* = nullptr */) RsGxsId* id /* = nullptr */)
{ {
@ -826,6 +899,47 @@ bool p3IdService::deserialiseIdentityFromMemory(const std::string& radix_string,
return true; return true;
} }
bool p3IdService::createIdentity(
RsGxsId& id,
const std::string& name, const RsGxsImage& avatar,
bool pseudonimous, const std::string& pgpPassword)
{
if(!pgpPassword.empty())
std::cerr<< __PRETTY_FUNCTION__ << " Warning! PGP Password handling "
<< "not implemented yet!" << std::endl;
RsIdentityParameters params;
params.isPgpLinked = !pseudonimous;
params.nickname = name;
params.mImage = avatar;
uint32_t token;
if(!createIdentity(token, params))
{
std::cerr << __PRETTY_FUNCTION__ << " Error! Failed creating group."
<< std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << " Error! GXS operation failed."
<< std::endl;
return false;
}
RsGroupMetaData meta;
if(!RsGenExchange::getPublishedGroupMeta(token, meta))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failure getting updated "
<< " group data." << std::endl;
return false;
}
id = RsGxsId(meta.mGroupId);
return true;
}
bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters &params) bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters &params)
{ {
@ -863,6 +977,26 @@ bool p3IdService::createIdentity(uint32_t& token, RsIdentityParameters &params)
return true; return true;
} }
bool p3IdService::updateIdentity(RsGxsIdGroup& identityData)
{
uint32_t token;
if(!updateGroup(token, identityData))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed updating group."
<< std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
return true;
}
bool p3IdService::updateIdentity(uint32_t& token, RsGxsIdGroup &group) bool p3IdService::updateIdentity(uint32_t& token, RsGxsIdGroup &group)
{ {
#ifdef DEBUG_IDS #ifdef DEBUG_IDS
@ -876,6 +1010,27 @@ bool p3IdService::updateIdentity(uint32_t& token, RsGxsIdGroup &group)
return false; return false;
} }
bool p3IdService::deleteIdentity(RsGxsId& id)
{
uint32_t token;
RsGxsGroupId grouId = RsGxsGroupId(id);
if(!deleteGroup(token, grouId))
{
std::cerr << __PRETTY_FUNCTION__ << "Error! Failed deleting group."
<< std::endl;
return false;
}
if(waitToken(token) != RsTokenService::COMPLETE)
{
std::cerr << __PRETTY_FUNCTION__ << "Error! GXS operation failed."
<< std::endl;
return false;
}
return true;
}
bool p3IdService::deleteIdentity(uint32_t& token, RsGxsIdGroup &group) bool p3IdService::deleteIdentity(uint32_t& token, RsGxsIdGroup &group)
{ {
#ifdef DEBUG_IDS #ifdef DEBUG_IDS
@ -883,7 +1038,7 @@ bool p3IdService::deleteIdentity(uint32_t& token, RsGxsIdGroup &group)
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
deleteGroup(token, group); deleteGroup(token, group.mMeta.mGroupId);
return false; return false;
} }
@ -1796,16 +1951,16 @@ bool p3IdService::updateGroup(uint32_t& token, RsGxsIdGroup &group)
return true; return true;
} }
bool p3IdService::deleteGroup(uint32_t& token, RsGxsIdGroup &group) bool p3IdService::deleteGroup(uint32_t& token, RsGxsGroupId& groupId)
{ {
RsGxsId id(group.mMeta.mGroupId); RsGxsId id(groupId);
#ifdef DEBUG_IDS #ifdef DEBUG_IDS
std::cerr << "p3IdService::deleteGroup() Deleting RsGxsId: " << id; std::cerr << "p3IdService::deleteGroup() Deleting RsGxsId: " << id;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
RsGenExchange::deleteGroup(token,group.mMeta.mGroupId); RsGenExchange::deleteGroup(token, groupId);
// if its in the cache - clear it. // if its in the cache - clear it.
{ {

View File

@ -215,9 +215,8 @@ struct SerialisedIdentityStruct
rstime_t mLastUsageTS; rstime_t mLastUsageTS;
}; };
// Not sure exactly what should be inherited here? // We cache all identities, and provide alternative (instantaneous)
// Chris - please correct as necessary. // functions to extract info, rather than the horrible Token system.
class p3IdService: public RsGxsIdExchange, public RsIdentity, public GxsTokenQueue, public RsTickEvent, public p3Config class p3IdService: public RsGxsIdExchange, public RsIdentity, public GxsTokenQueue, public RsTickEvent, public p3Config
{ {
public: public:
@ -239,6 +238,13 @@ public:
/* Data Specific Interface */ /* Data Specific Interface */
/// @see RsIdentity
bool getIdentitiesInfo(const std::set<RsGxsId>& ids,
std::vector<RsGxsIdGroup>& idsInfo ) override;
/// @see RsIdentity
bool getIdentitiesSummaries(std::list<RsGroupMetaData>& ids) override;
// These are exposed via RsIdentity. // These are exposed via RsIdentity.
virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups); virtual bool getGroupData(const uint32_t &token, std::vector<RsGxsIdGroup> &groups);
virtual bool getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups); virtual bool getGroupSerializedData(const uint32_t &token, std::map<RsGxsId,std::string>& serialized_groups);
@ -248,7 +254,7 @@ public:
// These are local - and not exposed via RsIdentity. // These are local - and not exposed via RsIdentity.
virtual bool createGroup(uint32_t& token, RsGxsIdGroup &group); virtual bool createGroup(uint32_t& token, RsGxsIdGroup &group);
virtual bool updateGroup(uint32_t& token, RsGxsIdGroup &group); virtual bool updateGroup(uint32_t& token, RsGxsIdGroup &group);
virtual bool deleteGroup(uint32_t& token, RsGxsIdGroup &group); virtual bool deleteGroup(uint32_t& token, RsGxsGroupId& group);
//virtual bool createMsg(uint32_t& token, RsGxsIdOpinion &opinion); //virtual bool createMsg(uint32_t& token, RsGxsIdOpinion &opinion);
/**************** RsIdentity External Interface. /**************** RsIdentity External Interface.
@ -263,12 +269,28 @@ public:
//virtual bool getNickname(const RsGxsId &id, std::string &nickname); //virtual bool getNickname(const RsGxsId &id, std::string &nickname);
virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details); virtual bool getIdDetails(const RsGxsId &id, RsIdentityDetails &details);
// RS_DEPRECATED_FOR(RsReputations)
virtual bool submitOpinion(uint32_t& token, const RsGxsId &id, virtual bool submitOpinion(uint32_t& token, const RsGxsId &id,
bool absOpinion, int score); bool absOpinion, int score);
/// @see RsIdentity
virtual bool createIdentity(
RsGxsId& id,
const std::string& name, const RsGxsImage& avatar = RsGxsImage(),
bool pseudonimous = true, const std::string& pgpPassword = "" ) override;
virtual bool createIdentity(uint32_t& token, RsIdentityParameters &params); virtual bool createIdentity(uint32_t& token, RsIdentityParameters &params);
/// @see RsIdentity
bool updateIdentity(RsGxsIdGroup& identityData) override;
RS_DEPRECATED
virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group); virtual bool updateIdentity(uint32_t& token, RsGxsIdGroup &group);
/// @see RsIdentity
bool deleteIdentity(RsGxsId& id) override;
RS_DEPRECATED
virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group); virtual bool deleteIdentity(uint32_t& token, RsGxsIdGroup &group);
virtual void setDeleteBannedNodesThreshold(uint32_t days) ; virtual void setDeleteBannedNodesThreshold(uint32_t days) ;
@ -289,6 +311,12 @@ public:
/**************** RsGixs Implementation ***************/ /**************** RsGixs Implementation ***************/
/// @see RsIdentity
bool getOwnSignedIds(std::vector<RsGxsId> ids) override;
/// @see RsIdentity
bool getOwnPseudonimousIds(std::vector<RsGxsId> ids) override;
virtual bool getOwnIds(std::list<RsGxsId> &ownIds, bool signed_only = false); virtual bool getOwnIds(std::list<RsGxsId> &ownIds, bool signed_only = false);
//virtual bool getPublicKey(const RsGxsId &id, RsTlvSecurityKey &key) ; //virtual bool getPublicKey(const RsGxsId &id, RsTlvSecurityKey &key) ;
@ -350,6 +378,15 @@ public:
const RsIdentityUsage &use_info ); const RsIdentityUsage &use_info );
virtual bool requestPrivateKey(const RsGxsId &id); virtual bool requestPrivateKey(const RsGxsId &id);
/// @see RsIdentity
bool identityToBase64( const RsGxsId& id,
std::string& base64String ) override;
/// @see RsIdentity
bool identityFromBase64( const std::string& base64String,
RsGxsId& id ) override;
virtual bool serialiseIdentityToMemory(const RsGxsId& id, virtual bool serialiseIdentityToMemory(const RsGxsId& id,
std::string& radix_string); std::string& radix_string);
virtual bool deserialiseIdentityFromMemory(const std::string& radix_string, virtual bool deserialiseIdentityFromMemory(const std::string& radix_string,
@ -599,7 +636,9 @@ private:
rstime_t mLastKeyCleaningTime ; rstime_t mLastKeyCleaningTime ;
rstime_t mLastConfigUpdate ; rstime_t mLastConfigUpdate ;
bool mOwnIdsLoaded ; bool mOwnIdsLoaded;
bool ownIdsAreLoaded() { RS_STACK_MUTEX(mIdMtx); return mOwnIdsLoaded; }
bool mAutoAddFriendsIdentitiesAsContacts; bool mAutoAddFriendsIdentitiesAsContacts;
uint32_t mMaxKeepKeysBanned ; uint32_t mMaxKeepKeysBanned ;
}; };