summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/mime/mimetreeparser/otp/autotests/setupenv.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-23 21:00:50 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-23 21:00:50 +0200
commit31bf3102fe8f8cdd3f1448f0f22f182d0c2820d2 (patch)
treeb5b508c3f065e0f51c8ce40aaf97d7070b5f9ef5 /framework/src/domain/mime/mimetreeparser/otp/autotests/setupenv.h
parent1948369d4da2d0bc23b6af93683982b0e65d4992 (diff)
downloadkube-31bf3102fe8f8cdd3f1448f0f22f182d0c2820d2.tar.gz
kube-31bf3102fe8f8cdd3f1448f0f22f182d0c2820d2.zip
Moved MIME related stuff to a mime subdir
Diffstat (limited to 'framework/src/domain/mime/mimetreeparser/otp/autotests/setupenv.h')
-rw-r--r--framework/src/domain/mime/mimetreeparser/otp/autotests/setupenv.h175
1 files changed, 175 insertions, 0 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/otp/autotests/setupenv.h b/framework/src/domain/mime/mimetreeparser/otp/autotests/setupenv.h
new file mode 100644
index 00000000..3582853e
--- /dev/null
+++ b/framework/src/domain/mime/mimetreeparser/otp/autotests/setupenv.h
@@ -0,0 +1,175 @@
1/*
2 Copyright (C) 2010 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com
3 Copyright (c) 2010 Leo Franchi <lfranchi@kde.org>
4
5 This library is free software; you can redistribute it and/or modify it
6 under the terms of the GNU Library General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or (at your
8 option) any later version.
9
10 This library is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 02110-1301, USA.
19*/
20
21#ifndef MESSAGECORE_TESTS_UTIL_H
22#define MESSAGECORE_TESTS_UTIL_H
23
24#include <gpgme++/key.h>
25#include <attachmentstrategy.h>
26#include <bodypartformatter.h>
27#include <bodypartformatterbasefactory.h>
28#include <messagepartrenderer.h>
29#include <objecttreesource.h>
30
31namespace MimeTreeParser
32{
33
34namespace Test
35{
36
37/**
38* setup a environment variables for tests:
39* * set LC_ALL to C
40* * set KDEHOME
41*/
42void setupEnv();
43
44// We can't use EmptySource, since we need to control some emelnets of the source for tests to also test
45// loadExternal and htmlMail.
46class TestObjectTreeSource : public MimeTreeParser::Interface::ObjectTreeSource
47{
48public:
49 TestObjectTreeSource(MimeTreeParser::HtmlWriter *writer)
50 : mWriter(writer)
51 , mAttachmentStrategy(QStringLiteral("smart"))
52 , mPreferredMode(Util::Html)
53 , mHtmlLoadExternal(false)
54 , mDecryptMessage(false)
55 {
56 }
57
58 MimeTreeParser::HtmlWriter *htmlWriter() Q_DECL_OVERRIDE {
59 return mWriter;
60 }
61
62 bool htmlLoadExternal() const Q_DECL_OVERRIDE
63 {
64 return mHtmlLoadExternal;
65 }
66
67 void setHtmlLoadExternal(bool loadExternal)
68 {
69 mHtmlLoadExternal = loadExternal;
70 }
71
72 void setAttachmentStrategy(QString strategy)
73 {
74 mAttachmentStrategy = strategy;
75 }
76
77 const AttachmentStrategy *attachmentStrategy() Q_DECL_OVERRIDE {
78 return AttachmentStrategy::create(mAttachmentStrategy);
79 }
80
81 bool autoImportKeys() const Q_DECL_OVERRIDE
82 {
83 return true;
84 }
85
86 bool showEmoticons() const Q_DECL_OVERRIDE
87 {
88 return false;
89 }
90
91 bool showExpandQuotesMark() const Q_DECL_OVERRIDE
92 {
93 return false;
94 }
95
96 const BodyPartFormatterBaseFactory *bodyPartFormatterFactory() Q_DECL_OVERRIDE {
97 return &mBodyPartFormatterBaseFactory;
98 }
99
100 bool decryptMessage() const Q_DECL_OVERRIDE
101 {
102 return mDecryptMessage;
103 }
104
105 void setAllowDecryption(bool allowDecryption)
106 {
107 mDecryptMessage = allowDecryption;
108 }
109
110 void setShowSignatureDetails(bool showSignatureDetails)
111 {
112 mShowSignatureDetails = showSignatureDetails;
113 }
114
115 bool showSignatureDetails() const Q_DECL_OVERRIDE
116 {
117 return mShowSignatureDetails;
118 }
119
120 void setHtmlMode(MimeTreeParser::Util::HtmlMode mode, const QList<MimeTreeParser::Util::HtmlMode> &availableModes) Q_DECL_OVERRIDE {
121 Q_UNUSED(mode);
122 Q_UNUSED(availableModes);
123 }
124
125 MimeTreeParser::Util::HtmlMode preferredMode() const Q_DECL_OVERRIDE
126 {
127 return mPreferredMode;
128 }
129
130 void setPreferredMode(MimeTreeParser::Util::HtmlMode mode)
131 {
132 mPreferredMode = mode;
133 }
134
135 int levelQuote() const Q_DECL_OVERRIDE
136 {
137 return 1;
138 }
139
140 const QTextCodec *overrideCodec() Q_DECL_OVERRIDE {
141 return nullptr;
142 }
143
144 QString createMessageHeader(KMime::Message *message) Q_DECL_OVERRIDE {
145 Q_UNUSED(message);
146 return QString(); //do nothing
147 }
148
149 QObject *sourceObject() Q_DECL_OVERRIDE {
150 return nullptr;
151 }
152
153 Interface::MessagePartRenderer::Ptr messagePartTheme(Interface::MessagePart::Ptr msgPart) Q_DECL_OVERRIDE {
154 Q_UNUSED(msgPart);
155 return Interface::MessagePartRenderer::Ptr();
156 }
157 bool isPrinting() const Q_DECL_OVERRIDE
158 {
159 return false;
160 }
161private:
162 MimeTreeParser::HtmlWriter *mWriter;
163 QString mAttachmentStrategy;
164 BodyPartFormatterBaseFactory mBodyPartFormatterBaseFactory;
165 MimeTreeParser::Util::HtmlMode mPreferredMode;
166 bool mHtmlLoadExternal;
167 bool mDecryptMessage;
168 bool mShowSignatureDetails;
169};
170
171}
172
173}
174
175#endif