Messagelib

attachmentpart.h
1/*
2 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "messagecore_export.h"
10
11#include <KMime/Headers>
12
13#include <QList>
14#include <QMetaType>
15#include <QSharedPointer>
16
17class QUrl;
18namespace MessageCore
19{
20/**
21 * @short A class that encapsulates an attachment.
22 *
23 * @author Constantin Berzan <exit3219@gmail.com>
24 */
25class MESSAGECORE_EXPORT AttachmentPart
26{
27public:
28 /**
29 * Defines a pointer to an attachment object.
30 */
32
33 /**
34 * Defines a list of pointers to attachment objects.
35 */
37
38 /**
39 * Creates a new attachment part.
40 */
42
43 /**
44 * Destroys the attachment part.
45 */
47
48 /**
49 * Sets the @p name of the attachment.
50 *
51 * The name will be used in the 'name=' part of
52 * the Content-Type header.
53 */
54 void setName(const QString &name);
55
56 /**
57 * Returns the name of the attachment.
58 */
59 [[nodiscard]] QString name() const;
60
61 /**
62 * Sets the file @p name of the attachment.
63 *
64 * The name will be used in the 'filename=' part of
65 * the Content-Disposition header.
66 */
67 void setFileName(const QString &name);
68
69 /**
70 * Returns the file name of the attachment.
71 */
72 [[nodiscard]] QString fileName() const;
73
74 /**
75 * Sets the @p description of the attachment.
76 */
77 void setDescription(const QString &description);
78
79 /**
80 * Returns the description of the attachment.
81 */
82 [[nodiscard]] QString description() const;
83
84 /**
85 * Sets whether the attachment will be displayed inline the message.
86 */
87 void setInline(bool value);
88
89 /**
90 * Returns whether the attachment will be displayed inline the message.
91 */
92 [[nodiscard]] bool isInline() const;
93
94 /**
95 * Sets whether encoding of the attachment will be determined automatically.
96 */
97 void setAutoEncoding(bool enabled);
98
99 /**
100 * Returns whether encoding of the attachment will be determined automatically.
101 */
102 [[nodiscard]] bool isAutoEncoding() const;
103
104 /**
105 * Sets the @p encoding that will be used for the attachment.
106 *
107 * @note only applies if isAutoEncoding is @c false
108 */
109 void setEncoding(KMime::Headers::contentEncoding encoding);
110
111 /**
112 * Returns the encoding that will be used for the attachment.
113 */
114 [[nodiscard]] KMime::Headers::contentEncoding encoding() const;
115
116 /**
117 * Sets the @p charset that will be used for the attachment.
118 */
119 void setCharset(const QByteArray &charset);
120
121 /**
122 * Returns the charset that will be used for the attachment.
123 */
124 [[nodiscard]] QByteArray charset() const;
125
126 /**
127 * Sets the @p mimeType of the attachment.
128 */
129 void setMimeType(const QByteArray &mimeType);
130
131 /**
132 * Returns the mime type of the attachment.
133 */
134 [[nodiscard]] QByteArray mimeType() const;
135
136 /**
137 * Sets whether the attachment is @p compressed.
138 */
139 void setCompressed(bool compressed);
140
141 /**
142 * Returns whether the attachment is compressed.
143 */
144 [[nodiscard]] bool isCompressed() const;
145
146 /**
147 * Sets whether the attachment is @p encrypted.
148 */
149 void setEncrypted(bool encrypted);
150
151 /**
152 * Returns whether the attachment is encrypted.
153 */
154 [[nodiscard]] bool isEncrypted() const;
155
156 /**
157 * Sets whether the attachment is @p signed.
158 */
159 void setSigned(bool sign);
160
161 /**
162 * Returns whether the attachment is signed.
163 */
164 [[nodiscard]] bool isSigned() const;
165
166 /**
167 * Sets the payload @p data of the attachment.
168 */
169 void setData(const QByteArray &data);
170
171 /**
172 * Returns the payload data of the attachment.
173 */
174 [[nodiscard]] QByteArray data() const;
175
176 /**
177 * Returns the size of the attachment.
178 */
179 [[nodiscard]] qint64 size() const;
180
181 /**
182 * Returns whether the specified attachment part is an encapsulated message
183 * (message/rfc822) or a collection of encapsulated messages (multipart/digest)
184 */
185 [[nodiscard]] bool isMessageOrMessageCollection() const;
186
187 void setUrl(const QUrl &url);
188 [[nodiscard]] QUrl url() const;
189
190private:
191 //@cond PRIVATE
192 class AttachmentPartPrivate;
193 AttachmentPartPrivate *const d;
194 //@endcond
195};
196}
197
198Q_DECLARE_METATYPE(MessageCore::AttachmentPart::Ptr)
A class that encapsulates an attachment.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:33:26 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.