mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-02 14:16:16 -04:00
added notifiction of denying conversation for distant chat
This commit is contained in:
parent
9dfac71822
commit
a80a6669b6
6 changed files with 41 additions and 8 deletions
|
@ -106,6 +106,12 @@ bool DistantChatService::handleOutgoingItem(RsChatItem *item)
|
|||
|
||||
void DistantChatService::handleRecvChatStatusItem(RsChatStatusItem *cs)
|
||||
{
|
||||
if(cs->flags & RS_CHAT_FLAG_CONNEXION_REFUSED)
|
||||
{
|
||||
std::cerr << "(II) Distant chat: received notification that peer refuses conversation." << std::endl;
|
||||
RsServer::notify()->notifyChatStatus(ChatId(DistantChatPeerId(cs->PeerId())),"Connexion refused by distant peer!") ;
|
||||
}
|
||||
|
||||
if(cs->flags & RS_CHAT_FLAG_CLOSING_DISTANT_CONNECTION)
|
||||
markDistantChatAsClosed(DistantChatPeerId(cs->PeerId())) ;
|
||||
|
||||
|
@ -115,15 +121,41 @@ void DistantChatService::handleRecvChatStatusItem(RsChatStatusItem *cs)
|
|||
std::cerr << "DistantChatService::handleRecvChatStatusItem(): received keep alive packet for inactive chat! peerId=" << cs->PeerId() << std::endl;
|
||||
}
|
||||
|
||||
bool DistantChatService::acceptDataFromPeer(const RsGxsId& gxs_id)
|
||||
bool DistantChatService::acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTunnelId& tunnel_id)
|
||||
{
|
||||
bool res = true ;
|
||||
|
||||
if(mDistantChatPermissions & RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_NON_CONTACTS)
|
||||
return (rsIdentity!=NULL) && rsIdentity->isARegularContact(gxs_id) ;
|
||||
res = (rsIdentity!=NULL) && rsIdentity->isARegularContact(gxs_id) ;
|
||||
|
||||
if(mDistantChatPermissions & RS_DISTANT_CHAT_CONTACT_PERMISSION_FLAG_FILTER_EVERYBODY)
|
||||
return false ;
|
||||
res = false ;
|
||||
|
||||
return true ;
|
||||
if(!res)
|
||||
{
|
||||
std::cerr << "(II) refusing distant chat from peer " << gxs_id << ". Sending a notification back to tunnel " << tunnel_id << std::endl;
|
||||
RsChatStatusItem *item = new RsChatStatusItem ;
|
||||
item->flags = RS_CHAT_FLAG_CONNEXION_REFUSED ;
|
||||
item->status_string.clear() ; // is not used yet! But could be set in GUI to some message (??).
|
||||
item->PeerId(RsPeerId(tunnel_id)) ;
|
||||
|
||||
// we do not use handleOutGoingItem() because there's no distant chat contact, as the chat is refused.
|
||||
|
||||
uint32_t size = item->serial_size() ;
|
||||
RsTemporaryMemory mem(size) ;
|
||||
|
||||
if(!item->serialise(mem,size))
|
||||
{
|
||||
std::cerr << "(EE) serialisation error. Something's really wrong!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::cerr << " sending: " << RsUtil::BinToHex(mem,size) << std::endl;
|
||||
|
||||
mGxsTunnels->sendData( RsGxsTunnelId(item->PeerId()),DISTANT_CHAT_GXS_TUNNEL_SERVICE_ID,mem,size);
|
||||
}
|
||||
|
||||
return res ;
|
||||
}
|
||||
|
||||
void DistantChatService::notifyTunnelStatus(const RsGxsTunnelService::RsGxsTunnelId &tunnel_id, uint32_t tunnel_status)
|
||||
|
|
|
@ -89,7 +89,7 @@ public:
|
|||
virtual void connectToGxsTunnelService(RsGxsTunnelService *tunnel_service) ;
|
||||
|
||||
private:
|
||||
virtual bool acceptDataFromPeer(const RsGxsId& gxs_id) ;
|
||||
virtual bool acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTunnelService::RsGxsTunnelId& tunnel_id) ;
|
||||
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) ;
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ const uint32_t RS_CHAT_FLAG_LOBBY = 0x0200;
|
|||
const uint32_t RS_CHAT_FLAG_CLOSING_DISTANT_CONNECTION = 0x0400;
|
||||
const uint32_t RS_CHAT_FLAG_ACK_DISTANT_CONNECTION = 0x0800;
|
||||
const uint32_t RS_CHAT_FLAG_KEEP_ALIVE = 0x1000;
|
||||
const uint32_t RS_CHAT_FLAG_CONNEXION_REFUSED = 0x2000;
|
||||
|
||||
const uint32_t RS_CHATMSG_CONFIGFLAG_INCOMING = 0x0001;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue