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

messageviewer

  • sources
  • kde-4.12
  • 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 MessageViewer {
44 
45 class AttachmentTemporaryFilesDirs;
46 
48 typedef enum
49 {
50  KMMsgEncryptionStateUnknown=' ',
51  KMMsgNotEncrypted='N',
52  KMMsgPartiallyEncrypted='P',
53  KMMsgFullyEncrypted='F',
54  KMMsgEncryptionProblematic='X'
55 } KMMsgEncryptionState;
56 
58 typedef enum
59 {
60  KMMsgSignatureStateUnknown=' ',
61  KMMsgNotSigned='N',
62  KMMsgPartiallySigned='P',
63  KMMsgFullySigned='F',
64  KMMsgSignatureProblematic='X'
65 } KMMsgSignatureState;
66 
67 
71 class MESSAGEVIEWER_EXPORT NodeHelper {
72 public:
73  NodeHelper();
74 
75  ~NodeHelper();
76 
77  void setNodeProcessed( KMime::Content* node, bool recurse );
78  void setNodeUnprocessed( KMime::Content* node, bool recurse );
79  bool nodeProcessed( KMime::Content* node ) const;
80  void clear();
81  void forceCleanTempFiles();
82 
83  void setEncryptionState( KMime::Content* node, const KMMsgEncryptionState state );
84  KMMsgEncryptionState encryptionState( KMime::Content *node ) const;
85 
86  void setSignatureState( KMime::Content* node, const KMMsgSignatureState state );
87  KMMsgSignatureState signatureState( KMime::Content *node ) const;
88 
89  KMMsgSignatureState overallSignatureState( KMime::Content* node ) const;
90  KMMsgEncryptionState overallEncryptionState( KMime::Content *node ) const;
91 
92  void setPartMetaData( KMime::Content* node, const PartMetaData &metaData );
93  PartMetaData partMetaData( KMime::Content* node );
94 
95  static QString iconName( KMime::Content *node, int size = KIconLoader::Desktop );
96 
102  void magicSetType( KMime::Content *node, bool autoDecode=true );
103 
104 
109  static QString cleanSubject( KMime::Message *message );
110 
112  void attachExtraContent( KMime::Content *topLevelNode, KMime::Content* content );
113  void removeAllExtraContent( KMime::Content *topLevelNode );
114 
116  QList<KMime::Content*> extraContents( KMime::Content *topLevelNode ) const;
117 
121  KMime::Message *messageWithExtraContent( KMime::Content* topLevelNode );
122 
128  bool isPermanentWithExtraContent( KMime::Content* node ) const;
129 
131  const QTextCodec * codec( KMime::Content* node );
132 
134  void setOverrideCodec( KMime::Content* node, const QTextCodec* codec );
135 
136  const QTextCodec * localCodec() const { return mLocalCodec;}
137 
138  Interface::BodyPartMemento *bodyPartMemento( KMime::Content* node, const QByteArray &which ) const;
139 
140  void setBodyPartMemento( KMime::Content* node, const QByteArray &which,
141  Interface::BodyPartMemento *memento );
142 
143  // A flag to remember if the node was embedded. This is useful for attachment nodes, the reader
144  // needs to know if they were displayed inline or not.
145  bool isNodeDisplayedEmbedded( KMime::Content* node ) const;
146  void setNodeDisplayedEmbedded( KMime::Content* node, bool displayedEmbedded );
147 
148  // Same as above, but this time determines if the node was hidden or not
149  bool isNodeDisplayedHidden( KMime::Content* node ) const;
150  void setNodeDisplayedHidden( KMime::Content* node, bool displayedHidden );
151 
156  QString writeNodeToTempFile( KMime::Content* node );
157 
162  KUrl tempFileUrlFromNode( const KMime::Content *node );
163 
169  QString createTempDir( const QString &param = QString() );
170 
174  void removeTempFiles();
175 
179  void addTempFile( const QString& file );
180 
181  // Get a href in the form attachment:<nodeId>?place=<place>, used by ObjectTreeParser and
182  // UrlHandlerManager.
183  QString asHREF( const KMime::Content* node, const QString &place );
184 
185  static bool isToltecMessage( KMime::Content* node );
186 
190  static bool isInEncapsulatedMessage( KMime::Content* node );
191 
196  static QByteArray charset( KMime::Content *node );
197 
205  static QString replacePrefixes( const QString& str,
206  const QStringList& prefixRegExps,
207  bool replace,
208  const QString& newPrefix );
209 
214  static const QTextCodec* codecForName(const QByteArray& _str);
215 
221  static QString fileName( const KMime::Content *node );
222 
228  static QString fixEncoding( const QString &encoding ); //TODO(Andras) move to a utility class?
229 
236  static QString encodingForName( const QString &descriptiveName ); //TODO(Andras) move to a utility class?
237 
242  static QStringList supportedEncodings( bool usAscii ); //TODO(Andras) move to a utility class?
243 
244  static QByteArray autoDetectCharset(const QByteArray &_encoding, const QStringList &encodingList, const QString &text);
245  static QByteArray toUsAscii(const QString& _str, bool *ok);
246 
247  static QString fromAsString( KMime::Content* node );
248 
249  struct AttachmentDisplayInfo
250  {
251  QString label;
252  QString icon;
253  bool displayInHeader;
254  };
255 
256  static AttachmentDisplayInfo attachmentDisplayInfo( KMime::Content *node );
257 
258  KMime::Content * decryptedNodeForContent( KMime::Content * content ) const;
259 
273  KMime::Message::Ptr unencryptedMessage( const KMime::Message::Ptr &originalMessage );
274 
275 private:
276 
277  bool unencryptedMessage_helper( KMime::Content *node, QByteArray &resultingData, bool addHeaders,
278  int recursionLevel = 1 );
279 
286  static QString cleanSubject( KMime::Message *message, const QStringList& prefixRegExps,
287  bool replace, const QString& newPrefix );
288 
289  void mergeExtraNodes( KMime::Content *node );
290  void cleanFromExtraNodes( KMime::Content *node );
291 
292  QString persistentIndex( const KMime::Content * node ) const;
293 
294 private:
295  QList<KMime::Content*> mProcessedNodes;
296  QList<KMime::Content*> mNodesUnderProcess;
297  QMap<KMime::Content *, KMMsgEncryptionState> mEncryptionState;
298  QMap<KMime::Content *, KMMsgSignatureState> mSignatureState;
299  QSet<KMime::Content *> mDisplayEmbeddedNodes;
300  QSet<KMime::Content *> mDisplayHiddenNodes;
301  QTextCodec *mLocalCodec;
302  QMap<KMime::Content*, const QTextCodec*> mOverrideCodecs;
303  QMap<QString, QMap<QByteArray, Interface::BodyPartMemento*> > mBodyPartMementoMap;
304  QMap<KMime::Content*, PartMetaData> mPartMetaDatas;
305  QMap<KMime::Message::Content*, QList<KMime::Content*> > mExtraContents;
306  AttachmentTemporaryFilesDirs *mAttachmentFilesDir;
307 };
308 
309 }
310 
311 #endif
MessageViewer::PartMetaData
Definition: partmetadata.h:31
MessageViewer::NodeHelper::AttachmentDisplayInfo::icon
QString icon
Definition: nodehelper.h:252
MessageViewer::AttachmentTemporaryFilesDirs
Definition: attachmenttemporaryfilesdirs.h:29
MessageViewer::KMMsgSignatureState
KMMsgSignatureState
Flags for the signature state.
Definition: nodehelper.h:58
partmetadata.h
MessageViewer::KMMsgPartiallySigned
Definition: nodehelper.h:62
MessageViewer::KMMsgPartiallyEncrypted
Definition: nodehelper.h:52
MessageViewer::KMMsgSignatureStateUnknown
Definition: nodehelper.h:60
MessageViewer::KMMsgNotSigned
Definition: nodehelper.h:61
MessageViewer::KMMsgFullySigned
Definition: nodehelper.h:63
MessageViewer::KMMsgNotEncrypted
Definition: nodehelper.h:51
MessageViewer::NodeHelper::AttachmentDisplayInfo
Definition: nodehelper.h:249
MESSAGEVIEWER_EXPORT
#define MESSAGEVIEWER_EXPORT
Definition: messageviewer_export.h:37
MessageViewer::NodeHelper::localCodec
const QTextCodec * localCodec() const
Definition: nodehelper.h:136
MessageViewer::KMMsgSignatureProblematic
Definition: nodehelper.h:64
MessageViewer::Interface::BodyPartMemento
interface of classes that implement status for BodyPartFormatters.
Definition: bodypart.h:55
MessageViewer::NodeHelper
Definition: nodehelper.h:71
MessageViewer::KMMsgFullyEncrypted
Definition: nodehelper.h:53
MessageViewer::KMMsgEncryptionState
KMMsgEncryptionState
Flags for the encryption state.
Definition: nodehelper.h:48
MessageViewer::KMMsgEncryptionStateUnknown
Definition: nodehelper.h:50
MessageViewer::NodeHelper::AttachmentDisplayInfo::displayInHeader
bool displayInHeader
Definition: nodehelper.h:253
MessageViewer::NodeHelper::AttachmentDisplayInfo::label
QString label
Definition: nodehelper.h:251
MessageViewer::KMMsgEncryptionProblematic
Definition: nodehelper.h:54
messageviewer_export.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 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

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