diff --git a/libretroshare/src/chat/distantchat.cc b/libretroshare/src/chat/distantchat.cc index cc372b01c..621e92229 100644 --- a/libretroshare/src/chat/distantchat.cc +++ b/libretroshare/src/chat/distantchat.cc @@ -178,8 +178,7 @@ bool DistantChatService::acceptDataFromPeer(const RsGxsId& gxs_id,const RsGxsTun return res ; } -void DistantChatService::notifyTunnelStatus( - const RsGxsTunnelId& tunnel_id, uint32_t tunnel_status ) +void DistantChatService::notifyTunnelStatus( const RsGxsTunnelId& tunnel_id, uint32_t tunnel_status ) { #ifdef DEBUG_DISTANT_CHAT DISTANT_CHAT_DEBUG() << "DistantChatService::notifyTunnelStatus(): got notification " << std::hex << tunnel_status << std::dec << " for tunnel " << tunnel_id << std::endl; @@ -195,18 +194,17 @@ void DistantChatService::notifyTunnelStatus( RsServer::notify()->notifyPeerStatusChanged(tunnel_id.toStdString(),RS_STATUS_ONLINE) ; break ; - case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_TUNNEL_DN: RsServer::notify()->notifyChatStatus(ChatId(DistantChatPeerId(tunnel_id)),"tunnel is down...") ; + case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_TUNNEL_DN: RsServer::notify()->notifyChatStatus(ChatId(DistantChatPeerId(tunnel_id)),"Tunnel is down...") ; RsServer::notify()->notifyPeerStatusChanged(tunnel_id.toStdString(),RS_STATUS_OFFLINE) ; break ; - case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_REMOTELY_CLOSED: RsServer::notify()->notifyChatStatus(ChatId(DistantChatPeerId(tunnel_id)),"tunnel is down...") ; + case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_REMOTELY_CLOSED: RsServer::notify()->notifyChatStatus(ChatId(DistantChatPeerId(tunnel_id)),"Tunnel is down...") ; RsServer::notify()->notifyPeerStatusChanged(tunnel_id.toStdString(),RS_STATUS_OFFLINE) ; break ; } } -void DistantChatService::receiveData( - const RsGxsTunnelId& tunnel_id, unsigned char* data, uint32_t data_size) +void DistantChatService::receiveData( const RsGxsTunnelId& tunnel_id, unsigned char* data, uint32_t data_size) { #ifdef DEBUG_DISTANT_CHAT DISTANT_CHAT_DEBUG() << "DistantChatService::receiveData(): got data of size " << std::dec << data_size << " for tunnel " << tunnel_id << std::endl; @@ -303,16 +301,14 @@ bool DistantChatService::getDistantChatStatus(const DistantChatPeerId& tunnel_id cinfo.to_id = tinfo.destination_gxs_id; cinfo.own_id = tinfo.source_gxs_id; + cinfo.pending_items = tinfo.pending_data_packets; cinfo.peer_id = tunnel_id; switch(tinfo.tunnel_status) { - case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_CAN_TALK : - cinfo.status = RS_DISTANT_CHAT_STATUS_CAN_TALK; break; - case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_TUNNEL_DN: - cinfo.status = RS_DISTANT_CHAT_STATUS_TUNNEL_DN; break; - case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_REMOTELY_CLOSED: - cinfo.status = RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED; break; + case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_CAN_TALK : cinfo.status = RS_DISTANT_CHAT_STATUS_CAN_TALK; break; + case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_TUNNEL_DN: cinfo.status = RS_DISTANT_CHAT_STATUS_TUNNEL_DN; break; + case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_REMOTELY_CLOSED: cinfo.status = RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED; break; case RsGxsTunnelService::RS_GXS_TUNNEL_STATUS_UNKNOWN: default: cinfo.status = RS_DISTANT_CHAT_STATUS_UNKNOWN; break; diff --git a/libretroshare/src/gxstunnel/p3gxstunnel.cc b/libretroshare/src/gxstunnel/p3gxstunnel.cc index 5f75c633b..0a1a45024 100644 --- a/libretroshare/src/gxstunnel/p3gxstunnel.cc +++ b/libretroshare/src/gxstunnel/p3gxstunnel.cc @@ -1596,7 +1596,13 @@ bool p3GxsTunnelService::getTunnelInfo(const RsGxsTunnelId& tunnel_id,GxsTunnelI // Data packets - info.pending_data_packets = 0; + info.pending_data_packets = 0; + RsPeerId p(tunnel_id); + + for(auto it(pendingGxsTunnelDataItems.begin());it!=pendingGxsTunnelDataItems.end();++it) + if(it->second.data_item->PeerId() == p) + ++info.pending_data_packets ; + info.total_data_packets_sent=0 ; info.total_data_packets_received=0 ; @@ -1704,7 +1710,16 @@ bool p3GxsTunnelService::getTunnelsInfo(std::vectorsecond.status ; ti.total_size_sent = it->second.total_sent ; ti.total_size_received = it->second.total_received ; - + + ti.pending_data_packets = 0; + RsPeerId p(it->first); + for(auto it(pendingGxsTunnelDataItems.begin());it!=pendingGxsTunnelDataItems.end();++it) + if(it->second.data_item->PeerId() == p) + ++ti.pending_data_packets ; + + ti.total_data_packets_sent =0; // not accounted for yet. + ti.total_data_packets_received=0 ; // not accounted for yet. + infos.push_back(ti) ; } diff --git a/libretroshare/src/retroshare/rsmsgs.h b/libretroshare/src/retroshare/rsmsgs.h index 7a44248d0..109084dd7 100644 --- a/libretroshare/src/retroshare/rsmsgs.h +++ b/libretroshare/src/retroshare/rsmsgs.h @@ -343,10 +343,13 @@ struct RsMailStatusEvent : RsEvent struct DistantChatPeerInfo { + DistantChatPeerInfo() : status(0),pending_items(0) {} + RsGxsId to_id ; RsGxsId own_id ; DistantChatPeerId peer_id ; // this is the tunnel id actually - uint32_t status ; // see the values in rsmsgs.h + uint32_t status ; // see the values in rsmsgs.h + uint32_t pending_items; // items not sent, waiting for a tunnel }; // Identifier for an chat endpoint like diff --git a/retroshare-gui/src/gui/chat/ChatWidget.cpp b/retroshare-gui/src/gui/chat/ChatWidget.cpp index cca487b59..94fca3d99 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.cpp +++ b/retroshare-gui/src/gui/chat/ChatWidget.cpp @@ -113,6 +113,7 @@ ChatWidget::ChatWidget(QWidget *parent) ui->searchButton->setIconSize(iconSize); ui->sendButton->setFixedHeight(iconHeight); ui->sendButton->setIconSize(iconSize); + ui->typingLabel->setMaximumHeight(QFontMetricsF(font()).height()*1.2); //Initialize search iCharToStartSearch=Settings->getChatSearchCharToStartSearch(); diff --git a/retroshare-gui/src/gui/chat/ChatWidget.ui b/retroshare-gui/src/gui/chat/ChatWidget.ui index 34ee50e53..a7af7c79f 100644 --- a/retroshare-gui/src/gui/chat/ChatWidget.ui +++ b/retroshare-gui/src/gui/chat/ChatWidget.ui @@ -7,16 +7,25 @@ 0 0 667 - 334 + 528 + + 0 + + + 0 + + + 0 + + + 0 + 2 - - 0 - @@ -37,7 +46,16 @@ QFrame::Raised - + + 0 + + + 0 + + + 0 + + 0 @@ -113,7 +131,16 @@ QFrame::Box - + + 6 + + + 6 + + + 6 + + 6 @@ -238,12 +265,6 @@ border-image: url(:/images/closepressed.png) - - - 400 - 18 - - 0 @@ -291,7 +312,7 @@ border-image: url(:/images/closepressed.png) 30 - + Type a message here @@ -311,7 +332,16 @@ border-image: url(:/images/closepressed.png) QFrame::Sunken - + + 2 + + + 2 + + + 2 + + 2 @@ -520,7 +550,7 @@ border-image: url(:/images/closepressed.png) Qt::NoFocus - + :/images/arrow-left.png:/images/arrow-left.png @@ -546,7 +576,7 @@ border-image: url(:/images/closepressed.png) Qt::NoFocus - + :/images/arrow-right.png:/images/arrow-right.png @@ -583,7 +613,16 @@ border-image: url(:/images/closepressed.png) QFrame::Plain - + + 2 + + + 2 + + + 2 + + 2 @@ -675,7 +714,16 @@ border-image: url(:/images/closepressed.png) QFrame::Sunken - + + 2 + + + 2 + + + 2 + + 2 @@ -756,7 +804,16 @@ border-image: url(:/images/closepressed.png) QFrame::Plain - + + 2 + + + 2 + + + 2 + + 2 @@ -998,6 +1055,7 @@ border-image: url(:/images/closepressed.png) + diff --git a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp index 6f0ddd711..b93c2d438 100644 --- a/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp +++ b/retroshare-gui/src/gui/chat/PopupDistantChatDialog.cpp @@ -111,7 +111,7 @@ void PopupDistantChatDialog::updateDisplay() switch(tinfo.status) { case RS_DISTANT_CHAT_STATUS_UNKNOWN: - //std::cerr << "Unknown hash. Error!" << std::endl; + _status_label->setIcon(QIcon(IMAGE_GRY_LED)); msg = tr("Remote status unknown."); _status_label->setToolTip(msg); @@ -124,31 +124,31 @@ void PopupDistantChatDialog::updateDisplay() case RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED: std::cerr << "Chat remotely closed. " << std::endl; _status_label->setIcon(QIcon(IMAGE_RED_LED)); - _status_label->setToolTip( - QObject::tr("Distant peer has closed the chat") ); - getChatWidget()->updateStatusString( - "%1", tr( "The person you are talking to has deleted the" - " secured chat tunnel." ), true ); - getChatWidget()->blockSending(tr( "The chat partner deleted the secure" - " tunnel, messages will be delivered" - " as soon as possible")); + _status_label->setToolTip( QObject::tr("Distant peer has closed the chat") ); + + getChatWidget()->updateStatusString("%1", tr( "Your partner closed the conversation." ), true ); + getChatWidget()->blockSending(tr( "Your partner closed the conversation.")); + setPeerStatus(RS_STATUS_OFFLINE) ; break ; + case RS_DISTANT_CHAT_STATUS_TUNNEL_DN: - //std::cerr << "Tunnel asked. Waiting for reponse. " << std::endl; + _status_label->setIcon(QIcon(IMAGE_YEL_LED)); - msg = QObject::tr( "Tunnel is pending... Messages will be delivered as" - " soon as possible" ); + msg = QObject::tr( "Tunnel is pending"); + + if(tinfo.pending_items > 0) + msg += QObject::tr("(some undelivered messages)") ; // we cannot use the pending_items count because it accounts for ACKS and keep alive packets as well. + _status_label->setToolTip(msg); getChatWidget()->updateStatusString("%1", msg, true); getChatWidget()->blockSending(msg); setPeerStatus(RS_STATUS_OFFLINE); break; case RS_DISTANT_CHAT_STATUS_CAN_TALK: - //std::cerr << "Tunnel is ok and data is transmitted." << std::endl; + _status_label->setIcon(QIcon(IMAGE_GRN_LED)); - msg = QObject::tr( "Secured tunnel is working. " - "Messages are delivered immediately!" ); + msg = QObject::tr( "End-to-end encrypted conversation established"); _status_label->setToolTip(msg); getChatWidget()->unblockSending(); setPeerStatus(RS_STATUS_ONLINE); @@ -158,17 +158,15 @@ void PopupDistantChatDialog::updateDisplay() void PopupDistantChatDialog::closeEvent(QCloseEvent *e) { - //std::cerr << "Closing window => closing distant chat for hash " << _pid << std::endl; - DistantChatPeerInfo tinfo ; rsMsgs->getDistantChatStatus(_tunnel_id,tinfo) ; if(tinfo.status != RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED) { - QString msg = tr("Closing this window will end the conversation, notify the peer and remove the encrypted tunnel.") ; + QString msg = tr("Closing this window will end the conversation. Unsent messages will be dropped.") ; - if(QMessageBox::Ok == QMessageBox::critical(NULL,tr("Kill the tunnel?"),msg, QMessageBox::Ok | QMessageBox::Cancel)) + if(QMessageBox::Ok == QMessageBox::critical(NULL,tr("Close conversation?"),msg, QMessageBox::Ok | QMessageBox::Cancel)) rsMsgs->closeDistantChatConnexion(_tunnel_id) ; else {