• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.14
  • kdepim
  • messageviewer
  • viewer
partnodebodypart.cpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2  partnodebodypart.cpp
3 
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>
7 
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.
12 
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.
17 
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
21 
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.
32 */
33 
34 
35 
36 
37 #include "partnodebodypart.h"
38 #include "viewer/nodehelper.h"
39 
40 #include <kurl.h>
41 
42 #include <kmime/kmime_content.h>
43 
44 #include <KDebug>
45 
46 #include <QTextCodec>
47 
48 using namespace MessageViewer;
49 
50 static int serial = 0;
51 
52 PartNodeBodyPart::PartNodeBodyPart( KMime::Content *topLevelContent, KMime::Content *content,
53  NodeHelper *nodeHelper, const QTextCodec * codec )
54  : Interface::BodyPart(), mTopLevelContent( topLevelContent ), mContent( content ), mCodec( codec ),
55  mDefaultDisplay( Interface::BodyPart::None ), mNodeHelper( nodeHelper )
56 {}
57 
58 QString PartNodeBodyPart::makeLink( const QString & path ) const {
59  // FIXME: use a PRNG for the first arg, instead of a serial number
60  return QString::fromLatin1( "x-kmail:/bodypart/%1/%2/%3" )
61  .arg( serial++ ).arg( mContent->index().toString() )
62  .arg( QString::fromLatin1( KUrl::toPercentEncoding( path, "/" ) ) );
63 }
64 
65 QString PartNodeBodyPart::asText() const {
66  if ( !mContent->contentType()->isText() )
67  return QString();
68  return mContent->decodedText();
69 }
70 
71 QByteArray PartNodeBodyPart::asBinary() const {
72  return mContent->decodedContent();
73 }
74 
75 QString PartNodeBodyPart::contentTypeParameter( const char * param ) const {
76  return mContent->contentType()->parameter( QString::fromLatin1(param) );
77 }
78 
79 QString PartNodeBodyPart::contentDescription() const {
80  return mContent->contentDescription()->asUnicodeString();
81 }
82 
83 QString PartNodeBodyPart::contentDispositionParameter( const char * param ) const {
84  return mContent->contentDisposition()->parameter( QString::fromLatin1(param) );
85 }
86 
87 bool PartNodeBodyPart::hasCompleteBody() const {
88  kWarning() << "Sorry, not yet implemented.";
89  return true;
90 }
91 
92 Interface::BodyPartMemento * PartNodeBodyPart::memento() const {
93  /*TODO(Andras) Volker suggests to use a ContentIndex->Mememnto mapping
94  Also review if the reader's bodyPartMemento should be returned or the NodeHelper's one
95  */
96  return mNodeHelper->bodyPartMemento( mContent, "__plugin__" );
97 }
98 
99 void PartNodeBodyPart::setBodyPartMemento( Interface::BodyPartMemento * memento ) {
100  /*TODO(Andras) Volker suggests to use a ContentIndex->Memento mapping
101 Also review if the reader's bodyPartMemento should be set or the NodeHelper's one */
102  mNodeHelper->setBodyPartMemento( mContent, "__plugin__" , memento );
103 }
104 
105 Interface::BodyPart::Display PartNodeBodyPart::defaultDisplay() const {
106  return mDefaultDisplay;
107 }
108 
109 void PartNodeBodyPart::setDefaultDisplay( Interface::BodyPart::Display d ){
110  mDefaultDisplay = d;
111 }
MessageViewer::PartNodeBodyPart::defaultDisplay
BodyPart::Display defaultDisplay() const
Definition: partnodebodypart.cpp:105
serial
static int serial
Definition: partnodebodypart.cpp:50
MessageViewer::PartNodeBodyPart::contentDescription
QString contentDescription() const
Definition: partnodebodypart.cpp:79
QByteArray
MessageViewer::PartNodeBodyPart::hasCompleteBody
bool hasCompleteBody() const
Definition: partnodebodypart.cpp:87
MessageViewer::PartNodeBodyPart::PartNodeBodyPart
PartNodeBodyPart(KMime::Content *topLevelContent, KMime::Content *content, NodeHelper *nodeHelper, const QTextCodec *codec=0)
Definition: partnodebodypart.cpp:52
nodehelper.h
partnodebodypart.h
MessageViewer::PartNodeBodyPart::contentDispositionParameter
QString contentDispositionParameter(const char *param) const
Definition: partnodebodypart.cpp:83
MessageViewer::PartNodeBodyPart::memento
Interface::BodyPartMemento * memento() const
Definition: partnodebodypart.cpp:92
MessageViewer::PartNodeBodyPart::asBinary
QByteArray asBinary() const
Definition: partnodebodypart.cpp:71
MessageViewer::PartNodeBodyPart::setDefaultDisplay
void setDefaultDisplay(BodyPart::Display)
Definition: partnodebodypart.cpp:109
QString
QTextCodec
MessageViewer::NodeHelper::setBodyPartMemento
void setBodyPartMemento(KMime::Content *node, const QByteArray &which, Interface::BodyPartMemento *memento)
Definition: nodehelper.cpp:612
MessageViewer::Interface::BodyPart::Display
Display
Definition: bodypart.h:161
MessageViewer::NodeHelper::bodyPartMemento
Interface::BodyPartMemento * bodyPartMemento(KMime::Content *node, const QByteArray &which) const
Definition: nodehelper.cpp:599
MessageViewer::Interface::BodyPartMemento
interface of classes that implement status for BodyPartFormatters.
Definition: bodypart.h:55
MessageViewer::NodeHelper
Definition: nodehelper.h:74
QString::fromLatin1
QString fromLatin1(const char *str, int size)
MessageViewer::PartNodeBodyPart::makeLink
QString makeLink(const QString &path) const
Definition: partnodebodypart.cpp:58
MessageViewer::PartNodeBodyPart::setBodyPartMemento
void setBodyPartMemento(Interface::BodyPartMemento *memento)
Definition: partnodebodypart.cpp:99
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
MessageViewer::PartNodeBodyPart::contentTypeParameter
QString contentTypeParameter(const char *param) const
Definition: partnodebodypart.cpp:75
MessageViewer::PartNodeBodyPart::asText
QString asText() const
Definition: partnodebodypart.cpp:65
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:45 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal