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

KTNEF Library

  • sources
  • kde-4.14
  • kdepimlibs
  • ktnef
ktnefmessage.cpp
Go to the documentation of this file.
1 /*
2  ktnefmessage.cpp
3 
4  Copyright (C) 2002 Michael Goffioul <kdeprint@swing.be>
5 
6  This file is part of KTNEF, the KDE TNEF support library/program.
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22  */
31 #include "ktnefmessage.h"
32 #include "ktnefattach.h"
33 #include "lzfu.h"
34 
35 #include <QtCore/QBuffer>
36 #include <QtCore/QList>
37 
38 using namespace KTnef;
39 
44 //@cond PRIVATE
45 class KTnef::KTNEFMessage::MessagePrivate
46 {
47  public:
48  MessagePrivate() {}
49  ~MessagePrivate();
50 
51  void clearAttachments();
52 
53  QList<KTNEFAttach *>attachments_;
54 };
55 
56 KTNEFMessage::MessagePrivate::~MessagePrivate()
57 {
58  clearAttachments();
59 }
60 
61 void KTNEFMessage::MessagePrivate::clearAttachments()
62 {
63  while ( !attachments_.isEmpty() ) {
64  delete attachments_.takeFirst();
65  }
66 }
67 //@endcond
68 
69 KTNEFMessage::KTNEFMessage() : d( new KTnef::KTNEFMessage::MessagePrivate )
70 {
71 }
72 
73 KTNEFMessage::~KTNEFMessage()
74 {
75  delete d;
76 }
77 
78 const QList<KTNEFAttach *> &KTNEFMessage::attachmentList() const
79 {
80  return d->attachments_;
81 }
82 
83 KTNEFAttach *KTNEFMessage::attachment( const QString &filename ) const
84 {
85  QList<KTNEFAttach *>::const_iterator it = d->attachments_.constBegin();
86  for ( ; it != d->attachments_.constEnd(); ++it ) {
87  if ( (*it)->name() == filename ) {
88  return *it;
89  }
90  }
91  return 0;
92 }
93 
94 void KTNEFMessage::addAttachment( KTNEFAttach *attach )
95 {
96  d->attachments_.append( attach );
97 }
98 
99 void KTNEFMessage::clearAttachments()
100 {
101  d->clearAttachments();
102 }
103 
104 QString KTNEFMessage::rtfString() const
105 {
106  QVariant prop = property( 0x1009 );
107  if ( prop.isNull() || prop.type() != QVariant::ByteArray ) {
108  return QString();
109  } else {
110  QByteArray rtf;
111  QByteArray propArray( prop.toByteArray() );
112  QBuffer input( &propArray ), output( &rtf );
113  if ( input.open( QIODevice::ReadOnly ) &&
114  output.open( QIODevice::WriteOnly ) ) {
115  lzfu_decompress( &input, &output );
116  }
117  return QString( rtf );
118  }
119 }
QVariant::toByteArray
QByteArray toByteArray() const
KTnef::KTNEFPropertySet::property
QVariant property(int key) const
Returns the property associcated with the specified key.
Definition: ktnefpropertyset.cpp:135
KTnef::KTNEFMessage::rtfString
QString rtfString() const
Returns the Rich Text Format (RTF) data contained in the message.
Definition: ktnefmessage.cpp:104
QByteArray
QBuffer
ktnefmessage.h
This file is part of the API for handling TNEF data and defines the KTNEFMessage class.
QList::const_iterator
KTnef::KTNEFMessage
Represents a TNEF message.
Definition: ktnefmessage.h:49
KTnef::KTNEFMessage::clearAttachments
void clearAttachments()
Clear the attachments list.
Definition: ktnefmessage.cpp:99
lzfu.h
This file is part of the API for handling TNEF data and provides the LZFU decompression functionality...
QVariant::isNull
bool isNull() const
KTnef::KTNEFMessage::attachment
KTNEFAttach * attachment(const QString &filename) const
Find the attachment associated to the specified file name.
Definition: ktnefmessage.cpp:83
QString
QList
KTnef::KTNEFMessage::attachmentList
const QList< KTNEFAttach * > & attachmentList() const
Return a QList containing all the message's attachments.
Definition: ktnefmessage.cpp:78
KTnef::KTNEFAttach
Represents a TNEF attachment.
Definition: ktnefattach.h:51
KTnef::KTNEFMessage::KTNEFMessage
KTNEFMessage()
Creates a KTNEFMessage message object.
Definition: ktnefmessage.cpp:69
KTnef::KTNEFMessage::~KTNEFMessage
~KTNEFMessage()
Destroys a KTNEFMessage message object.
Definition: ktnefmessage.cpp:73
KTnef::KTNEFMessage::addAttachment
void addAttachment(KTNEFAttach *attach)
Append an attachment to the message.
Definition: ktnefmessage.cpp:94
lzfu_decompress
int lzfu_decompress(QIODevice *input, QIODevice *output)
LZFU decompress data in compressed Rich Text Format (RTF).
Definition: lzfu.cpp:76
QVariant::type
Type type() const
ktnefattach.h
This file is part of the API for handling TNEF data and defines the KTNEFAttach class.
QVariant
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:38:43 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KTNEF Library

Skip menu "KTNEF Library"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2

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