File indexing completed on 2024-04-28 05:19:25

0001 /*
0002     ktnefattach.cpp
0003 
0004     SPDX-FileCopyrightText: 2002 Michael Goffioul <kdeprint@swing.be>
0005 
0006     This file is part of KTNEF, the KDE TNEF support library/program.
0007 
0008     SPDX-License-Identifier: LGPL-2.0-or-later
0009  */
0010 /**
0011  * @file
0012  * This file is part of the API for handling TNEF data and
0013  * defines the KTNEFAttach class.
0014  *
0015  * @author Michael Goffioul
0016  */
0017 
0018 #include "ktnefattach.h"
0019 
0020 using namespace KTnef;
0021 
0022 /**
0023  * Private class that helps to provide binary compatibility between releases.
0024  * @internal
0025  */
0026 //@cond PRIVATE
0027 class KTnef::KTNEFAttach::AttachPrivate
0028 {
0029 public:
0030     int state_;
0031     int size_;
0032     int offset_;
0033     int displaysize_;
0034     QString name_;
0035     int index_;
0036     QString filename_;
0037     QString displayname_;
0038     QString mimetag_;
0039     QString extension_;
0040 };
0041 //@endcond
0042 
0043 KTNEFAttach::KTNEFAttach()
0044     : d(new KTnef::KTNEFAttach::AttachPrivate)
0045 {
0046     d->state_ = Unparsed;
0047     d->offset_ = -1;
0048     d->size_ = 0;
0049     d->displaysize_ = 0;
0050     d->index_ = -1;
0051 }
0052 
0053 KTNEFAttach::~KTNEFAttach() = default;
0054 
0055 void KTNEFAttach::setTitleParsed()
0056 {
0057     d->state_ |= TitleParsed;
0058 }
0059 
0060 void KTNEFAttach::setDataParsed()
0061 {
0062     d->state_ |= DataParsed;
0063 }
0064 
0065 void KTNEFAttach::unsetDataParser()
0066 {
0067     d->state_ = (d->state_ & ~DataParsed);
0068 }
0069 
0070 void KTNEFAttach::setInfoParsed()
0071 {
0072     d->state_ |= InfoParsed;
0073 }
0074 
0075 bool KTNEFAttach::titleParsed() const
0076 {
0077     return d->state_ & TitleParsed;
0078 }
0079 
0080 bool KTNEFAttach::dataParsed() const
0081 {
0082     return d->state_ & DataParsed;
0083 }
0084 
0085 bool KTNEFAttach::infoParsed() const
0086 {
0087     return d->state_ & InfoParsed;
0088 }
0089 
0090 bool KTNEFAttach::checkState(int state) const
0091 {
0092     return d->state_ & state;
0093 }
0094 
0095 int KTNEFAttach::offset() const
0096 {
0097     return d->offset_;
0098 }
0099 
0100 void KTNEFAttach::setOffset(int n)
0101 {
0102     setDataParsed();
0103     d->offset_ = n;
0104 }
0105 
0106 int KTNEFAttach::size() const
0107 {
0108     return d->size_;
0109 }
0110 
0111 void KTNEFAttach::setSize(int s)
0112 {
0113     d->size_ = s;
0114 }
0115 
0116 int KTNEFAttach::displaySize() const
0117 {
0118     return d->displaysize_;
0119 }
0120 
0121 void KTNEFAttach::setDisplaySize(int s)
0122 {
0123     d->displaysize_ = s;
0124 }
0125 
0126 QString KTNEFAttach::name() const
0127 {
0128     return d->name_;
0129 }
0130 
0131 void KTNEFAttach::setName(const QString &str)
0132 {
0133     setTitleParsed();
0134     d->name_ = str;
0135 }
0136 
0137 int KTNEFAttach::index() const
0138 {
0139     return d->index_;
0140 }
0141 
0142 void KTNEFAttach::setIndex(int i)
0143 {
0144     setInfoParsed();
0145     d->index_ = i;
0146 }
0147 
0148 QString KTNEFAttach::fileName() const
0149 {
0150     return d->filename_;
0151 }
0152 
0153 void KTNEFAttach::setFileName(const QString &str)
0154 {
0155     d->filename_ = str;
0156 }
0157 
0158 QString KTNEFAttach::displayName() const
0159 {
0160     return d->displayname_;
0161 }
0162 
0163 void KTNEFAttach::setDisplayName(const QString &str)
0164 {
0165     d->displayname_ = str;
0166 }
0167 
0168 QString KTNEFAttach::mimeTag() const
0169 {
0170     return d->mimetag_;
0171 }
0172 
0173 void KTNEFAttach::setMimeTag(const QString &str)
0174 {
0175     d->mimetag_ = str;
0176 }
0177 
0178 QString KTNEFAttach::extension() const
0179 {
0180     return d->extension_;
0181 }
0182 
0183 void KTNEFAttach::setExtension(const QString &str)
0184 {
0185     d->extension_ = str;
0186 }