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