From e80135b5cf9eddd28ee5e23d830eebaa5155ba8f Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Sun, 30 Oct 2011 04:32:26 -0400 Subject: [PATCH] Cleanup UI around connect/shutdown --- stmclient.cpp | 20 +++++++++++++++----- stmclient.hpp | 2 -- terminaloverlay.hpp | 1 + transportsender.cpp | 8 ++++---- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/stmclient.cpp b/stmclient.cpp index 12c8bdb..64602bd 100644 --- a/stmclient.cpp +++ b/stmclient.cpp @@ -255,8 +255,6 @@ void STMClient::main( void ) pollfds[ 3 ].fd = shutdown_signal_fd; pollfds[ 3 ].events = POLLIN; - last_remote_num = network->get_remote_state_num(); - while ( 1 ) { try { output_new_frame(); @@ -333,11 +331,23 @@ void STMClient::main( void ) break; } + static const wstring connecting_notification( L"Connecting..." ); + if ( (network->get_remote_state_num() == 0) && (!network->shutdown_in_progress()) ) { + overlays.get_notification_engine().set_notification_string( connecting_notification ); + } else if ( (network->get_remote_state_num() != 0) + && (overlays.get_notification_engine().get_notification_string() + == connecting_notification) ) { + overlays.get_notification_engine().set_notification_string( L"" ); + } + network->tick(); } catch ( Network::NetworkException e ) { - wchar_t tmp[ 128 ]; - swprintf( tmp, 128, L"%s: %s\r\n", e.function.c_str(), strerror( e.the_errno ) ); - overlays.get_notification_engine().set_notification_string( wstring( tmp ) ); + if ( !network->shutdown_in_progress() ) { + wchar_t tmp[ 128 ]; + swprintf( tmp, 128, L"%s: %s\r\n", e.function.c_str(), strerror( e.the_errno ) ); + overlays.get_notification_engine().set_notification_string( wstring( tmp ) ); + } + struct timespec req; req.tv_sec = 0; req.tv_nsec = 200000000; /* 0.2 sec */ diff --git a/stmclient.hpp b/stmclient.hpp index 5d85f1c..1ff64a8 100644 --- a/stmclient.hpp +++ b/stmclient.hpp @@ -24,7 +24,6 @@ private: Terminal::Framebuffer *local_framebuffer; Overlay::OverlayManager overlays; Network::Transport< Network::UserStream, Terminal::Complete > *network; - uint64_t last_remote_num; bool repaint_requested, quit_sequence_started; @@ -44,7 +43,6 @@ public: local_framebuffer( NULL ), overlays(), network( NULL ), - last_remote_num( -1 ), repaint_requested( false ), quit_sequence_started( false ) {} diff --git a/terminaloverlay.hpp b/terminaloverlay.hpp index 95fd592..1ba5e7d 100644 --- a/terminaloverlay.hpp +++ b/terminaloverlay.hpp @@ -101,6 +101,7 @@ namespace Overlay { public: void apply( Framebuffer &fb ) const; void set_notification_string( const wstring s_message ); + const wstring &get_notification_string( void ) { return message; } void server_ping( uint64_t s_last_word ); void render_notification( void ); diff --git a/transportsender.cpp b/transportsender.cpp index e8af77c..c9c7cb2 100644 --- a/transportsender.cpp +++ b/transportsender.cpp @@ -242,6 +242,10 @@ void TransportSender::send_in_fragments( string diff, uint64_t new_num inst.set_throwaway_num( sent_states.front().num ); inst.set_diff( diff ); + if ( new_num == uint64_t(-1) ) { + shutdown_tries++; + } + vector fragments = fragmenter.make_fragments( inst, connection->get_MTU() ); for ( auto i = fragments.begin(); i != fragments.end(); i++ ) { @@ -257,10 +261,6 @@ void TransportSender::send_in_fragments( string diff, uint64_t new_num } - if ( new_num == uint64_t(-1) ) { - shutdown_tries++; - } - pending_data_ack = false; }