libkmime

kmime_codec_qp.h

00001 /*  -*- c++ -*-
00002     kmime_codec_qp.h
00003 
00004     This file is part of KMime, the KDE internet mail/usenet news message library.
00005     Copyright (c) 2001-2002 Marc Mutz <mutz@kde.org>
00006 
00007     KMime is free software; you can redistribute it and/or modify it
00008     under the terms of the GNU General Public License, version 2, as
00009     published by the Free Software Foundation.
00010 
00011     KMime is distributed in the hope that it will be useful, but
00012     WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this library; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020     In addition, as a special exception, the copyright holders give
00021     permission to link the code of this library with any edition of
00022     the Qt library by Trolltech AS, Norway (or with modified versions
00023     of Qt that use the same license as Qt), and distribute linked
00024     combinations including the two.  You must obey the GNU General
00025     Public License in all respects for all of the code used other than
00026     Qt.  If you modify this file, you may extend this exception to
00027     your version of the file, but you are not obligated to do so.  If
00028     you do not wish to do so, delete this exception statement from
00029     your version.
00030 */
00031 
00032 #ifndef __KMIME_CODEC_QP__
00033 #define __KMIME_CODEC_QP__
00034 
00035 #include "kmime_codecs.h"
00036 
00037 namespace KMime {
00038 
00039 
00040 class QuotedPrintableCodec : public Codec {
00041 protected:
00042   friend class Codec;
00043   QuotedPrintableCodec() : Codec() {}
00044 
00045 public:
00046   virtual ~QuotedPrintableCodec() {}
00047 
00048   const char * name() const {
00049     return "quoted-printable";
00050   }
00051 
00052   int maxEncodedSizeFor( int insize, bool withCRLF=false ) const {
00053     // all chars encoded:
00054     int result = 3*insize;
00055     // then after 25 hexchars comes a soft linebreak: =(\r)\n
00056     result += (withCRLF ? 3 : 2) * (insize/25);
00057     
00058     return result;
00059   }
00060 
00061   int maxDecodedSizeFor( int insize, bool withCRLF=false ) const;
00062 
00063   Encoder * makeEncoder( bool withCRLF=false ) const;
00064   Decoder * makeDecoder( bool withCRLF=false ) const;
00065 };
00066 
00067 
00068 class Rfc2047QEncodingCodec : public Codec {
00069 protected:
00070   friend class Codec;
00071   Rfc2047QEncodingCodec() : Codec() {}
00072 
00073 public:
00074   virtual ~Rfc2047QEncodingCodec() {}
00075 
00076   const char * name() const {
00077     return "q";
00078   }
00079 
00080   int maxEncodedSizeFor( int insize, bool withCRLF=false ) const {
00081     (void)withCRLF; // keep compiler happy
00082     // this one is simple: We don't do linebreaking, so all that can
00083     // happen is that every char needs encoding, so:
00084     return 3*insize;
00085   }
00086 
00087   int maxDecodedSizeFor( int insize, bool withCRLF=false ) const;
00088 
00089   Encoder * makeEncoder( bool withCRLF=false ) const;
00090   Decoder * makeDecoder( bool withCRLF=false ) const;
00091 };
00092 
00093 
00094 class Rfc2231EncodingCodec : public Codec {
00095 protected:
00096   friend class Codec;
00097   Rfc2231EncodingCodec() : Codec() {}
00098 
00099 public:
00100   virtual ~Rfc2231EncodingCodec() {}
00101 
00102   const char * name() const {
00103     return "x-kmime-rfc2231";
00104   }
00105 
00106   int maxEncodedSizeFor( int insize, bool withCRLF=false ) const {
00107     (void)withCRLF; // keep compiler happy
00108     // same as for "q" encoding:
00109     return 3*insize;
00110   }
00111 
00112   int maxDecodedSizeFor( int insize, bool withCRLF=false ) const;
00113 
00114   Encoder * makeEncoder( bool withCRLF=false ) const;
00115   Decoder * makeDecoder( bool withCRLF=false ) const;
00116 };
00117 
00118 
00119 } // namespace KMime
00120 
00121 #endif // __KMIME_CODEC_QP__
KDE Home | KDE Accessibility Home | Description of Access Keys