File indexing completed on 2024-03-03 15:46:54

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqolacore_export.h"
0010 #include "user.h"
0011 #include <QDebug>
0012 
0013 class LIBRUQOLACORE_EXPORT CustomUserStatus
0014 {
0015 public:
0016     CustomUserStatus();
0017     ~CustomUserStatus();
0018 
0019     [[nodiscard]] bool isValid() const;
0020 
0021     [[nodiscard]] QString name() const;
0022     void setName(const QString &value);
0023 
0024     [[nodiscard]] qint64 updatedAt() const;
0025     void setUpdatedAt(qint64 updatedAt);
0026 
0027     [[nodiscard]] QString identifier() const;
0028     void setIdentifier(const QString &identifier);
0029 
0030     [[nodiscard]] User::PresenceStatus statusType() const;
0031     void setStatusType(User::PresenceStatus statusType);
0032 
0033     void parseCustomStatus(const QJsonObject &customStatusObj, bool useRestApi = true);
0034 
0035     [[nodiscard]] bool operator==(const CustomUserStatus &other) const;
0036 
0037 private:
0038     QString mIdentifier;
0039     QString mName;
0040     qint64 mUpdatedAt = -1;
0041     User::PresenceStatus mStatusType = User::PresenceStatus::Unknown;
0042 };
0043 Q_DECLARE_METATYPE(CustomUserStatus)
0044 Q_DECLARE_TYPEINFO(CustomUserStatus, Q_MOVABLE_TYPE);
0045 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const CustomUserStatus &t);