Backport r950340 | aacid | 2009-04-06 23:21:18 +0200 (Mon, 06 Apr 2009) | 4 lines
[kdepim.git] / kmail / partnodebodypart.cpp
blobe058c7192e509a6bee369d5e33681683f8774898
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 partnodebodypart.cpp
4 This file is part of KMail, the KDE mail client.
5 Copyright (c) 2004 Marc Mutz <mutz@kde.org>,
6 Ingo Kloecker <kloecker@kde.org>
8 KMail is free software; you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 KMail is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 In addition, as a special exception, the copyright holders give
23 permission to link the code of this program with any edition of
24 the Qt library by Trolltech AS, Norway (or with modified versions
25 of Qt that use the same license as Qt), and distribute linked
26 combinations including the two. You must obey the GNU General
27 Public License in all respects for all of the code used other than
28 Qt. If you modify this file, you may extend this exception to
29 your version of the file, but you are not obligated to do so. If
30 you do not wish to do so, delete this exception statement from
31 your version.
35 #include "partnodebodypart.h"
37 #include "partNode.h"
39 #include <kurl.h>
41 #include <QString>
43 static int serial = 0;
45 KMail::PartNodeBodyPart::PartNodeBodyPart( partNode & n, const QTextCodec * codec )
46 : KMail::Interface::BodyPart(), mPartNode( n ), mCodec( codec ),
47 mDefaultDisplay( KMail::Interface::BodyPart::None )
50 QString KMail::PartNodeBodyPart::makeLink( const QString & path ) const {
51 // FIXME: use a PRNG for the first arg, instead of a serial number
52 return QString( "x-kmail:/bodypart/%1/%2/%3" )
53 .arg( serial++ ).arg( mPartNode.nodeId() )
54 .arg( QString::fromLatin1( KUrl::toPercentEncoding( path, "/" ) ) );
57 QString KMail::PartNodeBodyPart::asText() const {
58 if ( mPartNode.type() != DwMime::kTypeText )
59 return QString();
60 return mPartNode.msgPart().bodyToUnicode( mCodec );
63 QByteArray KMail::PartNodeBodyPart::asBinary() const {
64 return mPartNode.msgPart().bodyDecodedBinary();
67 QString KMail::PartNodeBodyPart::contentTypeParameter( const char * param ) const {
68 return mPartNode.contentTypeParameter( param );
71 QString KMail::PartNodeBodyPart::contentDescription() const {
72 return mPartNode.msgPart().contentDescription();
75 QString KMail::PartNodeBodyPart::contentDispositionParameter( const char * ) const {
76 kWarning( 5006 ) << "Sorry, not yet implemented.";
77 return QString();
80 bool KMail::PartNodeBodyPart::hasCompleteBody() const {
81 kWarning( 5006 ) << "Sorry, not yet implemented.";
82 return true;
85 KMail::Interface::BodyPartMemento * KMail::PartNodeBodyPart::memento() const {
86 return mPartNode.bodyPartMemento();
89 void KMail::PartNodeBodyPart::setBodyPartMemento( Interface::BodyPartMemento * memento ) {
90 mPartNode.setBodyPartMemento( memento );
93 KMail::Interface::BodyPart::Display KMail::PartNodeBodyPart::defaultDisplay() const {
94 return mDefaultDisplay;
97 void KMail::PartNodeBodyPart::setDefaultDisplay( KMail::Interface::BodyPart::Display d ){
98 mDefaultDisplay = d;