Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 5dc497c3 authored by Sandro Knauß's avatar Sandro Knauß

remove special TestObjectTreeSource - add SimpleObjectTreeSource

parent 15d24886
......@@ -23,7 +23,6 @@
#include "qtest_messagecomposer.h"
#include "cryptofunctions.h"
#include "testobjecttreesource.h"
#include "setupenv.h"
#include <Libkleo/Enum>
......@@ -47,6 +46,7 @@ using namespace MessageComposer;
using namespace MessageCore;
#include <MimeTreeParser/ObjectTreeParser>
#include <MimeTreeParser/SimpleObjectTreeSource>
#include <gpgme++/key.h>
......@@ -151,8 +151,8 @@ void CryptoComposerTest::testEncryptSameAttachments()
QCOMPARE(message->from()->asUnicodeString(), QString::fromLocal8Bit("me@me.me"));
QCOMPARE(message->to()->asUnicodeString(), QString::fromLocal8Bit("you@you.you"));
MimeTreeParser::Test::TestObjectTreeSource testSource;
testSource.mDecryptMessage = true;
MimeTreeParser::SimpleObjectTreeSource testSource;
testSource.setDecryptMessage(true);
MimeTreeParser::NodeHelper *nh = new MimeTreeParser::NodeHelper;
MimeTreeParser::ObjectTreeParser otp(&testSource, nh);
......
......@@ -20,7 +20,6 @@
#include "cryptofunctions.h"
#include "testobjecttreesource.h"
#include "setupenv.h"
#include <MessageComposer/Util>
......@@ -30,6 +29,7 @@
#include <KMime/Content>
#include <MimeTreeParser/ObjectTreeParser>
#include <MimeTreeParser/SimpleObjectTreeSource>
#include <MessageCore/NodeHelper>
......@@ -58,10 +58,9 @@ void ComposerTestUtil::verifySignature(KMime::Content *content, const QByteArray
resultMessage->parse();
// parse the result and make sure it is valid in various ways
MimeTreeParser::Test::TestObjectTreeSource testSource;
MimeTreeParser::SimpleObjectTreeSource testSource;
MimeTreeParser::NodeHelper *nh = new MimeTreeParser::NodeHelper;
MimeTreeParser::ObjectTreeParser otp(&testSource, nh);
MimeTreeParser::ProcessResult pResult(nh);
// ensure the signed part exists and is parseable
if (f & Kleo::OpenPGPMIMEFormat) {
......@@ -128,8 +127,8 @@ void ComposerTestUtil::verifyEncryption(KMime::Content *content, const QByteArra
resultMessage->parse();
// parse the result and make sure it is valid in various ways
MimeTreeParser::Test::TestObjectTreeSource testSource;
testSource.mDecryptMessage = true;
MimeTreeParser::SimpleObjectTreeSource testSource;
testSource.setDecryptMessage(true);
MimeTreeParser::NodeHelper *nh = new MimeTreeParser::NodeHelper;
MimeTreeParser::ObjectTreeParser otp(&testSource, nh);
......@@ -181,8 +180,8 @@ void ComposerTestUtil::verifySignatureAndEncryption(KMime::Content *content, con
resultMessage->parse();
// parse the result and make sure it is valid in various ways
MimeTreeParser::Test::TestObjectTreeSource testSource;
testSource.mDecryptMessage = true;
MimeTreeParser::SimpleObjectTreeSource testSource;
testSource.setDecryptMessage(true);
MimeTreeParser::NodeHelper *nh = new MimeTreeParser::NodeHelper;
MimeTreeParser::ObjectTreeParser otp(&testSource, nh);
......
......@@ -46,8 +46,8 @@
#include <MessageComposer/RecipientsEditor>
#include "settings/messagecomposersettings.h"
#include <MessageViewer/ObjectTreeEmptySource>
#include <MimeTreeParser/ObjectTreeParser>
#include <MimeTreeParser/SimpleObjectTreeSource>
#ifndef QT_NO_CURSOR
#include <Libkdepim/KCursorSaver>
#endif
......@@ -180,9 +180,9 @@ void ComposerViewBase::setMessage(const KMime::Message::Ptr &msg, bool allowDecr
KMime::Content *msgContent = new KMime::Content;
msgContent->setContent(m_msg->encodedContent());
msgContent->parse();
MessageViewer::EmptySource emptySource;
MimeTreeParser::SimpleObjectTreeSource emptySource;
MimeTreeParser::ObjectTreeParser otp(&emptySource); //All default are ok
emptySource.setAllowDecryption(allowDecryption);
emptySource.setDecryptMessage(allowDecryption);
otp.parseObjectTree(msgContent);
// Load the attachments
......@@ -231,7 +231,7 @@ void ComposerViewBase::updateTemplate(const KMime::Message::Ptr &msg)
KMime::Content *msgContent = new KMime::Content;
msgContent->setContent(msg->encodedContent());
msgContent->parse();
MessageViewer::EmptySource emptySource;
MimeTreeParser::SimpleObjectTreeSource emptySource;
MimeTreeParser::ObjectTreeParser otp(&emptySource); //All default are ok
otp.parseObjectTree(msgContent);
// Set the HTML text and collect HTML images
......
......@@ -20,7 +20,7 @@
#include "util.h"
#include "setupenv.h"
#include "testobjecttreesource.h"
#include <MimeTreeParser/SimpleObjectTreeSource>
#include <qtest.h>
......@@ -56,8 +56,8 @@ void AttachmentTest::testEncryptedAttachment()
QFETCH(QString, mbox);
auto msg = readAndParseMail(mbox);
NodeHelper nodeHelper;
Test::TestObjectTreeSource testSource;
testSource.mDecryptMessage = true;
SimpleObjectTreeSource testSource;
testSource.setDecryptMessage(true);
ObjectTreeParser otp(&testSource, &nodeHelper);
otp.parseObjectTree(msg.data());
......
/*
Copyright (C) 2017 Sandro Kanuß <sknauss@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library 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 Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef MIMETREEPARSER_TESTS_TESTOBJECTTREESOURCE_H
#define MIMETREEPARSER_TESTS_TESTOBJECTTREESOURCE_H
#include <MimeTreeParser/BodyPartFormatterFactory>
#include <MimeTreeParser/MessagePart>
#include <MimeTreeParser/ObjectTreeSource>
namespace MimeTreeParser {
namespace Test {
class TestObjectTreeSource : public MimeTreeParser::Interface::ObjectTreeSource
{
public:
TestObjectTreeSource()
: mBodyPartFormatterFactory(MimeTreeParser::BodyPartFormatterFactory::instance())
, mPreferredMode(Util::Html)
, mDecryptMessage(false)
{
}
bool autoImportKeys() const override
{
return true;
}
const BodyPartFormatterFactory *bodyPartFormatterFactory() override
{
return mBodyPartFormatterFactory;
}
bool decryptMessage() const override
{
return mDecryptMessage;
}
void setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList<MimeTreeParser::Util::HtmlMode> &availableModes) override
{
Q_UNUSED(mode);
Q_UNUSED(availableModes);
}
MimeTreeParser::Util::HtmlMode preferredMode() const override
{
return mPreferredMode;
}
const QTextCodec *overrideCodec() override
{
return nullptr;
}
void render(const MessagePart::Ptr &msgPart, bool showOnlyOneMimePart) override
{
Q_UNUSED(msgPart);
Q_UNUSED(showOnlyOneMimePart);
}
BodyPartFormatterFactory *mBodyPartFormatterFactory;
MimeTreeParser::Util::HtmlMode mPreferredMode;
bool mDecryptMessage;
};
}
}
#endif
......@@ -32,6 +32,7 @@ set(libmimetreeparser_main_SRCS
objecttreeparser.cpp
messagepart.cpp
partnodebodypart.cpp
simpleobjecttreesource.cpp
memento/cryptobodypartmemento.cpp
memento/decryptverifybodypartmemento.cpp
memento/verifydetachedbodypartmemento.cpp
......@@ -51,6 +52,7 @@ ecm_generate_headers(MimeTreeParser_Camelcasemain_HEADERS
ObjectTreeParser
PartMetaData
PartNodeBodyPart
SimpleObjectTreeSource
REQUIRED_HEADERS MimeTreeParser_main_HEADERS
PREFIX MimeTreeParser
)
......
/*
Copyright (C) 2017 Sandro Kanuß <sknauss@kde.org>
This program 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.
This program 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.
*/
#include "simpleobjecttreesource.h"
#include <MimeTreeParser/BodyPartFormatterFactory>
#include <MimeTreeParser/MessagePart>
#include <MimeTreeParser/ObjectTreeSource>
using namespace MimeTreeParser;
namespace MimeTreeParser
{
class SimpleObjectTreeSourcePrivate
{
public:
bool mDecryptMessage = false;
};
}
SimpleObjectTreeSource::SimpleObjectTreeSource()
: d(new SimpleObjectTreeSourcePrivate)
{
}
SimpleObjectTreeSource::~SimpleObjectTreeSource() = default;
bool SimpleObjectTreeSource::autoImportKeys() const
{
return true;
}
const BodyPartFormatterFactory *SimpleObjectTreeSource::bodyPartFormatterFactory()
{
return BodyPartFormatterFactory::instance();
}
bool SimpleObjectTreeSource::decryptMessage() const
{
return d->mDecryptMessage;
}
void SimpleObjectTreeSource::setDecryptMessage(bool decryptMessage)
{
d->mDecryptMessage = decryptMessage;
}
MimeTreeParser::Util::HtmlMode SimpleObjectTreeSource::preferredMode() const
{
return Util::Html;
}
const QTextCodec *SimpleObjectTreeSource::overrideCodec()
{
return nullptr;
}
void SimpleObjectTreeSource::setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList<MimeTreeParser::Util::HtmlMode> &availableModes)
{
Q_UNUSED(mode);
Q_UNUSED(availableModes);
}
void SimpleObjectTreeSource::render(const MessagePart::Ptr &msgPart, bool showOnlyOneMimePart)
{
Q_UNUSED(msgPart);
Q_UNUSED(showOnlyOneMimePart);
}
......@@ -17,66 +17,41 @@
02110-1301, USA.
*/
#ifndef MIMETREEPARSER_TESTS_TESTOBJECTTREESOURCE_H
#define MIMETREEPARSER_TESTS_TESTOBJECTTREESOURCE_H
#ifndef MIMETREEPARSER_SIMPLEOBJECTTREESOURCE_H
#define MIMETREEPARSER_SIMPLEOBJECTTREESOURCE_H
#include <MimeTreeParser/BodyPartFormatterFactory>
#include <MimeTreeParser/MessagePart>
#include <MimeTreeParser/ObjectTreeSource>
#include "mimetreeparser/objecttreesource.h"
#include <memory>
namespace MimeTreeParser {
namespace Test {
class TestObjectTreeSource : public MimeTreeParser::Interface::ObjectTreeSource
class SimpleObjectTreeSourcePrivate;
/**
* A very simple ObjectTreeSource.
* mostly used in tests and outside the read redering
*/
class MIMETREEPARSER_EXPORT SimpleObjectTreeSource : public Interface::ObjectTreeSource
{
public:
TestObjectTreeSource()
: mBodyPartFormatterFactory(MimeTreeParser::BodyPartFormatterFactory::instance())
, mPreferredMode(Util::Html)
, mDecryptMessage(false)
{
}
bool autoImportKeys() const override
{
return true;
}
SimpleObjectTreeSource();
~SimpleObjectTreeSource();
const BodyPartFormatterFactory *bodyPartFormatterFactory() override
{
return mBodyPartFormatterFactory;
}
bool autoImportKeys() const override;
bool decryptMessage() const override
{
return mDecryptMessage;
}
const BodyPartFormatterFactory *bodyPartFormatterFactory() override;
bool decryptMessage() const override;
void setDecryptMessage(bool decryptMessage);
void setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList<MimeTreeParser::Util::HtmlMode> &availableModes) override
{
Q_UNUSED(mode);
Q_UNUSED(availableModes);
}
void setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList<MimeTreeParser::Util::HtmlMode> &availableModes) override;
MimeTreeParser::Util::HtmlMode preferredMode() const override;
MimeTreeParser::Util::HtmlMode preferredMode() const override
{
return mPreferredMode;
}
const QTextCodec *overrideCodec() override;
const QTextCodec *overrideCodec() override
{
return nullptr;
}
void render(const MessagePartPtr &msgPart, bool showOnlyOneMimePart) override;
void render(const MessagePart::Ptr &msgPart, bool showOnlyOneMimePart) override
{
Q_UNUSED(msgPart);
Q_UNUSED(showOnlyOneMimePart);
}
BodyPartFormatterFactory *mBodyPartFormatterFactory;
MimeTreeParser::Util::HtmlMode mPreferredMode;
bool mDecryptMessage;
private:
std::unique_ptr<SimpleObjectTreeSourcePrivate> d;
};
}
}
#endif
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