mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 08:05:18 -04:00
fixed GUI for distant chat: correct display of peer names, chat window on client shows up when chat is openned. Window on server only shows up when first message is received.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7688 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8480d46eb5
commit
fd20f629dc
5 changed files with 139 additions and 130 deletions
|
@ -36,84 +36,85 @@ static const uint32_t DISTANT_CHAT_AES_KEY_SIZE = 16 ;
|
|||
|
||||
class DistantChatService: public RsTurtleClientService
|
||||
{
|
||||
public:
|
||||
DistantChatService(p3IdService *pids)
|
||||
: mIdService(pids), mDistantChatMtx("distant chat")
|
||||
{
|
||||
mTurtle = NULL ;
|
||||
}
|
||||
public:
|
||||
DistantChatService(p3IdService *pids)
|
||||
: mIdService(pids), mDistantChatMtx("distant chat")
|
||||
{
|
||||
mTurtle = NULL ;
|
||||
}
|
||||
|
||||
void flush() ;
|
||||
void flush() ;
|
||||
|
||||
virtual void connectToTurtleRouter(p3turtle *) ;
|
||||
virtual void connectToTurtleRouter(p3turtle *) ;
|
||||
|
||||
// Creates the invite if the public key of the distant peer is available.
|
||||
// Om success, stores the invite in the map above, so that we can respond to tunnel requests.
|
||||
//
|
||||
bool initiateDistantChatConnexion(const RsGxsId& gxs_id,uint32_t& error_code) ;
|
||||
bool closeDistantChatConnexion(const RsGxsId& pid) ;
|
||||
virtual bool getDistantChatStatus(const RsGxsId &gxs_id,uint32_t &status) ;
|
||||
// Creates the invite if the public key of the distant peer is available.
|
||||
// Om success, stores the invite in the map above, so that we can respond to tunnel requests.
|
||||
//
|
||||
bool initiateDistantChatConnexion(const RsGxsId& gxs_id,uint32_t& error_code) ;
|
||||
bool closeDistantChatConnexion(const RsGxsId& pid) ;
|
||||
virtual bool getDistantChatStatus(const RsGxsId &gxs_id,uint32_t &status) ;
|
||||
|
||||
// derived in p3ChatService
|
||||
virtual void handleIncomingItem(RsItem *) = 0;
|
||||
// derived in p3ChatService
|
||||
virtual void handleIncomingItem(RsItem *) = 0;
|
||||
virtual bool handleRecvChatMsgItem(RsChatMsgItem *ci)=0 ;
|
||||
|
||||
bool handleOutgoingItem(RsChatItem *) ;
|
||||
bool handleRecvItem(RsChatItem *) ;
|
||||
void handleRecvChatStatusItem(RsChatStatusItem *cs) ;
|
||||
bool handleOutgoingItem(RsChatItem *) ;
|
||||
bool handleRecvItem(RsChatItem *) ;
|
||||
void handleRecvChatStatusItem(RsChatStatusItem *cs) ;
|
||||
|
||||
private:
|
||||
class DistantChatPeerInfo
|
||||
{
|
||||
public:
|
||||
DistantChatPeerInfo() { dh = NULL; }
|
||||
private:
|
||||
class DistantChatPeerInfo
|
||||
{
|
||||
public:
|
||||
DistantChatPeerInfo() { dh = NULL; }
|
||||
|
||||
time_t last_contact ; // used to send keep alive packets
|
||||
time_t last_contact ; // used to send keep alive packets
|
||||
|
||||
DH *dh ;
|
||||
unsigned char aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
||||
DH *dh ;
|
||||
unsigned char aes_key[DISTANT_CHAT_AES_KEY_SIZE] ;
|
||||
|
||||
|
||||
uint32_t status ; // info: do we have a tunnel ?
|
||||
RsPeerId virtual_peer_id; // given by the turtle router. Identifies the tunnel.
|
||||
RsGxsId gxs_id ; // gxs id of the peer we're talking to.
|
||||
RsGxsId own_gxs_id ; // gxs id we're using to talk.
|
||||
RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server.
|
||||
};
|
||||
uint32_t status ; // info: do we have a tunnel ?
|
||||
RsPeerId virtual_peer_id; // given by the turtle router. Identifies the tunnel.
|
||||
RsGxsId gxs_id ; // gxs id of the peer we're talking to.
|
||||
RsGxsId own_gxs_id ; // gxs id we're using to talk.
|
||||
RsTurtleGenericTunnelItem::Direction direction ; // specifiec wether we are client(managing the tunnel) or server.
|
||||
};
|
||||
|
||||
// This maps contains the current peers to talk to with distant chat.
|
||||
//
|
||||
std::map<TurtleFileHash,DistantChatPeerInfo> _distant_chat_peers ;
|
||||
// This maps contains the current peers to talk to with distant chat.
|
||||
//
|
||||
std::map<TurtleFileHash,DistantChatPeerInfo> _distant_chat_peers ;
|
||||
|
||||
// List of items to be sent asap. Used to store items that we cannot pass directly to
|
||||
// sendTurtleData(), because of Mutex protection.
|
||||
// List of items to be sent asap. Used to store items that we cannot pass directly to
|
||||
// sendTurtleData(), because of Mutex protection.
|
||||
|
||||
std::list<RsChatItem*> pendingDistantChatItems ;
|
||||
std::list<RsChatItem*> pendingDistantChatItems ;
|
||||
|
||||
// Overloaded from RsTurtleClientService
|
||||
// Overloaded from RsTurtleClientService
|
||||
|
||||
virtual bool handleTunnelRequest(const RsFileHash &hash,const RsPeerId& peer_id) ;
|
||||
virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
||||
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
||||
void markDistantChatAsClosed(const RsGxsId &vpid) ;
|
||||
void startClientDistantChatConnection(const RsFileHash& hash,const RsGxsId& to_gxs_id,const RsGxsId& from_gxs_id) ;
|
||||
bool getHashFromVirtualPeerId(const TurtleVirtualPeerId& pid,RsFileHash& hash) ;
|
||||
TurtleFileHash hashFromGxsId(const RsGxsId& pid) ;
|
||||
virtual bool handleTunnelRequest(const RsFileHash &hash,const RsPeerId& peer_id) ;
|
||||
virtual void receiveTurtleData(RsTurtleGenericTunnelItem *item,const RsFileHash& hash,const RsPeerId& virtual_peer_id,RsTurtleGenericTunnelItem::Direction direction) ;
|
||||
void addVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&,RsTurtleGenericTunnelItem::Direction dir) ;
|
||||
void removeVirtualPeer(const TurtleFileHash&, const TurtleVirtualPeerId&) ;
|
||||
void markDistantChatAsClosed(const RsGxsId &vpid) ;
|
||||
void startClientDistantChatConnection(const RsFileHash& hash,const RsGxsId& to_gxs_id,const RsGxsId& from_gxs_id) ;
|
||||
bool getHashFromVirtualPeerId(const TurtleVirtualPeerId& pid,RsFileHash& hash) ;
|
||||
TurtleFileHash hashFromGxsId(const RsGxsId& pid) ;
|
||||
|
||||
void handleRecvDHPublicKey(RsChatDHPublicKeyItem *item) ;
|
||||
bool locked_sendDHPublicKey(const DistantChatPeerInfo& pinfo) ;
|
||||
bool locked_initDHSessionKey(DistantChatPeerInfo& pinfo);
|
||||
DistantChatPeerId virtualPeerIdFromHash(const TurtleFileHash& hash ) ; // ... and to a hash for p3turtle
|
||||
void handleRecvDHPublicKey(RsChatDHPublicKeyItem *item) ;
|
||||
bool locked_sendDHPublicKey(const DistantChatPeerInfo& pinfo) ;
|
||||
bool locked_initDHSessionKey(DistantChatPeerInfo& pinfo);
|
||||
DistantChatPeerId virtualPeerIdFromHash(const TurtleFileHash& hash ) ; // ... and to a hash for p3turtle
|
||||
|
||||
|
||||
// Utility functions
|
||||
// Utility functions
|
||||
|
||||
void sendTurtleData(RsChatItem *) ;
|
||||
void sendTurtleData(RsChatItem *) ;
|
||||
|
||||
static TurtleFileHash hashFromVirtualPeerId(const DistantChatPeerId& peerId) ; // converts IDs so that we can talk to RsPeerId from outside
|
||||
static TurtleFileHash hashFromVirtualPeerId(const DistantChatPeerId& peerId) ; // converts IDs so that we can talk to RsPeerId from outside
|
||||
|
||||
p3turtle *mTurtle ;
|
||||
p3IdService *mIdService ;
|
||||
p3turtle *mTurtle ;
|
||||
p3IdService *mIdService ;
|
||||
|
||||
RsMutex mDistantChatMtx ;
|
||||
RsMutex mDistantChatMtx ;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue