File indexing completed on 2024-11-10 04:32:38

0001 /*
0002    SPDX-FileCopyrightText: 2022-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 <QDebug>
0011 #include <QJsonArray>
0012 #include <QPixmap>
0013 
0014 class LIBRUQOLACORE_EXPORT NotificationInfo
0015 {
0016     Q_GADGET
0017 public:
0018     NotificationInfo();
0019     ~NotificationInfo();
0020 
0021     enum NotificationType {
0022         StandardMessage,
0023         ConferenceCall,
0024     };
0025     Q_ENUM(NotificationType);
0026 
0027     [[nodiscard]] const QString &accountName() const;
0028     void setAccountName(const QString &newAccountName);
0029 
0030     [[nodiscard]] const QString &message() const;
0031     void setMessage(const QString &newMessage);
0032 
0033     [[nodiscard]] const QString &title() const;
0034     void setTitle(const QString &newTitle);
0035 
0036     [[nodiscard]] const QString &senderId() const;
0037     void setSenderId(const QString &newSenderId);
0038 
0039     [[nodiscard]] const QString &senderName() const;
0040     void setSenderName(const QString &newSenderName);
0041 
0042     [[nodiscard]] const QString &senderUserName() const;
0043     void setSenderUserName(const QString &newSenderUserName);
0044 
0045     [[nodiscard]] const QString &roomName() const;
0046     void setRoomName(const QString &newRoomName);
0047 
0048     [[nodiscard]] const QString &roomId() const;
0049     void setRoomId(const QString &newRoomId);
0050 
0051     [[nodiscard]] const QString &channelType() const;
0052     void setChannelType(const QString &newChannelType);
0053 
0054     [[nodiscard]] const QString &tmId() const;
0055     void setTmId(const QString &newTmId);
0056 
0057     [[nodiscard]] const QPixmap &pixmap() const;
0058     void setPixmap(const QPixmap &newPixmap);
0059 
0060     void parseNotification(const QJsonArray &contents);
0061 
0062     // Pixmap can be null.
0063     [[nodiscard]] bool isValid() const;
0064 
0065     [[nodiscard]] const QString &dateTime() const;
0066     void setDateTime(const QString &newDateTime);
0067 
0068     [[nodiscard]] const QString &messageId() const;
0069     void setMessageId(const QString &newMessageId);
0070 
0071     [[nodiscard]] NotificationType notificationType() const;
0072     void setNotificationType(const NotificationType &newNotificationType);
0073 
0074     [[nodiscard]] bool operator==(const NotificationInfo &other) const;
0075 
0076 private:
0077     QString mMessageId;
0078     QString mAccountName;
0079     QString mMessage;
0080     QString mTitle;
0081     QString mSenderId;
0082     QString mSenderName;
0083     QString mSenderUserName;
0084     QString mRoomName;
0085     QString mRoomId;
0086     QString mChannelType;
0087     QString mTmId;
0088     QString mDateTime;
0089     QPixmap mPixmap;
0090     NotificationType mNotificationType = StandardMessage;
0091 };
0092 Q_DECLARE_TYPEINFO(NotificationInfo, Q_RELOCATABLE_TYPE);
0093 LIBRUQOLACORE_EXPORT QDebug operator<<(QDebug d, const NotificationInfo &t);