initial commit
[rofl0r-KOL.git] / units / http / mckHTTP.pas
blobcfa75ac4b810d8938f4242de33c046f643de76a3
1 unit mckHTTP;
3 interface
5 uses
6 Windows, Classes, Messages, Forms, SysUtils,
7 KOLRAS, mirror, KOL, KOLHTTP;
9 type
11 PKOLHttp =^TKOLHttp;
12 TKOLHttp = class(TKOLObj)
13 private
15 fUserName: string;
16 fUserPass: string;
17 fHostAddr: string;
18 fHostPort: string;
19 fProxyAdr: string;
20 fProxyPrt: string;
22 fOnHttpClo: TOnEvent;
24 public
26 constructor Create(Owner: TComponent); override;
28 protected
30 function AdditionalUnits: string; override;
31 procedure SetupFirst( SL: TStringList; const AName, AParent, Prefix: String ); override;
32 procedure SetupLast( SL: TStringList; const AName, AParent, Prefix: String ); override;
33 procedure AssignEvents( SL: TStringList; const AName: String ); override;
35 procedure SetUserName(Value: string);
36 procedure SetUserPass(Value: string);
37 procedure SetHostAddr(Value: string);
38 procedure SetHostPort(Value: string);
39 procedure SetProxyAdr(Value: string);
40 procedure SetProxyPrt(Value: string);
42 procedure SetOnHttpClo(Value: TOnEvent);
44 published
46 property UserName : string read fUserName write SetUserName;
47 property Password : string read fUserPass write SetUserPass;
48 property Url : string read fHostAddr write SetHostAddr;
49 property Port : string read fHostPort write SetHostPort;
50 property ProxyAddr: string read fProxyAdr write SetProxyAdr;
51 property ProxyPort: string read fProxyPrt write SetProxyPrt;
53 property OnClose : TOnEvent read fOnHttpClo write SetOnHttpClo;
55 end;
57 procedure Register;
59 implementation
61 {$R *.dcr}
63 constructor TKOLHttp.create;
64 begin
65 inherited create(Owner);
66 fHostPort := '80';
67 end;
69 procedure TKOLHttp.SetUserName;
70 begin
71 fUserName := Value;
72 Change;
73 end;
75 procedure TKOLHttp.SetUserPass;
76 begin
77 fUserPass := Value;
78 Change;
79 end;
81 procedure TKOLHttp.SetHostAddr;
82 begin
83 fHostAddr := Value;
84 Change;
85 end;
87 procedure TKOLHttp.SetHostPort;
88 begin
89 fHostPort := Value;
90 Change;
91 end;
93 procedure TKOLHttp.SetProxyAdr;
94 begin
95 fProxyAdr := Value;
96 Change;
97 end;
99 procedure TKOLHttp.SetProxyPrt;
100 begin
101 fProxyPrt := Value;
102 Change;
103 end;
105 procedure TKOLHttp.SetOnHttpClo;
106 begin
107 fOnHttpClo := Value;
108 Change;
109 end;
111 function TKOLHttp.AdditionalUnits;
112 begin
113 Result := ', KOLHttp';
114 end;
116 procedure TKOLHttp.SetupFirst(SL: TStringList; const AName,
117 AParent, Prefix: String);
118 begin
119 SL.Add( Prefix + AName + ' := NewKOLHttpControl;' );
120 if fUserName <> '' then
121 SL.Add( Prefix + AName + '.UserName := ''' + fUserName + ''';');
122 if fUserPass <> '' then
123 SL.Add( Prefix + AName + '.Password := ''' + fUserPass + ''';');
124 if fHostAddr <> '' then
125 SL.Add( Prefix + AName + '.Url := ''' + fHostAddr + ''';');
126 if fHostPort <> '80' then
127 SL.Add( Prefix + AName + '.HostPort := ' + fHostPort + ';');
128 if fProxyAdr <> '' then
129 SL.Add( Prefix + AName + '.ProxyAddr := ''' + fProxyAdr + ''';');
130 if fProxyPrt <> '' then
131 SL.Add( Prefix + AName + '.ProxyPort := ' + fProxyPrt + ';');
132 end;
134 procedure TKOLHttp.SetupLast(SL: TStringList; const AName,
135 AParent, Prefix: String);
136 begin
138 end;
140 procedure TKOLHttp.AssignEvents(SL: TStringList; const AName: String);
141 begin
142 inherited;
143 DoAssignEvents( SL, AName,
144 [ 'OnClose' ],
145 [ @OnClose ]);
146 end;
148 procedure Register;
149 begin
150 RegisterComponents('KOLUtil', [TKOLHttp]);
151 end;
153 end.