KMime

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 "kmime_headers.h"
14#include "kmime_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*/
28KMIME_EXPORT extern bool isUsAscii(const QString &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*/
37KMIME_EXPORT extern 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>
45encodingsForData(const QByteArray &data);
46
47/**
48 Constructs a random string (sans leading/trailing "--") that can
49 be used as a multipart delimiter (ie. as @p boundary parameter
50 to a multipart/... content-type).
51
52 @return the randomized string.
53 @see uniqueString
54*/
55KMIME_EXPORT extern QByteArray multiPartBoundary();
56
57/**
58 Converts all occurrences of "\r\n" (CRLF) in @p s to "\n" (LF).
59
60 This function is expensive and should be used only if the mail
61 will be stored locally. All decode functions can cope with both
62 line endings.
63
64 @param s source string containing CRLF's
65
66 @return the string with CRLF's substituted for LF's
67 @see CRLFtoLF(const char*) LFtoCRLF
68*/
69KMIME_EXPORT extern QByteArray CRLFtoLF(const QByteArray &s);
70
71/**
72 Converts all occurrences of "\r\n" (CRLF) in @p s to "\n" (LF).
73
74 This function is expensive and should be used only if the mail
75 will be stored locally. All decode functions can cope with both
76 line endings.
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*/
83KMIME_EXPORT extern QByteArray CRLFtoLF(const char *s);
84
85/**
86 Converts all occurrences of "\n" (LF) in @p s to "\r\n" (CRLF).
87
88 This function is expensive and should be used only if the mail
89 will be transmitted as an RFC822 message later. All decode
90 functions can cope with and all encode functions can optionally
91 produce both line endings, which is much faster.
92
93 @param s source string containing CRLF's
94
95 @return the string with CRLF's substituted for LF's
96 @see CRLFtoLF(const QByteArray&) LFtoCRLF
97*/
98KMIME_EXPORT extern QByteArray LFtoCRLF(const QByteArray &s);
99
100/**
101 * Returns whether or not the given MIME node is an attachment part.
102 * @param content the MIME node to parse
103 * @see hasAttachment()
104 */
105KMIME_EXPORT bool isAttachment(Content *content);
106
107/**
108 * Returns whether or not the given MIME node contains an attachment part. This function will
109 * recursively parse the MIME tree looking for a suitable attachment and return true if one is found.
110 * @param content the MIME node to parse
111 * @see isAttachment()
112 */
113KMIME_EXPORT bool hasAttachment(Content *content);
114
115/**
116 * Returns whether or not the given MIME node contains an invitation part. This function will
117 * recursively parse the MIME tree looking for a suitable invitation and return true if one is found.
118 * @param content the MIME node to parse
119 * @since 4.14.6
120 */
121KMIME_EXPORT bool hasInvitation(Content *content);
122
123/**
124 * Returns whether or not the given @p message is partly or fully signed.
125 *
126 * @param message the message to check for being signed
127 * @since 4.6
128 */
129KMIME_EXPORT bool isSigned(Message *message);
130
131/**
132 * Returns whether or not the given @p message is partly or fully encrypted.
133 *
134 * @param message the message to check for being encrypted
135 * @since 4.6
136 */
137KMIME_EXPORT bool isEncrypted(Message *message);
138
139/**
140 * Determines if the MIME part @p content is a crypto part.
141 * This is, is either an encrypted part or a signature part.
142 */
143KMIME_EXPORT bool isCryptoPart(Content *content);
144
145/**
146 * Returns whether or not the given MIME @p content is an invitation
147 * message of the iTIP protocol.
148 *
149 * @since 4.6
150 */
151KMIME_EXPORT bool isInvitation(Content *content);
152
153} // namespace KMime
154
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.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:12 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.