mldonkey-commits
[Top][All Lists]
Advanced

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

[Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...


From: mldonkey-commits
Subject: [Mldonkey-commits] mldonkey distrib/ChangeLog src/daemon/common/co...
Date: Wed, 25 Oct 2006 11:12:38 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Changes by:     spiralvoice <spiralvoice>       06/10/25 11:12:38

Modified files:
        distrib        : ChangeLog 
        src/daemon/common: commonClient.ml commonClient.mli 
                           commonComplexOptions.ml commonFile.ml 
                           commonFile.mli commonOptions.ml 
                           commonTypes.ml commonUploads.ml 
                           guiDecoding.ml guiTypes.ml 
        src/daemon/driver: driverCommands.ml driverControlers.ml 
                           driverInteractive.ml 
        src/networks/bittorrent: bTClients.ml bTInteractive.ml 
        src/networks/donkey: donkeyClient.ml donkeyFiles.ml 
                             donkeyInteractive.ml donkeyOneFile.ml 
        src/utils/lib  : misc.ml 

Log message:
        patch #5461

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/distrib/ChangeLog?cvsroot=mldonkey&r1=1.1063&r2=1.1064
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonClient.ml?cvsroot=mldonkey&r1=1.30&r2=1.31
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonClient.mli?cvsroot=mldonkey&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonComplexOptions.ml?cvsroot=mldonkey&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonFile.ml?cvsroot=mldonkey&r1=1.65&r2=1.66
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonFile.mli?cvsroot=mldonkey&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonOptions.ml?cvsroot=mldonkey&r1=1.183&r2=1.184
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonTypes.ml?cvsroot=mldonkey&r1=1.58&r2=1.59
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/commonUploads.ml?cvsroot=mldonkey&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/guiDecoding.ml?cvsroot=mldonkey&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/common/guiTypes.ml?cvsroot=mldonkey&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverCommands.ml?cvsroot=mldonkey&r1=1.186&r2=1.187
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverControlers.ml?cvsroot=mldonkey&r1=1.90&r2=1.91
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/daemon/driver/driverInteractive.ml?cvsroot=mldonkey&r1=1.111&r2=1.112
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTClients.ml?cvsroot=mldonkey&r1=1.82&r2=1.83
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/bittorrent/bTInteractive.ml?cvsroot=mldonkey&r1=1.117&r2=1.118
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyClient.ml?cvsroot=mldonkey&r1=1.103&r2=1.104
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyFiles.ml?cvsroot=mldonkey&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyInteractive.ml?cvsroot=mldonkey&r1=1.130&r2=1.131
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/networks/donkey/donkeyOneFile.ml?cvsroot=mldonkey&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/mldonkey/src/utils/lib/misc.ml?cvsroot=mldonkey&r1=1.6&r2=1.7

Patches:
Index: distrib/ChangeLog
===================================================================
RCS file: /sources/mldonkey/mldonkey/distrib/ChangeLog,v
retrieving revision 1.1063
retrieving revision 1.1064
diff -u -b -r1.1063 -r1.1064
--- distrib/ChangeLog   25 Oct 2006 11:08:28 -0000      1.1063
+++ distrib/ChangeLog   25 Oct 2006 11:12:37 -0000      1.1064
@@ -15,6 +15,14 @@
 =========
 
 2006/10/25
+5461: Release slot, fix missing filenames in upstats
+- Each downloading file can be set to status "Release", this can
+  be done by clicking the "R" column in HTML, Transfers or by
+  using the new "release <file_num>" command to toggle the state.
+- A new option max_release_slots exists, default 20% of the default
+  5 max_upload_slots. This means 1 upload slot is available per default
+  and granted for files with status "Release" when requested.
+- Show filenames in pending upload slots list
 5484: Fix DNS test, test other domains besides www.mldonkey.net
 
 2006/10/23

Index: src/daemon/common/commonClient.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonClient.ml,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -b -r1.30 -r1.31
--- src/daemon/common/commonClient.ml   14 Sep 2006 17:31:00 -0000      1.30
+++ src/daemon/common/commonClient.ml   25 Oct 2006 11:12:38 -0000      1.31
@@ -33,9 +33,8 @@
     mutable impl_client_type : client_type;
     mutable impl_client_state : host_state;
     mutable impl_client_update : int;
-    mutable impl_client_has_slot : bool;
-    mutable impl_client_has_friend_slot : bool;
-    mutable impl_client_upload : shared option;
+    mutable impl_client_slot : slot_kind;
+    mutable impl_client_upload : file option;
     mutable impl_client_num : int;
     mutable impl_client_val : 'a;
     mutable impl_client_ops : 'a client_ops;
@@ -102,8 +101,7 @@
     impl_client_type = 0;
     impl_client_state = NewHost;
     impl_client_update = 1;
-    impl_client_has_slot = false;
-    impl_client_has_friend_slot = false;
+    impl_client_slot = NoSlot;
     impl_client_upload = None;
     impl_client_num = 0;
     impl_client_val = 0;
@@ -322,24 +320,26 @@
 let set_initialized c =
   set_client_type c (client_type c lor client_initialized_tag)
 
-let client_has_a_slot c =
-  (as_client_impl c).impl_client_has_slot
+let client_slot c =
+  (as_client_impl c).impl_client_slot
 
-let client_has_a_friend_slot c =
-  (as_client_impl c).impl_client_has_friend_slot
+let client_has_a_slot c =
+  match (as_client_impl c).impl_client_slot with
+    NoSlot -> false
+  | _ -> true
 
 let client_upload c =
   (as_client_impl c).impl_client_upload
 
 let set_client_upload c sh =
-  (as_client_impl c).impl_client_upload <- sh;
+  (as_client_impl c).impl_client_upload <- Some sh;
   client_must_update c
 
-let set_client_has_a_slot c b =
+let set_client_has_a_slot c slot =
   let impl = as_client_impl c in
-  if not b && impl.impl_client_has_slot then begin
-      impl.impl_client_has_slot <- false;
-      impl.impl_client_has_friend_slot <- false;
+  match slot with
+    NoSlot -> if client_has_a_slot c then begin
+      impl.impl_client_slot <- NoSlot;
       uploaders := Intmap.remove (client_num c) !uploaders;
       client_must_update c;
 (*
@@ -353,17 +353,15 @@
 *)
       Unix32.close_all ()
     end
-  else
-  if b && not impl.impl_client_has_slot then  begin
+  | slot -> if not (client_has_a_slot c) then begin
       uploaders := Intmap.add (client_num c) c !uploaders;
-      impl.impl_client_has_slot <- true;
-      impl.impl_client_has_friend_slot <- is_friend c;
+      impl.impl_client_slot <- slot;
       client_must_update c
     end
 
 let set_client_disconnected c reason =
   let impl = as_client_impl c in
-  set_client_has_a_slot c false;
+  set_client_has_a_slot c NoSlot;
 
   match impl.impl_client_state with
     Connected n -> set_client_state c (NotConnected (reason, n))

Index: src/daemon/common/commonClient.mli
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonClient.mli,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- src/daemon/common/commonClient.mli  16 Aug 2006 19:12:08 -0000      1.12
+++ src/daemon/common/commonClient.mli  25 Oct 2006 11:12:38 -0000      1.13
@@ -2,9 +2,8 @@
     mutable impl_client_type : CommonTypes.client_type;
     mutable impl_client_state : CommonTypes.host_state;
     mutable impl_client_update : int;
-    mutable impl_client_has_slot : bool;
-    mutable impl_client_has_friend_slot : bool;
-    mutable impl_client_upload : CommonTypes.shared option;
+    mutable impl_client_slot : CommonTypes.slot_kind;
+    mutable impl_client_upload : CommonTypes.file option;
     mutable impl_client_num : int;
     mutable impl_client_val : 'a;
     mutable impl_client_ops : 'a client_ops;
@@ -70,11 +69,11 @@
 val check_client_implementations : unit -> unit
 val client_can_upload : CommonTypes.client -> int -> unit
 val client_enter_upload_queue : CommonTypes.client -> unit
-val client_upload : CommonTypes.client -> CommonTypes.shared option
-val set_client_upload : CommonTypes.client -> CommonTypes.shared option -> unit
+val client_upload : CommonTypes.client -> CommonTypes.file option
+val set_client_upload : CommonTypes.client -> CommonTypes.file -> unit
+val client_slot : CommonTypes.client -> CommonTypes.slot_kind
 val client_has_a_slot : CommonTypes.client -> bool
-val client_has_a_friend_slot : CommonTypes.client -> bool
-val set_client_has_a_slot : CommonTypes.client -> bool -> unit
+val set_client_has_a_slot : CommonTypes.client -> CommonTypes.slot_kind -> unit
   
 val uploaders : CommonTypes.client Intmap.t ref
   

Index: src/daemon/common/commonComplexOptions.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonComplexOptions.ml,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- src/daemon/common/commonComplexOptions.ml   19 Sep 2006 17:07:42 -0000      
1.61
+++ src/daemon/common/commonComplexOptions.ml   25 Oct 2006 11:12:38 -0000      
1.62
@@ -104,6 +104,11 @@
                 normalize_time (get_value "file_age" value_to_int)
             with _ -> ());
 
