mldonkey-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Mldonkey-commits] Changes to mldonkey/src/networks/donkey/donkeyInterac


From: mldonkey-commits
Subject: [Mldonkey-commits] Changes to mldonkey/src/networks/donkey/donkeyInteractive.ml
Date: Sun, 10 Jul 2005 19:19:21 -0400

Index: mldonkey/src/networks/donkey/donkeyInteractive.ml
diff -u mldonkey/src/networks/donkey/donkeyInteractive.ml:1.50 
mldonkey/src/networks/donkey/donkeyInteractive.ml:1.51
--- mldonkey/src/networks/donkey/donkeyInteractive.ml:1.50      Thu Jun 23 
11:41:12 2005
+++ mldonkey/src/networks/donkey/donkeyInteractive.ml   Sun Jul 10 23:19:16 2005
@@ -21,7 +21,7 @@
 open Printf2
 open Md4
 open Options
-  
+
 open BasicSocket
 open TcpBufferedSocket
 
@@ -34,11 +34,11 @@
 open CommonUser
 open CommonInteractive
 open CommonNetwork
-open CommonDownloads  
+open CommonDownloads
 open CommonTypes
 open CommonComplexOptions
 open CommonFile
-  
+
 open DonkeySearch
 open DonkeyMftp
 open DonkeyProtoCom
@@ -53,21 +53,21 @@
 open CommonGlobals
 open CommonOptions
 open DonkeyStats
-  
+
 let result_name r =
   match r.result_names with
     [] -> None
   | name :: _ -> Some name
 
 
-let op_file_proposed_filenames file = 
+let op_file_proposed_filenames file =
   if !verbose then lprintf "op_file_proposed_filenames\n";
   List2.tail_map fst file.file_filenames
-      
+
 let reconnect_all file =
   DonkeyProtoOvernet.Overnet.recover_file file;
   DonkeyProtoKademlia.Kademlia.recover_file file;
-  
+
 (* This is expensive, no ? *)
 (*  DonkeySources.reschedule_sources file; *)
   List.iter (fun s ->
@@ -76,16 +76,16 @@
           s.server_waiting_queries <- file :: s.server_waiting_queries
       | _ -> ()
   ) (connected_servers())
-    
-let forget_search s =  
+
+let forget_search s =
   if !xs_last_search = s.search_num then begin
       xs_last_search := (-1);
       xs_servers_list := [];
     end;
   DonkeyProtoKademlia.Kademlia.forget_search s;
   DonkeyProtoOvernet.Overnet.forget_search s
-  
-  
+
+
 let load_server_met filename =
   if !!update_server_list_server then
   try
@@ -97,7 +97,7 @@
           let server = check_add_server r.S.ip r.S.port in
           List.iter (fun tag ->
               match tag with
-                { tag_name = Field_UNKNOWN "name"; tag_value = String s } -> 
+                { tag_name = Field_UNKNOWN "name"; tag_value = String s } ->
                   server.server_name <- s;
               |  { tag_name = Field_UNKNOWN "description" ; tag_value = String 
s } ->
                   server.server_description <- s
@@ -113,23 +113,23 @@
   else 0
 
 let already_done = Failure "File already downloaded (use 'force_download' if 
necessary)"
-      
+
 let really_query_download filenames size md4 location old_file absents =
-  
+
   if !verbose then lprintf "really_query_download..................... \n";
   begin
     try
       let file = Hashtbl.find files_by_md4 md4 in
-      if file_state file = FileDownloaded then 
+      if file_state file = FileDownloaded then
         raise already_done;
     with Not_found -> ()
   end;
-  
-  List.iter (fun file -> 
-      if file.file_md4 = md4 then raise already_done) 
+
+  List.iter (fun file ->
+      if file.file_md4 = md4 then raise already_done)
   !current_files;
 
-  let file_diskname = Filename.concat !!temp_directory 
+  let file_diskname = Filename.concat !!temp_directory
     (file_string_of_uid (Ed2k md4)) in
   begin
     match old_file with
@@ -157,7 +157,7 @@
     let other_names = [] in
     let filenames = List.fold_left (fun names name ->
           if List.mem name names then names else names @ [name]
-      ) filenames other_names in 
+      ) filenames other_names in
     (List.map (fun name -> name , { ips=[]; nips=0}) filenames)
   in
 
@@ -165,7 +165,7 @@
   begin
     match absents with
       None -> ()
-    | Some absents -> 
+    | Some absents ->
         match file.file_swarmer with
           None -> assert false
         | Some swarmer ->
@@ -175,13 +175,13 @@
 
   DonkeyProtoOvernet.Overnet.recover_file file;
   DonkeyProtoKademlia.Kademlia.recover_file file;
-  
+
   current_files := file :: !current_files;
 (*  !file_change_hook file; *)
 (*  set_file_size file (file_size file); *)
-  
+
   DonkeyNeighbours.recover_downloads [file];
-  
+
   List.iter (fun s ->
       add_query_location file s
   ) (connected_servers());
@@ -192,35 +192,35 @@
           udp_server_send s (DonkeyProtoUdp.QueryLocationUdpReq 
[file.file_md4])
       ) servers
     with _ -> ());
