kmail Library API Documentation

partnodebodypart.cpp

00001 /*  -*- mode: C++; c-file-style: "gnu" -*-
00002     partnodebodypart.cpp
00003 
00004     This file is part of KMail, the KDE mail client.
00005     Copyright (c) 2004 Marc Mutz <mutz@kde.org>,
00006                        Ingo Kloecker <kloecker@kde.org>
00007 
00008     KMail is free software; you can redistribute it and/or modify it
00009     under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     KMail is distributed in the hope that it will be useful, but
00014     WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with this program; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 
00022     In addition, as a special exception, the copyright holders give
00023     permission to link the code of this program with any edition of
00024     the Qt library by Trolltech AS, Norway (or with modified versions
00025     of Qt that use the same license as Qt), and distribute linked
00026     combinations including the two.  You must obey the GNU General
00027     Public License in all respects for all of the code used other than
00028     Qt.  If you modify this file, you may extend this exception to
00029     your version of the file, but you are not obligated to do so.  If
00030     you do not wish to do so, delete this exception statement from
00031     your version.
00032 */
00033 
00034 #include "partnodebodypart.h"
00035 
00036 #include "partNode.h"
00037 
00038 #include <qstring.h>
00039 #include <qcstring.h>
00040 
00041 static int serial = 0;
00042 
00043 KMail::PartNodeBodyPart::PartNodeBodyPart( partNode & n, const QTextCodec * codec  )
00044   : KMail::Interface::BodyPart(), mPartNode( n ), mCodec( codec ) {}
00045 
00046 QString KMail::PartNodeBodyPart::makeLink( const QString & path ) const {
00047   static const int utf8 = 106;
00048   // FIXME: use a PRNG for the first arg, instead of a serial number
00049   return QString( "x-kmail:/bodypart/%1/%2/%3" )
00050     .arg( serial++ ).arg( mPartNode.nodeId() )
00051     .arg( KURL::encode_string_no_slash( path, utf8 ) );
00052 }
00053 
00054 QString KMail::PartNodeBodyPart::asText() const {
00055   if ( mPartNode.type() != DwMime::kTypeText )
00056     return QString::null;
00057   return mPartNode.msgPart().bodyToUnicode( mCodec );
00058 }
00059 
00060 QByteArray KMail::PartNodeBodyPart::asBinary() const {
00061   if ( mPartNode.type() == DwMime::kTypeText )
00062     return QByteArray();
00063   return mPartNode.msgPart().bodyDecodedBinary();
00064 }
00065 
00066 QString KMail::PartNodeBodyPart::contentTypeParameter( const char * param ) const {
00067   return mPartNode.contentTypeParameter( param );
00068 }
00069 
00070 QString KMail::PartNodeBodyPart::contentDescription() const {
00071   return mPartNode.msgPart().contentDescription();
00072 }
00073 
00074 QString KMail::PartNodeBodyPart::contentDispositionParameter( const char * ) const {
00075   kdWarning( 5006 ) << "Sorry, not yet implemented: PartNodeBodyPart::contentDispositionParameter()" << endl;
00076   return QString::null;
00077 }
00078 
00079 bool KMail::PartNodeBodyPart::hasCompleteBody() const {
00080   kdWarning( 5006 ) << "Sorry, not yet implemented: PartNodeBodyPart::contentDispositionParameter()" << endl;
00081   return true;
00082 }
00083 
00084 KMail::Interface::BodyPartMemento * KMail::PartNodeBodyPart::memento() const {
00085   return mPartNode.bodyPartMemento();
00086 }
00087 
00088 void KMail::PartNodeBodyPart::setBodyPartMemento( Interface::BodyPartMemento * memento ) {
00089   mPartNode.setBodyPartMemento( memento );
00090 }
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Dec 21 14:25:04 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003