+          (try
+              impl.impl_file_release <- 
+                get_value "file_release" value_to_bool
+            with _ -> ());
+
          let file_user = try
              let u = get_value "file_owner" value_to_string in
              if user2_user_exist u then u else begin
@@ -178,6 +183,7 @@
        ("file_filenames", List
        (List.map string_to_value impl.impl_file_filenames)) ::
         ("file_age", IntValue (Int64.of_int impl.impl_file_age)) ::
+        ("file_release", bool_to_value impl.impl_file_release) ::
         ("file_owner", string_to_value (file_owner file)) ::
         ("file_group", option_to_stringvalue (file_group file)) ::
           (file_to_option file)

Index: src/daemon/common/commonFile.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonFile.ml,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -b -r1.65 -r1.66
--- src/daemon/common/commonFile.ml     8 Oct 2006 14:20:21 -0000       1.65
+++ src/daemon/common/commonFile.ml     25 Oct 2006 11:12:38 -0000      1.66
@@ -62,6 +62,7 @@
     mutable impl_file_filenames : string list;
     mutable impl_file_magic : string option;
     mutable impl_file_priority: int; (* normal = 0, low < 0, high > 0 *)
+    mutable impl_file_release : bool;
     mutable impl_file_last_seen : int;
     mutable impl_file_probable_name : string option;
   }
