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

95 lines
2.1 KiB

unit unitadd;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
ComCtrls, HTTPSend, SynaUtil, XMLRead, DOM, XMLUtils, fpjson, Clipbrd;
type
{ TformAdd }
TformAdd = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
edit_uri: TEdit;
edit_threads: TEdit;
edit_dir: TEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
UpDown1: TUpDown;
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
formAdd: TformAdd;
implementation
uses unit1,unitservers;
{$R *.lfm}
{ TformAdd }
procedure TformAdd.Button2Click(Sender: TObject);
var
myHTTP: THTTPSend;
O, R: TJSONObject;
A: TJSONArray;
response: TStringList;
begin
O := TJSONObject.Create(['jsonrpc', '2.0', 'id', 'qwer', 'method',
'aria2.addUri', 'params', TJSONArray.Create([TJSONArray.Create([edit_uri.Text]),
TJSONObject.Create(['dir',''+edit_dir.Text+'','max-connection-per-server',edit_threads.Text])])]);
Form1.ComboBox1.ItemIndex:=ComboBox1.ItemIndex;
Form1.JSONQuery(O);
//ShowMessage(O.FormatJSON());
Form1.UpdateAll;
Close;
end;
procedure TformAdd.Button3Click(Sender: TObject);
begin
Close;
end;
procedure TformAdd.Button4Click(Sender: TObject);
var
sd: TSelectDirectoryDialog;
begin
sd := TSelectDirectoryDialog.Create(Application);
if sd.Execute then
edit_dir.Text := sd.FileName;
FreeAndNil(sd);
end;
procedure TformAdd.FormShow(Sender: TObject);
begin
ComboBox1.Items:= Form1.ComboBox1.Items;
ComboBox1.ItemIndex:=Form1.ComboBox1.ItemIndex;
edit_uri.Clear;
if (pos('http://', Clipboard.AsText)>0) or (pos('https://', Clipboard.AsText)>0) or
(pos('ftp://', Clipboard.AsText)>0) then
edit_uri.Text := Clipboard.AsText;
end;
end.