mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
Add rsidentity API call to request specific identity to the network
This commit is contained in:
parent
cea88f0c6c
commit
08604774d3
@ -244,14 +244,22 @@ struct RsIdentityUsage : RsSerializable
|
|||||||
CIRCLE_MEMBERSHIP_CHECK = 0x13
|
CIRCLE_MEMBERSHIP_CHECK = 0x13
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
RS_DEPRECATED
|
||||||
RsIdentityUsage( uint16_t service, const RsIdentityUsage::UsageCode& code,
|
RsIdentityUsage( uint16_t service, const RsIdentityUsage::UsageCode& code,
|
||||||
const RsGxsGroupId& gid = RsGxsGroupId(),
|
const RsGxsGroupId& gid = RsGxsGroupId(),
|
||||||
const RsGxsMessageId& mid = RsGxsMessageId(),
|
const RsGxsMessageId& mid = RsGxsMessageId(),
|
||||||
uint64_t additional_id=0,
|
uint64_t additional_id=0,
|
||||||
const std::string& comment = std::string() );
|
const std::string& comment = std::string() );
|
||||||
|
|
||||||
|
RsIdentityUsage( RsServiceType service,
|
||||||
|
RsIdentityUsage::UsageCode code,
|
||||||
|
const RsGxsGroupId& gid = RsGxsGroupId(),
|
||||||
|
const RsGxsMessageId& mid = RsGxsMessageId(),
|
||||||
|
uint64_t additional_id=0,
|
||||||
|
const std::string& comment = std::string() );
|
||||||
|
|
||||||
/// Id of the service using that identity, as understood by rsServiceControl
|
/// Id of the service using that identity, as understood by rsServiceControl
|
||||||
uint16_t mServiceId;
|
RsServiceType mServiceId;
|
||||||
|
|
||||||
/** Specific code to use. Will allow forming the correct translated message
|
/** Specific code to use. Will allow forming the correct translated message
|
||||||
* in the GUI if necessary. */
|
* in the GUI if necessary. */
|
||||||
@ -504,6 +512,14 @@ struct RsIdentity : RsGxsIfaceHelper
|
|||||||
*/
|
*/
|
||||||
virtual void setDeleteBannedNodesThreshold(uint32_t days) = 0;
|
virtual void setDeleteBannedNodesThreshold(uint32_t days) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief request details of a not yet known identity to the network
|
||||||
|
* @jsonapi{development}
|
||||||
|
* @param[in] id id of the identity to request
|
||||||
|
* @return false on error, true otherwise
|
||||||
|
*/
|
||||||
|
virtual bool requestIdentity(const RsGxsId& id) = 0;
|
||||||
|
|
||||||
|
|
||||||
RS_DEPRECATED
|
RS_DEPRECATED
|
||||||
virtual bool getGroupSerializedData(
|
virtual bool getGroupSerializedData(
|
||||||
|
@ -1153,6 +1153,16 @@ static void mergeIds(std::map<RsGxsId,std::list<RsPeerId> >& idmap,const RsGxsId
|
|||||||
old_peers.push_back(*it) ;
|
old_peers.push_back(*it) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3IdService::requestIdentity(const RsGxsId& id)
|
||||||
|
{
|
||||||
|
RsIdentityUsage usageInfo( RsServiceType::GXSID,
|
||||||
|
RsIdentityUsage::IDENTITY_DATA_UPDATE );
|
||||||
|
std::list<RsPeerId> onlinePeers;
|
||||||
|
|
||||||
|
return rsPeers && rsPeers->getOnlineList(onlinePeers)
|
||||||
|
&& requestKey(id, onlinePeers, usageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
bool p3IdService::requestKey(const RsGxsId &id, const std::list<RsPeerId>& peers,const RsIdentityUsage& use_info)
|
bool p3IdService::requestKey(const RsGxsId &id, const std::list<RsPeerId>& peers,const RsIdentityUsage& use_info)
|
||||||
{
|
{
|
||||||
if(id.isNull())
|
if(id.isNull())
|
||||||
@ -4680,12 +4690,34 @@ void RsGxsIdGroup::serial_process(
|
|||||||
RS_SERIAL_PROCESS(mReputation);
|
RS_SERIAL_PROCESS(mReputation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RsIdentityUsage::RsIdentityUsage(
|
||||||
|
RsServiceType service, RsIdentityUsage::UsageCode code,
|
||||||
|
const RsGxsGroupId& gid, const RsGxsMessageId& mid,
|
||||||
|
uint64_t additional_id, const std::string& comment ) :
|
||||||
|
mServiceId(service), mUsageCode(code), mGrpId(gid), mMsgId(mid),
|
||||||
|
mAdditionalId(additional_id), mComment(comment)
|
||||||
|
{
|
||||||
|
/* This is a hack, since it will hash also mHash, but because it is
|
||||||
|
* initialized to 0, and only computed in the constructor here, it should
|
||||||
|
* be ok. */
|
||||||
|
librs::crypto::HashStream hs(librs::crypto::HashStream::SHA1);
|
||||||
|
|
||||||
|
hs << static_cast<uint32_t>(service); // G10h4ck: Why uint32 if it's 16 bits?
|
||||||
|
hs << static_cast<uint8_t>(code);
|
||||||
|
hs << gid;
|
||||||
|
hs << mid;
|
||||||
|
hs << static_cast<uint64_t>(additional_id);
|
||||||
|
hs << comment;
|
||||||
|
|
||||||
|
mHash = hs.hash();
|
||||||
|
}
|
||||||
|
|
||||||
RsIdentityUsage::RsIdentityUsage(
|
RsIdentityUsage::RsIdentityUsage(
|
||||||
uint16_t service, const RsIdentityUsage::UsageCode& code,
|
uint16_t service, const RsIdentityUsage::UsageCode& code,
|
||||||
const RsGxsGroupId& gid, const RsGxsMessageId& mid,
|
const RsGxsGroupId& gid, const RsGxsMessageId& mid,
|
||||||
uint64_t additional_id,const std::string& comment ) :
|
uint64_t additional_id,const std::string& comment ) :
|
||||||
mServiceId(service), mUsageCode(code), mGrpId(gid), mMsgId(mid),
|
mServiceId(static_cast<RsServiceType>(service)), mUsageCode(code),
|
||||||
mAdditionalId(additional_id), mComment(comment)
|
mGrpId(gid), mMsgId(mid), mAdditionalId(additional_id), mComment(comment)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG_IDS
|
#ifdef DEBUG_IDS
|
||||||
std::cerr << "New identity usage: " << std::endl;
|
std::cerr << "New identity usage: " << std::endl;
|
||||||
@ -4702,7 +4734,7 @@ RsIdentityUsage::RsIdentityUsage(
|
|||||||
* be ok. */
|
* be ok. */
|
||||||
librs::crypto::HashStream hs(librs::crypto::HashStream::SHA1) ;
|
librs::crypto::HashStream hs(librs::crypto::HashStream::SHA1) ;
|
||||||
|
|
||||||
hs << (uint32_t)service ;
|
hs << (uint32_t)service ; // G10h4ck: Why uint32 if it's 16 bits?
|
||||||
hs << (uint8_t)code ;
|
hs << (uint8_t)code ;
|
||||||
hs << gid ;
|
hs << gid ;
|
||||||
hs << mid ;
|
hs << mid ;
|
||||||
@ -4717,4 +4749,5 @@ RsIdentityUsage::RsIdentityUsage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
RsIdentityUsage::RsIdentityUsage() :
|
RsIdentityUsage::RsIdentityUsage() :
|
||||||
mServiceId(0), mUsageCode(UNKNOWN_USAGE), mAdditionalId(0) {}
|
mServiceId(RsServiceType::NONE), mUsageCode(UNKNOWN_USAGE), mAdditionalId(0)
|
||||||
|
{}
|
||||||
|
@ -370,6 +370,9 @@ public:
|
|||||||
virtual bool deserialiseIdentityFromMemory(const std::string& radix_string,
|
virtual bool deserialiseIdentityFromMemory(const std::string& radix_string,
|
||||||
RsGxsId* id = nullptr);
|
RsGxsId* id = nullptr);
|
||||||
|
|
||||||
|
/// @see RsIdentity
|
||||||
|
bool requestIdentity(const RsGxsId& id) override;
|
||||||
|
|
||||||
/**************** RsGixsReputation Implementation ****************/
|
/**************** RsGixsReputation Implementation ****************/
|
||||||
|
|
||||||
// get Reputation.
|
// get Reputation.
|
||||||
|
@ -1987,11 +1987,11 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const
|
|||||||
RetroShareLink::enumType service_type = RetroShareLink::TYPE_UNKNOWN;
|
RetroShareLink::enumType service_type = RetroShareLink::TYPE_UNKNOWN;
|
||||||
|
|
||||||
switch(u.mServiceId)
|
switch(u.mServiceId)
|
||||||
{
|
{
|
||||||
case RS_SERVICE_GXS_TYPE_CHANNELS: service_name = tr("Channels") ;service_type = RetroShareLink::TYPE_CHANNEL ; break ;
|
case RsServiceType::CHANNELS: service_name = tr("Channels") ;service_type = RetroShareLink::TYPE_CHANNEL ; break ;
|
||||||
case RS_SERVICE_GXS_TYPE_FORUMS: service_name = tr("Forums") ; service_type = RetroShareLink::TYPE_FORUM ; break ;
|
case RsServiceType::FORUMS: service_name = tr("Forums") ; service_type = RetroShareLink::TYPE_FORUM ; break ;
|
||||||
case RS_SERVICE_GXS_TYPE_POSTED: service_name = tr("Posted") ; service_type = RetroShareLink::TYPE_POSTED ; break ;
|
case RsServiceType::POSTED: service_name = tr("Posted") ; service_type = RetroShareLink::TYPE_POSTED ; break ;
|
||||||
case RS_SERVICE_TYPE_CHAT: service_name = tr("Chat") ; service_type = RetroShareLink::TYPE_CHAT_ROOM ; break ;
|
case RsServiceType::CHAT: service_name = tr("Chat") ; service_type = RetroShareLink::TYPE_CHAT_ROOM ; break ;
|
||||||
default:
|
default:
|
||||||
service_name = tr("Unknown"); service_type = RetroShareLink::TYPE_UNKNOWN ;
|
service_name = tr("Unknown"); service_type = RetroShareLink::TYPE_UNKNOWN ;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user