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

92 lines
2.5 KiB

unit aria2;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, HTTPSend, SynaUtil, XMLRead, DOM, XMLUtils;
type
TAria2 = class(TObject)
procedure addUri(params: TStringList);
private
{ private declarations }
public
{ public declarations }
end;
implementation
procedure TAria2.addUri(params: TStringList);
var
myHTTP: THTTPSend;
doc: TXMLDocument;
lParamList, download: TStringList;
begin
myHTTP := THTTPSend.Create;
lParamList := TStringList.Create;
try
{
lParamList.Add('<?xml version="1.0"?>');
lParamList.Add('<methodCall>');
//method
lParamList.Add(' <methodName>aria2.addUri</methodName>');
lParamList.Add(' <params>');
//method params
lParamList.Add(' <param>');
lParamList.Add(' <value>');
lParamList.Add(' <array>');
lParamList.Add(' <data>');
lParamList.Add(' <value><string>'+edit_uri.Text+'</string></value>');
lParamList.Add(' </data>');
lParamList.Add(' </array>');
lParamList.Add(' </value>');
lParamList.Add(' </param>');
//additional params
lParamList.Add(' <param>');
lParamList.Add(' <value>');
lParamList.Add(' <struct>');
lParamList.Add(' <member>');
lParamList.Add(' <name>dir</name>');
lParamList.Add(' <value>');
lParamList.Add(' <string>'+edit_dir.Text+'</string>');
lParamList.Add(' </value>');
lParamList.Add(' </member>');
lParamList.Add(' </struct>');
lParamList.Add(' </value>');
lParamList.Add(' </param>');
lParamList.Add(' </params>');
lParamList.Add('</methodCall>');
}
lParamList := params;
WriteStrToStream(myHTTP.Document, lParamList.Text);
myHTTP.MimeType := 'text/xml';
if myHTTP.HTTPMethod('POST', 'http://localhost:6800/rpc') then
begin
myHTTP.Document.Position := 0;
ReadXMLFile(doc, myHTTP.Document);
//ShowMessage(doc.DocumentElement.TextContent);
end;
//else
//ShowMessage('Cant connect to aria2c rpc server. Aria2c is installed?');
finally
myHTTP.Free;
lParamList.Free;
download := TStringList.Create;
{download.Add('Usual');
download.Add(edit_uri.Text);
download.Add(edit_dir.Text);
download.Add(edit_threads.Text);
download.Add('Active');}
download.Free;
//Close;
end;
end;
end.