Changeset View
Changeset View
Standalone View
Standalone View
mimetreeparser/src/viewer/messagepart.h
Show All 31 Lines | |||||
32 | #include <gpgme++/importresult.h> | 32 | #include <gpgme++/importresult.h> | ||
33 | 33 | | |||
34 | #include <QString> | 34 | #include <QString> | ||
35 | #include <QSharedPointer> | 35 | #include <QSharedPointer> | ||
36 | 36 | | |||
37 | #include <memory> | 37 | #include <memory> | ||
38 | 38 | | |||
39 | class QTextCodec; | 39 | class QTextCodec; | ||
40 | class PartPrivate; | | |||
41 | class TextPartRendered; | 40 | class TextPartRendered; | ||
42 | class AttachmentMessagePartRenderer; | 41 | class AttachmentMessagePartRenderer; | ||
43 | 42 | | |||
44 | namespace GpgME { | 43 | namespace GpgME { | ||
45 | class ImportResult; | 44 | class ImportResult; | ||
46 | } | 45 | } | ||
47 | 46 | | |||
48 | namespace QGpgME { | 47 | namespace QGpgME { | ||
49 | class Protocol; | 48 | class Protocol; | ||
50 | } | 49 | } | ||
51 | 50 | | |||
52 | namespace KMime { | 51 | namespace KMime { | ||
53 | class Content; | 52 | class Content; | ||
54 | } | 53 | } | ||
55 | 54 | | |||
56 | namespace MimeTreeParser { | 55 | namespace MimeTreeParser { | ||
57 | class ObjectTreeParser; | 56 | class ObjectTreeParser; | ||
58 | class HtmlWriter; | 57 | class HtmlWriter; | ||
59 | class HTMLBlock; | | |||
60 | typedef QSharedPointer<HTMLBlock> HTMLBlockPtr; | | |||
61 | class CryptoBodyPartMemento; | 58 | class CryptoBodyPartMemento; | ||
59 | class MessagePartPrivate; | ||||
62 | class MultiPartAlternativeBodyPartFormatter; | 60 | class MultiPartAlternativeBodyPartFormatter; | ||
63 | namespace Interface { | 61 | namespace Interface { | ||
64 | class ObjectTreeSource; | 62 | class ObjectTreeSource; | ||
65 | } | 63 | } | ||
66 | 64 | | |||
67 | class MIMETREEPARSER_EXPORT MessagePart : public Interface::MessagePart | 65 | class MIMETREEPARSER_EXPORT MessagePart : public QObject | ||
68 | { | 66 | { | ||
69 | Q_OBJECT | 67 | Q_OBJECT | ||
68 | Q_PROPERTY(QString plaintextContent READ plaintextContent) | ||||
69 | Q_PROPERTY(QString htmlContent READ htmlContent) | ||||
70 | Q_PROPERTY(bool attachment READ isAttachment) | 70 | Q_PROPERTY(bool attachment READ isAttachment) | ||
71 | Q_PROPERTY(bool root READ isRoot) | 71 | Q_PROPERTY(bool root READ isRoot) | ||
72 | Q_PROPERTY(bool isHtml READ isHtml) | 72 | Q_PROPERTY(bool isHtml READ isHtml) | ||
73 | Q_PROPERTY(bool isHidden READ isHidden) | 73 | Q_PROPERTY(bool isHidden READ isHidden) | ||
74 | public: | 74 | public: | ||
75 | typedef QSharedPointer<MessagePart> Ptr; | 75 | typedef QSharedPointer<MessagePart> Ptr; | ||
76 | MessagePart(ObjectTreeParser *otp, const QString &text); | 76 | MessagePart(ObjectTreeParser *otp, const QString &text); | ||
77 | ~MessagePart(); | ||||
knauss: doesn't it need to be virtual? | |||||
virtual is inherited from QObject here. Technically this should be override, but override on dtors makes some compilers choke. vkrause: virtual is inherited from QObject here. Technically this should be override, but override on… | |||||
77 | 78 | | |||
78 | virtual ~MessagePart(); | 79 | void setParentPart(MessagePart *parentPart); | ||
80 | MessagePart *parentPart() const; | ||||
79 | 81 | | |||
80 | QString text() const override; | 82 | virtual QString text() const; | ||
81 | void setText(const QString &text); | 83 | void setText(const QString &text); | ||
84 | | ||||
85 | virtual QString plaintextContent() const; | ||||
86 | virtual QString htmlContent() const; | ||||
87 | | ||||
82 | void setAttachmentFlag(KMime::Content *node); | 88 | void setAttachmentFlag(KMime::Content *node); | ||
83 | bool isAttachment() const; | 89 | bool isAttachment() const; | ||
84 | 90 | | |||
85 | void setIsRoot(bool root); | 91 | void setIsRoot(bool root); | ||
86 | bool isRoot() const; | 92 | bool isRoot() const; | ||
87 | 93 | | |||
88 | virtual bool isHtml() const; | 94 | virtual bool isHtml() const; | ||
89 | virtual bool isHidden() const; | 95 | virtual bool isHidden() const; | ||
90 | 96 | | |||
91 | PartMetaData *partMetaData(); | 97 | PartMetaData *partMetaData() const; | ||
92 | 98 | | |||
93 | /* only a function that should be removed if the refactoring is over */ | 99 | /* only a function that should be removed if the refactoring is over */ | ||
94 | virtual void fix() const; | 100 | virtual void fix() const; | ||
95 | 101 | | |||
96 | void appendSubPart(const Interface::MessagePart::Ptr &messagePart); | 102 | void appendSubPart(const MessagePart::Ptr &messagePart); | ||
97 | const QVector<Interface::MessagePart::Ptr> &subParts() const; | 103 | const QVector<MessagePart::Ptr> &subParts() const; | ||
98 | bool hasSubParts() const; | 104 | bool hasSubParts() const; | ||
99 | 105 | | |||
100 | Interface::ObjectTreeSource *source() const; | 106 | Interface::ObjectTreeSource *source() const; | ||
101 | KMime::Content *attachmentNode() const; | 107 | KMime::Content *attachmentNode() const; | ||
102 | 108 | | |||
103 | protected: | 109 | protected: | ||
104 | void parseInternal(KMime::Content *node, bool onlyOneMimePart); | 110 | void parseInternal(KMime::Content *node, bool onlyOneMimePart); | ||
105 | QString renderInternalText() const; | 111 | QString renderInternalText() const; | ||
106 | 112 | | |||
107 | QString mText; | | |||
108 | ObjectTreeParser *mOtp = nullptr; | 113 | ObjectTreeParser *mOtp = nullptr; | ||
109 | PartMetaData mMetaData; | | |||
110 | 114 | | |||
111 | private: | 115 | private: | ||
112 | QVector<Interface::MessagePart::Ptr> mBlocks; | 116 | std::unique_ptr<MessagePartPrivate> d; | ||
113 | | ||||
114 | KMime::Content *mAttachmentNode = nullptr; | | |||
115 | bool mRoot; | | |||
116 | }; | 117 | }; | ||
117 | 118 | | |||
118 | // TODO remove once all plugins are ported away from BPF::format() | 119 | // TODO remove once all plugins are ported away from BPF::format() | ||
119 | class MIMETREEPARSER_DEPRECATED_EXPORT LegacyPluginMessagePart : public Interface::MessagePart | 120 | class MIMETREEPARSER_DEPRECATED_EXPORT LegacyPluginMessagePart : public Interface::MessagePart | ||
120 | { | 121 | { | ||
121 | Q_OBJECT | 122 | Q_OBJECT | ||
122 | public: | 123 | public: | ||
123 | LegacyPluginMessagePart(); | 124 | LegacyPluginMessagePart(MimeTreeParser::ObjectTreeParser *otp); | ||
124 | ~LegacyPluginMessagePart(); | 125 | ~LegacyPluginMessagePart(); | ||
125 | 126 | | |||
126 | HtmlWriter *htmlWriter() const; | 127 | HtmlWriter *htmlWriter() const; | ||
127 | QString formatOutput() const; | 128 | QString formatOutput() const; | ||
128 | 129 | | |||
129 | private: | 130 | private: | ||
130 | std::unique_ptr<HtmlWriter> m_htmlWriter; | 131 | std::unique_ptr<HtmlWriter> m_htmlWriter; | ||
131 | }; | 132 | }; | ||
Show All 10 Lines | 137 | public: | |||
142 | 143 | | |||
143 | QString plaintextContent() const override; | 144 | QString plaintextContent() const override; | ||
144 | QString htmlContent() const override; | 145 | QString htmlContent() const override; | ||
145 | private: | 146 | private: | ||
146 | KMime::Content *mNode; | 147 | KMime::Content *mNode; | ||
147 | bool mOnlyOneMimePart; | 148 | bool mOnlyOneMimePart; | ||
148 | 149 | | |||
149 | friend class AlternativeMessagePart; | 150 | friend class AlternativeMessagePart; | ||
150 | friend class ::PartPrivate; | | |||
knauss: please keep them, these are for the new planned interface | |||||
knauss: okay lets kill them for the moment | |||||
151 | }; | 151 | }; | ||
152 | 152 | | |||
153 | class MIMETREEPARSER_EXPORT MessagePartList : public MessagePart | 153 | class MIMETREEPARSER_EXPORT MessagePartList : public MessagePart | ||
154 | { | 154 | { | ||
155 | Q_OBJECT | 155 | Q_OBJECT | ||
156 | public: | 156 | public: | ||
157 | typedef QSharedPointer<MessagePartList> Ptr; | 157 | typedef QSharedPointer<MessagePartList> Ptr; | ||
158 | MessagePartList(MimeTreeParser::ObjectTreeParser *otp); | 158 | MessagePartList(MimeTreeParser::ObjectTreeParser *otp); | ||
159 | virtual ~MessagePartList(); | 159 | virtual ~MessagePartList(); | ||
160 | 160 | | |||
161 | QString text() const override; | 161 | QString text() const override; | ||
162 | 162 | | |||
163 | QString plaintextContent() const override; | 163 | QString plaintextContent() const override; | ||
164 | QString htmlContent() const override; | 164 | QString htmlContent() const override; | ||
165 | private: | | |||
166 | }; | 165 | }; | ||
167 | 166 | | |||
168 | enum IconType { | 167 | enum IconType { | ||
169 | NoIcon = 0, | 168 | NoIcon = 0, | ||
170 | IconExternal, | 169 | IconExternal, | ||
171 | IconInline | 170 | IconInline | ||
172 | }; | 171 | }; | ||
173 | 172 | | |||
Show All 25 Lines | 194 | private: | |||
199 | KMMsgEncryptionState mEncryptionState; | 198 | KMMsgEncryptionState mEncryptionState; | ||
200 | bool mDrawFrame; | 199 | bool mDrawFrame; | ||
201 | bool mShowLink; | 200 | bool mShowLink; | ||
202 | bool mDecryptMessage; | 201 | bool mDecryptMessage; | ||
203 | bool mIsHidden; | 202 | bool mIsHidden; | ||
204 | 203 | | |||
205 | friend class ::TextPartRendered; | 204 | friend class ::TextPartRendered; | ||
206 | friend class ::AttachmentMessagePartRenderer; | 205 | friend class ::AttachmentMessagePartRenderer; | ||
207 | friend class DefaultRendererPrivate; | | |||
208 | friend class ObjectTreeParser; | 206 | friend class ObjectTreeParser; | ||
209 | friend class ::PartPrivate; | | |||
210 | }; | 207 | }; | ||
211 | 208 | | |||
212 | class MIMETREEPARSER_EXPORT AttachmentMessagePart : public TextMessagePart | 209 | class MIMETREEPARSER_EXPORT AttachmentMessagePart : public TextMessagePart | ||
213 | { | 210 | { | ||
214 | Q_OBJECT | 211 | Q_OBJECT | ||
215 | public: | 212 | public: | ||
216 | typedef QSharedPointer<AttachmentMessagePart> Ptr; | 213 | typedef QSharedPointer<AttachmentMessagePart> Ptr; | ||
217 | AttachmentMessagePart(MimeTreeParser::ObjectTreeParser *otp, KMime::Content *node, bool drawFrame, bool showLink, bool decryptMessage); | 214 | AttachmentMessagePart(MimeTreeParser::ObjectTreeParser *otp, KMime::Content *node, bool drawFrame, bool showLink, bool decryptMessage); | ||
Show All 27 Lines | |||||
245 | 242 | | |||
246 | private: | 243 | private: | ||
247 | KMime::Content *mNode; | 244 | KMime::Content *mNode; | ||
248 | Interface::ObjectTreeSource *mSource; | 245 | Interface::ObjectTreeSource *mSource; | ||
249 | QString mBodyHTML; | 246 | QString mBodyHTML; | ||
250 | QByteArray mCharset; | 247 | QByteArray mCharset; | ||
251 | 248 | | |||
252 | friend class DefaultRendererPrivate; | 249 | friend class DefaultRendererPrivate; | ||
253 | friend class ::PartPrivate; | | |||
254 | }; | 250 | }; | ||
255 | 251 | | |||
256 | class MIMETREEPARSER_EXPORT AlternativeMessagePart : public MessagePart | 252 | class MIMETREEPARSER_EXPORT AlternativeMessagePart : public MessagePart | ||
257 | { | 253 | { | ||
258 | Q_OBJECT | 254 | Q_OBJECT | ||
259 | public: | 255 | public: | ||
260 | typedef QSharedPointer<AlternativeMessagePart> Ptr; | 256 | typedef QSharedPointer<AlternativeMessagePart> Ptr; | ||
261 | AlternativeMessagePart(MimeTreeParser::ObjectTreeParser *otp, KMime::Content *node, Util::HtmlMode preferredMode); | 257 | AlternativeMessagePart(MimeTreeParser::ObjectTreeParser *otp, KMime::Content *node, Util::HtmlMode preferredMode); | ||
Show All 17 Lines | 272 | private: | |||
279 | Util::HtmlMode mPreferredMode; | 275 | Util::HtmlMode mPreferredMode; | ||
280 | 276 | | |||
281 | QMap<Util::HtmlMode, KMime::Content *> mChildNodes; | 277 | QMap<Util::HtmlMode, KMime::Content *> mChildNodes; | ||
282 | QMap<Util::HtmlMode, MimeMessagePart::Ptr> mChildParts; | 278 | QMap<Util::HtmlMode, MimeMessagePart::Ptr> mChildParts; | ||
283 | 279 | | |||
284 | friend class DefaultRendererPrivate; | 280 | friend class DefaultRendererPrivate; | ||
285 | friend class ObjectTreeParser; | 281 | friend class ObjectTreeParser; | ||
286 | friend class MultiPartAlternativeBodyPartFormatter; | 282 | friend class MultiPartAlternativeBodyPartFormatter; | ||
287 | friend class ::PartPrivate; | | |||
288 | }; | 283 | }; | ||
289 | 284 | | |||
290 | class MIMETREEPARSER_EXPORT CertMessagePart : public MessagePart | 285 | class MIMETREEPARSER_EXPORT CertMessagePart : public MessagePart | ||
291 | { | 286 | { | ||
292 | Q_OBJECT | 287 | Q_OBJECT | ||
293 | public: | 288 | public: | ||
294 | typedef QSharedPointer<CertMessagePart> Ptr; | 289 | typedef QSharedPointer<CertMessagePart> Ptr; | ||
295 | CertMessagePart(MimeTreeParser::ObjectTreeParser *otp, KMime::Content *node, const QGpgME::Protocol *cryptoProto, bool autoImport); | 290 | CertMessagePart(MimeTreeParser::ObjectTreeParser *otp, KMime::Content *node, const QGpgME::Protocol *cryptoProto, bool autoImport); | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 360 | protected: | |||
368 | const QGpgME::Protocol *mCryptoProto; | 363 | const QGpgME::Protocol *mCryptoProto; | ||
369 | QString mFromAddress; | 364 | QString mFromAddress; | ||
370 | KMime::Content *mNode = nullptr; | 365 | KMime::Content *mNode = nullptr; | ||
371 | bool mDecryptMessage; | 366 | bool mDecryptMessage; | ||
372 | QByteArray mVerifiedText; | 367 | QByteArray mVerifiedText; | ||
373 | std::vector<GpgME::DecryptionResult::Recipient> mDecryptRecipients; | 368 | std::vector<GpgME::DecryptionResult::Recipient> mDecryptRecipients; | ||
374 | 369 | | |||
375 | friend class DefaultRendererPrivate; | 370 | friend class DefaultRendererPrivate; | ||
376 | friend class ::PartPrivate; | | |||
377 | }; | 371 | }; | ||
378 | 372 | | |||
379 | class MIMETREEPARSER_EXPORT SignedMessagePart : public MessagePart | 373 | class MIMETREEPARSER_EXPORT SignedMessagePart : public MessagePart | ||
380 | { | 374 | { | ||
381 | Q_OBJECT | 375 | Q_OBJECT | ||
382 | Q_PROPERTY(bool isSigned READ isSigned) | 376 | Q_PROPERTY(bool isSigned READ isSigned) | ||
383 | public: | 377 | public: | ||
384 | typedef QSharedPointer<SignedMessagePart> Ptr; | 378 | typedef QSharedPointer<SignedMessagePart> Ptr; | ||
Show All 27 Lines | |||||
412 | protected: | 406 | protected: | ||
413 | const QGpgME::Protocol *mCryptoProto; | 407 | const QGpgME::Protocol *mCryptoProto; | ||
414 | QString mFromAddress; | 408 | QString mFromAddress; | ||
415 | KMime::Content *mNode = nullptr; | 409 | KMime::Content *mNode = nullptr; | ||
416 | QByteArray mVerifiedText; | 410 | QByteArray mVerifiedText; | ||
417 | 411 | | |||
418 | friend EncryptedMessagePart; | 412 | friend EncryptedMessagePart; | ||
419 | friend class DefaultRendererPrivate; | 413 | friend class DefaultRendererPrivate; | ||
420 | friend class ::PartPrivate; | | |||
421 | }; | 414 | }; | ||
422 | } | 415 | } | ||
423 | 416 | | |||
424 | #endif //__MIMETREEPARSER_MESSAGEPART_H__ | 417 | #endif //__MIMETREEPARSER_MESSAGEPART_H__ |
doesn't it need to be virtual?