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 <QString>
0010 
0011 class QXmlStreamReader;
0012 class QXmlStreamWriter;
0013 
0014 class EwsServerVersion
0015 {
0016 public:
0017     enum ServerFeature {
0018         StreamingSubscription,
0019         FreeBusyChangedEvent,
0020     };
0021 
0022     EwsServerVersion()
0023         : mMajor(0)
0024         , mMinor(0)
0025         , mMajorBuild(0)
0026         , mMinorBuild(0)
0027     {
0028     }
0029 
0030     EwsServerVersion(uint major, uint minor, const QString &name, const QString &friendlyName)
0031         : mMajor(major)
0032         , mMinor(minor)
0033         , mMajorBuild(0)
0034         , mMinorBuild(0)
0035         , mName(name)
0036         , mFriendlyName(friendlyName)
0037     {
0038     }
0039 
0040     explicit EwsServerVersion(QXmlStreamReader &reader);
0041     EwsServerVersion(const EwsServerVersion &other)
0042         : mMajor(other.mMajor)
0043         , mMinor(other.mMinor)
0044         , mMajorBuild(other.mMajorBuild)
0045         , mMinorBuild(other.mMinorBuild)
0046         , mName(other.mName)
0047         , mFriendlyName(other.mFriendlyName)
0048     {
0049     }
0050 
0051     EwsServerVersion &operator=(const EwsServerVersion &other)
0052     {
0053         mMajor = other.mMajor;
0054         mMinor = other.mMinor;
0055         mMajorBuild = other.mMajorBuild;
0056         mMinorBuild = other.mMinorBuild;
0057         mName = other.mName;
0058         mFriendlyName = other.mFriendlyName;
0059         return *this;
0060     }
0061 
0062     void writeRequestServerVersion(QXmlStreamWriter &writer) const;
0063 
0064     bool operator>(const EwsServerVersion &other) const
0065     {
0066         return (mMajor > other.mMajor) ? true : ((mMinor > other.mMinor) ? true : false);
0067     }
0068 
0069     bool operator<(const EwsServerVersion &other) const
0070     {
0071         return (mMajor < other.mMajor) ? true : ((mMinor < other.mMinor) ? true : false);
0072     }
0073 
0074     bool operator>=(const EwsServerVersion &other) const
0075     {
0076         return !(*this < other);
0077     }
0078 
0079     bool operator<=(const EwsServerVersion &other) const
0080     {
0081         return !(*this > other);
0082     }
0083 
0084     bool operator==(const EwsServerVersion &other) const
0085     {
0086         return (mMajor == other.mMajor) && (mMinor == other.mMinor);
0087     }
0088 
0089     bool operator!=(const EwsServerVersion &other) const
0090     {
0091         return !(*this == other);
0092     }
0093 
0094     bool supports(ServerFeature feature) const;
0095 
0096     bool isValid() const
0097     {
0098         return mMajor != 0;
0099     }
0100 
0101     uint majorVersion() const
0102     {
0103         return mMajor;
0104     }
0105 
0106     uint minorVersion() const
0107     {
0108         return mMinor;
0109     }
0110 
0111     QString name() const
0112     {
0113         return mName;
0114     }
0115 
0116     static const EwsServerVersion &minSupporting(ServerFeature feature);
0117 
0118     QString toString() const;
0119 
0120     static const EwsServerVersion ewsVersion2007;
0121     static const EwsServerVersion ewsVersion2007Sp1;
0122     static const EwsServerVersion ewsVersion2007Sp2;
0123     static const EwsServerVersion ewsVersion2007Sp3;
0124     static const EwsServerVersion ewsVersion2010;
0125     static const EwsServerVersion ewsVersion2010Sp1;
0126     static const EwsServerVersion ewsVersion2010Sp2;
0127     static const EwsServerVersion ewsVersion2010Sp3;
0128     static const EwsServerVersion ewsVersion2013;
0129     static const EwsServerVersion ewsVersion2016;
0130 
0131 private:
0132     uint mMajor;
0133     uint mMinor;
0134     uint mMajorBuild;
0135     uint mMinorBuild;
0136     QString mName;
0137     QString mFriendlyName;
0138 };
0139 
0140 QDebug operator<<(const QDebug dbg, const EwsServerVersion &version);