-  
+
   (match location with
       None -> ()
     | Some num ->
         let c = client_find num in
         client_connect c
         (*
-        try 
+        try
           let c = find_client num in
           (match c.client_kind with
-              Indirect_location -> 
+              Indirect_location ->
                 if not (Intmap.mem c.client_num file.file_indirect_locations) 
then
                   file.file_indirect_locations <- Intmap.add c.client_num c
                     file.file_indirect_locations
-            
-            | _ -> 
+
+            | _ ->
                 if not (Intmap.mem c.client_num file.file_known_locations) then
                   new_known_location file c
           );
           if not (List.memq file c.client_files) then
             c.client_files <- file :: c.client_files;
           match client_state c with
-            NotConnected -> 
+            NotConnected ->
               connect_client !!client_ip [file] c
           | Connected_busy | Connected_idle | Connected_queued ->
               begin
                 match c.client_sock with
                   None -> ()
-                | Some sock -> 
+                | Some sock ->
                     DonkeyClient.query_files c sock [file]
               end
           | _ -> ()
@@ -230,19 +230,19 @@
   as_file file
 
 let query_download filenames size md4 location old_file absents force =
-  
+
 (* TODO RESULT
   if not force then
-    List.iter (fun m -> 
+    List.iter (fun m ->
         if m = md4 then begin
             let r = try
                 DonkeyIndexer.find_result md4
-              with _ -> 
+              with _ ->
 (* OK, we temporary create a result corresponding to the
 file that should have been download, but has already been downloaded *)
-                  
-                  
-                  let r = { 
+
+
+                  let r = {
                       result_num = 0;
                       result_network = network.network_num;
                       result_md4 = md4;
@@ -254,15 +254,15 @@
                       result_comment = "";
                       result_done = false;
                     } in
-                  DonkeyIndexer.index_result_no_filter r 
+                  DonkeyIndexer.index_result_no_filter r
             in
             aborted_download := Some (result_num (as_result r.result_result));
             raise already_done
-          end) 
+          end)
     !!old_files; *)
   really_query_download filenames size md4 location old_file absents
 
-let result_download r filenames force =  
+let result_download r filenames force =
   let rec iter uids =
     match uids with
       [] -> raise IgnoreNetwork
@@ -273,8 +273,8 @@
         | _  -> iter tail
   in
   iter r.result_uids
-  
-let load_prefs filename = 
+
+let load_prefs filename =
   try
     let module P = DonkeyImport.Pref in
     let s = File.to_string filename in
@@ -284,8 +284,8 @@
       lprintf "Exception %s while loading %s\n" (Printexc2.to_string e)
       filename;
       [], []
-      
-let import_temp temp_dir =  
+
+let import_temp temp_dir =
   let list = Unix2.list_directory temp_dir in
   let module P = DonkeyImport.Part in
   List.iter (fun filename ->
@@ -301,21 +301,21 @@
             List.iter (fun tag ->
                 match tag with
                   { tag_name = Field_Filename; tag_value = String s } ->
-                    lprintf "Import Donkey %s\n" s; 
-                    
+                    lprintf "Import Donkey %s\n" s;
+
                     filenames := s :: !filenames;
                 | { tag_name = Field_Size; tag_value = Uint64 v } ->
                     size := v
                 | _ -> ()
             ) f.P.tags;
-            let file = query_download !filenames !size f.P.md4 None 
+            let file = query_download !filenames !size f.P.md4 None
               (Some filename) (Some (List.rev f.P.absents)) true;
-            in 
+            in
             ()
       with _ -> ()
   ) list
-  
-  
+
+
 let import_config dirname =
   ignore (load_server_met (Filename.concat dirname "server.met"));
   let ct, ot = load_prefs (Filename.concat dirname "pref.met") in
@@ -341,7 +341,7 @@
   ) ot;
 
   import_temp !temp_dir
-  
+
 let broadcast msg =
   let s = msg ^ "\n" in
   let len = String.length s in
@@ -366,14 +366,14 @@
         let name = if tags.T.artist <> "" then
             Printf.sprintf "%s/%s" tags.T.artist name
           else name in
-        name          
+        name
     | _ -> name
 else *)
   name
     *)
 
 let print_file buf file =
-  Printf.bprintf buf "[%-5d] %s %10Ld %32s %s" 
+  Printf.bprintf buf "[%-5d] %s %10Ld %32s %s"
     (file_num file)
   (file_best_name file)
   (file_size file)
@@ -391,7 +391,7 @@
         (Ip.to_string ip)
         port
           (match c.client_source.DonkeySources.source_sock with
-            NoConnection  -> 
+            NoConnection  ->
               string_of_date (c.client_source.DonkeySources.source_age)
           | ConnectionWaiting _ -> "Connecting"
           | Connection _ -> "Connected")
@@ -400,7 +400,7 @@
           (client_num c)
         "Indirect"
           (match c.client_source.DonkeySources.source_sock with
-            NoConnection -> 
+            NoConnection ->
               string_of_date (c.client_source.DonkeySources.source_age)
           | ConnectionWaiting _ -> "Connecting"
           | Connection _ -> "Connected")
@@ -411,15 +411,15 @@
     None -> ()
   | Some swarmer ->
       let bitmap = Int64Swarmer.verified_bitmap swarmer in
-      Printf.bprintf buf "\nChunks: %s\n" bitmap      
-  
+      Printf.bprintf buf "\nChunks: %s\n" bitmap
+
 let recover_md4s md4 =
-  let file = find_file md4 in  
+  let file = find_file md4 in
   match file.file_swarmer with
     None -> ()
   | Some swarmer ->
       Int64Swarmer.verify_all_chunks swarmer false
-  
+
   (*
   if file.file_chunks <> [||] then
     for i = 0 to file.file_nchunks - 1 do
@@ -429,9 +429,9 @@
         | PartialVerified x -> PartialTemp x
         | x -> x)
     done
-*)    
+*)
+
 
-    
 let parse_donkey_url url =
   match String2.split (String.escaped url) '|' with
 (* TODO RESULT *)
@@ -449,7 +449,7 @@
       let ip = Ip.of_string ip in
       let s = force_add_server ip (int_of_string port) in
       server_connect (as_server s.server_server);
-      true 
+      true
   | "ed2k://" :: "friend" :: ip :: port :: _
   | "friend" :: ip :: port :: _ ->
       let ip = Ip.of_string ip in
@@ -457,10 +457,10 @@
       let c = new_client (Direct_address (ip,port)) in
       friend_add c;
       true
-  
+
   | _ ->  false
 
-      
+
 let register_commands list =
   register_commands
     (List2.tail_map (fun (n,f,h) -> (n, "Network/Edonkey", f,h)) list)
@@ -476,13 +476,13 @@
         in
         let ip = Ip.from_name ip in
         let port = int_of_string port in
-        
+
         let s = force_add_server ip port in
-        Printf.bprintf buf "New server %s:%d\n" 
+        Printf.bprintf buf "New server %s:%d\n"
           (Ip.to_string ip) port;
         ""
     ), "<ip> [<port>] :\t\t\tadd a server";
-    
+
     "afr", Arg_multiple (fun args o ->
         let buf = o.conn_buf in
         let ip, port =
@@ -497,30 +497,30 @@
         friend_add c;
         "friend added";
     ),  "<ip> [<port>] :\t\t\tadd a friend";
