equal
deleted
inserted
replaced
51 return timestamp.str(); |
51 return timestamp.str(); |
52 } |
52 } |
53 |
53 |
54 std::string format(const vmime::mediaType& contentType) { |
54 std::string format(const vmime::mediaType& contentType) { |
55 return contentType.getType() + "/" + contentType.getSubType(); |
55 return contentType.getType() + "/" + contentType.getSubType(); |
|
56 } |
|
57 |
|
58 void appendBody(xmlpp::Element* element, std::shared_ptr<vmime::body> body) { |
|
59 element->set_attribute("content-type", format(body->getContentType())); |
|
60 |
|
61 if (body->getPartCount() == 0) { |
|
62 element->add_child_cdata("TODO: here will be body/part content"); |
|
63 } else { |
|
64 for (auto part : body->getPartList()) { |
|
65 xmlpp::Element* partElement = element->add_child("part"); |
|
66 appendBody(partElement, part->getBody()); |
|
67 } |
|
68 } |
56 } |
69 } |
57 |
70 |
58 public: |
71 public: |
59 |
72 |
60 XMLDocumentConstructor(std::istream* input, xmlpp::DomParser* parser) : input(input), parser(parser) { |
73 XMLDocumentConstructor(std::istream* input, xmlpp::DomParser* parser) : input(input), parser(parser) { |
152 field->add_child_text(value->getName()); |
165 field->add_child_text(value->getName()); |
153 } else { |
166 } else { |
154 field->add_child_text("TODO: unknown header type"); // TODO: generic conversion as fallback? |
167 field->add_child_text("TODO: unknown header type"); // TODO: generic conversion as fallback? |
155 } |
168 } |
156 } |
169 } |
157 |
170 |
158 // TODO: check null pointers |
171 // TODO: check null pointers |
159 |
172 |
160 xmlpp::Element* body = root->add_child("body"); |
173 xmlpp::Element* body = root->add_child("body"); |
161 |
174 appendBody(body, m.getBody()); |
162 body->set_attribute("content-type", format(m.getBody()->getContentType())); |
|
163 |
|
164 for (auto part : m.getBody()->getPartList()) { |
|
165 xmlpp::Element* partElement = body->add_child("part"); |
|
166 partElement->set_attribute("content-type", format(part->getBody()->getContentType())); |
|
167 } |
|
168 |
175 |
169 } |
176 } |
170 }; |
177 }; |
171 |
178 |
172 } |
179 } |