IdFingerServer.pas 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.6 12/2/2004 4:23:54 PM JPMugaas
  18. Adjusted for changes in Core.
  19. Rev 1.5 1/21/2004 2:29:40 PM JPMugaas
  20. InitComponent
  21. Rev 1.4 2/24/2003 08:41:24 PM JPMugaas
  22. Should compile with new code.
  23. Rev 1.3 1/17/2003 05:35:02 PM JPMugaas
  24. Now compiles with new design.
  25. Rev 1.2 1/9/2003 07:10:56 AM JPMugaas
  26. Changed Finger server API so developers do not have to mess with the Context
  27. and Connnection objects.
  28. Rev 1.1 1-1-2003 20:13:02 BGooijen
  29. Changed to support the new TIdContext class
  30. Rev 1.0 11/14/2002 02:19:56 PM JPMugaas
  31. 2000-May-15 J. Peter Mugaas
  32. -Added verbose querry event to complement TIdFinger
  33. 2000-Apr-22 J Peter Mugass
  34. -Ported to Indy
  35. 2000-Jan-13 MTL
  36. -Moved to new Palette Scheme (Winshoes Servers)
  37. 1999-Apr-13
  38. -Final Version
  39. }
  40. unit IdFingerServer;
  41. {
  42. Original Author: Ozz Nixon
  43. }
  44. interface
  45. {$i IdCompilerDefines.inc}
  46. uses
  47. IdAssignedNumbers,
  48. IdContext,
  49. IdCustomTCPServer;
  50. Type
  51. TIdFingerGetEvent = procedure (AContext:TIdContext; const AUserName: String; var VResponse : String) of object;
  52. TIdFingerServer = class ( TIdCustomTCPServer )
  53. protected
  54. FOnCommandFinger : TIdFingerGetEvent;
  55. FOnCommandVerboseFinger : TIdFingerGetEvent;
  56. //
  57. function DoExecute(AContext:TIdContext): boolean; override;
  58. procedure InitComponent; override;
  59. published
  60. {This event fires when you make a regular querry}
  61. property OnCommandFinger: TIdFingerGetEvent read FOnCommandFinger
  62. write FOnCommandFinger;
  63. { This event fires when you receive a VERBOSE finger request}
  64. property OnCommandVerboseFinger : TIdFingerGetEvent
  65. read FOnCommandVerboseFinger write FOnCommandVerboseFinger;
  66. property DefaultPort default IDPORT_Finger;
  67. end;
  68. implementation
  69. uses
  70. IdGlobal, SysUtils;
  71. procedure TIdFingerServer.InitComponent;
  72. begin
  73. inherited InitComponent;
  74. DefaultPort := IdPORT_FINGER;
  75. end;
  76. function TIdFingerServer.DoExecute(AContext:TIdContext): boolean;
  77. Var
  78. s, LResponse: String;
  79. begin
  80. Result := True;
  81. {We use TrimRight in case there are spaces ending the query which are problematic
  82. for verbose queries. CyberKit puts a space after the /W parameter}
  83. s := TrimRight(AContext.Connection.IOHandler.ReadLn);
  84. if Assigned(FOnCommandVerboseFinger) and TextEndsWith(s, '/W') then {Do not Localize}
  85. begin
  86. {we remove the /W switch before calling the event}
  87. s := Copy(s, 1, Length(s)-2);
  88. OnCommandVerboseFinger(AContext, s, LResponse);
  89. AContext.Connection.IOHandler.Write(LResponse);
  90. end
  91. else if Assigned(OnCommandFinger) then begin
  92. OnCommandFinger(AContext, s, LResponse);
  93. AContext.Connection.IOHandler.Write(LResponse);
  94. end;
  95. AContext.Connection.Disconnect;
  96. end;
  97. end.