Changeset c504199e7e127458fff243397776ee854e62b7a3
- Timestamp:
- 09/02/10 20:10:07 (21 months ago)
- Author:
- Antti-Juhani Kaijanaho <antti-juhani@…>
- Children:
- e7bbf3c6b857df8ad33c4d39396d693b48a48461
- Parents:
- 62231ec0359b34f6a82b6688a7af97f2eb2ede10
- git-committer:
- Antti-Juhani Kaijanaho <antti-juhani@…> (09/02/10 20:10:07)
- Message:
-
Support multipart entities
Signed-off-by: Antti-Juhani Kaijanaho <antti-juhani@…>
- Location:
- msg
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r62231ec
|
rc504199
|
|
| 21 | 21 | #include "entity.hh" |
| 22 | 22 | #include "format_violation.hh" |
| | 23 | #include "multipart.hh" |
| 23 | 24 | #include "text_plain.hh" |
| 24 | 25 | |
| … |
… |
|
| 56 | 57 | { |
| 57 | 58 | entity::entity(const entity &ent) |
| 58 | | : field_content(ent.field_content) |
| | 59 | : default_ct(ent.default_ct) |
| | 60 | , field_content(ent.field_content) |
| 59 | 61 | , body(ent.body) |
| 60 | 62 | { |
| … |
… |
|
| 70 | 72 | } |
| 71 | 73 | |
| 72 | | entity::entity(std::string msgstr) |
| | 74 | entity::entity(std::string msgstr, |
| | 75 | std::string default_ct) |
| | 76 | : default_ct(default_ct) |
| 73 | 77 | { |
| 74 | 78 | parse_headers(msgstr); |
| … |
… |
|
| 229 | 233 | content_type entity::get_content_type() const |
| 230 | 234 | { |
| 231 | | return content_type(get_field("content-type", false)); |
| | 235 | return content_type(has_field("content-type") |
| | 236 | ? get_field("content-type", false) |
| | 237 | : default_ct); |
| 232 | 238 | } |
| 233 | 239 | |
| … |
… |
|
| 235 | 241 | { |
| 236 | 242 | boost::shared_ptr<mime_entity> rv; |
| 237 | | // use text/plain as a fallback for now |
| 238 | | rv.reset(new text_plain(*this)); |
| | 243 | content_type ct = get_content_type(); |
| | 244 | switch (ct.get_type()) |
| | 245 | { |
| | 246 | case content_type::MULTIPART: |
| | 247 | rv.reset(new multipart(*this)); |
| | 248 | break; |
| | 249 | case content_type::TEXT: default: |
| | 250 | rv.reset(new text_plain(*this)); |
| | 251 | break; |
| | 252 | } |
| 239 | 253 | return rv; |
| 240 | 254 | } |
-
|
r62231ec
|
rc504199
|
|
| 39 | 39 | typedef std::list<std::string>::const_iterator field_iterator; |
| 40 | 40 | |
| 41 | | explicit entity(std::string msgstr); |
| | 41 | explicit entity(std::string msgstr, |
| | 42 | std::string default_ct = |
| | 43 | "text/plain; charset=\"US-ASCII\""); |
| 42 | 44 | |
| 43 | 45 | virtual ~entity() {} |
| … |
… |
|
| 59 | 61 | |
| 60 | 62 | |
| 61 | | bool has_field(std::string s) { |
| | 63 | bool has_field(std::string s) const{ |
| 62 | 64 | boost::to_lower(s); |
| 63 | 65 | return fields.find(s) != fields.end(); |
| … |
… |
|
| 82 | 84 | |
| 83 | 85 | private: |
| | 86 | std::string default_ct; |
| 84 | 87 | // this split is to both provide a fast name lookup |
| 85 | 88 | // and to preserve the field ordering |