xref: /haiku/headers/os/mail/E-mail.h (revision f6e4cbb95290a74b33d012600438b84742b0e572)
1bdde99f1Sshatty /*******************************************************************************
2bdde99f1Sshatty /
3bdde99f1Sshatty /	File:		E-mail.h
4bdde99f1Sshatty /
5bdde99f1Sshatty /	Description:	Mail attributes and BMailMessage class.
6bdde99f1Sshatty /
7bdde99f1Sshatty /	Copyright 1993-98, Be Incorporated, All Rights Reserved.
8bdde99f1Sshatty /
9bdde99f1Sshatty *******************************************************************************/
10bdde99f1Sshatty 
11bdde99f1Sshatty #ifndef _E_MAIL_H
12bdde99f1Sshatty #define _E_MAIL_H
13bdde99f1Sshatty 
14bdde99f1Sshatty #include <UTF8.h>
15bdde99f1Sshatty 
16bdde99f1Sshatty class BList;
17*f6e4cbb9SAxel Dörfler struct entry_ref;
18bdde99f1Sshatty 
19bdde99f1Sshatty /* -----------------------------------------------------------------------*/
20bdde99f1Sshatty /* 'E-Mail' attributes...*/
21bdde99f1Sshatty 
22bdde99f1Sshatty #define B_MAIL_ATTR_NAME		"MAIL:name"			/* indexed string*/
23bdde99f1Sshatty #define B_MAIL_ATTR_STATUS		"MAIL:status"		/* indexed string*/
24bdde99f1Sshatty #define B_MAIL_ATTR_PRIORITY	"MAIL:priority"		/* indexed string*/
25bdde99f1Sshatty #define B_MAIL_ATTR_TO			"MAIL:to"			/* indexed string*/
26bdde99f1Sshatty #define B_MAIL_ATTR_CC			"MAIL:cc"			/* indexed string*/
27bdde99f1Sshatty #define B_MAIL_ATTR_FROM		"MAIL:from"			/* indexed string*/
28bdde99f1Sshatty #define B_MAIL_ATTR_SUBJECT		"MAIL:subject"		/* indexed string*/
29bdde99f1Sshatty #define B_MAIL_ATTR_REPLY		"MAIL:reply"		/* indexed string*/
30bdde99f1Sshatty #define B_MAIL_ATTR_WHEN		"MAIL:when"			/* indexed time*/
31bdde99f1Sshatty #define B_MAIL_ATTR_FLAGS		"MAIL:flags"		/* indexed int32*/
32bdde99f1Sshatty #define B_MAIL_ATTR_RECIPIENTS	"MAIL:recipients"	/* string*/
33bdde99f1Sshatty #define B_MAIL_ATTR_MIME		"MAIL:mime"			/* string*/
34bdde99f1Sshatty #define B_MAIL_ATTR_HEADER		"MAIL:header_length"	/* int32*/
35bdde99f1Sshatty #define B_MAIL_ATTR_CONTENT		"MAIL:content_length"	/* int32*/
36bdde99f1Sshatty 
37bdde99f1Sshatty 
38bdde99f1Sshatty /* mail flags */
39bdde99f1Sshatty enum	mail_flags			{B_MAIL_PENDING	= 1,	/* waiting to be sent*/
40bdde99f1Sshatty 							 B_MAIL_SENT	= 2,	/* has been sent*/
41bdde99f1Sshatty 							 B_MAIL_SAVE	= 4};	/* save mail after sending*/
42bdde99f1Sshatty 
43bdde99f1Sshatty #define B_MAIL_TYPE			"text/x-email"			/* mime type*/
44bdde99f1Sshatty 
455344cdf4SNathan Whitehorn /* Everything past this point is deprecated. See MailMessage.h, mail_encoding.h
465344cdf4SNathan Whitehorn 	and MailDaemon.h for alternatives. */
47bdde99f1Sshatty 
485344cdf4SNathan Whitehorn /* DEPRECATED -- DEPRECATED -- DEPRECATED -- DEPRECATED -- DEPRECATED */
495344cdf4SNathan Whitehorn /* DEPRECATED -- DEPRECATED -- DEPRECATED -- DEPRECATED -- DEPRECATED */
505344cdf4SNathan Whitehorn 
51bdde99f1Sshatty /* defines...*/
52bdde99f1Sshatty 
53bdde99f1Sshatty /* schedule days */
54bdde99f1Sshatty #define B_CHECK_NEVER			 0
55bdde99f1Sshatty #define B_CHECK_WEEKDAYS		 1
56bdde99f1Sshatty #define B_CHECK_DAILY			 2
57bdde99f1Sshatty #define B_CHECK_CONTINUOUSLY	 3
58bdde99f1Sshatty #define B_CHECK_CONTINUOSLY		 3
59bdde99f1Sshatty 
60bdde99f1Sshatty /* max. lengths */
61bdde99f1Sshatty #define B_MAX_USER_NAME_LENGTH	32
62bdde99f1Sshatty #define B_MAX_HOST_NAME_LENGTH	64
63bdde99f1Sshatty 
64bdde99f1Sshatty /* rfc822 header field types */
65bdde99f1Sshatty #define B_MAIL_TO			"To: "
66bdde99f1Sshatty #define B_MAIL_CC			"Cc: "
67bdde99f1Sshatty #define B_MAIL_BCC			"Bcc: "
68bdde99f1Sshatty #define B_MAIL_FROM			"From: "
69bdde99f1Sshatty #define B_MAIL_DATE			"Date: "
70bdde99f1Sshatty #define B_MAIL_REPLY		"Reply-To: "
71bdde99f1Sshatty #define B_MAIL_SUBJECT		"Subject: "
72bdde99f1Sshatty #define B_MAIL_PRIORITY		"Priority: "
73bdde99f1Sshatty 
74bdde99f1Sshatty 
75bdde99f1Sshatty /* -----------------------------------------------------------------------*/
76bdde99f1Sshatty /* structs...*/
77bdde99f1Sshatty 
78bdde99f1Sshatty typedef struct {
79bdde99f1Sshatty 	char		pop_name[B_MAX_USER_NAME_LENGTH];
80bdde99f1Sshatty 	char		pop_password[B_MAX_USER_NAME_LENGTH];
81bdde99f1Sshatty 	char		pop_host[B_MAX_HOST_NAME_LENGTH];
82bdde99f1Sshatty 	char		real_name[128];
83bdde99f1Sshatty 	char		reply_to[128];
84bdde99f1Sshatty 	int32		days;			/* see flags above*/
85bdde99f1Sshatty 	int32		interval;		/* in seconds*/
86bdde99f1Sshatty 	int32		begin_time;		/* in seconds*/
87bdde99f1Sshatty 	int32		end_time;		/* in seconds*/
88bdde99f1Sshatty } mail_pop_account;
89bdde99f1Sshatty 
90bdde99f1Sshatty typedef struct {
91bdde99f1Sshatty 	bool		alert;
92bdde99f1Sshatty 	bool		beep;
93bdde99f1Sshatty } mail_notification;
94bdde99f1Sshatty 
95bdde99f1Sshatty /* -----------------------------------------------------------------------*/
96bdde99f1Sshatty /* global functions...*/
97bdde99f1Sshatty 
98*f6e4cbb9SAxel Dörfler int32		count_pop_accounts(void);
99*f6e4cbb9SAxel Dörfler status_t	get_pop_account(mail_pop_account*, int32 index = 0);
100*f6e4cbb9SAxel Dörfler status_t	set_pop_account(mail_pop_account*, int32 index = 0,
101bdde99f1Sshatty 							bool save = true);
102*f6e4cbb9SAxel Dörfler status_t	get_smtp_host(char*);
103*f6e4cbb9SAxel Dörfler status_t	set_smtp_host(char*, bool save = true);
104*f6e4cbb9SAxel Dörfler status_t	get_mail_notification(mail_notification*);
105*f6e4cbb9SAxel Dörfler status_t	set_mail_notification(mail_notification*, bool save = true);
106bdde99f1Sshatty 
107*f6e4cbb9SAxel Dörfler status_t	check_for_mail(int32 *incoming_count = NULL);
108*f6e4cbb9SAxel Dörfler status_t	send_queued_mail(void);
109*f6e4cbb9SAxel Dörfler status_t	forward_mail(entry_ref*, const char* recipients, bool now = true);
110bdde99f1Sshatty 
111*f6e4cbb9SAxel Dörfler ssize_t	decode_base64(char *out, char *in, off_t length,
112bdde99f1Sshatty 							bool replace_cr = false);
113*f6e4cbb9SAxel Dörfler ssize_t	encode_base64(char *out, char *in, off_t length);
114bdde99f1Sshatty 
115bdde99f1Sshatty 
116bdde99f1Sshatty /* -----------------------------------------------------------------------*/
117bdde99f1Sshatty /* class...*/
118bdde99f1Sshatty 
119bdde99f1Sshatty class BMailMessage {
120bdde99f1Sshatty 
121bdde99f1Sshatty public:
122bdde99f1Sshatty 					BMailMessage(void);
123bdde99f1Sshatty 					~BMailMessage(void);
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,
129bdde99f1Sshatty 							   const char *encoding, bool clobber = false);
130bdde99f1Sshatty 
131bdde99f1Sshatty 		status_t	AddEnclosure(entry_ref *ref, bool clobber = false);
132bdde99f1Sshatty 		status_t	AddEnclosure(const char *path, bool clobber = false);
133bdde99f1Sshatty 		status_t	AddEnclosure(const char *MIME_type, void *data, int32 len,
134bdde99f1Sshatty 								 bool clobber = false);
135bdde99f1Sshatty 
136bdde99f1Sshatty 		status_t	AddHeaderField(uint32 encoding, const char *field_name, const char *str,
137bdde99f1Sshatty 								   bool clobber = false);
138bdde99f1Sshatty 		status_t	AddHeaderField(const char *field_name, const char *str,
139bdde99f1Sshatty 								   bool clobber = false);
140bdde99f1Sshatty 
141bdde99f1Sshatty 		status_t	Send(bool send_now = false,
142bdde99f1Sshatty 						 bool remove_when_I_have_completed_sending_this_message_to_your_preferred_SMTP_server = false);
143bdde99f1Sshatty 
144bdde99f1Sshatty 
145bdde99f1Sshatty /* -----------------------------------------------------------------------*/
146bdde99f1Sshatty 
147bdde99f1Sshatty private:
148bdde99f1Sshatty 		BList*		fFields;
149bdde99f1Sshatty 		bool		fMultiPart;
150bdde99f1Sshatty 
151bdde99f1Sshatty 		int32		concatinate(char**, int32, char*);
152bdde99f1Sshatty 		int32		count_fields(char *name = NULL);
153bdde99f1Sshatty 		status_t	find_field(char*, type_code*, char**, void**, int32*,
154bdde99f1Sshatty 							   uint32*, char**, bool*, int32);
155bdde99f1Sshatty 		BList*		find_field(const char*);
156bdde99f1Sshatty 		status_t	get_field_name(char**, int32);
157bdde99f1Sshatty 		status_t	set_field(const char*, type_code, const char*, const void*,
158bdde99f1Sshatty 							  int32, uint32, const char*, bool);
159bdde99f1Sshatty };
160bdde99f1Sshatty 
161bdde99f1Sshatty #endif /* _MAIL_H */
162