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
26 * In which directory should the .ini files be stored ?
27 * Which directories should the temp/ and incoming/ be ?
28 * Which other directories are shared ?
29 * Which connection link is used ?
32 All these replies should be stored in a basic file ~/.mldonkey_install.ini
33 that should also be loaded at startup by mldonkey.
39 let home_dir = (try Sys.getenv
"HOME" with _
-> ".")
41 let config_dir_basename =
42 if Autoconf.windows
then "mldonkey" else ".mldonkey"
44 let config_dir = Filename.concat
home_dir config_dir_basename
46 let _ = Unix2.safe_mkdir
config_dir
48 let installer_name = Filename.concat
config_dir "installer.ini"
50 let installer_ini = create_options_file
installer_name
52 let mldonkey_directory =
53 define_option
installer_ini ["mldonkey_directory"]
54 "The directory where mldonkey's option files are" string_option
55 (Filename.concat
home_dir ".mldonkey")
58 (try Options.load
installer_ini with _ -> ())
60 module Config
= struct
66 let main_box = GPack.vbox
() in
70 let box = new string_param_box p
in
71 let _ = main_box#pack ~expand
: false ~padding
: 2 box#
box in
74 let box = new combo_param_box p
in
75 let _ = main_box#pack ~expand
: false ~padding
: 2 box#
box in
78 let box = new text_param_box p
in
79 let _ = main_box#pack ~expand
: p
.string_expand ~padding
: 2 box#
box in
82 let box = new bool_param_box p
in
83 let _ = main_box#pack ~expand
: false ~padding
: 2 box#
box in
86 let box = new filename_param_box p
in
87 let _ = main_box#pack ~expand
: false ~padding
: 2 box#
box in
91 let _ = main_box#pack ~expand
: true ~padding
: 2 box#
box in
94 let box = new custom_param_box p
in
95 let _ = main_box#pack ~expand
: p
.custom_expand ~padding
: 2 box#
box in
98 let box = new color_param_box p
in
99 let _ = main_box#pack ~expand
: false ~padding
: 2 box#
box in
102 let box = new font_param_box p
in
103 let _ = main_box#pack ~expand
: false ~padding
: 2 box#
box in
106 let box = new date_param_box p
in
107 let _ = main_box#pack ~expand
: false ~padding
: 2 box#
box in
110 let list_param_box = List.map
f param_list
in
112 List.iter
(fun param_box
-> param_box#apply
) list_param_box
119 class tab
(notebook
: GPack.notebook
) label
=
120 let tab_label = GMisc.label ~text
: label
() in
121 let vbox = GPack.vbox () in
122 let main_hbox = GPack.hbox ~packing
:
123 (vbox#pack ~fill
: true ~expand
: true) () in
124 let main_vbox = GPack.vbox ~packing
:
125 (main_hbox#pack ~fill
: true ~expand
: true) () in
127 let button_hbox = GPack.hbox ~packing
:
128 (vbox#pack ~expand
: false ~padding
: 10) () in
131 let previous_slide = GButton.button ~width
: 100 ~label
: "Previous" ()
132 ~packing
: (button_hbox#pack ~padding
: 10) in
134 let cancel = GButton.button ~label
: "Cancel" ()
135 ~packing
: (button_hbox#pack ~padding
: 10) in
137 let next_slide = GButton.button ~width
: 100 ~label
: "Next" ()
138 ~packing
: (button_hbox#pack ~padding
: 10) in
142 method vbox = main_vbox
145 notebook#append_page ~
tab_label: tab_label#coerce
vbox#coerce
;
146 ignore
(next_slide#connect#clicked
147 (fun () -> notebook#next_page
()));
148 ignore
(previous_slide#connect#clicked
149 (fun () -> notebook#previous_page
()));
150 ignore
(cancel#connect#clicked
156 let create_downloads_ini () =
158 let filename = Filename.concat
!!mldonkey_directory "downloads.ini" in
159 let downloads_ini = create_options_file
filename in
161 let shared_directories =
162 define_option
downloads_ini ["shared_directories" ]
163 "Directories where files will be shared"
164 (list_option string_option
) []
168 define_option
downloads_ini ["gui_port"] "port for user interaction" int_option
4001
172 define_option
downloads_ini ["http_port"] "The port used to connect to your client with a WEB browser" int_option
4080
175 let telnet_port = define_option
downloads_ini ["telnet_port"] "port for user interaction" port_option
4000
179 define_option
downloads_ini ["http_login"] "Your login when using a WEB browser" string_option
""
183 define_option
downloads_ini ["http_password"] "Your password when using a WEB browser" string_option
""
186 let max_hard_upload_rate = define_option
downloads_ini ["max_hard_upload_rate"]
187 "The maximal upload rate you can tolerate on your link in kBytes/s (0 = no limit)
188 The limit will apply on all your connections (clients and servers) and both
189 control and data messages." int_option
0
192 let max_hard_download_rate = define_option
downloads_ini ["max_hard_download_rate"]
193 "The maximal download rate you can tolerate on your link in kBytes/s (0 = no limit)
194 The limit will apply on all your connections (clients and servers) and both
195 control and data messages." int_option
0
198 let password = define_option
downloads_ini ["password"]
199 "The password to access your client from the GUI (setting it disables
200 the command-line client)" string_option
""
203 let allowed_ips = define_option
downloads_ini ["allowed_ips"]
204 "list of IP address allowed to control the client via telnet/GUI/WEB"
205 (list_option
Ip.option) [Ip.of_string
"127.0.0.1"]
208 Options.save_with_help
downloads_ini;
209 lprintf
"%s created successfully" filename; lprint_newline
()
212 let gui = new Gui_installer_base.window
() in
213 let window = gui#
window in
214 let notebook = gui#
notebook in
215 ignore
(window#connect#destroy ~callback
:GMain.Main.quit
);
217 let directories_tab = new tab
notebook "Directories" in
220 let param = Configwin_ihm.filename "MLdonkey directory:" !!mldonkey_directory
222 let directories_box, directories_apply
= Config.box [param] in
223 directories_tab#
vbox#pack ~expand
: true ~fill
: true directories_box#coerce
;
225 let connection_tab = new tab
notebook "Connection" in
226 let security_tab = new tab
notebook "Interfaces" in
228 let save_tab = new tab
notebook "Save" in
231 let label = GMisc.label ~text
:
232 "Click on the Save button to save this configuration.\n Be careful: it will erase any previous configuration."
234 ~packing
:(save_tab#
vbox#pack ~expand
: true ~fill
: true ~padding
: 100) () in
236 let save_button = GButton.button ~height
: 30 ~width
: 100 ~
label: "Save" ()
237 ~packing
: (save_tab#
vbox#pack ~expand
: true ~fill
: true ~padding
: 10) in
238 ignore
(save_button#connect#clicked
240 directories_apply
();
243 Unix2.safe_mkdir
!!mldonkey_directory;
244 create_downloads_ini ();
245 Options.save_with_help
installer_ini;
246 lprintf
"%s created successfully" installer_name; lprint_newline
();