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

0001 /*
0002     ktnefattach.h
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 #pragma once
0019 
0020 #include <QString>
0021 
0022 #include "ktnef_export.h"
0023 #include "ktnefpropertyset.h"
0024 #include <memory>
0025 
0026 namespace KTnef
0027 {
0028 class KTNEFProperty;
0029 }
0030 
0031 namespace KTnef
0032 {
0033 /**
0034  * @brief
0035  * Represents a @acronym TNEF attachment.
0036  */
0037 class KTNEF_EXPORT KTNEFAttach : public KTNEFPropertySet
0038 {
0039 public:
0040     /**
0041      * The different attachment parsed states.
0042      */
0043     enum ParseState {
0044         Unparsed = 0x0000, /**< Unparsed */
0045         TitleParsed = 0x0001, /**< The title is parsed */
0046         DataParsed = 0x0002, /**< The data is parsed */
0047         InfoParsed = 0x0004 /**< The info is parsed */
0048     };
0049 
0050     /**
0051      * Constructs a @acronym TNEF attachment.
0052      */
0053     KTNEFAttach();
0054 
0055     /**
0056      * Destroys the @acronym TNEF attachment.
0057      */
0058     ~KTNEFAttach();
0059 
0060     /**
0061      * Sets the #TitleParsed flag for this attachment.
0062      */
0063     void setTitleParsed();
0064 
0065     /**
0066      * Sets the #DataParsed flag for this attachment.
0067      */
0068     void setDataParsed();
0069 
0070     /**
0071      * Unsets the #DataParsed flag for this attachment.
0072      */
0073     void unsetDataParser();
0074 
0075     /**
0076      * Sets the #InfoParsed flag for this attachment.
0077      */
0078     void setInfoParsed();
0079 
0080     /**
0081      * Returns true if the #TitleParsed flag is set; else returns false.
0082      */
0083     [[nodiscard]] bool titleParsed() const;
0084 
0085     /**
0086      * Returns true if the ParseState::DataParsed flag is set; else returns false.
0087      */
0088     [[nodiscard]] bool dataParsed() const;
0089 
0090     /**
0091      * Returns true if the #InfoParsed flag is set; else returns false.
0092      */
0093     [[nodiscard]] bool infoParsed() const;
0094 
0095     /**
0096      * Sets/Unsets the attachment state according to the @p state flag
0097      * must be a #ParseState type.
0098      *
0099      * @param state a #ParseState type.
0100      * @return true if the state is turned-on; else returns false.
0101      */
0102     [[nodiscard]] bool checkState(int state) const;
0103 
0104     /**
0105      * Sets the offset value of this attachment to @p offset.
0106      *
0107      * @param offset is the attachment offset to set.
0108      */
0109     void setOffset(int offset);
0110 
0111     /**
0112      * Returns the offset value of the attachment.
0113      */
0114     [[nodiscard]] int offset() const;
0115 
0116     /**
0117      * Sets the size of the attachment to @p size.
0118      *
0119      * @param size is the attachment size to set.
0120      */
0121     void setSize(int size);
0122 
0123     /**
0124      * Returns the size of the attachment.
0125      */
0126     [[nodiscard]] int size() const;
0127 
0128     /**
0129      * Sets the display size of the attachment to @p size.
0130      *
0131      * @param size is the attachment display size to set.
0132      */
0133     void setDisplaySize(int size);
0134 
0135     /**
0136      * Returns the display size of the attachment.
0137      */
0138     [[nodiscard]] int displaySize() const;
0139 
0140     /**
0141      * Sets the name of this attachment to @p str.
0142      *
0143      * @param str is attachment name to set.
0144      */
0145     void setName(const QString &str);
0146 
0147     /**
0148      * Returns the name of the attachment.
0149      */
0150     [[nodiscard]] QString name() const;
0151 
0152     /**
0153      * Sets the index of this attachment to @p indx.
0154      *
0155      * @param indx is the attachment index to set.
0156      */
0157     void setIndex(int indx);
0158 
0159     /**
0160      * Returns the index of the attachment.
0161      */
0162     [[nodiscard]] int index() const;
0163 
0164     /**
0165      * Sets the filename of this attachment to @p str.
0166      *
0167      * @param str is the attachment filename to set.
0168      */
0169     void setFileName(const QString &str);
0170 
0171     /**
0172      * Returns the filename of the attachment.
0173      */
0174     [[nodiscard]] QString fileName() const;
0175 
0176     /**
0177      * Sets the display name of this attachment to @p str.
0178      *
0179      * @param str is the attachment display name to set.
0180      */
0181     void setDisplayName(const QString &str);
0182 
0183     /**
0184      * Returns the display name of the attachment.
0185      */
0186     [[nodiscard]] QString displayName() const;
0187 
0188     /**
0189      * Sets the @acronym MIME tag of this attachment to @p str.
0190      *
0191      * @param str is the attachment @acronym MIME tag to set.
0192      */
0193     void setMimeTag(const QString &str);
0194 
0195     /**
0196      * Returns the @acronym MIME tag of the attachment.
0197      */
0198     [[nodiscard]] QString mimeTag() const;
0199 
0200     /**
0201      * Sets the filename extension of this attachment to @p str.
0202      *
0203      * @param str is the attachment filename extension to set.
0204      */
0205     void setExtension(const QString &str);
0206 
0207     /**
0208      * Returns the filename extension of the attachment.
0209      */
0210     [[nodiscard]] QString extension() const;
0211 
0212 private:
0213     //@cond PRIVATE
0214     class AttachPrivate;
0215     std::unique_ptr<AttachPrivate> const d;
0216     //@endcond
0217 
0218     Q_DISABLE_COPY(KTNEFAttach)
0219 };
0220 
0221 }