Improve async distant chat, fix chat msg receiving

DistantChatService::initiateDistantChatConnexion(...) made notification
  message optional (enabled by default)
p3ChatService removed duplicion avoidance as it is not necessary
p3ChatService::sendStatusString(...) send status only if peer is online
protect p3ChatService::mDistantGxsMap with mutex as operation on it may
  be done by different threads
p3ChatService::receiveGxsMai(...) set chat message item peer id with
  distant tunnel id, so it is recognized as a distant message later
made p3GxsTunnelService::makeGxsTunnelId(...) static as it need no
  access to this, now it can be used easier by other components
rename RsGxsMailItem::recipientsHint to recipientHint as for now only
  one recipient is possible (TODO: update documentation too)
GxsMailsClient::receiveGxsMail(...) changed paramethers for better
  abstracion, now destination id is passed too because it is usually a
  very useful information
ChatWidget some adaptation to async chat, a couple of method have been
  deprecated too
PopupDistantChatDialog::updateDisplay(...) adapt message shown to the
  user to the new async chat paradigm (TODO: need review)
This commit is contained in:
Gioacchino Mazzurco 2017-03-01 23:07:53 +01:00
parent 0f1106fd8f
commit 953b70fbe4
14 changed files with 212 additions and 212 deletions

View file

@ -1023,7 +1023,8 @@ void p3GxsTunnelService::handleRecvDHPublicKey(RsGxsTunnelDHPublicKeyItem *item)
// Note: for some obscure reason, the typedef does not work here. Looks like a compiler error. So I use the primary type.
GXSTunnelId p3GxsTunnelService::makeGxsTunnelId(const RsGxsId &own_id, const RsGxsId &distant_id) const // creates a unique ID from two GXS ids.
/*static*/ GXSTunnelId p3GxsTunnelService::makeGxsTunnelId(
const RsGxsId &own_id, const RsGxsId &distant_id )
{
unsigned char mem[RsGxsId::SIZE_IN_BYTES * 2] ;
@ -1240,18 +1241,20 @@ bool p3GxsTunnelService::locked_sendEncryptedTunnelData(RsGxsTunnelItem *item)
std::map<RsGxsTunnelId,GxsTunnelPeerInfo>::iterator it = _gxs_tunnel_contacts.find(tunnel_id) ;
if(it == _gxs_tunnel_contacts.end())
{
if(it == _gxs_tunnel_contacts.end())
{
#ifdef DEBUG_GXS_TUNNEL
std::cerr << " Cannot find contact key info for tunnel id " << tunnel_id << ". Cannot send message!" << std::endl;
std::cerr << " Cannot find contact key info for tunnel id "
<< tunnel_id << ". Cannot send message!" << std::endl;
#endif
return false;
}
if(it->second.status != RS_GXS_TUNNEL_STATUS_CAN_TALK)
{
std::cerr << "(EE) Cannot talk to tunnel id " << tunnel_id << ". Tunnel status is: " << it->second.status << std::endl;
return false;
}
return false;
}
if(it->second.status != RS_GXS_TUNNEL_STATUS_CAN_TALK)
{
std::cerr << "(EE) Cannot talk to tunnel id " << tunnel_id
<< ". Tunnel status is: " << it->second.status << std::endl;
return false;
}
it->second.total_sent += rssize ; // counts the size of clear data that is sent

View file

@ -232,7 +232,6 @@ private:
bool locked_initDHSessionKey(DH *&dh);
TurtleVirtualPeerId virtualPeerIdFromHash(const TurtleFileHash& hash) ; // ... and to a hash for p3turtle
RsGxsTunnelId makeGxsTunnelId(const RsGxsId &own_id, const RsGxsId &distant_id) const; // creates a unique ID from two GXS ids.
// item handling
@ -256,5 +255,10 @@ private:
std::map<uint32_t,RsGxsTunnelClientService*> mRegisteredServices ;
void debug_dump();
public:
/// creates a unique tunnel ID from two GXS ids.
static RsGxsTunnelId makeGxsTunnelId( const RsGxsId &own_id,
const RsGxsId &distant_id );
};