--- parser3/src/classes/mail.C 2001/04/23 08:52:15 1.20 +++ parser3/src/classes/mail.C 2001/04/28 08:43:47 1.23 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: mail.C,v 1.20 2001/04/23 08:52:15 paf Exp $ + $Id: mail.C,v 1.23 2001/04/28 08:43:47 paf Exp $ */ #include "pa_config_includes.h" @@ -14,15 +14,22 @@ # include "smtp/smtp.h" #endif -#include "_mail.h" #include "pa_common.h" #include "pa_request.h" #include "pa_vfile.h" #include "pa_exec.h" -// global var +// defines -VStateless_class *mail_class; +#define MAIL_CLASS_NAME "mail" + +// class + +class MMail : public Methoded { +public: + MMail(Pool& pool); + bool used_directly() { return true; } +}; // helpers @@ -96,7 +103,7 @@ static void uuencode(String& result, con } //footer - result.APPEND_CLEAN((const char *)uue_table, 1/* one char */, 0, 0) << "\n" + result.APPEND_AS_IS((const char *)uue_table, 1/* one char */, 0, 0) << "\n" "end\n"; } @@ -155,6 +162,7 @@ static bool find_content_type_charset(co return StrEqNc(aattribute.cstr(), "charset"); } +/// used by mail: _send / letter_hash_to_string / add_header_attribute struct Mail_info { String *attribute_to_exclude; const char *charset; @@ -184,6 +192,8 @@ static void add_header_attribute(const H cstr(String::UL_UNSPECIFIED, 0, mi.charset) << "\n"; } + +/// used in mail: _send / letter_hash_to_string / add_part struct Seq_item { const String *part_name; Value *part_value; @@ -233,10 +243,6 @@ static const String& letter_hash_to_stri static_cast(hash->first_that(find_content_type_charset))) charset=content_type_charset->as_string().cstr(); -// if(Hash *hash=ameaning)->get_hash())) -// if(VString *vcharset=hash->get_string(String(pool, "charset - - *from=*to=0; Mail_info mail_info={ /*excluding*/ body_name, @@ -395,6 +401,7 @@ static void sendmail(Request& r, const S // methods +/// ^mail:send{hash} static void _send(Request& r, const String& method_name, MethodParams *params) { Pool& pool=r.pool(); @@ -408,12 +415,25 @@ static void _send(Request& r, const Stri const String *from, *to; const String& letter=letter_hash_to_string(r, method_name, *hash, 0, &from, &to); - r.write_assign_lang(*new(pool) VString(letter)); - //sendmail(r, method_name, letter, from, to); +// r.write_assign_lang(*new(pool) VString(letter)); + sendmail(r, method_name, letter, from, to); } -// initialize -void initialize_mail_class(Pool& pool, VStateless_class& vclass) { - // ^mail:send{hash} - vclass.add_native_method("send", Method::CT_STATIC, _send, 1, 1); +// constructor + +MMail::MMail(Pool& apool) : Methoded(apool) { + set_name(*NEW String(pool(), MAIL_CLASS_NAME)); + + /// ^mail:send{hash} + add_native_method("send", Method::CT_STATIC, _send, 1, 1); +} + +// global variable + +Methoded *mail_class; + +// creator + +Methoded *MMail_create(Pool& pool) { + return mail_class=new(pool) MMail(pool); }