1/*
2 ktnefattach.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 */
23/**
24 * @file
25 * This file is part of the API for handling TNEF data and
26 * defines the KTNEFAttach class.
27 *
28 * @author Michael Goffioul
29 */
30
31#include "ktnefattach.h"
32#include "ktnefproperty.h"
33
34using namespace KTnef;
35
36/**
37 * Private class that helps to provide binary compatibility between releases.
38 * @internal
39 */
40//@cond PRIVATE
41class KTnef::KTNEFAttach::AttachPrivate
42{
43 public:
44 int state_;
45 int size_;
46 int offset_;
47 int displaysize_;
48 QString name_;
49 int index_;
50 QString filename_;
51 QString displayname_;
52 QString mimetag_;
53 QString extension_;
54};
55//@endcond
56
57KTNEFAttach::KTNEFAttach() : d( new KTnef::KTNEFAttach::AttachPrivate )
58{
59 d->state_ = Unparsed;
60 d->offset_ = -1;
61 d->size_ = 0;
62 d->displaysize_ = 0;
63 d->index_ = -1;
64}
65
66KTNEFAttach::~KTNEFAttach()
67{
68 delete d;
69}
70
71void KTNEFAttach::setTitleParsed()
72{
73 d->state_ |= TitleParsed;
74}
75
76void KTNEFAttach::setDataParsed()
77{
78 d->state_ |= DataParsed;
79}
80
81void KTNEFAttach::unsetDataParser()
82{
83 d->state_ = ( d->state_ & ~DataParsed );
84}
85
86void KTNEFAttach::setInfoParsed()
87{
88 d->state_ |= InfoParsed;
89}
90
91bool KTNEFAttach::titleParsed() const
92{
93 return d->state_ & TitleParsed;
94}
95
96bool KTNEFAttach::dataParsed() const
97{
98 return d->state_ & DataParsed;
99}
100
101bool KTNEFAttach::infoParsed() const
102{
103 return d->state_ & InfoParsed;
104}
105
106bool KTNEFAttach::checkState( int state ) const
107{
108 return d->state_ & state;
109}
110
111int KTNEFAttach::offset() const
112{
113 return d->offset_;
114}
115
116void KTNEFAttach::setOffset( int n )
117{
118 setDataParsed();
119 d->offset_ = n;
120}
121
122int KTNEFAttach::size() const
123{
124 return d->size_;
125}
126
127void KTNEFAttach::setSize( int s )
128{
129 d->size_ = s;
130}
131
132int KTNEFAttach::displaySize() const
133{
134 return d->displaysize_;
135}
136
137void KTNEFAttach::setDisplaySize( int s )
138{
139 d->displaysize_ = s;
140}
141
142QString KTNEFAttach::name() const
143{
144 return d->name_;
145}
146
147void KTNEFAttach::setName( const QString &str )
148{
149 setTitleParsed();
150 d->name_ = str;
151}
152
153int KTNEFAttach::index() const
154{
155 return d->index_;
156}
157
158void KTNEFAttach::setIndex( int i )
159{
160 setInfoParsed();
161 d->index_ = i;
162}
163
164QString KTNEFAttach::fileName() const
165{
166 return d->filename_;
167}
168
169void KTNEFAttach::setFileName( const QString &str )
170{
171 d->filename_ = str;
172}
173
174QString KTNEFAttach::displayName() const
175{
176 return d->displayname_;
177}
178
179void KTNEFAttach::setDisplayName( const QString &str )
180{
181 d->displayname_ = str;
182}
183
184QString KTNEFAttach::mimeTag() const
185{
186 return d->mimetag_;
187}
188
189void KTNEFAttach::setMimeTag( const QString &str )
190{
191 d->mimetag_ = str;
192}
193
194QString KTNEFAttach::extension() const
195{
196 return d->extension_;
197}
198
199void KTNEFAttach::setExtension( const QString &str )
200{
201 d->extension_ = str;
202}
203