@@ -136,6 +137,7 @@
     impl_file_filenames = [];
     impl_file_magic = None;
     impl_file_priority = 0;
+    impl_file_release = false;
     impl_file_last_seen = 0;
     impl_file_comment = "";
     impl_file_probable_name = None;
@@ -261,6 +263,15 @@
       file.impl_file_ops.op_file_resume file.impl_file_val
   | _ -> ()
 
+let set_file_release file status user =
+  if user2_allow_file_admin file user then
+  let impl = as_file_impl file in
+  impl.impl_file_release <- status
+
+let file_release (file: file) =
+  let impl = as_file_impl file in
+  impl.impl_file_release
+
 let set_file_owner file owner =
   (as_file_impl file).impl_file_owner <- owner
 
@@ -1233,6 +1244,7 @@
     T.file_comments = [];
     T.file_user = impl.impl_file_owner;
     T.file_group = (impl_group_text impl);
+    T.file_release = impl.impl_file_release;
   }
 
 let lprintf_file_nl file fmt =

Index: src/daemon/common/commonFile.mli
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonFile.mli,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- src/daemon/common/commonFile.mli    8 Oct 2006 14:20:21 -0000       1.27
+++ src/daemon/common/commonFile.mli    25 Oct 2006 11:12:38 -0000      1.28
@@ -38,6 +38,7 @@
   mutable impl_file_filenames : string list;
   mutable impl_file_magic : string option;
   mutable impl_file_priority : int;
+  mutable impl_file_release : bool;
     mutable impl_file_last_seen : int;
     mutable impl_file_probable_name : string option;
 } 
@@ -86,6 +87,8 @@
 val file_info : CommonTypes.file -> GuiTypes.file_info
 val file_pause : CommonTypes.file -> string -> unit
 val file_resume : CommonTypes.file -> string -> unit
+val set_file_release : CommonTypes.file -> bool -> string -> unit
+val file_release : CommonTypes.file -> bool
 val set_file_state : CommonTypes.file -> CommonTypes.file_state -> unit
 val file_best_name : CommonTypes.file -> string
 val set_file_best_name : CommonTypes.file -> string -> string -> int -> unit

Index: src/daemon/common/commonOptions.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonOptions.ml,v
retrieving revision 1.183
retrieving revision 1.184
diff -u -b -r1.183 -r1.184
--- src/daemon/common/commonOptions.ml  23 Oct 2006 13:08:30 -0000      1.183
+++ src/daemon/common/commonOptions.ml  25 Oct 2006 11:12:38 -0000      1.184
@@ -603,6 +603,10 @@
   "How many slots can be used for upload"
     int_option 5
 
+let max_release_slots = define_option current_section ["max_release_slots"]
+  "How many percent of upload slots can be used for downloading files tagged 
as release"
+    percent_option 20
+
 let friends_upload_slot = define_option current_section ["friends_upload_slot"]
   "Set aside a single reserved slot to upload to friends"
     bool_option true

