Index: src/networks/donkey/donkeyClient.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyClient.ml,v
retrieving revision 1.83
diff -u -w -p -r1.83 donkeyClient.ml
--- src/networks/donkey/donkeyClient.ml	9 Feb 2006 11:41:39 -0000	1.83
+++ src/networks/donkey/donkeyClient.ml	10 Feb 2006 03:43:34 -0000
@@ -1634,6 +1634,38 @@ is checked for the file.
           lprintf_nl () "Sending %d Files in ViewFilesReqReply" (List.length !published_files);
       client_send_files sock !published_files
   
+  (*TODO: real directory support*)
+  | M.ViewDirsReq t when !CommonUploads.has_upload = 0 && 
+    (match !!allow_browse_share with
+        1 -> client_friend_tag land client_type c <> 0
+      | 2 -> true
+      | _ -> false) -> 
+      let published_dirs = ["FIXME"] in
+      if !verbose_msg_clients then
+          lprintf_nl () "Sending %d Dirs in ViewDirsReplyReq" (List.length published_dirs);
+      client_send c (M.ViewDirsReplyReq published_dirs)
+  
+  (*TODO: real directory support*)
+  (*TODO: "!Incomplete Files" support*)
+  | M.ViewFilesDirReq t when !CommonUploads.has_upload = 0 && 
+    (match !!allow_browse_share with
+        1 -> client_friend_tag land client_type c <> 0
+      | 2 -> true
+      | _ -> false) -> 
+      let files = DonkeyShare.all_shared () in
+      let published_files = ref [] in
+      List.iter (fun f ->
+          let filename = file_best_name f in
+          if not (String2.starts_with filename "hidden.") then
+            published_files := f :: !published_files
+      ) files;
+(*
+       lprintf "ASK VIEW FILES\n"; 
+       *)
+      if !verbose_msg_clients then
+          lprintf_nl () "Sending %d Files in ViewFilesReqReply" (List.length !published_files);
+      client_send_dir sock t !published_files
+
   | M.QueryFileReq t ->
       let md4 = t.M.QueryFile.md4 in
       c.client_requests_received <- c.client_requests_received + 1;
