File indexing completed on 2025-01-05 04:50:01

0001 /*
0002     SPDX-FileCopyrightText: 2015-2018 Krzysztof Nowicki <krissn@op.pl>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QObject>
0010 #include <QPointer>
0011 #include <QString>
0012 #include <QUrl>
0013 
0014 #include "ewsserverversion.h"
0015 
0016 class EwsAbstractAuth;
0017 
0018 class EwsClient : public QObject
0019 {
0020     Q_OBJECT
0021 public:
0022     explicit EwsClient(QObject *parent = nullptr);
0023     ~EwsClient() override;
0024 
0025     void setUrl(const QString &url)
0026     {
0027         mUrl.setUrl(url);
0028     }
0029 
0030     void setAuth(EwsAbstractAuth *auth);
0031     EwsAbstractAuth *auth() const;
0032 
0033     enum RequestedConfiguration {
0034         MailTips = 0,
0035         UnifiedMessagingConfiguration,
0036         ProtectionRules,
0037     };
0038 
0039     QUrl url() const;
0040 
0041     bool isConfigured() const
0042     {
0043         return !mUrl.isEmpty();
0044     }
0045 
0046     void setServerVersion(const EwsServerVersion &version);
0047     const EwsServerVersion &serverVersion() const
0048     {
0049         return mServerVersion;
0050     }
0051 
0052     void setUserAgent(const QString &userAgent)
0053     {
0054         mUserAgent = userAgent;
0055     }
0056 
0057     const QString &userAgent() const
0058     {
0059         return mUserAgent;
0060     }
0061 
0062     void setEnableNTLMv2(bool enable)
0063     {
0064         mEnableNTLMv2 = enable;
0065     }
0066 
0067     bool isNTLMv2Enabled() const
0068     {
0069         return mEnableNTLMv2;
0070     }
0071 
0072     static QHash<QString, QString> folderHash;
0073 Q_SIGNALS:
0074     void oAuthTokensChanged(const QString &accessToken, const QString &refreshToken);
0075     void oAuthBrowserDisplayRequest();
0076 
0077 private:
0078     QUrl mUrl;
0079 
0080     QPointer<EwsAbstractAuth> mAuth;
0081 
0082     QString mUserAgent;
0083     bool mEnableNTLMv2;
0084 
0085     EwsServerVersion mServerVersion;
0086 
0087     friend class EwsRequest;
0088 };