summaryrefslogtreecommitdiffstats
path: root/framework/src/domain/mime/mimetreeparser/bodypart.h
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/domain/mime/mimetreeparser/bodypart.h')
-rw-r--r--framework/src/domain/mime/mimetreeparser/bodypart.h159
1 files changed, 159 insertions, 0 deletions
diff --git a/framework/src/domain/mime/mimetreeparser/bodypart.h b/framework/src/domain/mime/mimetreeparser/bodypart.h
new file mode 100644
index 00000000..1d8b5826
--- /dev/null
+++ b/framework/src/domain/mime/mimetreeparser/bodypart.h
@@ -0,0 +1,159 @@
1/* -*- mode: C++; c-file-style: "gnu" -*-
2 bodypart.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_INTERFACES_BODYPART_H__
35#define __MIMETREEPARSER_INTERFACES_BODYPART_H__
36
37#include <QByteArray>
38#include <QString>
39
40namespace KMime
41{
42class Content;
43}
44
45namespace MimeTreeParser
46{
47class NodeHelper;
48class ObjectTreeParser;
49
50namespace Interface
51{
52
53
54/**
55 @short interface of classes that implement status for BodyPartFormatters.
56*/
57class BodyPartMemento
58{
59public:
60 virtual ~BodyPartMemento();
61
62 virtual void detach() = 0;
63};
64
65/**
66 @short interface of message body parts.
67*/
68class BodyPart
69{
70public:
71 virtual ~BodyPart();
72
73 /**
74 @return a string respresentation of an URL that can be used
75 to invoke a BodyPartURLHandler for this body part.
76 */
77 virtual QString makeLink(const QString &path) const = 0;
78
79 /**
80 @return the decoded (CTE, canonicalisation, and charset
81 encoding undone) text contained in the body part, or
82 QString(), it the body part is not of type "text".
83 */
84 virtual QString asText() const = 0;
85
86 /**
87 @return the decoded (CTE undone) content of the body part, or
88 a null array if this body part instance is of type text.
89 */
90 virtual QByteArray asBinary() const = 0;
91
92 /**
93 @return the value of the content-type header field parameter
94 with name \a parameter, or QString(), if that that
95 parameter is not present in the body's content-type header
96 field. RFC 2231 encoding is removed first.
97
98 Note that this method will suppress queries to certain
99 standard parameters (most notably "charset") to keep plugins
100 decent.
101
102 Note2 that this method preserves the case of the parameter
103 value returned. So, if the parameter you want to use defines
104 the value to be case-insensitive (such as the smime-type
105 parameter), you need to make sure you do the casemap yourself
106 before comparing to a reference value.
107 */
108 virtual QString contentTypeParameter(const char *parameter) const = 0;
109
110 /**
111 @return the content of the content-description header field,
112 or QString() if that header is not present in this body
113 part. RFC 2047 encoding is decoded first.
114 */
115 virtual QString contentDescription() const = 0;
116
117 //virtual int contentDisposition() const = 0;
118 /**
119 @return the value of the content-disposition header field
120 parameter with name \a parameter, or QString() if that
121 parameter is not present in the body's content-disposition
122 header field. RFC 2231 encoding is removed first.
123
124 The notes made for contentTypeParameter() above apply here as
125 well.
126 */
127 virtual QString contentDispositionParameter(const char *parameter) const = 0;
128
129 /** Returns the KMime::Content node represented here. Makes most of the above obsolete
130 and probably should be used in the interfaces in the first place.
131 */
132 virtual KMime::Content *content() const = 0;
133
134 /**
135 * Returns the top-level content.
136 * Note that this is _not_ necessarily the same as content()->topLevel(), for example the later
137 * will not work for "extra nodes", i.e. nodes in encrypted parts of the mail.
138 * topLevelContent() will return the correct result in this case. Also note that
139 * topLevelContent()
140 */
141 virtual KMime::Content *topLevelContent() const = 0;
142
143 /**
144 * Ok, this is ugly, exposing the node helper here, but there is too much useful stuff in there
145 * for real-world plugins. Still, there should be a nicer way for this.
146 */
147 virtual MimeTreeParser::NodeHelper *nodeHelper() const = 0;
148
149 /**
150 * For making it easier to refactor, add objectTreeParser
151 */
152 virtual MimeTreeParser::ObjectTreeParser *objectTreeParser() const = 0;
153};
154
155} // namespace Interface
156
157}
158
159#endif // __MIMETREEPARSER_INTERFACES_BODYPART_H__