-    
+
     "vu", Arg_none (fun o ->
         let buf = o.conn_buf in
-        Printf.sprintf 
-          "Upload credits : %d minutes\nUpload disabled for %d minutes" 
+        Printf.sprintf
+          "Upload credits : %d minutes\nUpload disabled for %d minutes"
           !CommonUploads.upload_credit !CommonUploads.has_upload;
-    
+
     ), ":\t\t\t\t\tview upload credits";
-    
-    
+
+
     "comments", Arg_one (fun filename o ->
         let buf = o.conn_buf in
-(* TODO        DonkeyIndexer.load_comments filename; 
+(* TODO        DonkeyIndexer.load_comments filename;
         DonkeyIndexer.save_comments (); *)
         "comments loaded and saved"
     ), "<filename> :\t\t\tload comments from file";
-    
+
     "comment", Arg_two (fun md4 comment o ->
         let buf = o.conn_buf in
         let md4 = Md4.of_string md4 in
 (* TODO        DonkeyIndexer.add_comment md4 comment; *)
         "Comment added"
     ), "<md4> \"<comment>\" :\t\tadd comment on a md4";
-    
+
     "import", Arg_one (fun dirname o ->
         let buf = o.conn_buf in
         try
@@ -530,7 +530,7 @@
             Printf.sprintf "error %s while loading config" (
               Printexc2.to_string e)
     ), "<dirname> :\t\t\timport the config from dirname";
-    
+
     "import_temp", Arg_one (fun dirname o ->
         let buf = o.conn_buf in
         try
@@ -540,26 +540,26 @@
             Printf.sprintf "error %s while loading temp files" (
               Printexc2.to_string e)
     ), "<temp_dir> :\t\t\timport the old edonkey temp directory";
-    
+
     "load_old_history", Arg_none (fun o ->
         let buf = o.conn_buf in
 (* TODO        DonkeyIndexer.load_old_history (); *)
         "Old history loaded"
     ), ":\t\t\tload history.dat file";
-    
+
     "servers", Arg_one (fun filename o ->
        let nservers = List.length (Hashtbl2.to_list servers_by_key) in
         let buf = o.conn_buf in
         try
           let n = load_server_met filename in
-          Printf.sprintf "%d servers found, %d new ones inserted" 
+          Printf.sprintf "%d servers found, %d new ones inserted"
            n
            ((List.length (Hashtbl2.to_list servers_by_key)) - nservers)
-        with e -> 
+        with e ->
             Printf.sprintf "error %s while loading file" (Printexc2.to_string 
e)
     ), "<filename> :\t\t\tadd the servers from a server.met file";
-    
-    
+
+
     "id", Arg_none (fun o ->
         let buf = o.conn_buf in
         List.iter (fun s ->
@@ -575,10 +575,10 @@
         ) (connected_servers());
         ""
     ), ":\t\t\t\t\tprint ID on connected servers";
-    
+
     "set_brothers", Arg_multiple (fun args o ->
         let buf = o.conn_buf in
-        
+
         let files = ref [] in
         List.iter (fun arg ->
             let num = int_of_string arg in
@@ -589,17 +589,17 @@
                   end
             ) !current_files
         ) args;
-        
-        DonkeySources.set_brothers 
+
+        DonkeySources.set_brothers
           (List.map (fun file -> file.file_sources) !files);
-        brotherhood =:= 
+        brotherhood =:=
           (List.map (fun file -> file.file_md4) !files) :: !!brotherhood;
         "    are now defined as colocated"
     ) , "<f1> < f2> ... :\t\tdefine these files as probably colocated";
-    
+
     "recover_bytes", Arg_multiple (fun args o ->
         let buf = o.conn_buf in
-        
+
         List.iter (fun arg ->
             let num = int_of_string arg in
             List.iter (fun file ->
@@ -612,9 +612,9 @@
                         Int64Swarmer.set_present swarmer segments;
                         let new_downloaded = Int64Swarmer.downloaded swarmer in
                         Printf.bprintf buf "Recovered %Ld bytes for %s\n"
-                          (new_downloaded -- old_downloaded) 
+                          (new_downloaded -- old_downloaded)
                         (file_best_name file)
-                        
+
                   end
             ) !current_files
         ) args;
@@ -632,7 +632,7 @@
         ) servers_by_key;
         "ok"
     ), "<true/false> <ip> :\t\tset the server with this IP as preferred";
-    
+
     "bs", Arg_multiple (fun args o ->
         List.iter (fun arg ->
             let ip = Ip.of_string arg in
@@ -640,12 +640,12 @@
         ) args;
         "done"
     ), "<ip1> <ip2> ... :\t\t\tadd these IPs to the servers black list";
-    
+
     "port", Arg_one (fun arg o ->
         donkey_port =:= int_of_string arg;
         "new port will change at next restart"),
     "<port> :\t\t\t\tchange connection port";
-    
+
     "add_url", Arg_two (fun kind url o ->
         let buf = o.conn_buf in
         let v = (kind, 1, url) in
@@ -654,36 +654,36 @@
         CommonWeb.load_url kind url;
         "url added to web_infos. downloading now"
     ), "<kind> <url> :\t\t\tload this file from the web. Kind is either 
