Rewrote header.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32749 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
+69
-68
@@ -1,67 +1,66 @@
|
|||||||
/*******************************************************************************
|
/*
|
||||||
/
|
* Copyright 2009, Haiku, Inc. All rights reserved.
|
||||||
/ File: E-mail.h
|
* Distributed under the terms of the MIT License.
|
||||||
/
|
*/
|
||||||
/ Description: Mail attributes and BMailMessage class.
|
|
||||||
/
|
|
||||||
/ Copyright 1993-98, Be Incorporated, All Rights Reserved.
|
|
||||||
/
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef _E_MAIL_H
|
#ifndef _E_MAIL_H
|
||||||
#define _E_MAIL_H
|
#define _E_MAIL_H
|
||||||
|
|
||||||
|
|
||||||
#include <UTF8.h>
|
#include <UTF8.h>
|
||||||
|
|
||||||
|
|
||||||
class BList;
|
class BList;
|
||||||
struct entry_ref;
|
struct entry_ref;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------*/
|
|
||||||
/* 'E-Mail' attributes...*/
|
|
||||||
|
|
||||||
#define B_MAIL_ATTR_NAME "MAIL:name" /* indexed string*/
|
// E-Mail attributes
|
||||||
#define B_MAIL_ATTR_STATUS "MAIL:status" /* indexed string*/
|
#define B_MAIL_ATTR_NAME "MAIL:name" // indexed string
|
||||||
#define B_MAIL_ATTR_PRIORITY "MAIL:priority" /* indexed string*/
|
#define B_MAIL_ATTR_STATUS "MAIL:status" // indexed string
|
||||||
#define B_MAIL_ATTR_TO "MAIL:to" /* indexed string*/
|
#define B_MAIL_ATTR_PRIORITY "MAIL:priority" // indexed string
|
||||||
#define B_MAIL_ATTR_CC "MAIL:cc" /* indexed string*/
|
#define B_MAIL_ATTR_TO "MAIL:to" // indexed string
|
||||||
#define B_MAIL_ATTR_FROM "MAIL:from" /* indexed string*/
|
#define B_MAIL_ATTR_CC "MAIL:cc" // indexed string
|
||||||
#define B_MAIL_ATTR_SUBJECT "MAIL:subject" /* indexed string*/
|
#define B_MAIL_ATTR_FROM "MAIL:from" // indexed string
|
||||||
#define B_MAIL_ATTR_REPLY "MAIL:reply" /* indexed string*/
|
#define B_MAIL_ATTR_SUBJECT "MAIL:subject" // indexed string
|
||||||
#define B_MAIL_ATTR_WHEN "MAIL:when" /* indexed time*/
|
#define B_MAIL_ATTR_REPLY "MAIL:reply" // indexed string
|
||||||
#define B_MAIL_ATTR_FLAGS "MAIL:flags" /* indexed int32*/
|
#define B_MAIL_ATTR_WHEN "MAIL:when" // indexed time
|
||||||
#define B_MAIL_ATTR_RECIPIENTS "MAIL:recipients" /* string*/
|
#define B_MAIL_ATTR_FLAGS "MAIL:flags" // indexed int32
|
||||||
#define B_MAIL_ATTR_MIME "MAIL:mime" /* string*/
|
#define B_MAIL_ATTR_RECIPIENTS "MAIL:recipients" // string
|
||||||
#define B_MAIL_ATTR_HEADER "MAIL:header_length" /* int32*/
|
#define B_MAIL_ATTR_MIME "MAIL:mime" // string
|
||||||
#define B_MAIL_ATTR_CONTENT "MAIL:content_length" /* int32*/
|
#define B_MAIL_ATTR_HEADER "MAIL:header_length" // int32
|
||||||
|
#define B_MAIL_ATTR_CONTENT "MAIL:content_length" // int32
|
||||||
|
|
||||||
|
|
||||||
/* mail flags */
|
// mail flags
|
||||||
enum mail_flags {B_MAIL_PENDING = 1, /* waiting to be sent*/
|
enum mail_flags {
|
||||||
B_MAIL_SENT = 2, /* has been sent*/
|
B_MAIL_PENDING = 1, // waiting to be sent
|
||||||
B_MAIL_SAVE = 4}; /* save mail after sending*/
|
|
||||||
|
|
||||||
#define B_MAIL_TYPE "text/x-email" /* mime type*/
|
B_MAIL_SENT = 2, // has been sent
|
||||||
|
|
||||||
/* Everything past this point is deprecated. See MailMessage.h, mail_encoding.h
|
B_MAIL_SAVE = 4 // save mail after
|
||||||
and MailDaemon.h for alternatives. */
|
// sending
|
||||||
|
};
|
||||||
|
|
||||||
/* DEPRECATED -- DEPRECATED -- DEPRECATED -- DEPRECATED -- DEPRECATED */
|
#define B_MAIL_TYPE "text/x-email" // mime type
|
||||||
/* DEPRECATED -- DEPRECATED -- DEPRECATED -- DEPRECATED -- DEPRECATED */
|
|
||||||
|
|
||||||
/* defines...*/
|
|
||||||
|
|
||||||
/* schedule days */
|
// WARNING: Everything past this point is deprecated. See MailMessage.h,
|
||||||
|
// mail_encoding.h and MailDaemon.h for alternatives.
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - defines
|
||||||
|
|
||||||
|
// schedule days
|
||||||
#define B_CHECK_NEVER 0
|
#define B_CHECK_NEVER 0
|
||||||
#define B_CHECK_WEEKDAYS 1
|
#define B_CHECK_WEEKDAYS 1
|
||||||
#define B_CHECK_DAILY 2
|
#define B_CHECK_DAILY 2
|
||||||
#define B_CHECK_CONTINUOUSLY 3
|
#define B_CHECK_CONTINUOUSLY 3
|
||||||
#define B_CHECK_CONTINUOSLY 3
|
#define B_CHECK_CONTINUOSLY 3
|
||||||
|
|
||||||
/* max. lengths */
|
// max. lengths
|
||||||
#define B_MAX_USER_NAME_LENGTH 32
|
#define B_MAX_USER_NAME_LENGTH 32
|
||||||
#define B_MAX_HOST_NAME_LENGTH 64
|
#define B_MAX_HOST_NAME_LENGTH 64
|
||||||
|
|
||||||
/* rfc822 header field types */
|
// rfc822 header field types
|
||||||
#define B_MAIL_TO "To: "
|
#define B_MAIL_TO "To: "
|
||||||
#define B_MAIL_CC "Cc: "
|
#define B_MAIL_CC "Cc: "
|
||||||
#define B_MAIL_BCC "Bcc: "
|
#define B_MAIL_BCC "Bcc: "
|
||||||
@@ -72,8 +71,8 @@ enum mail_flags {B_MAIL_PENDING = 1, /* waiting to be sent*/
|
|||||||
#define B_MAIL_PRIORITY "Priority: "
|
#define B_MAIL_PRIORITY "Priority: "
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------*/
|
// #pragma mark - structs
|
||||||
/* structs...*/
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char pop_name[B_MAX_USER_NAME_LENGTH];
|
char pop_name[B_MAX_USER_NAME_LENGTH];
|
||||||
@@ -92,8 +91,9 @@ typedef struct {
|
|||||||
bool beep;
|
bool beep;
|
||||||
} mail_notification;
|
} mail_notification;
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------*/
|
|
||||||
/* global functions...*/
|
// #pragma mark - global functions
|
||||||
|
|
||||||
|
|
||||||
int32 count_pop_accounts(void);
|
int32 count_pop_accounts(void);
|
||||||
status_t get_pop_account(mail_pop_account*, int32 index = 0);
|
status_t get_pop_account(mail_pop_account*, int32 index = 0);
|
||||||
@@ -113,49 +113,50 @@ ssize_t decode_base64(char *out, char *in, off_t length,
|
|||||||
ssize_t encode_base64(char* out, char* in, off_t length);
|
ssize_t encode_base64(char* out, char* in, off_t length);
|
||||||
|
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------*/
|
// #pragma mark - BMailMessage
|
||||||
/* class...*/
|
|
||||||
|
|
||||||
class BMailMessage {
|
class BMailMessage {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BMailMessage(void);
|
BMailMessage();
|
||||||
~BMailMessage(void);
|
~BMailMessage();
|
||||||
|
|
||||||
status_t AddContent(const char* text, int32 length,
|
status_t AddContent(const char* text, int32 length,
|
||||||
uint32 encoding = B_ISO1_CONVERSION,
|
uint32 encoding = B_ISO1_CONVERSION,
|
||||||
bool clobber = false);
|
bool clobber = false);
|
||||||
status_t AddContent(const char* text, int32 length,
|
status_t AddContent(const char* text, int32 length,
|
||||||
const char *encoding, bool clobber = false);
|
const char* encoding,
|
||||||
|
|
||||||
status_t AddEnclosure(entry_ref *ref, bool clobber = false);
|
|
||||||
status_t AddEnclosure(const char *path, bool clobber = false);
|
|
||||||
status_t AddEnclosure(const char *MIME_type, void *data, int32 len,
|
|
||||||
bool clobber = false);
|
bool clobber = false);
|
||||||
|
|
||||||
status_t AddHeaderField(uint32 encoding, const char *field_name, const char *str,
|
status_t AddEnclosure(entry_ref* ref,
|
||||||
bool clobber = false);
|
bool clobber = false);
|
||||||
status_t AddHeaderField(const char *field_name, const char *str,
|
status_t AddEnclosure(const char* path,
|
||||||
bool clobber = false);
|
bool clobber = false);
|
||||||
|
status_t AddEnclosure(const char* MIME_type, void* data,
|
||||||
|
int32 len, bool clobber = false);
|
||||||
|
|
||||||
status_t Send(bool send_now = false,
|
status_t AddHeaderField(uint32 encoding,
|
||||||
bool remove_when_I_have_completed_sending_this_message_to_your_preferred_SMTP_server = false);
|
const char* field_name, const char* str,
|
||||||
|
bool clobber = false);
|
||||||
|
status_t AddHeaderField(const char* field_name,
|
||||||
|
const char* str, bool clobber = false);
|
||||||
|
|
||||||
|
status_t Send(bool sendNow = false,
|
||||||
|
bool removeAfterSending = false);
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------*/
|
private:
|
||||||
|
int32 concatinate(char**, int32, char*);
|
||||||
|
int32 count_fields(char* name = NULL);
|
||||||
|
status_t find_field(char*, type_code*, char**, void**,
|
||||||
|
int32*, uint32*, char**, bool*, int32);
|
||||||
|
BList* find_field(const char*);
|
||||||
|
status_t get_field_name(char**, int32);
|
||||||
|
status_t set_field(const char*, type_code, const char*,
|
||||||
|
const void*, int32, uint32, const char*,
|
||||||
|
bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BList* fFields;
|
BList* fFields;
|
||||||
bool fMultiPart;
|
bool fMultiPart;
|
||||||
|
|
||||||
int32 concatinate(char**, int32, char*);
|
|
||||||
int32 count_fields(char *name = NULL);
|
|
||||||
status_t find_field(char*, type_code*, char**, void**, int32*,
|
|
||||||
uint32*, char**, bool*, int32);
|
|
||||||
BList* find_field(const char*);
|
|
||||||
status_t get_field_name(char**, int32);
|
|
||||||
status_t set_field(const char*, type_code, const char*, const void*,
|
|
||||||
int32, uint32, const char*, bool);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _MAIL_H */
|
#endif // _MAIL_H
|
||||||
|
|||||||
Reference in New Issue
Block a user