xref: /haiku/headers/os/mail/E-mail.h (revision ab33d547d2d9c8103e3881f93f85b1f2edac2433)
19d19a1c8SStephan Aßmus /*
29d19a1c8SStephan Aßmus  * Copyright 2009, Haiku, Inc. All rights reserved.
39d19a1c8SStephan Aßmus  * Distributed under the terms of the MIT License.
49d19a1c8SStephan Aßmus  */
5bdde99f1Sshatty #ifndef _E_MAIL_H
6bdde99f1Sshatty #define _E_MAIL_H
7bdde99f1Sshatty 
89d19a1c8SStephan Aßmus 
9bdde99f1Sshatty #include <UTF8.h>
10bdde99f1Sshatty 
119d19a1c8SStephan Aßmus 
12bdde99f1Sshatty class BList;
13f6e4cbb9SAxel Dörfler struct entry_ref;
14bdde99f1Sshatty 
15bdde99f1Sshatty 
169d19a1c8SStephan Aßmus // E-Mail attributes
179d19a1c8SStephan Aßmus #define B_MAIL_ATTR_NAME		"MAIL:name"				// indexed string
189d19a1c8SStephan Aßmus #define B_MAIL_ATTR_STATUS		"MAIL:status"			// indexed string
199d19a1c8SStephan Aßmus #define B_MAIL_ATTR_PRIORITY	"MAIL:priority"			// indexed string
209d19a1c8SStephan Aßmus #define B_MAIL_ATTR_TO			"MAIL:to"				// indexed string
219d19a1c8SStephan Aßmus #define B_MAIL_ATTR_CC			"MAIL:cc"				// indexed string
221ea9f437SJonas Sundström #define B_MAIL_ATTR_BCC			"MAIL:bcc"				// string
239d19a1c8SStephan Aßmus #define B_MAIL_ATTR_FROM		"MAIL:from"				// indexed string
249d19a1c8SStephan Aßmus #define B_MAIL_ATTR_SUBJECT		"MAIL:subject"			// indexed string
259d19a1c8SStephan Aßmus #define B_MAIL_ATTR_REPLY		"MAIL:reply"			// indexed string
269d19a1c8SStephan Aßmus #define B_MAIL_ATTR_WHEN		"MAIL:when"				// indexed time
279d19a1c8SStephan Aßmus #define B_MAIL_ATTR_FLAGS		"MAIL:flags"			// indexed int32
289d19a1c8SStephan Aßmus #define B_MAIL_ATTR_RECIPIENTS	"MAIL:recipients"		// string
299d19a1c8SStephan Aßmus #define B_MAIL_ATTR_MIME		"MAIL:mime"				// string
309d19a1c8SStephan Aßmus #define B_MAIL_ATTR_HEADER		"MAIL:header_length"	// int32
319d19a1c8SStephan Aßmus #define B_MAIL_ATTR_CONTENT		"MAIL:content_length"	// int32
329967dfd9SClemens Zeidler #define B_MAIL_ATTR_READ		"MAIL:read"				// int32
33a64bd564SClemens Zeidler #define B_MAIL_ATTR_THREAD		"MAIL:thread"			// string
34a64bd564SClemens Zeidler #define B_MAIL_ATTR_ACCOUNT		"MAIL:account"			// string
35a64bd564SClemens Zeidler #define B_MAIL_ATTR_ACCOUNT_ID	"MAIL:account_id"		// int32
369967dfd9SClemens Zeidler 
379967dfd9SClemens Zeidler 
389967dfd9SClemens Zeidler // read flags
399967dfd9SClemens Zeidler enum read_flags {
409967dfd9SClemens Zeidler 	B_UNREAD				= 0,
419967dfd9SClemens Zeidler 	B_SEEN					= 1,
429967dfd9SClemens Zeidler 	B_READ					= 2
439967dfd9SClemens Zeidler 
449967dfd9SClemens Zeidler };
45bdde99f1Sshatty 
46bdde99f1Sshatty 
479d19a1c8SStephan Aßmus // mail flags
489d19a1c8SStephan Aßmus enum mail_flags {
499d19a1c8SStephan Aßmus 	B_MAIL_PENDING			= 1,						// waiting to be sent
50bdde99f1Sshatty 
519d19a1c8SStephan Aßmus 	B_MAIL_SENT				= 2,						// has been sent
52bdde99f1Sshatty 
539d19a1c8SStephan Aßmus 	B_MAIL_SAVE				= 4							// save mail after
549d19a1c8SStephan Aßmus 														// sending
559d19a1c8SStephan Aßmus };
56bdde99f1Sshatty 
579d19a1c8SStephan Aßmus #define B_MAIL_TYPE				"text/x-email"			// mime type
58df0ad9c1SClemens Zeidler #define B_PARTIAL_MAIL_TYPE		"text/x-partial-email"	// mime type
595344cdf4SNathan Whitehorn 
60bdde99f1Sshatty 
619d19a1c8SStephan Aßmus // WARNING: Everything past this point is deprecated. See MailMessage.h,
629d19a1c8SStephan Aßmus // mail_encoding.h and MailDaemon.h for alternatives.
639d19a1c8SStephan Aßmus 
649d19a1c8SStephan Aßmus 
659d19a1c8SStephan Aßmus // #pragma mark - defines
669d19a1c8SStephan Aßmus 
679d19a1c8SStephan Aßmus // schedule days
68bdde99f1Sshatty #define B_CHECK_NEVER			 0
69bdde99f1Sshatty #define B_CHECK_WEEKDAYS		 1
70bdde99f1Sshatty #define B_CHECK_DAILY			 2
71bdde99f1Sshatty #define B_CHECK_CONTINUOUSLY	 3
72bdde99f1Sshatty #define B_CHECK_CONTINUOSLY		 3
73bdde99f1Sshatty 
749d19a1c8SStephan Aßmus // max. lengths
75bdde99f1Sshatty #define B_MAX_USER_NAME_LENGTH	32
76bdde99f1Sshatty #define B_MAX_HOST_NAME_LENGTH	64
77bdde99f1Sshatty 
789d19a1c8SStephan Aßmus // rfc822 header field types
79bdde99f1Sshatty #define B_MAIL_TO				"To: "
80bdde99f1Sshatty #define B_MAIL_CC				"Cc: "
81bdde99f1Sshatty #define B_MAIL_BCC				"Bcc: "
82bdde99f1Sshatty #define B_MAIL_FROM				"From: "
83bdde99f1Sshatty #define B_MAIL_DATE				"Date: "
84bdde99f1Sshatty #define B_MAIL_REPLY			"Reply-To: "
85bdde99f1Sshatty #define B_MAIL_SUBJECT			"Subject: "
86bdde99f1Sshatty #define B_MAIL_PRIORITY			"Priority: "
87bdde99f1Sshatty 
88bdde99f1Sshatty 
899d19a1c8SStephan Aßmus // #pragma mark - structs
909d19a1c8SStephan Aßmus 
91bdde99f1Sshatty 
92bdde99f1Sshatty typedef struct {
93bdde99f1Sshatty 	char		pop_name[B_MAX_USER_NAME_LENGTH];
94bdde99f1Sshatty 	char		pop_password[B_MAX_USER_NAME_LENGTH];
95bdde99f1Sshatty 	char		pop_host[B_MAX_HOST_NAME_LENGTH];
96bdde99f1Sshatty 	char		real_name[128];
97bdde99f1Sshatty 	char		reply_to[128];
98bdde99f1Sshatty 	int32		days;			/* see flags above*/
99bdde99f1Sshatty 	int32		interval;		/* in seconds*/
100bdde99f1Sshatty 	int32		begin_time;		/* in seconds*/
101bdde99f1Sshatty 	int32		end_time;		/* in seconds*/
102bdde99f1Sshatty } mail_pop_account;
103bdde99f1Sshatty 
104bdde99f1Sshatty typedef struct {
105bdde99f1Sshatty 	bool		alert;
106bdde99f1Sshatty 	bool		beep;
107bdde99f1Sshatty } mail_notification;
108bdde99f1Sshatty 
1099d19a1c8SStephan Aßmus 
110b676e13cSScott McCreary // #pragma mark - global functions
111b676e13cSScott McCreary 
112b676e13cSScott McCreary int32 count_pop_accounts(void);
113b676e13cSScott McCreary status_t get_pop_account(mail_pop_account*, int32 index = 0);
114b676e13cSScott McCreary status_t set_pop_account(mail_pop_account*, int32 index = 0,
115*ab33d547SStefano Ceccherini 	bool save = true);
116b676e13cSScott McCreary 
117b676e13cSScott McCreary 
1189d19a1c8SStephan Aßmus // #pragma mark - BMailMessage
119bdde99f1Sshatty 
120bdde99f1Sshatty class BMailMessage {
121bdde99f1Sshatty public:
1229d19a1c8SStephan Aßmus 								BMailMessage();
1239d19a1c8SStephan Aßmus 								~BMailMessage();
124bdde99f1Sshatty 
125bdde99f1Sshatty 			status_t			AddContent(const char* text, int32 length,
126bdde99f1Sshatty 									uint32 encoding = B_ISO1_CONVERSION,
127bdde99f1Sshatty 									bool clobber = false);
128bdde99f1Sshatty 			status_t			AddContent(const char* text, int32 length,
1299d19a1c8SStephan Aßmus 									const char* encoding,
130bdde99f1Sshatty 									bool clobber = false);
131bdde99f1Sshatty 
1329d19a1c8SStephan Aßmus 			status_t			AddEnclosure(entry_ref* ref,
133bdde99f1Sshatty 									bool clobber = false);
1349d19a1c8SStephan Aßmus 			status_t			AddEnclosure(const char* path,
135bdde99f1Sshatty 									bool clobber = false);
1369d19a1c8SStephan Aßmus 			status_t			AddEnclosure(const char* MIME_type, void* data,
1379d19a1c8SStephan Aßmus 									int32 len, bool clobber = false);
138bdde99f1Sshatty 
1399d19a1c8SStephan Aßmus 			status_t			AddHeaderField(uint32 encoding,
1409d19a1c8SStephan Aßmus 									const char* field_name, const char* str,
1419d19a1c8SStephan Aßmus 									bool clobber = false);
1429d19a1c8SStephan Aßmus 			status_t			AddHeaderField(const char* field_name,
1439d19a1c8SStephan Aßmus 									const char* str, bool clobber = false);
144bdde99f1Sshatty 
1459d19a1c8SStephan Aßmus 			status_t			Send(bool sendNow = false,
1469d19a1c8SStephan Aßmus 									 bool removeAfterSending = false);
147bdde99f1Sshatty 
1489d19a1c8SStephan Aßmus private:
1499d19a1c8SStephan Aßmus 			int32				concatinate(char**, int32, char*);
1509d19a1c8SStephan Aßmus 			int32				count_fields(char* name = NULL);
1519d19a1c8SStephan Aßmus 			status_t			find_field(char*, type_code*, char**, void**,
1529d19a1c8SStephan Aßmus 									int32*, uint32*, char**, bool*, int32);
1539d19a1c8SStephan Aßmus 			BList*				find_field(const char*);
1549d19a1c8SStephan Aßmus 			status_t			get_field_name(char**, int32);
1559d19a1c8SStephan Aßmus 			status_t			set_field(const char*, type_code, const char*,
1569d19a1c8SStephan Aßmus 									const void*, int32, uint32, const char*,
1579d19a1c8SStephan Aßmus 									bool);
158bdde99f1Sshatty 
159bdde99f1Sshatty private:
160bdde99f1Sshatty 			BList*		fFields;
161bdde99f1Sshatty 			bool		fMultiPart;
162bdde99f1Sshatty };
163bdde99f1Sshatty 
1649d19a1c8SStephan Aßmus #endif // _MAIL_H
165