KMIME Library
kmime_util.h
00001 /* -*- c++ -*- 00002 kmime_util.h 00003 00004 KMime, the KDE Internet mail/usenet news message library. 00005 Copyright (c) 2001 the KMime authors. 00006 See file AUTHORS for details 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Library General Public 00010 License as published by the Free Software Foundation; either 00011 version 2 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Library General Public License for more details. 00017 00018 You should have received a copy of the GNU Library General Public License 00019 along with this library; see the file COPYING.LIB. If not, write to 00020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00021 Boston, MA 02110-1301, USA. 00022 */ 00023 #ifndef __KMIME_UTIL_H__ 00024 #define __KMIME_UTIL_H__ 00025 00026 #include <QtCore/QString> 00027 #include "kmime_export.h" 00028 #include "kmime_headers.h" 00029 #include "kmime_content.h" 00030 00031 namespace KMime { 00032 00033 class Message; 00034 00040 KMIME_EXPORT extern QByteArray cachedCharset( const QByteArray &name ); 00041 00047 KMIME_EXPORT extern QByteArray cachedLanguage( const QByteArray &name ); 00048 00053 KMIME_EXPORT extern bool isUsAscii( const QString &s ); 00054 00061 KMIME_EXPORT extern QString nameForEncoding( KMime::Headers::contentEncoding enc ); 00062 00067 KMIME_EXPORT QList<KMime::Headers::contentEncoding> encodingsForData( 00068 const QByteArray &data ); 00069 //@cond PRIVATE 00070 extern const uchar specialsMap[16]; 00071 extern const uchar tSpecialsMap[16]; 00072 extern const uchar aTextMap[16]; 00073 extern const uchar tTextMap[16]; 00074 extern const uchar eTextMap[16]; 00075 00076 inline bool isOfSet( const uchar map[16], unsigned char ch ) 00077 { 00078 return ( ch < 128 ) && ( map[ ch/8 ] & 0x80 >> ch%8 ); 00079 } 00080 inline bool isSpecial( char ch ) 00081 { 00082 return isOfSet( specialsMap, ch ); 00083 } 00084 inline bool isTSpecial( char ch ) 00085 { 00086 return isOfSet( tSpecialsMap, ch ); 00087 } 00088 inline bool isAText( char ch ) 00089 { 00090 return isOfSet( aTextMap, ch ); 00091 } 00092 inline bool isTText( char ch ) 00093 { 00094 return isOfSet( tTextMap, ch ); 00095 } 00096 inline bool isEText( char ch ) 00097 { 00098 return isOfSet( eTextMap, ch ); 00099 } 00100 //@endcond 00101 00111 KMIME_EXPORT extern void setFallbackCharEncoding( const QString& fallbackCharEnc ); 00112 00121 KMIME_EXPORT extern QString fallbackCharEncoding(); 00122 00134 KMIME_EXPORT extern void setUseOutlookAttachmentEncoding( bool violateStandard ); 00135 00139 KMIME_EXPORT extern bool useOutlookAttachmentEncoding(); 00152 KMIME_EXPORT extern QString decodeRFC2047String( 00153 const QByteArray &src, QByteArray &usedCS, const QByteArray &defaultCS = QByteArray(), 00154 bool forceCS = false ); 00155 00162 KMIME_EXPORT extern QString decodeRFC2047String( const QByteArray &src ); 00163 00181 KMIME_EXPORT extern QByteArray encodeRFC2047String( 00182 const QString &src, const QByteArray &charset, bool addressHeader=false, 00183 bool allow8bitHeaders=false ); 00184 00185 00197 KMIME_EXPORT extern QString decodeRFC2231String( 00198 const QByteArray &src, QByteArray &usedCS, const QByteArray &defaultCS = QByteArray(), 00199 bool forceCS = false ); 00200 00207 KMIME_EXPORT extern QString decodeRFC2231String( const QByteArray &src ); 00208 00209 00217 KMIME_EXPORT extern QByteArray encodeRFC2231String( const QString &src, const QByteArray &charset ); 00218 00227 KMIME_EXPORT extern QByteArray uniqueString(); 00228 00237 KMIME_EXPORT extern QByteArray multiPartBoundary(); 00238 00243 KMIME_EXPORT extern QByteArray unfoldHeader( const QByteArray &header ); 00244 00255 KMIME_EXPORT extern QByteArray extractHeader( const QByteArray &src, 00256 const QByteArray &name ); 00257 00269 KMIME_EXPORT extern QList<QByteArray> extractHeaders( const QByteArray &src, 00270 const QByteArray &name ); 00271 00284 KMIME_EXPORT extern QByteArray CRLFtoLF( const QByteArray &s ); 00285 00298 KMIME_EXPORT extern QByteArray CRLFtoLF( const char *s ); 00299 00313 KMIME_EXPORT extern QByteArray LFtoCRLF( const QByteArray &s ); 00314 00322 //AK_REVIEW: add correctly spelled methods and deprecated the wrongly spelled 00323 // TODO: KDE5: BIC: rename to "removeQuotes" 00324 KMIME_EXPORT extern void removeQuots( QByteArray &str ); 00325 00333 //AK_REVIEW: add correctly spelled methods and deprecated the wrongly spelled 00334 // TODO: KDE5: BIC: rename to "removeQuotes" 00335 KMIME_EXPORT extern void removeQuots( QString &str ); 00336 00344 KMIME_EXPORT extern void addQuotes( QByteArray &str, bool forceQuotes ); 00345 00350 KMIME_EXPORT extern void addQuotes( QString &str, bool forceQuotes ); 00351 00393 KMIME_EXPORT QString balanceBidiState( const QString &input ); 00394 00401 KMIME_EXPORT QString removeBidiControlChars( const QString &input ); 00402 00407 KMIME_EXPORT bool hasAttachment( Content* content ); 00408 00414 KMIME_EXPORT bool isSigned( Message* message ); 00415 00421 KMIME_EXPORT bool isEncrypted( Message* message ); 00422 00429 KMIME_EXPORT bool isInvitation( Content* content ); 00430 00431 } // namespace KMime 00432 00433 #endif /* __KMIME_UTIL_H__ */
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:48:41 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Apr 30 2012 21:48:41 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.