server.met (if the downloaded file is a server.met)";
-    
+
     "scan_temp", Arg_none (fun o ->
         let buf = o.conn_buf in
         let list = Unix2.list_directory !!temp_directory in
-        
+
         let counter = ref 0 in
         let tr = ref "dl-1" in
-        
+
         if use_html_mods o then begin
 
-Printf.bprintf buf 
+Printf.bprintf buf
 "\\<script language=javascript\\>
-\\<!-- 
+\\<!--
 function submitRenameForm(i) {
 var formID = document.getElementById(\\\"renameForm\\\" + i)
 var regExp = new RegExp (' ', 'gi') ;
-var renameTextOut = formID.newName.value.replace(regExp, '+'); 
+var renameTextOut = formID.newName.value.replace(regExp, '+');
 parent.fstatus.location.href='submit?q=rename+'+i+'+\\\"'+renameTextOut+'\\\"';
 }
 //--\\>
 \\</script\\>";
-          
-          html_mods_table_header buf "scan_tempTable" "scan_temp" [ 
-            ( "0", "srh", "Filename", "Filename (press ENTER to rename)" ) ; 
+
+          html_mods_table_header buf "scan_tempTable" "scan_temp" [
+            ( "0", "srh", "Filename", "Filename (press ENTER to rename)" ) ;
             ( "0", "srh", "Status", "Status" ) ;
             ( "0", "srh", "MD4 (link=ed2k)", "MD4 (link=ed2k)" ); ];
-        
+
 
                end;
-        
+
         List.iter (fun filename ->
             incr counter;
             if (!counter mod 2 == 0) then tr := "dl-1"
@@ -710,23 +710,23 @@
               try
                 let file = find_file md4 in
                 if use_html_mods o then
-                                 let fnum = (file_num file) in 
+                                 let fnum = (file_num file) in
                   Printf.bprintf buf "
                                \\<tr class=\\\"%s\\\"\\>\\<td 
class=\\\"sr\\\"\\>
                                \\<form name=\\\"renameForm%d\\\" 
id=\\\"renameForm%d\\\" action=\\\"javascript:submitRenameForm(%d);\\\"\\>
                                \\<input style=\\\"font: 8pt sans-serif\\\" 
name=\\\"newName\\\" type=text size=50 
value=\\\"%s\\\"\\>\\</input\\>\\</td\\>\\</form\\>
-                \\<td class=\\\"sr \\\"\\>%s\\</td\\> 
+                \\<td class=\\\"sr \\\"\\>%s\\</td\\>
                 \\<td class=\\\"sr \\\"\\>\\<A 
HREF=\\\"%s\\\"\\>%s\\</A\\>\\</td\\>\\</tr\\>"
-                    !tr fnum fnum fnum (file_best_name file) "Downloading" 
(file_comment (as_file file)) filename  
+                    !tr fnum fnum fnum (file_best_name file) "Downloading" 
(file_comment (as_file file)) filename
                 else
                   Printf.bprintf buf "%s is %s %s\n" filename
                     (file_best_name file)
-                  "(downloading)" 
+                  "(downloading)"
               with _ ->
                   if use_html_mods o then
                     Printf.bprintf buf "\\<tr class=\\\"%s\\\"\\>\\<td 
class=\\\"sr\\\"\\>%s\\</td\\>
-                \\<td class=\\\"sr \\\"\\>%s\\</td\\> 
-                \\<td class=\\\"sr \\\"\\>%s\\</td\\>\\</tr\\>" !tr 
+                \\<td class=\\\"sr \\\"\\>%s\\</td\\>
+                \\<td class=\\\"sr \\\"\\>%s\\</td\\>\\</tr\\>" !tr
 (* TODO RESULT                      (try
                         let names = DonkeyIndexer.find_names md4 in
                         List.hd names
@@ -743,22 +743,22 @@
                         let names = DonkeyIndexer.find_names md4 in
                         List.hd names
                       with _ -> "and never seen") *) "?"
-            
-            with _ -> 
+
+            with _ ->
                 if use_html_mods o then
                   Printf.bprintf buf "\\<tr class=\\\"%s\\\"\\>\\<td 
class=\\\"sr\\\"\\>Unknown\\</td\\>
-                \\<td class=\\\"sr \\\"\\>\\</td\\> 
-                \\<td class=\\\"sr \\\"\\>%s\\</td\\>\\</tr\\>" !tr filename 
+                \\<td class=\\\"sr \\\"\\>\\</td\\>
+                \\<td class=\\\"sr \\\"\\>%s\\</td\\>\\</tr\\>" !tr filename
                 else
                   Printf.bprintf buf "%s unknown\n" filename
-        
+
         ) list;
-        
+
         if use_html_mods o then Printf.bprintf buf "\\</table\\>\\</div\\>";
-        
-        "done";
+
+        ""
     ), ":\t\t\t\tprint temp directory content";
-    
+
     "sources", Arg_none (fun o ->
         let buf = o.conn_buf in
         DonkeySources.print buf o.conn_output;
@@ -772,7 +772,7 @@
         "done"
     ), ":\t\t\trecompute order of connections to sources (experimental)";
 *)
-    
+
     "xs", Arg_none (fun o ->
         let buf = o.conn_buf in
         if !xs_last_search >= 0 then begin
@@ -782,7 +782,7 @@
             with e -> Printf.sprintf "Error %s" (Printexc2.to_string e)
           end else "No previous search to extend"),
     ":\t\t\t\t\textend the last search";
-    
+
     "clh", Arg_none (fun o ->
         let buf = o.conn_buf in
 (* TODO RESULT        DonkeyIndexer.clear (); *)
@@ -795,21 +795,21 @@
         let file = query_download [] (Int64.of_string size)
           (Md4.of_string md4) None None None false in
         CommonInteractive.start_download file;
-        "download started"    
+        "download started"
     ), "<size> <md4> :\t\t\tdownload from size and md4";
-    
+
     "dup", Arg_none (fun _ ->
         DonkeyChunks.duplicate_chunks (); "done"),
     ":\t\t\t\t\tfind duplicate chunks (experimental)";
-    
+
     "remove_old_servers", Arg_none (fun o ->
         let buf = o.conn_buf in
         DonkeyServers.remove_old_servers ();
         "clean done"
     ), ":\t\t\tremove servers that have not been connected for several days";
-    
-    
-    
+
+
+
     "bp", Arg_multiple (fun args o ->
         List.iter (fun arg ->
             let port = int_of_string arg in
@@ -817,14 +817,14 @@
         ) args;
         "done"
     ), "<port1> <port2> ... :\t\t\tadd these Ports to the port black list";
-    
+
     "send_servers", Arg_none (fun o ->
         CommonWeb.connect_redirector ();
         "done"
     ), ":\t\t\t\tsend the list of connected servers to the redirector";
-  
+
   ]
-          
+
 let _ =
   register_commands commands;
   file_ops.op_file_resume <- (fun file ->
@@ -836,16 +836,16 @@
       ()
   );
   file_ops.op_file_pause <- (fun file -> ()  );
