IdMailBox.pas 4.7 KB

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