[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Mldonkey-commits] Changes to mldonkey/src/gtk2/gui/guiGlobal.ml
From: |
mldonkey-commits |
Subject: |
[Mldonkey-commits] Changes to mldonkey/src/gtk2/gui/guiGlobal.ml |
Date: |
Mon, 31 Oct 2005 13:34:11 -0500 |
Index: mldonkey/src/gtk2/gui/guiGlobal.ml
diff -u mldonkey/src/gtk2/gui/guiGlobal.ml:1.1
mldonkey/src/gtk2/gui/guiGlobal.ml:1.2
--- mldonkey/src/gtk2/gui/guiGlobal.ml:1.1 Wed Mar 2 19:45:11 2005
+++ mldonkey/src/gtk2/gui/guiGlobal.ml Mon Oct 31 18:34:02 2005
@@ -32,6 +32,15 @@
(* The name of the client given by MLnet. *)
let client_name = ref ""
+(* The max download rate of the client given by MLnet in ko/s. *)
+let max_hard_download_rate = ref 64
+
+(* The max upload rate of the client given by MLnet in ko/s. *)
+let max_hard_upload_rate = ref 16
+
+(* The time between updates of the client given by MLnet in ms. *)
+let update_gui_delay = ref 1000
+
(* Number of known servers. *)
let nservers = ref 0
@@ -63,20 +72,26 @@
(* *)
(*************************************************************************)
-(* Information on networks. *)
let networks_filtered = ref ([] : int list)
let (networks : (int, GuiTypes2.net_info) Hashtbl.t) = Hashtbl.create 13
-(* Information on clients. *)
-let (sources : (int, GuiTypes2.source_info) Hashtbl.t) = Hashtbl.create 1023
+let (files : (int, GuiTypes2.g_file_info) Hashtbl.t) = Hashtbl.create 27
-let (results : (int, GuiTypes2.res_info) Hashtbl.t) = Hashtbl.create 103
+let (servers : (int, GuiTypes.server_info) Hashtbl.t) = Hashtbl.create 207
+
+let (rooms : (int, GuiTypes.room_info) Hashtbl.t) = Hashtbl.create 207
+
+let (sources : (int, GuiTypes2.source_info) Hashtbl.t) = Hashtbl.create 1023
+let (results : (int, GuiTypes2.res_info) Hashtbl.t) = Hashtbl.create 1023
-(* Information on users. *)
let (users : (int, GuiTypes.user_info) Hashtbl.t) = Hashtbl.create 1023
+let (shared_files : (int, GuiTypes2.shared_file) Hashtbl.t) = Hashtbl.create
103
+
+let (file_by_uid : (CommonTypes.uid_type, string) Hashtbl.t) = Hashtbl.create
103
+
(*************************************************************************)
(* *)
(* Global functions *)
@@ -92,12 +107,16 @@
search_counter := 0;
use_interested_in_sources := false;
(* tables *)
-
Hashtbl.clear networks;
+ Hashtbl.clear files;
+ Hashtbl.clear servers;
+ Hashtbl.clear rooms;
Hashtbl.clear sources;
Hashtbl.clear results;
- Hashtbl.clear users
-
+ Hashtbl.clear users;
+ Hashtbl.clear shared_files;
+ Hashtbl.clear file_by_uid;
+ Gc.compact ()
let console_message = ref (fun s ->
lprintf "CONSOLE: %s" s;
@@ -110,7 +129,7 @@
done
external setncnumeric : unit -> unit = "ml_setlcnumeric" "noalloc"
-
+
let _ =
ignore (GMain.Main.init ~setlocale: true ());
setncnumeric ();
@@ -124,11 +143,17 @@
label#misc#modify_font (Pango.Font.from_string !!O.gtk_font_list);
let font_metrics = label#misc#pango_context#get_metrics () in
char_width := GPango.to_pixels font_metrics#approx_char_width;
- digit_width := GPango.to_pixels font_metrics#approx_digit_width;
- Printf.printf "char_width : %d digit_width : %d\n" !char_width !digit_width;
- flush stdout
+ digit_width := GPango.to_pixels font_metrics#approx_digit_width
-let get_files = ref (fun (l : int list) -> ([] : GuiTypes.file_info list))
+let get_files list =
+ let l = ref [] in
+ List.iter (fun file_num ->
+ try
+ let f = Hashtbl.find files file_num in
+ l := f :: !l
+ with _ -> ()
+ ) list;
+ !l
let is_docked = ref false
@@ -141,3 +166,36 @@
}
let (set_systray_callback : ((GuiTypes2.button_types -> unit) -> unit) ref) =
ref (fun _ -> ())
+
+open GuiTypes2
+open CommonTypes
+
+let check_usefull_source s =
+ let is_not_source = if s.source_files_requested = [] then true else false in
+ let is_not_friend = if client_browsed_tag land s.source_type = 0 then false
else true in
+ let is_not_uploader = if source_only land s.source_has_upload = 1 then true
else false in
+ if is_not_source && is_not_friend && is_not_uploader
+ then (Hashtbl.remove sources s.source_num; false)
+ else true
+
+
+let hashtbl_update_sources s s_new =
+ s.source_kind <- s_new.source_kind;
+ s.source_state <- s_new.source_state;
+ s.source_type <- s_new.source_type;
+ s.source_tags <- s_new.source_tags;
+ s.source_name <- s_new.source_name;
+ s.source_files <- s_new.source_files;
+ s.source_rating <- s_new.source_rating;
+ s.source_chat_port <- s_new.source_chat_port;
+ s.source_connect_time <- s_new.source_connect_time;
+ s.source_last_seen <- s_new.source_last_seen;
+ s.source_software <- s_new.source_software;
+ s.source_downloaded <- s_new.source_downloaded;
+ s.source_uploaded <- s_new.source_uploaded;
+ s.source_upload_rate <- s_new.source_upload_rate;
+ s.source_download_rate <- s_new.source_download_rate;
+ s.source_upload <- s_new.source_upload;
+ s.source_has_upload <- s_new.source_has_upload;
+ s.source_availability <- s_new.source_availability;
+ s.source_files_requested <- s_new.source_files_requested
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Mldonkey-commits] Changes to mldonkey/src/gtk2/gui/guiGlobal.ml,
mldonkey-commits <=