--- parser3/src/classes/mail.C 2002/03/27 15:30:34 1.60 +++ parser3/src/classes/mail.C 2002/06/12 12:50:32 1.65 @@ -4,7 +4,7 @@ Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) - $Id: mail.C,v 1.60 2002/03/27 15:30:34 paf Exp $ + $Id: mail.C,v 1.65 2002/06/12 12:50:32 paf Exp $ */ #include "pa_config_includes.h" @@ -44,8 +44,6 @@ public: // Methoded void configure_user(Request& r); private: String mail_name; - String content_disposition_name; - String content_disposition_filename_name; }; // helpers @@ -152,7 +150,8 @@ static const String& attach_hash_to_stri String& result=*new(pool) String(pool); // content-type: application/octet-stream - result << "content-type: " << r.mime_type_of(file_name_cstr) << "\n"; + result << "content-type: " << r.mime_type_of(file_name_cstr) + << "; name=\"" << file_name_cstr << "\"\n"; // content-disposition: attachment; filename="user_file_name" result << "content-disposition: attachment; filename=\"" << file_name_cstr << "\"\n"; @@ -170,7 +169,7 @@ static const String& attach_hash_to_stri #ifndef DOXYGEN struct Mail_info { - Charset *charset; + Charset *charset; const char *content_charset_name; String *header; const String **from, **to; }; @@ -196,7 +195,7 @@ static void add_header_attribute(const H *mi.header << aattribute << ":" << attributed_meaning_to_string(lmeaning, String::UL_MAIL_HEADER). - cstr(String::UL_UNSPECIFIED, 0, mi.charset) << + cstr(String::UL_UNSPECIFIED, 0, mi.charset, mi.content_charset_name) << "\n"; } @@ -246,17 +245,23 @@ static const String& letter_hash_to_stri String& result=*new(pool) String(pool); Charset *charset; - if(Value *vcharset_name=static_cast(letter_hash.get(*charset_name))) - charset=&charsets->get_charset(vcharset_name->as_string()); + if(Value *vrecodecharset_name=static_cast(letter_hash.get(*charset_name))) + charset=&charsets->get_charset(vrecodecharset_name->as_string()); else charset=&pool.get_source_charset(); + const char *content_charset_name=0; + if(Value *vcontent_type=static_cast(letter_hash.get(*content_type_name))) + if(Hash *hcontent_type=vcontent_type->get_hash(0)) + if(Value *vcontentcharset_name=static_cast(hcontent_type->get(*charset_name))) + content_charset_name=vcontentcharset_name->as_string().cstr(); + if(from) *from=0; if(to) *to=0; Mail_info mail_info={ - charset, + charset, content_charset_name, &result, from, to }; @@ -453,19 +458,14 @@ 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); } // constructor & configurator -MMail::MMail(Pool& apool) : Methoded(apool), - mail_name(apool, MAIL_NAME), - content_disposition_name(apool, CONTENT_DISPOSITION_NAME), - content_disposition_filename_name(apool, CONTENT_DISPOSITION_FILENAME_NAME) +MMail::MMail(Pool& apool) : Methoded(apool, MAIL_CLASS_NAME), + mail_name(apool, MAIL_NAME) { - set_name(*NEW String(pool(), MAIL_CLASS_NAME)); - // ^mail:send{hash} add_native_method("send", Method::CT_STATIC, _send, 1, 1); } @@ -477,10 +477,10 @@ void MMail::configure_user(Request& r) { if(Value *mail_element=r.main_class->get_element(mail_name)) if(Hash *mail_conf=mail_element->get_hash(0)) r.classes_conf.put(name(), mail_conf); - else + else if(!mail_element->get_string()) throw Exception("parser.runtime", 0, - "$" MAIL_CLASS_NAME ":" MAIL_NAME " is not hash"); + "$" MAIN_CLASS_NAME ":" MAIL_NAME " is not hash"); } // creator