Move NetworkException formatting into NotificationEngine

This commit is contained in:
Keegan McAllister
2012-05-01 22:28:05 -04:00
committed by Keith Winstein
parent 1b86532a99
commit 9dddcd8566
2 changed files with 18 additions and 4 deletions
+1 -3
View File
@@ -417,9 +417,7 @@ void STMClient::main( void )
network->tick(); network->tick();
} catch ( Network::NetworkException e ) { } catch ( Network::NetworkException e ) {
if ( !network->shutdown_in_progress() ) { if ( !network->shutdown_in_progress() ) {
wchar_t tmp[ 128 ]; overlays.get_notification_engine().set_network_exception( e );
swprintf( tmp, 128, L"%s: %s", e.function.c_str(), strerror( e.the_errno ) );
overlays.get_notification_engine().set_notification_string( wstring( tmp ) );
} }
struct timespec req; struct timespec req;
+17 -1
View File
@@ -137,12 +137,28 @@ namespace Overlay {
bool need_countup( uint64_t ts ) const { return server_late( ts ) || reply_late( ts ); } bool need_countup( uint64_t ts ) const { return server_late( ts ) || reply_late( ts ); }
void adjust_message( void ); void adjust_message( void );
void apply( Framebuffer &fb ) const; void apply( Framebuffer &fb ) const;
void set_notification_string( const wstring &s_message, bool permanent = false ) { message = s_message; if ( permanent ) { message_expiration = -1; } else { message_expiration = timestamp() + 1000; } }
const wstring &get_notification_string( void ) const { return message; } const wstring &get_notification_string( void ) const { return message; }
void server_heard( uint64_t s_last_word ) { last_word_from_server = s_last_word; } void server_heard( uint64_t s_last_word ) { last_word_from_server = s_last_word; }
void server_acked( uint64_t s_last_acked ) { last_acked_state = s_last_acked; } void server_acked( uint64_t s_last_acked ) { last_acked_state = s_last_acked; }
uint64_t get_message_expiration( void ) const { return message_expiration; } uint64_t get_message_expiration( void ) const { return message_expiration; }
void set_notification_string( const wstring &s_message, bool permanent = false )
{
message = s_message;
if ( permanent ) {
message_expiration = -1;
} else {
message_expiration = timestamp() + 1000;
}
}
void set_network_exception( const NetworkException &e )
{
wchar_t tmp[ 128 ];
swprintf( tmp, 128, L"%s: %s", e.function.c_str(), strerror( e.the_errno ) );
set_notification_string( wstring( tmp ) );
}
NotificationEngine(); NotificationEngine();
}; };