summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2012-01-06 02:13:02 +0000
committerrandomdan <randomdan@localhost>2012-01-06 02:13:02 +0000
commit7de3a9e03d6f03315ee6025d12eaa26c6e3d03bd (patch)
treef9bc14a67f173fa11a219ba412fdab9aa3e67738
parentAddress memory leaks that have snook in over time (diff)
downloadproject2-7de3a9e03d6f03315ee6025d12eaa26c6e3d03bd.tar.bz2
project2-7de3a9e03d6f03315ee6025d12eaa26c6e3d03bd.tar.xz
project2-7de3a9e03d6f03315ee6025d12eaa26c6e3d03bd.zip
Fix missing email message content
Reimplement ordering of email content parts with support from WritableContent classes
-rw-r--r--project2/common/transform.h6
-rw-r--r--project2/json/presenter.cpp3
-rw-r--r--project2/mail/sendmailTask.cpp5
-rw-r--r--project2/xml/transformHtml.cpp5
-rw-r--r--project2/xml/transformHtml.h1
-rw-r--r--project2/xml/transformText.cpp4
-rw-r--r--project2/xml/transformText.h1
-rw-r--r--project2/xml/xmlPresenter.cpp5
-rw-r--r--project2/xml/xmlPresenter.h1
9 files changed, 29 insertions, 2 deletions
diff --git a/project2/common/transform.h b/project2/common/transform.h
index 4e80476..a9dde49 100644
--- a/project2/common/transform.h
+++ b/project2/common/transform.h
@@ -88,6 +88,12 @@ class TransformImpl : public Transform {
class WritableContent {
public:
+ enum Class {
+ ClassPlain = 1,
+ ClassPretty = 2,
+ ClassData = 3
+ };
+ virtual Class getContentClass() const = 0;
virtual Glib::ustring getContentType() const = 0;
virtual void writeTo(std::ostream &, const std::string & encoding) const = 0;
};
diff --git a/project2/json/presenter.cpp b/project2/json/presenter.cpp
index 6500ea1..f50c322 100644
--- a/project2/json/presenter.cpp
+++ b/project2/json/presenter.cpp
@@ -53,6 +53,9 @@ class JsonPresenter : public MultiRowSetPresenter, public ContentPresenter, publ
Glib::ustring getContentType() const {
return contentType;
}
+ Class getContentClass() const {
+ return ClassData;
+ }
void writeTo(std::ostream & o, const std::string & encoding) const {
serializeObject(object, o, encoding);
}
diff --git a/project2/mail/sendmailTask.cpp b/project2/mail/sendmailTask.cpp
index d3ee53a..f8bc879 100644
--- a/project2/mail/sendmailTask.cpp
+++ b/project2/mail/sendmailTask.cpp
@@ -158,10 +158,10 @@ class TransformWritableContentToEmail : public TransformImpl<WritableContent, Se
}
void transform(const WritableContent * wc, SendMailTask::Parts * parts) const
{
- parts->parts.insert(new BoundaryBegin(wc->getContentType(), encoding, 1));
+ parts->parts.insert(new BoundaryBegin(wc->getContentType(), encoding, wc->getContentClass()));
std::stringstream str;
wc->writeTo(str, encoding);
- parts->parts.insert(new MimeContent(str.str(), 1));
+ parts->parts.insert(new MimeContent(str.str(), wc->getContentClass()));
SendMailTask::MailPart::mimeIdx += 1;
}
void configure(ScriptNodePtr s)
@@ -176,6 +176,7 @@ DECLARE_TRANSFORM(TransformWritableContentToEmail);
class EmailViewHost : public ViewHost {
public:
EmailViewHost(boost::intrusive_ptr<SendMailTask::Parts> & ps, ScriptNodePtr node) :
+ CommonObjects(node),
CheckHost(node),
ViewHost(node),
parts(ps),
diff --git a/project2/xml/transformHtml.cpp b/project2/xml/transformHtml.cpp
index 8cc9202..e280f27 100644
--- a/project2/xml/transformHtml.cpp
+++ b/project2/xml/transformHtml.cpp
@@ -40,6 +40,11 @@ HtmlDocument::getContentType() const
return contentType();
}
+WritableContent::Class
+HtmlDocument::getContentClass() const {
+ return ClassPretty;
+}
+
class TransformXmlToHtml : public TransformImpl<xmlpp::Document, HtmlDocument> {
public:
void transform(const xmlpp::Document * cdata, HtmlDocument * result) const
diff --git a/project2/xml/transformHtml.h b/project2/xml/transformHtml.h
index 3ea10fd..b8d4207 100644
--- a/project2/xml/transformHtml.h
+++ b/project2/xml/transformHtml.h
@@ -10,6 +10,7 @@ class HtmlDocument : public SourceOf<HtmlDocument>, public WritableContent, publ
htmlDocPtr doc;
operator const HtmlDocument * () const;
operator const WritableContent * () const;
+ Class getContentClass() const;
Glib::ustring getContentType() const;
void writeTo(std::ostream &, const std::string & encoding) const;
Variable contentType;
diff --git a/project2/xml/transformText.cpp b/project2/xml/transformText.cpp
index b9b5e56..2002734 100644
--- a/project2/xml/transformText.cpp
+++ b/project2/xml/transformText.cpp
@@ -29,6 +29,10 @@ TextDocument::getContentType() const
return contentType();
}
+WritableContent::Class
+TextDocument::getContentClass() const {
+ return ClassPlain;
+}
class TransformHtmlToText : public TransformImpl<HtmlDocument, TextDocument> {
public:
diff --git a/project2/xml/transformText.h b/project2/xml/transformText.h
index 7fd1e8f..f1fcaaf 100644
--- a/project2/xml/transformText.h
+++ b/project2/xml/transformText.h
@@ -10,6 +10,7 @@ class TextDocument : public SourceOf<TextDocument>, public WritableContent, publ
Glib::ustring doc;
operator const TextDocument * () const;
operator const WritableContent * () const;
+ Class getContentClass() const;
Glib::ustring getContentType() const;
void writeTo(std::ostream &, const std::string & encoding) const;
Variable contentType;
diff --git a/project2/xml/xmlPresenter.cpp b/project2/xml/xmlPresenter.cpp
index 91d43aa..bde649d 100644
--- a/project2/xml/xmlPresenter.cpp
+++ b/project2/xml/xmlPresenter.cpp
@@ -151,6 +151,11 @@ XmlPresenter::getContentType() const {
return contentType;
}
+WritableContent::Class
+XmlPresenter::getContentClass() const {
+ return ClassData;
+}
+
void
XmlPresenter::writeTo(std::ostream & o, const std::string & enc) const {
responseDoc->write_to_stream_formatted(o, enc);
diff --git a/project2/xml/xmlPresenter.h b/project2/xml/xmlPresenter.h
index eacc793..a7fbb11 100644
--- a/project2/xml/xmlPresenter.h
+++ b/project2/xml/xmlPresenter.h
@@ -28,6 +28,7 @@ class XmlPresenter : public Presenter, public ContentPresenter, public SourceOf<
operator const xmlDoc * () const;
operator const boost::shared_ptr<xmlpp::Document> * () const;
operator const WritableContent * () const;
+ Class getContentClass() const;
Glib::ustring getContentType() const;
void writeTo(std::ostream &, const std::string & enc) const;