initial commit
[rofl0r-KOL.git] / units / indy / IdFinger.pas
blobe0ef1c09f628cd95bf689bddef8e7f627a68f9fd
1 // 26-nov-2002
2 unit IdFinger;
4 interface
6 uses KOL { ,
7 Classes } ,
8 IdGlobal,
9 IdTCPClient;
11 const
12 Id_TIdFinger_VerboseOutput = False;
13 type
14 TIdFinger = object(TIdTCPClient)
15 protected
16 FQuery: string;
17 FVerboseOutput: Boolean;
18 procedure SetCompleteQuery(AQuery: string);
19 function GetCompleteQuery: string;
20 public
21 { constructor Create(AOwner: TComponent); override;
22 } function Finger: string;
23 { published }
24 property Query: string read FQuery write FQuery;
25 property CompleteQuery: string read GetCompleteQuery write SetCompleteQuery;
26 property VerboseOutput: Boolean read FVerboseOutPut write FVerboseOutPut
27 default Id_TIdFinger_VerboseOutput;
28 property Port default IdPORT_FINGER;
29 end;
30 PIdFinger=^TIdFinger;
31 function NewIdFinger(AOwner: PControl):PIdFinger;
33 implementation
35 uses
36 IdTCPConnection,
37 SysUtils;
39 //constructor TIdFinger.Create(AOwner: TComponent);
40 function NewIdFinger(AOwner: PControl):PIdFinger;
41 begin
42 // inherited;
43 New( Result, Create );
44 with Result^ do
45 begin
46 Port := IdPORT_FINGER;
47 FVerboseOutput := Id_TIdFinger_VerboseOutput;
48 end;
49 end;
51 function TIdFinger.Finger: string;
52 var
53 QStr: string;
54 begin
55 QStr := FQuery;
56 if VerboseOutPut then
57 begin
58 QStr := QStr + '/W';
59 end;
60 Connect;
61 try
62 Result := '';
63 WriteLn(QStr);
64 Result := AllData;
65 finally
66 Disconnect;
67 end;
68 end;
70 function TIdFinger.GetCompleteQuery: string;
71 begin
72 Result := FQuery + '@' + Host;
73 end;
75 procedure TIdFinger.SetCompleteQuery(AQuery: string);
76 var
77 p: Integer;
78 begin
79 p := RPos('@', AQuery, -1);
80 if (p <> 0) then
81 begin
82 if (p < Length(AQuery)) then
83 begin
84 Host := Copy(AQuery, p + 1, Length(AQuery));
85 end;
86 FQuery := Copy(AQuery, 1, p - 1);
87 end
88 else
89 begin
90 FQuery := AQuery;
91 end;
92 end;
94 end.