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: Thu, 18 May 2006 17:28:45 +0000

CVSROOT:        /sources/mldonkey
Module name:    mldonkey
Branch:         
Changes by:     spiralvoice <address@hidden>    06/05/18 17:28:44

Modified files:
        distrib        : ChangeLog 
        src/daemon/common: commonMessages.ml 
        src/daemon/driver: driverCommands.ml driverControlers.ml 
                           driverInteractive.ml 

Log message:
        patch #5097

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/distrib/ChangeLog.diff?tr1=1.832&tr2=1.833&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/common/commonMessages.ml.diff?tr1=1.50&tr2=1.51&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverCommands.ml.diff?tr1=1.142&tr2=1.143&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverControlers.ml.diff?tr1=1.67&tr2=1.68&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/mldonkey/mldonkey/src/daemon/driver/driverInteractive.ml.diff?tr1=1.74&tr2=1.75&r1=text&r2=text

Patches:
Index: mldonkey/distrib/ChangeLog
diff -u mldonkey/distrib/ChangeLog:1.832 mldonkey/distrib/ChangeLog:1.833
--- mldonkey/distrib/ChangeLog:1.832    Thu May 18 17:26:18 2006
+++ mldonkey/distrib/ChangeLog  Thu May 18 17:28:44 2006
@@ -15,6 +15,7 @@
 =========
 
 2006/05/18
+5097: HTML: Improved DL multiline input button (jave)
 5103: Fix compile bug in magiclib_stub.c on Solaris & NetBSD
 
 2006/05/17
