mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 08:05:18 -04:00
- fixed a few bugs in PopupDistantChatDialog (Possible deadlock, wrong window for private chat)
- added method to properly close distant chat conversation (Still needs some work) - improved chat link creation window + clipboard copy git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6426 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
3f752b9eae
commit
42db43e590
10 changed files with 111 additions and 25 deletions
|
@ -329,6 +329,7 @@ virtual bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_va
|
|||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) = 0;
|
||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) = 0;
|
||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) = 0;
|
||||
virtual bool closeDistantChatConnexion(const std::string& hash) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -360,4 +360,8 @@ bool p3Msgs::getDistantChatStatus(const std::string& hash,uint32_t& status,std::
|
|||
{
|
||||
return mChatSrv->getDistantChatStatus(hash,status,pgp_id) ;
|
||||
}
|
||||
bool p3Msgs::closeDistantChatConnexion(const std::string& hash)
|
||||
{
|
||||
return mChatSrv->closeDistantChatConnexion(hash) ;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,6 +191,7 @@ class p3Msgs: public RsMsgs
|
|||
virtual bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites);
|
||||
virtual bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) ;
|
||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) ;
|
||||
virtual bool closeDistantChatConnexion(const std::string& hash) ;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -2891,6 +2891,7 @@ void p3ChatService::addVirtualPeer(const TurtleFileHash& hash,const TurtleVirtua
|
|||
it->second.last_contact = now ;
|
||||
it->second.status = RS_DISTANT_CHAT_STATUS_TUNNEL_OK ;
|
||||
it->second.virtual_peer_id = virtual_peer_id ;
|
||||
it->second.direction = dir ;
|
||||
|
||||
#ifdef DEBUG_DISTANT_CHAT
|
||||
std::cerr << "(II) Adding virtual peer " << virtual_peer_id << " for chat hash " << hash << std::endl;
|
||||
|
@ -2918,6 +2919,7 @@ void p3ChatService::addVirtualPeer(const TurtleFileHash& hash,const TurtleVirtua
|
|||
info.status = RS_DISTANT_CHAT_STATUS_TUNNEL_OK ;
|
||||
info.virtual_peer_id = virtual_peer_id ;
|
||||
info.pgp_id = it->second.destination_pgp_id ;
|
||||
info.direction = dir ;
|
||||
memcpy(info.aes_key,it->second.aes_key,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||
|
||||
_distant_chat_peers[hash] = info ;
|
||||
|
@ -2926,8 +2928,6 @@ void p3ChatService::addVirtualPeer(const TurtleFileHash& hash,const TurtleVirtua
|
|||
|
||||
rsicontrol->getNotify().notifyChatStatus(hash,"tunnel is up again!",true) ;
|
||||
rsicontrol->getNotify().notifyPeerStatusChanged(hash,RS_STATUS_ONLINE) ;
|
||||
|
||||
getPqiNotify()->AddPopupMessage(RS_POPUP_CHAT, hash, "Distant peer", "Conversation starts...");
|
||||
}
|
||||
|
||||
void p3ChatService::removeVirtualPeer(const TurtleFileHash& hash,const TurtleVirtualPeerId& virtual_peer_id)
|
||||
|
@ -3079,7 +3079,7 @@ void p3ChatService::sendTurtleData(RsChatItem *item)
|
|||
|
||||
if(it == _distant_chat_peers.end())
|
||||
{
|
||||
std::cerr << "(EE) item is not coming out of a registered tunnel. Weird. peer id = " << virtual_peer_id << std::endl;
|
||||
std::cerr << "(EE) item is not going into a registered tunnel. Weird. peer id = " << virtual_peer_id << std::endl;
|
||||
delete[] buff ;
|
||||
return ;
|
||||
}
|
||||
|
@ -3285,6 +3285,7 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
|||
info.last_contact = time(NULL) ;
|
||||
info.status = RS_DISTANT_CHAT_STATUS_TUNNEL_DN ;
|
||||
info.pgp_id = pgp_id.toStdString() ;
|
||||
info.direction = RsTurtleGenericTunnelItem::DIRECTION_SERVER ;
|
||||
memcpy(info.aes_key,data+DISTANT_CHAT_HASH_SIZE,DISTANT_CHAT_AES_KEY_SIZE) ;
|
||||
|
||||
_distant_chat_peers[hash] = info ;
|
||||
|
@ -3302,6 +3303,8 @@ bool p3ChatService::initiateDistantChatConnexion(const std::string& encrypted_st
|
|||
// And notify about chatting.
|
||||
|
||||
error_code = RS_DISTANT_CHAT_ERROR_NO_ERROR ;
|
||||
|
||||
getPqiNotify()->AddPopupMessage(RS_POPUP_CHAT, hash, "Distant peer", "Conversation starts...");
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
@ -3359,7 +3362,10 @@ bool p3ChatService::getDistantChatStatus(const std::string& hash,uint32_t& statu
|
|||
std::map<TurtleFileHash,DistantChatPeerInfo>::const_iterator it = _distant_chat_peers.find(hash) ;
|
||||
|
||||
if(it == _distant_chat_peers.end())
|
||||
{
|
||||
status = RS_DISTANT_CHAT_STATUS_UNKNOWN ;
|
||||
return false ;
|
||||
}
|
||||
|
||||
status = it->second.status ;
|
||||
pgp_id = it->second.pgp_id ;
|
||||
|
@ -3367,6 +3373,40 @@ bool p3ChatService::getDistantChatStatus(const std::string& hash,uint32_t& statu
|
|||
return true ;
|
||||
}
|
||||
|
||||
bool p3ChatService::closeDistantChatConnexion(const std::string& hash)
|
||||
{
|
||||
// two cases:
|
||||
// - client needs to stop asking for tunnels => remove the hash from the list of tunnelled files
|
||||
// - server needs to only close the window and let the tunnel die. But the window should only open if a message arrives.
|
||||
|
||||
RsStackMutex stack(mChatMtx); /********** STACK LOCKED MTX ******/
|
||||
|
||||
std::map<std::string,DistantChatPeerInfo>::iterator it = _distant_chat_peers.find(hash) ;
|
||||
|
||||
if(it == _distant_chat_peers.end()) // server side. Nothing to do.
|
||||
{
|
||||
std::cerr << "Cannot close chat associated to hash " << hash << ": not found." << std::endl;
|
||||
return false ;
|
||||
}
|
||||
|
||||
// We can't do just that. We should:
|
||||
// - mark the peer as closing, but not closed. If the tunnel gets deleted because of no traffic, then stop monitor
|
||||
// it. That can be done in removeVirtualPeer
|
||||
//
|
||||
if(it->second.direction == RsTurtleGenericTunnelItem::DIRECTION_SERVER)
|
||||
{
|
||||
// Client side: Stop tunnels
|
||||
//
|
||||
std::cerr << "This is client side. Stopping tunnel manageement for hash " << hash << std::endl;
|
||||
mTurtle->stopMonitoringTunnels(hash) ;
|
||||
|
||||
// and remove hash from list of current peers.
|
||||
_distant_chat_peers.erase(it) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -313,6 +313,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
|||
bool createDistantChatInvite(const std::string& pgp_id,time_t time_of_validity,TurtleFileHash& hash) ;
|
||||
bool getDistantChatInviteList(std::vector<DistantChatInviteInfo>& invites) ;
|
||||
bool initiateDistantChatConnexion(const std::string& encrypted_string,std::string& hash,uint32_t& error_code) ;
|
||||
bool closeDistantChatConnexion(const std::string& hash) ;
|
||||
|
||||
virtual bool getDistantChatStatus(const std::string& hash,uint32_t& status,std::string& pgp_id) ;
|
||||
|
||||
|
@ -332,6 +333,7 @@ class p3ChatService: public p3Service, public p3Config, public pqiMonitor, publi
|
|||
uint32_t status ; // info: do we have a tunnel ?
|
||||
std::string virtual_peer_id; // given by the turtle router. Identifies the tunnel.
|
||||
std::string pgp_id ; // pgp id of the peer we're talking to.
|
||||
RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server.
|
||||
};
|
||||
|
||||
// This map contains the ongoing invites. This is the list where to look to
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue