Fix FreeBSD build.
[haiku.git] / headers / os / mail / MailMessage.h
blob63a81501ae071f3678e73d8c9c566c3120728144
1 /*
2 * Copyright 2007-2012, Haiku Inc. All Rights Reserved.
3 * Copyright 2001, Dr. Zoidberg Enterprises. All rights reserved.
5 * Distributed under the terms of the MIT License.
6 */
7 #ifndef _MAIL_MESSAGE_H_
8 #define _MAIL_MESSAGE_H_
11 //! The main general purpose mail message class
14 #include <MailContainer.h>
17 // add our additional attributes
18 #define B_MAIL_ATTR_ACCOUNT "MAIL:account"
19 #define B_MAIL_ATTR_THREAD "MAIL:thread"
22 class BDirectory;
23 class BEntry;
26 enum mail_reply_to_mode {
27 B_MAIL_REPLY_TO = 0,
28 B_MAIL_REPLY_TO_ALL,
29 B_MAIL_REPLY_TO_SENDER
33 class BEmailMessage : public BMailContainer {
34 public:
35 BEmailMessage(BPositionIO* stream = NULL,
36 bool ownStream = false,
37 uint32 defaultCharSet
38 = B_MAIL_NULL_CONVERSION);
39 BEmailMessage(const entry_ref* ref,
40 uint32 defaultCharSet
41 = B_MAIL_NULL_CONVERSION);
42 virtual ~BEmailMessage();
44 status_t InitCheck() const;
45 BPositionIO* Data() const { return fData; }
46 // is only set if the message owns the data
48 BEmailMessage* ReplyMessage(mail_reply_to_mode replyTo,
49 bool accountFromMail,
50 const char* quoteStyle = "> ");
51 BEmailMessage* ForwardMessage(bool accountFromMail,
52 bool includeAttachments = false);
53 // These return messages with the body quoted and
54 // ready to send via the appropriate channel. ReplyMessage()
55 // addresses the message appropriately, but ForwardMessage()
56 // leaves it unaddressed.
58 const char* To() const;
59 const char* From() const;
60 const char* ReplyTo() const;
61 const char* CC() const;
62 const char* Subject() const;
63 time_t Date() const;
64 int Priority() const;
66 void SetSubject(const char* to,
67 uint32 charset = B_MAIL_NULL_CONVERSION,
68 mail_encoding encoding = null_encoding);
69 void SetReplyTo(const char* to,
70 uint32 charset = B_MAIL_NULL_CONVERSION,
71 mail_encoding encoding = null_encoding);
72 void SetFrom(const char* to,
73 uint32 charset = B_MAIL_NULL_CONVERSION,
74 mail_encoding encoding = null_encoding);
75 void SetTo(const char* to,
76 uint32 charset = B_MAIL_NULL_CONVERSION,
77 mail_encoding encoding = null_encoding);
78 void SetCC(const char* to,
79 uint32 charset = B_MAIL_NULL_CONVERSION,
80 mail_encoding encoding = null_encoding);
81 void SetBCC(const char* to);
82 void SetPriority(int to);
84 status_t GetName(char* name, int32 maxLength) const;
85 status_t GetName(BString* name) const;
87 void SendViaAccountFrom(BEmailMessage* message);
88 void SendViaAccount(const char* accountName);
89 void SendViaAccount(int32 account);
90 int32 Account() const;
91 status_t GetAccountName(BString& accountName) const;
93 virtual status_t AddComponent(BMailComponent *component);
94 virtual status_t RemoveComponent(BMailComponent *component);
95 virtual status_t RemoveComponent(int32 index);
97 virtual BMailComponent* GetComponent(int32 index,
98 bool parseNow = false);
99 virtual int32 CountComponents() const;
101 void Attach(entry_ref* ref,
102 bool includeAttributes = true);
103 bool IsComponentAttachment(int32 index);
105 void SetBodyTextTo(const char* text);
106 const char* BodyText();
108 status_t SetBody(BTextMailComponent* body);
109 BTextMailComponent* Body();
111 virtual status_t SetToRFC822(BPositionIO* data, size_t length,
112 bool parseNow = false);
113 virtual status_t RenderToRFC822(BPositionIO* renderTo);
115 status_t RenderTo(BDirectory* dir,
116 BEntry* message = NULL);
117 // Message will be set to the message file if not equal to NULL
119 status_t Send(bool sendNow);
121 private:
122 BTextMailComponent* _RetrieveTextBody(BMailComponent* component);
124 virtual void _ReservedMessage1();
125 virtual void _ReservedMessage2();
126 virtual void _ReservedMessage3();
128 private:
129 BPositionIO* fData;
131 status_t fStatus;
132 int32 fAccountID;
133 char* fBCC;
135 int32 fComponentCount;
136 BMailComponent* fBody;
137 BTextMailComponent* fTextBody;
139 uint32 _reserved[5];
143 #endif // _MAIL_MESSAGE_H_