mirror of
https://github.com/RetroShare/RetroShare.git
synced 2026-09-12 19:50:17 +05:00
Distant chat window: close it when the conversation is closed from another client
A distant chat started from the web UI pops the desktop chat window for its tunnel (the core sends itself a "[Starting distant chat" message). Leaving that conversation from the web UI then left the window as it was: green LED, "You can talk", and on close the offer to end a conversation the core no longer had -- closeEvent() ignored the false answer of getDistantChatStatus() and read a default-initialised status. On the new RsDistantChatEventCode::TUNNEL_STATUS_LOCALLY_CLOSED (libretroshare fix/distant-chat-locally-closed-event) the window closes, as it does when the conversation is ended from the window itself. And closeEvent() asks no confirmation and calls no close for a tunnel the core does not know any more.
This commit is contained in:
parent
f8553d2fd9
commit
ea97a7437d
@ -217,16 +217,30 @@ void PopupDistantChatDialog::handleEvent_main_thread(std::shared_ptr<const RsEve
|
||||
getChatWidget()->unblockSending();
|
||||
setPeerStatus(RsStatusValue::RS_STATUS_ONLINE);
|
||||
break;
|
||||
|
||||
case RsDistantChatEventCode::TUNNEL_STATUS_LOCALLY_CLOSED:
|
||||
// Closed by another client of this core -- the web UI, or a JSON API
|
||||
// caller. Closing it from this window never reaches here: the window
|
||||
// is gone before the event arrives. Ending a conversation closes its
|
||||
// window when done from here; done from elsewhere it must end the
|
||||
// same way. closeEvent() asks nothing: the core has no tunnel left.
|
||||
close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void PopupDistantChatDialog::closeEvent(QCloseEvent *e)
|
||||
{
|
||||
DistantChatPeerInfo tinfo ;
|
||||
|
||||
rsChats->getDistantChatStatus(_tunnel_id,tinfo) ;
|
||||
|
||||
if(tinfo.status != RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED)
|
||||
// getDistantChatStatus() answers false once the core has dropped the
|
||||
// tunnel -- closed from another client, or died on its own. Its return
|
||||
// value was ignored and tinfo left at its default, status 0, which is not
|
||||
// REMOTELY_CLOSED: the user was then asked whether to end a conversation
|
||||
// that did not exist, and closeDistantChatConnexion() ran on nothing.
|
||||
bool tunnel_known = rsChats->getDistantChatStatus(_tunnel_id,tinfo) ;
|
||||
|
||||
if(tunnel_known && tinfo.status != RS_DISTANT_CHAT_STATUS_REMOTELY_CLOSED)
|
||||
{
|
||||
QString msg = tr("Closing this window will end the conversation. Unsent messages will be dropped.") ;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user