Forgot some files in the MDR import.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9017 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Nathan Whitehorn
2004-09-20 22:34:03 +00:00
parent f7215ac853
commit fa84ff9eb1
13 changed files with 720 additions and 0 deletions
+127
View File
@@ -0,0 +1,127 @@
#ifndef ZOIDBERG_MAIL_ATTACHMENT_H
#define ZOIDBERG_MAIL_ATTACHMENT_H
/* Attachment - classes which handle mail attachments
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
#include <Node.h>
#include <MailContainer.h>
#include <MailComponent.h>
class BMailAttachment : public BMailComponent {
public:
virtual void SetFileName(const char *name) = 0;
virtual status_t FileName(char *name) = 0;
virtual status_t SetTo(BFile *file, bool deleteFileWhenDone = false) = 0;
virtual status_t SetTo(entry_ref *ref) = 0;
virtual status_t InitCheck() = 0;
private:
virtual void _ReservedAttachment1();
virtual void _ReservedAttachment2();
virtual void _ReservedAttachment3();
virtual void _ReservedAttachment4();
};
class BSimpleMailAttachment : public BMailAttachment {
public:
BSimpleMailAttachment(BPositionIO *dataToAttach, mail_encoding encoding = base64);
BSimpleMailAttachment(const void *dataToAttach, size_t lengthOfData, mail_encoding encoding = base64);
BSimpleMailAttachment(BFile *file, bool delete_when_done);
BSimpleMailAttachment(entry_ref *ref);
BSimpleMailAttachment();
virtual ~BSimpleMailAttachment();
virtual status_t SetTo(BFile *file, bool delete_file_when_done = false);
virtual status_t SetTo(entry_ref *ref);
virtual status_t InitCheck();
virtual void SetFileName(const char *name);
virtual status_t FileName(char *name);
virtual status_t GetDecodedData(BPositionIO *data);
virtual status_t SetDecodedData(BPositionIO *data);
virtual BPositionIO *GetDecodedData();
virtual status_t SetDecodedData(const void *data, size_t length /* data to attach */);
virtual status_t SetDecodedDataAndDeleteWhenDone(BPositionIO *data);
void SetEncoding(mail_encoding encoding = base64 /* note: we only support base64. This is a no-op */);
mail_encoding Encoding();
virtual status_t SetToRFC822(BPositionIO *data, size_t length, bool parse_now = false);
virtual status_t RenderToRFC822(BPositionIO *render_to);
private:
void Initialize(mail_encoding encoding);
void ParseNow();
virtual void _ReservedSimple1();
virtual void _ReservedSimple2();
virtual void _ReservedSimple3();
status_t fStatus;
BPositionIO *_data, *_raw_data;
size_t _raw_length;
off_t _raw_offset;
bool _we_own_data;
mail_encoding _encoding;
uint32 _reserved[5];
};
class BAttributedMailAttachment : public BMailAttachment {
public:
BAttributedMailAttachment(BFile *file, bool delete_when_done);
BAttributedMailAttachment(entry_ref *ref);
BAttributedMailAttachment();
virtual ~BAttributedMailAttachment();
virtual status_t SetTo(BFile *file, bool delete_file_when_done = false);
virtual status_t SetTo(entry_ref *ref);
virtual status_t InitCheck();
void SaveToDisk(BEntry *entry);
//-----we pay no attention to entry, but set it to the location of our file in /tmp
void SetEncoding(mail_encoding encoding /* anything but uuencode */);
mail_encoding Encoding();
virtual status_t FileName(char *name);
virtual void SetFileName(const char *name);
virtual status_t GetDecodedData(BPositionIO *data);
virtual status_t SetDecodedData(BPositionIO *data);
virtual status_t SetToRFC822(BPositionIO *data, size_t length, bool parse_now = false);
virtual status_t RenderToRFC822(BPositionIO *render_to);
virtual status_t MIMEType(BMimeType *mime);
private:
status_t Initialize();
virtual void _ReservedAttributed1();
virtual void _ReservedAttributed2();
virtual void _ReservedAttributed3();
BMIMEMultipartMailContainer *fContainer;
status_t fStatus;
BSimpleMailAttachment *_data, *_attributes_attach;
BMessage _attributes;
uint32 _reserved[5];
};
#endif /* ZOIDBERG_MAIL_ATTACHMENT_H */
+140
View File
@@ -0,0 +1,140 @@
#ifndef ZOIDBERG_MAIL_COMPONENT_H
#define ZOIDBERG_MAIL_COMPONENT_H
/* (Text)Component - message component base class and plain text
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
#include <UTF8.h>
#include <Message.h>
#include <String.h>
#include <mail_encoding.h>
class BMimeType;
extern const char *kHeaderCharsetString;
extern const char *kHeaderEncodingString;
// Special field names in the headers which specify the character set (int32)
// and encoding (int8) to use when converting the headers from UTF-8 to the
// output e-mail format (rfc2047). For use with SetHeaderField when you pass
// it a structured header in a BMessage.
enum component_type {
B_MAIL_PLAIN_TEXT_BODY = 0,
B_MAIL_SIMPLE_ATTACHMENT,
B_MAIL_ATTRIBUTED_ATTACHMENT,
B_MAIL_MULTIPART_CONTAINER
};
class BMailComponent {
public:
BMailComponent(uint32 defaultCharSet = B_MAIL_NULL_CONVERSION);
virtual ~BMailComponent();
//------Info on this component
uint32 ComponentType();
BMailComponent *WhatIsThis();
// Takes any generic MailComponent, and returns an instance
// of a MailComponent subclass that applies to this case,
// ready for instantiation. Note that you still have to
// Instantiate() it yourself.
bool IsAttachment();
// Returns true if this component is an attachment, false
// otherwise
void SetHeaderField(
const char *key, const char *value,
uint32 charset = B_MAIL_NULL_CONVERSION,
mail_encoding encoding = null_encoding,
bool replace_existing = true);
// If you want to delete a header, pass in a zero length or NULL
// string for the value field, or use RemoveHeader.
void SetHeaderField(
const char *key, BMessage *structured_header,
bool replace_existing = true);
const char *HeaderAt(int32 index);
const char *HeaderField(const char *key, int32 index = 0);
status_t HeaderField(const char *key, BMessage *structured_header, int32 index = 0);
status_t RemoveHeader(const char *key);
virtual status_t GetDecodedData(BPositionIO *data);
virtual status_t SetDecodedData(BPositionIO *data);
virtual status_t SetToRFC822(BPositionIO *data, size_t length, bool parse_now = false);
virtual status_t RenderToRFC822(BPositionIO *render_to);
virtual status_t MIMEType(BMimeType *mime);
protected:
uint32 _charSetForTextDecoding;
// This is the character set to be used for decoding text
// components, or if it is B_MAIL_NULL_CONVERSION then the character
// set will be determined automatically. Since we can't use a
// global variable (different messages might have different values
// of this), and since sub-components can't find their parents,
// this is passed down during construction to some (just Component,
// Container, Message, MIME, Text) child components and ends up
// being used in the text components.
private:
virtual void _ReservedComponent1();
virtual void _ReservedComponent2();
virtual void _ReservedComponent3();
virtual void _ReservedComponent4();
virtual void _ReservedComponent5();
BMessage headers;
uint32 _reserved[5];
};
class BTextMailComponent : public BMailComponent {
public:
BTextMailComponent(const char *text = NULL, uint32 defaultCharSet = B_MAIL_NULL_CONVERSION);
virtual ~BTextMailComponent();
void SetEncoding(mail_encoding encoding, int32 charset);
// encoding: you should always use quoted_printable, base64 is strongly not
// recommended, see rfc 2047 for the reasons why
// charset: use Conversion flavor constants from UTF8.h
void SetText(const char *text);
void AppendText(const char *text);
const char *Text();
BString *BStringText();
void Quote(const char *message = NULL,
const char *quote_style = "> ");
virtual status_t GetDecodedData(BPositionIO *data);
virtual status_t SetDecodedData(BPositionIO *data);
virtual status_t SetToRFC822(BPositionIO *data, size_t length, bool parse_now = false);
virtual status_t RenderToRFC822(BPositionIO *render_to);
private:
virtual void _ReservedText1();
virtual void _ReservedText2();
BString text;
BString decoded;
mail_encoding encoding;
uint32 charset; // This character set is used for encoding, not decoding.
status_t ParseRaw();
BPositionIO *raw_data;
size_t raw_length;
off_t raw_offset;
uint32 _reserved[5];
};
#endif /* ZOIDBERG_MAIL_COMPONENT_H */
+78
View File
@@ -0,0 +1,78 @@
#ifndef ZOIDBERG_MAIL_CONTAINER_H
#define ZOIDBERG_MAIL_CONTAINER_H
/* Container - message part container class
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
#include <List.h>
#include <MailComponent.h>
class BPositionIO;
class BMailContainer : public BMailComponent {
public:
BMailContainer (uint32 defaultCharSet = B_MAIL_NULL_CONVERSION) :
BMailComponent (defaultCharSet) {};
virtual status_t AddComponent(BMailComponent *component) = 0;
virtual status_t RemoveComponent(BMailComponent *component) = 0;
virtual status_t RemoveComponent(int32 index) = 0;
virtual BMailComponent *GetComponent(int32 index, bool parse_now = false) = 0;
virtual int32 CountComponents() const = 0;
private:
virtual void _ReservedContainer1();
virtual void _ReservedContainer2();
virtual void _ReservedContainer3();
virtual void _ReservedContainer4();
};
class BMIMEMultipartMailContainer : public BMailContainer {
public:
BMIMEMultipartMailContainer(
const char *boundary = NULL,
const char *this_is_an_MIME_message_text = NULL,
uint32 defaultCharSet = B_MAIL_NULL_CONVERSION);
BMIMEMultipartMailContainer(BMIMEMultipartMailContainer &copy);
virtual ~BMIMEMultipartMailContainer();
void SetBoundary(const char *boundary);
void SetThisIsAnMIMEMessageText(const char *text);
// MailContainer
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;
// MailComponent
virtual status_t GetDecodedData(BPositionIO *data);
virtual status_t SetDecodedData(BPositionIO *data);
virtual status_t SetToRFC822(BPositionIO *data, size_t length, bool parse_now = false);
virtual status_t RenderToRFC822(BPositionIO *render_to);
private:
virtual void _ReservedMultipart1();
virtual void _ReservedMultipart2();
virtual void _ReservedMultipart3();
const char *_boundary;
const char *_MIME_message_warning;
BPositionIO *_io_data;
BList _components_in_raw;
BList _components_in_code;
uint32 _reserved[5];
};
#endif /* ZOIDBERG_MAIL_CONTAINER_H */
+18
View File
@@ -0,0 +1,18 @@
#ifndef ZOIDBERG_MAIL_DAEMON_H
#define ZOIDBERG_MAIL_DAEMON_H
/* Daemon - talking to the mail daemon
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
class BMailDaemon {
public:
static status_t CheckMail(bool send_queued_mail = true,const char *account = NULL);
static status_t SendQueuedMail();
static int32 CountNewMessages(bool wait_for_fetch_completion = false);
static status_t Quit();
};
#endif /* ZOIDBERG_MAIL_DAEMON_H */
+112
View File
@@ -0,0 +1,112 @@
#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);
BEmailMessage(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);
void SendViaAccount(int32 chain_id);
int32 Account() const;
status_t GetAccountName(char *account,int32 maxLength) const;
status_t GetAccountName(BString *account) 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;
int32 _chain_id;
char *_bcc;
int32 _num_components;
BMailComponent *_body;
BTextMailComponent *_text_body;
uint32 _reserved[5];
};
#endif /* ZOIDBERG_MAIL_MESSAGE_H */
+153
View File
@@ -0,0 +1,153 @@
#ifndef ZOIDBERG_MAIL_SETTINGS_H
#define ZOIDBERG_MAIL_SETTINGS_H
/* Settings - the mail daemon's settings
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
#include <Archivable.h>
#include <List.h>
#include <Message.h>
class BPath;
typedef enum
{
B_MAIL_SHOW_STATUS_WINDOW_NEVER = 0,
B_MAIL_SHOW_STATUS_WINDOW_WHEN_SENDING = 1,
B_MAIL_SHOW_STATUS_WINDOW_WHEN_ACTIVE = 2,
B_MAIL_SHOW_STATUS_WINDOW_ALWAYS = 3
} b_mail_status_window_option;
typedef enum
{
B_MAIL_STATUS_LOOK_TITLED = 0,
B_MAIL_STATUS_LOOK_NORMAL_BORDER = 1,
B_MAIL_STATUS_LOOK_FLOATING = 2,
B_MAIL_STATUS_LOOK_THIN_BORDER = 3,
B_MAIL_STATUS_LOOK_NO_BORDER = 4
} b_mail_status_window_look;
typedef enum {
inbound,
outbound
} b_mail_chain_direction;
class BMailStatusWindow;
class BMailChain;
BMailChain* NewMailChain();
BMailChain* GetMailChain(uint32 id);
status_t GetOutboundMailChains(BList *list);
status_t GetInboundMailChains(BList *list);
class BMailChain : public BArchivable
{
public:
BMailChain(uint32 id);
BMailChain(BMessage*);
virtual ~BMailChain();
virtual status_t Archive(BMessage*,bool) const;
static BArchivable* Instantiate(BMessage*);
status_t Save(bigtime_t timeout = B_INFINITE_TIMEOUT);
status_t Delete() const;
status_t Reload();
status_t InitCheck() const;
uint32 ID() const;
b_mail_chain_direction ChainDirection() const;
void SetChainDirection(b_mail_chain_direction);
const char *Name() const;
status_t SetName(const char*);
BMessage *MetaData() const;
// "Filter" below refers to the settings message for a MailFilter
int32 CountFilters() const;
status_t GetFilter(int32 index, BMessage* out_settings, entry_ref *addon = NULL) const;
status_t SetFilter(int32 index, const BMessage&, const entry_ref&);
status_t AddFilter(const BMessage&, const entry_ref&); // at end
status_t AddFilter(int32 index, const BMessage&, const entry_ref&);
status_t RemoveFilter(int32 index);
void RunChain(BMailStatusWindow *window,
bool async = true,
bool save_when_done = true,
bool delete_when_done = false);
private:
status_t Path(BPath *path) const;
status_t Load(BMessage*);
int32 id;
char name[B_FILE_NAME_LENGTH];
BMessage *meta_data;
status_t _err;
b_mail_chain_direction direction;
int32 settings_ct, addons_ct;
BList filter_settings;
BList filter_addons;
uint32 _reserved[5];
};
class BMailSettings
{
public:
BMailSettings();
~BMailSettings();
status_t Save(bigtime_t timeout = B_INFINITE_TIMEOUT);
status_t Reload();
status_t InitCheck() const;
// Global settings
int32 WindowFollowsCorner();
void SetWindowFollowsCorner(int32 which_corner);
uint32 ShowStatusWindow();
void SetShowStatusWindow(uint32 mode);
bool DaemonAutoStarts();
void SetDaemonAutoStarts(bool does_it);
void SetConfigWindowFrame(BRect frame);
BRect ConfigWindowFrame();
void SetStatusWindowFrame(BRect frame);
BRect StatusWindowFrame();
int32 StatusWindowWorkspaces();
void SetStatusWindowWorkspaces(int32 workspaces);
int32 StatusWindowLook();
void SetStatusWindowLook(int32 look);
bigtime_t AutoCheckInterval();
void SetAutoCheckInterval(bigtime_t);
bool CheckOnlyIfPPPUp();
void SetCheckOnlyIfPPPUp(bool yes);
bool SendOnlyIfPPPUp();
void SetSendOnlyIfPPPUp(bool yes);
uint32 DefaultOutboundChainID();
void SetDefaultOutboundChainID(uint32 to);
private:
BMessage data;
uint32 _reserved[4];
};
#endif /* ZOIDBERG_MAIL_SETTINGS_H */
+59
View File
@@ -0,0 +1,59 @@
#ifndef ZOIDBERG_MAIL_ENCODING_H
#define ZOIDBERG_MAIL_ENCODING_H
/* mail encoding - mail de-/encoding functions (base64 and friends)
**
** Copyright 2001 Dr. Zoidberg Enterprises. All rights reserved.
*/
#include <size_t.h>
#include <sys/types.h>
#define B_MAIL_NULL_CONVERSION ((uint32) -1)
#define B_MAIL_UTF8_CONVERSION ((uint32) -2)
// For specifying the UTF-8 character set when converting to/from UTF-8.
#define B_MAIL_US_ASCII_CONVERSION ((uint32) -3)
// Plain 7 bit ASCII character set. A subset of UTF-8, but some mail software
// specifies it so we need to recognize it.
#define BASE64_LINELENGTH 76
typedef enum {
base64 = 'b',
quoted_printable = 'q',
seven_bit = '7',
eight_bit = '8',
uuencode = 'u', // Invalid to encode something using uuencode.
null_encoding = 0, // For not changing existing settings.
no_encoding = -1
} mail_encoding;
#ifdef __cplusplus
extern "C" {
#endif
ssize_t encode(mail_encoding encoding, char *out, const char *in,
off_t length, int headerMode);
// boolean headerMode only matters for quoted_printable and base64.
ssize_t decode(mail_encoding encoding, char *out, const char *in, off_t length,
int underscore_is_space);
// the value of underscore_is_space only matters for quoted_printable.
ssize_t max_encoded_length(mail_encoding encoding, off_t cur_length);
mail_encoding encoding_for_cte(const char *content_transfer_encoding);
ssize_t encode_base64(char *out, const char *in, off_t length, int headerMode);
ssize_t decode_base64(char *out, const char *in, off_t length);
ssize_t encode_qp(char *out, const char *in, off_t length, int headerMode);
ssize_t decode_qp(char *out, const char *in, off_t length, int underscore_is_space);
//---underscore_is_space should be 1 if and only if you are decoding a header field
ssize_t uu_decode(char *out, const char *in, off_t length);
#ifdef __cplusplus
}
#endif
#endif /* ZOIDBERG_MAIL_ENCODING_H */
+8
View File
@@ -0,0 +1,8 @@
SubDir OBOS_TOP src add-ons mail_daemon ;
SubInclude OBOS_TOP src add-ons mail_daemon inbound_protocols ;
SubInclude OBOS_TOP src add-ons mail_daemon inbound_filters ;
SubInclude OBOS_TOP src add-ons mail_daemon outbound_protocols ;
SubInclude OBOS_TOP src add-ons mail_daemon outbound_filters ;
SubInclude OBOS_TOP src add-ons mail_daemon system_filters ;
@@ -0,0 +1,5 @@
SubDir OBOS_TOP src add-ons mail_daemon inbound_filters ;
SubInclude OBOS_TOP src add-ons mail_daemon inbound_filters r5_filter ;
SubInclude OBOS_TOP src add-ons mail_daemon inbound_filters match_header ;
@@ -0,0 +1,5 @@
SubDir OBOS_TOP src add-ons mail_daemon inbound_protocols ;
SubInclude OBOS_TOP src add-ons mail_daemon inbound_protocols imap ;
SubInclude OBOS_TOP src add-ons mail_daemon inbound_protocols pop3 ;
@@ -0,0 +1,4 @@
SubDir OBOS_TOP src add-ons mail_daemon outbound_filters ;
SubInclude OBOS_TOP src add-ons mail_daemon outbound_filters fortune ;
@@ -0,0 +1,4 @@
SubDir OBOS_TOP src add-ons mail_daemon outbound_protocols ;
SubInclude OBOS_TOP src add-ons mail_daemon outbound_protocols smtp ;
@@ -0,0 +1,7 @@
SubDir OBOS_TOP src add-ons mail_daemon system_filters ;
SubInclude OBOS_TOP src add-ons mail_daemon system_filters inbox ;
SubInclude OBOS_TOP src add-ons mail_daemon system_filters notifier ;
SubInclude OBOS_TOP src add-ons mail_daemon system_filters outbox ;
SubInclude OBOS_TOP src add-ons mail_daemon system_filters parser ;