diff --git a/autotests/roomtest.cpp b/autotests/roomtest.cpp index 04ef1642..7c2eebc9 100644 --- a/autotests/roomtest.cpp +++ b/autotests/roomtest.cpp @@ -1,357 +1,359 @@ /* Copyright (c) 2017-2019 Montel Laurent This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License or ( at your option ) version 3 or, at the discretion of KDE e.V. ( which shall act as a proxy as in section 14 of the GPLv3 ), any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "roomtest.h" #include "room.h" #include "ruqola_autotest_helper.h" #include "model/usersforroommodel.h" #include "model/usersforroomfilterproxymodel.h" #include "model/filesforroomfilterproxymodel.h" #include "model/filesforroommodel.h" #include #include #include QTEST_GUILESS_MAIN(RoomTest) RoomTest::RoomTest(QObject *parent) : QObject(parent) { } void RoomTest::shouldHaveDefaultValue() { Room input(nullptr); QVERIFY(input.usersModelForRoom()); QVERIFY(input.usersModelForRoomProxyModel()); QVERIFY(input.filesModelForRoom()); QVERIFY(input.filesForRoomFilterProxyModel()); QCOMPARE(input.filesForRoomFilterProxyModel()->sourceModel(), input.filesModelForRoom()); QCOMPARE(input.usersModelForRoomProxyModel()->sourceModel(), input.usersModelForRoom()); QVERIFY(input.messageModel()); QVERIFY(input.inputMessage().isEmpty()); QVERIFY(input.description().isEmpty()); QVERIFY(input.announcement().isEmpty()); QVERIFY(!input.readOnly()); //Add more QCOMPARE(input.userMentions(), 0); QCOMPARE(input.unread(), 0); QCOMPARE(input.blocked(), false); QCOMPARE(input.blocker(), false); QVERIFY(input.roles().isEmpty()); QVERIFY(!input.archived()); QVERIFY(input.name().isEmpty()); QVERIFY(input.ignoredUsers().isEmpty()); QVERIFY(input.e2EKey().isEmpty()); QVERIFY(input.e2eKeyId().isEmpty()); QVERIFY(!input.encrypted()); QVERIFY(!input.alert()); QVERIFY(!input.readOnly()); QVERIFY(!input.joinCodeRequired()); } //TODO add notification, userMentions too void RoomTest::shouldSerialized() { Room input(nullptr); input.setRoomId(QStringLiteral("foo")); input.setChannelType(QStringLiteral("p")); input.setName(QStringLiteral("d")); input.setAnnouncement(QStringLiteral("AA")); input.setRoomCreatorUserName(QStringLiteral("pp")); input.setRoomCreatorUserId(QStringLiteral("sdfsdfs")); input.setTopic(QStringLiteral("topic")); input.setMutedUsers(QStringList{QStringLiteral("mutedUsers"), QStringLiteral("muted2")}); input.setJitsiTimeout(55); input.setReadOnly(true); input.setUnread(66); input.setSelected(true); input.setFavorite(true); input.setAlert(true); input.setOpen(true); input.setBlocker(true); input.setBlocked(true); input.setArchived(true); input.setDescription(QStringLiteral("dd")); input.setUserMentions(3); input.setRoles({QStringLiteral("foo"), QStringLiteral("bla")}); input.setIgnoredUsers({QStringLiteral("gg"), QStringLiteral("gg2")}); input.setJoinCodeRequired(true); const QByteArray ba = Room::serialize(&input); //qDebug() << QJsonObject(QJsonDocument::fromBinaryData(ba).object()); Room *output = Room::fromJSon(QJsonObject(QJsonDocument::fromBinaryData(ba).object())); //qDebug() << "after" << QJsonObject(QJsonDocument::fromBinaryData(Room::serialize(output)).object()); QVERIFY(input.isEqual(*output)); delete output; } void RoomTest::shouldEmitSignals() { Room input(nullptr); QSignalSpy spyNameChanged(&input, &Room::nameChanged); QSignalSpy spyannouncementChanged(&input, &Room::announcementChanged); QSignalSpy spytopicChanged(&input, &Room::topicChanged); QSignalSpy spyfavoriteChanged(&input, &Room::favoriteChanged); QSignalSpy spyalertChanged(&input, &Room::alertChanged); QSignalSpy spyreadOnlyChanged(&input, &Room::readOnlyChanged); QSignalSpy spyunreadChanged(&input, &Room::unreadChanged); QSignalSpy spyblockerChanged(&input, &Room::blockerChanged); QSignalSpy spyarchivedChanged(&input, &Room::archivedChanged); QSignalSpy spydescriptionChanged(&input, &Room::descriptionChanged); QSignalSpy spyblockedChanged(&input, &Room::blockedChanged); QSignalSpy spyrolesChanged(&input, &Room::rolesChanged); QSignalSpy spyignoredUsersChanged(&input, &Room::ignoredUsersChanged); QSignalSpy spymutedUsersChanged(&input, &Room::mutedUsersChanged); QSignalSpy spyencryptedChanged(&input, &Room::encryptedChanged); QSignalSpy spyjoinCodeRequiredChanged(&input, &Room::joinCodeRequiredChanged); + QSignalSpy spychannelTypeChanged(&input, &Room::channelTypeChanged); input.setRoomId(QStringLiteral("foo")); input.setChannelType(QStringLiteral("p")); input.setName(QStringLiteral("d")); input.setAnnouncement(QStringLiteral("AA")); input.setRoomCreatorUserName(QStringLiteral("pp")); input.setRoomCreatorUserId(QStringLiteral("sdfsdfs")); input.setTopic(QStringLiteral("topic")); input.setMutedUsers(QStringList{QStringLiteral("mutedUsers"), QStringLiteral("muted2")}); input.setJitsiTimeout(55); input.setReadOnly(true); input.setUnread(66); input.setSelected(true); input.setFavorite(true); input.setAlert(true); input.setOpen(true); input.setBlocker(true); input.setBlocked(true); input.setArchived(true); input.setEncrypted(true); input.setJoinCodeRequired(true); input.setDescription(QStringLiteral("ddd")); input.setRoles({QStringLiteral("bla"), QStringLiteral("blu")}); input.setIgnoredUsers({QStringLiteral("bla"), QStringLiteral("blu3")}); QCOMPARE(spyNameChanged.count(), 1); QCOMPARE(spyannouncementChanged.count(), 1); QCOMPARE(spytopicChanged.count(), 1); QCOMPARE(spyfavoriteChanged.count(), 1); QCOMPARE(spyalertChanged.count(), 1); QCOMPARE(spyreadOnlyChanged.count(), 1); QCOMPARE(spyunreadChanged.count(), 1); QCOMPARE(spyblockerChanged.count(), 1); QCOMPARE(spyarchivedChanged.count(), 1); QCOMPARE(spyblockedChanged.count(), 1); QCOMPARE(spydescriptionChanged.count(), 1); QCOMPARE(spyrolesChanged.count(), 1); QCOMPARE(spyignoredUsersChanged.count(), 1); QCOMPARE(spymutedUsersChanged.count(), 1); QCOMPARE(spyencryptedChanged.count(), 1); QCOMPARE(spyjoinCodeRequiredChanged.count(), 1); + QCOMPARE(spychannelTypeChanged.count(), 1); } void RoomTest::shouldChangeInputMessage() { Room input(nullptr); QString inputMsg = QStringLiteral("Foo"); input.setInputMessage(inputMsg); QCOMPARE(input.inputMessage(), inputMsg); inputMsg = QString(); input.setInputMessage(inputMsg); QCOMPARE(input.inputMessage(), inputMsg); inputMsg = QStringLiteral("foo"); input.setInputMessage(inputMsg); QCOMPARE(input.inputMessage(), inputMsg); } void RoomTest::shouldParseRoom_data() { QTest::addColumn("fileName"); //Missing _updatedAt/ts/_id/groupMentions/ls/roles (implement roles ! ) QTest::newRow("notification-room") << QStringLiteral("notification-room"); QTest::newRow("unread-usermentions-room") << QStringLiteral("unread-usermentions-room"); QTest::newRow("muted-users") << QStringLiteral("muted-users"); QTest::newRow("userignored-room") << QStringLiteral("userignored-room"); } void RoomTest::shouldParseRoom() { QFETCH(QString, fileName); const QString originalJsonFile = QLatin1String(RUQOLA_DATA_DIR) + QStringLiteral("/room/") + fileName + QStringLiteral(".json"); QFile f(originalJsonFile); QVERIFY(f.open(QIODevice::ReadOnly)); const QByteArray content = f.readAll(); f.close(); const QJsonDocument doc = QJsonDocument::fromJson(content); const QJsonObject fields = doc.object(); Room r; r.parseSubscriptionRoom(fields); //qDebug() << " fields"<("fileNameinit"); QTest::addColumn("fileNameupdate"); //Missing _updatedAt/ts/_id/groupMentions/ls/roles (implement roles ! ) QTest::newRow("notification-roomupdate") << QStringLiteral("notification-room") << (QStringList() <("fileNameinit"); QTest::addColumn("UpdateRoomfileNames"); QTest::addColumn("UpdateSubscriptionFileNames"); //Missing _updatedAt/ts/_id/groupMentions/ls/roles (implement roles ! ) QTest::newRow("notification-roomupdate") << QStringLiteral("notification-room") << (QStringList() << QStringLiteral("notification-roomupdate1")) << (QStringList() << QStringLiteral("notification-roomsubscription1")); QTest::newRow("room-blocked") << QStringLiteral("room-blocked") << (QStringList() << QStringLiteral("room-blockedupdate1")) << QStringList(); QTest::newRow("room-encryption") << QStringLiteral("room-encryption") << (QStringList() << QStringLiteral("room-encryptionupdate1")) << QStringList(); } void RoomTest::shouldParseRoomAndUpdateSubscription() { QFETCH(QString, fileNameinit); QFETCH(QStringList, UpdateRoomfileNames); QFETCH(QStringList, UpdateSubscriptionFileNames); const QString originalJsonFile = QLatin1String(RUQOLA_DATA_DIR) + QStringLiteral("/room-updated/") + fileNameinit + QStringLiteral(".json"); QFile f(originalJsonFile); QVERIFY(f.open(QIODevice::ReadOnly)); const QByteArray content = f.readAll(); f.close(); const QJsonDocument doc = QJsonDocument::fromJson(content); const QJsonObject fields = doc.object(); Room r; r.parseSubscriptionRoom(fields); for (const QString &updateFile : UpdateRoomfileNames) { const QString originalUpdateJsonFile = QLatin1String(RUQOLA_DATA_DIR) + QStringLiteral("/room-update-subscription/") + updateFile + QStringLiteral(".json"); QFile f(originalUpdateJsonFile); QVERIFY(f.open(QIODevice::ReadOnly)); const QByteArray content = f.readAll(); f.close(); const QJsonDocument doc = QJsonDocument::fromJson(content); const QJsonObject fields = doc.object(); r.parseUpdateRoom(fields); } for (const QString &updateFile : UpdateSubscriptionFileNames) { const QString originalUpdateJsonFile = QLatin1String(RUQOLA_DATA_DIR) + QStringLiteral("/room-update-subscription/") + updateFile + QStringLiteral(".json"); QFile f(originalUpdateJsonFile); QVERIFY(f.open(QIODevice::ReadOnly)); const QByteArray content = f.readAll(); f.close(); const QJsonDocument doc = QJsonDocument::fromJson(content); const QJsonObject fields = doc.object(); r.updateSubscriptionRoom(fields); } //qDebug() << " fields"< * Copyright 2017-2018 Laurent Montel * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include "rocketchataccount.h" #include "notificationoptionswrapper.h" #include "room.h" #include "utils.h" #include "ruqola_debug.h" #include "model/usersforroommodel.h" #include "model/usersforroomfilterproxymodel.h" #include "model/filesforroommodel.h" #include "model/filesforroomfilterproxymodel.h" #include "model/messagemodel.h" #include #include #include Room::Room(RocketChatAccount *account, QObject *parent) : QObject(parent) , mRocketChatAccount(account) { mUsersModelForRoom = new UsersForRoomModel(this); mUsersModelForRoom->setObjectName(QStringLiteral("usersforroommodel")); mUsersModelForRoomProxyModel = new UsersForRoomFilterProxyModel(this); mUsersModelForRoomProxyModel->setObjectName(QStringLiteral("usersforroommodelproxymodel")); mUsersModelForRoomProxyModel->setSourceModel(mUsersModelForRoom); mFilesModelForRoom = new FilesForRoomModel(mRocketChatAccount, this); mFilesModelForRoom->setObjectName(QStringLiteral("filesmodelforrooms")); mFilesForRoomFilterProxyModel = new FilesForRoomFilterProxyModel(this); mFilesForRoomFilterProxyModel->setObjectName(QStringLiteral("filesforroomfiltermodelproxy")); mFilesForRoomFilterProxyModel->setSourceModel(mFilesModelForRoom); mMessageModel = new MessageModel(QString(), mRocketChatAccount, this, this); } bool Room::operator==(const Room &other) const { //qDebug() << " other.id"< we need to clear it. setRoomCreatorUserId(QString()); setRoomCreatorUserName(QString()); } } bool Room::selected() const { return mSelected; } void Room::setSelected(bool selected) { if (mSelected != selected) { mSelected = selected; //Add signal otherwise it's not necessary to check value } } int Room::unread() const { return mUnread; } void Room::setUnread(int unread) { if (mUnread != unread) { mUnread = unread; Q_EMIT unreadChanged(); } } qint64 Room::jitsiTimeout() const { return mJitsiTimeout; } void Room::setJitsiTimeout(const qint64 &jitsiTimeout) { if (mJitsiTimeout != jitsiTimeout) { mJitsiTimeout = jitsiTimeout; Q_EMIT jitsiTimeoutChanged(); } } QStringList Room::mutedUsers() const { return mMutedUsers; } void Room::setMutedUsers(const QStringList &mutedUsers) { if (mMutedUsers != mutedUsers) { mMutedUsers = mutedUsers; Q_EMIT mutedUsersChanged(); } } QString Room::roomCreatorUserId() const { return mRoomCreateUserId; } void Room::setRoomCreatorUserId(const QString &userId) { mRoomCreateUserId = userId; } QString Room::roomOwnerUserName() const { return mRoomCreatorUserName; } void Room::setRoomCreatorUserName(const QString &userName) { mRoomCreatorUserName = userName; } QString Room::roomId() const { return mRoomId; } void Room::setRoomId(const QString &id) { if (mRoomId != id) { mRoomId = id; mMessageModel->setRoomID(id); } } bool Room::alert() const { return mAlert; } void Room::setBlocker(bool block) { if (mBlocker != block) { mBlocker = block; Q_EMIT blockerChanged(); } } bool Room::blocker() const { return mBlocker; } void Room::setAlert(bool alert) { if (mAlert != alert) { mAlert = alert; Q_EMIT alertChanged(); } } bool Room::open() const { return mOpen; } void Room::setOpen(bool open) { if (mOpen != open) { mOpen = open; Q_EMIT openChanged(); } } bool Room::readOnly() const { return mReadOnly; } void Room::setReadOnly(bool readOnly) { if (mReadOnly != readOnly) { mReadOnly = readOnly; Q_EMIT readOnlyChanged(); } } QString Room::topic() const { return mTopic; } void Room::setTopic(const QString &topic) { if (mTopic != topic) { mTopic = topic; Q_EMIT topicChanged(); } } bool Room::favorite() const { return mFavorite; } void Room::setFavorite(bool favorite) { if (mFavorite != favorite) { mFavorite = favorite; Q_EMIT favoriteChanged(); } } QString Room::channelType() const { return mChannelType; } void Room::setChannelType(const QString &channelType) { - mChannelType = channelType; + if (mChannelType != channelType) { + mChannelType = channelType; + Q_EMIT channelTypeChanged(); + } } QString Room::markdownAnnouncement() const { return Utils::markdownToRichText(mAnnouncement); } QString Room::announcement() const { return mAnnouncement; } void Room::setAnnouncement(const QString &announcement) { if (mAnnouncement != announcement) { mAnnouncement = announcement; Q_EMIT announcementChanged(); } } void Room::setName(const QString &name) { if (mName != name) { mName = name; Q_EMIT nameChanged(); } } void Room::parseInsertRoom(const QJsonObject &json) { QString roomID = json.value(QLatin1String("_id")).toString(); setRoomId(roomID); setName(json[QStringLiteral("name")].toString()); setJitsiTimeout(Utils::parseDate(QStringLiteral("jitsiTimeout"), json)); //topic/announcement/description is not part of update subscription const QString roomType = json.value(QLatin1String("t")).toString(); setChannelType(roomType); const QJsonValue favoriteValue = json.value(QLatin1String("f")); if (!favoriteValue.isUndefined()) { setFavorite(favoriteValue.toBool()); } setReadOnly(json[QStringLiteral("ro")].toBool()); if (json.contains(QLatin1String("userMentions"))) { setUserMentions(json[QStringLiteral("userMentions")].toInt()); } if (json.contains(QLatin1String("announcement"))) { setAnnouncement(json[QStringLiteral("announcement")].toString()); } if (json.contains(QLatin1String("description"))) { setDescription(json[QStringLiteral("description")].toString()); } setUpdatedAt(Utils::parseDate(QStringLiteral("_updatedAt"), json)); setUnread(json[QStringLiteral("unread")].toInt()); setOpen(json[QStringLiteral("open")].toBool()); setAlert(json[QStringLiteral("alert")].toBool()); const QJsonValue blockerValue = json.value(QLatin1String("blocker")); if (!blockerValue.isUndefined()) { setBlocker(blockerValue.toBool()); } else { setBlocker(false); } //setE2eKeyId(json[QStringLiteral("e2eKeyId")].toString()); setE2EKey(json[QStringLiteral("E2EKey")].toString()); if (json.contains(QLatin1String("encrypted"))) { setEncrypted(json[QStringLiteral("encrypted")].toBool()); } else { setEncrypted(false); } //Blocked ??? const QJsonValue archivedValue = json.value(QLatin1String("archived")); if (!archivedValue.isUndefined()) { setArchived(archivedValue.toBool()); } else { setArchived(false); } parseCommonData(json); const QJsonValue ownerValue = json.value(QLatin1String("u")); if (!ownerValue.isUndefined()) { const QJsonObject objOwner = ownerValue.toObject(); setRoomCreatorUserId(objOwner.value(QLatin1String("_id")).toString()); setRoomCreatorUserName(objOwner.value(QLatin1String("username")).toString()); } else { //When room is initialized we are the owner. When we update room we have the real //owner and if it's empty => we need to clear it. setRoomCreatorUserId(QString()); setRoomCreatorUserName(QString()); } //qDebug() << " *thus" << *this; mNotificationOptions.parseNotificationOptions(json); } qint64 Room::lastSeeAt() const { return mLastSeeAt; } void Room::setLastSeeAt(qint64 lastSeeAt) { mLastSeeAt = lastSeeAt; //Add signal otherwise it's not necessary to check value } bool Room::blocked() const { return mBlocked; } void Room::setBlocked(bool blocked) { if (mBlocked != blocked) { mBlocked = blocked; Q_EMIT blockedChanged(); } } QStringList Room::roles() const { return mRoles; } void Room::setRoles(const QStringList &roles) { if (mRoles != roles) { mRoles = roles; Q_EMIT rolesChanged(); } } QStringList Room::ignoredUsers() const { return mIgnoredUsers; } void Room::setIgnoredUsers(const QStringList &ignoredUsers) { if (mIgnoredUsers != ignoredUsers) { mIgnoredUsers = ignoredUsers; Q_EMIT ignoredUsersChanged(); } } void Room::parseSubscriptionRoom(const QJsonObject &json) { QString roomID = json.value(QLatin1String("rid")).toString(); if (roomID.isEmpty()) { roomID = json.value(QLatin1String("_id")).toString(); } setRoomId(roomID); setName(json[QStringLiteral("name")].toString()); setJitsiTimeout(Utils::parseDate(QStringLiteral("jitsiTimeout"), json)); //topic/announcement/description is not part of update subscription const QString roomType = json.value(QLatin1String("t")).toString(); setChannelType(roomType); const QJsonValue favoriteValue = json.value(QLatin1String("f")); if (!favoriteValue.isUndefined()) { setFavorite(favoriteValue.toBool()); } setE2EKey(json[QStringLiteral("E2EKey")].toString()); setReadOnly(json[QStringLiteral("ro")].toBool()); setUpdatedAt(Utils::parseDate(QStringLiteral("_updatedAt"), json)); setUnread(json[QStringLiteral("unread")].toInt()); setUserMentions(json[QStringLiteral("userMentions")].toInt()); setOpen(json[QStringLiteral("open")].toBool()); setAlert(json[QStringLiteral("alert")].toBool()); const QJsonValue blockerValue = json.value(QLatin1String("blocker")); if (!blockerValue.isUndefined()) { setBlocker(blockerValue.toBool()); } else { setBlocker(false); } //TODO e2ekey //TODO blocked ? const QJsonValue archivedValue = json.value(QLatin1String("archived")); if (!archivedValue.isUndefined()) { setArchived(archivedValue.toBool()); } else { setArchived(false); } parseCommonData(json); // const QJsonValue ownerValue = json.value(QLatin1String("u")); // if (!ownerValue.isUndefined()) { // const QJsonObject objOwner = ownerValue.toObject(); // setRoomCreatorUserId(objOwner.value(QLatin1String("_id")).toString()); // setRoomCreatorUserName(objOwner.value(QLatin1String("username")).toString()); // } else { // //When room is initialized we are the owner. When we update room we have the real // //owner and if it's empty => we need to clear it. // setRoomCreatorUserId(QString()); // setRoomCreatorUserName(QString()); // } //qDebug() << " *thus" << *this; mNotificationOptions.parseNotificationOptions(json); //TODO encrypted ? //TODO add muted } void Room::parseCommonData(const QJsonObject &json) { const QJsonArray mutedArray = json.value(QLatin1String("muted")).toArray(); QStringList lst; lst.reserve(mutedArray.count()); for (int i = 0; i < mutedArray.count(); ++i) { lst << mutedArray.at(i).toString(); } setMutedUsers(lst); const QJsonArray ignoredArray = json.value(QLatin1String("ignored")).toArray(); QStringList lstIgnored; lstIgnored.reserve(ignoredArray.count()); for (int i = 0; i < ignoredArray.count(); ++i) { lstIgnored << ignoredArray.at(i).toString(); } setIgnoredUsers(lstIgnored); const QJsonArray rolesArray = json.value(QLatin1String("roles")).toArray(); QStringList lstRoles; lstRoles.reserve(rolesArray.count()); for (int i = 0; i < rolesArray.count(); ++i) { lstRoles << rolesArray.at(i).toString(); } setRoles(lstRoles); } bool Room::joinCodeRequired() const { return mJoinCodeRequired; } void Room::setJoinCodeRequired(bool joinCodeRequired) { if (mJoinCodeRequired != joinCodeRequired) { mJoinCodeRequired = joinCodeRequired; Q_EMIT joinCodeRequiredChanged(); } } QString Room::e2eKeyId() const { return mE2eKeyId; } void Room::setE2eKeyId(const QString &e2eKeyId) { if (mE2eKeyId != e2eKeyId) { mE2eKeyId = e2eKeyId; Q_EMIT encryptionKeyIdChanged(); } } QString Room::e2EKey() const { return mE2EKey; } void Room::setE2EKey(const QString &e2EKey) { if (mE2EKey != e2EKey) { mE2EKey = e2EKey; Q_EMIT encryptionKeyChanged(); } } bool Room::encrypted() const { return mEncrypted; } void Room::setEncrypted(bool encrypted) { if (mEncrypted != encrypted) { mEncrypted = encrypted; Q_EMIT encryptedChanged(); } } Room *Room::fromJSon(const QJsonObject &o) { //FIXME Room *r = new Room(nullptr); r->setRoomId(o[QStringLiteral("rid")].toString()); r->setChannelType(o[QStringLiteral("t")].toString()); r->setName(o[QStringLiteral("name")].toString()); r->setRoomCreatorUserName(o[QStringLiteral("roomCreatorUserName")].toString()); r->setRoomCreatorUserId(o[QStringLiteral("roomCreatorUserID")].toString()); r->setTopic(o[QStringLiteral("topic")].toString()); r->setJitsiTimeout(static_cast(o[QStringLiteral("jitsiTimeout")].toDouble())); r->setReadOnly(o[QStringLiteral("ro")].toBool()); r->setUnread(o[QStringLiteral("unread")].toInt(0)); r->setUserMentions(o[QStringLiteral("userMentions")].toInt(0)); r->setAnnouncement(o[QStringLiteral("announcement")].toString()); r->setSelected(o[QStringLiteral("selected")].toBool()); r->setFavorite(o[QStringLiteral("favorite")].toBool()); r->setAlert(o[QStringLiteral("alert")].toBool()); r->setOpen(o[QStringLiteral("open")].toBool()); r->setArchived(o[QStringLiteral("archived")].toBool()); r->setDescription(o[QStringLiteral("description")].toString()); r->setBlocker(o[QStringLiteral("blocker")].toBool()); r->setBlocked(o[QStringLiteral("blocked")].toBool()); r->setEncrypted(o[QStringLiteral("encrypted")].toBool()); r->setE2EKey(o[QStringLiteral("e2ekey")].toString()); r->setE2eKeyId(o[QStringLiteral("e2ekeyid")].toString()); r->setJoinCodeRequired(o[QStringLiteral("joinCodeRequired")].toBool()); r->setUpdatedAt(static_cast(o[QStringLiteral("updatedAt")].toDouble())); r->setLastSeeAt(static_cast(o[QStringLiteral("lastSeeAt")].toDouble())); const QJsonArray mutedArray = o.value(QLatin1String("mutedUsers")).toArray(); QStringList lst; lst.reserve(mutedArray.count()); for (int i = 0; i < mutedArray.count(); ++i) { lst <setMutedUsers(lst); const QJsonArray ignoredArray = o.value(QLatin1String("ignored")).toArray(); QStringList lstIgnored; lstIgnored.reserve(ignoredArray.count()); for (int i = 0; i < ignoredArray.count(); ++i) { lstIgnored <setIgnoredUsers(lstIgnored); const QJsonArray rolesArray = o.value(QLatin1String("roles")).toArray(); QStringList lstRoles; lstRoles.reserve(rolesArray.count()); for (int i = 0; i < rolesArray.count(); ++i) { lstRoles <setRoles(lstRoles); const QJsonObject notificationsObj = o.value(QLatin1String("notifications")).toObject(); const NotificationOptions notifications = NotificationOptions::fromJSon(notificationsObj); r->setNotificationOptions(notifications); return r; } QByteArray Room::serialize(Room *r, bool toBinary) { QJsonDocument d; QJsonObject o; //todo add timestamp o[QStringLiteral("rid")] = r->roomId(); o[QStringLiteral("t")] = r->channelType(); o[QStringLiteral("name")] = r->name(); o[QStringLiteral("roomCreatorUserName")] = r->roomOwnerUserName(); o[QStringLiteral("roomCreatorUserID")] = r->roomCreatorUserId(); if (!r->topic().isEmpty()) { o[QStringLiteral("topic")] = r->topic(); } o[QStringLiteral("jitsiTimeout")] = r->jitsiTimeout(); o[QStringLiteral("updatedAt")] = r->updatedAt(); o[QStringLiteral("lastSeeAt")] = r->lastSeeAt(); o[QStringLiteral("ro")] = r->readOnly(); o[QStringLiteral("unread")] = r->unread(); if (!r->announcement().isEmpty()) { o[QStringLiteral("announcement")] = r->announcement(); } o[QStringLiteral("selected")] = r->selected(); o[QStringLiteral("favorite")] = r->favorite(); o[QStringLiteral("alert")] = r->alert(); o[QStringLiteral("open")] = r->open(); o[QStringLiteral("blocker")] = r->blocker(); o[QStringLiteral("blocked")] = r->blocked(); o[QStringLiteral("encrypted")] = r->encrypted(); o[QStringLiteral("archived")] = r->archived(); if (r->joinCodeRequired()) { o[QStringLiteral("joinCodeRequired")] = true; } if (!r->e2EKey().isEmpty()) { o[QStringLiteral("e2ekey")] = r->e2EKey(); } if (!r->e2eKeyId().isEmpty()) { o[QStringLiteral("e2ekeyid")] = r->e2eKeyId(); } if (!r->description().isEmpty()) { o[QStringLiteral("description")] = r->description(); } o[QStringLiteral("userMentions")] = r->userMentions(); if (!r->mutedUsers().isEmpty()) { QJsonArray array; const int nbMuted = r->mutedUsers().count(); for (int i = 0; i < nbMuted; ++i) { array.append(r->mutedUsers().at(i)); } o[QStringLiteral("mutedUsers")] = array; } if (!r->ignoredUsers().isEmpty()) { QJsonArray array; const int nbIgnoredUsers = r->ignoredUsers().count(); for (int i = 0; i < nbIgnoredUsers; ++i) { array.append(r->ignoredUsers().at(i)); } o[QStringLiteral("ignored")] = array; } if (!r->roles().isEmpty()) { QJsonArray array; const int nbRoles = r->roles().count(); for (int i = 0; i < nbRoles; ++i) { array.append(r->roles().at(i)); } o[QStringLiteral("roles")] = array; } o[QStringLiteral("notifications")] = NotificationOptions::serialize(r->notificationOptions()); d.setObject(o); if (toBinary) { return d.toBinaryData(); } return d.toJson(QJsonDocument::Indented); } UsersForRoomModel *Room::usersModelForRoom() const { return mUsersModelForRoom; } UsersForRoomFilterProxyModel *Room::usersModelForRoomProxyModel() const { return mUsersModelForRoomProxyModel; } FilesForRoomModel *Room::filesModelForRoom() const { return mFilesModelForRoom; } FilesForRoomFilterProxyModel *Room::filesForRoomFilterProxyModel() const { return mFilesForRoomFilterProxyModel; } MessageModel *Room::messageModel() const { return mMessageModel; } QString Room::inputMessage() const { return mInputMessage; } void Room::setInputMessage(const QString &inputMessage) { mInputMessage = inputMessage; } bool Room::archived() const { return mArchived; } void Room::setArchived(bool archived) { if (mArchived != archived) { mArchived = archived; Q_EMIT archivedChanged(); } } QString Room::description() const { return mDescription; } void Room::setDescription(const QString &description) { if (mDescription != description) { mDescription = description; Q_EMIT descriptionChanged(); } } bool Room::encryptedEnabled() const { if (mRocketChatAccount) { return mRocketChatAccount->encryptedEnabled(); } return false; } bool Room::userIsIgnored(const QString &userId) { return mIgnoredUsers.contains(userId); } QString Room::roomMessageInfo() const { if (mReadOnly) { return i18n("Channel is read only."); } if (mBlocker) { return i18n("You have blocked this channel."); } if (mBlocked) { return i18n("Channel was blocked."); } return QString(); } diff --git a/src/ruqolacore/room.h b/src/ruqolacore/room.h index 3ead3f03..fbe3be62 100644 --- a/src/ruqolacore/room.h +++ b/src/ruqolacore/room.h @@ -1,297 +1,300 @@ /* * Copyright 2016 Riccardo Iaconelli * Copyright 2017-2018 Laurent Montel * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef ROOM_H #define ROOM_H #include #include #include "notificationoptions.h" #include "libruqola_private_export.h" class UsersForRoomModel; class UsersForRoomFilterProxyModel; class FilesForRoomModel; class FilesForRoomFilterProxyModel; class MessageModel; class RocketChatAccount; class NotificationOptionsWrapper; class LIBRUQOLACORE_TESTS_EXPORT Room : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString announcement READ announcement WRITE setAnnouncement NOTIFY announcementChanged) Q_PROPERTY(QString topic READ topic WRITE setTopic NOTIFY topicChanged) Q_PROPERTY(bool favorite READ favorite WRITE setFavorite NOTIFY favoriteChanged) Q_PROPERTY(bool readOnly READ readOnly WRITE setReadOnly NOTIFY readOnlyChanged) Q_PROPERTY(bool alert READ alert WRITE setAlert NOTIFY alertChanged) Q_PROPERTY(bool blocker READ blocker WRITE setBlocker NOTIFY blockerChanged) Q_PROPERTY(bool archived READ archived WRITE setArchived NOTIFY archivedChanged) Q_PROPERTY(bool blocked READ blocked WRITE setBlocked NOTIFY blockedChanged) Q_PROPERTY(bool open READ open WRITE setOpen NOTIFY openChanged) Q_PROPERTY(bool encrypted READ encrypted WRITE setEncrypted NOTIFY encryptedChanged) Q_PROPERTY(QString description READ description WRITE setDescription NOTIFY descriptionChanged) Q_PROPERTY(QStringList roles READ roles WRITE setRoles NOTIFY rolesChanged) Q_PROPERTY(QString e2eKeyId READ e2eKeyId WRITE setE2eKeyId NOTIFY encryptionKeyIdChanged) Q_PROPERTY(bool joinCodeRequired READ joinCodeRequired WRITE setJoinCodeRequired NOTIFY joinCodeRequiredChanged) + Q_PROPERTY(QString channelType READ channelType WRITE setChannelType NOTIFY channelTypeChanged) + public: explicit Room(RocketChatAccount *account = nullptr, QObject *parent = nullptr); // To be used in ID find: message ID Q_REQUIRED_RESULT bool operator==(const Room &other) const; //we can't use operator== as it tests only id. We need it for autotest Q_REQUIRED_RESULT bool isEqual(const Room &other) const; Q_REQUIRED_RESULT QString roomOwnerUserName() const; void setRoomCreatorUserName(const QString &userName); Q_REQUIRED_RESULT QString roomCreatorUserId() const; void setRoomCreatorUserId(const QString &userId); Q_REQUIRED_RESULT QStringList mutedUsers() const; void setMutedUsers(const QStringList &mutedUsers); Q_REQUIRED_RESULT qint64 jitsiTimeout() const; void setJitsiTimeout(const qint64 &jitsiTimeout); Q_REQUIRED_RESULT int unread() const; void setUnread(int unread); Q_REQUIRED_RESULT bool selected() const; void setSelected(bool selected); /** * @brief Return room name * * @return QString, The name of the room */ Q_REQUIRED_RESULT QString name() const; void setName(const QString &name); Q_REQUIRED_RESULT QString announcement() const; void setAnnouncement(const QString &announcement); Q_REQUIRED_RESULT QString channelType() const; void setChannelType(const QString &channelType); Q_REQUIRED_RESULT bool favorite() const; void setFavorite(bool favorite); QString topic() const; void setTopic(const QString &topic); Q_REQUIRED_RESULT bool readOnly() const; void setReadOnly(bool readOnly); Q_REQUIRED_RESULT bool open() const; void setOpen(bool open); Q_REQUIRED_RESULT bool alert() const; void setAlert(bool alert); Q_REQUIRED_RESULT QString roomId() const; void setRoomId(const QString &id); void setBlocker(bool alert); Q_REQUIRED_RESULT bool blocker() const; void parseSubscriptionRoom(const QJsonObject &json); void parseUpdateRoom(const QJsonObject &json); /** * @brief Constructs Room object from QJsonObject (cache) * * @param source The Json containing room attributes * @return Room object, The room constructed from Json */ static Room *fromJSon(const QJsonObject &source); /** * @brief Constructs QBytearray from Room object * * @param message The Room object * @return QByteArray, The Json containing room attributes */ static QByteArray serialize(Room *r, bool toBinary = true); UsersForRoomModel *usersModelForRoom() const; UsersForRoomFilterProxyModel *usersModelForRoomProxyModel() const; FilesForRoomModel *filesModelForRoom() const; FilesForRoomFilterProxyModel *filesForRoomFilterProxyModel() const; MessageModel *messageModel() const; Q_REQUIRED_RESULT QString inputMessage() const; void setInputMessage(const QString &inputMessage); Q_REQUIRED_RESULT bool archived() const; void setArchived(bool archived); QString description() const; void setDescription(const QString &description); Q_REQUIRED_RESULT bool encryptedEnabled() const; Q_REQUIRED_RESULT bool canBeModify() const; Q_REQUIRED_RESULT NotificationOptions notificationOptions() const; void setNotificationOptions(const NotificationOptions ¬ificationOptions); Q_REQUIRED_RESULT int userMentions() const; void setUserMentions(int userMentions); void updateSubscriptionRoom(const QJsonObject &json); Q_REQUIRED_RESULT qint64 updatedAt() const; void setUpdatedAt(qint64 updatedAt); void parseInsertRoom(const QJsonObject &json); Q_REQUIRED_RESULT qint64 lastSeeAt() const; void setLastSeeAt(qint64 lastSeeAt); Q_REQUIRED_RESULT bool blocked() const; void setBlocked(bool blocked); Q_REQUIRED_RESULT QStringList roles() const; void setRoles(const QStringList &roles); Q_REQUIRED_RESULT QStringList ignoredUsers() const; void setIgnoredUsers(const QStringList &ignoredUsers); Q_REQUIRED_RESULT bool encrypted() const; void setEncrypted(bool encrypted); Q_REQUIRED_RESULT bool userIsIgnored(const QString &userId); Q_REQUIRED_RESULT QString markdownAnnouncement() const; Q_REQUIRED_RESULT QString roomMessageInfo() const; Q_REQUIRED_RESULT QString e2EKey() const; void setE2EKey(const QString &e2EKey); QString e2eKeyId() const; void setE2eKeyId(const QString &e2eKeyId); NotificationOptionsWrapper *getNotificationWrapper(); Q_REQUIRED_RESULT bool joinCodeRequired() const; void setJoinCodeRequired(bool joinCodeRequired); Q_SIGNALS: void nameChanged(); void announcementChanged(); void topicChanged(); void favoriteChanged(); void alertChanged(); void readOnlyChanged(); void unreadChanged(); void openChanged(); void encryptedChanged(); void encryptionKeyChanged(); void encryptionKeyIdChanged(); //Blocker we blocked the channel void blockerChanged(); //Blocked the channel was blocked void blockedChanged(); void archivedChanged(); void descriptionChanged(); void rolesChanged(); void mutedUsersChanged(); void ignoredUsersChanged(); void jitsiTimeoutChanged(); void joinCodeRequiredChanged(); + void channelTypeChanged(); private: Q_DISABLE_COPY(Room) void parseCommonData(const QJsonObject &json); //Room Object Fields NotificationOptions mNotificationOptions; // muted - collection of muted users by its usernames QStringList mMutedUsers; QStringList mIgnoredUsers; //Roles QStringList mRoles; QString mInputMessage; // _id QString mRoomId; // t (can take values "d" , "c" or "p" or "l") QString mChannelType; // name QString mName; // Announcement QString mAnnouncement; // u QString mRoomCreatorUserName; QString mRoomCreateUserId; // topic QString mTopic; QString mDescription; // jitsiTimeout qint64 mJitsiTimeout = -1; qint64 mUpdatedAt = -1; qint64 mLastSeeAt = -1; //Encryption Key QString mE2EKey; QString mE2eKeyId; //quint64 ? int mUnread = 0; int mUserMentions = 0; // ro - read-only chat or not bool mReadOnly = false; bool mSelected = false; bool mFavorite = false; //We can hide it or not. bool mOpen = false; bool mAlert = false; bool mBlocker = false; bool mArchived = false; bool mBlocked = false; bool mEncrypted = false; bool mJoinCodeRequired = false; UsersForRoomModel *mUsersModelForRoom = nullptr; UsersForRoomFilterProxyModel *mUsersModelForRoomProxyModel = nullptr; FilesForRoomModel *mFilesModelForRoom = nullptr; FilesForRoomFilterProxyModel *mFilesForRoomFilterProxyModel = nullptr; MessageModel *mMessageModel = nullptr; RocketChatAccount *mRocketChatAccount = nullptr; }; LIBRUQOLACORE_EXPORT QDebug operator <<(QDebug d, const Room &t); #endif // ROOM_H diff --git a/src/ruqolacore/roomwrapper.cpp b/src/ruqolacore/roomwrapper.cpp index 790ef391..e0d4ac96 100644 --- a/src/ruqolacore/roomwrapper.cpp +++ b/src/ruqolacore/roomwrapper.cpp @@ -1,151 +1,152 @@ /* * Copyright 2016 Riccardo Iaconelli * Copyright 2017-2018 Laurent Montel * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #include "roomwrapper.h" #include "ruqola_debug.h" #include "room.h" #include "notificationoptionswrapper.h" RoomWrapper::RoomWrapper(QObject *parent) : QObject(parent) { } RoomWrapper::RoomWrapper(Room *r, QObject *parent) : QObject(parent) { mRoom = r; connect(mRoom, &Room::favoriteChanged, this, &RoomWrapper::favoriteChanged); connect(mRoom, &Room::topicChanged, this, &RoomWrapper::topicChanged); connect(mRoom, &Room::announcementChanged, this, &RoomWrapper::announcementChanged); connect(mRoom, &Room::nameChanged, this, &RoomWrapper::nameChanged); connect(mRoom, &Room::readOnlyChanged, this, &RoomWrapper::readOnlyChanged); connect(mRoom, &Room::blockerChanged, this, &RoomWrapper::blockerChanged); connect(mRoom, &Room::blockedChanged, this, &RoomWrapper::blockedChanged); connect(mRoom, &Room::encryptedChanged, this, &RoomWrapper::encryptedChanged); + connect(mRoom, &Room::channelTypeChanged, this, &RoomWrapper::channelTypeChanged); //Reduce connection ? connect(mRoom, &Room::readOnlyChanged, this, &RoomWrapper::roomMessageInfoChanged); connect(mRoom, &Room::blockerChanged, this, &RoomWrapper::roomMessageInfoChanged); connect(mRoom, &Room::blockedChanged, this, &RoomWrapper::roomMessageInfoChanged); connect(mRoom, &Room::descriptionChanged, this, &RoomWrapper::descriptionChanged); connect(mRoom, &Room::archivedChanged, this, &RoomWrapper::archivedChanged); connect(mRoom, &Room::rolesChanged, this, &RoomWrapper::rolesChanged); connect(mRoom, &Room::ignoredUsersChanged, this, &RoomWrapper::ignoredUsersChanged); connect(mRoom, &Room::mutedUsersChanged, this, &RoomWrapper::mutedUsersChanged); connect(mRoom, &Room::joinCodeRequiredChanged, this, &RoomWrapper::joinCodeRequiredChanged); } RoomWrapper::~RoomWrapper() { } QString RoomWrapper::name() const { return mRoom->name(); } QString RoomWrapper::topic() const { return mRoom->topic(); } QString RoomWrapper::announcement() const { return mRoom->markdownAnnouncement(); } bool RoomWrapper::favorite() const { return mRoom->favorite(); } bool RoomWrapper::readOnly() const { return mRoom->readOnly(); } bool RoomWrapper::blocker() const { return mRoom->blocker(); } bool RoomWrapper::blocked() const { return mRoom->blocked(); } bool RoomWrapper::encrypted() const { return mRoom->encrypted(); } QString RoomWrapper::channelType() const { return mRoom->channelType(); } QString RoomWrapper::roomCreatorUserId() const { return mRoom->roomCreatorUserId(); } QString RoomWrapper::rid() const { return mRoom->roomId(); } QString RoomWrapper::description() const { return mRoom->description(); } bool RoomWrapper::archived() const { return mRoom->archived(); } bool RoomWrapper::canBeModify() const { return mRoom->canBeModify(); } NotificationOptionsWrapper *RoomWrapper::notificationOptions() const { return mRoom->getNotificationWrapper(); } QString RoomWrapper::roomMessageInfo() const { return mRoom->roomMessageInfo(); } bool RoomWrapper::encryptedEnabled() const { return mRoom->encryptedEnabled(); } bool RoomWrapper::joinCodeRequired() const { return mRoom->joinCodeRequired(); } diff --git a/src/ruqolacore/roomwrapper.h b/src/ruqolacore/roomwrapper.h index 4dc62e12..f9628733 100644 --- a/src/ruqolacore/roomwrapper.h +++ b/src/ruqolacore/roomwrapper.h @@ -1,98 +1,99 @@ /* * Copyright 2016 Riccardo Iaconelli * Copyright 2017-2018 Laurent Montel * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License or (at your option) version 3 or any later version * accepted by the membership of KDE e.V. (or its successor approved * by the membership of KDE e.V.), which shall act as a proxy * defined in Section 14 of version 3 of the license. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . * */ #ifndef ROOMWRAPPER_H #define ROOMWRAPPER_H #include #include "room.h" #include "libruqola_private_export.h" class Room; class LIBRUQOLACORE_EXPORT RoomWrapper : public QObject { Q_PROPERTY(QString name READ name NOTIFY nameChanged) Q_PROPERTY(QString topic READ topic NOTIFY topicChanged) Q_PROPERTY(QString announcement READ announcement NOTIFY announcementChanged) - Q_PROPERTY(QString channelType READ channelType CONSTANT) + Q_PROPERTY(QString channelType READ channelType NOTIFY channelTypeChanged) Q_PROPERTY(QString roomCreatorUserId READ roomCreatorUserId CONSTANT) Q_PROPERTY(QString rid READ rid CONSTANT) Q_PROPERTY(QString description READ description NOTIFY descriptionChanged) Q_PROPERTY(bool favorite READ favorite NOTIFY favoriteChanged) Q_PROPERTY(bool readOnly READ readOnly NOTIFY readOnlyChanged) Q_PROPERTY(bool blocker READ blocker NOTIFY blockerChanged) Q_PROPERTY(bool blocked READ blocked NOTIFY blockedChanged) Q_PROPERTY(bool encrypted READ encrypted NOTIFY encryptedChanged) Q_PROPERTY(bool canBeModify READ canBeModify NOTIFY rolesChanged) Q_PROPERTY(bool archived READ archived NOTIFY archivedChanged) //TODO add Q_PROPERTY for mutedUsersChanged and ignoreUsersChanged Q_PROPERTY(QString roomMessageInfo READ roomMessageInfo NOTIFY roomMessageInfoChanged) Q_PROPERTY(bool encryptedEnabled READ encryptedEnabled CONSTANT) Q_PROPERTY(bool joinCodeRequired READ joinCodeRequired NOTIFY joinCodeRequiredChanged) Q_OBJECT public: explicit RoomWrapper(QObject *parent = nullptr); explicit RoomWrapper(Room *r, QObject *parent = nullptr); ~RoomWrapper(); Q_REQUIRED_RESULT QString name() const; Q_REQUIRED_RESULT QString topic() const; Q_REQUIRED_RESULT QString announcement() const; Q_REQUIRED_RESULT bool favorite() const; Q_REQUIRED_RESULT bool readOnly() const; Q_REQUIRED_RESULT bool blocker() const; Q_REQUIRED_RESULT bool blocked() const; Q_REQUIRED_RESULT bool encrypted() const; Q_REQUIRED_RESULT QString channelType() const; Q_REQUIRED_RESULT QString roomCreatorUserId() const; Q_REQUIRED_RESULT QString rid() const; Q_REQUIRED_RESULT QString description() const; Q_REQUIRED_RESULT bool archived() const; Q_REQUIRED_RESULT bool canBeModify() const; Q_REQUIRED_RESULT QString roomMessageInfo() const; Q_REQUIRED_RESULT bool encryptedEnabled() const; Q_REQUIRED_RESULT bool joinCodeRequired() const; Q_REQUIRED_RESULT Q_INVOKABLE NotificationOptionsWrapper *notificationOptions() const; Q_SIGNALS: void nameChanged(); void topicChanged(); void announcementChanged(); void favoriteChanged(); void readOnlyChanged(); void blockerChanged(); void descriptionChanged(); void archivedChanged(); void blockedChanged(); void rolesChanged(); void ignoredUsersChanged(); void mutedUsersChanged(); void roomMessageInfoChanged(); void encryptedChanged(); void joinCodeRequiredChanged(); + void channelTypeChanged(); private: Q_DISABLE_COPY(RoomWrapper) Room *mRoom = nullptr; }; #endif // ROOMWRAPPER_H