Графический интерфейс в 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.

unitadd.pas 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. unit unitadd;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  6. ComCtrls, HTTPSend, SynaUtil, XMLRead, DOM, XMLUtils, fpjson, Clipbrd;
  7. type
  8. { TformAdd }
  9. TformAdd = class(TForm)
  10. Button1: TButton;
  11. Button2: TButton;
  12. Button3: TButton;
  13. Button4: TButton;
  14. ComboBox1: TComboBox;
  15. ComboBox2: TComboBox;
  16. edit_uri: TEdit;
  17. edit_threads: TEdit;
  18. edit_dir: TEdit;
  19. Label1: TLabel;
  20. Label2: TLabel;
  21. Label3: TLabel;
  22. Label4: TLabel;
  23. Label5: TLabel;
  24. Label6: TLabel;
  25. UpDown1: TUpDown;
  26. procedure Button2Click(Sender: TObject);
  27. procedure Button3Click(Sender: TObject);
  28. procedure Button4Click(Sender: TObject);
  29. procedure FormShow(Sender: TObject);
  30. private
  31. { private declarations }
  32. public
  33. { public declarations }
  34. end;
  35. var
  36. formAdd: TformAdd;
  37. implementation
  38. uses unit1,unitservers;
  39. {$R *.lfm}
  40. { TformAdd }
  41. procedure TformAdd.Button2Click(Sender: TObject);
  42. var
  43. myHTTP: THTTPSend;
  44. O, R: TJSONObject;
  45. A: TJSONArray;
  46. response: TStringList;
  47. begin
  48. O := TJSONObject.Create(['jsonrpc', '2.0', 'id', 'qwer', 'method',
  49. 'aria2.addUri', 'params', TJSONArray.Create([TJSONArray.Create([edit_uri.Text]),
  50. TJSONObject.Create(['dir',''+edit_dir.Text+'','max-connection-per-server',edit_threads.Text])])]);
  51. Form1.ComboBox1.ItemIndex:=ComboBox1.ItemIndex;
  52. Form1.JSONQuery(O);
  53. //ShowMessage(O.FormatJSON());
  54. Form1.UpdateAll;
  55. Close;
  56. end;
  57. procedure TformAdd.Button3Click(Sender: TObject);
  58. begin
  59. Close;
  60. end;
  61. procedure TformAdd.Button4Click(Sender: TObject);
  62. var
  63. sd: TSelectDirectoryDialog;
  64. begin
  65. sd := TSelectDirectoryDialog.Create(Application);
  66. if sd.Execute then
  67. edit_dir.Text := sd.FileName;
  68. FreeAndNil(sd);
  69. end;
  70. procedure TformAdd.FormShow(Sender: TObject);
  71. begin
  72. ComboBox1.Items:= Form1.ComboBox1.Items;
  73. ComboBox1.ItemIndex:=Form1.ComboBox1.ItemIndex;
  74. edit_uri.Clear;
  75. if (pos('http://', Clipboard.AsText)>0) or (pos('https://', Clipboard.AsText)>0) or
  76. (pos('ftp://', Clipboard.AsText)>0) then
  77. edit_uri.Text := Clipboard.AsText;
  78. end;
  79. end.