mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-23 08:11:24 -04:00
Safer rsids API
Deprecate unsafe costructor, substituted by fromBufferUnsafe which explicitely marked suggest the caller to pay attention. Use enum class for id types instead of constants Make size constants more private Use internal Id_t alias to avoid huge template lines Remove and deprecate oguly names in favor of consistent names
This commit is contained in:
parent
ccf7dc24b8
commit
7642216912
12 changed files with 337 additions and 267 deletions
|
@ -67,13 +67,10 @@ uint32_t msecs_of_day()
|
|||
|
||||
static const uint32_t DISTANT_CHAT_GXS_TUNNEL_SERVICE_ID = 0xa0001 ;
|
||||
|
||||
typedef RsGxsTunnelService::RsGxsTunnelId RsGxsTunnelId;
|
||||
|
||||
DistantChatService::DistantChatService() : mDistantChatMtx("distant chat")
|
||||
{
|
||||
mGxsTunnels = NULL ;
|
||||
mDistantChatPermissions = RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NONE ; // default: accept everyone
|
||||
}
|
||||
DistantChatService::DistantChatService() :
|
||||
// default: accept everyone
|
||||
mDistantChatPermissions(RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NONE),
|
||||
mGxsTunnels(nullptr), mDistantChatMtx("distant chat") {}
|
||||
|
||||
void DistantChatService::connectToGxsTunnelService(RsGxsTunnelService *tr)
|
||||
{
|
||||
|
@ -181,7 +178,8 @@ bool DistantChatService::acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTun
|
|||
return res ;
|
||||
}
|
||||
|
||||
void DistantChatService::notifyTunnelStatus(const RsGxsTunnelService::RsGxsTunnelId &tunnel_id, uint32_t tunnel_status)
|
||||
void DistantChatService::notifyTunnelStatus(
|
||||
const RsGxsTunnelId& tunnel_id, uint32_t tunnel_status )
|
||||
{
|
||||
#ifdef DEBUG_DISTANT_CHAT
|
||||
DISTANT_CHAT_DEBUG() << "DistantChatService::notifyTunnelStatus(): got notification " << std::hex << tunnel_status << std::dec << " for tunnel " << tunnel_id << std::endl;
|
||||
|
@ -207,7 +205,8 @@ void DistantChatService::notifyTunnelStatus(const RsGxsTunnelService::RsGxsTunne
|
|||
}
|
||||
}
|
||||
|
||||
void DistantChatService::receiveData(const RsGxsTunnelService::RsGxsTunnelId &tunnel_id, unsigned char *data, uint32_t data_size)
|
||||
void DistantChatService::receiveData(
|
||||
const RsGxsTunnelId& tunnel_id, unsigned char* data, uint32_t data_size)
|
||||
{
|
||||
#ifdef DEBUG_DISTANT_CHAT
|
||||
DISTANT_CHAT_DEBUG() << "DistantChatService::receiveData(): got data of size " << std::dec << data_size << " for tunnel " << tunnel_id << std::endl;
|
||||
|
@ -249,7 +248,8 @@ void DistantChatService::receiveData(const RsGxsTunnelService::RsGxsTunnelId &tu
|
|||
|
||||
void DistantChatService::markDistantChatAsClosed(const DistantChatPeerId& dcpid)
|
||||
{
|
||||
mGxsTunnels->closeExistingTunnel(RsGxsTunnelService::RsGxsTunnelId(dcpid),DISTANT_CHAT_GXS_TUNNEL_SERVICE_ID) ;
|
||||
mGxsTunnels->closeExistingTunnel(
|
||||
RsGxsTunnelId(dcpid), DISTANT_CHAT_GXS_TUNNEL_SERVICE_ID );
|
||||
|
||||
RS_STACK_MUTEX(mDistantChatMtx) ;
|
||||
|
||||
|
|
|
@ -30,12 +30,13 @@ class RsGixs ;
|
|||
|
||||
static const uint32_t DISTANT_CHAT_AES_KEY_SIZE = 16 ;
|
||||
|
||||
/**
|
||||
* Public interface only uses DistandChatPeerId, but internally, this is
|
||||
* converted into a RsGxsTunnelId
|
||||
*/
|
||||
class DistantChatService: public RsGxsTunnelService::RsGxsTunnelClientService
|
||||
{
|
||||
public:
|
||||
// So, public interface only uses DistandChatPeerId, but internally, this is converted into a RsGxsTunnelService::RsGxsTunnelId
|
||||
|
||||
|
||||
DistantChatService() ;
|
||||
|
||||
virtual void triggerConfigSave()=0 ;
|
||||
|
@ -91,9 +92,13 @@ public:
|
|||
virtual void connectToGxsTunnelService(RsGxsTunnelService *tunnel_service) ;
|
||||
|
||||
private:
|
||||
virtual bool acceptDataFromPeer(const RsGxsId& gxs_id, const RsGxsTunnelService::RsGxsTunnelId& tunnel_id, bool am_I_client_side) ;
|
||||
virtual void notifyTunnelStatus(const RsGxsTunnelService::RsGxsTunnelId& tunnel_id,uint32_t tunnel_status) ;
|
||||
virtual void receiveData(const RsGxsTunnelService::RsGxsTunnelId& id,unsigned char *data,uint32_t data_size) ;
|
||||
virtual bool acceptDataFromPeer(
|
||||
const RsGxsId& gxs_id, const RsGxsTunnelId& tunnel_id,
|
||||
bool am_I_client_side);
|
||||
virtual void notifyTunnelStatus(
|
||||
const RsGxsTunnelId& tunnel_id, uint32_t tunnel_status);
|
||||
virtual void receiveData(
|
||||
const RsGxsTunnelId& id, unsigned char* data, uint32_t data_size );
|
||||
|
||||
// Utility functions.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue