summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--framework/domain/CMakeLists.txt1
-rw-r--r--framework/domain/csshelper.cpp64
-rw-r--r--framework/domain/csshelper.h44
-rw-r--r--framework/domain/mailtemplates.cpp5
-rw-r--r--framework/domain/messageparser.cpp5
-rw-r--r--framework/domain/objecttreesource.cpp10
-rw-r--r--framework/domain/objecttreesource.h4
7 files changed, 4 insertions, 129 deletions
diff --git a/framework/domain/CMakeLists.txt b/framework/domain/CMakeLists.txt
index 39a47111..d64aebc5 100644
--- a/framework/domain/CMakeLists.txt
+++ b/framework/domain/CMakeLists.txt
@@ -5,7 +5,6 @@ set(mailplugin_SRCS
5 actions/sinkactions.cpp 5 actions/sinkactions.cpp
6 objecttreesource.cpp 6 objecttreesource.cpp
7 stringhtmlwriter.cpp 7 stringhtmlwriter.cpp
8 csshelper.cpp
9 composercontroller.cpp 8 composercontroller.cpp
10 messageparser.cpp 9 messageparser.cpp
11 mailtemplates.cpp 10 mailtemplates.cpp
diff --git a/framework/domain/csshelper.cpp b/framework/domain/csshelper.cpp
deleted file mode 100644
index 8b61ddcc..00000000
--- a/framework/domain/csshelper.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
1/*
2 csshelper.cpp
3
4 This file is part of KMail, the KDE mail client.
5 Copyright (c) 2003 Marc Mutz <mutz@kde.org>
6
7 KMail is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License, version 2, as
9 published by the Free Software Foundation.
10
11 KMail is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 In addition, as a special exception, the copyright holders give
21 permission to link the code of this program with any edition of
22 the Qt library by Trolltech AS, Norway (or with modified versions
23 of Qt that use the same license as Qt), and distribute linked
24 combinations including the two. You must obey the GNU General
25 Public License in all respects for all of the code used other than
26 Qt. If you modify this file, you may extend this exception to
27 your version of the file, but you are not obligated to do so. If
28 you do not wish to do so, delete this exception statement from
29 your version.
30*/
31
32#include "csshelper.h"
33
34#include <QColor>
35#include <QDebug>
36#include <QFile>
37#include <QFont>
38#include <QFont>
39#include <QPalette>
40
41CSSHelper::CSSHelper(const QPaintDevice *pd) :
42 MimeTreeParser::CSSHelperBase(pd)
43{
44
45}
46
47QString cssDefinitions()
48{
49 QFile file(QLatin1String(MAIL_DATA_DIR) + QLatin1Char('/') + "mail.css");
50 if (file.open(QFile::ReadOnly)) {
51 return file.readAll();
52 }
53 return QString();
54}
55
56QString CSSHelper::htmlHead(bool fixed) const
57{
58 return
59 QLatin1String("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n"
60 "<html><head><title></title><style>\n")
61 + ::cssDefinitions() +
62 QLatin1String("</style></head>\n"
63 "<body>\n");
64} \ No newline at end of file
diff --git a/framework/domain/csshelper.h b/framework/domain/csshelper.h
deleted file mode 100644
index 7be0faa5..00000000
--- a/framework/domain/csshelper.h
+++ /dev/null
@@ -1,44 +0,0 @@
1/* -*- c++ -*-
2 csshelper.h
3
4 This file is part of KMail, the KDE mail client.
5 Copyright (c) 2003 Marc Mutz <mutz@kde.org>
6
7 KMail is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License, version 2, as
9 published by the Free Software Foundation.
10
11 KMail is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
20 In addition, as a special exception, the copyright holders give
21 permission to link the code of this program with any edition of
22 the Qt library by Trolltech AS, Norway (or with modified versions
23 of Qt that use the same license as Qt), and distribute linked
24 combinations including the two. You must obey the GNU General
25 Public License in all respects for all of the code used other than
26 Qt. If you modify this file, you may extend this exception to
27 your version of the file, but you are not obligated to do so. If
28 you do not wish to do so, delete this exception statement from
29 your version.
30*/
31
32#pragma once
33
34#include <MimeTreeParser/CSSHelperBase>
35
36class CSSHelper : public MimeTreeParser::CSSHelperBase
37{
38public:
39 explicit CSSHelper(const QPaintDevice *pd);
40
41 /** @return HTML head including style sheet definitions and the
42 &gt;body&lt; tag */
43 QString htmlHead(bool fixedFont = false) const Q_DECL_OVERRIDE;
44}; \ No newline at end of file
diff --git a/framework/domain/mailtemplates.cpp b/framework/domain/mailtemplates.cpp
index 9b0dab5d..6af381d2 100644
--- a/framework/domain/mailtemplates.cpp
+++ b/framework/domain/mailtemplates.cpp
@@ -35,7 +35,6 @@
35 35
36#include "stringhtmlwriter.h" 36#include "stringhtmlwriter.h"
37#include "objecttreesource.h" 37#include "objecttreesource.h"
38#include "csshelper.h"
39 38
40#include <MimeTreeParser/ObjectTreeParser> 39#include <MimeTreeParser/ObjectTreeParser>
41 40
@@ -757,10 +756,8 @@ KMime::Message::Ptr MailTemplates::reply(const KMime::Message::Ptr &origMsg)
757 756
758 //TODO set empty source instead 757 //TODO set empty source instead
759 StringHtmlWriter htmlWriter; 758 StringHtmlWriter htmlWriter;
760 QImage paintDevice;
761 CSSHelper cssHelper(&paintDevice);
762 MimeTreeParser::NodeHelper nodeHelper; 759 MimeTreeParser::NodeHelper nodeHelper;
763 ObjectTreeSource source(&htmlWriter, &cssHelper); 760 ObjectTreeSource source(&htmlWriter);
764 MimeTreeParser::ObjectTreeParser otp(&source, &nodeHelper); 761 MimeTreeParser::ObjectTreeParser otp(&source, &nodeHelper);
765 otp.setAllowAsync(false); 762 otp.setAllowAsync(false);
766 otp.parseObjectTree(origMsg.data()); 763 otp.parseObjectTree(origMsg.data());
diff --git a/framework/domain/messageparser.cpp b/framework/domain/messageparser.cpp
index 7be5e052..8363e119 100644
--- a/framework/domain/messageparser.cpp
+++ b/framework/domain/messageparser.cpp
@@ -20,7 +20,6 @@
20 20
21#include "stringhtmlwriter.h" 21#include "stringhtmlwriter.h"
22#include "objecttreesource.h" 22#include "objecttreesource.h"
23#include "csshelper.h"
24 23
25#include <QFile> 24#include <QFile>
26#include <QImage> 25#include <QImage>
@@ -170,11 +169,9 @@ void MessageParser::setMessage(const QVariant &message)
170 169
171 // render the mail 170 // render the mail
172 StringHtmlWriter htmlWriter; 171 StringHtmlWriter htmlWriter;
173 QImage paintDevice;
174 CSSHelper cssHelper(&paintDevice);
175 //temporary files only have the lifetime of the nodehelper, so we keep it around until the mail changes. 172 //temporary files only have the lifetime of the nodehelper, so we keep it around until the mail changes.
176 mNodeHelper = std::make_shared<MimeTreeParser::NodeHelper>(); 173 mNodeHelper = std::make_shared<MimeTreeParser::NodeHelper>();
177 ObjectTreeSource source(&htmlWriter, &cssHelper); 174 ObjectTreeSource source(&htmlWriter);
178 MimeTreeParser::ObjectTreeParser otp(&source, mNodeHelper.get()); 175 MimeTreeParser::ObjectTreeParser otp(&source, mNodeHelper.get());
179 176
180 otp.parseObjectTree(msg.data()); 177 otp.parseObjectTree(msg.data());
diff --git a/framework/domain/objecttreesource.cpp b/framework/domain/objecttreesource.cpp
index 19a216c9..12cf88ab 100644
--- a/framework/domain/objecttreesource.cpp
+++ b/framework/domain/objecttreesource.cpp
@@ -29,7 +29,6 @@ class ObjectSourcePrivate
29public: 29public:
30 ObjectSourcePrivate() 30 ObjectSourcePrivate()
31 : mWriter(0) 31 : mWriter(0)
32 , mCSSHelper(0)
33 , mAllowDecryption(true) 32 , mAllowDecryption(true)
34 , mHtmlLoadExternal(true) 33 , mHtmlLoadExternal(true)
35 , mHtmlMail(true) 34 , mHtmlMail(true)
@@ -37,20 +36,17 @@ public:
37 36
38 } 37 }
39 MimeTreeParser::HtmlWriter *mWriter; 38 MimeTreeParser::HtmlWriter *mWriter;
40 MimeTreeParser::CSSHelperBase *mCSSHelper;
41 MimeTreeParser::BodyPartFormatterBaseFactory mBodyPartFormatterBaseFactory; 39 MimeTreeParser::BodyPartFormatterBaseFactory mBodyPartFormatterBaseFactory;
42 bool mAllowDecryption; 40 bool mAllowDecryption;
43 bool mHtmlLoadExternal; 41 bool mHtmlLoadExternal;
44 bool mHtmlMail; 42 bool mHtmlMail;
45}; 43};
46 44
47ObjectTreeSource::ObjectTreeSource(MimeTreeParser::HtmlWriter *writer, 45ObjectTreeSource::ObjectTreeSource(MimeTreeParser::HtmlWriter *writer)
48 MimeTreeParser::CSSHelperBase *cssHelper)
49 : MimeTreeParser::Interface::ObjectTreeSource() 46 : MimeTreeParser::Interface::ObjectTreeSource()
50 , d(new ObjectSourcePrivate) 47 , d(new ObjectSourcePrivate)
51 { 48 {
52 d->mWriter = writer; 49 d->mWriter = writer;
53 d->mCSSHelper = cssHelper;
54 } 50 }
55 51
56ObjectTreeSource::~ObjectTreeSource() 52ObjectTreeSource::~ObjectTreeSource()
@@ -67,10 +63,6 @@ MimeTreeParser::HtmlWriter *ObjectTreeSource::htmlWriter()
67{ 63{
68 return d->mWriter; 64 return d->mWriter;
69} 65}
70MimeTreeParser::CSSHelperBase *ObjectTreeSource::cssHelper()
71{
72 return d->mCSSHelper;
73}
74 66
75bool ObjectTreeSource::htmlLoadExternal() const 67bool ObjectTreeSource::htmlLoadExternal() const
76{ 68{
diff --git a/framework/domain/objecttreesource.h b/framework/domain/objecttreesource.h
index eceb04d3..bb0cd679 100644
--- a/framework/domain/objecttreesource.h
+++ b/framework/domain/objecttreesource.h
@@ -28,8 +28,7 @@ class ObjectSourcePrivate;
28class ObjectTreeSource : public MimeTreeParser::Interface::ObjectTreeSource 28class ObjectTreeSource : public MimeTreeParser::Interface::ObjectTreeSource
29{ 29{
30public: 30public:
31 ObjectTreeSource(MimeTreeParser::HtmlWriter *writer, 31 ObjectTreeSource(MimeTreeParser::HtmlWriter *writer);
32 MimeTreeParser::CSSHelperBase *cssHelper);
33 virtual ~ObjectTreeSource(); 32 virtual ~ObjectTreeSource();
34 void setHtmlLoadExternal(bool loadExternal); 33 void setHtmlLoadExternal(bool loadExternal);
35 void setHtmlMail(bool htmlMail); 34 void setHtmlMail(bool htmlMail);
@@ -44,7 +43,6 @@ public:
44 QString createMessageHeader(KMime::Message *message) Q_DECL_OVERRIDE; 43 QString createMessageHeader(KMime::Message *message) Q_DECL_OVERRIDE;
45 const MimeTreeParser::AttachmentStrategy *attachmentStrategy() Q_DECL_OVERRIDE; 44 const MimeTreeParser::AttachmentStrategy *attachmentStrategy() Q_DECL_OVERRIDE;
46 MimeTreeParser::HtmlWriter *htmlWriter() Q_DECL_OVERRIDE; 45 MimeTreeParser::HtmlWriter *htmlWriter() Q_DECL_OVERRIDE;
47 MimeTreeParser::CSSHelperBase *cssHelper() Q_DECL_OVERRIDE;
48 QObject *sourceObject() Q_DECL_OVERRIDE; 46 QObject *sourceObject() Q_DECL_OVERRIDE;
49 bool autoImportKeys() const Q_DECL_OVERRIDE; 47 bool autoImportKeys() const Q_DECL_OVERRIDE;
50 bool showEmoticons() const Q_DECL_OVERRIDE; 48 bool showEmoticons() const Q_DECL_OVERRIDE;