1#ifndef ZOIDBERG_MAIL_MESSAGE_H
2#define ZOIDBERG_MAIL_MESSAGE_H
3/* Message - the main general purpose mail message class
4**
5** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
6*/
7
8
9#include <MailContainer.h>
10
11
12// add our additional attributes
13#define B_MAIL_ATTR_ACCOUNT "MAIL:account"
14#define B_MAIL_ATTR_THREAD "MAIL:thread"
15
16
17class BDirectory;
18
19enum mail_reply_to_mode {
20	B_MAIL_REPLY_TO = 0,
21	B_MAIL_REPLY_TO_ALL,
22	B_MAIL_REPLY_TO_SENDER
23};
24
25class BEmailMessage : public BMailContainer {
26	public:
27		BEmailMessage(BPositionIO *mail_file = NULL, bool own = false, uint32 defaultCharSet = B_MAIL_NULL_CONVERSION);
28		BEmailMessage(const entry_ref *ref,
29			uint32 defaultCharSet = B_MAIL_NULL_CONVERSION);
30		virtual ~BEmailMessage();
31
32		status_t InitCheck() const;
33		BPositionIO *Data() const { return fData; }
34			// is only set if the message owns the data
35
36		BEmailMessage *ReplyMessage(mail_reply_to_mode replyTo, bool accountFromMail, const char *quote_style = "> ");
37		BEmailMessage *ForwardMessage(bool accountFromMail, bool includeAttachments = false);
38			// These return messages with the body quoted and
39			// ready to send via the appropriate channel. ReplyMessage()
40			// addresses the message appropriately, but ForwardMessage()
41			// leaves it unaddressed.
42
43		const char *To();
44		const char *From();
45		const char *ReplyTo();
46		const char *CC();
47		const char *Subject();
48		const char *Date();
49		int Priority();
50
51		void SetSubject(const char *to, uint32 charset = B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
52		void SetReplyTo(const char *to, uint32 charset = B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
53		void SetFrom(const char *to, uint32 charset = B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
54		void SetTo(const char *to, uint32 charset = B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
55		void SetCC(const char *to, uint32 charset = B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
56		void SetBCC(const char *to);
57		void SetPriority(int to);
58
59		status_t GetName(char *name,int32 maxLength) const;
60		status_t GetName(BString *name) const;
61
62		void SendViaAccountFrom(BEmailMessage *message);
63		void SendViaAccount(const char *account_name);
64		void SendViaAccount(int32 account);
65		int32 Account() const;
66		status_t GetAccountName(BString& accountName) const;
67
68		virtual status_t AddComponent(BMailComponent *component);
69		virtual status_t RemoveComponent(BMailComponent *component);
70		virtual status_t RemoveComponent(int32 index);
71
72		virtual BMailComponent *GetComponent(int32 index, bool parse_now = false);
73		virtual int32 CountComponents() const;
74
75		void Attach(entry_ref *ref, bool include_attributes = true);
76		bool IsComponentAttachment(int32 index);
77
78		void SetBodyTextTo(const char *text);
79		const char *BodyText();
80
81		status_t SetBody(BTextMailComponent *body);
82		BTextMailComponent *Body();
83
84		virtual status_t SetToRFC822(BPositionIO *data, size_t length, bool parse_now = false);
85		virtual status_t RenderToRFC822(BPositionIO *render_to);
86
87		status_t RenderTo(BDirectory *dir, BEntry *message = NULL);
88			//---message will be set to the message file if not equal to NULL
89
90		status_t Send(bool send_now);
91
92	private:
93		BTextMailComponent *RetrieveTextBody(BMailComponent *);
94
95		virtual void _ReservedMessage1();
96		virtual void _ReservedMessage2();
97		virtual void _ReservedMessage3();
98
99		BPositionIO *fData;
100
101		status_t _status;
102		int32 _account_id;
103		char *_bcc;
104
105		int32 _num_components;
106		BMailComponent *_body;
107		BTextMailComponent *_text_body;
108
109		uint32 _reserved[5];
110};
111
112#endif	/* ZOIDBERG_MAIL_MESSAGE_H */
113