KMime

util.h
1/* -*- c++ -*-
2 kmime_util.h
3
4 KMime, the KDE Internet mail/usenet news message library.
5 SPDX-FileCopyrightText: 2001 the KMime authors.
6 See file AUTHORS for details
7
8 SPDX-License-Identifier: LGPL-2.0-or-later
9*/
10#pragma once
11
12#include "kmime_export.h"
13#include "headers.h"
14#include "content.h"
15
16#include <QList>
17#include <QString>
18
19namespace KMime
20{
21
22class Message;
23
24/**
25 Checks whether @p s contains any non-us-ascii characters.
26 @param s
27*/
28[[nodiscard]] KMIME_EXPORT bool isUsAscii(QStringView s);
29
30/**
31 Returns a user-visible string for a contentEncoding, for example
32 "quoted-printable" for CEquPr.
33 @param enc the contentEncoding to return string for
34 @ since 4.4
35 TODO should they be i18n'ed?
36*/
37[[nodiscard]] KMIME_EXPORT QString nameForEncoding(KMime::Headers::contentEncoding enc);
38
39/**
40 Returns a list of encodings that can correctly encode the @p data.
41 @param data the data to check encodings for
42 @ since 4.4
43*/
44[[nodiscard]] KMIME_EXPORT QList<KMime::Headers::contentEncoding> encodingsForData(QByteArrayView data);
45
46/**
47 Constructs a random string (sans leading/trailing "--") that can
48 be used as a multipart delimiter (ie. as @p boundary parameter
49 to a multipart/... content-type).
50
51 @return the randomized string.
52 @see uniqueString
53*/
54[[nodiscard]] KMIME_EXPORT QByteArray multiPartBoundary();
55
56/**
57 Converts all occurrences of "\r\n" (CRLF) in @p s to "\n" (LF).
58
59 This function is expensive and should be used only if the mail
60 will be stored locally. All decode functions can cope with both
61 line endings.
62
63 @param s source string containing CRLF's
64
65 @return the string with CRLF's substituted for LF's
66 @see LFtoCRLF
67*/
68[[nodiscard]] KMIME_EXPORT QByteArray CRLFtoLF(const QByteArray &s);
69
70/**
71 Converts all occurrences of "\n" (LF) in @p s to "\r\n" (CRLF).
72
73 This function is expensive and should be used only if the mail
74 will be transmitted as an RFC822 message later. All decode
75 functions can cope with and all encode functions can optionally
76 produce both line endings, which is much faster.
77
78 @param s source string containing CRLF's
79
80 @return the string with CRLF's substituted for LF's
81 @see CRLFtoLF(const QByteArray&) LFtoCRLF
82*/
83[[nodiscard]] KMIME_EXPORT QByteArray LFtoCRLF(const QByteArray &s);
84
85/**
86 * Returns whether or not the given MIME node is an attachment part.
87 * @param content the MIME node to parse
88 * @see hasAttachment()
89 */
90[[nodiscard]] KMIME_EXPORT bool isAttachment(const Content *content);
91
92/**
93 * Returns whether or not the given MIME node contains an attachment part. This function will
94 * recursively parse the MIME tree looking for a suitable attachment and return true if one is found.
95 * @param content the MIME node to parse
96 * @see isAttachment()
97 */
98[[nodiscard]] KMIME_EXPORT bool hasAttachment(const Content *content);
99
100/**
101 * Returns whether or not the given MIME node contains an invitation part. This function will
102 * recursively parse the MIME tree looking for a suitable invitation and return true if one is found.
103 * @param content the MIME node to parse
104 * @since 4.14.6
105 */
106[[nodiscard]] KMIME_EXPORT bool hasInvitation(const Content *content);
107
108/**
109 * Returns whether or not the given @p message is partly or fully signed.
110 *
111 * @param message the message to check for being signed
112 * @since 4.6
113 */
114[[nodiscard]] KMIME_EXPORT bool isSigned(const Message *message);
115
116/**
117 * Returns whether or not the given @p message is partly or fully encrypted.
118 *
119 * @param message the message to check for being encrypted
120 * @since 4.6
121 */
122[[nodiscard]] KMIME_EXPORT bool isEncrypted(const Message *message);
123
124/**
125 * Determines if the MIME part @p content is a crypto part.
126 * This is, is either an encrypted part or a signature part.
127 */
128[[nodiscard]] KMIME_EXPORT bool isCryptoPart(const Content *content);
129
130/**
131 * Returns whether or not the given MIME @p content is an invitation
132 * message of the iTIP protocol.
133 *
134 * @since 4.6
135 */
136[[nodiscard]] KMIME_EXPORT bool isInvitation(const Content *content);
137
138} // namespace KMime
139
This file is part of the API for handling MIME data and defines the Content class.
This file is part of the API for handling MIME data and defines the various header classes:
contentEncoding
Various possible values for the "Content-Transfer-Encoding" header.
Definition headers.h:52
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.