diff options
author | 2010-08-03 04:28:09 +0300 | |
---|---|---|
committer | 2010-08-03 04:28:09 +0300 | |
commit | 394e79b27aeae9de83c378b391e5e3cf59ec9759 (patch) | |
tree | 0dc1663a05931ea5a717eb99e977198eb746feb2 | |
parent | Add distfiles window to tuiclient. (diff) | |
download | idfetch-394e79b27aeae9de83c378b391e5e3cf59ec9759.tar.gz idfetch-394e79b27aeae9de83c378b391e5e3cf59ec9759.tar.bz2 idfetch-394e79b27aeae9de83c378b391e5e3cf59ec9759.zip |
Provide more info on distfiles to tuiclients.
Provide info on distfiles that are already in the list or just added,
but not in progress (not started yet or already downloaded) to ui_server/tui_clients.
-rw-r--r-- | segget/connection.cpp | 2 | ||||
-rw-r--r-- | segget/connection.h | 3 | ||||
-rw-r--r-- | segget/distfile.cpp | 18 | ||||
-rw-r--r-- | segget/distfile.h | 13 | ||||
-rw-r--r-- | segget/networkbroker.cpp | 1 | ||||
-rw-r--r-- | segget/networkbroker.h | 2 | ||||
-rw-r--r-- | segget/pkg.h | 1 | ||||
-rw-r--r-- | segget/response.cpp | 2 | ||||
-rw-r--r-- | segget/response.h | 3 | ||||
-rw-r--r-- | segget/segment.h | 3 | ||||
-rw-r--r-- | segget/shorttypes.h | 1 | ||||
-rw-r--r-- | segget/ui_server.cpp | 28 | ||||
-rw-r--r-- | segget/ui_server.h | 9 |
13 files changed, 61 insertions, 25 deletions
diff --git a/segget/connection.cpp b/segget/connection.cpp index 274d9ca..5cf8bb3 100644 --- a/segget/connection.cpp +++ b/segget/connection.cpp @@ -24,6 +24,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "connection.h" +#include "utils.h" +#include "settings.h" long script_waiting_connection_num=-1; uint Tconnection::total_connections=0; diff --git a/segget/connection.h b/segget/connection.h index a758ee6..9ac5950 100644 --- a/segget/connection.h +++ b/segget/connection.h @@ -31,12 +31,13 @@ #include <curl/curl.h> class Tsegment; #include "segment.h" -#include "utils.h" #include "networkbroker.h" #include "scriptserver.h" using namespace std; +#define MAX_CONNECTS 20 + class Tconnection{ static uint total_connections; private: diff --git a/segget/distfile.cpp b/segget/distfile.cpp index d8f8eda..1bc122d 100644 --- a/segget/distfile.cpp +++ b/segget/distfile.cpp @@ -25,6 +25,11 @@ */ #include "distfile.h" +#include "mirror.h" +#include "checksum.h" +#include "network.h" +#include "segment.h" +#include "response.h" //Make the necessary includes and set up the variables: using namespace std; @@ -257,6 +262,7 @@ bool Tdistfile::load_distfile_from_json(json_object* json_obj_distfile){ load_url_list(json_object_object_get(json_obj_distfile,"url_list")); } debug("Added distfile: "+name+" to download queue"); + ui_server.send_distfile_progress_msg_to_all_clients(get_distfile_progress_str()); }catch(...){ error_log("Error: distfile.cpp: load_distfile_from_json()"); } @@ -662,11 +668,21 @@ int Tdistfile::provide_segment(CURLM* cm, uint connection_num, uint seg_num){ return 1; } } + +string Tdistfile::get_distfile_progress_str(){ + try{ + return name+" "+toString(dld_segments_count)+" "+toString(segments_count)+" "+toString(dld_bytes)+" "+toString(size); + }catch(...){ + error_log("Error: distfile.cpp: get_distfile_progress_str()"); + return ""; + } +} + void Tdistfile::inc_dld_segments_count(Tsegment* current_segment){ try{ stats.inc_dld_size(current_segment->segment_size); dld_bytes+=current_segment->segment_size; - ui_server.send_distfile_progress_msg_to_all_clients(name+" "+toString(dld_segments_count)+" "+toString(segments_count)+" "+toString(dld_bytes)+" "+toString(size)); + ui_server.send_distfile_progress_msg_to_all_clients(get_distfile_progress_str()); if (++dld_segments_count==segments_count){ combine_segments(); } diff --git a/segget/distfile.h b/segget/distfile.h index ebf2b4a..5654848 100644 --- a/segget/distfile.h +++ b/segget/distfile.h @@ -46,13 +46,11 @@ #include <unistd.h> #define GetCurrentDir getcwd #endif +//class Tui_server; #include "segment.h" -#include "mirror.h" -#include "checksum.h" -#include "network.h" #include "networkbroker.h" -#include "segment.h" -#include "response.h" +//#include "settings.h" +//class Tsettings; class Tsegment; //#include <sys/types.h> @@ -71,6 +69,7 @@ class Tsegment; using namespace std; +#define MAX_NETWORKS 10 typedef unsigned int uint; enum Tdistfile_status{ @@ -141,7 +140,8 @@ class Tdistfile{ MD5(""), CRC32(""), url_count(0), - segment_size(settings.max_segment_size) +// segment_size(settings.max_segment_size) + segment_size(500000) {init();}; Tdistfile(const Tdistfile &L); // copy constructor Tdistfile & operator=(const Tdistfile &L); @@ -156,6 +156,7 @@ class Tdistfile{ uint request_proxy_fetcher_network(uint network_priority); uint provide_remote_or_coral_cdn_network(CURLM* cm, uint connection_num, uint seg_num, uint network_priority); int provide_segment(CURLM* cm, uint connection_num, uint seg_num); + string get_distfile_progress_str(); void inc_dld_segments_count(Tsegment * current_segment); void symlink_distfile_to_provide_mirror_dir(); int combine_segments(); diff --git a/segget/networkbroker.cpp b/segget/networkbroker.cpp index c5e36d3..36e3d7e 100644 --- a/segget/networkbroker.cpp +++ b/segget/networkbroker.cpp @@ -25,6 +25,7 @@ */ #include "networkbroker.h" +#include "network.h" string phaseToString(int phase_num); diff --git a/segget/networkbroker.h b/segget/networkbroker.h index 602cdb0..9c43ec3 100644 --- a/segget/networkbroker.h +++ b/segget/networkbroker.h @@ -27,8 +27,8 @@ #define __NETWORK_DISTFILE_BROKER_H__ #include <vector> +#include <sys/time.h> #include "shorttypes.h" -#include "network.h" #include "response.h" #include "phase.h" using namespace std; diff --git a/segget/pkg.h b/segget/pkg.h index a5a6f7b..63a913e 100644 --- a/segget/pkg.h +++ b/segget/pkg.h @@ -31,6 +31,7 @@ #include <fstream> #include <iostream> #include <json/json.h> +class Tdistfile; #include "distfile.h" using namespace std; diff --git a/segget/response.cpp b/segget/response.cpp index 5db952e..f8456c0 100644 --- a/segget/response.cpp +++ b/segget/response.cpp @@ -25,6 +25,8 @@ */ #include "response.h" +#include "tui.h" + int decode_server_response(string server_response){ int int_server_response=atoi(server_response.c_str()); switch (int_server_response){ diff --git a/segget/response.h b/segget/response.h index fbeb4f5..571f17b 100644 --- a/segget/response.h +++ b/segget/response.h @@ -26,8 +26,7 @@ #ifndef __RESPONSE_H__ #define __RESPONSE_H__ - -#include "tui.h" +#include <string> using namespace std; diff --git a/segget/segment.h b/segget/segment.h index bdb6dcc..b63e8e6 100644 --- a/segget/segment.h +++ b/segget/segment.h @@ -44,7 +44,8 @@ class Tdistfile; #include "stats.h" -extern Tsettings settings; +#define MAX_CONNECTS 20 +//extern Tsettings settings; //unsigned long downloaded_bytes=0; size_t write_data(void *buffer, size_t size, size_t nmemb, void *cur_segment); diff --git a/segget/shorttypes.h b/segget/shorttypes.h index af0b982..5d99613 100644 --- a/segget/shorttypes.h +++ b/segget/shorttypes.h @@ -28,5 +28,6 @@ #define _TYPES_H_ typedef unsigned long ulong; +typedef unsigned int uint; #endif
\ No newline at end of file diff --git a/segget/ui_server.cpp b/segget/ui_server.cpp index 29eb5f4..8464e70 100644 --- a/segget/ui_server.cpp +++ b/segget/ui_server.cpp @@ -101,15 +101,20 @@ void Tui_server::send_log_msg_to_all_clients(string msg){ } } -void Tui_server::send_error_log_msg_to_all_clients(string msg){ - string message="<m>e<t>"+msg+"<.>"; +void Tui_server::send_distfile_progress_msg_to_fd(uint fd, string msg){ + string message="<m>d<t>"+msg+"<.>"; + send_to_fd(fd, message); +} + +void Tui_server::send_distfile_progress_msg_to_all_clients(string msg){ + string message="<m>d<t>"+msg+"<.>"; for(uint fd = 0; fd <= ui_server.max_fd_num; fd++){ send_to_fd(fd, message); } } -void Tui_server::send_distfile_progress_msg_to_all_clients(string msg){ - string message="<m>d<t>"+msg+"<.>"; +void Tui_server::send_error_log_msg_to_all_clients(string msg){ + string message="<m>e<t>"+msg+"<.>"; for(uint fd = 0; fd <= ui_server.max_fd_num; fd++){ send_to_fd(fd, message); } @@ -150,12 +155,15 @@ void *run_ui_server(void * ){ // 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(client_sockfd, line_num, screenlines[line_num]); - debug_no_msg("Sending to client line:"+toString(line_num)+" "+screenlines[line_num]); -// ui_server.send(line_num,screenlines[line_num]); - } - - + ui_server.send_connection_msg_to_fd(client_sockfd, line_num, screenlines[line_num]); + debug_no_msg("Sending to client line:"+toString(line_num)+" "+screenlines[line_num]); +// ui_server.send(line_num,screenlines[line_num]); + } + for (ulong distfile_num=0; distfile_num<request_server_pkg.distfile_count; distfile_num++){ + ui_server.send_distfile_progress_msg_to_fd(client_sockfd, request_server_pkg.Pdistfile_list[distfile_num]->get_distfile_progress_str()); + } +// if (0==pkg_choose_segment(&proxy_fetcher_pkg, connection_num)){ + //If it isn’t the server, it must be client activity. If close is received, the client has gone away, and you remove it from the descriptor set. Otherwise, you “serve” the client as in the previous examples. }else{ ioctl(fd, FIONREAD, &nread); diff --git a/segget/ui_server.h b/segget/ui_server.h index 21dbc9e..3581564 100644 --- a/segget/ui_server.h +++ b/segget/ui_server.h @@ -37,9 +37,11 @@ #include <unistd.h> #include <stdlib.h> #include <string> -#include "settings.h" -#include "tui.h" - +//#include "settings.h" +//class Tpkg; +//class Tdistfile; +//#include "tui.h" +#include "pkg.h" using namespace std; #define MAX_BIND_ATTEMPTS 5 @@ -58,6 +60,7 @@ class Tui_server{ void send_connection_msg_to_all_clients(uint y, string msg); void send_log_msg_to_all_clients(string msg); void send_error_log_msg_to_all_clients(string msg); + void send_distfile_progress_msg_to_fd(uint fd, string msg); void send_distfile_progress_msg_to_all_clients(string msg); }; |