40 |
open CommonTypes |
open CommonTypes |
41 |
open CommonComplexOptions |
open CommonComplexOptions |
42 |
|
|
|
|
|
43 |
(************* ADD/REMOVE FUNCTIONS ************) |
(************* ADD/REMOVE FUNCTIONS ************) |
44 |
let check_forbidden_chars (uc : Charset.uchar) = |
let check_forbidden_chars (uc : Charset.uchar) = |
45 |
match uc with |
match uc with |
129 |
Unix.chmod new_name (Misc.int_of_octal_string !!create_dir_mask); |
Unix.chmod new_name (Misc.int_of_octal_string !!create_dir_mask); |
130 |
let best_name = file_best_name file in |
let best_name = file_best_name file in |
131 |
Unix32.destroy (file_fd file); |
Unix32.destroy (file_fd file); |
132 |
if !verbose_files then lprintf_nl "commonInteractive.file_commit: destroyed"; |
if !verbose_files then lprintf_nl "[cInt] file_commit: destroyed"; |
133 |
if Unix2.is_directory file_name then Unix2.remove_all_directory file_name; |
if Unix2.is_directory file_name then Unix2.remove_all_directory file_name; |
134 |
let impl = as_file_impl file in |
let impl = as_file_impl file in |
135 |
|
|
144 |
incoming.shdir_dirname incoming.shdir_priority |
incoming.shdir_dirname incoming.shdir_priority |
145 |
best_name new_name); |
best_name new_name); |
146 |
with e -> |
with e -> |
147 |
lprintf_nl "Exception %s while trying to share commited file" |
lprintf_nl "[cInt]Exception %s while trying to share commited file" |
148 |
(Printexc2.to_string e); |
(Printexc2.to_string e); |
149 |
end; |
end; |
150 |
|
|
152 |
done_files =:= List2.removeq file !!done_files; |
done_files =:= List2.removeq file !!done_files; |
153 |
files =:= List2.removeq file !!files; |
files =:= List2.removeq file !!files; |
154 |
|
|
155 |
if !verbose_files then lprintf_nl "commonInteractive.file_commit: going to secondaries..."; |
if !verbose_files then lprintf_nl "[cInt]file_commit: going to secondaries..."; |
156 |
List.iter (fun file -> |
List.iter (fun file -> |
157 |
(* Commit the file first, and share it after... *) |
(* Commit the file first, and share it after... *) |
158 |
try |
try |
163 |
files =:= List2.removeq file !!files; |
files =:= List2.removeq file !!files; |
164 |
|
|
165 |
with e -> |
with e -> |
166 |
lprintf_nl "Exception %s in file_commit secondaries" (Printexc2.to_string e); |
lprintf_nl "[cInt]Exception %s in file_commit secondaries" (Printexc2.to_string e); |
167 |
) secondary_files |
) secondary_files |
168 |
with e -> |
with e -> |
169 |
lprintf_nl "Exception in file_commit: %s" (Printexc2.to_string e)) |
lprintf_nl "[cInt]Exception in file_commit: %s" (Printexc2.to_string e)) |
170 |
| _ -> assert false |
| _ -> assert false |
171 |
|
|
172 |
let file_cancel file = |
let file_cancel file = |
182 |
impl.impl_file_ops.op_file_cancel impl.impl_file_val; |
impl.impl_file_ops.op_file_cancel impl.impl_file_val; |
183 |
files =:= List2.removeq file !!files; |
files =:= List2.removeq file !!files; |
184 |
with e -> |
with e -> |
185 |
lprintf_nl "Exception %s in file_cancel" (Printexc2.to_string e); |
lprintf_nl "[cInt]Exception %s in file_cancel" (Printexc2.to_string e); |
186 |
) subfiles; |
) subfiles; |
187 |
(try |
(try |
188 |
let fd = file_fd file in |
let fd = file_fd file in |
189 |
if fd != Unix32.bad_fd then Unix32.remove (file_fd file) |
if fd != Unix32.bad_fd then Unix32.remove (file_fd file) |
190 |
with e -> |
with e -> |
191 |
lprintf_nl "Sys.remove %s exception %s" |
lprintf_nl "[cInt]Sys.remove %s exception %s" |
192 |
(file_disk_name file) |
(file_disk_name file) |
193 |
(Printexc2.to_string e); ); |
(Printexc2.to_string e); ); |
194 |
Unix32.destroy (file_fd file); |
Unix32.destroy (file_fd file); |
195 |
with e -> |
with e -> |
196 |
lprintf_nl "Exception in file_cancel: %s" (Printexc2.to_string e) |
lprintf_nl "[cInt]Exception in file_cancel: %s" (Printexc2.to_string e) |
197 |
|
|
198 |
let time_to_string time = |
let time_to_string time = |
199 |
let days = time / 60 / 60 / 24 in |
let days = time / 60 / 60 / 24 in |
263 |
ignore (CommonShared.new_shared "completed" 0 ( |
ignore (CommonShared.new_shared "completed" 0 ( |
264 |
file_best_name file ) file_name); |
file_best_name file ) file_name); |
265 |
(try mail_for_completed_file file with e -> |
(try mail_for_completed_file file with e -> |
266 |
lprintf_nl "Exception %s in sendmail" (Printexc2.to_string e); |
lprintf_nl "[cInt]Exception %s in sendmail" (Printexc2.to_string e); |
267 |
); |
); |
268 |
if !!CommonOptions.chat_warning_for_downloaded then |
if !!CommonOptions.chat_warning_for_downloaded then |
269 |
chat_for_completed_file file; |
chat_for_completed_file file; |
279 |
end |
end |
280 |
end |
end |
281 |
with e -> |
with e -> |
282 |
lprintf_nl "Exception in file_completed: %s" (Printexc2.to_string e) |
lprintf_nl "[cInt]Exception in file_completed: %s" (Printexc2.to_string e) |
283 |
|
|
284 |
let file_add impl state = |
let file_add impl state = |
285 |
try |
try |
301 |
update_file_state impl state |
update_file_state impl state |
302 |
end |
end |
303 |
with e -> |
with e -> |
304 |
lprintf_nl "Exception in file_add: %s" (Printexc2.to_string e) |
lprintf_nl "[cInt]Exception in file_add: %s" (Printexc2.to_string e) |
305 |
|
|
306 |
let server_remove server = |
let server_remove server = |
307 |
try |
try |
313 |
servers =:= Intmap.remove (server_num server) !!servers; |
servers =:= Intmap.remove (server_num server) !!servers; |
314 |
end |
end |
315 |
with e -> |
with e -> |
316 |
lprintf_nl "Exception in server_remove: %s" (Printexc2.to_string e) |
lprintf_nl "[cInt]Exception in server_remove: %s" (Printexc2.to_string e) |
317 |
|
|
318 |
let server_add impl = |
let server_add impl = |
319 |
let server = as_server impl in |
let server = as_server impl in |
352 |
end |
end |
353 |
|
|
354 |
with e -> |
with e -> |
355 |
lprintf_nl "Exception in friend_remove: %s" (Printexc2.to_string e) |
lprintf_nl "[cInt]Exception in friend_remove: %s" (Printexc2.to_string e) |
356 |
|
|
357 |
let contact_add c = |
let contact_add c = |
358 |
let impl = as_client_impl c in |
let impl = as_client_impl c in |
373 |
impl.impl_client_ops.op_client_clear_files impl.impl_client_val |
impl.impl_client_ops.op_client_clear_files impl.impl_client_val |
374 |
end |
end |
375 |
with e -> |
with e -> |
376 |
lprintf_nl "Exception in contact_remove: %s" (Printexc2.to_string e) |
lprintf_nl "[cInt]Exception in contact_remove: %s" (Printexc2.to_string e) |
377 |
|
|
378 |
|
|
379 |
let time_of_sec sec = |
let time_of_sec sec = |
695 |
!names |
!names |
696 |
|
|
697 |
let apply_on_fully_qualified_options name f = |
let apply_on_fully_qualified_options name f = |
698 |
if !verbose then lprintf_nl "For option %s" name; |
if !verbose then lprintf_nl "[cInt]Change option %s" name; |
699 |
let rec iter prefix opfile = |
let rec iter prefix opfile = |
700 |
let args = simple_options prefix opfile in |
let args = simple_options prefix opfile in |
701 |
List.iter (fun o -> |
List.iter (fun o -> |
718 |
false |
false |
719 |
with Exit -> true |
with Exit -> true |
720 |
)) then begin |
)) then begin |
721 |
lprintf_nl "Could not set option %s" name; |
lprintf_nl "[cInt]Could not set option %s" name; |
722 |
raise Not_found |
raise Not_found |
723 |
end |
end |
724 |
with Exit -> () |
with Exit -> () |
776 |
| _ -> () |
| _ -> () |
777 |
end |
end |
778 |
| QNone -> |
| QNone -> |
779 |
lprintf_nl "LimewireInteractive.start_search: QNone in query"; |
lprintf_nl "[cInt]start_search: QNone in query"; |
780 |
() |
() |
781 |
in |
in |
782 |
iter query; |
iter query; |