haiku/headers/os/mail/MailMessage.h

113 lines
3.6 KiB
C
Raw Normal View History

#ifndef ZOIDBERG_MAIL_MESSAGE_H
#define ZOIDBERG_MAIL_MESSAGE_H
/* Message - the main general purpose mail message class
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
#include <MailContainer.h>
// add our additional attributes
#define B_MAIL_ATTR_ACCOUNT "MAIL:account"
#define B_MAIL_ATTR_THREAD "MAIL:thread"
class BDirectory;
enum mail_reply_to_mode {
B_MAIL_REPLY_TO = 0,
B_MAIL_REPLY_TO_ALL,
B_MAIL_REPLY_TO_SENDER
};
class BEmailMessage : public BMailContainer {
public:
BEmailMessage(BPositionIO *mail_file = NULL, bool own = false, uint32 defaultCharSet = B_MAIL_NULL_CONVERSION);
Major restructuring of the mail server: Accounts are now stored in a separate file. Previously they where somehow magically assembled from the chain ids. Now its possible to remove a account temporary by removing the account file form the account folder. Each account could have an inbound protocol, an outbound protocol and some filters. Mails are now associated with an account and not with a chain. This required to replace the chain id attribute by an account attribute. Replace BMailFilter and BMailChain by a less general approach. Basically the chain had a list of filters and call the ProcessMailMessage for each filter. This made it sometime difficult to understand what is going on, e.g. sometimes a filter used information gathered by another filters. The new MailProtocol and MailFilter classes are calling more dedicated hook functions, e.g. HeaderFetched or MessageReadyToSend. As before all MailProtocol's (plus their filters) are running in their own thread. Cleaned up the error and status window a bit. Abstracted the interface to these windows. Should be easy to write a BNotification api back-end now. Parsing of mail headers is much faster now. Fetching the headers of a large mailbox takes ~min and not ~hour now! Initial checkout time is in the same order like Opera. The problem was the massive use of fgets in parse_header (mail_util.cpp) now the complete header is read in one go. Furthermore, only interesting fields are extracted. Remove some unused files, BeOS relicts... Feel free to translate the mail server and remove the own language system (headers/private/mail/MDRLanguage.h). Sorry for the remaining old (and new) coding style issues, sometime just ignore them, to many :( git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40397 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-02-09 04:49:01 +03:00
BEmailMessage(const entry_ref *ref,
uint32 defaultCharSet = B_MAIL_NULL_CONVERSION);
virtual ~BEmailMessage();
status_t InitCheck() const;
BPositionIO *Data() const { return fData; }
// is only set if the message owns the data
BEmailMessage *ReplyMessage(mail_reply_to_mode replyTo, bool accountFromMail, const char *quote_style = "> ");
BEmailMessage *ForwardMessage(bool accountFromMail, bool includeAttachments = false);
// These return messages with the body quoted and
// ready to send via the appropriate channel. ReplyMessage()
// addresses the message appropriately, but ForwardMessage()
// leaves it unaddressed.
const char *To();
const char *From();
const char *ReplyTo();
const char *CC();
const char *Subject();
const char *Date();
int Priority();
void SetSubject(const char *to, uint32 charset = B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
void SetReplyTo(const char *to, uint32 charset = B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
void SetFrom(const char *to, uint32 charset = B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
void SetTo(const char *to, uint32 charset = B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
void SetCC(const char *to, uint32 charset = B_MAIL_NULL_CONVERSION, mail_encoding encoding = null_encoding);
void SetBCC(const char *to);
void SetPriority(int to);
status_t GetName(char *name,int32 maxLength) const;
status_t GetName(BString *name) const;
void SendViaAccountFrom(BEmailMessage *message);
void SendViaAccount(const char *account_name);
Major restructuring of the mail server: Accounts are now stored in a separate file. Previously they where somehow magically assembled from the chain ids. Now its possible to remove a account temporary by removing the account file form the account folder. Each account could have an inbound protocol, an outbound protocol and some filters. Mails are now associated with an account and not with a chain. This required to replace the chain id attribute by an account attribute. Replace BMailFilter and BMailChain by a less general approach. Basically the chain had a list of filters and call the ProcessMailMessage for each filter. This made it sometime difficult to understand what is going on, e.g. sometimes a filter used information gathered by another filters. The new MailProtocol and MailFilter classes are calling more dedicated hook functions, e.g. HeaderFetched or MessageReadyToSend. As before all MailProtocol's (plus their filters) are running in their own thread. Cleaned up the error and status window a bit. Abstracted the interface to these windows. Should be easy to write a BNotification api back-end now. Parsing of mail headers is much faster now. Fetching the headers of a large mailbox takes ~min and not ~hour now! Initial checkout time is in the same order like Opera. The problem was the massive use of fgets in parse_header (mail_util.cpp) now the complete header is read in one go. Furthermore, only interesting fields are extracted. Remove some unused files, BeOS relicts... Feel free to translate the mail server and remove the own language system (headers/private/mail/MDRLanguage.h). Sorry for the remaining old (and new) coding style issues, sometime just ignore them, to many :( git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40397 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-02-09 04:49:01 +03:00
void SendViaAccount(int32 account);
int32 Account() const;
status_t GetAccountName(BString& accountName) const;
virtual status_t AddComponent(BMailComponent *component);
virtual status_t RemoveComponent(BMailComponent *component);
virtual status_t RemoveComponent(int32 index);
virtual BMailComponent *GetComponent(int32 index, bool parse_now = false);
virtual int32 CountComponents() const;
void Attach(entry_ref *ref, bool include_attributes = true);
bool IsComponentAttachment(int32 index);
void SetBodyTextTo(const char *text);
const char *BodyText();
status_t SetBody(BTextMailComponent *body);
BTextMailComponent *Body();
virtual status_t SetToRFC822(BPositionIO *data, size_t length, bool parse_now = false);
virtual status_t RenderToRFC822(BPositionIO *render_to);
status_t RenderTo(BDirectory *dir, BEntry *message = NULL);
//---message will be set to the message file if not equal to NULL
status_t Send(bool send_now);
private:
BTextMailComponent *RetrieveTextBody(BMailComponent *);
virtual void _ReservedMessage1();
virtual void _ReservedMessage2();
virtual void _ReservedMessage3();
BPositionIO *fData;
status_t _status;
Major restructuring of the mail server: Accounts are now stored in a separate file. Previously they where somehow magically assembled from the chain ids. Now its possible to remove a account temporary by removing the account file form the account folder. Each account could have an inbound protocol, an outbound protocol and some filters. Mails are now associated with an account and not with a chain. This required to replace the chain id attribute by an account attribute. Replace BMailFilter and BMailChain by a less general approach. Basically the chain had a list of filters and call the ProcessMailMessage for each filter. This made it sometime difficult to understand what is going on, e.g. sometimes a filter used information gathered by another filters. The new MailProtocol and MailFilter classes are calling more dedicated hook functions, e.g. HeaderFetched or MessageReadyToSend. As before all MailProtocol's (plus their filters) are running in their own thread. Cleaned up the error and status window a bit. Abstracted the interface to these windows. Should be easy to write a BNotification api back-end now. Parsing of mail headers is much faster now. Fetching the headers of a large mailbox takes ~min and not ~hour now! Initial checkout time is in the same order like Opera. The problem was the massive use of fgets in parse_header (mail_util.cpp) now the complete header is read in one go. Furthermore, only interesting fields are extracted. Remove some unused files, BeOS relicts... Feel free to translate the mail server and remove the own language system (headers/private/mail/MDRLanguage.h). Sorry for the remaining old (and new) coding style issues, sometime just ignore them, to many :( git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40397 a95241bf-73f2-0310-859d-f6bbb57e9c96
2011-02-09 04:49:01 +03:00
int32 _account_id;
char *_bcc;
int32 _num_components;
BMailComponent *_body;
BTextMailComponent *_text_body;
uint32 _reserved[5];
};
#endif /* ZOIDBERG_MAIL_MESSAGE_H */