Index: src/daemon/common/commonTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonTypes.ml,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -b -r1.58 -r1.59
--- src/daemon/common/commonTypes.ml    1 Oct 2006 17:53:59 -0000       1.58
+++ src/daemon/common/commonTypes.ml    25 Oct 2006 11:12:38 -0000      1.59
@@ -906,3 +906,20 @@
   f : string -> string -> unit;
   description : string
 }
+
+type slot_kind =
+  NoSlot
+| FriendSlot
+| ReleaseSlot
+| SmallFileSlot
+| NormalSlot
+| PrioSlot of string
+
+let string_of_slot_kind slot_kind short =
+  match slot_kind with
+    NoSlot -> "NoSlot"
+  | FriendSlot -> "FriendSlot"
+  | ReleaseSlot -> "ReleaseSlot"
+  | SmallFileSlot -> "SmallFileSlot"
+  | NormalSlot -> if short then "" else "NormalSlot"
+  | PrioSlot dir -> Printf.sprintf "Prio %s" dir

Index: src/daemon/common/commonUploads.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/commonUploads.ml,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- src/daemon/common/commonUploads.ml  8 Oct 2006 14:20:21 -0000       1.47
+++ src/daemon/common/commonUploads.ml  25 Oct 2006 11:12:38 -0000      1.48
@@ -839,14 +839,7 @@
     end
   else
   if not (Intmap.mem (client_num c) !pending_slots_map) then
-    begin
-(* This is useless since it is the goal of the pending_slots_map
-        else if Fifo.mem pending_slots_fifo (client_num c) then begin
-       lprintf "Avoided inserting a client twice in pending slots\n";
-       
-      end else *)
-      pending_slots_map := Intmap.add (client_num c) c !pending_slots_map;
-    end
+    pending_slots_map := Intmap.add (client_num c) c !pending_slots_map
 
 let remove_pending_slot c =
   if Intmap.mem (client_num c) !pending_slots_map then
@@ -854,11 +847,11 @@
 
 let rec give_a_slot c =
   remove_pending_slot c;
-  if not (client_is_connected c) then begin
+  if not (client_is_connected c) then
       find_pending_slot ()
-    end
-  else begin
-      set_client_has_a_slot c true;
+  else
+    begin
+      set_client_has_a_slot c NormalSlot;
       client_enter_upload_queue c
     end
 
@@ -873,36 +866,47 @@
   with _ -> ()
 
 let add_pending_slot c =
-  let csh = client_upload c in
+  let client_upload c =
+    match client_upload c with
+      None -> raise Not_found
+    | Some file -> file
+  in
+  let csh = file_shared (client_upload c) in
   let cdir = shared_dir csh in
   let cprio = ref (shared_prio csh) in
   let cfriend = ref (if is_friend c && !!friends_upload_slot then 1 else 0) in
   let csmallfiles = ref (match csh with 
     | None -> 0
     | Some sh -> if shared_size sh <= !!small_files_slot_limit then 1 else 0) 
in
-  (* if cdir <> "" then
-    lprintf "Testing cdir %s\n" cdir; *)
+  let allowed_release_slots =
+    ref (Misc.percentage_of_ints !!max_upload_slots !!max_release_slots) in
+
+(* check current upload slots for already used special slots *)
   Intmap.iter (fun _ c ->
-    let sh = client_upload c in
-    if shared_dir sh = cdir then decr cprio;
-    if client_has_a_friend_slot c then decr cfriend;
-    match sh with
-      | None -> ()
-      | Some sh ->
-         if shared_size sh <= !!small_files_slot_limit then
-           decr csmallfiles;
-  ) !CommonClient.uploaders;
-  (* if cdir <> "" then
-     lprintf "Testing cprio %d cfriend %d csmallfiles\n" 
-     !cprio !cfriend !csmallfiles; *)
-  if !cprio > 0 || !cfriend > 0 || !csmallfiles > 0 then begin
+    if shared_dir (file_shared (client_upload c)) = cdir then
+      decr cprio;
+    match client_slot c with
+      ReleaseSlot -> decr allowed_release_slots
+    | FriendSlot -> decr cfriend
+    | SmallFileSlot -> decr csmallfiles
+    | _ -> ()) !CommonClient.uploaders;
+
+  let slot_type =
+    if file_release (client_upload c) && !allowed_release_slots > 0 then Some 
ReleaseSlot else
+    if !cfriend > 0 then Some FriendSlot else
+    if !csmallfiles > 0 then Some SmallFileSlot else
+    if !cprio > 0 then Some (PrioSlot cdir) else
+    None
+  in
+  match slot_type with
+    Some slot ->
     remove_pending_slot c;
