Commit 2d1d0b42 authored by Sandro Knauß's avatar Sandro Knauß

Move DefaultRenderer to MessageViewer

parent 8002036d
......@@ -38,6 +38,7 @@ if(BUILD_TESTING)
add_subdirectory(htmlwriter/autotests/)
add_subdirectory(viewer/webengine/tests)
add_subdirectory(messageviewerheaderplugins/autotests)
add_subdirectory(messagepartthemes/default/autotests)
endif()
add_subdirectory(pics)
add_subdirectory(kconf_update)
......@@ -157,7 +158,20 @@ set(libmessageviewer_viewerplugins_SRCS
viewerplugins/viewerplugintoolmanager.cpp
)
set(libmessageviewer_messagepartthemes_default_SRCS
messagepartthemes/default/converthtmltoplaintext.cpp
messagepartthemes/default/defaultrenderer.cpp
messagepartthemes/default/htmlblock.cpp
)
FILE(GLOB themesfiles_default_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/messagepartthemes/default/templates/*.html")
install(FILES ${themesfiles_default_SRCS} DESTINATION ${DATA_INSTALL_DIR}/messageviewer/messagepartthemes/default)
set(libmessageviewer_messagepartthemes_SRCS
${libmessageviewer_messagepartthemes_default_SRCS}
)
set(libmessageviewer_SRCS
${libmessageviewer_messagepartthemes_SRCS}
${libmessageviewer_scamdetection_webengine_SRCS}
${libmessageviewer_widgets_webengine_SRCS}
${libmessageviewer_viewer_SRCS}
......@@ -219,6 +233,8 @@ target_link_libraries(KF5MessageViewer
KF5::CalendarCore
KF5::Gravatar
KF5::IconThemes
Grantlee5::TextDocument
Grantlee5::Templates
)
if (WIN32)
target_link_libraries(KF5MessageViewer PUBLIC KF5::Gpgmepp)
......
......@@ -19,16 +19,16 @@
#include "defaultrenderer.h"
#include "mimetreeparser_debug.h"
#include "messageviewer_debug.h"
#include "converthtmltoplaintext.h"
#include "htmlblock.h"
#include "interfaces/htmlwriter.h"
#include "utils/iconnamecache.h"
#include "viewer/csshelperbase.h"
#include "viewer/messagepart.h"
#include "viewer/objecttreeparser.h"
#include <MimeTreeParser/HtmlWriter>
#include <MimeTreeParser/CSSHelperBase>
#include <MimeTreeParser/MessagePart>
#include <MimeTreeParser/ObjectTreeParser>
#include <Libkleo/CryptoBackend>
#include <Libkleo/CryptoBackendFactory>
......@@ -36,6 +36,7 @@
#include <MessageCore/StringUtil>
#include <KEmailAddress>
#include <KIconLoader>
#include <KLocalizedString>
#include <KTextToHTML>
......@@ -52,6 +53,7 @@
#include <grantlee/templateloader.h>
#include <grantlee/template.h>
using namespace MessageViewer;
using namespace MimeTreeParser;
Q_DECLARE_METATYPE(GpgME::DecryptionResult::Recipient)
......@@ -90,12 +92,12 @@ Grantlee::Template getGrantleeTemplate(QObject *parent, const QString &name)
m_engine->addDefaultLibrary(QStringLiteral("grantlee_scriptabletags"));
auto loader = QSharedPointer<Grantlee::FileSystemTemplateLoader>(new Grantlee::FileSystemTemplateLoader());
loader->setTemplateDirs(QStringList() << QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("/mimetreeparser/themes/default"), QStandardPaths::LocateDirectory));
loader->setTemplateDirs(QStringList() << QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("/messageviewer/messagepartthemes/default"), QStandardPaths::LocateDirectory));
m_engine->addTemplateLoader(loader);
Grantlee::Template t = m_engine->loadByName(name);
if (t->error()) {
qCWarning(MIMETREEPARSER_LOG) << t->errorString() << ". Searched in subdir mimetreeparser/themes/default in these locations" << QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
qCWarning(MESSAGEVIEWER_LOG) << t->errorString() << ". Searched in subdir mimetreeparser/themes/default in these locations" << QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
}
return t;
}
......@@ -445,10 +447,10 @@ public:
class MimeTreeParser::DefaultRendererPrivate
{
public:
DefaultRendererPrivate(DefaultRenderer *qPtr, MessagePart::Ptr msgPart)
DefaultRendererPrivate(DefaultRenderer *qPtr, Interface::MessagePart::Ptr msgPart)
: mMsgPart(msgPart)
, mOldWriter(msgPart->htmlWriter())
, q(qPtr)
, mOldWriter(msgPart->htmlWriter())
{
mHtml = renderFactory(mMsgPart, QSharedPointer<CacheHtmlWriter>());
}
......@@ -817,7 +819,7 @@ public:
htmlStr += quoteEnd + cssHelper()->addEndBlockQuote(currQuoteLevel + 1);
}
// qCDebug(MIMETREEPARSER_LOG) << "========================================\n"
// qCDebug(MESSAGEVIEWER_LOG) << "========================================\n"
// << htmlStr
// << "\n======================================\n";
return htmlStr;
......@@ -1254,7 +1256,7 @@ public:
return htmlWriter->html;
}
QString renderFactory(MessagePart::Ptr msgPart, const QSharedPointer<CacheHtmlWriter> &htmlWriter)
QString renderFactory(Interface::MessagePart::Ptr msgPart, const QSharedPointer<CacheHtmlWriter> &htmlWriter)
{
const QString className = QString::fromUtf8(msgPart->metaObject()->className());
......@@ -1322,7 +1324,7 @@ public:
}
QString mHtml;
MessagePart::Ptr mMsgPart;
Interface::MessagePart::Ptr mMsgPart;
private:
DefaultRenderer *q;
HtmlWriter *mOldWriter;
......@@ -1331,8 +1333,8 @@ private:
QString mExpandIcon;
};
DefaultRenderer::DefaultRenderer(MessagePart::Ptr msgPart)
: d(new DefaultRendererPrivate(this, msgPart))
DefaultRenderer::DefaultRenderer(MimeTreeParser::Interface::MessagePart::Ptr msgPart)
: d(new MimeTreeParser::DefaultRendererPrivate(this, msgPart))
{
}
......
......@@ -17,30 +17,39 @@
02110-1301, USA.
*/
#ifndef __MIMETREEPARSER_MAILRENDERER_H__
#define __MIMETREEPARSER_MAILRENDERER_H__
#ifndef __MESSAGEVIEWER_DEFAULTRENDERER_H__
#define __MESSAGEVIEWER_DEFAULTRENDERER_H__
#include "interfaces/messagepartrenderer.h"
#include <MimeTreeParser/MessagePartRenderer>
#include<QSharedPointer>
namespace MimeTreeParser
{
class DefaultRendererPrivate;
namespace Interface
{
class MessagePart;
typedef QSharedPointer<MessagePart> MessagePartPtr;
}
}
namespace MessageViewer
{
class DefaultRendererPrivate;
class DefaultRenderer : public Interface::MessagePartRenderer
class DefaultRenderer : public MimeTreeParser::Interface::MessagePartRenderer
{
public:
DefaultRenderer(MessagePartPtr msgPart);
DefaultRenderer(MimeTreeParser::Interface::MessagePartPtr msgPart);
~DefaultRenderer();
QString html() const Q_DECL_OVERRIDE;
private:
DefaultRendererPrivate *d;
MimeTreeParser::DefaultRendererPrivate *d;
};
}
#endif //__MIMETREEPARSER_MAILRENDERER_H__
......@@ -21,10 +21,15 @@
#include "viewer/viewer_p.h"
#include <MimeTreeParser/AttachmentStrategy>
#include <MimeTreeParser/BodyPartFormatter>
#include "messagepartthemes/default/defaultrenderer.h"
#include "bodypartformatterfactorysingleton.h"
namespace MessageViewer
{
using namespace MessageViewer;
namespace MessageViewer {
class EmptySourcePrivate
{
......@@ -37,6 +42,8 @@ public:
bool mAllowDecryption;
};
}
EmptySource::EmptySource()
: MimeTreeParser::Interface::ObjectTreeSource(),
d(new MessageViewer::EmptySourcePrivate)
......@@ -133,5 +140,9 @@ const MimeTreeParser::BodyPartFormatterBaseFactory *EmptySource::bodyPartFormatt
{
return bodyPartFormatterBaseFactoryInstance();
}
MimeTreeParser::Interface::MessagePartRendererPtr EmptySource::messagePartTheme(MimeTreeParser::Interface::MessagePart::Ptr msgPart)
{
return MimeTreeParser::Interface::MessagePartRenderer::Ptr(new DefaultRenderer(msgPart));
}
......@@ -52,6 +52,7 @@ public:
bool showEmoticons() const Q_DECL_OVERRIDE;
bool showExpandQuotesMark() const Q_DECL_OVERRIDE;
const MimeTreeParser::BodyPartFormatterBaseFactory *bodyPartFormatterFactory() Q_DECL_OVERRIDE;
MimeTreeParser::Interface::MessagePartRendererPtr messagePartTheme(MimeTreeParser::Interface::MessagePartPtr msgPart) Q_DECL_OVERRIDE;
private:
EmptySourcePrivate *const d;
};
......
......@@ -21,12 +21,15 @@
#include "csshelper.h"
#include "bodypartformatterfactorysingleton.h"
#include <MimeTreeParser/BodyPartFormatter>
#include "messagepartthemes/default/defaultrenderer.h"
#include "viewer/viewer_p.h"
#include "widgets/htmlstatusbar.h"
#include "settings/messageviewersettings.h"
namespace MessageViewer
{
using namespace MessageViewer;
MailViewerSource::MailViewerSource(ViewerPrivate *viewer) :
MimeTreeParser::Interface::ObjectTreeSource(), mViewer(viewer)
{
......@@ -115,4 +118,8 @@ const MimeTreeParser::BodyPartFormatterBaseFactory *MailViewerSource::bodyPartFo
{
return bodyPartFormatterBaseFactoryInstance();
}
}
MimeTreeParser::Interface::MessagePartRendererPtr MailViewerSource::messagePartTheme(MimeTreeParser::Interface::MessagePart::Ptr msgPart)
{
return MimeTreeParser::Interface::MessagePartRenderer::Ptr(new DefaultRenderer(msgPart));
}
\ No newline at end of file
......@@ -52,6 +52,7 @@ public:
bool showEmoticons() const Q_DECL_OVERRIDE;
bool showExpandQuotesMark() const Q_DECL_OVERRIDE;
const MimeTreeParser::BodyPartFormatterBaseFactory *bodyPartFormatterFactory() Q_DECL_OVERRIDE;
MimeTreeParser::Interface::MessagePartRendererPtr messagePartTheme(MimeTreeParser::Interface::MessagePartPtr msgPart) Q_DECL_OVERRIDE;
private:
ViewerPrivate *mViewer;
};
......
......@@ -38,15 +38,7 @@ endmacro ()
add_mimetreeparser_crypto_unittest(attachmenttest.cpp)
add_mimetreeparser_crypto_unittest(objecttreeparsertest.cpp)
add_mimetreeparser_crypto_unittest(rendertest.cpp)
add_mimetreeparser_crypto_unittest(unencryptedmessagetest.cpp)
add_mimetreeparser_class_unittest(messageparttest.cpp "setupenv.cpp;../src/themes/default/defaultrenderer.cpp;../src/themes/default/htmlblock.cpp;../src/themes/default/converthtmltoplaintext.cpp;../src/mimetreeparser_debug.cpp")
add_mimetreeparser_unittest(nodehelpertest.cpp)
add_mimetreeparser_unittest(csshelpertest.cpp)
add_mimetreeparser_class_unittest( cryptohelpertest.cpp "../src/viewer/cryptohelper.cpp")
ecm_add_test(converthtmltoplaintexttest.cpp ../src/themes/default/converthtmltoplaintext.cpp
TEST_NAME converthtmltoplaintexttest
NAME_PREFIX "mimetreeparser-"
LINK_LIBRARIES Qt5::Test Grantlee5::TextDocument
)
add_mimetreeparser_class_unittest( cryptohelpertest.cpp "../src/viewer/cryptohelper.cpp")
\ No newline at end of file
......@@ -23,7 +23,8 @@
#include <gpgme++/key.h>
#include "interfaces/objecttreesource.h"
#include <viewer/attachmentstrategy.h>
#include "interfaces/messagepartrenderer.h"
#include "viewer/attachmentstrategy.h"
#include "viewer/bodypartformatterbasefactory.h"
namespace MimeTreeParser
......@@ -152,6 +153,10 @@ public:
return Q_NULLPTR;
}
Interface::MessagePartRenderer::Ptr messagePartTheme(Interface::MessagePart::Ptr msgPart) Q_DECL_OVERRIDE {
Q_UNUSED(msgPart);
return Interface::MessagePartRenderer::Ptr();
}
private:
MimeTreeParser::HtmlWriter *mWriter;
MimeTreeParser::CSSHelperBase *mCSSHelper;
......
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