Commit cb5ee1b5 authored by Sandro Knauß's avatar Sandro Knauß

The format method in its total need to die.

The idea is to switch to the process method and have a plugin system
for the rendering part, so plugins hav not to meld the parsing and
rendering together.

see T6166

as a first step let's die the format function that uses an
asyncObserver.
parent 1cdfac1a
...@@ -42,18 +42,6 @@ const Interface::BodyPartFormatter *ApplicationPGPEncryptedBodyPartFormatter::cr ...@@ -42,18 +42,6 @@ const Interface::BodyPartFormatter *ApplicationPGPEncryptedBodyPartFormatter::cr
return self; return self;
} }
Interface::BodyPartFormatter::Result ApplicationPGPEncryptedBodyPartFormatter::format(Interface::BodyPart *part, HtmlWriter *writer) const
{
Q_UNUSED(writer)
const auto p = process(*part);
const auto mp = static_cast<MessagePart *>(p.data());
if (mp) {
mp->html(false);
return Ok;
}
return Failed;
}
Interface::MessagePart::Ptr ApplicationPGPEncryptedBodyPartFormatter::process(Interface::BodyPart &part) const Interface::MessagePart::Ptr ApplicationPGPEncryptedBodyPartFormatter::process(Interface::BodyPart &part) const
{ {
KMime::Content *node(part.content()); KMime::Content *node(part.content());
......
...@@ -31,7 +31,6 @@ class ApplicationPGPEncryptedBodyPartFormatter : public Interface::BodyPartForma ...@@ -31,7 +31,6 @@ class ApplicationPGPEncryptedBodyPartFormatter : public Interface::BodyPartForma
static const ApplicationPGPEncryptedBodyPartFormatter *self; static const ApplicationPGPEncryptedBodyPartFormatter *self;
public: public:
Interface::MessagePart::Ptr process(Interface::BodyPart &part) const Q_DECL_OVERRIDE; Interface::MessagePart::Ptr process(Interface::BodyPart &part) const Q_DECL_OVERRIDE;
Interface::BodyPartFormatter::Result format(Interface::BodyPart *, HtmlWriter *) const Q_DECL_OVERRIDE;
using Interface::BodyPartFormatter::format; using Interface::BodyPartFormatter::format;
static const Interface::BodyPartFormatter *create(); static const Interface::BodyPartFormatter *create();
}; };
......
...@@ -44,17 +44,6 @@ const Interface::BodyPartFormatter *ApplicationPkcs7MimeBodyPartFormatter::creat ...@@ -44,17 +44,6 @@ const Interface::BodyPartFormatter *ApplicationPkcs7MimeBodyPartFormatter::creat
} }
return self; return self;
} }
Interface::BodyPartFormatter::Result ApplicationPkcs7MimeBodyPartFormatter::format(Interface::BodyPart *part, HtmlWriter *writer) const
{
Q_UNUSED(writer)
const auto p = process(*part);
const auto mp = static_cast<MessagePart *>(p.data());
if (mp) {
mp->html(false);
return Ok;
}
return Failed;
}
Interface::MessagePart::Ptr ApplicationPkcs7MimeBodyPartFormatter::process(Interface::BodyPart &part) const Interface::MessagePart::Ptr ApplicationPkcs7MimeBodyPartFormatter::process(Interface::BodyPart &part) const
{ {
......
...@@ -31,7 +31,6 @@ class ApplicationPkcs7MimeBodyPartFormatter : public Interface::BodyPartFormatte ...@@ -31,7 +31,6 @@ class ApplicationPkcs7MimeBodyPartFormatter : public Interface::BodyPartFormatte
static const ApplicationPkcs7MimeBodyPartFormatter *self; static const ApplicationPkcs7MimeBodyPartFormatter *self;
public: public:
Interface::MessagePart::Ptr process(Interface::BodyPart &part) const Q_DECL_OVERRIDE; Interface::MessagePart::Ptr process(Interface::BodyPart &part) const Q_DECL_OVERRIDE;
Interface::BodyPartFormatter::Result format(Interface::BodyPart *, HtmlWriter *) const Q_DECL_OVERRIDE;
using Interface::BodyPartFormatter::format; using Interface::BodyPartFormatter::format;
static const Interface::BodyPartFormatter *create(); static const Interface::BodyPartFormatter *create();
}; };
......
...@@ -39,17 +39,6 @@ const Interface::BodyPartFormatter *MailmanBodyPartFormatter::create() ...@@ -39,17 +39,6 @@ const Interface::BodyPartFormatter *MailmanBodyPartFormatter::create()
} }
return self; return self;
} }
Interface::BodyPartFormatter::Result MailmanBodyPartFormatter::format(Interface::BodyPart *part, HtmlWriter *writer) const
{
Q_UNUSED(writer)
const auto p = process(*part);
const auto mp = static_cast<MessagePart *>(p.data());
if (mp) {
mp->html(false);
return Ok;
}
return Failed;
}
bool MailmanBodyPartFormatter::isMailmanMessage(KMime::Content *curNode) const bool MailmanBodyPartFormatter::isMailmanMessage(KMime::Content *curNode) const
{ {
......
...@@ -31,7 +31,6 @@ class MailmanBodyPartFormatter : public Interface::BodyPartFormatter ...@@ -31,7 +31,6 @@ class MailmanBodyPartFormatter : public Interface::BodyPartFormatter
static const MailmanBodyPartFormatter *self; static const MailmanBodyPartFormatter *self;
public: public:
Interface::MessagePart::Ptr process(Interface::BodyPart &part) const Q_DECL_OVERRIDE; Interface::MessagePart::Ptr process(Interface::BodyPart &part) const Q_DECL_OVERRIDE;
Interface::BodyPartFormatter::Result format(Interface::BodyPart *, HtmlWriter *) const Q_DECL_OVERRIDE;
using Interface::BodyPartFormatter::format; using Interface::BodyPartFormatter::format;
static const Interface::BodyPartFormatter *create(); static const Interface::BodyPartFormatter *create();
......
...@@ -39,17 +39,6 @@ const Interface::BodyPartFormatter *MultiPartAlternativeBodyPartFormatter::creat ...@@ -39,17 +39,6 @@ const Interface::BodyPartFormatter *MultiPartAlternativeBodyPartFormatter::creat
} }
return self; return self;
} }
Interface::BodyPartFormatter::Result MultiPartAlternativeBodyPartFormatter::format(Interface::BodyPart *part, HtmlWriter *writer) const
{
Q_UNUSED(writer)
const auto p = process(*part);
const auto mp = static_cast<MessagePart *>(p.data());
if (mp) {
mp->html(false);
return Ok;
}
return Failed;
}
Interface::MessagePart::Ptr MultiPartAlternativeBodyPartFormatter::process(Interface::BodyPart &part) const Interface::MessagePart::Ptr MultiPartAlternativeBodyPartFormatter::process(Interface::BodyPart &part) const
{ {
......
...@@ -31,7 +31,6 @@ class MultiPartAlternativeBodyPartFormatter : public Interface::BodyPartFormatte ...@@ -31,7 +31,6 @@ class MultiPartAlternativeBodyPartFormatter : public Interface::BodyPartFormatte
static const MultiPartAlternativeBodyPartFormatter *self; static const MultiPartAlternativeBodyPartFormatter *self;
public: public:
Interface::MessagePart::Ptr process(Interface::BodyPart &part) const Q_DECL_OVERRIDE; Interface::MessagePart::Ptr process(Interface::BodyPart &part) const Q_DECL_OVERRIDE;
Interface::BodyPartFormatter::Result format(Interface::BodyPart *, HtmlWriter *) const Q_DECL_OVERRIDE;
using Interface::BodyPartFormatter::format; using Interface::BodyPartFormatter::format;
static const Interface::BodyPartFormatter *create(); static const Interface::BodyPartFormatter *create();
}; };
......
...@@ -138,6 +138,13 @@ void MessagePart::setHtmlWriter(MimeTreeParser::HtmlWriter *htmlWriter) const ...@@ -138,6 +138,13 @@ void MessagePart::setHtmlWriter(MimeTreeParser::HtmlWriter *htmlWriter) const
} }
} }
BodyPartFormatter::Result BodyPartFormatter::format(BodyPart *part, MimeTreeParser::HtmlWriter *writer) const
{
Q_UNUSED(part);
Q_UNUSED(writer);
return Failed;
}
MessagePart::Ptr BodyPartFormatter::process(BodyPart &part) const MessagePart::Ptr BodyPartFormatter::process(BodyPart &part) const
{ {
auto mp = MessagePart::Ptr(new MessagePart(part)); auto mp = MessagePart::Ptr(new MessagePart(part));
......
...@@ -97,21 +97,12 @@ public: ...@@ -97,21 +97,12 @@ public:
Format body part \a part by generating some HTML and writing Format body part \a part by generating some HTML and writing
that to \a writer. that to \a writer.
@return the result code (see above) If you a async process and need to send an update information you can use
*/ MimeTreeParser::NodeHelper::Update signal with the corresponding instance of BodyPart::nodeHelper()
virtual Result format(BodyPart *part, MimeTreeParser::HtmlWriter *writer) const = 0;
/**
Variant of format that allows implementors to hook notifications up to
a listener interested in the result, for async operations.
@return the result code (see above) @return the result code (see above)
*/ */
virtual Result format(BodyPart *part, MimeTreeParser::HtmlWriter *writer, QObject *asyncResultObserver) const virtual Result format(BodyPart *part, MimeTreeParser::HtmlWriter *writer) const;
{
Q_UNUSED(asyncResultObserver);
return format(part, writer);
}
virtual void adaptProcessResult(ProcessResult &result) const virtual void adaptProcessResult(ProcessResult &result) const
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment