FTPSiteInfo.pas 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. { $HDR$}
  2. {**********************************************************************}
  3. { Unit archived using Team Coherence }
  4. { Team Coherence is Copyright 2002 by Quality Software Components }
  5. { }
  6. { For further information / comments, visit our WEB site at }
  7. { http://www.TeamCoherence.com }
  8. {**********************************************************************}
  9. {}
  10. { $Log: 23176: FTPSiteInfo.pas
  11. {
  12. { Rev 1.1 09/11/2003 2:11:52 PM Jeremy Darling
  13. { Updated some of the site configuration stuff and made it so that you can add,
  14. { edit and delete sites from your site list. Also added a Site Name so that
  15. { you don't have to see the address when selecting a site.
  16. }
  17. {
  18. { Rev 1.0 09/11/2003 12:50:02 PM Jeremy Darling
  19. { Project Added to TC
  20. }
  21. unit FTPSiteInfo;
  22. interface
  23. uses
  24. Classes,
  25. SysUtils;
  26. type
  27. TFTPSiteInfo = class
  28. Address,
  29. Name,
  30. UserName,
  31. Password,
  32. RootDir : String;
  33. end;
  34. TFTPSiteList = class
  35. private
  36. List : TList;
  37. function GetCount: Integer;
  38. function GetSites(index: integer): TFTPSiteInfo;
  39. public
  40. property Sites[index:integer] : TFTPSiteInfo read GetSites; default;
  41. property Count : Integer read GetCount;
  42. function New : TFTPSiteInfo;
  43. function Add( Site : TFTPSiteInfo ) : Integer;
  44. function IndexOfName(SiteName : String) : Integer;
  45. function IndexOfAddress(SiteAddress : String) : Integer;
  46. function IndexOf(Site : TFTPSiteInfo) : Integer;
  47. procedure Clear;
  48. procedure Delete(index : Integer);
  49. constructor Create;
  50. destructor Destroy; override;
  51. end;
  52. implementation
  53. { TFTPSiteList }
  54. function TFTPSiteList.Add(Site: TFTPSiteInfo): Integer;
  55. begin
  56. Result := List.Add(Site);
  57. end;
  58. procedure TFTPSiteList.Clear;
  59. begin
  60. while Count > 0 do
  61. Delete(0);
  62. end;
  63. constructor TFTPSiteList.Create;
  64. begin
  65. inherited;
  66. List := TList.Create;
  67. end;
  68. procedure TFTPSiteList.Delete(index: Integer);
  69. begin
  70. Sites[index].Free;
  71. List.Delete(index);
  72. end;
  73. destructor TFTPSiteList.Destroy;
  74. begin
  75. List.Free;
  76. inherited;
  77. end;
  78. function TFTPSiteList.GetCount: Integer;
  79. begin
  80. Result := List.Count;
  81. end;
  82. function TFTPSiteList.GetSites(index: integer): TFTPSiteInfo;
  83. begin
  84. Result := List[index];
  85. end;
  86. function TFTPSiteList.IndexOf(Site: TFTPSiteInfo): Integer;
  87. begin
  88. Result := List.IndexOf(Site);
  89. end;
  90. function TFTPSiteList.IndexOfAddress(SiteAddress: String): Integer;
  91. var
  92. i : Integer;
  93. begin
  94. i := 0;
  95. Result := -1;
  96. while (i < Count) and
  97. (Result = -1) do
  98. begin
  99. if AnsiCompareText(Sites[i].Address, SiteAddress) = 0 then
  100. Result := i;
  101. inc(i);
  102. end;
  103. end;
  104. function TFTPSiteList.IndexOfName(SiteName: String): Integer;
  105. var
  106. i : Integer;
  107. begin
  108. i := 0;
  109. Result := -1;
  110. while (i < Count) and
  111. (Result = -1) do
  112. begin
  113. if AnsiCompareText(Sites[i].Name, SiteName) = 0 then
  114. Result := i;
  115. inc(i);
  116. end;
  117. end;
  118. function TFTPSiteList.New: TFTPSiteInfo;
  119. begin
  120. Result := TFTPSiteInfo.Create;
  121. List.Add(Result);
  122. end;
  123. end.