diff options
author | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-07-28 04:14:15 +0300 |
---|---|---|
committer | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-07-28 04:14:15 +0300 |
commit | 2c1b29264dcb2acaacae5406028dcac7ded3ff6f (patch) | |
tree | 978e5c84eb043d57ff4d41ef87fc2a6efa5dc830 | |
parent | Add BIND_LOCAL_PORT and BIND_LOCAL_PORT_RANGE options to network#.conf files (diff) | |
download | idfetch-2c1b29264dcb2acaacae5406028dcac7ded3ff6f.tar.gz idfetch-2c1b29264dcb2acaacae5406028dcac7ded3ff6f.tar.bz2 idfetch-2c1b29264dcb2acaacae5406028dcac7ded3ff6f.zip |
Show network_type in tui.
-rw-r--r-- | segget/connection.cpp | 40 | ||||
-rw-r--r-- | segget/tui.cpp | 64 | ||||
-rw-r--r-- | segget/tui.h | 2 |
3 files changed, 34 insertions, 72 deletions
diff --git a/segget/connection.cpp b/segget/connection.cpp index ec05269..02993b6 100644 --- a/segget/connection.cpp +++ b/segget/connection.cpp @@ -204,15 +204,37 @@ void Tconnection::inc_bytes_per_last_interval(ulong new_bytes_count){ void Tconnection::show_connection_progress(ulong time_diff){ try{ stats.total_bytes_per_last_interval+=bytes_per_last_interval; - msg_segment_progress( - segment->connection_num, - network_num, - segment->segment_num, - segment->try_num, - segment->downloaded_bytes, - segment->segment_size, - (bytes_per_last_interval*1000)/time_diff, - (total_dld_bytes*1000)/time_left_from(start_time)); + ulong speed=(bytes_per_last_interval*1000)/time_diff; + ulong avg_speed=(total_dld_bytes*1000)/time_left_from(start_time); + string eta_string; + if (speed==0){ + eta_string=" ETA: inf"; + }else{ + eta_string=" ETA: "+secsToString((segment->segment_size-segment->downloaded_bytes)/speed); + } + string speed_str; + string avg_speed_str; + speed_str=" Speed: "+speedToString(speed); + avg_speed_str=" AVG speed: "+speedToString(avg_speed); + int percent=segment->downloaded_bytes*100/segment->segment_size; + string network_type_str; + switch (network_array[network_num].network_mode){ + case MODE_REMOTE: network_type_str="REM"; break; + case MODE_PROXY_FETCHER: network_type_str="P-F"; break; + case MODE_LOCAL: network_type_str="LOC"; break; + case MODE_CORAL_CDN: network_type_str="CDN"; break; + } + string progress_text=field("[Net",network_num,1) + +":"+network_type_str+"]" + +field(" Segment:",segment->segment_num, 5) + +field(" Try:",segment->try_num,4) + +field(" Bytes:",segment->downloaded_bytes,7) + +field(" / ",segment->segment_size,7) + +field(" = ",percent,3)+"%" + +speed_str + +avg_speed_str + +eta_string; + msg_segment_progress(segment->connection_num, progress_text); bytes_per_last_interval=0; }catch(...){ error_log("Error in connection.cpp: show_connection_progress()"); diff --git a/segget/tui.cpp b/segget/tui.cpp index 423547a..0d26e11 100644 --- a/segget/tui.cpp +++ b/segget/tui.cpp @@ -52,53 +52,14 @@ void msg(uint y, uint x, string msg_text){ // } } -void msg_segment_progress(uint connection_num, uint network_num, uint segment_num, uint try_num, ulong dld_bytes, ulong total_bytes, ulong speed, ulong avg_speed){ +void msg_segment_progress(uint connection_num, string progress_text){ try{ - - string eta_string; - if (speed==0){ - eta_string=" ETA: inf"; - }else{ - eta_string=" ETA: "+secsToString((total_bytes-dld_bytes)/speed); - } - - string speed_str; - string avg_speed_str; -/* - if (speed<1000) - speed_str=field(" Speed:",speed,7)+" b/s"; - else - speed_str=field(" Speed:",speed/1000,7)+" Kb/s"; -*/ - - speed_str=" Speed: "+speedToString(speed); -/* - if (avg_speed<1000) - avg_speed_str=field(" AVG",avg_speed,7)+" b/s"; - else - avg_speed_str=field(" AVG",avg_speed/1000,7)+" Kb/s"; -*/ - avg_speed_str=" AVG speed: "+speedToString(avg_speed); - - int percent=dld_bytes*100/total_bytes; - - msg(connection_num*CONNECTION_LINES,0, - field("[",connection_num,2)+"]" - +field(" Net",network_num,1) - +field(" Segment:",segment_num, 5) - +field(" Try:",try_num,4) - +field(" Bytes:",dld_bytes,7) - +field(" / ",total_bytes,7) - +field(" = ",percent,3)+"%" - +speed_str - +avg_speed_str - +eta_string); + field("[",connection_num,2)+"]"+progress_text); }catch(...){ error_log_no_msg("Error in tui.cpp: msg_segment_progress()"); } } - void msg_connecting(uint connection_num, uint distfile_num, uint segment_num, string msg_text){ try{ msg(connection_num*CONNECTION_LINES+1,0,"DF#"+toString(distfile_num)+" Seg#"+toString(segment_num)+" "+msg_text); @@ -106,22 +67,6 @@ void msg_connecting(uint connection_num, uint distfile_num, uint segment_num, st error_log_no_msg("Error in tui.cpp: msg_connecting()"); } } -/* -void msg_status1(uint connection_num, uint segment_num, string msg_text){ - try{ - msg(connection_num*CONNECTION_LINES+2,0,"Seg#"+toString(segment_num)+" "+msg_text); - }catch(...){ - error_log_no_msg("Error in tui.cpp: msg_status1()"); - } -} -void msg_status2(uint connection_num, string msg_text){ - try{ - msg(connection_num*CONNECTION_LINES+3,0,msg_text); - }catch(...){ - error_log_no_msg("Error in tui.cpp: msg_status2()"); - } -} -*/ void msg_clean_connection(uint connection_num){ try{ @@ -129,11 +74,6 @@ void msg_clean_connection(uint connection_num){ msg(connection_num*CONNECTION_LINES+1,0,""); msg(connection_num*CONNECTION_LINES+2,0,""); msg(connection_num*CONNECTION_LINES+3,0,""); - -// msg(connection_num*CONNECTION_LINES,0," "); -// msg(connection_num*CONNECTION_LINES+1,0," "); -// msg(connection_num*CONNECTION_LINES+2,0," "); -// msg(connection_num*CONNECTION_LINES+3,0," "); }catch(...){ error_log_no_msg("Error in tui.cpp: msg_clean_connection()"); } diff --git a/segget/tui.h b/segget/tui.h index 079c568..8a3022b 100644 --- a/segget/tui.h +++ b/segget/tui.h @@ -51,7 +51,7 @@ extern uint log_lines_counter; void msg_total(string msg_text); void msg(uint y, uint x, string msg_text); void msg_connecting(uint connection_num, uint distfile_num, uint segment_num, string msg_text); -void msg_segment_progress(uint connection_num, uint network_num, uint segment_num, uint try_num, ulong dld_bytes, ulong total_bytes, ulong speed, ulong avg_speed); +void msg_segment_progress(uint connection_num, string progress_text); void msg_status1(uint connection_num, uint segment_num, string msg_text); void msg_status2(uint connection_num, string msg_text); void msg_clean_connection(uint connection_num); |