-    if client_is_connected c then begin
-      set_client_has_a_slot c true;
+       if client_is_connected c then
+         begin
+           set_client_has_a_slot c slot;
       client_enter_upload_queue c
     end
-  end else
-    add_pending_slot c
+  | None -> add_pending_slot c
 
 let static_refill_upload_slots () =
   let len = Intmap.length !CommonClient.uploaders in

Index: src/daemon/common/guiDecoding.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/guiDecoding.ml,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- src/daemon/common/guiDecoding.ml    8 Oct 2006 14:20:21 -0000       1.61
+++ src/daemon/common/guiDecoding.ml    25 Oct 2006 11:12:38 -0000      1.62
@@ -650,6 +650,7 @@
     file_comments = comments;
     file_user = user;
     file_group = group;
+    file_release = false;
   }, pos
 
 let get_host_state proto s pos =

Index: src/daemon/common/guiTypes.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/common/guiTypes.ml,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- src/daemon/common/guiTypes.ml       8 Oct 2006 14:20:21 -0000       1.31
+++ src/daemon/common/guiTypes.ml       25 Oct 2006 11:12:38 -0000      1.32
@@ -140,6 +140,7 @@
     mutable file_comments : (Ip.t * string * int * string) list;
     mutable file_user : string;
     mutable file_group : string;
+    mutable file_release : bool;
   }
   
 type user_info = {
@@ -337,5 +338,6 @@
     file_comments = [];
     file_user = "";
     file_group = "";
+    file_release = false;
  } 
   

Index: src/daemon/driver/driverCommands.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverCommands.ml,v
retrieving revision 1.186
retrieving revision 1.187
diff -u -b -r1.186 -r1.187
--- src/daemon/driver/driverCommands.ml 23 Oct 2006 13:08:30 -0000      1.186
+++ src/daemon/driver/driverCommands.ml 25 Oct 2006 11:12:38 -0000      1.187
@@ -1597,6 +1597,7 @@
                        strings_of_option set_client_ip;
                        strings_of_option force_client_ip;
                        strings_of_option max_upload_slots;
+                       strings_of_option max_release_slots;
                        strings_of_option dynamic_slots;
                        strings_of_option max_hard_upload_rate;
                        strings_of_option max_hard_download_rate;
@@ -2333,6 +2334,7 @@
                   @ [
                   ( "0", "srh ar", "Total DL bytes from this client for all 
files", "DL" ) ;
                   ( "0", "srh ar", "Total UL bytes to this client for all 
files", "UL" ) ;
+                  ( "0", "srh ar", "Slot kind", "Slot" ) ;
                   ( "0", "srh", "Filename", "Filename" ) ]);
 
                 List.iter (fun c ->
@@ -2372,8 +2374,15 @@
                             @ [
                             ("", "sr ar", size_of_int64 i.client_downloaded);
                             ("", "sr ar", size_of_int64 i.client_uploaded);
+                           (let text1, text2 =
+                               match client_slot c with
+                               | FriendSlot -> "Friend", "F"
+                               | ReleaseSlot -> "Release", "R"
+                               | SmallFileSlot -> "Small file", "S"
+                               | PrioSlot dir -> "Prio dir: " ^ dir, "P"
+                               | _ -> "", "" in text1, "sr ar", text2);
                             ("", "sr", (match i.client_upload with
-                                  Some cu -> cu
+                                  Some f -> shorten f !!max_name_len
                                 | None -> "") ) ]);
 
                           Printf.bprintf buf "\\</tr\\>"
@@ -2657,6 +2666,19 @@
               ) !!files) args; ""
     ), "<num> :\t\t\t\tresume a paused download (use arg 'all' for all files)";
 
