mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 06:06:10 -04:00
fixed compilation, added missing methods for new distant chat
This commit is contained in:
parent
6ca49a2d98
commit
a29f15ae32
13 changed files with 124 additions and 46 deletions
|
@ -97,7 +97,7 @@ bool DistantChatService::handleOutgoingItem(RsChatItem *item)
|
|||
void DistantChatService::handleRecvChatStatusItem(RsChatStatusItem *cs)
|
||||
{
|
||||
if(cs->flags & RS_CHAT_FLAG_CLOSING_DISTANT_CONNECTION)
|
||||
markDistantChatAsClosed(RsGxsId(cs->PeerId())) ;
|
||||
markDistantChatAsClosed(DistantChatPeerId(cs->PeerId())) ;
|
||||
|
||||
// nothing more to do, because the decryption routing will update the last_contact time when decrypting.
|
||||
|
||||
|
@ -105,6 +105,30 @@ void DistantChatService::handleRecvChatStatusItem(RsChatStatusItem *cs)
|
|||
std::cerr << "DistantChatService::handleRecvChatStatusItem(): received keep alive packet for inactive chat! peerId=" << cs->PeerId() << std::endl;
|
||||
}
|
||||
|
||||
void DistantChatService::notifyTunnelStatus(const RsGxsTunnelService::RsGxsTunnelId &tunnel_id, uint32_t tunnel_status)
|
||||
{
|
||||
std::cerr << "DistantChatService::notifyTunnelStatus(): got notification " << std::hex << tunnel_status << std::dec << " for tunnel " << tunnel_id << std::endl;
|
||||
#warning do something here
|
||||
}
|
||||
|
||||
void DistantChatService::receiveData(const RsGxsTunnelService::RsGxsTunnelId &tunnel_id, unsigned char *data, uint32_t data_size)
|
||||
{
|
||||
std::cerr << "DistantChatService::receiveData(): got data of size " << data_size << " for tunnel " << tunnel_id << std::endl;
|
||||
#warning do something here
|
||||
}
|
||||
|
||||
void DistantChatService::markDistantChatAsClosed(const DistantChatPeerId& dcpid)
|
||||
{
|
||||
mGxsTunnels->closeExistingTunnel(RsGxsTunnelService::RsGxsTunnelId(dcpid)) ;
|
||||
|
||||
RS_STACK_MUTEX(mDistantChatMtx) ;
|
||||
|
||||
std::map<DistantChatPeerId,DistantChatContact>::iterator it = mDistantChatContacts.find(dcpid) ;
|
||||
|
||||
if(it != mDistantChatContacts.end())
|
||||
mDistantChatContacts.erase(it) ;
|
||||
}
|
||||
|
||||
bool DistantChatService::initiateDistantChatConnexion(const RsGxsId& to_gxs_id, const RsGxsId& from_gxs_id, DistantChatPeerId& dcpid, uint32_t& error_code)
|
||||
{
|
||||
RsGxsTunnelId tunnel_id ;
|
||||
|
@ -130,7 +154,7 @@ bool DistantChatService::getDistantChatStatus(const DistantChatPeerId& tunnel_id
|
|||
|
||||
RsGxsTunnelService::GxsTunnelInfo tinfo ;
|
||||
|
||||
if(!mGxsTunnels->getGxsTunnelInfo(RsGxsTunnelId(tunnel_id),tinfo))
|
||||
if(!mGxsTunnels->getTunnelInfo(RsGxsTunnelId(tunnel_id),tinfo))
|
||||
return false;
|
||||
|
||||
cinfo.to_id = tinfo.destination_gxs_id;
|
||||
|
|
|
@ -44,6 +44,8 @@ public:
|
|||
mGxsTunnels = NULL ;
|
||||
}
|
||||
|
||||
// Overloaded methods from RsGxsTunnelClientService
|
||||
|
||||
virtual void connectToGxsTunnelService(RsGxsTunnelService *tunnel_service) ;
|
||||
|
||||
// Creates the invite if the public key of the distant peer is available.
|
||||
|
@ -79,8 +81,7 @@ private:
|
|||
|
||||
// Utility functions.
|
||||
|
||||
void markDistantChatAsClosed(const RsGxsId &gxs_id) ;
|
||||
void startClientDistantChatConnection(const RsGxsId &to_gxs_id,const RsGxsId& from_gxs_id) ;
|
||||
void markDistantChatAsClosed(const DistantChatPeerId& dcpid) ;
|
||||
|
||||
RsGxsTunnelService *mGxsTunnels ;
|
||||
|
||||
|
|
|
@ -500,11 +500,11 @@ void p3ChatService::handleIncomingItem(RsItem *item)
|
|||
return ; // don't delete! It's handled by handleRecvChatMsgItem in some specific cases only.
|
||||
}
|
||||
|
||||
if(DistantChatService::handleRecvItem(dynamic_cast<RsChatItem*>(item)))
|
||||
{
|
||||
delete item ;
|
||||
return ;
|
||||
}
|
||||
// if(DistantChatService::handleRecvItem(dynamic_cast<RsChatItem*>(item)))
|
||||
// {
|
||||
// delete item ;
|
||||
// return ;
|
||||
// }
|
||||
|
||||
if(DistributedChatService::handleRecvItem(dynamic_cast<RsChatItem*>(item)))
|
||||
{
|
||||
|
|
|
@ -58,6 +58,8 @@ static const uint32_t RS_GXS_TUNNEL_DELAY_BETWEEN_RESEND = 10 ; // re-send ever
|
|||
static const uint32_t GXS_TUNNEL_ENCRYPTION_HMAC_SIZE = SHA_DIGEST_LENGTH ;
|
||||
static const uint32_t GXS_TUNNEL_ENCRYPTION_IV_SIZE = 8 ;
|
||||
|
||||
RsGxsTunnelService *rsGxsTunnel = NULL ;
|
||||
|
||||
p3GxsTunnelService::p3GxsTunnelService(RsGixs *pids)
|
||||
: mGixs(pids), mGxsTunnelMtx("GXS tunnel")
|
||||
{
|
||||
|
@ -73,6 +75,22 @@ void p3GxsTunnelService::connectToTurtleRouter(p3turtle *tr)
|
|||
tr->registerTunnelService(this) ;
|
||||
}
|
||||
|
||||
bool p3GxsTunnelService::registerClientService(uint32_t service_id,RsGxsTunnelService::RsGxsTunnelClientService *service)
|
||||
{
|
||||
RS_STACK_MUTEX(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
if(mRegisteredServices.find(service_id) != mRegisteredServices.end())
|
||||
{
|
||||
std::cerr << "(EE) p3GxsTunnelService::registerClientService(): trying to register client " << std::hex << service_id << std::dec << ", which is already registered!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cerr << "p3GxsTunnelService::registerClientService(): registering client service " << std::hex << service_id << std::dec << std::endl;
|
||||
|
||||
mRegisteredServices[service_id] = service ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
void p3GxsTunnelService::flush()
|
||||
{
|
||||
// Flush pending DH items. This is a higher priority, so we deal with them first.
|
||||
|
@ -1193,6 +1211,31 @@ RsGxsId p3GxsTunnelService::destinationGxsIdFromHash(const TurtleFileHash& sum)
|
|||
return RsGxsId(sum.toByteArray());// takes the first 16 bytes
|
||||
}
|
||||
|
||||
bool p3GxsTunnelService::getTunnelInfo(const RsGxsTunnelId& tunnel_id,GxsTunnelInfo& info)
|
||||
{
|
||||
RsStackMutex stack(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<RsGxsTunnelId,GxsTunnelPeerInfo>::const_iterator it = _gxs_tunnel_contacts.find(tunnel_id) ;
|
||||
|
||||
if(it == _gxs_tunnel_contacts.end())
|
||||
return false ;
|
||||
|
||||
info.destination_gxs_id = it->second.to_gxs_id;
|
||||
info.source_gxs_id = it->second.own_gxs_id;
|
||||
info.tunnel_status = it->second.status;
|
||||
#warning data missing here
|
||||
info.total_size_sent = 0;
|
||||
info.total_size_received= 0;
|
||||
|
||||
// Data packets
|
||||
|
||||
info.pending_data_packets = 0;
|
||||
info.total_data_packets_sent=0 ;
|
||||
info.total_data_packets_received=0 ;
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
bool p3GxsTunnelService::getTunnelStatus(const RsGxsTunnelId& tunnel_id,uint32_t& status)
|
||||
{
|
||||
RsStackMutex stack(mGxsTunnelMtx); /********** STACK LOCKED MTX ******/
|
||||
|
|
|
@ -126,6 +126,7 @@ public:
|
|||
|
||||
virtual bool closeExistingTunnel(const RsGxsTunnelId &tunnel_id) ;
|
||||
virtual bool getTunnelStatus(const RsGxsTunnelId& tunnel_id,uint32_t &status);
|
||||
virtual bool getTunnelInfo(const RsGxsTunnelId& tunnel_id,GxsTunnelInfo& info);
|
||||
virtual bool sendData(const RsGxsTunnelId& tunnel_id,uint32_t service_id,const uint8_t *data,uint32_t size) ;
|
||||
|
||||
virtual bool registerClientService(uint32_t service_id,RsGxsTunnelClientService *service) ;
|
||||
|
|
|
@ -333,7 +333,7 @@ bool RsGxsTunnelDataAckItem::serialise(void *data, uint32_t& pktsize)
|
|||
|
||||
/*************************************************************************/
|
||||
|
||||
RsGxsTunnelDHPublicKeyItem *deserialise_RsGxsTunnelDHPublicKeyItem(void *data,uint32_t /*size*/)
|
||||
RsGxsTunnelDHPublicKeyItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelDHPublicKeyItem(void *data,uint32_t /*size*/)
|
||||
{
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
@ -367,7 +367,7 @@ RsGxsTunnelDHPublicKeyItem *deserialise_RsGxsTunnelDHPublicKeyItem(void *data,ui
|
|||
return item ;
|
||||
}
|
||||
|
||||
RsGxsTunnelDataItem *deserialise_RsGxsTunnelDataItem(void *dat,uint32_t size)
|
||||
RsGxsTunnelDataItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelDataItem(void *dat,uint32_t size)
|
||||
{
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(dat);
|
||||
|
@ -415,7 +415,7 @@ RsGxsTunnelDataItem *deserialise_RsGxsTunnelDataItem(void *dat,uint32_t size)
|
|||
return item ;
|
||||
}
|
||||
|
||||
RsGxsTunnelDataAckItem *deserialise_RsGxsTunnelDataAckItem(void *dat,uint32_t /* size */)
|
||||
RsGxsTunnelDataAckItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelDataAckItem(void *dat,uint32_t /* size */)
|
||||
{
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(dat);
|
||||
|
@ -443,7 +443,7 @@ RsGxsTunnelDataAckItem *deserialise_RsGxsTunnelDataAckItem(void *dat,uint32_t /*
|
|||
return item ;
|
||||
}
|
||||
|
||||
RsGxsTunnelStatusItem *deserialise_RsGxsTunnelStatusItem(void *dat,uint32_t size)
|
||||
RsGxsTunnelStatusItem *RsGxsTunnelSerialiser::deserialise_RsGxsTunnelStatusItem(void *dat,uint32_t size)
|
||||
{
|
||||
uint32_t offset = 8; // skip the header
|
||||
uint32_t rssize = getRsItemSize(dat);
|
||||
|
|
|
@ -86,7 +86,7 @@ public:
|
|||
//===================================================//
|
||||
|
||||
//virtual bool getGxsTunnelsInfo(std::vector<GxsTunnelInfo>& infos) =0;
|
||||
//virtual bool getGxsTunnelInfo(const RsGxsTunnelId& tunnel_id,GxsTunnelInfo& info) =0;
|
||||
virtual bool getTunnelInfo(const RsGxsTunnelId& tunnel_id,GxsTunnelInfo& info) =0;
|
||||
|
||||
// retrieve the routing probabilities
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue