File indexing completed on 2024-12-22 04:57:00

0001 /*
0002     SPDX-FileCopyrightText: 2017 Krzysztof Nowicki <krissn@op.pl>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QDateTime>
0010 #include <QList>
0011 #include <QSharedDataPointer>
0012 #include <QXmlStreamReader>
0013 #include <QXmlStreamWriter>
0014 
0015 #include "ewsitem.h"
0016 #include "ewspropertyfield.h"
0017 #include "ewstypes.h"
0018 
0019 class EwsAttachmentPrivate;
0020 
0021 class EwsAttachment
0022 {
0023 public:
0024     enum Type {
0025         UnknownAttachment,
0026         ItemAttachment,
0027         FileAttachment,
0028         ReferenceAttachment // Occurs in 2016 XSD, but not documented on MSDN
0029     };
0030 
0031     typedef QList<EwsAttachment> List;
0032 
0033     EwsAttachment();
0034     ~EwsAttachment();
0035     explicit EwsAttachment(QXmlStreamReader &reader);
0036     EwsAttachment(const EwsAttachment &other);
0037     EwsAttachment(EwsAttachment &&other);
0038     EwsAttachment &operator=(EwsAttachment &&other);
0039     EwsAttachment &operator=(const EwsAttachment &other);
0040 
0041     bool isValid() const;
0042 
0043     Type type() const;
0044     void setType(Type type);
0045 
0046     QString id() const;
0047     void setId(const QString &id);
0048     void resetId();
0049     bool hasId() const;
0050 
0051     QString name() const;
0052     void setName(const QString &name);
0053     void resetName();
0054     bool hasName() const;
0055 
0056     QString contentType() const;
0057     void setContentType(const QString &contentType);
0058     void resetContentType();
0059     bool hasContentType() const;
0060 
0061     QString contentId() const;
0062     void setContentId(const QString &contentId);
0063     void resetContentId();
0064     bool hasContentId() const;
0065 
0066     QString contentLocation() const;
0067     void setContentLocation(const QString &contentLocation);
0068     void resetContentLocation();
0069     bool hasContentLocation() const;
0070 
0071     long size() const;
0072     void setSize(long size);
0073     void resetSize();
0074     bool hasSize() const;
0075 
0076     QDateTime lastModifiedTime() const;
0077     void setLastModifiedTime(const QDateTime &time);
0078     void resetLastModifiedTime();
0079     bool hasLastModifiedTime() const;
0080 
0081     bool isInline() const;
0082     void setIsInline(bool isInline);
0083     void resetIsInline();
0084     bool hasIsInline() const;
0085 
0086     bool isContactPhoto() const;
0087     void setIsContactPhoto(bool isContactPhoto);
0088     void resetIsContactPhoto();
0089     bool hasIsContactPhoto() const;
0090 
0091     QByteArray content() const;
0092     void setContent(const QByteArray &content);
0093     void resetContent();
0094     bool hasContent() const;
0095 
0096     const EwsItem &item() const;
0097     void setItem(const EwsItem &item);
0098     void resetItem();
0099     bool hasItem() const;
0100 
0101     void write(QXmlStreamWriter &writer) const;
0102 
0103 protected:
0104     QSharedDataPointer<EwsAttachmentPrivate> d;
0105 };
0106 
0107 Q_DECLARE_METATYPE(EwsAttachment)
0108 Q_DECLARE_METATYPE(EwsAttachment::List)