|
|
| version 1.26, 2001/05/04 10:42:36 | version 1.35, 2001/08/24 06:26:13 |
|---|---|
| Line 7 | Line 7 |
| $Id$ | $Id$ |
| */ | */ |
| static const char *RCSId="$Id$"; | |
| #include "pa_config_includes.h" | #include "pa_config_includes.h" |
| Line 119 static void uuencode(String& result, con | Line 120 static void uuencode(String& result, con |
| "end\n"; | "end\n"; |
| } | } |
| /// ^mail:send[$attach[$type[uue|mime64] $value[DATA]]] | /** ^mail:send[$attach[$type[uue|mime64] $value[DATA]]] |
| @todo solve - bad with html attaches | |
| */ | |
| static const String& attach_hash_to_string(Request& r, const String& origin_string, | static const String& attach_hash_to_string(Request& r, const String& origin_string, |
| Hash& attach_hash) { | Hash& attach_hash) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| Line 165 static const String& attach_hash_to_stri | Line 168 static const String& attach_hash_to_stri |
| } | } |
| static bool find_content_type(const Hash::Key& aattribute, Hash::Val *ameaning, | static void *find_content_type(const Hash::Key& aattribute, Hash::Val *ameaning, |
| void *) { | void *) { |
| return StrEqNc(aattribute.cstr(), CONTENT_TYPE_NAME); | return StrEqNc(aattribute.cstr(), CONTENT_TYPE_NAME)?ameaning:0; |
| } | } |
| static bool find_content_type_charset(const Hash::Key& aattribute, Hash::Val *ameaning, | static void *find_content_type_charset(const Hash::Key& aattribute, Hash::Val *ameaning, |
| void *) { | void *) { |
| return StrEqNc(aattribute.cstr(), "charset"); | return StrEqNc(aattribute.cstr(), "charset")?ameaning:0; |
| } | } |
| /// used by mail: _send / letter_hash_to_string / add_header_attribute | /// used by mail: _send / letter_hash_to_string / add_header_attribute |
| Line 206 static void add_header_attribute(const H | Line 209 static void add_header_attribute(const H |
| } | } |
| /// used in mail: _send / letter_hash_to_string / add_part | /// used in mail: _send / letter_hash_to_string / add_part |
| struct Seq_item { | struct Mail_seq_item { |
| const String *part_name; | const String *part_name; |
| Value *part_value; | Value *part_value; |
| }; | }; |
| static void add_part(const Hash::Key& part_name, Hash::Val *part_value, | static void add_part(const Hash::Key& part_name, Hash::Val *part_value, |
| void *info) { | void *info) { |
| Seq_item **seq_ref=static_cast<Seq_item **>(info); | Mail_seq_item **seq_ref=static_cast<Mail_seq_item **>(info); |
| (**seq_ref).part_name=&part_name; | (**seq_ref).part_name=&part_name; |
| (**seq_ref).part_value=static_cast<Value *>(part_value); | (**seq_ref).part_value=static_cast<Value *>(part_value); |
| (*seq_ref)++; | (*seq_ref)++; |
| } | } |
| static double key_of_part(const void *item) { | static double key_of_part(const void *item) { |
| const char *cstr=static_cast<const Seq_item *>(item)->part_name->cstr(); | const char *cstr=static_cast<const Mail_seq_item *>(item)->part_name->cstr(); |
| char *error_pos; | char *error_pos; |
| return strtod(cstr, &error_pos); | return strtod(cstr, &error_pos); |
| } | } |
| Line 275 static const String& letter_hash_to_stri | Line 278 static const String& letter_hash_to_stri |
| // body parts.. | // body parts.. |
| // ..collect | // ..collect |
| Seq_item *seq=(Seq_item *)malloc(sizeof(Seq_item)*body_hash->size()); | Mail_seq_item *seq=(Mail_seq_item *)pool.malloc(sizeof(Mail_seq_item)*body_hash->size()); |
| Seq_item *seq_ref=seq; body_hash->for_each(add_part, &seq_ref); | Mail_seq_item *seq_ref=seq; body_hash->for_each(add_part, &seq_ref); |
| // ..sort | // ..sort |
| _qsort(seq, body_hash->size(), sizeof(Seq_item), | _qsort(seq, body_hash->size(), sizeof(Mail_seq_item), |
| sort_cmp_string_double_value); | sort_cmp_string_double_value); |
| // ..insert in 'seq' order | // ..insert in 'seq' order |
| for(int i=0; i<body_hash->size(); i++) { | for(int i=0; i<body_hash->size(); i++) { |
| Line 332 static void sendmail(Request& r, const S | Line 335 static void sendmail(Request& r, const S |
| SMTP& smtp=*new(pool) SMTP(pool, method_name); | SMTP& smtp=*new(pool) SMTP(pool, method_name); |
| Value *server_port; | Value *server_port; |
| // $MAIN:MAIL.SMTP[mail.design.ru] | // $MAIN:MAIL.SMTP[mail.yourdomain.ru[:port]] |
| if(mail_conf && | if(mail_conf && |
| (server_port=static_cast<Value *>(mail_conf->get( | (server_port=static_cast<Value *>(mail_conf->get( |
| *new(pool) String(pool, "SMTP"))))) { | *new(pool) String(pool, "SMTP"))))) { |
| Line 417 static void sendmail(Request& r, const S | Line 420 static void sendmail(Request& r, const S |
| static void _send(Request& r, const String& method_name, MethodParams *params) { | static void _send(Request& r, const String& method_name, MethodParams *params) { |
| Pool& pool=r.pool(); | Pool& pool=r.pool(); |
| Value& vhash=params->get_no_junction(0, "message must not be code"); | Value& vhash=params->as_no_junction(0, "message must not be code"); |
| Hash *hash=vhash.get_hash(); | Hash *hash=vhash.get_hash(); |
| if(!hash) | if(!hash) |
| PTHROW(0, 0, | PTHROW(0, 0, |
| Line 440 MMail::MMail(Pool& apool) : Methoded(apo | Line 443 MMail::MMail(Pool& apool) : Methoded(apo |
| { | { |
| set_name(*NEW String(pool(), MAIL_CLASS_NAME)); | set_name(*NEW String(pool(), MAIL_CLASS_NAME)); |
| /// ^mail:send{hash} | // ^mail:send{hash} |
| add_native_method("send", Method::CT_STATIC, _send, 1, 1); | add_native_method("send", Method::CT_STATIC, _send, 1, 1); |
| } | } |