+    "release", Arg_one (fun arg o ->
+       let num = int_of_string arg in
+       let file = file_find num in
+       let old_state = file_release file in
+       set_file_release file (not (file_release file)) 
o.conn_user.ui_user_name;
+       Printf.sprintf "%s, file: %s"
+         (match old_state, file_release file with
+             true, false -> "deactivated release state"
+           | false, true -> "activated release state"
+           | _ -> "unchanged status, enough rights?")
+         (shorten (file_best_name file) !!max_name_len)
+    ), "<num> :\t\t\t\tchange release state of a download";
+
     "commit", Arg_none (fun o ->
         List.iter (fun file ->
             file_commit file

Index: src/daemon/driver/driverControlers.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverControlers.ml,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -b -r1.90 -r1.91
--- src/daemon/driver/driverControlers.ml       21 Oct 2006 19:35:09 -0000      
1.90
+++ src/daemon/driver/driverControlers.ml       25 Oct 2006 11:12:38 -0000      
1.91
@@ -1300,6 +1300,14 @@
                     let num = int_of_string value in
                     let file = file_find num in
                     file_resume file o.conn_user.ui_user_name
+                | "release" ->
+                    let num = int_of_string value in
+                    let file = file_find num in
+                    set_file_release file true o.conn_user.ui_user_name
+                | "norelease" ->
+                    let num = int_of_string value in
+                    let file = file_find num in
+                    set_file_release file false o.conn_user.ui_user_name
                 | "sortby" ->
                     begin
                       match value with

Index: src/daemon/driver/driverInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/daemon/driver/driverInteractive.ml,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -b -r1.111 -r1.112
--- src/daemon/driver/driverInteractive.ml      20 Oct 2006 15:52:30 -0000      
1.111
+++ src/daemon/driver/driverInteractive.ml      25 Oct 2006 11:12:38 -0000      
1.112
@@ -572,7 +572,7 @@
   Printf.bprintf buf "\\</form\\>"
 
 
-  let print_file_html_mods buf guifiles =
+let print_file_html_mods buf guifiles =
 
     if (List.length guifiles) > 0 then begin
        let tsize = ref Int64.zero in
@@ -657,7 +657,8 @@
 
 \\<td title=\\\"Pause\\\"  class=\\\"dlheader np\\\"\\>P\\</td\\>
 \\<td title=\\\"Resume\\\" class=\\\"dlheader np\\\"\\>R\\</td\\>
-\\<td title=\\\"Cancel\\\" class=\\\"dlheader brs\\\"\\>C\\</td\\>"
+\\<td title=\\\"Cancel\\\" class=\\\"dlheader brs\\\"\\>C\\</td\\>
+\\<td title=\\\"Click to switch release status\\\" class=\\\"dlheader 
brs\\\"\\>R\\</td\\>"
 (if !qnum > 0 then begin
        Printf.sprintf "title=\\\"Active(%d): %s/%s | Queued(%d): %s/%s\\\""
        (List.length guifiles - !qnum) (size_of_int64 (!tdl -- !qdl)) 
(size_of_int64 (!tsize -- !qsize))
@@ -668,7 +669,7 @@
 (let unread = ref 0 in
 Fifo.iter (fun (t,i,num,n,s) -> if t > !last_message_log then incr unread) 
chat_message_fifo;
 if !unread > 0 then Printf.sprintf "\\<td class=downloaded title=\\\"%d unread 
messages\\\"\\>\\<a 
onClick=\\\"mSub('fstatus','version');mSub('output','message')\\\"\\>(+%d)\\</a\\>\\&nbsp;\\</td\\>"
 !unread !unread else "");
-(* onClick="mSub('fstatus','version');mSub('output','message')" *)
+
 if !!html_mods_vd_network then Printf.bprintf buf
 "\\<td title=\\\"Sort by network\\\" class=dlheader\\>\\<input 
style=\\\"padding-left: 0px; padding-right: 0px;\\\" class=headbutton 
type=submit value=N name=sortby\\>\\</td\\>";
 
@@ -752,6 +753,10 @@
                 file.file_num
                 file.file_num);
 
+         Printf.sprintf "\\<td onClick=\\\"location.href='files?%s=%d';return 
true;\\\" class=\\\"dl al brs\\\"\\>\\%s\\</td\\>"
+           (if file.file_release then "norelease" else "release")
+           file.file_num (if file.file_release then "R" else "-");
+
           (if !!html_mods_vd_network then
                        Printf.sprintf "\\<td 
onClick=\\\"location.href='submit?q=vd+%d';return true;\\\"
                        title=\\\"%s\\\" class=\\\"dl al\\\"\\>%s\\</td\\>"
@@ -953,6 +958,7 @@
           |] else
           [|
             "$nNum";
+           "Rele";
            "Comm";
             "File";
             "    %";
@@ -998,6 +1004,7 @@
                     file.file_num
                       (if downloading file then "PAUSE" else "RESUME")
                   else ""));
+             (Printf.sprintf "%s" (if file.file_release then "R" else "-"));
              (Printf.sprintf "%4d" (number_of_comments file));
               (short_name file);
               (Printf.sprintf "%3.1f" (percent file));

Index: src/networks/bittorrent/bTClients.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTClients.ml,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -b -r1.82 -r1.83
--- src/networks/bittorrent/bTClients.ml        8 Oct 2006 14:01:04 -0000       
1.82
+++ src/networks/bittorrent/bTClients.ml        25 Oct 2006 11:12:38 -0000      
1.83
@@ -225,7 +225,7 @@
   (*Send choke if a current_uploader is not in next_uploaders*)
   List.iter ( fun c -> if ((List.mem c !next_uploaders)==false) then
         begin
-          set_client_has_a_slot (as_client c) false;
+          set_client_has_a_slot (as_client c) NoSlot;
           (*we will let him finish his download and choke him on next_request*)
         end
   ) !current_uploaders;
@@ -233,7 +233,7 @@
   (*don't send Choke if new uploader is already an uploaders *)
   List.iter ( fun c -> if ((List.mem c !current_uploaders)==false) then
         begin
-          set_client_has_a_slot (as_client c) true;
+          set_client_has_a_slot (as_client c) NormalSlot;
           Rate.update_no_change c.client_downloaded_rate;
           Rate.update_no_change c.client_upload_rate;
           c.client_last_optimist <- last_time();
@@ -873,7 +873,7 @@
             *)
             current_uploaders := c::(!current_uploaders);
             c.client_sent_choke <- false;
-            set_client_has_a_slot (as_client c) true;
+            set_client_has_a_slot (as_client c) NormalSlot;
             Rate.update_no_change c.client_downloaded_rate;
             Rate.update_no_change c.client_upload_rate;
             c.client_last_optimist <- last_time();
@@ -903,7 +903,7 @@
               don't miss the opportunity if we can *)
               current_uploaders := c::(!current_uploaders);
               c.client_sent_choke <- false;
-              set_client_has_a_slot (as_client c) true;
+              set_client_has_a_slot (as_client c) NormalSlot;
               Rate.update_no_change c.client_downloaded_rate;
               Rate.update_no_change c.client_upload_rate;
               c.client_last_optimist <- last_time();

Index: src/networks/bittorrent/bTInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/bittorrent/bTInteractive.ml,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -b -r1.117 -r1.118
--- src/networks/bittorrent/bTInteractive.ml    8 Oct 2006 14:20:22 -0000       
1.117
+++ src/networks/bittorrent/bTInteractive.ml    25 Oct 2006 11:12:38 -0000      
1.118
@@ -562,6 +562,7 @@
     P.file_comments = [];
     P.file_user = "";
     P.file_group = "";
+    P.file_release = file_release (as_ft ft);
   }
 
 

Index: src/networks/donkey/donkeyClient.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyClient.ml,v
retrieving revision 1.103
retrieving revision 1.104
diff -u -b -r1.103 -r1.104
--- src/networks/donkey/donkeyClient.ml 8 Oct 2006 14:20:22 -0000       1.103
+++ src/networks/donkey/donkeyClient.ml 25 Oct 2006 11:12:38 -0000      1.104
@@ -192,9 +192,13 @@
           M.AvailableSlotReq Q.t);
         
         if !verbose then
