IdMailBox.pas 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. {$IFNDEF HAS_UInt32}
  41. IdGlobal,
  42. {$ENDIF}
  43. IdBaseComponent,
  44. IdMessage,
  45. IdMessageCollection;
  46. type
  47. TIdMailBoxState = ( msReadWrite, msReadOnly );
  48. TIdMailBoxAttributes = ( maNoinferiors, maNoselect, maMarked, maUnmarked );
  49. TIdMailBoxAttributesSet = set of TIdMailBoxAttributes;
  50. TUInt32Array = array of UInt32;
  51. TIdMailBox = class(TIdBaseComponent)
  52. protected
  53. FAttributes: TIdMailBoxAttributes;
  54. FChangeableFlags: TIdMessageFlagsSet;
  55. FFirstUnseenMsg: UInt32;
  56. FFlags: TIdMessageFlagsSet;
  57. FName: String;
  58. FMessageList: TIdMessageCollection;
  59. FRecentMsgs: Integer;
  60. FState: TIdMailBoxState;
  61. FTotalMsgs: Integer;
  62. FUIDNext: String;
  63. FUIDValidity: String;
  64. FUnseenMsgs: Integer;
  65. procedure SetMessageList(const Value: TIdMessageCollection);
  66. procedure InitComponent; override;
  67. public
  68. DeletedMsgs: TUInt32Array;
  69. SearchResult: TUInt32Array;
  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. procedure Clear; virtual;
  83. destructor Destroy; override;
  84. published
  85. end;
  86. const
  87. MailBoxAttributes : array [maNoinferiors..maUnmarked] of String =
  88. ( '\Noinferiors', //It is not possible for any child levels of {Do not Localize}
  89. //hierarchy to exist under this name; no child levels
  90. //exist now and none can be created in the future.
  91. '\Noselect', //It is not possible to use this name as a selectable {Do not Localize}
  92. //mailbox.
  93. '\Marked', //The mailbox has been marked "interesting" by the {Do not Localize}
  94. //server; the mailbox probably contains messages that
  95. //have been added since the last time the mailbox was
  96. //selected.
  97. '\Unmarked' ); //The mailbox does not contain any additional {Do not Localize}
  98. //messages since the last time the mailbox was
  99. //selected.
  100. implementation
  101. uses
  102. SysUtils;
  103. { TIdMailBox }
  104. procedure TIdMailBox.Clear;
  105. begin
  106. FTotalMsgs := 0;
  107. FRecentMsgs := 0;
  108. FUnseenMsgs := 0;
  109. FFirstUnseenMsg := 0;
  110. FUIDValidity := ''; {Do not Localize}
  111. FUIDNext := ''; {Do not Localize}
  112. FName := ''; {Do not Localize}
  113. FState := msReadOnly;
  114. FAttributes := maNoselect;
  115. SetLength(DeletedMsgs, 0);
  116. SetLength(SearchResult, 0);
  117. FFlags := [];
  118. FChangeableFlags := [];
  119. MessageList.Clear;
  120. end;
  121. procedure TIdMailBox.InitComponent;
  122. begin
  123. inherited InitComponent;
  124. FMessageList := TIdMessageCollection.Create;
  125. Clear;
  126. end;
  127. destructor TIdMailBox.Destroy;
  128. begin
  129. FreeAndNil(FMessageList);
  130. inherited Destroy;
  131. end;
  132. procedure TIdMailBox.SetMessageList(const Value: TIdMessageCollection);
  133. begin
  134. FMessageList.Assign(Value);
  135. end;
  136. end.