libkdenetwork Library API Documentation

kmime_codec_identity.cpp

00001 /* -*- c++ -*- 00002 kmime_codec_identity.cpp 00003 00004 This file is part of KMime, the KDE internet mail/usenet news message library. 00005 Copyright (c) 2004 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 #include "kmime_codec_identity.h" 00033 00034 #include <kdebug.h> 00035 #include <kglobal.h> 00036 00037 #include <cassert> 00038 #include <cstring> 00039 00040 using namespace KMime; 00041 00042 namespace KMime { 00043 00044 00045 class IdentityEnDecoder : public Encoder, public Decoder { 00046 protected: 00047 friend class IdentityCodec; 00048 IdentityEnDecoder( bool withCRLF ) 00049 : Encoder( false ) 00050 { 00051 kdWarning( withCRLF, 5100 ) << "IdentityEnDecoder: withCRLF isn't yet supported!" << endl; 00052 } 00053 00054 public: 00055 ~IdentityEnDecoder() {} 00056 00057 bool encode( const char* & scursor, const char * const send, 00058 char* & dcursor, const char * const dend ) { 00059 return decode( scursor, send, dcursor, dend ); 00060 } 00061 bool decode( const char* & scursor, const char * const send, 00062 char* & dcursor, const char * const dend ); 00063 bool finish( char* & /*dcursor*/, const char * const /*dend*/ ) { return true; } 00064 }; 00065 00066 00067 Encoder * IdentityCodec::makeEncoder( bool withCRLF ) const { 00068 return new IdentityEnDecoder( withCRLF ); 00069 } 00070 00071 Decoder * IdentityCodec::makeDecoder( bool withCRLF ) const { 00072 return new IdentityEnDecoder( withCRLF ); 00073 } 00074 00075 00076 /********************************************************/ 00077 /********************************************************/ 00078 /********************************************************/ 00079 00080 00081 00082 bool IdentityEnDecoder::decode( const char* & scursor, const char * const send, 00083 char* & dcursor, const char * const dend ) 00084 { 00085 const int size = kMin( send - scursor, dcursor - dend ); 00086 if ( size > 0 ) { 00087 std::memmove( dcursor, scursor, size ); 00088 dcursor += size; 00089 scursor += size; 00090 } 00091 return scursor == send; 00092 } 00093 00094 QByteArray IdentityCodec::encode( const QByteArray & src, bool withCRLF ) const { 00095 kdWarning( withCRLF, 5100 ) << "IdentityCodec::encode(): withCRLF not yet supported!" << endl; 00096 return src; 00097 } 00098 00099 QByteArray IdentityCodec::decode( const QByteArray & src, bool withCRLF ) const { 00100 kdWarning( withCRLF, 5100 ) << "IdentityCodec::decode(): withCRLF not yet supported!" << endl; 00101 return src; 00102 } 00103 00104 QCString IdentityCodec::encodeToQCString( const QByteArray & src, bool withCRLF ) const { 00105 kdWarning( withCRLF, 5100 ) << "IdentityCodec::encodeToQCString(): withCRLF not yet supported!" << endl; 00106 return QCString( src.data(), src.size() + 1 ); 00107 } 00108 00109 } // namespace KMime
KDE Logo
This file is part of the documentation for libkdenetwork Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:48:41 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003