Commit 7c8c7e98 authored by Sandro Knauß's avatar Sandro Knauß

Make BodyPartFormatterFactory part of ObjectTreeeSourceIf

with that we have full control of what is used as plugins within the ObjectTreeParser.
parent 0df06124
......@@ -18,7 +18,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
set(MESSAGELIB_LIB_VERSION "5.1.72")
set(MESSAGELIB_LIB_VERSION "5.1.73")
set(KF5_VERSION "5.19.0")
set(KDEPIMLIBS_LIB_VERSION "5.1.42")
......
......@@ -138,6 +138,7 @@ set(libmessageviewer_viewer_SRCS
viewer/bodypartformatter.cpp
viewer/bodypartformatterbasefactory.cpp
viewer/bodypartformatterfactory.cpp
viewer/bodypartformatterfactorysingleton.cpp
viewer/cryptohelper.cpp
viewer/csshelper.cpp
viewer/csshelperbase.cpp
......@@ -390,6 +391,8 @@ ecm_generate_headers(MessageViewer_Camelcaseviewer_HEADERS
CSSHelperBase
MessagePart
Enums
BodyPartFormatterBaseFactory
BodyPartFormatterFactory
REQUIRED_HEADERS MessageViewer_viewer_HEADERS
PREFIX MessageViewer
RELATIVE viewer
......
......@@ -33,6 +33,7 @@ namespace MessageViewer
class HtmlWriter;
class CSSHelperBase;
class AttachmentStrategy;
class BodyPartFormatterBaseFactory;
}
namespace MessageViewer
......@@ -95,6 +96,8 @@ public:
virtual bool showEmoticons() const = 0;
virtual bool showExpandQuotesMark() const = 0;
virtual const BodyPartFormatterBaseFactory *bodyPartFormatterFactory() = 0;
};
}
......
......@@ -34,6 +34,8 @@
#ifndef __MESSAGEVIEWER_BODYPARTFORMATTERBASEFACTORY_H__
#define __MESSAGEVIEWER_BODYPARTFORMATTERBASEFACTORY_H__
#include "messageviewer_export.h"
#include <map>
#include <QByteArray>
......@@ -59,7 +61,7 @@ typedef std::map<const char *, MessageViewer::SubtypeRegistry, MessageViewer::lt
class BodyPartFormatterBaseFactoryPrivate;
class BodyPartFormatterBaseFactory
class MESSAGEVIEWER_EXPORT BodyPartFormatterBaseFactory
{
public:
BodyPartFormatterBaseFactory();
......
......@@ -34,14 +34,16 @@
#ifndef __MESSAGEVIEWER_BODYPARTFORMATTERFACTORY_H__
#define __MESSAGEVIEWER_BODYPARTFORMATTERFACTORY_H__
#include "bodypartformatterbasefactory.h"
#include "messageviewer_export.h"
#include "messageviewer/bodypartformatterbasefactory.h"
class QString;
namespace MessageViewer
{
class BodyPartFormatterFactory : public BodyPartFormatterBaseFactory
class MESSAGEVIEWER_EXPORT BodyPartFormatterFactory : public BodyPartFormatterBaseFactory
{
public:
BodyPartFormatterFactory();
......
/*
Copyright (c) 2016 Sandro Knauß <sknauss@kde.org>
KMail is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
KMail is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include "bodypartformatterfactorysingleton.h"
#include "bodypartformatterfactory.h"
#include <QSharedPointer>
using namespace MessageViewer;
static QSharedPointer<BodyPartFormatterBaseFactory> singleton;
const BodyPartFormatterBaseFactory* MessageViewer::bodyPartFormatterBaseFactoryInstance()
{
if (!singleton) {
singleton = QSharedPointer<BodyPartFormatterBaseFactory>(new BodyPartFormatterFactory());
}
return singleton.data();
}
/*
Copyright (c) 2016 Sandro Knauß <sknauss@kde.org>
KMail is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
KMail is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the Qt library by Trolltech AS, Norway (or with modified versions
of Qt that use the same license as Qt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
Qt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#ifndef __MESSAGEVIEWER_BODYPARTFORMATTERFACTORYSIGNLETON_P_H__
#define __MESSAGEVIEWER_BODYPARTFORMATTERFACTORYSIGNLETON_P_H__
namespace MessageViewer
{
class BodyPartFormatterBaseFactory;
const BodyPartFormatterBaseFactory *bodyPartFormatterBaseFactoryInstance();
}
#endif
\ No newline at end of file
......@@ -21,6 +21,7 @@
#include "viewer/viewer_p.h"
#include "attachmentstrategy.h"
#include "bodypartformatterfactorysingleton.h"
namespace MessageViewer
{
......@@ -128,5 +129,9 @@ bool EmptySource::showExpandQuotesMark() const
return false;
}
const BodyPartFormatterBaseFactory *EmptySource::bodyPartFormatterFactory()
{
return bodyPartFormatterBaseFactoryInstance();
}
}
......@@ -51,6 +51,7 @@ public:
bool autoImportKeys() const Q_DECL_OVERRIDE;
bool showEmoticons() const Q_DECL_OVERRIDE;
bool showExpandQuotesMark() const Q_DECL_OVERRIDE;
const BodyPartFormatterBaseFactory *bodyPartFormatterFactory() Q_DECL_OVERRIDE;
private:
EmptySourcePrivate *const d;
};
......
......@@ -47,7 +47,7 @@
#include "attachmentstrategy.h"
#include "interfaces/htmlwriter.h"
#include "csshelperbase.h"
#include "viewer/bodypartformatterfactory.h"
#include "bodypartformatterbasefactory.h"
#include "viewer/partnodebodypart.h"
#include "interfaces/bodypartformatter.h"
#include "messageviewer/mimetype.h"
......@@ -141,7 +141,6 @@ ObjectTreeParser::ObjectTreeParser(const ObjectTreeParser *topLevelParser,
mHtmlWriter(topLevelParser->mHtmlWriter),
mTopLevelContent(topLevelParser->mTopLevelContent),
mCryptoProtocol(topLevelParser->mCryptoProtocol),
mBodyPartFormatterFactory(topLevelParser->mBodyPartFormatterFactory),
mShowOnlyOneMimePart(showOnlyOneMimePart),
mHasPendingAsyncJobs(false),
mAllowAsync(topLevelParser->mAllowAsync),
......@@ -161,7 +160,6 @@ ObjectTreeParser::ObjectTreeParser(ObjectTreeSourceIf *source,
mHtmlWriter(0),
mTopLevelContent(0),
mCryptoProtocol(protocol),
mBodyPartFormatterFactory(BodyPartFormatterFactory::instance()),
mShowOnlyOneMimePart(showOnlyOneMimePart),
mHasPendingAsyncJobs(false),
mAllowAsync(false),
......@@ -329,7 +327,7 @@ MessagePart::Ptr ObjectTreeParser::parseObjectTreeInternal(KMime::Content *node)
}
bool bRendered = false;
const auto sub = mBodyPartFormatterFactory->subtypeRegistry(mediaType);
const auto sub = mSource->bodyPartFormatterFactory()->subtypeRegistry(mediaType);
const auto end = sub.end();
auto it = sub.find(subType);
if (it == end) {
......
......@@ -69,7 +69,6 @@ class AttachmentStrategy;
class NodeHelper;
class MessagePart;
class MimeMessagePart;
class BodyPartFormatterBaseFactory;
typedef QSharedPointer<MessagePart> MessagePartPtr;
typedef QSharedPointer<MimeMessagePart> MimeMessagePartPtr;
......@@ -443,7 +442,6 @@ private:
QString mHtmlContent;
KMime::Content *mTopLevelContent;
const Kleo::CryptoBackend::Protocol *mCryptoProtocol;
const BodyPartFormatterBaseFactory *mBodyPartFormatterFactory;
/// Show only one mime part means that the user has selected some node in the message structure
/// viewer that is not the root, which means the user wants to only see the selected node and its
......
......@@ -19,6 +19,8 @@
#include "objecttreeviewersource.h"
#include "csshelper.h"
#include "bodypartformatterfactorysingleton.h"
#include "viewer/viewer_p.h"
#include "widgets/htmlstatusbar.h"
#include "settings/messageviewersettings.h"
......@@ -109,4 +111,8 @@ bool MailViewerSource::showExpandQuotesMark() const
return MessageViewer::MessageViewerSettings::self()->showExpandQuotesMark();
}
const BodyPartFormatterBaseFactory *MailViewerSource::bodyPartFormatterFactory()
{
return bodyPartFormatterBaseFactoryInstance();
}
}
......@@ -51,6 +51,7 @@ public:
bool autoImportKeys() const Q_DECL_OVERRIDE;
bool showEmoticons() const Q_DECL_OVERRIDE;
bool showExpandQuotesMark() const Q_DECL_OVERRIDE;
const BodyPartFormatterBaseFactory *bodyPartFormatterFactory() Q_DECL_OVERRIDE;
private:
ViewerPrivate *mViewer;
};
......
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