Index: mldonkey/src/daemon/common/commonMessages.ml
diff -u mldonkey/src/daemon/common/commonMessages.ml:1.50 
mldonkey/src/daemon/common/commonMessages.ml:1.51
--- mldonkey/src/daemon/common/commonMessages.ml:1.50   Wed Mar 29 14:22:08 2006
+++ mldonkey/src/daemon/common/commonMessages.ml        Thu May 18 17:28:44 2006
@@ -311,14 +311,14 @@
 document.onmousemove = handlerMM;
 
 function dllink() {
-       var l = prompt( \"enter ed2k, sig2dat, torrent or other link\", \"\" );
-       if( l != null ) {
-               var f = document.forms[\"cmdFormular\"];
-               var t = f.elements[\"q\"].value;
-               f.elements[\"q\"].value = \"dllink \" + l;
-               f.submit();
-               f.elements[\"q\"].value = t;
-       }
+    var popw = 620;
+    var poph = 330;
+    var popx = 0;
+    var popy = 0;
+    popx = screen.availWidth/2 - popw/2;
+    popy = screen.availHeight/2 - poph/2;
+    var dimensions = 'height='+poph+', width='+popw+', top='+popy+', 
left='+popx+', scrollbars=yes, resizable=yes';
+    window.open(\"multidllink.html\", \"_blank\", dimensions );
 }
 
 function servers() {
@@ -335,6 +335,66 @@
 //-->
   "
 
+let multidllink_old =  define_option message_section ["multidllink_old"]
+  "multidllink - old"
+  string_option
+  "OLD multidllink JAVE"
+
+let multidllink_mods0 =  define_option message_section ["multidllink_mods0"]
+  "multidllink - Style 0"
+  string_option
+  "
+<html>
+<head>
+<link href=\"h.css\" rel=\"stylesheet\" type=\"text/css\" />
+</head>
+<script type=\"text/javascript\">
+window.document.title='Insert links here and press Input';
+
+function fixHeightOfTheText()
+{
+  var t = document.getElementById(\"links\");
+
+  var myWidth = 0, myHeight = 0;
+  if( typeof( window.innerWidth ) == 'number' ) {
+    //Non-IE
+    myWidth = window.innerWidth;
+    myHeight = window.innerHeight;
+  } else if( document.documentElement && ( 
document.documentElement.clientWidth || document.documentElement.clientHeight ) 
) {
+    //IE 6+ in 'standards compliant mode'
+    myWidth = document.documentElement.clientWidth;
+    myHeight = document.documentElement.clientHeight;
+  } else if( document.body && ( document.body.clientWidth || 
document.body.clientHeight ) ) {
+    //IE 4 compatible
+    myWidth = document.body.clientWidth;
+    myHeight = document.body.clientHeight;
+  }
+
+  h=myHeight;
+
+  var height = (h - t.offsetTop - 45) + \"px\";
+
+  t.style.height = height;
+
+}
+window.onresize = fixHeightOfTheText;
+
+
+</script>
+<body onload=\"document.dllinkform.links.focus();\">
+<form name=\"dllinkform\" method=\"GET\" action=\"submit\">
+<table width=\"100%\">
+<input type=\"hidden\" name=\"jvcmd\" value=\"multidllink\">
+<tr><td><textarea id=\"links\" style=\"width: 100%; height:100%\" 
name=\"links\"></textarea> <br></td></tr>
+<tr><td align=\"right\" class=\"bu bbigm\" style=\"padding-top: 0px; 
padding-bottom: 0px;\" title=\"Download Links\"  ><INPUT class=\"but2\" 
type=submit value=\"Input\" style=\"width:100%\"></td></tr>
+</form>
+<script type=\"text/javascript\">
+fixHeightOfTheText(); 
+</script>
+</body>
+</html>
+"
+
 
 let html_header_mods0 = define_option message_section ["html_header_mods0"]
   "Header - style 0"
Index: mldonkey/src/daemon/driver/driverCommands.ml
diff -u mldonkey/src/daemon/driver/driverCommands.ml:1.142 
mldonkey/src/daemon/driver/driverCommands.ml:1.143
--- mldonkey/src/daemon/driver/driverCommands.ml:1.142  Sun May 14 18:53:26 2006
+++ mldonkey/src/daemon/driver/driverCommands.ml        Thu May 18 17:28:44 2006
@@ -2813,156 +2813,19 @@
     ), "<num> \"<new name>\" :\t\tchange name of download <num> to <new name>";
 
     "dllink", Arg_multiple (fun args o ->
-        let query_networks url =
-       let print_result buf o result =
-         List.iter (fun s ->
-           if o.conn_output = HTML then
-             begin
-               Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-1\\\"\\>";
-               html_mods_td buf [ ("", "sr", s); ]
-             end
-           else
-             Printf.bprintf buf "%s\n" s) (List.rev result);
-       in
-       let result = ref [] in
-          if not (networks_iter_until_true (fun n ->
-               try
-                  let s,r = network_parse_url n url in
-                   if s = "" then r else
-                     let s1 = Printf.sprintf "%s: %s" n.network_name s in
-                       result := s1 :: !result;
-                     r
-               with e ->
-                   let s1 = Printf.sprintf "%s: Exception %s"
-                     (n.network_name) (Printexc2.to_string e)
-                   in
-                   result := s1 :: !result;
-                    false
-            )) then
-            let output =
-               (let buf = Buffer.create 100 in
-                 if o.conn_output = HTML then
-                   begin
-                     Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>";
-                     html_mods_table_header buf "dllinkTable" "results" [];
-                     Printf.bprintf buf "\\<tr\\>";
-                     html_mods_td buf [ ("", "srh", "Unable to match URL"); ];
-                     Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-1\\\"\\>";
-                     html_mods_td buf [ ("", "sr", url); ]
-                   end
-                 else
-                    Printf.bprintf buf "Unable to match URL : %s\n" url;
-                   print_result buf o !result;
-                 if o.conn_output = HTML then
-                   Printf.bprintf buf 
"\\</tr\\>\\</table\\>\\</div\\>\\</div\\>";
-                Buffer.contents buf) in
-            _s output
-          else
-            let output = (if o.conn_output = HTML then begin
-                let buf = Buffer.create 100 in
-                Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>";
-                html_mods_table_header buf "dllinkTable" "results" [];
-                Printf.bprintf buf "\\<tr\\>";
-                html_mods_td buf [ ("", "srh", "Added link"); ];
-                Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-1\\\"\\>";
-                html_mods_td buf [ ("", "sr", url); ];
-               print_result buf o !result;
-                Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>";
-                Buffer.contents buf
-              end
-            else begin
-                Printf.sprintf "Added link : %s" url
-            end) in
-            _s output
-        in
-
         let url = String2.unsplit args ' ' in
-        if (String2.starts_with url "http") then (
-            let u = Url.of_string url in
-            let module H = Http_client in
-            let r = {
-              H.basic_request with
-                H.req_url =  u;
-                H.req_proxy = !CommonOptions.http_proxy;
-                H.req_request = H.HEAD;
-               H.req_max_retry = 10;
-                H.req_referer = (
-                  let (rule_search,rule_value) =
-                    try (List.find(fun (rule_search,rule_value) ->
-                            Str.string_match (Str.regexp rule_search) 
u.Url.server 0
-                        ) !!referers )
-                    with Not_found -> ("",Url.to_string u) in
-                  Some (Url.of_string rule_value) );
-                H.req_headers = (try
-                  let cookies = List.assoc u.Url.server !!cookies in
-                 [ ( "Cookie", List.fold_left (fun res (key, value) ->
-                          if res = "" then
-                            key ^ "=" ^ value
-                          else
-                            res ^ "; " ^ key ^ "=" ^ value
-                      ) "" cookies
-                    ) ]
-                with Not_found -> []);
-                H.req_user_agent = get_user_agent ();
-            } in
-            H.whead r
-                (fun headers ->
-                   (* Combine the list of header fields into one string *)
-                   let concat_headers =
-                     (List.fold_right (fun (n, c) t -> n ^ ": " ^ c ^ "\n" ^ 
t) headers "")
-                   in
-                   ignore (query_networks concat_headers)
-                );
-            let output = (if o.conn_output = HTML then begin
-                let buf = Buffer.create 100 in
-                Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>";
-                html_mods_table_header buf "dllinkTable" "results" [];
-                Printf.bprintf buf "\\<tr\\>";
-                html_mods_td buf [ ("", "srh", "Parsing HTTP url"); ];
-                Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-1\\\"\\>";
-                html_mods_td buf [ ("", "sr", url); ];
-                Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>";
-                Buffer.contents buf
-              end
-            else begin
-                Printf.sprintf "Parsing HTTP url : %s" url
-            end) in
-            _s output
-            )
-        else
-          if (String2.starts_with url "ftp") then
-           query_networks (Printf.sprintf "Location: %s" url)
-         else
-            query_networks url
+        dllink_parse (o.conn_output = HTML) url
         ), "<link> :\t\t\t\tdownload ed2k, sig2dat, torrent or other link";
 
     "dllinks", Arg_one (fun arg o ->
-
+       let result = Buffer.create 100 in
         let file = File.to_string arg in
         let lines = String2.split_simplify file '\n' in
         List.iter (fun line ->
-            ignore (networks_iter_until_true (fun n ->
-                  let s,r = network_parse_url n line in r))
+         Buffer.add_string result (dllink_parse (o.conn_output = HTML) line);
+         Buffer.add_string result (if o.conn_output = HTML then "\\<P\\>" else 
"\n")
         ) lines;
-        let output = (if o.conn_output = HTML then begin
-            let buf = Buffer.create 100 in
-            Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>";
-            html_mods_table_header buf "dllinksTable" "results" [];
-            Printf.bprintf buf "\\<tr\\>";
-            html_mods_td buf [ ("", "srh", "Added links"); ];
-            Printf.bprintf buf "\\</tr\\>";
-            List.iter (fun line ->
-                Printf.bprintf buf "\\<tr class=\\\"dl-1\\\"\\>";
-                html_mods_td buf [ ("", "sr", line); ];
-                Printf.bprintf buf "\\</tr\\>";
-            ) lines;
-            Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>";
-            Buffer.contents buf
-          end
-        else begin
-            Printf.sprintf "done"
-        end) in
-        _s output
+        (Buffer.contents result)
     ), "<file> :\t\t\tdownload all the links contained in the file";
 
   ]
Index: mldonkey/src/daemon/driver/driverControlers.ml
diff -u mldonkey/src/daemon/driver/driverControlers.ml:1.67 
mldonkey/src/daemon/driver/driverControlers.ml:1.68
--- mldonkey/src/daemon/driver/driverControlers.ml:1.67 Wed May 17 08:52:43 2006
+++ mldonkey/src/daemon/driver/driverControlers.ml      Thu May 18 17:28:44 2006
@@ -1106,6 +1106,14 @@
                 read_theme_page this_page else
               if !!html_mods then !!CommonMessages.web_common_header_mods0
               else !!CommonMessages.web_common_header_old)
+        | "multidllink.html" ->
+            html_open_page buf t r true;
+            let this_page = "multidllink.html" in
+            Buffer.add_string buf (
+              if !!html_mods_theme != "" && theme_page_exists this_page then
+                read_theme_page this_page else
+              if !!html_mods then !!CommonMessages.multidllink_mods0
+              else !!CommonMessages.multidllink_old)
         | "" | "index.html" ->
             if !!use_html_frames then begin
                 html_open_page buf t r false;
@@ -1385,7 +1393,18 @@
 
         | "submit" ->
             begin
+
               match r.get_url.Url.args with
+                | [ "jvcmd", "multidllink" ; "links", links] ->
+                    html_open_page buf t r true;
+                    List.iter (fun url ->
+                     if url <> "\013" && url <> "" then
+                       begin
+                          Buffer.add_string buf (html_escaped (dllink_parse 
(o.conn_output = HTML) url));
+                          Buffer.add_string buf (html_escaped "\\<P\\>")
+                       end
+                    ) (String2.split links '\n')
+
               | ("q", cmd) :: other_args ->
                   List.iter (fun arg ->
                       match arg with
Index: mldonkey/src/daemon/driver/driverInteractive.ml
diff -u mldonkey/src/daemon/driver/driverInteractive.ml:1.74 
mldonkey/src/daemon/driver/driverInteractive.ml:1.75
--- mldonkey/src/daemon/driver/driverInteractive.ml:1.74        Wed May 17 
08:52:43 2006
+++ mldonkey/src/daemon/driver/driverInteractive.ml     Thu May 18 17:28:44 2006
@@ -1972,3 +1972,92 @@
     end
   else
     Printf.bprintf buf "\n\t--Helptext--\n%s\n" help_text
+
+let dllink_print_result html url header results =
+  let buf = Buffer.create 100 in
+  if html then
+    begin
+      Printf.bprintf buf "\\<div class=\\\"cs\\\"\\>";
+      html_mods_table_header buf "dllinkTable" "results" [];
+      Printf.bprintf buf "\\<tr\\>";
+      html_mods_td buf [ ("", "srh", header); ];
+      Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-1\\\"\\>";
+      html_mods_td buf [ ("", "sr", url); ]
+    end
+  else
+    Printf.bprintf buf "%s : %s\n" header url;
+  List.iter (fun s ->
+    if html then
+      begin
+        Printf.bprintf buf "\\</tr\\>\\<tr class=\\\"dl-1\\\"\\>";
+        html_mods_td buf [ ("", "sr", s); ]
+      end
+    else
+      Printf.bprintf buf "%s\n" s) (List.rev results);
+  if html then Printf.bprintf buf "\\</tr\\>\\</table\\>\\</div\\>\\</div\\>";
+  Buffer.contents buf
+
+let dllink_query_networks html url =
+  let result = ref [] in
+  if not (networks_iter_until_true (fun n ->
+    try
+      let s,r = network_parse_url n url in
+        if s = "" then
+          r
+        else
+          let s1 = Printf.sprintf "%s: %s" n.network_name s in
+            result := s1 :: !result;
+            r
+    with e ->
+      let s1 = Printf.sprintf "%s: Exception %s"
+        (n.network_name) (Printexc2.to_string e)
+      in
+        result := s1 :: !result;
+        false
+  )) then
+    dllink_print_result html url "Unable to match URL" !result
+  else
+    dllink_print_result html url "Added link" !result
+
+let dllink_parse html url =
+  if (String2.starts_with url "http") then (
+    let u = Url.of_string url in
+    let module H = Http_client in
+    let r = {
+      H.basic_request with
+      H.req_url =  u;
+      H.req_proxy = !CommonOptions.http_proxy;
+      H.req_request = H.HEAD;
+      H.req_max_retry = 10;
+      H.req_referer = (
+        let (rule_search,rule_value) =
+        try (List.find(fun (rule_search,rule_value) ->
+          Str.string_match (Str.regexp rule_search) u.Url.server 0
+        ) !!referers )
+        with Not_found -> ("",Url.to_string u) in
+        Some (Url.of_string rule_value) );
+      H.req_headers = (try
+        let cookies = List.assoc u.Url.server !!cookies in
+          [ ( "Cookie", List.fold_left (fun res (key, value) ->
+              if res = "" then
+                key ^ "=" ^ value
+              else
+                res ^ "; " ^ key ^ "=" ^ value
+            ) "" cookies
+            ) ]
+         with Not_found -> []);
+      H.req_user_agent = get_user_agent ();
+    } in
+    H.whead r (fun headers ->
+      (* Combine the list of header fields into one string *)
+      let concat_headers =
+        (List.fold_right (fun (n, c) t -> n ^ ": " ^ c ^ "\n" ^ t) headers "")
+      in
+      ignore (dllink_query_networks html concat_headers)
+    );
+    dllink_print_result html url "Parsing HTTP url" [])
+  else
+    if (String2.starts_with url "ftp") then
+      dllink_query_networks html (Printf.sprintf "Location: %s" url)
+    else
+      dllink_query_networks html url




reply via email to

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