-            lprintf_nl "New uploader %s"
-              (full_client_identifier c);
-        
+            lprintf_nl "New uploader %s%s%s"
+              (full_client_identifier c)
+             (let slot_text = string_of_slot_kind (client_slot (as_client c)) 
true in
+                if slot_text = "" then "" else Printf.sprintf "(%s)" slot_text)
+             (match client_upload (as_client c) with
+                None -> ""
+              | Some f -> Printf.sprintf " for file %s" 
(CommonFile.file_best_name f))
     )  
   in
   client_ops.op_client_enter_upload_queue <- client_enter_upload_queue
@@ -262,7 +266,7 @@
           c.client_connect_time <- 0;
           (try Hashtbl.remove connected_clients c.client_md4 with _ -> ());
           (try CommonUploads.remove_pending_slot (as_client c) with _ -> ());
-          set_client_has_a_slot (as_client c) false;
+          set_client_has_a_slot (as_client c) NoSlot;
 (*          connection_failed c.client_connection_control; *)
           (try TcpBufferedSocket.close sock reason with _ -> ());
 
@@ -1108,7 +1112,7 @@
       
       init_client_after_first_message sock c;
       
-      set_client_has_a_slot (as_client c) false;
+      set_client_has_a_slot (as_client c) NoSlot;
       
       let module CR = M.Connect in
 
@@ -1364,8 +1368,11 @@
         end else *)
       CommonUploads.add_pending_slot (as_client c);
       if !verbose_upload then
-          lprintf_nl "donkeyClient: uploader couldn't get a slot: %s"
-            (full_client_identifier c);
+          lprintf_nl "added to pending slots: %s %s"
+            (full_client_identifier c) 
+           (match client_upload (as_client c) with
+              None -> ""
+            | Some f -> CommonFile.file_best_name f);
 (*      end *)
   
   | M.CloseSlotReq _ ->
