diff --git a/libretroshare/src/retroshare/rsidentity.h b/libretroshare/src/retroshare/rsidentity.h index 82d22e046..815014d22 100644 --- a/libretroshare/src/retroshare/rsidentity.h +++ b/libretroshare/src/retroshare/rsidentity.h @@ -244,14 +244,22 @@ struct RsIdentityUsage : RsSerializable CIRCLE_MEMBERSHIP_CHECK = 0x13 } ; + RS_DEPRECATED RsIdentityUsage( uint16_t service, const RsIdentityUsage::UsageCode& code, const RsGxsGroupId& gid = RsGxsGroupId(), const RsGxsMessageId& mid = RsGxsMessageId(), uint64_t additional_id=0, 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 - uint16_t mServiceId; + RsServiceType mServiceId; /** Specific code to use. Will allow forming the correct translated message * in the GUI if necessary. */ @@ -504,6 +512,14 @@ struct RsIdentity : RsGxsIfaceHelper */ 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 virtual bool getGroupSerializedData( diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index 1853f1529..d1a05225f 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -1153,6 +1153,16 @@ static void mergeIds(std::map >& idmap,const RsGxsId old_peers.push_back(*it) ; } +bool p3IdService::requestIdentity(const RsGxsId& id) +{ + RsIdentityUsage usageInfo( RsServiceType::GXSID, + RsIdentityUsage::IDENTITY_DATA_UPDATE ); + std::list onlinePeers; + + return rsPeers && rsPeers->getOnlineList(onlinePeers) + && requestKey(id, onlinePeers, usageInfo); +} + bool p3IdService::requestKey(const RsGxsId &id, const std::list& peers,const RsIdentityUsage& use_info) { if(id.isNull()) @@ -4680,12 +4690,34 @@ void RsGxsIdGroup::serial_process( 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(service); // G10h4ck: Why uint32 if it's 16 bits? + hs << static_cast(code); + hs << gid; + hs << mid; + hs << static_cast(additional_id); + hs << comment; + + mHash = hs.hash(); +} + RsIdentityUsage::RsIdentityUsage( uint16_t service, const 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) + mServiceId(static_cast(service)), mUsageCode(code), + mGrpId(gid), mMsgId(mid), mAdditionalId(additional_id), mComment(comment) { #ifdef DEBUG_IDS std::cerr << "New identity usage: " << std::endl; @@ -4702,7 +4734,7 @@ RsIdentityUsage::RsIdentityUsage( * be ok. */ 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 << gid ; hs << mid ; @@ -4717,4 +4749,5 @@ RsIdentityUsage::RsIdentityUsage( } RsIdentityUsage::RsIdentityUsage() : - mServiceId(0), mUsageCode(UNKNOWN_USAGE), mAdditionalId(0) {} + mServiceId(RsServiceType::NONE), mUsageCode(UNKNOWN_USAGE), mAdditionalId(0) +{} diff --git a/libretroshare/src/services/p3idservice.h b/libretroshare/src/services/p3idservice.h index 94b6981ec..3152096ce 100644 --- a/libretroshare/src/services/p3idservice.h +++ b/libretroshare/src/services/p3idservice.h @@ -370,6 +370,9 @@ public: virtual bool deserialiseIdentityFromMemory(const std::string& radix_string, RsGxsId* id = nullptr); + /// @see RsIdentity + bool requestIdentity(const RsGxsId& id) override; + /**************** RsGixsReputation Implementation ****************/ // get Reputation. diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 8bd1f0352..d5b6b799b 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -1987,11 +1987,11 @@ QString IdDialog::createUsageString(const RsIdentityUsage& u) const RetroShareLink::enumType service_type = RetroShareLink::TYPE_UNKNOWN; switch(u.mServiceId) - { - case RS_SERVICE_GXS_TYPE_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 RS_SERVICE_GXS_TYPE_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::CHANNELS: service_name = tr("Channels") ;service_type = RetroShareLink::TYPE_CHANNEL ; break ; + case RsServiceType::FORUMS: service_name = tr("Forums") ; service_type = RetroShareLink::TYPE_FORUM ; break ; + case RsServiceType::POSTED: service_name = tr("Posted") ; service_type = RetroShareLink::TYPE_POSTED ; break ; + case RsServiceType::CHAT: service_name = tr("Chat") ; service_type = RetroShareLink::TYPE_CHAT_ROOM ; break ; default: service_name = tr("Unknown"); service_type = RetroShareLink::TYPE_UNKNOWN ; }