1 (* Copyright 2001, 2002 b8_bavard, b8_fee_carabine, INRIA *)
3 This file is part of mldonkey.
5 mldonkey is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 mldonkey is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with mldonkey; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 (** Global variables. *)
23 (** Number of known servers. *)
26 (** Number of connected servers. *)
27 let nconnected_servers = ref 0
29 (** Number of friends. *)
32 (** Number of query results. *)
35 (** Number of locations for selected downloading file. *)
36 let nlocations = ref 0
38 (** Number of connected locations for selected downloading file. *)
39 let nclocations = ref 0
41 (** Number of downloaded files *)
42 let ndownloaded = ref 0
44 (** Number of downloading files *)
45 let ndownloads = ref 0
47 (** Information on locations. *)
48 let (locations
: (int, GuiTypes.client_info
) Hashtbl.t
) = Hashtbl.create
103
50 (** Information on locations. *)
51 let (results
: (int, CommonTypes.result_info
) Hashtbl.t
) = Hashtbl.create
103
53 (** Search counter. *)
54 let search_counter = ref 0
59 mutable net_enabled
: bool;
60 net_menu_item
: GMenu.check_menu_item
;
61 mutable net_displayed
: bool;
64 let networks_filtered = ref ([] : int list
)
68 let (networks
: (int, net_info
) Hashtbl.t
) = Hashtbl.create
13
70 let network_name num
= try
71 match (Hashtbl.find networks num
).net_name
with
72 | "Direct Connect" -> "DC"
75 | "OpenNapster" -> "NAP"
79 | "Soulseek" -> "SLSK"
83 let (users
: (int, GuiTypes.user_info
) Hashtbl.t
) = Hashtbl.create
1023
86 let (client_sections
: (string * (string * GuiTypes.option_widget
* string) list
ref) list
ref) = ref []
87 let (plugins_sections
: (string * (string * GuiTypes.option_widget
* string) list
ref) list
ref) = ref []
89 type mldonkey_option
= {
90 mutable option_old_value
: string;
91 option_value
: string ref;
94 let (options_values
: (string, mldonkey_option
) Hashtbl.t
) = Hashtbl.create
100
96 let (availabilities
: (string * file_info
) Intmap.t
ref
97 Intmap.t
ref) = ref Intmap.empty
102 nconnected_servers := 0;
109 Hashtbl.clear locations
;
110 Hashtbl.clear networks
;
111 Hashtbl.clear results
;
114 Hashtbl.clear options_values
;
115 client_sections
:= [];
116 plugins_sections
:= []
118 let console_message = ref (fun s
->
119 lprintf
"CONSOLE: %s" s
;
123 let gtk_handler timer
=
124 while Glib.Main.pending
() do
125 ignore
(Glib.Main.iteration
false)
128 external setncnumeric
: unit -> unit = "ml_setlcnumeric" "noalloc"
131 ignore
(GMain.Main.init ~setlocale
: true ());
133 BasicSocket.add_infinite_timer
0.1 gtk_handler
135 let top_menus = ref ([]: (string * (GMenu.menu
-> unit)) list
)
137 let scanned_ports = ref ([] : ((string * int) list
))
138 let new_scanned_port = ref true
141 let networks_combo all_possible
=
143 Hashtbl.iter
(fun num net
->
144 if net
.net_enabled
then
145 nets := (net
.net_name
, num
) :: !nets
147 let nets = if all_possible
then
148 ("All Networks", 0) :: !nets
150 let wcombo = GEdit.combo
151 ~popdown_strings
: (List.map fst
nets)