1 /* 2 SPDX-FileCopyrightText: 2017 Krzysztof Nowicki <krissn@op.pl> 3 4 SPDX-License-Identifier: LGPL-2.0-or-later 5 */ 6 7 #pragma once 8 9 #include <QDateTime> 10 #include <QSharedDataPointer> 11 #include <QVector> 12 #include <QXmlStreamReader> 13 #include <QXmlStreamWriter> 14 15 #include "ewsitem.h" 16 #include "ewspropertyfield.h" 17 #include "ewstypes.h" 18 19 class EwsAttachmentPrivate; 20 21 class EwsAttachment 22 { 23 public: 24 enum Type { 25 UnknownAttachment, 26 ItemAttachment, 27 FileAttachment, 28 ReferenceAttachment // Occurs in 2016 XSD, but not documented on MSDN 29 }; 30 31 typedef QVector<EwsAttachment> List; 32 33 EwsAttachment(); 34 ~EwsAttachment(); 35 explicit EwsAttachment(QXmlStreamReader &reader); 36 EwsAttachment(const EwsAttachment &other); 37 EwsAttachment(EwsAttachment &&other); 38 EwsAttachment &operator=(EwsAttachment &&other); 39 EwsAttachment &operator=(const EwsAttachment &other); 40 41 bool isValid() const; 42 43 Type type() const; 44 void setType(Type type); 45 46 QString id() const; 47 void setId(const QString &id); 48 void resetId(); 49 bool hasId() const; 50 51 QString name() const; 52 void setName(const QString &name); 53 void resetName(); 54 bool hasName() const; 55 56 QString contentType() const; 57 void setContentType(const QString &contentType); 58 void resetContentType(); 59 bool hasContentType() const; 60 61 QString contentId() const; 62 void setContentId(const QString &contentId); 63 void resetContentId(); 64 bool hasContentId() const; 65 66 QString contentLocation() const; 67 void setContentLocation(const QString &contentLocation); 68 void resetContentLocation(); 69 bool hasContentLocation() const; 70 71 long size() const; 72 void setSize(long size); 73 void resetSize(); 74 bool hasSize() const; 75 76 QDateTime lastModifiedTime() const; 77 void setLastModifiedTime(const QDateTime &time); 78 void resetLastModifiedTime(); 79 bool hasLastModifiedTime() const; 80 81 bool isInline() const; 82 void setIsInline(bool isInline); 83 void resetIsInline(); 84 bool hasIsInline() const; 85 86 bool isContactPhoto() const; 87 void setIsContactPhoto(bool isContactPhoto); 88 void resetIsContactPhoto(); 89 bool hasIsContactPhoto() const; 90 91 QByteArray content() const; 92 void setContent(const QByteArray &content); 93 void resetContent(); 94 bool hasContent() const; 95 96 const EwsItem &item() const; 97 void setItem(const EwsItem &item); 98 void resetItem(); 99 bool hasItem() const; 100 101 void write(QXmlStreamWriter &writer) const; 102 103 protected: 104 QSharedDataPointer<EwsAttachmentPrivate> d; 105 }; 106 107 Q_DECLARE_METATYPE(EwsAttachment) 108 Q_DECLARE_METATYPE(EwsAttachment::List) 109 110