diff options
author | 2010-08-04 21:25:01 +0300 | |
---|---|---|
committer | 2010-08-04 21:25:01 +0300 | |
commit | 085adf80f89b1eab2c0b7a501c6ae00c946b4648 (patch) | |
tree | 86b9c3a08d00de56e9f73e6cee61a50a7c275b3a | |
parent | Add --wait-distfile=distfile_name option to cli of tuiclient (diff) | |
download | idfetch-085adf80f89b1eab2c0b7a501c6ae00c946b4648.tar.gz idfetch-085adf80f89b1eab2c0b7a501c6ae00c946b4648.tar.bz2 idfetch-085adf80f89b1eab2c0b7a501c6ae00c946b4648.zip |
Add DSCRIPTREJECTED status for distfiles.
-rw-r--r-- | segget/connection.cpp | 19 | ||||
-rw-r--r-- | segget/distfile.cpp | 11 | ||||
-rw-r--r-- | segget/distfile.h | 7 | ||||
-rw-r--r-- | segget/pkg.cpp | 2 | ||||
-rw-r--r-- | segget/scriptserver.cpp | 2 | ||||
-rw-r--r-- | segget/ui_server.cpp | 16 | ||||
-rw-r--r-- | tuiclient/colors.cpp | 13 | ||||
-rw-r--r-- | tuiclient/colors.h | 1 | ||||
-rw-r--r-- | tuiclient/distfilewindow.cpp | 32 | ||||
-rw-r--r-- | tuiclient/distfilewindow.h | 1 | ||||
-rw-r--r-- | tuiclient/log.cpp | 3 | ||||
-rw-r--r-- | tuiclient/mainwindow.cpp | 31 | ||||
-rw-r--r-- | tuiclient/mainwindow.h | 4 | ||||
-rw-r--r-- | tuiclient/scrollwindow.cpp | 8 | ||||
-rw-r--r-- | tuiclient/scrollwindow.h | 1 | ||||
-rw-r--r-- | tuiclient/tuiclient.cpp | 58 | ||||
-rw-r--r-- | tuiclient/tuidistfile.cpp | 1 | ||||
-rw-r--r-- | tuiclient/tuidistfile.h | 1 | ||||
-rw-r--r-- | tuiclient/twindow.cpp | 3 |
19 files changed, 151 insertions, 63 deletions
diff --git a/segget/connection.cpp b/segget/connection.cpp index 5aa8453..25e3d79 100644 --- a/segget/connection.cpp +++ b/segget/connection.cpp @@ -49,9 +49,7 @@ int Tconnection::start(CURLM *cm, uint network_number, uint distfile_num, Tsegme gettimeofday(&start_time,NULL); debug("Connecting network"+toString(network_num)); - segment->parent_distfile->active_connections_num++; - - segment->parent_distfile->status=DDOWNLOADING; + segment->parent_distfile->set_status(DDOWNLOADING); if (network_array[network_num].network_mode==MODE_PROXY_FETCHER){ connection_start_time_network_phase_for_pf_networks=segment->parent_distfile->network_distfile_brokers_array[network_num].phase; @@ -77,8 +75,13 @@ int Tconnection::start(CURLM *cm, uint network_number, uint distfile_num, Tsegme debug(" URL:"+url); if (run_user_python_script(connection_num)){ + if (segment->parent_distfile->active_connections_num<=0){ + segment->parent_distfile->set_status(DSCRIPTREJECTED); + } return REJECTED_BY_USER_PYTHON_SCRIPT; } + + segment->parent_distfile->active_connections_num++; active=true; debug("aaaaa"); Pcurr_mirror->start(); @@ -188,7 +191,7 @@ void Tconnection::stop(CURLcode connection_result){ debug(toString(connection_result)+"]- Failed download "+segment->url); if (segment->try_num>=settings.max_tries){ segment->status=SFAILED; - segment->parent_distfile->status=DFAILED; + segment->parent_distfile->set_status(DFAILED); error_log("Segget failed to download distfile: "+segment->parent_distfile->name); error_log("Segment:"+segment->file_name+" has reached max_tries limit - segment.status set to FAILED"); } @@ -199,14 +202,14 @@ void Tconnection::stop(CURLcode connection_result){ debug(" Successful download "+segment->url); // already done earlier in this function Pcurr_mirror=find_mirror(strip_mirror_name(segment->url)); segment->status=SDOWNLOADED; - if (segment->parent_distfile->status!=DFAILED){ + segment->parent_distfile->inc_dld_segments_count(segment); + if ((segment->parent_distfile->get_status()!=DFAILED) and (segment->parent_distfile->get_status()!=DDOWNLOADED)){ if (segment->parent_distfile->active_connections_num>0){ - segment->parent_distfile->status=DDOWNLOADING; + segment->parent_distfile->set_status(DDOWNLOADING); }else{ - segment->parent_distfile->status=DWAITING; + segment->parent_distfile->set_status(DWAITING); } } - segment->parent_distfile->inc_dld_segments_count(segment); }; }catch(...){ error_log("Error in connection.cpp: stop()"); diff --git a/segget/distfile.cpp b/segget/distfile.cpp index 9276af7..21d90c8 100644 --- a/segget/distfile.cpp +++ b/segget/distfile.cpp @@ -59,6 +59,15 @@ using namespace std; #define ALLOW_LOWER_PRIORITY_NETWORKS 205 */ +void Tdistfile::set_status(Tdistfile_status new_status){ + try{ + status=new_status; + ui_server.send_distfile_progress_msg_to_all_clients(get_distfile_progress_str()); + }catch(...){ + error_log("Error: distfile.cpp: set_status()"); + } +} + int Tdistfile::request(ulong network_num, string msg){ gettimeofday(&network_distfile_brokers_array[network_num].last_request_time, NULL); int sockfd; @@ -681,11 +690,11 @@ string Tdistfile::get_distfile_progress_str(){ void Tdistfile::inc_dld_segments_count(Tsegment* current_segment){ try{ + stats.dld_segments_count++; stats.inc_dld_size(current_segment->segment_size); if (++dld_segments_count==segments_count){ combine_segments(); } - stats.dld_segments_count++; dld_bytes+=current_segment->segment_size; ui_server.send_distfile_progress_msg_to_all_clients(get_distfile_progress_str()); }catch(...){ diff --git a/segget/distfile.h b/segget/distfile.h index 5654848..56e2b79 100644 --- a/segget/distfile.h +++ b/segget/distfile.h @@ -81,6 +81,7 @@ enum Tdistfile_status{ DPROXY_DOWNLOADED, DPROXY_FAILED, DWAITING, + DSCRIPTREJECTED, DDOWNLOADING, DDOWNLOADED, DFAILED @@ -92,13 +93,13 @@ class Tdistfile{ private: bool choose_best_local_mirror(CURLM* cm, uint connection_num, uint network_num, uint seg_num); bool choose_best_mirror(CURLM* cm, uint connection_num, uint network_num, uint seg_num); + Tdistfile_status status; public: uint dld_segments_count; ulong dld_bytes; Tnetwork_distfile_broker network_distfile_brokers_array[MAX_NETWORKS]; string json_data; // bool downloaded; - Tdistfile_status status; uint active_connections_num; string *url_list; uint url_num; @@ -118,11 +119,11 @@ class Tdistfile{ uint url_count; uint segment_size; Tdistfile(): + status(DNEW), dld_segments_count(0), dld_bytes(0), json_data(""), // downloaded(0), - status(DNEW), active_connections_num(0), url_list(0), url_num(0), @@ -148,6 +149,8 @@ class Tdistfile{ ~Tdistfile(); int request(ulong network_num, string msg); void init(); + void set_status(Tdistfile_status new_status); + Tdistfile_status get_status(){return status;}; bool allows_new_actions(); bool load_distfile_from_json(json_object* json_obj_distfile); void load_url_list(json_object* json_array_distfile_urllist); diff --git a/segget/pkg.cpp b/segget/pkg.cpp index 20cf0c0..737bb5d 100644 --- a/segget/pkg.cpp +++ b/segget/pkg.cpp @@ -58,7 +58,7 @@ int Tpkg::find_distfile(string distfile_name){ try{ for (ulong distfile_num=0; distfile_num<distfile_count; distfile_num++){ if (Pdistfile_list[distfile_num]->name==distfile_name){ - switch (Pdistfile_list[distfile_num]->status){ + switch (Pdistfile_list[distfile_num]->get_status()){ case DDOWNLOADED: { debug("find_distfile(): distfile: "+distfile_name+" was downloaded"); return R_PF_DOWNLOADED; diff --git a/segget/scriptserver.cpp b/segget/scriptserver.cpp index 44173d7..d257745 100644 --- a/segget/scriptserver.cpp +++ b/segget/scriptserver.cpp @@ -234,7 +234,7 @@ bool run_user_python_script(uint connection_num){ } } - error_log("Created pid:"+toString(pID)); + debug("Launched python script, pid:"+toString(pID)); // parent //Now wait for clients and requests. Because you have passed a null pointer as the timeout parameter, no timeout will occur. The program will exit and report an error if select returns a value less than 1: struct timeval user_script_start_time; diff --git a/segget/ui_server.cpp b/segget/ui_server.cpp index 967112e..8fb48e6 100644 --- a/segget/ui_server.cpp +++ b/segget/ui_server.cpp @@ -170,7 +170,7 @@ void *run_ui_server(void * ){ debug("Client parted from fd:"+toString(fd)); }else{ error_log("reading buffer"); - char buffer[1000]; + char buffer[1000]=""; if (nread!=read(fd, &buffer, nread)){ debug("Not all data has been read from ui_client()"); } @@ -184,7 +184,7 @@ void *run_ui_server(void * ){ if (distfile_by_name_lookup_request.length()>0){ for (ulong distfile_num=0; distfile_num<request_server_pkg.distfile_count; distfile_num++){ if (distfile_by_name_lookup_request==request_server_pkg.Pdistfile_list[distfile_num]->name){ - if (request_server_pkg.Pdistfile_list[distfile_num]->status==DDOWNLOADED){ + if (request_server_pkg.Pdistfile_list[distfile_num]->get_status()==DDOWNLOADED){ distfile_search_result=DOWNLOADED; }else{ distfile_search_result=IN_QUEUE; @@ -195,7 +195,7 @@ void *run_ui_server(void * ){ if (distfile_search_result==NOT_FOUND){ for (ulong distfile_num=0; distfile_num<proxy_fetcher_pkg.distfile_count; distfile_num++){ if (distfile_by_name_lookup_request==proxy_fetcher_pkg.Pdistfile_list[distfile_num]->name){ - if (proxy_fetcher_pkg.Pdistfile_list[distfile_num]->status==DDOWNLOADED){ + if (proxy_fetcher_pkg.Pdistfile_list[distfile_num]->get_status()==DDOWNLOADED){ distfile_search_result=DOWNLOADED; }else{ distfile_search_result=IN_QUEUE; @@ -219,18 +219,22 @@ void *run_ui_server(void * ){ case IN_QUEUE: string err_msg="Found distfile by name:"; err_msg=err_msg+buffer; - error_log(err_msg); + error_log_no_msg(err_msg); ui_server.send_to_fd(fd, "<m>y<t><.>"); //distfile is in the list continue // Get this info to catch up! for (uint line_num=0; line_num<=max_published_screenline_num;line_num++){ ui_server.send_connection_msg_to_fd(fd, line_num, screenlines[line_num]); + error_log_no_msg("Sending to client line:"+toString(line_num)+" "+screenlines[line_num]); debug_no_msg("Sending to client line:"+toString(line_num)+" "+screenlines[line_num]); } - for (ulong distfile_num=0; distfile_num<request_server_pkg.distfile_count; distfile_num++){ + error_log_no_msg("Sending to client distfiles_num:"+toString(request_server_pkg.Pdistfile_list.size())); + for (ulong distfile_num=0; distfile_num<request_server_pkg.Pdistfile_list.size(); distfile_num++){ ui_server.send_distfile_progress_msg_to_fd(fd, request_server_pkg.Pdistfile_list[distfile_num]->get_distfile_progress_str()); + error_log_no_msg("Sending to client:"+request_server_pkg.Pdistfile_list[distfile_num]->get_distfile_progress_str()); } - for (ulong distfile_num=0; distfile_num<proxy_fetcher_pkg.distfile_count; distfile_num++){ + for (ulong distfile_num=0; distfile_num<proxy_fetcher_pkg.Pdistfile_list.size(); distfile_num++){ ui_server.send_distfile_progress_msg_to_fd(fd, proxy_fetcher_pkg.Pdistfile_list[distfile_num]->get_distfile_progress_str()); + error_log_no_msg("Sending to client:"+proxy_fetcher_pkg.Pdistfile_list[distfile_num]->get_distfile_progress_str()); } } } diff --git a/tuiclient/colors.cpp b/tuiclient/colors.cpp index a8b380c..939a006 100644 --- a/tuiclient/colors.cpp +++ b/tuiclient/colors.cpp @@ -40,6 +40,13 @@ void color_distfile_waiting(WINDOW * window){ } } +void color_distfile_script_rejected(WINDOW * window){ + if(has_colors()){ + start_color(); /* Start color */ + wattron(window, COLOR_PAIR(9)); + } +} + void color_distfile_downloading(WINDOW * window){ if(has_colors()){ start_color(); /* Start color */ @@ -109,9 +116,10 @@ void colors_connected(){ init_pair(3, COLOR_GREEN, COLOR_BLUE); init_pair(4, COLOR_WHITE, COLOR_BLACK); init_pair(5, COLOR_GREEN, COLOR_BLACK); - init_pair(6, COLOR_BLUE, COLOR_BLACK); + init_pair(6, COLOR_CYAN, COLOR_BLACK); init_pair(7, COLOR_RED, COLOR_BLACK); - init_pair(8, COLOR_YELLOW, COLOR_BLACK); + init_pair(8, COLOR_BLUE, COLOR_BLACK); + init_pair(9, COLOR_YELLOW, COLOR_BLACK); // init_pair(4, COLOR_BLACK, COLOR_WHITE); // attrset(A_REVERSE); attrset(A_DIM); @@ -130,6 +138,7 @@ void colors_disconnected(){ init_pair(6, COLOR_WHITE, COLOR_BLACK); init_pair(7, COLOR_WHITE, COLOR_BLACK); init_pair(8, COLOR_WHITE, COLOR_BLACK); + init_pair(9, COLOR_WHITE, COLOR_BLACK); /// attrset(A_BOLD); // attrset(A_REVERSE); } diff --git a/tuiclient/colors.h b/tuiclient/colors.h index 1e63bec..288feb1 100644 --- a/tuiclient/colors.h +++ b/tuiclient/colors.h @@ -32,6 +32,7 @@ he terms of the GNU Lesser General Public void color_distfile_added(WINDOW * window); void color_distfile_waiting(WINDOW * window); +void color_distfile_script_rejected(WINDOW * window); void color_distfile_downloading(WINDOW * window); void color_distfile_downloaded(WINDOW * window); void color_distfile_failed(WINDOW * window); diff --git a/tuiclient/distfilewindow.cpp b/tuiclient/distfilewindow.cpp index 718f9fe..58ed688 100644 --- a/tuiclient/distfilewindow.cpp +++ b/tuiclient/distfilewindow.cpp @@ -26,7 +26,17 @@ #include "distfilewindow.h" +void Tdistfile_window::make_frame(){ + wclear(window); + box(window, ACS_VLINE, ACS_HLINE); + mvwaddstr(window,0,(width-caption.length())/2,caption.c_str()); +// msg_short(0,width-20,"[Lines:"+toString(top_position+1)+"-"+toString(top_position+bottom_screenline_num)+"/"+toString(max_received_screenline_num)+"]"); + msg_short(0,width-20,"[Lines:"+toString(top_position+1)+"-"+toString(top_position+bottom_screenline_num)+"/"+toString(tuidistfiles.size())+"]"); + msg_short(height-1,width-27,"[Up/Dn/PgUp/PgDn - scroll]"); +} + void Tdistfile_window::compose(){ +// max_received_screenline_num= // color_distfiles_window(window); make_frame(); // box(window, ACS_VLINE, ACS_HLINE); @@ -49,18 +59,12 @@ void Tdistfile_window::compose(){ percent="(n/a%)"; switch (tuidistfiles[distfile_num].status){ - case DNEW: - case D_NOT_PROXY_REQUESTED: - case DPROXY_REJECTED: - case DPROXY_QUEUED: - case DPROXY_DOWNLOADING: - case DPROXY_DOWNLOADED: - case DPROXY_FAILED: - color_distfile_added(window); - break; case DWAITING: color_distfile_waiting(window); break; + case DSCRIPTREJECTED: + color_distfile_script_rejected(window); + break; case DDOWNLOADING: color_distfile_downloading(window); break; @@ -70,6 +74,16 @@ void Tdistfile_window::compose(){ case DFAILED: color_distfile_failed(window); break; + case DNEW: + case D_NOT_PROXY_REQUESTED: + case DPROXY_REJECTED: + case DPROXY_QUEUED: + case DPROXY_DOWNLOADING: + case DPROXY_DOWNLOADED: + case DPROXY_FAILED: + default: + color_distfile_added(window); + break; } msg_line(y+1,field("",distfile_num+1,4)+") " +percent diff --git a/tuiclient/distfilewindow.h b/tuiclient/distfilewindow.h index e7e5593..e366de8 100644 --- a/tuiclient/distfilewindow.h +++ b/tuiclient/distfilewindow.h @@ -34,6 +34,7 @@ using namespace std; class Tdistfile_window: public Twindow{ public: + void make_frame(); void compose(); }; diff --git a/tuiclient/log.cpp b/tuiclient/log.cpp index ed2cb19..d9ee588 100644 --- a/tuiclient/log.cpp +++ b/tuiclient/log.cpp @@ -70,7 +70,8 @@ void debug_no_msg(string debug_msg_text){ ofstream file; file.exceptions (ofstream::failbit | ofstream::badbit); try{ - file.open((settings.logs_dir+"/"+settings.debug_log_file).c_str(), ios::app); +// file.open((settings.logs_dir+"/"+settings.debug_log_file).c_str(), ios::app); + file.open("./logs/debug.log", ios::app); } catch(...){ error_log("Error opening "+settings.logs_dir+"/"+settings.debug_log_file+"."); diff --git a/tuiclient/mainwindow.cpp b/tuiclient/mainwindow.cpp index 1164c50..1dbd590 100644 --- a/tuiclient/mainwindow.cpp +++ b/tuiclient/mainwindow.cpp @@ -26,20 +26,43 @@ #include "mainwindow.h" +string get_time(string time_format){ + try{ + time_format=time_format+" "; + time_t rawtime; + struct tm * timeinfo; + char buffer [80]; + time ( &rawtime ); + timeinfo = localtime ( &rawtime ); + strftime(buffer,80,time_format.c_str(),timeinfo); + return buffer; + }catch(...){ + error_log("Error in log.cpp: get_time()"); + return ""; + } +} + void Tmainwindow::connected(){ - scroll_lines.clear(); + if (disconnected_flag){ + scroll_lines.clear(); + max_received_screenline_num=0; + tuidistfiles.clear(); + colors_connected(); + set_status("[Connected]"); + disconnected_flag=false; +// set_line(2," CONNECTED "+get_time("%X")); + } // for (int line_num=0; line_num<=max_received_screenline_num; line_num++){ // screenlines[line_num]=""; // } - max_received_screenline_num=0; - colors_connected(); - set_status("[Connected]"); + // notfresh=true; } void Tmainwindow::disconnected(){ colors_disconnected(); set_status("[Connecting... Attempt:"+toString(attempt_num)+". Waiting for 1 sec, before next reconnect.]"); + disconnected_flag=true; // notfresh=true; } void Tmainwindow::msg_status(){ diff --git a/tuiclient/mainwindow.h b/tuiclient/mainwindow.h index ca55343..6ebcadc 100644 --- a/tuiclient/mainwindow.h +++ b/tuiclient/mainwindow.h @@ -51,6 +51,7 @@ class Tmainwindow: public Tscroll_window{ // string screenlines[200]; string screen_info_lines[4]; ulong attempt_num; + bool disconnected_flag; Tmainwindow(): help_win(), log_win(), @@ -58,7 +59,8 @@ class Tmainwindow: public Tscroll_window{ distfiles_win(), // exit_flag(FALSE), connected_status(FALSE), - attempt_num(0) + attempt_num(0), + disconnected_flag(true) {}; ~Tmainwindow(){}; Tmainwindow(const Twindow &L); // copy constructor diff --git a/tuiclient/scrollwindow.cpp b/tuiclient/scrollwindow.cpp index f9cce9c..8c84e2e 100644 --- a/tuiclient/scrollwindow.cpp +++ b/tuiclient/scrollwindow.cpp @@ -46,6 +46,14 @@ void Tscroll_window::compose(){ wrefresh(window); } +void Tscroll_window::make_frame(){ + wclear(window); + box(window, ACS_VLINE, ACS_HLINE); + mvwaddstr(window,0,(width-caption.length())/2,caption.c_str()); +// msg_short(0,width-20,"[Lines:"+toString(top_position+1)+"-"+toString(top_position+bottom_screenline_num)+"/"+toString(max_received_screenline_num)+"]"); + msg_short(0,width-20,"[Lines:"+toString(top_position+1)+"-"+toString(top_position+bottom_screenline_num)+"/"+toString(scroll_lines.size())+"]"); + msg_short(height-1,width-27,"[Up/Dn/PgUp/PgDn - scroll]"); +} void Tscroll_window::add_line(string line){ max_received_screenline_num=scroll_lines.size(); diff --git a/tuiclient/scrollwindow.h b/tuiclient/scrollwindow.h index 19b1e0a..bc678d3 100644 --- a/tuiclient/scrollwindow.h +++ b/tuiclient/scrollwindow.h @@ -42,6 +42,7 @@ class Tscroll_window: public Twindow{ scroll_lines_counter(0) {}; ~Tscroll_window(){}; + void make_frame(); void add_line(string line); void compose(); }; diff --git a/tuiclient/tuiclient.cpp b/tuiclient/tuiclient.cpp index d5665d5..00561a4 100644 --- a/tuiclient/tuiclient.cpp +++ b/tuiclient/tuiclient.cpp @@ -233,7 +233,6 @@ void decode_downloaded_distfile_msg(string msg_body){ a_tuidistfile.dld_bytes=atol(parts[4]); a_tuidistfile.size=atol(parts[5]); tuidistfiles.push_back(a_tuidistfile); - mainwindow.distfiles_win.max_received_screenline_num=tuidistfiles.size(); } } @@ -365,6 +364,7 @@ int main(int argc, char* argv[]) } } + debug("connected"); mainwindow.connected(); if (settings.arg_wait_distfile.length()>999){ quit(1,"Error in argument --wait-distfile="+settings.arg_wait_distfile+" : Distfile name is too long"); @@ -398,36 +398,42 @@ int main(int argc, char* argv[]) // printf("removing client on fd %d\n", sockfd); run_flag=false; }else { - char recv_buffer[BUFFER_SIZE+1]=""; + char recv_buffer[BUFFER_SIZE+1]=" "; if (nread!=read(sockfd, recv_buffer, BUFFER_SIZE)){ error_log("Error in tuiclient.cpp : main() read bytes count does NOT match declared count."); }; //recv_msg=recv_msg+recv_buffer; - rest_of_the_msg=rest_of_the_msg+recv_buffer; +// rest_of_the_msg=rest_of_the_msg+recv_buffer; + rest_of_the_msg=recv_buffer; + debug("RECEIVED:"+rest_of_the_msg); + debug("END============================"); Tparts msg_parts; - while (rest_of_the_msg.find("<.>")!=rest_of_the_msg.npos){ - msg_parts=split("<m>",rest_of_the_msg); - msg_parts=split("<t>",msg_parts.after); - char msg_type=msg_parts.before[0]; - debug("msg_type="+msg_type); - msg_parts=split("<.>",msg_parts.after); - string msg_body=msg_parts.before; - debug("msg_body="+msg_body); - rest_of_the_msg=msg_parts.after; - switch (msg_type){ - case 'c': decode_connection_msg(msg_parts.before); break; - case 'l': decode_log_msg(msg_parts.before);break; - case 'e': decode_error_log_msg(msg_parts.before);break; - case 'd': decode_downloaded_distfile_msg(msg_parts.before);break; - // yes-distfile present in the queue - case 'y': break; // continue waiting for catchup info - // no distfile in the queue - case 'n': - quit(1,"Distfile: "+settings.arg_wait_distfile+" is not in the queue - quit"); - break; //shouldn't get to this point - but just in case - case 'N': - quit(0,"Distfile: "+settings.arg_wait_distfile+" is already downloaded - quit"); - break; //shouldn't get to this point - but just in case + vector<string> submsgs=split_to_vector("<.>", rest_of_the_msg); + for (ulong submsg_num=0; submsg_num<submsgs.size(); submsg_num++){ + vector<string> before_msg_and_msg=split_to_vector("<m>",submsgs[submsg_num]); + if (before_msg_and_msg.size()>1){ + vector<string> msg_type_and_body=split_to_vector("<t>",before_msg_and_msg[1]); + if (msg_type_and_body.size()>1){ + debug("msg_type="+msg_type_and_body[0]); + debug("msg_body="+msg_type_and_body[1]); + char msg_type=msg_type_and_body[0][0]; +// debug("msg_type="+msg_type_str); + switch (msg_type){ + case 'c': decode_connection_msg(msg_type_and_body[1]); break; + case 'l': decode_log_msg(msg_type_and_body[1]);break; + case 'e': decode_error_log_msg(msg_type_and_body[1]);break; + case 'd': decode_downloaded_distfile_msg(msg_type_and_body[1]);break; + // yes-distfile present in the queue + case 'y': break; // continue waiting for catchup info + // no distfile in the queue + case 'n': + quit(1,"Distfile: "+settings.arg_wait_distfile+" is not in the queue - quit"); + break; //shouldn't get to this point - but just in case + case 'N': + quit(0,"Distfile: "+settings.arg_wait_distfile+" is already downloaded - quit"); + break; //shouldn't get to this point - but just in case + } + } } } }; diff --git a/tuiclient/tuidistfile.cpp b/tuiclient/tuidistfile.cpp index 45d135d..15138d3 100644 --- a/tuiclient/tuidistfile.cpp +++ b/tuiclient/tuidistfile.cpp @@ -38,6 +38,7 @@ string Ttuidistfile::statusToString(){ case DPROXY_DOWNLOADED: return "Downloaded via proxy"; case DPROXY_FAILED: return "Failed"; case DWAITING: return "Waiting"; + case DSCRIPTREJECTED: return "Rejected by script"; case DDOWNLOADING: return "Downloading"; case DDOWNLOADED: return "Downloaded"; case DFAILED: return "Failed"; diff --git a/tuiclient/tuidistfile.h b/tuiclient/tuidistfile.h index f69d734..866f049 100644 --- a/tuiclient/tuidistfile.h +++ b/tuiclient/tuidistfile.h @@ -40,6 +40,7 @@ enum Tdistfile_status{ DPROXY_DOWNLOADED, DPROXY_FAILED, DWAITING, + DSCRIPTREJECTED, DDOWNLOADING, DDOWNLOADED, DFAILED diff --git a/tuiclient/twindow.cpp b/tuiclient/twindow.cpp index 080506d..fadd8b2 100644 --- a/tuiclient/twindow.cpp +++ b/tuiclient/twindow.cpp @@ -106,7 +106,8 @@ void Twindow::make_frame(){ wclear(window); box(window, ACS_VLINE, ACS_HLINE); mvwaddstr(window,0,(width-caption.length())/2,caption.c_str()); - msg_short(0,width-20,"[Lines:"+toString(top_position+1)+"-"+toString(top_position+bottom_screenline_num)+"/"+toString(max_received_screenline_num)+"]"); +// msg_short(0,width-20,"[Lines:"+toString(top_position+1)+"-"+toString(top_position+bottom_screenline_num)+"/"+toString(max_received_screenline_num)+"]"); +// msg_short(0,width-20,"[Lines:"+toString(top_position+1)+"-"+toString(top_position+bottom_screenline_num)+"/"+toString(screen_lines.size())+"]"); msg_short(height-1,width-27,"[Up/Dn/PgUp/PgDn - scroll]"); } |