Start of BMailMessage support by Eric
This commit is contained in:
277
bepascal/bepascal/be/mail/E-mail.cpp
Normal file
277
bepascal/bepascal/be/mail/E-mail.cpp
Normal file
@@ -0,0 +1,277 @@
|
||||
/* BePascal - A pascal wrapper around the BeOS API
|
||||
Copyright (C) 2002 Eric Jourde
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef _MAIL_CPP_
|
||||
#define _MAIL_CPP_
|
||||
|
||||
#include "E-mail.h"
|
||||
#include <beobj.h>
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::BMailMessage()
|
||||
* Descr:
|
||||
*/
|
||||
TCPlusObject BMailMessage_Create()
|
||||
{
|
||||
return new BMailMessage();
|
||||
}
|
||||
|
||||
void BMail_Free(BMailMessage *Mail)
|
||||
{
|
||||
delete Mail;
|
||||
}
|
||||
/*
|
||||
* Method: BMailMessage::AddContent()
|
||||
* Descr:
|
||||
*/
|
||||
status_t
|
||||
BMailMessage_AddContent(BMailMessage *MailMessage, const char *text,
|
||||
int32 length,
|
||||
uint32 encoding,
|
||||
bool clobber)
|
||||
{
|
||||
return MailMessage->AddContent(text,
|
||||
length,
|
||||
encoding,
|
||||
clobber);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::AddContent()
|
||||
* Descr:
|
||||
*/
|
||||
status_t
|
||||
BMailMessage_AddContent_1
|
||||
(BMailMessage *MailMessage, const char *text,
|
||||
int32 length,
|
||||
const char *encoding,
|
||||
bool clobber)
|
||||
{
|
||||
return MailMessage->AddContent(text,
|
||||
length,
|
||||
encoding,
|
||||
clobber);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::AddEnclosure()
|
||||
* Descr:
|
||||
*/
|
||||
status_t
|
||||
BMailMessage_AddEnclosure(BMailMessage *MailMessage, entry_ref *ref,
|
||||
bool clobber)
|
||||
{
|
||||
return MailMessage->AddEnclosure(ref,
|
||||
clobber);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::AddEnclosure()
|
||||
* Descr:
|
||||
*/
|
||||
status_t
|
||||
BMailMessage_AddEnclosure_1
|
||||
(BMailMessage *MailMessage, const char *path,
|
||||
bool clobber)
|
||||
{
|
||||
return MailMessage->AddEnclosure(path,
|
||||
clobber);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::AddEnclosure()
|
||||
* Descr:
|
||||
*/
|
||||
status_t
|
||||
BMailMessage_AddEnclosure_2
|
||||
(BMailMessage *MailMessage, const char *MIME_type,
|
||||
void *data,
|
||||
int32 len,
|
||||
bool clobber)
|
||||
{
|
||||
return MailMessage->AddEnclosure(MIME_type,
|
||||
data,
|
||||
len,
|
||||
clobber);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::AddHeaderField()
|
||||
* Descr:
|
||||
*/
|
||||
status_t
|
||||
BMailMessage_AddHeaderField(BMailMessage *MailMessage, uint32 encoding,
|
||||
const char *field_name,
|
||||
const char *str,
|
||||
bool clobber)
|
||||
{
|
||||
return MailMessage->AddHeaderField(encoding,
|
||||
field_name,
|
||||
str,
|
||||
clobber);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::AddHeaderField()
|
||||
* Descr:
|
||||
*/
|
||||
status_t
|
||||
BMailMessage_AddHeaderField_1
|
||||
(BMailMessage *MailMessage, const char *field_name,
|
||||
const char *str,
|
||||
bool clobber)
|
||||
{
|
||||
return MailMessage->AddHeaderField(field_name,
|
||||
str,
|
||||
clobber);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::Send()
|
||||
* Descr:
|
||||
*/
|
||||
status_t
|
||||
BMailMessage_Send(BMailMessage *MailMessage, bool send_now,
|
||||
bool remove_when_I_have_completed_sending_this_message_to_your_preferred_SMTP_server)
|
||||
{
|
||||
return MailMessage->Send(send_now,
|
||||
remove_when_I_have_completed_sending_this_message_to_your_preferred_SMTP_server);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::concatinate()
|
||||
* Descr:
|
||||
*/
|
||||
/*int32
|
||||
BMailMessage_concatinate(BMailMessage *MailMessage, char **,
|
||||
int32,
|
||||
char *)
|
||||
{
|
||||
return MailMessage->concatinate(,
|
||||
,
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::count_fields()
|
||||
* Descr:
|
||||
*/
|
||||
/*int32
|
||||
BMailMessage_count_fields(BMailMessage *MailMessage, char *name)
|
||||
{
|
||||
return MailMessage->count_fields(name);
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
* Method: BMailMessage::find_field()
|
||||
* Descr:
|
||||
*/
|
||||
/*status_t
|
||||
BMailMessage_find_field(BMailMessage *MailMessage, char *,
|
||||
type_code *,
|
||||
char **,
|
||||
void **,
|
||||
int32 *,
|
||||
uint32 *,
|
||||
char **,
|
||||
bool *,
|
||||
int32)
|
||||
{
|
||||
return MailMessage->find_field(,
|
||||
,
|
||||
,
|
||||
,
|
||||
,
|
||||
,
|
||||
,
|
||||
,
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::find_field()
|
||||
* Descr:
|
||||
*/
|
||||
/*BList *
|
||||
BMailMessage_find_field_1
|
||||
(BMailMessage *MailMessage, const char *)
|
||||
{
|
||||
return MailMessage->find_field();
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::get_field_name()
|
||||
* Descr:
|
||||
*/
|
||||
/*status_t
|
||||
BMailMessage_get_field_name(BMailMessage *MailMessage, char **,
|
||||
int32)
|
||||
{
|
||||
return MailMessage->get_field_name(,
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Method: BMailMessage::set_field()
|
||||
* Descr:
|
||||
*/
|
||||
/*status_t
|
||||
BMailMessage_set_field(BMailMessage *MailMessage, const char *,
|
||||
type_code,
|
||||
const char *,
|
||||
const void *,
|
||||
int32,
|
||||
uint32,
|
||||
const char *,
|
||||
bool)
|
||||
{
|
||||
return MailMessage->set_field(,
|
||||
,
|
||||
,
|
||||
,
|
||||
,
|
||||
,
|
||||
,
|
||||
);
|
||||
}
|
||||
*/
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _MAIL_CPP_ */
|
||||
|
||||
|
||||
125
bepascal/bepascal/be/mail/Email.pp
Normal file
125
bepascal/bepascal/be/mail/Email.pp
Normal file
@@ -0,0 +1,125 @@
|
||||
{ BePascal - A pascal wrapper around the BeOS API
|
||||
Copyright (C) 2002 Eric Jourde
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
}
|
||||
|
||||
unit Email;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
beobj, SupportDefs, os,utf8;
|
||||
|
||||
// null because begin at 1 form e-mail.h
|
||||
type mail_flags =(B_Mail_null,B_MAIL_PENDING,B_MAIL_SENT,B_MAIL_SAVE);
|
||||
|
||||
Const
|
||||
B_MAIL_ATTR_NAME='MAIL:name';
|
||||
B_MAIL_ATTR_STATUS='MAIL:status';
|
||||
B_MAIL_ATTR_PRIORITY='MAIL:priority';
|
||||
B_MAIL_ATTR_TO='MAIL:to';
|
||||
B_MAIL_ATTR_CC='MAIL:cc';
|
||||
B_MAIL_ATTR_FROM='MAIL:from';
|
||||
B_MAIL_ATTR_SUBJECT='MAIL:subject';
|
||||
B_MAIL_ATTR_REPLY='MAIL:reply';
|
||||
B_MAIL_ATTR_WHEN='MAIL:when';
|
||||
B_MAIL_ATTR_FLAGS='MAIL:flags';
|
||||
B_MAIL_ATTR_RECIPIENTS='MAIL:recipients';
|
||||
B_MAIL_ATTR_MIME='MAIL:mime';
|
||||
B_MAIL_ATTR_HEADER='MAIL:header_length';
|
||||
B_MAIL_ATTR_CONTENT='MAIL:content_length';
|
||||
|
||||
|
||||
type TEMail = class(TbeObject)
|
||||
private
|
||||
public
|
||||
constructor Create; override;
|
||||
destructor Destroy; override;
|
||||
|
||||
function Add_Content(text : PChar;length: cardinal;encoding : TCharSet; clobber : boolean) : TStatus_t;
|
||||
function Add_Content(text : PChar;length: cardinal;encoding : Pchar; clobber : boolean) : TStatus_t;
|
||||
function AddEnclosure( path : Pchar; clobber:boolean) : TStatus_t;
|
||||
function AddEnclosure(MIME_type : Pchar;data : pointer;len : cardinal; clobber:boolean) : TStatus_t;
|
||||
function AddHeaderField( encoding: TCharSet; field_name : Pchar; str : PChar;clobber:boolean) : TStatus_t;
|
||||
function AddHeaderField( field_name : Pchar; str : PChar;clobber:boolean) : TStatus_t;
|
||||
function Send( send_now : boolean; remove_when_I_have_completed_sending_this_message_to_your_preferred_SMTP_server : boolean) : TStatus_t;
|
||||
end;
|
||||
|
||||
function BMailMessage_Create() : TCPlusObject;cdecl; external BePascalLibName name 'BMailMessage_Create';
|
||||
procedure BMail_Free(AObject : TCPlusObject);cdecl; external BePascalLibName name 'BMail_Free';
|
||||
function BMailMessage_AddContent(AObject : TCPlusObject;text : PChar;length: cardinal;encoding : cardinal; clobber : boolean) : TStatus_t;cdecl; external BePascalLibName name 'BMailMessage_AddContent';
|
||||
function BMailMessage_AddContent_1(AObject : TCPlusObject;text : PChar;length: cardinal;encoding : Pchar; clobber : boolean) : TStatus_t;cdecl; external BePascalLibName name 'BMailMessage_AddContent_1';
|
||||
//function BMailMessage_AddEnclosure(AObject : TCPlusObject; entry_ref *ref, bool clobber) : TStatus_t;cdecl; external BePascalLibName name 'BMailMessage_AddEnclosure';
|
||||
function BMailMessage_AddEnclosure_1(AObject : TCPlusObject; path : Pchar; clobber:boolean) : TStatus_t;cdecl; external BePascalLibName name 'BMailMessage_AddEnclosure_1';
|
||||
function BMailMessage_AddEnclosure_2(AObject : TCPlusObject; MIME_type : Pchar;data : pointer;len : cardinal; clobber:boolean) : TStatus_t;cdecl; external BePascalLibName name 'BMailMessage_AddEnclosure_2';
|
||||
function BMailMessage_AddHeaderField(AObject : TCPlusObject; encoding: cardinal; field_name : Pchar; str : PChar;clobber:boolean) : TStatus_t;cdecl; external BePascalLibName name 'BMailMessage_AddHeaderField';
|
||||
function BMailMessage_AddHeaderField_1(AObject : TCPlusObject; field_name : Pchar; str : PChar;clobber:boolean) : TStatus_t;cdecl; external BePascalLibName name 'BMailMessage_AddHeaderField_1';
|
||||
function BMailMessage_Send(AObject : TCPlusObject; send_now : boolean; remove_when_I_have_completed_sending_this_message_to_your_preferred_SMTP_server : boolean) : TStatus_t;cdecl; external BePascalLibName name 'BMailMessage_Send';
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
constructor TEmail.Create;
|
||||
begin
|
||||
inherited;
|
||||
CPlusObject := BMailMessage_Create();
|
||||
end;
|
||||
|
||||
destructor TEmail.Destroy;
|
||||
begin
|
||||
if CPlusObject <> nil then
|
||||
BMail_Free(CPlusObject);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TEmail.Add_Content(text : PChar;length: cardinal;encoding : TCharSet; clobber : boolean) : TStatus_t;
|
||||
begin
|
||||
result:=BMailMessage_AddContent(CPlusObject,text,length,cardinal(encoding),clobber );
|
||||
end;
|
||||
|
||||
function TEmail.Add_Content(text : PChar;length: cardinal;encoding : Pchar; clobber : boolean) : TStatus_t;
|
||||
begin
|
||||
result:=BMailMessage_AddContent_1(CPlusObject,text,length,encoding,clobber );
|
||||
end;
|
||||
|
||||
function TEmail.AddEnclosure( path : Pchar; clobber:boolean) : TStatus_t;
|
||||
begin
|
||||
result:=BMailMessage_AddEnclosure_1(CPlusObject,path,clobber);
|
||||
end;
|
||||
|
||||
function TEmail.AddEnclosure(MIME_type : Pchar;data : pointer;len : cardinal; clobber:boolean) : TStatus_t;
|
||||
begin
|
||||
result:=BMailMessage_AddEnclosure_2(CPlusObject,MIME_type,data,len,clobber);
|
||||
end;
|
||||
|
||||
function TEmail.AddHeaderField( encoding: TCharSet; field_name : Pchar; str : PChar;clobber:boolean) : TStatus_t;
|
||||
begin
|
||||
result:=BMailMessage_AddHeaderField(CPlusObject, cardinal(encoding), field_name , str,clobber);
|
||||
end;
|
||||
|
||||
function TEmail.AddHeaderField( field_name : Pchar; str : PChar;clobber:boolean) : TStatus_t;
|
||||
begin
|
||||
result:=BMailMessage_AddHeaderField_1(CPlusObject, field_name, str,clobber) ;
|
||||
end;
|
||||
|
||||
function TEmail.Send( send_now : boolean; remove_when_I_have_completed_sending_this_message_to_your_preferred_SMTP_server : boolean) : TStatus_t;
|
||||
begin
|
||||
result:=BMailMessage_Send(CPlusObject, send_now, remove_when_I_have_completed_sending_this_message_to_your_preferred_SMTP_server );
|
||||
end;
|
||||
|
||||
|
||||
|
||||
end.
|
||||
Reference in New Issue
Block a user