blob: d94efb6c433017ce71597d3739d2a2d717533ffc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*
ktnefmessage.cpp
Copyright (C) 2002 Michael Goffioul <kdeprint@swing.be>
This file is part of KTNEF, the KDE TNEF support library/program.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "ktnef/ktnefmessage.h"
#include "ktnef/ktnefattach.h"
#include "lzfu.h"
#include <qbuffer.h>
class KTNEFMessage::MessagePrivate
{
public:
MessagePrivate()
{
attachments_.setAutoDelete( true );
}
QPtrList<KTNEFAttach> attachments_;
};
KTNEFMessage::KTNEFMessage()
{
d = new MessagePrivate;
}
KTNEFMessage::~KTNEFMessage()
{
delete d;
}
const QPtrList<KTNEFAttach>& KTNEFMessage::attachmentList() const
{
return d->attachments_;
}
KTNEFAttach* KTNEFMessage::attachment( const QString& filename ) const
{
QPtrListIterator<KTNEFAttach> it( d->attachments_ );
for ( ; it.current(); ++it )
if ( it.current()->name() == filename )
return it.current();
return 0;
}
void KTNEFMessage::addAttachment( KTNEFAttach *attach )
{
d->attachments_.append( attach );
}
void KTNEFMessage::clearAttachments()
{
d->attachments_.clear();
}
QString KTNEFMessage::rtfString()
{
QVariant prop = property( 0x1009 );
if ( prop.isNull() || prop.type() != QVariant::ByteArray)
return QString::null;
else
{
QByteArray rtf;
QBuffer input( prop.asByteArray() ), output( rtf );
if ( input.open( IO_ReadOnly ) && output.open( IO_WriteOnly ) )
lzfu_decompress( &input, &output );
return QString( rtf );
}
}
|