Графический интерфейс в aria2c RPC http://blindage.org/?p=5385
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

aria2.pas 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. unit aria2;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, HTTPSend, SynaUtil, XMLRead, DOM, XMLUtils;
  6. type
  7. TAria2 = class(TObject)
  8. procedure addUri(params: TStringList);
  9. private
  10. { private declarations }
  11. public
  12. { public declarations }
  13. end;
  14. implementation
  15. procedure TAria2.addUri(params: TStringList);
  16. var
  17. myHTTP: THTTPSend;
  18. doc: TXMLDocument;
  19. lParamList, download: TStringList;
  20. begin
  21. myHTTP := THTTPSend.Create;
  22. lParamList := TStringList.Create;
  23. try
  24. {
  25. lParamList.Add('<?xml version="1.0"?>');
  26. lParamList.Add('<methodCall>');
  27. //method
  28. lParamList.Add(' <methodName>aria2.addUri</methodName>');
  29. lParamList.Add(' <params>');
  30. //method params
  31. lParamList.Add(' <param>');
  32. lParamList.Add(' <value>');
  33. lParamList.Add(' <array>');
  34. lParamList.Add(' <data>');
  35. lParamList.Add(' <value><string>'+edit_uri.Text+'</string></value>');
  36. lParamList.Add(' </data>');
  37. lParamList.Add(' </array>');
  38. lParamList.Add(' </value>');
  39. lParamList.Add(' </param>');
  40. //additional params
  41. lParamList.Add(' <param>');
  42. lParamList.Add(' <value>');
  43. lParamList.Add(' <struct>');
  44. lParamList.Add(' <member>');
  45. lParamList.Add(' <name>dir</name>');
  46. lParamList.Add(' <value>');
  47. lParamList.Add(' <string>'+edit_dir.Text+'</string>');
  48. lParamList.Add(' </value>');
  49. lParamList.Add(' </member>');
  50. lParamList.Add(' </struct>');
  51. lParamList.Add(' </value>');
  52. lParamList.Add(' </param>');
  53. lParamList.Add(' </params>');
  54. lParamList.Add('</methodCall>');
  55. }
  56. lParamList := params;
  57. WriteStrToStream(myHTTP.Document, lParamList.Text);
  58. myHTTP.MimeType := 'text/xml';
  59. if myHTTP.HTTPMethod('POST', 'http://localhost:6800/rpc') then
  60. begin
  61. myHTTP.Document.Position := 0;
  62. ReadXMLFile(doc, myHTTP.Document);
  63. //ShowMessage(doc.DocumentElement.TextContent);
  64. end;
  65. //else
  66. //ShowMessage('Cant connect to aria2c rpc server. Aria2c is installed?');
  67. finally
  68. myHTTP.Free;
  69. lParamList.Free;
  70. download := TStringList.Create;
  71. {download.Add('Usual');
  72. download.Add(edit_uri.Text);
  73. download.Add(edit_dir.Text);
  74. download.Add(edit_threads.Text);
  75. download.Add('Active');}
  76. download.Free;
  77. //Close;
  78. end;
  79. end;
  80. end.