Index: src/networks/donkey/donkeyProtoClient.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyProtoClient.ml,v
retrieving revision 1.33
diff -u -w -p -r1.33 donkeyProtoClient.ml
--- src/networks/donkey/donkeyProtoClient.ml	18 Dec 2005 14:50:38 -0000	1.33
+++ src/networks/donkey/donkeyProtoClient.ml	10 Feb 2006 03:43:35 -0000
@@ -533,6 +533,7 @@ module AvailableSlot = NoArg(struct let 
 module ReleaseSlot = NoArg(struct let m = "ReleaseSlot" end)
 module CloseSlot = NoArg(struct let m = "CloseSlot" end)
 module ViewFiles = NoArg(struct let m = "VIEW FILES" end)
+module ViewDirs = NoArg(struct let m = "VIEW DIRS" end)
 
 module ViewFilesReply = struct
 
@@ -607,6 +608,83 @@ module ViewFilesReply = struct
             nfiles, prev_len
   end
 
+module ViewDirsReply = struct
+
+    type t = string list
+
+    let rec get_dirs s pos n =
+      if n = 0 then [], pos else
+      let dir, pos = get_string16 s pos in
+      let dirs, pos = get_dirs s pos (n-1) in
+      dir :: dirs, pos
+
+    let parse len s =
+      let dirs, pos = get_dirs s 2 (get_int16 s 0) in
+      dirs
+
+    let print t =
+      lprintf_nl "VIEW DIRS REPLY:";
+      List.iter (fun dir ->
+          lprintf_nl "DIR: %s" dir;) t
+
+    let write buf t =
+      buf_int buf (List.length t);
+      List.iter (fun dir ->
+        buf_string buf dir;) t
+
+  end
+
+module ViewFilesDir = struct
+
+    type t = string
+
+    let print t =
+      lprintf_nl "VIEW FILES DIR: %s" t
+
+    let parse len s =
+      let dir, pos = get_string s 1 in
+      dir
+
+    let write buf t =
+      buf_string buf t
+
+  end
+
+module ViewFilesDirReply = struct
+
+    type t = string * tagged_file list
+
+    let names_of_tag = file_common_tags
+
+    let parse len s =
+      let dir, pos = get_string s 1 in
+      let n = get_int s (pos+1) in
+      let files, pos = ViewFilesReply.get_files s (pos+5) n in
+      dir, files
+
+    let print t =
+      lprintf_nl "VIEW FILES DIR REPLY:";
+      let dir, files = t in begin
+        lprintf_nl "DIR: %s" dir;
+        List.iter (fun file ->
+            lprintf_nl "FILE:";
+            lprintf_nl "  MD4: %s" (Md4.to_string file.f_md4);
+            lprintf_nl "  ip: %s" (Ip.to_string file.f_ip);
+            lprintf_nl "  port: %d" file.f_port;
+            lprintf "  tags: ";
+            print_tags file.f_tags;
+            lprint_newline ();) files
+      end
+
+    let write buf t =
+      let dir, files = t in begin
+        buf_string buf dir;
+        buf_int buf (List.length files);
+        ViewFilesReply.write_files buf files
+      end
+
+  end
+
 module OtherLocations = struct
 
     type t = Ip.t list
@@ -984,6 +1062,10 @@ type t =
 | QueryChunkMd4ReplyReq of QueryChunkMd4Reply.t
 | ViewFilesReq of ViewFiles.t
 | ViewFilesReplyReq of ViewFilesReply.t
+| ViewDirsReq of ViewDirs.t
+| ViewDirsReplyReq of ViewDirsReply.t
+| ViewFilesDirReq of ViewFilesDir.t
+| ViewFilesDirReplyReq of ViewFilesDirReply.t
 | QueueReq of OtherLocations.t
 | UnknownReq of int * string
 | OtherLocationsReq of OtherLocations.t
@@ -1026,6 +1108,10 @@ let rec print t =
     | QueryChunkMd4ReplyReq t -> QueryChunkMd4Reply.print t
     | ViewFilesReplyReq t -> ViewFilesReply.print t
     | ViewFilesReq t -> ViewFiles.print t
+    | ViewDirsReq t -> ViewDirs.print t
+    | ViewDirsReplyReq t -> ViewDirsReply.print t
+    | ViewFilesDirReq t -> ViewFilesDir.print t
+    | ViewFilesDirReplyReq t -> ViewFilesDirReply.print t
     | QueueReq t -> OtherLocations.print t
     | OtherLocationsReq t  -> OtherLocations.print t
     | SayReq t -> Say.print t
@@ -1254,6 +1340,12 @@ and parse emule_version magic s =
           | 88 -> QueryFileReq (QueryFile.parse emule_version len s)
           | 89 -> QueryFileReplyReq (QueryFileReply.parse len s)
           | 92 -> QueueRankReq (QueueRank.parse len s)
+          | 93 -> ViewDirsReq (ViewDirs.parse len s)
+          | 94 -> ViewFilesDirReq (ViewFilesDir.parse len s)
+          (*
+          | 95 -> ViewDirsReplyReq (ViewDirsReply.parse len s)
+          | 96 -> ViewFilesDirReplyReq (ViewFilesDirReply.parse len s)
+          *)
           | 250 -> SourcesReq (Sources.parse len s)
 
           | _ -> raise Not_found
@@ -1373,6 +1465,18 @@ let write emule buf t =
     | ViewFilesReplyReq t ->
         buf_int8 buf 75;
         ViewFilesReply.write buf t
+    | ViewDirsReq t ->
+        buf_int8 buf 93;
+        ViewDirs.write buf t
+    | ViewDirsReplyReq t ->
+        buf_int8 buf 95;
+        ViewDirsReply.write buf t
+    | ViewFilesDirReq t ->
+        buf_int8 buf 94;
+        ViewFilesDir.write buf t
+    | ViewFilesDirReplyReq t ->
+        buf_int8 buf 96;
+        ViewFilesDirReply.write buf t
     | OtherLocationsReq t ->
         buf_int8 buf 72;
         OtherLocations.write buf t
Index: src/networks/donkey/donkeyProtoCom.ml
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyProtoCom.ml,v
retrieving revision 1.29
diff -u -w -p -r1.29 donkeyProtoCom.ml
--- src/networks/donkey/donkeyProtoCom.ml	9 Feb 2006 11:41:39 -0000	1.29
+++ src/networks/donkey/donkeyProtoCom.ml	10 Feb 2006 03:43:35 -0000
@@ -398,6 +398,27 @@ let client_send_files sock msg =
   str_int s 6 nfiles;
   write_string sock s
 
+let client_send_dir sock dir files =
+  let max_len = !!client_buffer_size - 100 -
+    TcpBufferedSocket.remaining_to_write sock in
+  Buffer.reset buf;
+  buf_int8 buf 227;
+  buf_int buf 0;
+  buf_int8 buf 96; (* ViewFilesDirReply *)
+  buf_string buf dir;
+  buf_int buf 0;
+  let pos = Buffer.length buf in
+  let nfiles, prev_len = DonkeyProtoClient.ViewFilesReply.write_files_max buf (
+      make_tagged (Some sock) files)
+    0 max_len in
+  let s = Buffer.contents buf in
+  let s = String.sub s 0 prev_len in
+  let len = String.length s - 5 in begin
+    str_int s 1 len;
+    str_int s (pos-4) nfiles;
+  end;
+  write_string sock s
+
 let udp_server_send s t =
   udp_send (get_udp_sock ()) s.server_ip (s.server_port+4) t
 
Index: src/networks/donkey/donkeyProtoCom.mli
===================================================================
RCS file: /sources/mldonkey/mldonkey/src/networks/donkey/donkeyProtoCom.mli,v
retrieving revision 1.6
diff -u -w -p -r1.6 donkeyProtoCom.mli
--- src/networks/donkey/donkeyProtoCom.mli	16 Jan 2006 16:05:14 -0000	1.6
+++ src/networks/donkey/donkeyProtoCom.mli	10 Feb 2006 03:43:35 -0000
@@ -72,6 +72,8 @@ val server_send_share :
   bool -> TcpBufferedSocket.t  -> file list -> unit
 val client_send_files :
     TcpBufferedSocket.t -> file list -> unit
+val client_send_dir :
+    TcpBufferedSocket.t -> string -> file list -> unit
 
 val new_string :  DonkeyProtoClient.t -> string -> unit
 
