KMime

content.h
Go to the documentation of this file.
1/*
2 KMime, the KDE Internet mail/usenet news message library.
3 SPDX-FileCopyrightText: 2001 the KMime authors.
4 See file AUTHORS for details
5 SPDX-FileCopyrightText: 2006 Volker Krause <vkrause@kde.org>
6 SPDX-FileCopyrightText: 2009 Constantin Berzan <exit3219@gmail.com>
7
8 SPDX-License-Identifier: LGPL-2.0-or-later
9*/
10/**
11 @file
12 This file is part of the API for handling @ref MIME data and
13 defines the Content class.
14
15 @brief
16 Defines the Content class.
17
18 @authors the KMime authors (see AUTHORS file),
19 Volker Krause <vkrause@kde.org>
20
21TODO: possible glossary terms:
22 content
23 encoding, transfer type, disposition, description
24 header
25 body
26 attachment
27 charset
28 article
29 string representation
30 broken-down object representation
31*/
32
33#pragma once
34
35#include "kmime_export.h"
36#include "contentindex.h"
37#include "util.h"
38#include "headers.h"
39
40#include <QByteArray>
41#include <QList>
42#include <QMetaType>
43#include <QSharedPointer>
44
45#include <span>
46
47namespace KMime
48{
49
50///@cond internal
51namespace Internal {
52
53template <typename T>
54class OwningConstPtrSpan : public std::span<const T *const> {
55public:
56 explicit inline OwningConstPtrSpan(const QList<T*> &list)
57 : std::span<const T *const>(static_cast<const T* const*>(list.constData()), list.size())
58 , m_list(list)
59 {}
60private:
61 QList<T*> m_list;
62};
63}
64///@endcond
65
66class ContentPrivate;
67class Message;
68
69/**
70 @brief
71 A class that encapsulates @ref MIME encoded Content.
72
73 A Content object holds two representations of a content:
74 - the string representation: This is the content encoded as a string ready
75 for transport. Accessible through the encodedContent() method.
76 - the broken-down representation: This is the tree of objects (headers,
77 sub-Contents and (if present) the encapsulated message) that this Content is made of.
78 Accessible through methods like header(), contents() and bodyAsMessage().
79
80 The parse() function updates the broken-down representation of the Content
81 from its string representation. Calling it is necessary to access the
82 headers, sub-Contents or the encapsulated message of this Content.
83
84 The assemble() function updates the string representation of the Content
85 from its broken-down representation. Calling it is necessary for
86 encodedContent() to reflect any changes made to the broken-down representation of the Content.
87
88 There are two basic types of a Content:
89 - A leaf Content: This is a content that is neither a multipart content nor an encapsulated
90 message. Because of this, it will not have any children, it has no sub-contents
91 and is therefore a leaf content.
92 Only leaf contents have a body that is not empty, i.e. functions that operate
93 on the body, such as body(), size() and decodedContent(), will work only on
94 leaf contents.
95 - A non-leaf Content: This is a content that itself doesn't have any body, but that does have
96 sub-contents.
97 This is the case for contents that are of mimetype multipart/ or of mimetype
98 message/rfc822. In case of a multipart content, contents() will return the
99 multipart child contents. In case of an encapsulated message, the message
100 can be accessed with bodyAsMessage(), and contents() will have one entry
101 that is the message as well.
102 On a non-leaf content, body() will have an empty return value and other
103 functions working on the body will not work.
104 A call to parse() is required before the child multipart contents or the
105 encapsulated message is created.
106*/
107class KMIME_EXPORT Content
108{
109public:
110
111 /**
112 Describes a list of Content objects.
113 */
115
116 /**
117 Creates an empty Content object with a specified parent.
118 @param parent the parent Content object
119 @since 4.3
120 */
121 explicit Content(Content *parent = nullptr);
122
123 /**
124 Destroys this Content object.
125 */
126 virtual ~Content();
127
128 /**
129 Returns true if this Content object is not empty.
130 */
131 [[nodiscard]] bool hasContent() const;
132
133 /**
134 Sets the Content to the given raw data, containing the Content head and
135 body separated by two linefeeds.
136
137 This method operates on the string representation of the Content. Call
138 parse() if you want to access individual headers, sub-Contents or the
139 encapsulated message.
140
141 @note The passed data must not contain any CRLF sequences, only LF.
142 Use CRLFtoLF for conversion before passing in the data.
143
144 @param s is a QByteArray containing the raw Content data.
145 */
146 void setContent(const QByteArray &s);
147
148 /**
149 * Parses the Content.
150 *
151 * This means the broken-down object representation of the Content is
152 * updated from the string representation of the Content.
153 *
154 * Call this if you want to access or change headers, sub-Contents or the
155 * encapsulated message.
156 *
157 * @note Calling parse() twice will not work for multipart contents or for
158 * contents of which the body is an encapsulated message. The reason is that
159 * the first parse() will delete the body, so there is no body to work on for
160 * the second call of parse().
161 *
162 * @note Calling this will reset the message returned by bodyAsMessage(), as
163 * the message is re-parsed as well.
164 * Also, all old sub-contents will be deleted, so any old Content
165 * pointer will become invalid.
166 */
167 void parse();
168
169 /**
170 Returns whether this Content is frozen.
171 A frozen content is immutable, i.e. calling assemble() will never modify
172 its head or body, and encodedContent() will return the same data before
173 and after parsing.
174
175 @since 4.4.
176 @see setFrozen().
177 */
178 [[nodiscard]] bool isFrozen() const;
179
180 /**
181 Freezes this Content if @p frozen is true; otherwise unfreezes it.
182 @param frozen freeze content if @c true, otherwise unfreeze
183 @since 4.4
184 @see isFrozen().
185 */
186 void setFrozen(bool frozen = true);
187
188 /**
189 Generates the MIME content.
190 This means the string representation of this Content is updated from the
191 broken-down object representation.
192 Call this if you have made changes to the content, and want
193 encodedContent() to reflect those changes.
194
195 @note assemble() has no effect if the Content isFrozen(). You may want
196 to freeze, for instance, signed sub-Contents, to make sure they are kept
197 unmodified.
198
199 @note If this content is an encapsulated message, i.e. bodyIsMessage()
200 returns true, then calling assemble() will also assemble the message
201 returned by bodyAsMessage().
202
203 @warning assemble() may change the order of the headers, and other
204 details such as where folding occurs. This may break things like
205 signature verification, so you should *ONLY* call assemble() when you
206 have actually modified the content.
207 */
208 void assemble();
209
210 /**
211 Clears the content, deleting all headers and sub-Contents.
212 */
213 void clear();
214
215 /**
216 Removes all sub-Contents from this content. Deletes them if @p del is true.
217 This is different from calling removeContent() on each sub-Content, because
218 removeContent() will convert this to a single-part Content if only one
219 sub-Content is left. Calling clearContents() does NOT make this Content
220 single-part.
221
222 @param del Whether to delete the sub-Contents.
223 @see removeContent()
224 @since 4.4
225 */
226 void clearContents(bool del = true);
227
228 /**
229 Returns the Content header raw data.
230
231 @see setHead().
232 */
233 [[nodiscard]] QByteArray head() const;
234
235 /**
236 Sets the Content header raw data.
237
238 This method operates on the string representation of the Content. Call
239 parse() if you want to access individual headers.
240
241 @param head is a QByteArray containing the header data.
242
243 @see head().
244 */
245 void setHead(const QByteArray &head);
246
247 /**
248 * Returns all headers.
249 * @since 5.7
250 */
251 [[nodiscard]] QList<Headers::Base *> headers();
252 [[nodiscard]] inline auto headers() const -> auto
253 {
254 return Internal::OwningConstPtrSpan<Headers::Base>(const_cast<Content*>(this)->headers());
255 }
256
257 /**
258 Returns the first header of type @p type, if it exists. Otherwise returns
259 0. Note that the returned header may be empty.
260 @param type the header type to find
261 @since 4.2
262 */
263 [[nodiscard]] Headers::Base *headerByType(QByteArrayView type) const;
264
265 /**
266 Returns the first header of type T, if it exists.
267 If the header does not exist and @p create is true, creates an empty header
268 and returns it. Otherwise returns 0.
269 Note that the returned header may be empty.
270 @param create Whether to create the header if it does not exist.
271 @since 4.4.
272
273 KDE5: BIC: FIXME: Why is the default argument false here? That is
274 inconsistent with the methods in KMime::Message!
275 */
276 template <typename T> T *header(bool create = false);
277 /**
278 Returns the first header of type @tparam T.
279
280 Can be @c nullptr if such a header doesn't exist.
281 @since 24.08
282 */
283 template <typename T> [[nodiscard]] T *header() const;
284
285 /**
286 Returns all @p type headers in the Content.
287 Take care that this result is not cached, so could be slow.
288 @param type the header type to find
289 @since 4.2
290 */
291 [[nodiscard]] QList<Headers::Base *> headersByType(QByteArrayView type) const;
292
293 /**
294 Sets the specified header to this Content.
295 Any previous header of the same type is removed.
296 If you need multiple headers of the same type, use appendHeader() or
297 prependHeader().
298
299 @param h The header to set.
300 @see appendHeader()
301 @see removeHeader()
302 @since 4.4
303 */
304 void setHeader(Headers::Base *h);
305
306 /**
307 Appends the specified header to the headers of this Content.
308 @param h The header to append.
309 @since 4.4
310 */
311 void appendHeader(Headers::Base *h);
312
313 /**
314 Searches for the first header of type @p type, and deletes it, removing
315 it from this Content.
316 @param type The type of the header to look for.
317 @return true if a header was found and removed.
318 */
319 bool removeHeader(QByteArrayView type);
320
321 /**
322 Searches for the first header of type @p T, and deletes it, removing
323 it from this Content.
324 @tparam T The type of the header to look for.
325 @return true if a header was found and removed.
326 */
327 template <typename T> bool removeHeader();
328
329 /**
330 @return true if this Content has a header of type @p type.
331 @param type The type of the header to look for.
332 */
333 // TODO probably provide hasHeader<T>() too.
334 [[nodiscard]] bool hasHeader(QByteArrayView type) const;
335
336 /**
337 Returns the Content-Type header.
338
339 @param create If true, create the header if it doesn't exist yet.
340 */
341 Headers::ContentType *contentType(bool create = true);
342 /**
343 Returns the Content-Type header.
344
345 Can be @c nullptr if the header doesn't exist.
346 @since 24.08
347 */
348 [[nodiscard]] const Headers::ContentType *contentType() const;
349
350 /**
351 Returns the Content-Transfer-Encoding header.
352
353 @param create If true, create the header if it doesn't exist yet.
354 */
356 /**
357 Returns the Content-Transfer-Encoding header.
358
359 Can be @c nullptr if the header doesn't exist.
360 @since 24.08
361 */
363
364 /**
365 Returns the Content-Disposition header.
366
367 @param create If true, create the header if it doesn't exist yet.
368 */
370 /**
371 Returns the Content-Disposition header.
372
373 Can be @c nullptr if the header doesn't exist.
374 @since 24.08
375 */
377
378 /**
379 Returns the Content-Description header.
380
381 @param create If true, create the header if it doesn't exist yet.
382 */
384 /**
385 Returns the Content-Description header.
386
387 Can be @c nullptr if the header doesn't exist.
388 @since 24.08
389 */
391
392 /**
393 Returns the Content-Location header.
394
395 @param create If true, create the header if it doesn't exist yet.
396 @since 4.2
397 */
399 /**
400 Returns the Content-Location header.
401
402 Can be @c nullptr if the header doesn't exist.
403 @since 24.08
404 */
405 [[nodiscard]] const Headers::ContentLocation *contentLocation() const;
406
407 /**
408 Returns the Content-ID header.
409 @param create if true, create the header if it does not exist yet.
410 @since 4.4
411 */
412 Headers::ContentID *contentID(bool create = true);
413 /**
414 Returns the Content-ID header.
415
416 Can be @c nullptr if the header doesn't exist.
417 @since 24.08
418 */
419 [[nodiscard]] const Headers::ContentID *contentID() const;
420
421 /**
422 Returns the size of the Content body after encoding.
423 (If the encoding is quoted-printable, this is only an approximate size.)
424 This will return 0 for multipart contents or for encapsulated messages.
425 */
426 [[nodiscard]] qsizetype size() const;
427
428 /**
429 Returns the size of this Content and all sub-Contents.
430 */
431 [[nodiscard]] qsizetype storageSize() const;
432
433 /**
434 Returns the Content body raw data.
435
436 Note that this will be empty for multipart contents or for encapsulated
437 messages, after parse() has been called.
438
439 @see setBody().
440 */
441 [[nodiscard]] QByteArray body() const;
442
443 /**
444 Sets the Content decoded body raw data.
445
446 This method operates on the string representation of the Content. Call
447 parse() if you want to access individual sub-Contents or the encapsulated
448 message.
449
450 @param body is a QByteArray containing the body data.
451
452 @note @p body is assumed to be decoded as far as the content transfer encoding
453 is concerned.
454
455 @see setEncodedBody()
456 */
457 void setBody(const QByteArray &body);
458
459 /**
460 Sets the Content body raw data encoded according to the content transfer encoding.
461
462 This method operates on the string representation of the Content. Call
463 parse() if you want to access individual sub-Contents or the encapsulated
464 message.
465
466 @param body is a QByteArray containing the body data.
467
468 @note @p body is assumed to be encoded as far as the content transfer encoding
469 is concerned.
470
471 @since 24.08
472
473 @see setBody()
474 */
475 void setEncodedBody(const QByteArray &body);
476
477 /**
478 Returns the MIME preamble.
479
480 @return a QByteArray containing the MIME preamble.
481
482 @since 4.9
483 */
484 [[nodiscard]] QByteArray preamble() const;
485
486 /**
487 Sets the MIME preamble.
488
489 @param preamble a QByteArray containing what will be used as the
490 MIME preamble.
491
492 @since 4.9
493 */
494
495 void setPreamble(const QByteArray &preamble);
496
497 /**
498 Returns the MIME preamble.
499
500 @return a QByteArray containing the MIME epilogue.
501
502 @since 4.9
503 */
504 [[nodiscard]] QByteArray epilogue() const;
505
506 /**
507 Sets the MIME preamble.
508
509 @param epilogue a QByteArray containing what will be used as the
510 MIME epilogue.
511
512 @since 4.9
513 */
514 void setEpilogue(const QByteArray &epilogue);
515
516 /**
517 Returns a QByteArray containing the encoded Content, including the
518 Content header and all sub-Contents.
519
520 If you make changes to the broken-down representation of the message, be
521 sure to first call assemble() before calling encodedContent(), otherwise
522 the result will not be up-to-date.
523
524 If this content is an encapsulated message, i.e. bodyIsMessage() returns
525 true, then encodedContent() will use the message returned by bodyAsMessage()
526 as the body of the result, calling encodedContent() on the message.
527
528 @param useCrLf If true, use @ref CRLF instead of @ref LF for linefeeds.
529 */
530 [[nodiscard]] QByteArray encodedContent(bool useCrLf = false) const;
531
532 /**
533 * Like encodedContent(), with the difference that only the body will be
534 * returned, i.e. the headers are excluded.
535 *
536 * @since 4.6
537 */
538 [[nodiscard]] QByteArray encodedBody() const;
539
540 /**
541 * Returns the decoded Content body.
542 *
543 * Note that this will be empty for multipart contents or for encapsulated
544 * messages, after parse() has been called.
545 */
546 // TODO: KDE5: BIC: Rename this to decodedBody(), since only the body is
547 // returned. In contrast, setContent() sets the head and the body! Also, try
548 // to make this const.
549 [[nodiscard]] QByteArray decodedContent() const;
550
551 /** Options for Content::decodedText().
552 * @since 24.12
553 */
555 NoTrim, ///< do not trim text content.
556 TrimNewlines, ///< trim trailing newlines
557 TrimSpaces, ///< trim any trailing whitespaces
558 };
559
560 /**
561 Returns the decoded text. Additional to decodedContent(), this also
562 applies charset decoding. If this is not a text Content, decodedText()
563 returns an empty QString.
564
565 @param trimOption Control how to trim trailing white spaces.
566 The last trailing new line of the decoded text is always removed.
567
568 @since 24.12
569 */
570 [[nodiscard]] QString decodedText(DecodedTextTrimOption trimOption = NoTrim) const;
571
572 /**
573 Returns the decoded text. Additional to decodedContent(), this also
574 applies charset decoding. If this is not a text Content, decodedText()
575 returns an empty QString.
576
577 @param trimText If true, then the decoded text will have all trailing
578 whitespace removed.
579 @param removeTrailingNewlines If true, then the decoded text will have
580 all consecutive trailing newlines removed.
581
582 The last trailing new line of the decoded text is always removed.
583
584 @deprecated since 24.12, use decodedText(DecodedTextTrimOption) instead.
585 */
586 [[deprecated("use decodedText(DecodedTextTrimOption) instead")]]
587 [[nodiscard]] inline QString decodedText(bool trimText, bool removeTrailingNewlines = false) const
588 {
589 return decodedText(trimText ? TrimSpaces : removeTrailingNewlines ? TrimNewlines : NoTrim);
590 }
591
592 /**
593 Sets the Content body to the given string using charset of the content type.
594
595 If the charset can not be found, the system charset is taken and the content
596 type header is changed to that charset. The charset of the content type
597 header should be set to a charset that can encode the given string before
598 calling this method.
599
600 This method does not set the content transfer encoding automatically, it
601 needs to be set to a suitable value that can encode the given string before
602 calling this method.
603
604 This method only makes sense for single-part contents, do not try to pass a
605 multipart body or an encapsulated message here, that wouldn't work.
606
607 @param s Unicode-encoded string.
608 */
609 void fromUnicodeString(const QString &s);
610
611 /**
612 Returns the first Content with mimetype text/.
613 */
614 [[nodiscard]] Content *textContent();
615 /**
616 Returns the first Content with MIME type text/.
617 Const overload of the above, the returned Content cannot be modified.
618 @since 24.08
619 */
620 [[nodiscard]] const Content *textContent() const;
621
622 /**
623 * Returns all attachments below this node, recursively.
624 * This does not include crypto parts, nodes of alternative or related
625 * multipart nodes, or the primary body part (see textContent()).
626 * @see KMime::isAttachment(), KMime::hasAttachment()
627 */
628 [[nodiscard]] QList<Content *> attachments();
629 [[nodiscard]] inline auto attachments() const -> auto {
630 return Internal::OwningConstPtrSpan<Content>(const_cast<Content*>(this)->attachments());
631 }
632
633 /**
634 * For multipart contents, this will return a list of all multipart child
635 * contents. For contents that are of mimetype message/rfc822, this will
636 * return a list with one entry, and that entry is the encapsulated message,
637 * as it would be returned by bodyAsMessage().
638 */
639 [[nodiscard]] QList<Content *> contents();
640 [[nodiscard]] inline auto contents() const -> auto {
641 return Internal::OwningConstPtrSpan<Content>(const_cast<Content*>(this)->contents());
642 }
643
644 /**
645 Appends a new sub-Content. If the sub-Content is already part of another
646 Content object, it is removed from there and its parent is updated.
647
648 @param content The new sub-Content.
649 @see prependContent()
650 @see takeContent()
651 @since 6.0
652 */
653 void appendContent(Content *content);
654 /**
655 Prepends a new sub-Content. If the sub-Content is already part of another
656 Content object, it is removed from there and its parent is updated.
657
658 @param content The new sub-Content.
659 @see appendContent()
660 @see takeContent()
661 @since 6.0
662 */
663 void prependContent(Content *content);
664
665 void replaceContent(Content *oldContent, Content *newContent);
666 /**
667 Removes the given sub-Content and, if that actually was a sub-content
668 returns that.
669
670 @param content The Content to remove. It is not deleted, ownership goes
671 back to the caller.
672
673 @see appendContent()
674 @see prependContent()
675 @see clearContents()
676 @since 6.0
677 */
678 Content *takeContent(Content *content);
679
680 /**
681 Changes the encoding of this Content to @p e. If the Content is binary,
682 this actually re-encodes the data to use the new encoding.
683
684 @param e The new encoding to use.
685 */
686 void changeEncoding(Headers::contentEncoding e);
687
688 /**
689 Returns the Content specified by the given index.
690 If the index does not point to a Content, 0 is returned. If the index
691 is invalid (empty), this Content is returned.
692
693 @param index The Content index.
694 */
695 [[nodiscard]] Content *content(const ContentIndex &index) const;
696
697 /**
698 Returns the ContentIndex for the given Content, or an invalid index
699 if the Content is not found within the hierarchy.
700 @param content the Content object to search.
701 */
702 [[nodiscard]] ContentIndex indexForContent(Content *content) const;
703
704 /**
705 Returns true if this is the top-level node in the MIME tree. The top-level
706 node is always a Message or NewsArticle. However, a node can be a Message
707 without being a top-level node when it is an encapsulated message.
708 */
709 [[nodiscard]] bool isTopLevel() const;
710
711 /**
712 * Sets a new parent to the Content and add to its contents list. If it
713 * already had a parent, it is removed from the old parents contents list.
714 * @param parent the new parent
715 * @since 4.3
716 */
717 void setParent(Content *parent);
718
719 /**
720 * Returns the parent content object, or 0 if the content doesn't have a
721 * parent.
722 * @since 4.3
723 */
724 [[nodiscard]] Content *parent();
725 [[nodiscard]] const Content *parent() const;
726
727 /**
728 * Returns the toplevel content object, 0 if there is no such object.
729 * @since 4.3
730 */
731 [[nodiscard]] Content *topLevel();
732 [[nodiscard]] const Content *topLevel() const;
733
734
735 /**
736 * Returns the index of this Content based on the topLevel() object.
737 * @since 4.3
738 */
739 [[nodiscard]] ContentIndex index() const;
740
741 /**
742 * @return true if this content is an encapsulated message, i.e. if it has the
743 * mimetype message/rfc822.
744 *
745 * @since 4.5
746 */
747 // AK_REVIEW: move to MessageViewer/ObjectTreeParser
748 [[nodiscard]] bool bodyIsMessage() const;
749
750 /**
751 * If this content is an encapsulated message, in which case bodyIsMessage()
752 * will return true, the message represented by the body of this content will
753 * be returned. The returned message is already fully parsed. Calling this
754 * method is the aquivalent of calling contents().first() and casting the
755 * result to a KMime::Message*. bodyAsMessage() has the advantage that it will
756 * return a shared pointer that will not be destroyed when the container
757 * message is destroyed or re-parsed.
758 *
759 * The message that is returned here is created when calling parse(), so make
760 * sure to call parse() first. Since each parse() creates a new message
761 * object, a different message object will be returned each time you call
762 * parse().
763 *
764 * If you make changes to the returned message, you need to call assemble() on
765 * this content or on the message if you want that encodedContent() reflects
766 * these changes. This also means that calling assemble() on this content will
767 * assemble the returned message.
768 *
769 * @since 4.5
770 */
771 [[nodiscard]] QSharedPointer<Message> bodyAsMessage();
772 [[nodiscard]] inline QSharedPointer<const Message> bodyAsMessage() const
773 {
774 return qSharedPointerCast<const Message>(const_cast<Content*>(this)->bodyAsMessage());
775 }
776
777protected:
778 /**
779 Reimplement this method if you need to assemble additional headers in a
780 derived class. Don't forget to call the implementation of the base class.
781 @return The raw, assembled headers.
782 */
783 virtual QByteArray assembleHeaders();
784
785 //@cond PRIVATE
786 ContentPrivate *d_ptr;
787 //@endcond
788
789private:
790 Q_DECLARE_PRIVATE(Content)
791 Q_DISABLE_COPY(Content)
792};
793
794template <typename T> T *Content::header(bool create)
795{
796 Headers::Base *h = headerByType(T::staticType());
797 if (h) {
798 // Make sure the header is actually of the right type.
799 Q_ASSERT(dynamic_cast<T *>(h));
800 } else if (create) {
801 h = new T;
802 appendHeader(h); // we already know the header doesn't exist yet
803 }
804 return static_cast<T *>(h);
805}
806
807template <typename T> T *Content::header() const
808{
809 Headers::Base *h = headerByType(T::staticType());
810 if (h) {
811 // Make sure the header is actually of the right type.
812 Q_ASSERT(dynamic_cast<T *>(h));
813 }
814 return static_cast<T *>(h);
815}
816
817template <typename T> bool Content::removeHeader()
818{
819 return removeHeader(T::staticType());
820}
821
822} // namespace KMime
823
824Q_DECLARE_METATYPE(KMime::Content*)
825
A class that encapsulates MIME encoded Content.
Definition content.h:108
Headers::ContentDescription * contentDescription(bool create=true)
Returns the Content-Description header.
bool removeHeader()
Searches for the first header of type T, and deletes it, removing it from this Content.
Definition content.h:817
Headers::ContentType * contentType(bool create=true)
Returns the Content-Type header.
QString decodedText(bool trimText, bool removeTrailingNewlines=false) const
Returns the decoded text.
Definition content.h:587
const Headers::ContentType * contentType() const
Returns the Content-Type header.
const Headers::ContentLocation * contentLocation() const
Returns the Content-Location header.
T * header() const
Returns the first header of type.
Definition content.h:807
QList< KMime::Content * > List
Describes a list of Content objects.
Definition content.h:114
Headers::Base * headerByType(QByteArrayView type) const
Returns the first header of type type, if it exists.
Definition content.cpp:568
Headers::ContentTransferEncoding * contentTransferEncoding(bool create=true)
Returns the Content-Transfer-Encoding header.
Headers::ContentDisposition * contentDisposition(bool create=true)
Returns the Content-Disposition header.
const Headers::ContentID * contentID() const
Returns the Content-ID header.
const Headers::ContentTransferEncoding * contentTransferEncoding() const
Returns the Content-Transfer-Encoding header.
Headers::ContentID * contentID(bool create=true)
Returns the Content-ID header.
const Headers::ContentDisposition * contentDisposition() const
Returns the Content-Disposition header.
DecodedTextTrimOption
Options for Content::decodedText().
Definition content.h:554
@ TrimSpaces
trim any trailing whitespaces
Definition content.h:557
@ NoTrim
do not trim text content.
Definition content.h:555
@ TrimNewlines
trim trailing newlines
Definition content.h:556
Headers::ContentLocation * contentLocation(bool create=true)
Returns the Content-Location header.
void appendHeader(Headers::Base *h)
Appends the specified header to the headers of this Content.
Definition content.cpp:599
const Headers::ContentDescription * contentDescription() const
Returns the Content-Description header.
Baseclass of all header-classes.
Definition headers.h:97
Represents a "Content-Description" header.
Definition headers.h:1240
Represents a "Content-Disposition" header.
Definition headers.h:1145
Represents a "Content-ID" header.
Definition headers.h:941
Represents a "Content-Location" header.
Definition headers.h:1249
Represents a "Content-Transfer-Encoding" header.
Definition headers.h:868
Represents a "Content-Type" header.
Definition headers.h:989
This file is part of the API for handling MIME data and defines the ContentIndex class.
This file is part of the API for handling MIME data and defines the various header classes:
KIOCORE_EXPORT QStringList list(const QString &fileClass)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:05:57 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.