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 b214324d authored by Sandro Knauß's avatar Sandro Knauß

Make TemplateParser clean so only MimeTreeParser is needed.

parent 5dc497c3
......@@ -14,7 +14,7 @@ macro(add_templateparser_unittest _source)
target_link_libraries(${_name}
KF5::Libkleo
KF5::TemplateParser
KF5::MessageViewer
KF5::MimeTreeParser
QGpgme
Qt5::Test
KF5::KIOCore
......
......@@ -20,6 +20,7 @@
#include "templateparserjobtest.h"
#define private public
#include "templateparserjob_p.h"
#include "templateparserjob.h"
#undef protected
......@@ -86,9 +87,9 @@ void TemplateParserJobTest::test_convertedHtml()
TemplateParser::TemplateParserJob *parser = new TemplateParser::TemplateParserJob(msg, TemplateParser::TemplateParserJob::NewMessage);
KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
parser->setIdentityManager(identMan);
parser->mOtp->parseObjectTree(msg.data());
QVERIFY(parser->mOtp->htmlContent().isEmpty());
QVERIFY(!parser->mOtp->plainTextContent().isEmpty());
parser->d->mOtp->parseObjectTree(msg.data());
QVERIFY(parser->d->mOtp->htmlContent().isEmpty());
QVERIFY(!parser->d->mOtp->plainTextContent().isEmpty());
QSignalSpy spy(parser, &TemplateParser::TemplateParserJob::parsingDone);
parser->processWithTemplate(QString());
......@@ -144,8 +145,8 @@ void TemplateParserJobTest::test_replyPlain()
//KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
//parser->setIdentityManager(identMan);
parser->mOtp->parseObjectTree(msg.data());
parser->mOrigMsg = msg;
parser->d->mOtp->parseObjectTree(msg.data());
parser->d->mOrigMsg = msg;
//QVERIFY(parser->mOtp->htmlContent().isEmpty());
//QVERIFY(!parser->mOtp->plainTextContent().isEmpty());
......@@ -198,7 +199,7 @@ void TemplateParserJobTest::test_processWithTemplatesForBody()
KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
parser->setIdentityManager(identMan);
parser->setAllowDecryption(true);
parser->mOrigMsg = msg;
parser->d->mOrigMsg = msg;
QSignalSpy spy(parser, &TemplateParser::TemplateParserJob::parsingDone);
parser->processWithTemplate(command);
......@@ -287,7 +288,7 @@ void TemplateParserJobTest::test_processWithTemplatesForContent()
KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
parser->setIdentityManager(identMan);
parser->setAllowDecryption(false);
parser->mOrigMsg = msg;
parser->d->mOrigMsg = msg;
QSignalSpy spy(parser, &TemplateParser::TemplateParserJob::parsingDone);
parser->processWithTemplate(command);
QVERIFY(spy.wait());
......@@ -331,7 +332,7 @@ void TemplateParserJobTest::test_processWithTemplatesForContentOtherTimeZone()
KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
parser->setIdentityManager(identMan);
parser->setAllowDecryption(false);
parser->mOrigMsg = msg;
parser->d->mOrigMsg = msg;
QSignalSpy spy(parser, &TemplateParser::TemplateParserJob::parsingDone);
parser->processWithTemplate(command);
QVERIFY(spy.wait());
......
......@@ -47,7 +47,7 @@ add_library(KF5::TemplateParser ALIAS KF5TemplateParser)
target_link_libraries(KF5TemplateParser
PRIVATE
KF5::Mime
KF5::MessageViewer
KF5::MimeTreeParser
KF5::IdentityManagement
KF5::MessageCore
KF5::XmlGui
......
This diff is collapsed.
......@@ -21,18 +21,12 @@
#define TEMPLATEPARSERJOB_H
#include "templateparser_export.h"
#include "templateparserextracthtmlinforesult.h"
#include <MessageViewer/ObjectTreeEmptySource>
#include <KMime/KMimeMessage>
#include <KMime/Message>
#include <QObject>
class TemplateParserTester;
namespace MimeTreeParser {
class ObjectTreeParser;
}
#include <memory>
namespace KIdentityManagement {
class IdentityManager;
......@@ -42,7 +36,10 @@ namespace MessageCore {
class ImageCollector;
}
class TemplateParserExtractHtmlInfoResult;
namespace TemplateParser {
class TemplateParserJobPrivate;
/**
* \brief The TemplateParser transforms a message with a given template.
*
......@@ -367,28 +364,7 @@ private:
*/
void makeValidHtml(QString &body);
friend class ::TemplateParserTester;
Mode mMode;
qint64 mFolder = -1; //Used to find a template
uint mIdentity;
KMime::Message::Ptr mMsg; // Msg to write to
KMime::Message::Ptr mOrigMsg; // Msg to read from
QString mSelection;
bool mAllowDecryption;
bool mDebug;
QString mQuoteString;
QString mTo, mCC;
KIdentityManagement::IdentityManager *m_identityManager = nullptr;
bool mWrap;
int mColWrap;
QStringList m_charsets;
MimeTreeParser::ObjectTreeParser *mOtp = nullptr;
MessageViewer::EmptySource *mEmptySource = nullptr;
QString mHeadElement;
Quotes mQuotes;
TemplateParserExtractHtmlInfoResult mExtractHtmlInfoResult;
bool mForceCursorPosition;
std::unique_ptr<TemplateParserJobPrivate> d;
};
}
......
/*
Copyright (C) 2017 Sandro Knauß <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 TEMPLATEPARSERJOB_P_H
#define TEMPLATEPARSERJOB_P_H
#include "templateparserjob.h"
#include "templateparserextracthtmlinforesult.h"
#include <KMime/Message>
namespace MimeTreeParser {
class ObjectTreeParser;
class SimpleObjectTreeSource;
}
namespace KIdentityManagement {
class IdentityManager;
}
namespace MessageCore {
class ImageCollector;
}
namespace TemplateParser
{
class TemplateParserJobPrivate
{
public:
TemplateParserJobPrivate(const KMime::Message::Ptr &amsg, const TemplateParserJob::Mode amode);
~TemplateParserJobPrivate();
void setAllowDecryption(const bool allowDecryption);
KMime::Message::Ptr mMsg; // Msg to write to
KMime::Message::Ptr mOrigMsg; // Msg to read from
KIdentityManagement::IdentityManager *m_identityManager = nullptr;
MimeTreeParser::ObjectTreeParser *mOtp = nullptr;
MimeTreeParser::SimpleObjectTreeSource *mEmptySource = nullptr;
QString mSelection;
QString mQuoteString = QStringLiteral("> ");
QString mTo;
QString mCC;
QString mHeadElement;
QStringList mCharsets;
TemplateParserJob::Quotes mQuotes = TemplateParserJob::ReplyAsOriginalMessage;
TemplateParserJob::Mode mMode;
TemplateParserExtractHtmlInfoResult mExtractHtmlInfoResult;
qint64 mFolder = -1; //Used to find a template
uint mIdentity = 0;
int mColWrap = 80;
bool mForceCursorPosition = false;
bool mAllowDecryption = true;
bool mDebug = false;
bool mWrap = true;
};
}
#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