--- parser3/src/classes/mail.C 2001/04/26 14:55:12 1.22 +++ parser3/src/classes/mail.C 2001/04/28 10:58:26 1.24 @@ -5,7 +5,7 @@ Author: Alexander Petrosyan (http://design.ru/paf) - $Id: mail.C,v 1.22 2001/04/26 14:55:12 paf Exp $ + $Id: mail.C,v 1.24 2001/04/28 10:58:26 paf Exp $ */ #include "pa_config_includes.h" @@ -14,15 +14,24 @@ # 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); +public: // Methoded + bool used_directly() { return true; } + void configure_user(Request& r); +}; // helpers @@ -387,7 +396,7 @@ static void sendmail(Request& r, const S } else PTHROW(0, 0, &method_name, - "$"MAIN_CLASS_NAME":"MAIL_NAME" not defined"); + "$" MAIN_CLASS_NAME ":" MAIL_NAME " not defined"); #endif } @@ -412,8 +421,32 @@ static void _send(Request& r, const Stri sendmail(r, method_name, letter, from, to); } -// initialize -void initialize_mail_class(Pool& pool, VStateless_class& vclass) { +// constructor & configurator + +MMail::MMail(Pool& apool) : Methoded(apool) { + set_name(*NEW String(pool(), MAIL_CLASS_NAME)); + /// ^mail:send{hash} - vclass.add_native_method("send", Method::CT_STATIC, _send, 1, 1); + add_native_method("send", Method::CT_STATIC, _send, 1, 1); +} + +void MMail::configure_user(Request& r) { + Pool& pool=r.pool(); + + // $MAIN:MAIL[$SMTP[mail.design.ru]] + if(Value *mail_element=r.main_class->get_element(*mail_name)) + if(!(r.mail=mail_element->get_hash())) + PTHROW(0, 0, + 0, + "$" MAIL_CLASS_NAME ":" MAIL_NAME " is not hash"); +} + +// global variable + +Methoded *mail_class; + +// creator + +Methoded *MMail_create(Pool& pool) { + return mail_class=new(pool) MMail(pool); }