File indexing completed on 2024-05-12 05:17:24

0001 /**********************************************************************
0002  *
0003  *   rfccodecs  - handler for various rfc/mime encodings
0004  *   Copyright (C) 2000 s.carstens@gmx.de
0005  *
0006  *   This library is free software; you can redistribute it and/or
0007  *   modify it under the terms of the GNU Library General Public
0008  *   License as published by the Free Software Foundation; either
0009  *   version 2 of the License, or (at your option) any later version.
0010  *
0011  *   This library is distributed in the hope that it will be useful,
0012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  *   Library General Public License for more details.
0015  *
0016  *   You should have received a copy of the GNU Library General Public License
0017  *   along with this library; see the file COPYING.LIB.  If not, write to
0018  *   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  *   Boston, MA 02110-1301, USA.
0020  *
0021  *********************************************************************/
0022 /**
0023  * @file
0024  * This file is part of the IMAP support library and defines the
0025  * RfcCodecs class.
0026  *
0027  * @brief
0028  * Provides handlers for various RFC/MIME encodings.
0029  *
0030  * @author Sven Carstens
0031  */
0032 
0033 #ifndef KIMAP2_RFCCODECS_H
0034 #define KIMAP2_RFCCODECS_H
0035 
0036 #include <QtCore/QString>
0037 
0038 #include "kimap2_export.h"
0039 
0040 class QTextCodec;
0041 
0042 namespace KIMAP2
0043 {
0044 
0045 /**
0046   Converts an Unicode IMAP mailbox to a QByteArray which can be used in
0047   IMAP communication.
0048   @param src is the QByteArray containing the IMAP mailbox.
0049   @since 4.3
0050 */
0051 KIMAP2_EXPORT QByteArray encodeImapFolderName(const QByteArray &src);
0052 
0053 /**
0054   Converts an UTF-7 encoded IMAP mailbox to a QByteArray
0055   @param inSrc is the QByteArray containing the Unicode path.
0056   @since 4.3
0057 */
0058 KIMAP2_EXPORT QByteArray decodeImapFolderName(const QByteArray &inSrc);
0059 /**
0060   Converts an Unicode IMAP mailbox to a QString which can be used in
0061   IMAP communication.
0062   @param src is the QString containing the IMAP mailbox.
0063 */
0064 KIMAP2_EXPORT QString encodeImapFolderName(const QString &src);
0065 
0066 /**
0067   Converts an UTF-7 encoded IMAP mailbox to a Unicode QString.
0068   @param inSrc is the QString containing the Unicode path.
0069 */
0070 KIMAP2_EXPORT QString decodeImapFolderName(const QString &inSrc);
0071 
0072 /**
0073   Replaces " with \" and \ with \\ " and \ characters.
0074   @param src is the QString to quote.
0075 */
0076 KIMAP2_EXPORT QString quoteIMAP(const QString &src);
0077 
0078 /**
0079   Replaces " with \" and \ with \\ " and \ characters.
0080   @param src is the QString to quote.
0081   @since 4.3
0082 */
0083 KIMAP2_EXPORT QByteArray quoteIMAP(const QByteArray &src);
0084 
0085 /**
0086   Fetches a Codec by @p name.
0087   @param name is the QString version of the Codec name.
0088   @return Text Codec object
0089 */
0090 KIMAP2_EXPORT QTextCodec *codecForName(const QString &name);
0091 
0092 /**
0093   Decodes a RFC2047 string @p str.
0094   @param str is the QString to decode.
0095   @param charset is the character set to use when decoding.
0096   @param language is the language found in the charset.
0097 */
0098 KIMAP2_EXPORT const QString decodeRFC2047String(const QString &str,
0099         QString &charset,
0100         QString &language);
0101 /**
0102   Decodes a RFC2047 string @p str.
0103   @param str is the QString to decode.
0104   @param charset is the character set to use when decoding.
0105 */
0106 KIMAP2_EXPORT const QString decodeRFC2047String(const QString &str,
0107         QString &charset);
0108 
0109 /**
0110   Decodes a RFC2047 string @p str.
0111   @param str is the QString to decode.
0112 */
0113 KIMAP2_EXPORT const QString decodeRFC2047String(const QString &str);
0114 
0115 /**
0116   Encodes a RFC2047 string @p str.
0117   @param str is the QString to encode.
0118 */
0119 KIMAP2_EXPORT const QString encodeRFC2047String(const QString &str);
0120 
0121 /**
0122   Encodes a RFC2047 string @p str.
0123   @param str is the QString to encode.
0124 */
0125 KIMAP2_EXPORT const QByteArray encodeRFC2047String(const QByteArray &str);
0126 
0127 /**
0128   Encodes a RFC2231 string @p str.
0129   @param str is the QString to encode.
0130 */
0131 KIMAP2_EXPORT const QString encodeRFC2231String(const QString &str);
0132 
0133 /**
0134   Decodes a RFC2231 string @p str.
0135   @param str is the QString to decode.
0136 */
0137 KIMAP2_EXPORT const QString decodeRFC2231String(const QString &str);
0138 }
0139 
0140 #endif