diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-29 16:17:04 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-06-04 12:57:04 +0200 |
commit | e452707fdfbd61be1e5633b516b653b7337e7865 (patch) | |
tree | 1e1d4b48ebf8d381f292436f2ba04b8763edc5de /framework/src/domain/mime/mimetreeparser/bodypartformatter.h | |
parent | 5a1033bdace740799a6e03389bee30e5a4de5d44 (diff) | |
download | kube-e452707fdfbd61be1e5633b516b653b7337e7865.tar.gz kube-e452707fdfbd61be1e5633b516b653b7337e7865.zip |
Reduced the messagetreeparser to aproximately what we actually require
While in a much more managable state it's still not pretty.
However, further refactoring can now gradually happen as we need to do
further work on it.
Things that should happen eventually:
* Simplify the logic that creates the messageparts (we don't need the whole formatter plugin complexity)
* Get rid of the nodehelper (let the parts hold the necessary data)
* Get rid of partmetadata (let the part handleit)
Diffstat (limited to 'framework/src/domain/mime/mimetreeparser/bodypartformatter.h')
-rw-r--r-- | framework/src/domain/mime/mimetreeparser/bodypartformatter.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/bodypartformatter.h b/framework/src/domain/mime/mimetreeparser/bodypartformatter.h new file mode 100644 index 00000000..7e1fc74e --- /dev/null +++ b/framework/src/domain/mime/mimetreeparser/bodypartformatter.h | |||
@@ -0,0 +1,96 @@ | |||
1 | /* -*- mode: C++; c-file-style: "gnu" -*- | ||
2 | bodypartformatter.h | ||
3 | |||
4 | This file is part of KMail's plugin interface. | ||
5 | Copyright (c) 2004 Marc Mutz <mutz@kde.org>, | ||
6 | Ingo Kloecker <kloecker@kde.org> | ||
7 | |||
8 | KMail is free software; you can redistribute it and/or modify it | ||
9 | under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | KMail is distributed in the hope that it will be useful, but | ||
14 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
21 | |||
22 | In addition, as a special exception, the copyright holders give | ||
23 | permission to link the code of this program with any edition of | ||
24 | the Qt library by Trolltech AS, Norway (or with modified versions | ||
25 | of Qt that use the same license as Qt), and distribute linked | ||
26 | combinations including the two. You must obey the GNU General | ||
27 | Public License in all respects for all of the code used other than | ||
28 | Qt. If you modify this file, you may extend this exception to | ||
29 | your version of the file, but you are not obligated to do so. If | ||
30 | you do not wish to do so, delete this exception statement from | ||
31 | your version. | ||
32 | */ | ||
33 | |||
34 | #ifndef __MIMETREEPARSER_INTERFACE_BODYPARTFORMATTER_H__ | ||
35 | #define __MIMETREEPARSER_INTERFACE_BODYPARTFORMATTER_H__ | ||
36 | |||
37 | #include <QObject> | ||
38 | #include <QSharedPointer> | ||
39 | |||
40 | #include "objecttreeparser.h" | ||
41 | #include "messagepart.h" | ||
42 | |||
43 | namespace MimeTreeParser | ||
44 | { | ||
45 | |||
46 | namespace Interface | ||
47 | { | ||
48 | |||
49 | class BodyPartURLHandler; | ||
50 | class BodyPart; | ||
51 | |||
52 | class BodyPartFormatter | ||
53 | { | ||
54 | public: | ||
55 | virtual ~BodyPartFormatter() {} | ||
56 | |||
57 | /** | ||
58 | @li Ok returned when format() generated some HTML | ||
59 | @li NeedContent returned when format() needs the body of the part | ||
60 | @li AsIcon returned when the part should be shown iconified | ||
61 | @li Failed returned when formatting failed. Currently equivalent to Ok | ||
62 | */ | ||
63 | enum Result { Ok, NeedContent, AsIcon, Failed }; | ||
64 | |||
65 | virtual MessagePart::Ptr process(BodyPart &part) const; | ||
66 | }; | ||
67 | |||
68 | /** | ||
69 | @short interface for BodyPartFormatter plugins | ||
70 | |||
71 | The interface is queried by for types, subtypes, and the | ||
72 | corresponding bodypart formatter, and the result inserted into | ||
73 | the bodypart formatter factory. | ||
74 | |||
75 | Subtype alone or both type and subtype may be "*", which is | ||
76 | taken as a wildcard, so that e.g. type=text subtype=* matches | ||
77 | any text subtype, but with lesser specificity than a concrete | ||
78 | mimetype such as text/plain. type=* is only allowed when | ||
79 | subtype=*, too. | ||
80 | */ | ||
81 | class BodyPartFormatterPlugin | ||
82 | { | ||
83 | public: | ||
84 | virtual ~BodyPartFormatterPlugin() {} | ||
85 | |||
86 | virtual const BodyPartFormatter *bodyPartFormatter(int idx) const = 0; | ||
87 | virtual const char *type(int idx) const = 0; | ||
88 | virtual const char *subtype(int idx) const = 0; | ||
89 | |||
90 | virtual const BodyPartURLHandler *urlHandler(int idx) const = 0; | ||
91 | }; | ||
92 | |||
93 | } // namespace Interface | ||
94 | |||
95 | } | ||
96 | #endif // __MIMETREEPARSER_INTERFACE_BODYPARTFORMATTER_H__ | ||