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

0001 /*
0002     SPDX-FileCopyrightText: 2015-2016 Krzysztof Nowicki <krissn@op.pl>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "ewsitem.h"
0010 #include "ewsitemshape.h"
0011 #include "ewsrequest.h"
0012 #include "ewstypes.h"
0013 
0014 class EwsSyncFolderItemsRequest : public EwsRequest
0015 {
0016     Q_OBJECT
0017 public:
0018     enum ChangeType {
0019         Create,
0020         Update,
0021         Delete,
0022         ReadFlagChange,
0023         Unknown,
0024     };
0025 
0026     class Response;
0027 
0028     class Change
0029     {
0030     public:
0031         typedef QList<Change> List;
0032 
0033         ChangeType type() const
0034         {
0035             return mType;
0036         }
0037 
0038         const EwsId &itemId() const
0039         {
0040             return mId;
0041         }
0042 
0043         const EwsItem &item() const
0044         {
0045             return mItem;
0046         }
0047 
0048         bool isRead() const
0049         {
0050             return mIsRead;
0051         }
0052 
0053     protected:
0054         Change(QXmlStreamReader &reader);
0055         bool isValid() const
0056         {
0057             return mType != Unknown;
0058         }
0059 
0060         ChangeType mType;
0061         EwsId mId;
0062         EwsItem mItem;
0063         bool mIsRead;
0064 
0065         friend class Response;
0066     };
0067 
0068     EwsSyncFolderItemsRequest(EwsClient &client, QObject *parent);
0069     ~EwsSyncFolderItemsRequest() override;
0070 
0071     void setFolderId(const EwsId &id);
0072     void setItemShape(const EwsItemShape &shape);
0073     void setSyncState(const QString &state);
0074     void setMaxChanges(uint max);
0075 
0076     void start() override;
0077 
0078     bool includesLastItem() const
0079     {
0080         return mIncludesLastItem;
0081     }
0082 
0083     const Change::List &changes() const
0084     {
0085         return mChanges;
0086     }
0087 
0088     const QString &syncState() const
0089     {
0090         return mSyncState;
0091     }
0092 
0093 protected:
0094     bool parseResult(QXmlStreamReader &reader) override;
0095     bool parseItemsResponse(QXmlStreamReader &reader);
0096 
0097 private:
0098     EwsId mFolderId;
0099     EwsItemShape mShape;
0100     QString mSyncState;
0101     uint mMaxChanges;
0102     Change::List mChanges;
0103     bool mIncludesLastItem;
0104 };
0105 
0106 Q_DECLARE_METATYPE(EwsSyncFolderItemsRequest::Change::List)