• 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
nodehelper.h
Go to the documentation of this file.
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2  Copyright (C) 2009 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.net
3  Copyright (c) 2009 Andras Mantia <andras@kdab.net>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19 
20 #ifndef _MESSAGEVIEWER_NODEHELPER_H
21 #define _MESSAGEVIEWER_NODEHELPER_H
22 #include "messageviewer_export.h"
23 
24 #include "partmetadata.h"
25 
26 #include <KMime/Message>
27 
28 #include <KIconLoader>
29 
30 #include <QList>
31 #include <QMap>
32 #include <QSet>
33 
34 class KUrl;
35 class QTextCodec;
36 
37 namespace MessageViewer {
38  namespace Interface {
39  class BodyPartMemento;
40  }
41 }
42 
43 namespace PimCommon
44 {
45 class AttachmentTemporaryFilesDirs;
46 
47 }
48 namespace MessageViewer {
49 
51 typedef enum
52 {
53  KMMsgEncryptionStateUnknown=' ',
54  KMMsgNotEncrypted='N',
55  KMMsgPartiallyEncrypted='P',
56  KMMsgFullyEncrypted='F',
57  KMMsgEncryptionProblematic='X'
58 } KMMsgEncryptionState;
59 
61 typedef enum
62 {
63  KMMsgSignatureStateUnknown=' ',
64  KMMsgNotSigned='N',
65  KMMsgPartiallySigned='P',
66  KMMsgFullySigned='F',
67  KMMsgSignatureProblematic='X'
68 } KMMsgSignatureState;
69 
70 
74 class MESSAGEVIEWER_EXPORT NodeHelper {
75 public:
76  NodeHelper();
77 
78  ~NodeHelper();
79 
80  void setNodeProcessed( KMime::Content* node, bool recurse );
81  void setNodeUnprocessed( KMime::Content* node, bool recurse );
82  bool nodeProcessed( KMime::Content* node ) const;
83  void clear();
84  void forceCleanTempFiles();
85 
86  void setEncryptionState( KMime::Content* node, const KMMsgEncryptionState state );
87  KMMsgEncryptionState encryptionState( KMime::Content *node ) const;
88 
89  void setSignatureState( KMime::Content* node, const KMMsgSignatureState state );
90  KMMsgSignatureState signatureState( KMime::Content *node ) const;
91 
92  KMMsgSignatureState overallSignatureState( KMime::Content* node ) const;
93  KMMsgEncryptionState overallEncryptionState( KMime::Content *node ) const;
94 
95  void setPartMetaData( KMime::Content* node, const PartMetaData &metaData );
96  PartMetaData partMetaData( KMime::Content* node );
97 
98  static QString iconName( KMime::Content *node, int size = KIconLoader::Desktop );
99 
105  void magicSetType( KMime::Content *node, bool autoDecode=true );
106 
107 
112  static QString cleanSubject( KMime::Message *message );
113 
115  void attachExtraContent( KMime::Content *topLevelNode, KMime::Content* content );
116  void removeAllExtraContent( KMime::Content *topLevelNode );
117 
119  QList<KMime::Content*> extraContents( KMime::Content *topLevelNode ) const;
120 
124  KMime::Message *messageWithExtraContent( KMime::Content* topLevelNode );
125 
131  bool isPermanentWithExtraContent( KMime::Content* node ) const;
132 
134  const QTextCodec * codec( KMime::Content* node );
135 
137  void setOverrideCodec( KMime::Content* node, const QTextCodec* codec );
138 
139  const QTextCodec * localCodec() const { return mLocalCodec;}
140 
141  Interface::BodyPartMemento *bodyPartMemento( KMime::Content* node, const QByteArray &which ) const;
142 
143  void setBodyPartMemento( KMime::Content* node, const QByteArray &which,
144  Interface::BodyPartMemento *memento );
145 
146  // A flag to remember if the node was embedded. This is useful for attachment nodes, the reader
147  // needs to know if they were displayed inline or not.
148  bool isNodeDisplayedEmbedded( KMime::Content* node ) const;
149  void setNodeDisplayedEmbedded( KMime::Content* node, bool displayedEmbedded );
150 
151  // Same as above, but this time determines if the node was hidden or not
152  bool isNodeDisplayedHidden( KMime::Content* node ) const;
153  void setNodeDisplayedHidden( KMime::Content* node, bool displayedHidden );
154 
159  QString writeNodeToTempFile( KMime::Content* node );
160 
165  KUrl tempFileUrlFromNode( const KMime::Content *node );
166 
172  QString createTempDir( const QString &param = QString() );
173 
177  void removeTempFiles();
178 
182  void addTempFile( const QString& file );
183 
184  // Get a href in the form attachment:<nodeId>?place=<place>, used by ObjectTreeParser and
185  // UrlHandlerManager.
186  QString asHREF( const KMime::Content* node, const QString &place );
187 
188  static bool isToltecMessage( KMime::Content* node );
189 
193  static bool isInEncapsulatedMessage( KMime::Content* node );
194 
199  static QByteArray charset( KMime::Content *node );
200 
208  static QString replacePrefixes( const QString& str,
209  const QStringList& prefixRegExps,
210  bool replace,
211  const QString& newPrefix );
212 
217  static const QTextCodec* codecForName(const QByteArray& _str);
218 
224  static QString fileName( const KMime::Content *node );
225 
231  static QString fixEncoding( const QString &encoding ); //TODO(Andras) move to a utility class?
232 
239  static QString encodingForName( const QString &descriptiveName ); //TODO(Andras) move to a utility class?
240 
245  static QStringList supportedEncodings( bool usAscii ); //TODO(Andras) move to a utility class?
246 
247  static QByteArray autoDetectCharset(const QByteArray &_encoding, const QStringList &encodingList, const QString &text);
248  static QByteArray toUsAscii(const QString& _str, bool *ok);
249 
250  static QString fromAsString( KMime::Content* node );
251 
252  struct AttachmentDisplayInfo
253  {
254  QString label;
255  QString icon;
256  bool displayInHeader;
257  };
258 
259  static AttachmentDisplayInfo attachmentDisplayInfo( KMime::Content *node );
260 
261  KMime::Content * decryptedNodeForContent( KMime::Content * content ) const;
262 
276  KMime::Message::Ptr unencryptedMessage( const KMime::Message::Ptr &originalMessage );
277 
278 private:
279 
280  bool unencryptedMessage_helper( KMime::Content *node, QByteArray &resultingData, bool addHeaders,
281  int recursionLevel = 1 );
282 
289  static QString cleanSubject( KMime::Message *message, const QStringList& prefixRegExps,
290  bool replace, const QString& newPrefix );
291 
292  void mergeExtraNodes( KMime::Content *node );
293  void cleanFromExtraNodes( KMime::Content *node );
294 
295  QString persistentIndex( const KMime::Content * node ) const;
296 
297 private:
298  QList<KMime::Content*> mProcessedNodes;
299  QList<KMime::Content*> mNodesUnderProcess;
300  QMap<KMime::Content *, KMMsgEncryptionState> mEncryptionState;
301  QMap<KMime::Content *, KMMsgSignatureState> mSignatureState;
302  QSet<KMime::Content *> mDisplayEmbeddedNodes;
303  QSet<KMime::Content *> mDisplayHiddenNodes;
304  QTextCodec *mLocalCodec;
305  QMap<KMime::Content*, const QTextCodec*> mOverrideCodecs;
306  QMap<QString, QMap<QByteArray, Interface::BodyPartMemento*> > mBodyPartMementoMap;
307  QMap<KMime::Content*, PartMetaData> mPartMetaDatas;
308  QMap<KMime::Message::Content*, QList<KMime::Content*> > mExtraContents;
309  PimCommon::AttachmentTemporaryFilesDirs *mAttachmentFilesDir;
310 };
311 
312 }
313 
314 #endif
MessageViewer::PartMetaData
Definition: partmetadata.h:31
MessageViewer::NodeHelper::AttachmentDisplayInfo::icon
QString icon
Definition: nodehelper.h:255
QByteArray
MessageViewer::KMMsgSignatureState
KMMsgSignatureState
Flags for the signature state.
Definition: nodehelper.h:61
QMap< KMime::Content *, KMMsgEncryptionState >
partmetadata.h
MessageViewer::KMMsgPartiallySigned
Definition: nodehelper.h:65
MessageViewer::KMMsgPartiallyEncrypted
Definition: nodehelper.h:55
MessageViewer::KMMsgSignatureStateUnknown
Definition: nodehelper.h:63
MessageViewer::KMMsgNotSigned
Definition: nodehelper.h:64
MessageViewer::KMMsgFullySigned
Definition: nodehelper.h:66
MessageViewer::KMMsgNotEncrypted
Definition: nodehelper.h:54
QSet< KMime::Content * >
QString
QList< KMime::Content * >
QTextCodec
MessageViewer::NodeHelper::AttachmentDisplayInfo
Definition: nodehelper.h:252
QStringList
MESSAGEVIEWER_EXPORT
#define MESSAGEVIEWER_EXPORT
Definition: messageviewer_export.h:37
MessageViewer::NodeHelper::localCodec
const QTextCodec * localCodec() const
Definition: nodehelper.h:139
MessageViewer::KMMsgSignatureProblematic
Definition: nodehelper.h:67
MessageViewer::Interface::BodyPartMemento
interface of classes that implement status for BodyPartFormatters.
Definition: bodypart.h:55
MessageViewer::NodeHelper
Definition: nodehelper.h:74
MessageViewer::KMMsgFullyEncrypted
Definition: nodehelper.h:56
MessageViewer::KMMsgEncryptionState
KMMsgEncryptionState
Flags for the encryption state.
Definition: nodehelper.h:51
MessageViewer::KMMsgEncryptionStateUnknown
Definition: nodehelper.h:53
MessageViewer::NodeHelper::AttachmentDisplayInfo::displayInHeader
bool displayInHeader
Definition: nodehelper.h:256
MessageViewer::NodeHelper::AttachmentDisplayInfo::label
QString label
Definition: nodehelper.h:254
MessageViewer::KMMsgEncryptionProblematic
Definition: nodehelper.h:57
messageviewer_export.h
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