File indexing completed on 2024-12-22 04:57:03
0001 /* 0002 SPDX-FileCopyrightText: 2015-2017 Krzysztof Nowicki <krissn@op.pl> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QSharedPointer> 0010 0011 #include "ewsid.h" 0012 #include "ewsrequest.h" 0013 #include "ewstypes.h" 0014 0015 class EwsSubscribeRequest : public EwsRequest 0016 { 0017 Q_OBJECT 0018 public: 0019 enum Type { 0020 PullSubscription = 0, 0021 PushSubscription, 0022 StreamingSubscription, 0023 }; 0024 0025 class Response : public EwsRequest::Response 0026 { 0027 public: 0028 const QString &subscriptionId() const 0029 { 0030 return mId; 0031 } 0032 0033 const QString &watermark() const 0034 { 0035 return mWatermark; 0036 } 0037 0038 protected: 0039 Response(QXmlStreamReader &reader); 0040 0041 QString mId; 0042 QString mWatermark; 0043 0044 friend class EwsSubscribeRequest; 0045 }; 0046 0047 EwsSubscribeRequest(EwsClient &client, QObject *parent); 0048 ~EwsSubscribeRequest() override; 0049 0050 void setType(Type t) 0051 { 0052 mType = t; 0053 } 0054 0055 void setFolderIds(const EwsId::List &folders) 0056 { 0057 mFolderIds = folders; 0058 } 0059 0060 void setAllFolders(bool allFolders) 0061 { 0062 mAllFolders = allFolders; 0063 } 0064 0065 void setEventTypes(const QList<EwsEventType> &types) 0066 { 0067 mEventTypes = types; 0068 } 0069 0070 void setWatermark(const QString &watermark) 0071 { 0072 mWatermark = watermark; 0073 } 0074 0075 void setTimeout(uint timeout) 0076 { 0077 mTimeout = timeout; 0078 } 0079 0080 const Response &response() const 0081 { 0082 return *mResponse; 0083 } 0084 0085 void start() override; 0086 0087 protected: 0088 bool parseResult(QXmlStreamReader &reader) override; 0089 bool parseSubscribeResponse(QXmlStreamReader &reader); 0090 0091 private: 0092 // QSharedPointer<EwsSubscription> mSubscription; 0093 Type mType; 0094 EwsId::List mFolderIds; 0095 QList<EwsEventType> mEventTypes; 0096 bool mAllFolders; 0097 QString mWatermark; 0098 uint mTimeout; 0099 0100 QSharedPointer<Response> mResponse; 0101 };