KTNEF Library
ktnefmessage.cpp
Go to the documentation of this file.
00001 /* 00002 ktnefmessage.cpp 00003 00004 Copyright (C) 2002 Michael Goffioul <kdeprint@swing.be> 00005 00006 This file is part of KTNEF, the KDE TNEF support library/program. 00007 00008 This library is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU Library General Public 00010 License as published by the Free Software Foundation; either 00011 version 2 of the License, or (at your option) any later version. 00012 00013 This library is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Library General Public License for more details. 00017 00018 You should have received a copy of the GNU Library General Public License 00019 along with this library; see the file COPYING.LIB. If not, write to 00020 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00021 Boston, MA 02110-1301, USA. 00022 */ 00031 #include "ktnefmessage.h" 00032 #include "ktnefattach.h" 00033 #include "lzfu.h" 00034 00035 #include <QtCore/QBuffer> 00036 #include <QtCore/QList> 00037 00038 using namespace KTnef; 00039 00044 //@cond PRIVATE 00045 class KTnef::KTNEFMessage::MessagePrivate 00046 { 00047 public: 00048 MessagePrivate() {} 00049 ~MessagePrivate(); 00050 00051 void clearAttachments(); 00052 00053 QList<KTNEFAttach *>attachments_; 00054 }; 00055 00056 KTNEFMessage::MessagePrivate::~MessagePrivate() 00057 { 00058 clearAttachments(); 00059 } 00060 00061 void KTNEFMessage::MessagePrivate::clearAttachments() 00062 { 00063 while ( !attachments_.isEmpty() ) { 00064 delete attachments_.takeFirst(); 00065 } 00066 } 00067 //@endcond 00068 00069 KTNEFMessage::KTNEFMessage() : d( new KTnef::KTNEFMessage::MessagePrivate ) 00070 { 00071 } 00072 00073 KTNEFMessage::~KTNEFMessage() 00074 { 00075 delete d; 00076 } 00077 00078 const QList<KTNEFAttach *> &KTNEFMessage::attachmentList() const 00079 { 00080 return d->attachments_; 00081 } 00082 00083 KTNEFAttach *KTNEFMessage::attachment( const QString &filename ) const 00084 { 00085 QList<KTNEFAttach *>::const_iterator it = d->attachments_.constBegin(); 00086 for ( ; it != d->attachments_.constEnd(); ++it ) { 00087 if ( (*it)->name() == filename ) { 00088 return *it; 00089 } 00090 } 00091 return 0; 00092 } 00093 00094 void KTNEFMessage::addAttachment( KTNEFAttach *attach ) 00095 { 00096 d->attachments_.append( attach ); 00097 } 00098 00099 void KTNEFMessage::clearAttachments() 00100 { 00101 d->clearAttachments(); 00102 } 00103 00104 QString KTNEFMessage::rtfString() const 00105 { 00106 QVariant prop = property( 0x1009 ); 00107 if ( prop.isNull() || prop.type() != QVariant::ByteArray ) { 00108 return QString(); 00109 } else { 00110 QByteArray rtf; 00111 QByteArray propArray( prop.toByteArray() ); 00112 QBuffer input( &propArray ), output( &rtf ); 00113 if ( input.open( QIODevice::ReadOnly ) && 00114 output.open( QIODevice::WriteOnly ) ) { 00115 lzfu_decompress( &input, &output ); 00116 } 00117 return QString( rtf ); 00118 } 00119 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:10:31 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:10:31 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.