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 | |
34 | using namespace KTnef; |
35 | |
36 | /** |
37 | * Private class that helps to provide binary compatibility between releases. |
38 | * @internal |
39 | */ |
40 | //@cond PRIVATE |
41 | class 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 | |
57 | KTNEFAttach::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 | |
66 | KTNEFAttach::~KTNEFAttach() |
67 | { |
68 | delete d; |
69 | } |
70 | |
71 | void KTNEFAttach::setTitleParsed() |
72 | { |
73 | d->state_ |= TitleParsed; |
74 | } |
75 | |
76 | void KTNEFAttach::setDataParsed() |
77 | { |
78 | d->state_ |= DataParsed; |
79 | } |
80 | |
81 | void KTNEFAttach::unsetDataParser() |
82 | { |
83 | d->state_ = ( d->state_ & ~DataParsed ); |
84 | } |
85 | |
86 | void KTNEFAttach::setInfoParsed() |
87 | { |
88 | d->state_ |= InfoParsed; |
89 | } |
90 | |
91 | bool KTNEFAttach::titleParsed() const |
92 | { |
93 | return d->state_ & TitleParsed; |
94 | } |
95 | |
96 | bool KTNEFAttach::dataParsed() const |
97 | { |
98 | return d->state_ & DataParsed; |
99 | } |
100 | |
101 | bool KTNEFAttach::infoParsed() const |
102 | { |
103 | return d->state_ & InfoParsed; |
104 | } |
105 | |
106 | bool KTNEFAttach::checkState( int state ) const |
107 | { |
108 | return d->state_ & state; |
109 | } |
110 | |
111 | int KTNEFAttach::offset() const |
112 | { |
113 | return d->offset_; |
114 | } |
115 | |
116 | void KTNEFAttach::setOffset( int n ) |
117 | { |
118 | setDataParsed(); |
119 | d->offset_ = n; |
120 | } |
121 | |
122 | int KTNEFAttach::size() const |
123 | { |
124 | return d->size_; |
125 | } |
126 | |
127 | void KTNEFAttach::setSize( int s ) |
128 | { |
129 | d->size_ = s; |
130 | } |
131 | |
132 | int KTNEFAttach::displaySize() const |
133 | { |
134 | return d->displaysize_; |
135 | } |
136 | |
137 | void KTNEFAttach::setDisplaySize( int s ) |
138 | { |
139 | d->displaysize_ = s; |
140 | } |
141 | |
142 | QString KTNEFAttach::name() const |
143 | { |
144 | return d->name_; |
145 | } |
146 | |
147 | void KTNEFAttach::setName( const QString &str ) |
148 | { |
149 | setTitleParsed(); |
150 | d->name_ = str; |
151 | } |
152 | |
153 | int KTNEFAttach::index() const |
154 | { |
155 | return d->index_; |
156 | } |
157 | |
158 | void KTNEFAttach::setIndex( int i ) |
159 | { |
160 | setInfoParsed(); |
161 | d->index_ = i; |
162 | } |
163 | |
164 | QString KTNEFAttach::fileName() const |
165 | { |
166 | return d->filename_; |
167 | } |
168 | |
169 | void KTNEFAttach::setFileName( const QString &str ) |
170 | { |
171 | d->filename_ = str; |
172 | } |
173 | |
174 | QString KTNEFAttach::displayName() const |
175 | { |
176 | return d->displayname_; |
177 | } |
178 | |
179 | void KTNEFAttach::setDisplayName( const QString &str ) |
180 | { |
181 | d->displayname_ = str; |
182 | } |
183 | |
184 | QString KTNEFAttach::mimeTag() const |
185 | { |
186 | return d->mimetag_; |
187 | } |
188 | |
189 | void KTNEFAttach::setMimeTag( const QString &str ) |
190 | { |
191 | d->mimetag_ = str; |
192 | } |
193 | |
194 | QString KTNEFAttach::extension() const |
195 | { |
196 | return d->extension_; |
197 | } |
198 | |
199 | void KTNEFAttach::setExtension( const QString &str ) |
200 | { |
201 | d->extension_ = str; |
202 | } |
203 | |