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 */
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)
AttachmentPart()
Creates a new attachment part.
void setEncrypted(bool encrypted)
Sets whether the attachment is encrypted.
void setMimeType(const QByteArray &mimeType)
Sets the mimeType of the attachment.
void setSigned(bool sign)
Sets whether the attachment is signed.
AttachmentPart()
Creates a new attachment part.
QSharedPointer< AttachmentPart > Ptr
Defines a pointer to an attachment object.
bool isEncrypted() const
Returns whether the attachment is encrypted.
bool isSigned() const
Returns whether the attachment is signed.
KMime::Headers::contentEncoding encoding() const
Returns the encoding that will be used for the attachment.
QByteArray mimeType() const
Returns the mime type of the attachment.
void setInline(bool value)
Sets whether the attachment will be displayed inline the message.
void setName(const QString &name)
Sets the name of the attachment.
bool isAutoEncoding() const
Returns whether encoding of the attachment will be determined automatically.
QString name() const
Returns the name of the attachment.
void setDescription(const QString &description)
Sets the description of the attachment.
QByteArray charset() const
Returns the charset that will be used for the attachment.
QString fileName() const
Returns the file name of the attachment.
QList< Ptr > List
Defines a list of pointers to attachment objects.
void setAutoEncoding(bool enabled)
Sets whether encoding of the attachment will be determined automatically.
QString description() const
Returns the description of the attachment.
bool isInline() const
Returns whether the attachment will be displayed inline the message.
void setData(const QByteArray &data)
Sets the payload data of the attachment.
qint64 size() const
Returns the size of the attachment.
void setFileName(const QString &name)
Sets the file name of the attachment.
void setCharset(const QByteArray &charset)
Sets the charset that will be used for the attachment.
bool isMessageOrMessageCollection() const
Returns whether the specified attachment part is an encapsulated message (message/rfc822) or a collec...
QByteArray data() const
Returns the payload data of the attachment.
void setCompressed(bool compressed)
Sets whether the attachment is compressed.
bool isCompressed() const
Returns whether the attachment is compressed.
void setEncoding(KMime::Headers::contentEncoding encoding)
Sets the encoding that will be used for the attachment.
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 31 2025 12:05:41 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.