IdMailBox.pas 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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.4 2/4/2004 2:47:38 AM JPMugaas
  18. MOved SysUtils down to the implemenation uses clause.
  19. Rev 1.3 24/01/2004 21:45:36 CCostelloe
  20. InitCOmponent -> InitComponent (removes a warning)
  21. Rev 1.2 1/21/2004 3:11:26 PM JPMugaas
  22. InitComponent
  23. Rev 1.1 22/12/2003 00:44:34 CCostelloe
  24. .NET fixes
  25. Rev 1.0 11/13/2002 07:56:28 AM JPMugaas
  26. 2001-FEB-27 IC:
  27. First version, most of the needed MailBox features are implemented,
  28. next version should include a MailBox list structure that will hold
  29. an entire account mail box structure with the updated information.
  30. 2001-MAY-05 IC:
  31. }
  32. unit IdMailBox;
  33. {
  34. IdMailBox (Created for use with the IdIMAP4 unit)
  35. By Idan Cohen [email protected]
  36. }
  37. interface
  38. {$i IdCompilerDefines.inc}
  39. uses
  40. Classes,
  41. IdBaseComponent,
  42. IdMessage,
  43. IdMessageCollection;
  44. type
  45. TIdMailBoxState = ( msReadWrite, msReadOnly );
  46. TIdMailBoxAttributes = ( maNoinferiors, maNoselect, maMarked, maUnmarked );
  47. TIdMailBoxAttributesSet = set of TIdMailBoxAttributes;
  48. TUInt32Array = array of UInt32;
  49. TIdMailBox = class(TIdBaseComponent)
  50. protected
  51. FAttributes: TIdMailBoxAttributes;
  52. FChangeableFlags: TIdMessageFlagsSet;
  53. FFirstUnseenMsg: UInt32;
  54. FFlags: TIdMessageFlagsSet;
  55. FName: String;
  56. FMessageList: TIdMessageCollection;
  57. FRecentMsgs: Integer;
  58. FState: TIdMailBoxState;
  59. FTotalMsgs: Integer;
  60. FUIDNext: String;
  61. FUIDValidity: String;
  62. FUnseenMsgs: Integer;
  63. procedure SetMessageList(const Value: TIdMessageCollection);
  64. public
  65. DeletedMsgs: TUInt32Array;
  66. SearchResult: TUInt32Array;
  67. constructor Create(AOwner: TComponent); override;
  68. destructor Destroy; override;
  69. procedure Clear; virtual;
  70. property Attributes: TIdMailBoxAttributes read FAttributes write FAttributes;
  71. property ChangeableFlags: TIdMessageFlagsSet read FChangeableFlags write FChangeableFlags;
  72. property FirstUnseenMsg: UInt32 read FFirstUnseenMsg write FFirstUnseenMsg;
  73. property Flags: TIdMessageFlagsSet read FFlags write FFlags;
  74. property Name: String read FName write FName;
  75. property MessageList: TIdMessageCollection read FMessageList write SetMessageList;
  76. property RecentMsgs: Integer read FRecentMsgs write FRecentMsgs;
  77. property State: TIdMailBoxState read FState write FState;
  78. property TotalMsgs: Integer read FTotalMsgs write FTotalMsgs;
  79. property UIDNext: String read FUIDNext write FUIDNext;
  80. property UIDValidity: String read FUIDValidity write FUIDValidity;
  81. property UnseenMsgs: Integer read FUnseenMsgs write FUnseenMsgs;
  82. published
  83. end;
  84. const
  85. MailBoxAttributes : array [maNoinferiors..maUnmarked] of String =
  86. ( '\Noinferiors', //It is not possible for any child levels of {Do not Localize}
  87. //hierarchy to exist under this name; no child levels
  88. //exist now and none can be created in the future.
  89. '\Noselect', //It is not possible to use this name as a selectable {Do not Localize}
  90. //mailbox.
  91. '\Marked', //The mailbox has been marked "interesting" by the {Do not Localize}
  92. //server; the mailbox probably contains messages that
  93. //have been added since the last time the mailbox was
  94. //selected.
  95. '\Unmarked' ); //The mailbox does not contain any additional {Do not Localize}
  96. //messages since the last time the mailbox was
  97. //selected.
  98. implementation
  99. uses
  100. SysUtils;
  101. { TIdMailBox }
  102. constructor TIdMailBox.Create(AOwner: TComponent);
  103. begin
  104. inherited Create(AOwner);
  105. FMessageList := TIdMessageCollection.Create;
  106. Clear;
  107. end;
  108. destructor TIdMailBox.Destroy;
  109. begin
  110. FMessageList.Free;
  111. inherited Destroy;
  112. end;
  113. procedure TIdMailBox.Clear;
  114. begin
  115. FTotalMsgs := 0;
  116. FRecentMsgs := 0;
  117. FUnseenMsgs := 0;
  118. FFirstUnseenMsg := 0;
  119. FUIDValidity := ''; {Do not Localize}
  120. FUIDNext := ''; {Do not Localize}
  121. FName := ''; {Do not Localize}
  122. FState := msReadOnly;
  123. FAttributes := maNoselect;
  124. SetLength(DeletedMsgs, 0);
  125. SetLength(SearchResult, 0);
  126. FFlags := [];
  127. FChangeableFlags := [];
  128. MessageList.Clear;
  129. end;
  130. procedure TIdMailBox.SetMessageList(const Value: TIdMessageCollection);
  131. begin
  132. FMessageList.Assign(Value);
  133. end;
  134. end.