Skip to content

Commit

Permalink
closes feature request mobile-shell#321 - Lost contact for XX seconds…
Browse files Browse the repository at this point in the history
… should know about other units
  • Loading branch information
teancom committed Sep 14, 2012
1 parent 815aff9 commit f172a4b
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/frontend/terminaloverlay.cc
Expand Up @@ -210,19 +210,47 @@ void NotificationEngine::apply( Framebuffer &fb ) const
double since_ack = (double)(now - last_acked_state) / 1000.0; double since_ack = (double)(now - last_acked_state) / 1000.0;
const char server_message[] = "contact"; const char server_message[] = "contact";
const char reply_message[] = "reply"; const char reply_message[] = "reply";
const char tunit_seconds[] = "seconds";
const char tunit_minutes[] = "minutes";
const char tunit_minute[] = "minute";
const char tunit_hours[] = "hours";
const char tunit_hour[] = "hour";
const char tunit_days[] = "days";
const char tunit_day[] = "day";


double time_elapsed = since_heard; double time_elapsed = since_heard;
const char *explanation = server_message; const char *explanation = server_message;
const char *time_unit = tunit_seconds;


if ( reply_late( now ) && (!server_late( now )) ) { if ( reply_late( now ) && (!server_late( now )) ) {
time_elapsed = since_ack; time_elapsed = since_ack;
explanation = reply_message; explanation = reply_message;
} }


if ( time_elapsed > 172800 ) {
time_unit = tunit_days;
time_elapsed = time_elapsed / 86400;
} else if ( time_elapsed > 86400 ) {
time_unit = tunit_day;
time_elapsed = time_elapsed / 86400;
} else if ( time_elapsed > 7200 ) {
time_unit = tunit_hours;
time_elapsed = time_elapsed / 3600;
} else if ( time_elapsed > 3600 ) {
time_unit = tunit_hour;
time_elapsed = time_elapsed / 3600;
} else if ( time_elapsed > 120 ) {
time_unit = tunit_minutes;
time_elapsed = time_elapsed / 60;
} else if ( time_elapsed > 60 ) {
time_unit = tunit_minute;
time_elapsed = time_elapsed / 60;
}

if ( message.empty() && (!time_expired) ) { if ( message.empty() && (!time_expired) ) {
return; return;
} else if ( message.empty() && time_expired ) { } else if ( message.empty() && time_expired ) {
swprintf( tmp, 128, L"mosh: Last %s %.0f seconds ago. [To quit: Ctrl-^ .]", explanation, time_elapsed ); swprintf( tmp, 128, L"mosh: Last %s %.0f %s ago. [To quit: Ctrl-^ .]", explanation, time_elapsed, time_unit );
} else if ( (!message.empty()) && (!time_expired) ) { } else if ( (!message.empty()) && (!time_expired) ) {
swprintf( tmp, 128, L"mosh: %ls [To quit: Ctrl-^ .]", message.c_str() ); swprintf( tmp, 128, L"mosh: %ls [To quit: Ctrl-^ .]", message.c_str() );
} else { } else {
Expand Down

0 comments on commit f172a4b

Please sign in to comment.