@@ -1694,7 +1701,7 @@
                 shared_must_update_downloaded (as_shared impl);
                 impl.impl_shared_requests <- impl.impl_shared_requests + 1);
           request_for c file sock;
-          set_client_upload (as_client c) (shared_of_file file);
+          set_client_upload (as_client c) (as_file file);
           client_send c (
             let module Q = M.QueryFileReply in
             let filename = file_best_name file in
@@ -2030,7 +2037,7 @@
         new_chunk up t.Q.start_pos2 t.Q.end_pos2;
         new_chunk up t.Q.start_pos3 t.Q.end_pos3;
         c.client_upload <- Some up;
-        set_client_upload (as_client c) (shared_of_file file);
+        set_client_upload (as_client c) (as_file file);
         if not waiting && !CommonUploads.has_upload = 0 then begin
             CommonUploads.ready_for_upload (as_client c);
             up.up_waiting <- true
@@ -2126,7 +2133,7 @@
 (*  c.client_block <- None; *)
 (*  c.client_zones <- []; *)
   c.client_file_queue <- [];
-  set_client_has_a_slot (as_client c) false;
+  set_client_has_a_slot (as_client c) NoSlot;
   c.client_upload <- None;
   c.client_rank <- 0;
   c.client_requests_received <- 0;

Index: src/networks/donkey/donkeyFiles.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyFiles.ml,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- src/networks/donkey/donkeyFiles.ml  19 May 2006 23:43:54 -0000      1.20
+++ src/networks/donkey/donkeyFiles.ml  25 Oct 2006 11:12:38 -0000      1.21
@@ -79,8 +79,8 @@
 (*      let len_int = Int32.to_int len in *)
       try
        if !verbose_upload then
-    lprintf_nl "send_small_block (%s) %Ld %d"
-           (full_client_identifier c)
+         lprintf_nl "Sending %s to %s, begin %Ld len %d"
+           (file_best_name file) (full_client_identifier c)
             (begin_pos) (len_int);
         
         let msg =  
@@ -135,7 +135,7 @@
 (* last block from chunk *)
               begin
                 if !verbose_upload then
-                    lprintf_nl "END OF CHUNK (%d) %Ld" max_len 
up.up_end_chunk; 
+                    lprintf_nl "End of chunk (%d) %Ld %s" max_len 
up.up_end_chunk (file_best_name up.up_file);
                 send_small_block c sock up.up_file up.up_pos max_len;
                 up.up_chunks <- chunks;
                 let per_client = per_client - max_len in

Index: src/networks/donkey/donkeyInteractive.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyInteractive.ml,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -b -r1.130 -r1.131
--- src/networks/donkey/donkeyInteractive.ml    20 Oct 2006 15:52:30 -0000      
1.130
+++ src/networks/donkey/donkeyInteractive.ml    25 Oct 2006 11:12:38 -0000      
1.131
@@ -1145,8 +1145,8 @@
         P.client_uploaded = c.client_uploaded;
 (*        P.client_source.source_sock_addr =    (); *)
         P.client_upload =
-        (match c.client_upload with
-            Some cu -> Some (file_best_name cu.up_file)
+        (match client_upload (as_client c) with
+            Some f -> Some (CommonFile.file_best_name f)
           | None -> None);
         P.client_sui_verified = c.client_sui_verified;
       }

Index: src/networks/donkey/donkeyOneFile.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyOneFile.ml,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- src/networks/donkey/donkeyOneFile.ml        8 Oct 2006 14:20:22 -0000       
1.44
+++ src/networks/donkey/donkeyOneFile.ml        25 Oct 2006 11:12:38 -0000      
1.45
@@ -100,7 +100,7 @@
                 end
 
 let remove_client_slot c =
-  set_client_has_a_slot (as_client c) false;
+  set_client_has_a_slot (as_client c) NoSlot;
   client_send c (
     let module M = DonkeyProtoClient in
     let module Q = M.CloseSlot in

Index: src/utils/lib/misc.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/utils/lib/misc.ml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- src/utils/lib/misc.ml       3 Apr 2006 20:50:09 -0000       1.6
+++ src/utils/lib/misc.ml       25 Oct 2006 11:12:38 -0000      1.7
@@ -49,6 +49,10 @@
   let s = string_of_int num in
     int_of_string ("0b" ^ s)
 
+let percentage_of_ints v percent =
+  int_of_float (
+  (float_of_int v *. float_of_int percent /. 100.0) +. 0.5)
+
 let zip_extract_entry ifile e =
   if e.Zip.is_directory then begin
     try




reply via email to

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