-  
+
   file_ops.op_file_commit <- (fun file new_name ->
-      
+
 (*      DonkeyStats.save_download_history file; *)
-      
+
       if !!keep_cancelled_in_old_files
           && not (List.mem file.file_md4 !!old_files) then
         old_files =:= file.file_md4 :: !!old_files;
       DonkeyShare.remember_shared_info file new_name;
-      
+
 (**************************************************************
 
 Since the new version of Unix32.rename does not update the
@@ -855,17 +855,17 @@
 file.---------> to be done urgently
 
 ***************************************************************)
-      
+
       unshare_file file;
   );
   network.op_network_connected <- (fun _ ->
-    !nservers > 0  
+    !nservers > 0
   );
-  network.op_network_private_message <- (fun iddest s ->      
+  network.op_network_private_message <- (fun iddest s ->
       try
         let c = DonkeyGlobals.find_client_by_name iddest in
         match c.client_source.DonkeySources.source_sock with
-          NoConnection -> 
+          NoConnection ->
             DonkeyClient.reconnect_client c;
             c.client_pending_messages <- c.client_pending_messages @ [s];
         | ConnectionWaiting _ ->
@@ -874,7 +874,7 @@
             client_send c (DonkeyProtoClient.SayReq s)
       with
         Not_found ->
-          CommonChat.send_text !!CommonOptions.chat_console_id None 
+          CommonChat.send_text !!CommonOptions.chat_console_id None
             (Printf.sprintf "client %s unknown" iddest)
   );
   network.op_network_download <- (fun r ->
@@ -886,7 +886,7 @@
 (* How often is this function called when the interface is running ?
 is it called when no interface is connected ? it should be as fast
 as possible. *)
-  
+
 let _ =
   file_ops.op_file_info <- (fun file ->
       try
@@ -894,10 +894,10 @@
             None -> [| last_time () |]
           | Some swarmer -> Int64Swarmer.compute_last_seen swarmer
         in
-        let v = 
+        let v =
           {
             P.file_fields = Fields_file_info.all;
-            
+
             P.file_comment = file_comment (as_file file);
             P.file_name = file_best_name file;
             P.file_num = (file_num file);
@@ -915,7 +915,7 @@
                 None -> "" | Some swarmer ->
                   Int64Swarmer.verified_bitmap swarmer);
             P.file_priority = file_priority  file;
-            P.file_availability =  
+            P.file_availability =
             [network.network_num,(match file.file_swarmer with
                   None -> "" | Some swarmer ->
                     Int64Swarmer.availability swarmer)];
@@ -929,12 +929,12 @@
       with e ->
           lprintf "Exception %s in op_file_info\n" (Printexc2.to_string e);
           raise e
-          
+
   )
-  
+
 let _ =
   server_ops.op_server_info <- (fun s ->
-      if !!enable_donkey then 
+      if !!enable_donkey then
         {
           P.server_num = (server_num s);
           P.server_network = network.network_num;
@@ -971,10 +971,10 @@
 
 let string_of_client_addr c =
   try match c.client_source.DonkeySources.source_sock with
-      Connection sock -> (Ip.to_string (peer_ip sock)) 
+      Connection sock -> (Ip.to_string (peer_ip sock))
     | _ -> ""
   with _ -> ""
-      
+
 let _ =
   client_ops.op_client_info <- (fun c ->
       {
@@ -996,10 +996,10 @@
         P.client_downloaded = c.client_downloaded;
         P.client_uploaded = c.client_uploaded;
 (*        P.client_source.source_sock_addr =    (); *)
-        P.client_upload = 
+        P.client_upload =
         (match c.client_upload with
             Some cu -> Some (file_best_name cu.up_file)
-          | None -> None);        
+          | None -> None);
       }
   );
   client_ops.op_client_debug <- (fun c debug ->
@@ -1038,11 +1038,11 @@
         Connection sock, (Connected _ | Connected_downloading _) ->
           server_send sock (DonkeyProtoServer.QueryUsersReq user);
           Fifo.put s.server_users_queries true
-      | _ -> ()      
+      | _ -> ()
   );
   server_ops.op_server_users <- (fun s ->
       List2.tail_map (fun u -> as_user u.user_user) s.server_users)    ;
-  server_ops.op_server_cid <- (fun s -> 
+  server_ops.op_server_cid <- (fun s ->
       match s.server_cid with
         None -> Ip.null
       | Some ip -> ip);
@@ -1063,13 +1063,13 @@
   file_ops.op_file_set_format <- (fun file format ->
       file.file_format <- format);
   file_ops.op_file_check <- (fun file ->
-      DonkeyChunks.verify_chunks file);  
+      DonkeyChunks.verify_chunks file);
   file_ops.op_file_recover <- (fun file ->
-      if file_state file = FileDownloading then 
-        reconnect_all file);  
+      if file_state file = FileDownloading then
+        reconnect_all file);
   file_ops.op_file_all_sources <- (fun file ->
       let list = ref [] in
-      DonkeySources.iter_all_sources (fun s -> 
+      DonkeySources.iter_all_sources (fun s ->
           let s_uid = s.DonkeySources.source_uid in
           let c = new_client s_uid in
           list := (as_client c) :: !list
@@ -1078,7 +1078,7 @@
   );
   file_ops.op_file_active_sources <- (fun file ->
       let list = ref [] in
-      DonkeySources.iter_active_sources (fun s -> 
+      DonkeySources.iter_active_sources (fun s ->
           let s_uid = s.DonkeySources.source_uid in
           let c = new_client s_uid in
           list := (as_client c) :: !list
@@ -1089,9 +1089,9 @@
 
      html_mods_cntr_init ();
 
-     let tr () = 
+     let tr () =
       Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-%d\\\"\\>" 
(html_mods_cntr ())
-     in 
+     in
 
       tr ();
       html_mods_td buf [
@@ -1130,11 +1130,11 @@
         ("Rename file by selecting an alternate name", "sr br", "Filename");
         ("Rename file", "sr",
           Printf.sprintf "\\<script language=javascript\\>
-\\<!-- 
+\\<!--
 function submitRenameForm(i) {
 var formID = document.getElementById(\\\"renameForm\\\" + i)
 var regExp = new RegExp (' ', 'gi') ;
-var renameTextOut = formID.newName.value.replace(regExp, '+'); 
+var renameTextOut = formID.newName.value.replace(regExp, '+');
 parent.fstatus.location.href='submit?q=rename+%d+\\\"'+renameTextOut+'\\\"';
 }
 //--\\>
@@ -1155,76 +1155,76 @@
 
    if List.length (file_ops.op_file_all_sources file) > 0 then begin
 
-      let chunks = 
+      let chunks =
       (match file.file_swarmer with
        None -> "" | Some swarmer ->
        Int64Swarmer.verified_bitmap swarmer)
       in
 
 
-      html_mods_table_header buf "sourcesTable" "sources al" ([ 
-          ( "1", "srh ac", "Client number (click to add as friend)", "Num" ) ; 
-          ( "0", "srh", "[A] = Active download from client", "A" ) ; 
-          ( "0", "srh", "Client state", "CS" ) ; 
-          ( "0", "srh", "Client name", "Name" ) ; 
-          ( "0", "srh", "Client brand", "CB" ) ; 
+      html_mods_table_header buf "sourcesTable" "sources al" ([
+          ( "1", "srh ac", "Client number (click to add as friend)", "Num" ) ;
+          ( "0", "srh", "[A] = Active download from client", "A" ) ;
+          ( "0", "srh", "Client state", "CS" ) ;
+          ( "0", "srh", "Client name", "Name" ) ;
+          ( "0", "srh", "Client brand", "CB" ) ;
         ] @
           (if !!emule_mods_count then [( "0", "srh", "eMule MOD", "EM" )] else 
[])
         @ [
-          ( "0", "srh", "Overnet [T]rue, [F]alse", "O" ) ; 
-          ( "0", "srh", "Connection [I]ndirect, [D]irect", "C" ) ; 
-          ( "0", "srh br", "IP address", "IP address" ) ; 
-          ( "1", "srh ar", "Total UL bytes to this client for all files", "UL" 
) ; 
-          ( "1", "srh ar br", "Total DL bytes from this client for all files", 
"DL" ) ; 
-          ( "1", "srh ar", "Your queue rank on this client", "Rnk" ) ; 
-          ( "1", "srh ar br", "Source score", "Scr" ) ; 
-          ( "1", "srh ar", "Last ok (minutes)", "LO" ) ; 
-          ( "1", "srh ar", "Last try (minutes)", "LT" ) ; 
-          ( "1", "srh ar br", "Next try (minutes)", "NT" ) ; 
-          ( "0", "srh", "Has a slot [T]rue, [F]alse", "H" ) ; 
-          ( "0", "srh br", "Banned [T]rue, [F]alse", "B" ) ; 
-          ( "1", "srh ar", "Requests sent", "RS" ) ; 
-          ( "1", "srh ar", "Requests received", "RR" ) ; 
-          ( "1", "srh ar br", "Connected time (minutes)", "CT" ) ; 
-          ( "0", "srh br", "Client MD4", "MD4" ) ; 
-          ( "0", "srh", "Chunks (absent|partial|present|verified)", 
-            (colored_chunks 
+          ( "0", "srh", "Overnet [T]rue, [F]alse", "O" ) ;
+          ( "0", "srh", "Connection [I]ndirect, [D]irect", "C" ) ;
+          ( "0", "srh br", "IP address", "IP address" ) ;
+          ( "1", "srh ar", "Total UL bytes to this client for all files", "UL" 
) ;
+          ( "1", "srh ar br", "Total DL bytes from this client for all files", 
"DL" ) ;
+          ( "1", "srh ar", "Your queue rank on this client", "Rnk" ) ;
+          ( "1", "srh ar br", "Source score", "Scr" ) ;
+          ( "1", "srh ar", "Last ok (minutes)", "LO" ) ;
+          ( "1", "srh ar", "Last try (minutes)", "LT" ) ;
+          ( "1", "srh ar br", "Next try (minutes)", "NT" ) ;
+          ( "0", "srh", "Has a slot [T]rue, [F]alse", "H" ) ;
+          ( "0", "srh br", "Banned [T]rue, [F]alse", "B" ) ;
+          ( "1", "srh ar", "Requests sent", "RS" ) ;
+          ( "1", "srh ar", "Requests received", "RR" ) ;
+          ( "1", "srh ar br", "Connected time (minutes)", "CT" ) ;
+          ( "0", "srh br", "Client MD4", "MD4" ) ;
+          ( "0", "srh", "Chunks (absent|partial|present|verified)",
+            (colored_chunks
                 (Array.init (String.length chunks)
-                (fun i -> ((int_of_char chunks.[i])-48)))) ) ; 
+                (fun i -> ((int_of_char chunks.[i])-48)))) ) ;
           ( "1", "srh ar", "Number of full chunks", (Printf.sprintf "%d"
-                (let fc = ref 0 in (String.iter (fun s -> if s = '2' then incr 
fc) 
+                (let fc = ref 0 in (String.iter (fun s -> if s = '2' then incr 
fc)
                   chunks );!fc ))) ]);
 
 
       let counter = ref 0 in
-      DonkeySources.iter_all_sources (fun s -> 
+      DonkeySources.iter_all_sources (fun s ->
           let s_uid = s.DonkeySources.source_uid in
           let c = new_client s_uid in
           let c1 = (as_client c) in
           incr counter;
 
-        try 
+        try
           let i = (client_info (as_client c)) in
 
 
-          Printf.bprintf buf "\\<tr onMouseOver=\\\"mOvr(this);\\\" 
+          Printf.bprintf buf "\\<tr onMouseOver=\\\"mOvr(this);\\\"
         onMouseOut=\\\"mOut(this);\\\" class=\\\"%s\\\"\\>"
            (if (!counter mod 2 == 0) then "dl-1" else "dl-2");
 
-          
+
           Printf.bprintf buf "\\<td title=\\\"Add as Friend\\\" class=\\\"srb 
ar\\\"
     
onClick=\\\"parent.fstatus.location.href='submit?q=friend_add+%d'\\\"\\>%d\\</TD\\>"
             (client_num c) (client_num c);
-          
+
           html_mods_td buf ([
-            ("", "sr", (match c.client_download with 
-                  None -> Printf.sprintf "" 
-                | Some _ -> Printf.sprintf "%s" ( 
+            ("", "sr", (match c.client_download with
+                  None -> Printf.sprintf ""
+                | Some _ -> Printf.sprintf "%s" (
                       let qfiles = c.client_file_queue in
                       let (qfile, qchunks,_) =  List.hd qfiles in
                       if (qfile == file) then
                         "A" else "";)) );
-            ((string_of_connection_state (client_state c)), "sr", 
+            ((string_of_connection_state (client_state c)), "sr",
               (short_string_of_connection_state (client_state c)) );
             (String.escaped c.client_name, "sr", client_short_name 
c.client_name);
             (brand_to_string c.client_brand, "sr", gbrand_to_string 
c.client_brand);
@@ -1233,7 +1233,7 @@
             @ [
               ("", "sr", (if DonkeySources.source_brand c.client_source
                   then "T" else "F"));
-            ("", "sr", (match c.client_kind with 
+            ("", "sr", (match c.client_kind with
                   | Direct_address (ip,port) -> Printf.sprintf "D"
                   | _ -> Printf.sprintf "I"
                 ));
@@ -1253,25 +1253,25 @@
             ("", "sr ar", Printf.sprintf "%d" c.client_requests_received);
             ("", "sr ar br", Printf.sprintf "%d" (((last_time ()) - 
c.client_connect_time) / 60));
             ("", "sr br", (Md4.to_string c.client_md4)); ]);
-          
+
           Printf.bprintf buf "\\<td class=\\\"sr \\\"\\>";
-          
+
           ( let qfiles = c.client_file_queue in
             if qfiles <> [] then begin
                 try
                   let _, qchunks,_ = List.find (fun (qfile, _,_) ->
                         qfile == file) qfiles in
                   let tc = ref 0 in
-                  Printf.bprintf buf "%s\\</td\\>\\<td class=\\\"sr 
ar\\\"\\>%d\\</td\\>" 
-                    (CommonFile.colored_chunks (Array.init (Array.length 
qchunks) 
-                      (fun i -> (if qchunks.(i) then 2 else 0)) )) 
+                  Printf.bprintf buf "%s\\</td\\>\\<td class=\\\"sr 
ar\\\"\\>%d\\</td\\>"
+                    (CommonFile.colored_chunks (Array.init (Array.length 
qchunks)
+                      (fun i -> (if qchunks.(i) then 2 else 0)) ))
                   (Array.iter (fun b -> if b then incr tc) qchunks;!tc);
                 with Not_found -> (
-                      Printf.bprintf buf "\\</td\\>\\<td class=\\\"sr 
ar\\\"\\>\\</td\\>" 
+                      Printf.bprintf buf "\\</td\\>\\<td class=\\\"sr 
ar\\\"\\>\\</td\\>"
                     );
               end
             else
-              Printf.bprintf buf "\\</td\\>\\<td class=\\\"sr 
ar\\\"\\>\\</td\\>" 
+              Printf.bprintf buf "\\</td\\>\\<td class=\\\"sr 
ar\\\"\\>\\</td\\>"
           );
 
            Printf.bprintf buf "\\</tr\\>";
@@ -1296,12 +1296,12 @@
       DonkeyProtoKademlia.Kademlia.cancel_recover_file file;
   );
   file_ops.op_file_comment <- (fun file ->
-      Printf.sprintf "ed2k://|file|%s|%Ld|%s|" 
+      Printf.sprintf "ed2k://|file|%s|%Ld|%s|"
         (file_best_name file)
       (file_size file)
       (Md4.to_string file.file_md4)
   );
-  file_ops.op_file_files <- (fun file impl -> 
+  file_ops.op_file_files <- (fun file impl ->
       match file.file_swarmer with
         None -> [CommonFile.as_file impl]
       | Some swarmer ->
@@ -1324,7 +1324,7 @@
           query_download names size md4 None (Some file_diskname) None true
         in
         recover_md4s md4
-        
+
 let _ =
   network.op_network_extend_search <- (fun s e ->
       match e with
@@ -1333,10 +1333,10 @@
       | ExtendSearchRemotely ->
           DonkeyUdp.make_xs s
   );
-  
+
   network.op_network_clean_servers <- (fun _ ->
       DonkeyServers.remove_old_servers ());
-  
+
   network.op_network_connect_servers <- (fun _ ->
       force_check_server_connections true);
 
@@ -1369,9 +1369,9 @@
           | _ -> ()
       ) files
   );
-  
+
   network.op_network_parse_url <- parse_donkey_url;
-  
+
   network.op_network_forget_search <- forget_search
 
 (* emule<->mldonkey disconnects during chat, and this doesn't seem to auto 
reconnect
@@ -1379,21 +1379,21 @@
 let _ =
   client_ops.op_client_say <- (fun c s ->
       match c.client_source.DonkeySources.source_sock with
-      | NoConnection -> 
+      | NoConnection ->
           DonkeyClient.reconnect_client c;
           c.client_pending_messages <- c.client_pending_messages @ [s];
-      | ConnectionWaiting _ -> 
+      | ConnectionWaiting _ ->
           c.client_pending_messages <- c.client_pending_messages @ [s];
       | Connection sock ->
           client_send c (DonkeyProtoClient.SayReq s)
-  );  
+  );
   client_ops.op_client_files <- (fun c ->
       match c.client_all_files with
         None ->  []
-      | Some files -> 
+      | Some files ->
           List2.tail_map (fun r -> "", r) files);
   client_ops.op_client_browse <- (fun c immediate ->
-      lprintf "*************** should browse  ***********\n"; 
+      lprintf "*************** should browse  ***********\n";
       match c.client_source.DonkeySources.source_sock with
       | Connection sock    ->
 (*
@@ -1405,11 +1405,11 @@
           client_send c (
             let module M = DonkeyProtoClient in
             let module C = M.ViewFiles in
-            M.ViewFilesReq C.t);          
-      | NoConnection -> 
+            M.ViewFilesReq C.t);
+      | NoConnection ->
           lprintf "****************************************\n";
           lprintf "       TRYING TO CONTACT FRIEND         \n";
-          
+
           reconnect_client c
       | _ -> ()
   );
@@ -1424,7 +1424,7 @@
   client_ops.op_client_clear_files <- (fun c ->
       c.client_all_files <- None;
   );
-  
+
   client_ops.op_client_bprint <- (fun c buf ->
       Printf.bprintf buf "\t\t%s (last_ok <%s>)\n"
         c.client_name
@@ -1433,12 +1433,12 @@
   client_ops.op_client_dprint <- (fun c o file ->
       let info = file_info file in
       let buf = o.conn_buf in
-      
+
       try
-        
+
         (match c.client_download with
             None -> ()
-          | Some _ ->  ( 
+          | Some _ ->  (
                 let qfiles = c.client_file_queue in
                 let (qfile, qchunks,_) =  List.hd qfiles in
                 if (qfile == (as_file_impl file).impl_file_val) then begin
@@ -1449,41 +1449,41 @@
                        Direct_address (ip,port) -> (Ip.to_string ip)
                        |  _ -> (string_of_client_addr c));
                     Printf.bprintf buf "\n%14sDown  : %-10s                  
Uploaded: %-10s  Ratio: %s%1.1f (%s)\n" ""
-                    (Int64.to_string c.client_downloaded) 
+                    (Int64.to_string c.client_downloaded)
                     (Int64.to_string c.client_uploaded)
                     (if c.client_downloaded > c.client_uploaded then "-" else 
"+")
                     (if c.client_uploaded > Int64.zero then (Int64.to_float 
(Int64.div c.client_downloaded c.client_uploaded)) else (1.))
                     (brand_to_string c.client_brand);
                     (Printf.bprintf buf "%14sFile  : %s\n" "" 
info.GuiTypes.file_name);
                   end;
-              
+
               )
-        
+
         )
-      
+
       with _ -> ()
-  
+
   );
-  
+
   client_ops.op_client_dprint_html <- (fun c o file str ->
       let info = file_info file in
       let buf = o.conn_buf in
       try
         (match c.client_download with
-            None -> false 
-          | Some _ ->  ( 
+            None -> false
+          | Some _ ->  (
                 let qfiles = c.client_file_queue in
                 let (qfile, qchunks,_) =  List.hd qfiles in
                 if (qfile == (as_file_impl file).impl_file_val) then begin
                     let i = (client_info (as_client c)) in
-                    
-                    Printf.bprintf buf " \\<tr onMouseOver=\\\"mOvr(this);\\\" 
onMouseOut=\\\"mOut(this);\\\" 
+
+                    Printf.bprintf buf " \\<tr onMouseOver=\\\"mOvr(this);\\\" 
onMouseOut=\\\"mOut(this);\\\"
                        class=\\\"%s\\\"\\> \\<td title=\\\"Add as friend\\\" 
class=\\\"srb ar\\\"
                        
onClick=\\\"parent.fstatus.location.href='submit?q=friend_add+%d'\\\"\\>%d\\</TD\\>"
                       str (client_num c) (client_num c);
-                    
+
                     html_mods_td buf ([
-                      (string_of_connection_state (client_state c), "sr", 
+                      (string_of_connection_state (client_state c), "sr",
                         short_string_of_connection_state (client_state c));
                       (Md4.to_string c.client_md4, "sr", client_short_name 
c.client_name);
                       ("", "sr", gbrand_to_string c.client_brand);
@@ -1493,7 +1493,7 @@
                         ("", "sr", (if DonkeySources.source_brand 
c.client_source
                                then "T" else "F"));
                       ("", "sr ar", Printf.sprintf "%d" (((last_time ()) - 
c.client_connect_time) / 60));
-                      ("", "sr", (match c.client_kind with  
+                      ("", "sr", (match c.client_kind with
                             | Direct_address (ip,port) -> Printf.sprintf "D"
                             | _ -> Printf.sprintf "I"
                           ));
@@ -1503,7 +1503,7 @@
                       ("", "sr ar", (size_of_int64 c.client_uploaded));
                       ("", "sr ar", (size_of_int64 c.client_downloaded));
                       ("", "sr", info.GuiTypes.file_name) ]);
-                    
+
                     Printf.bprintf buf "\\</tr\\>";
                     true
                   end
@@ -1512,18 +1512,18 @@
         )
       with _ -> false;
   )
-  
+
 let _ =
   user_ops.op_user_set_friend <- (fun u ->
       let s = u.user_server in
       DonkeyUdp.add_user_friend s u
   )
-  
+
 let _ =
   shared_ops.op_shared_unshare <- (fun file ->
       if !verbose_share then lprintf "************ UNSHARE FILE 
************\n";
       unshare_file file;
-      
+
 (* Should we or not ??? *)
       if file_state file = FileShared then
         try Hashtbl.remove files_by_md4 file.file_md4 with _ -> ();
@@ -1533,7 +1533,7 @@
      match file.file_shared with
         None -> assert false
       | Some impl ->
-          { (impl_shared_info impl) with 
+          { (impl_shared_info impl) with
             T.shared_network = network.network_num;
             T.shared_filename = file_best_name file;
             T.shared_uids = [Uid.create (Ed2k file.file_md4)];
@@ -1542,27 +1542,27 @@
   pre_shared_ops.op_shared_info <- (fun s ->
       let module T = GuiTypes in
       let impl = s.shared_shared in
-      { (impl_shared_info impl) with 
+      { (impl_shared_info impl) with
         T.shared_network = network.network_num }
   )
 
 let _ =
   CommonWeb.add_web_kind "server.met" (fun _ filename ->
-      lprintf "FILE LOADED\n"; 
+      lprintf "FILE LOADED\n";
       let n = load_server_met filename in
       lprintf "%d SERVERS ADDED\n" n;
   );
   CommonWeb.add_web_kind "servers.met" (fun _ filename ->
-      lprintf "FILE LOADED\n"; 
+      lprintf "FILE LOADED\n";
       let n = load_server_met filename in
-      lprintf "%d SERVERS ADDED\n" n; 
+      lprintf "%d SERVERS ADDED\n" n;
   );
   CommonWeb.add_web_kind "comments.met" (fun _ filename ->
 (* TODO      DonkeyIndexer.load_comments filename; *)
-      lprintf "COMMENTS ADDED\n"; 
+      lprintf "COMMENTS ADDED\n";
   );
-  
-  file_ops.op_file_proposed_filenames <- op_file_proposed_filenames;  
+
+  file_ops.op_file_proposed_filenames <- op_file_proposed_filenames;
   network.op_network_add_server <- (fun ip port ->
       let s = DonkeyComplexOptions.force_add_server (Ip.ip_of_addr ip) port in
       as_server s.server_server




reply via email to

[Prev in Thread] Current Thread [Next in Thread]