Remove no longer needed ifdefs
This commit is contained in:
@@ -63,11 +63,7 @@ Controller::Controller(QObject *parent)
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
auto c = new NeoChatConnection(this);
|
auto c = new NeoChatConnection(this);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
c->assumeIdentity(QStringLiteral("@user:localhost:1234"), QStringLiteral("device_1234"), QStringLiteral("token_1234"));
|
c->assumeIdentity(QStringLiteral("@user:localhost:1234"), QStringLiteral("device_1234"), QStringLiteral("token_1234"));
|
||||||
#else
|
|
||||||
c->assumeIdentity(QStringLiteral("@user:localhost:1234"), QStringLiteral("token_1234"));
|
|
||||||
#endif
|
|
||||||
connect(c, &Connection::connected, this, [c, this]() {
|
connect(c, &Connection::connected, this, [c, this]() {
|
||||||
m_accountRegistry.add(c);
|
m_accountRegistry.add(c);
|
||||||
c->syncLoop();
|
c->syncLoop();
|
||||||
@@ -230,11 +226,7 @@ void Controller::invokeLogin()
|
|||||||
Qt::SingleShotConnection);
|
Qt::SingleShotConnection);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
connection->assumeIdentity(account.userId(), account.deviceId(), accessToken);
|
connection->assumeIdentity(account.userId(), account.deviceId(), accessToken);
|
||||||
#else
|
|
||||||
connection->assumeIdentity(account.userId(), accessToken);
|
|
||||||
#endif
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -441,11 +433,7 @@ void Controller::removeConnection(const QString &userId)
|
|||||||
|
|
||||||
bool Controller::csSupported() const
|
bool Controller::csSupported() const
|
||||||
{
|
{
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
return true;
|
return true;
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Controller::revertToDefaultConfig()
|
void Controller::revertToDefaultConfig()
|
||||||
|
|||||||
@@ -225,18 +225,10 @@ QString EventHandler::rawMessageBody(const Quotient::RoomMessageEvent &event)
|
|||||||
{
|
{
|
||||||
QString body;
|
QString body;
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (event.has<EventContent::FileContent>()) {
|
if (event.has<EventContent::FileContent>()) {
|
||||||
#else
|
|
||||||
if (event.hasFileContent()) {
|
|
||||||
#endif
|
|
||||||
// if filename is given or body is equal to filename,
|
// if filename is given or body is equal to filename,
|
||||||
// then body is a caption
|
// then body is a caption
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
QString filename = event.get<EventContent::FileContent>()->originalName;
|
QString filename = event.get<EventContent::FileContent>()->originalName;
|
||||||
#else
|
|
||||||
QString filename = event.content()->fileInfo()->originalName;
|
|
||||||
#endif
|
|
||||||
QString body = event.plainBody();
|
QString body = event.plainBody();
|
||||||
if (filename.isEmpty() || filename == body) {
|
if (filename.isEmpty() || filename == body) {
|
||||||
return QString();
|
return QString();
|
||||||
@@ -244,13 +236,8 @@ QString EventHandler::rawMessageBody(const Quotient::RoomMessageEvent &event)
|
|||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (event.has<EventContent::TextContent>() && event.content()) {
|
if (event.has<EventContent::TextContent>() && event.content()) {
|
||||||
body = event.get<EventContent::TextContent>()->body;
|
body = event.get<EventContent::TextContent>()->body;
|
||||||
#else
|
|
||||||
if (event.hasTextContent() && event.content()) {
|
|
||||||
body = static_cast<const EventContent::TextContent *>(event.content())->body;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
body = event.plainBody();
|
body = event.plainBody();
|
||||||
}
|
}
|
||||||
@@ -477,13 +464,8 @@ QString EventHandler::getMessageBody(const NeoChatRoom *room, const RoomMessageE
|
|||||||
{
|
{
|
||||||
TextHandler textHandler;
|
TextHandler textHandler;
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (event.has<EventContent::FileContent>()) {
|
if (event.has<EventContent::FileContent>()) {
|
||||||
QString fileCaption = event.get<EventContent::FileContent>()->originalName;
|
QString fileCaption = event.get<EventContent::FileContent>()->originalName;
|
||||||
#else
|
|
||||||
if (event.hasFileContent()) {
|
|
||||||
QString fileCaption = event.content()->fileInfo()->originalName;
|
|
||||||
#endif
|
|
||||||
if (fileCaption.isEmpty()) {
|
if (fileCaption.isEmpty()) {
|
||||||
fileCaption = event.plainBody();
|
fileCaption = event.plainBody();
|
||||||
} else if (fileCaption != event.plainBody()) {
|
} else if (fileCaption != event.plainBody()) {
|
||||||
@@ -494,13 +476,8 @@ QString EventHandler::getMessageBody(const NeoChatRoom *room, const RoomMessageE
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString body;
|
QString body;
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (event.has<EventContent::TextContent>() && event.content()) {
|
if (event.has<EventContent::TextContent>() && event.content()) {
|
||||||
body = event.get<EventContent::TextContent>()->body;
|
body = event.get<EventContent::TextContent>()->body;
|
||||||
#else
|
|
||||||
if (event.hasTextContent() && event.content()) {
|
|
||||||
body = static_cast<const EventContent::TextContent *>(event.content())->body;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
body = event.plainBody();
|
body = event.plainBody();
|
||||||
}
|
}
|
||||||
@@ -715,28 +692,15 @@ QVariantMap EventHandler::getMediaInfoForEvent(const NeoChatRoom *room, const Qu
|
|||||||
// Get the file info for the event.
|
// Get the file info for the event.
|
||||||
if (event->is<RoomMessageEvent>()) {
|
if (event->is<RoomMessageEvent>()) {
|
||||||
auto roomMessageEvent = eventCast<const RoomMessageEvent>(event);
|
auto roomMessageEvent = eventCast<const RoomMessageEvent>(event);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (!roomMessageEvent->has<EventContent::FileContentBase>()) {
|
if (!roomMessageEvent->has<EventContent::FileContentBase>()) {
|
||||||
#else
|
|
||||||
if (!roomMessageEvent->hasFileContent()) {
|
|
||||||
#endif
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
const auto content = roomMessageEvent->get<EventContent::FileContentBase>();
|
const auto content = roomMessageEvent->get<EventContent::FileContentBase>();
|
||||||
QVariantMap mediaInfo = getMediaInfoFromFileInfo(room, content.get(), eventId, false, false);
|
QVariantMap mediaInfo = getMediaInfoFromFileInfo(room, content.get(), eventId, false, false);
|
||||||
#else
|
|
||||||
const auto content = static_cast<const EventContent::FileContent *>(roomMessageEvent->content());
|
|
||||||
QVariantMap mediaInfo = getMediaInfoFromFileInfo(room, content, eventId, false, false);
|
|
||||||
#endif
|
|
||||||
// if filename isn't specifically given, it is in body
|
// if filename isn't specifically given, it is in body
|
||||||
// https://spec.matrix.org/latest/client-server-api/#mfile
|
// https://spec.matrix.org/latest/client-server-api/#mfile
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
mediaInfo["filename"_ls] = content->commonInfo().originalName.isEmpty() ? roomMessageEvent->plainBody() : content->commonInfo().originalName;
|
mediaInfo["filename"_ls] = content->commonInfo().originalName.isEmpty() ? roomMessageEvent->plainBody() : content->commonInfo().originalName;
|
||||||
#else
|
|
||||||
mediaInfo["filename"_ls] = (content->fileInfo()->originalName.isEmpty()) ? roomMessageEvent->plainBody() : content->fileInfo()->originalName;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return mediaInfo;
|
return mediaInfo;
|
||||||
} else if (event->is<StickerEvent>()) {
|
} else if (event->is<StickerEvent>()) {
|
||||||
@@ -750,11 +714,7 @@ QVariantMap EventHandler::getMediaInfoForEvent(const NeoChatRoom *room, const Qu
|
|||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap EventHandler::getMediaInfoFromFileInfo(const NeoChatRoom *room,
|
QVariantMap EventHandler::getMediaInfoFromFileInfo(const NeoChatRoom *room,
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
const Quotient::EventContent::FileContentBase *fileContent,
|
const Quotient::EventContent::FileContentBase *fileContent,
|
||||||
#else
|
|
||||||
const Quotient::EventContent::TypedBase *fileContent,
|
|
||||||
#endif
|
|
||||||
const QString &eventId,
|
const QString &eventId,
|
||||||
bool isThumbnail,
|
bool isThumbnail,
|
||||||
bool isSticker)
|
bool isSticker)
|
||||||
@@ -762,18 +722,10 @@ QVariantMap EventHandler::getMediaInfoFromFileInfo(const NeoChatRoom *room,
|
|||||||
QVariantMap mediaInfo;
|
QVariantMap mediaInfo;
|
||||||
|
|
||||||
// Get the mxc URL for the media.
|
// Get the mxc URL for the media.
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (!fileContent->url().isValid() || fileContent->url().scheme() != QStringLiteral("mxc") || eventId.isEmpty()) {
|
if (!fileContent->url().isValid() || fileContent->url().scheme() != QStringLiteral("mxc") || eventId.isEmpty()) {
|
||||||
#else
|
|
||||||
if (!fileContent->fileInfo()->url().isValid() || fileContent->fileInfo()->url().scheme() != QStringLiteral("mxc") || eventId.isEmpty()) {
|
|
||||||
#endif
|
|
||||||
mediaInfo["source"_ls] = QUrl();
|
mediaInfo["source"_ls] = QUrl();
|
||||||
} else {
|
} else {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
QUrl source = room->makeMediaUrl(eventId, fileContent->url());
|
QUrl source = room->makeMediaUrl(eventId, fileContent->url());
|
||||||
#else
|
|
||||||
QUrl source = room->makeMediaUrl(eventId, fileContent->fileInfo()->url());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (source.isValid()) {
|
if (source.isValid()) {
|
||||||
mediaInfo["source"_ls] = source;
|
mediaInfo["source"_ls] = source;
|
||||||
@@ -790,25 +742,15 @@ QVariantMap EventHandler::getMediaInfoFromFileInfo(const NeoChatRoom *room,
|
|||||||
mediaInfo["mimeIcon"_ls] = mimeType.iconName();
|
mediaInfo["mimeIcon"_ls] = mimeType.iconName();
|
||||||
|
|
||||||
// Add media size if available.
|
// Add media size if available.
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
mediaInfo["size"_ls] = fileContent->commonInfo().payloadSize;
|
mediaInfo["size"_ls] = fileContent->commonInfo().payloadSize;
|
||||||
#else
|
|
||||||
mediaInfo["size"_ls] = static_cast<const EventContent::FileContent *>(fileContent)->fileInfo()->payloadSize;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mediaInfo["isSticker"_ls] = isSticker;
|
mediaInfo["isSticker"_ls] = isSticker;
|
||||||
|
|
||||||
// Add parameter depending on media type.
|
// Add parameter depending on media type.
|
||||||
if (mimeType.name().contains(QStringLiteral("image"))) {
|
if (mimeType.name().contains(QStringLiteral("image"))) {
|
||||||
if (auto castInfo = static_cast<const EventContent::ImageContent *>(fileContent)) {
|
if (auto castInfo = static_cast<const EventContent::ImageContent *>(fileContent)) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
mediaInfo["width"_ls] = castInfo->imageSize.width();
|
mediaInfo["width"_ls] = castInfo->imageSize.width();
|
||||||
mediaInfo["height"_ls] = castInfo->imageSize.height();
|
mediaInfo["height"_ls] = castInfo->imageSize.height();
|
||||||
#else
|
|
||||||
const auto imageInfo = static_cast<const EventContent::ImageInfo *>(castInfo->fileInfo());
|
|
||||||
mediaInfo["width"_ls] = imageInfo->imageSize.width();
|
|
||||||
mediaInfo["height"_ls] = imageInfo->imageSize.height();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// TODO: Images in certain formats (e.g. WebP) will be erroneously marked as animated, even if they are static.
|
// TODO: Images in certain formats (e.g. WebP) will be erroneously marked as animated, even if they are static.
|
||||||
mediaInfo["animated"_ls] = QMovie::supportedFormats().contains(mimeType.preferredSuffix().toUtf8());
|
mediaInfo["animated"_ls] = QMovie::supportedFormats().contains(mimeType.preferredSuffix().toUtf8());
|
||||||
|
|||||||
@@ -290,11 +290,7 @@ private:
|
|||||||
|
|
||||||
static QVariantMap getMediaInfoForEvent(const NeoChatRoom *room, const Quotient::RoomEvent *event);
|
static QVariantMap getMediaInfoForEvent(const NeoChatRoom *room, const Quotient::RoomEvent *event);
|
||||||
QVariantMap static getMediaInfoFromFileInfo(const NeoChatRoom *room,
|
QVariantMap static getMediaInfoFromFileInfo(const NeoChatRoom *room,
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
const Quotient::EventContent::FileContentBase *fileContent,
|
const Quotient::EventContent::FileContentBase *fileContent,
|
||||||
#else
|
|
||||||
const Quotient::EventContent::TypedBase *fileContent,
|
|
||||||
#endif
|
|
||||||
const QString &eventId,
|
const QString &eventId,
|
||||||
bool isThumbnail = false,
|
bool isThumbnail = false,
|
||||||
bool isSticker = false);
|
bool isSticker = false);
|
||||||
|
|||||||
@@ -7,13 +7,10 @@
|
|||||||
|
|
||||||
#include <Quotient/accountregistry.h>
|
#include <Quotient/accountregistry.h>
|
||||||
#include <Quotient/e2ee/sssshandler.h>
|
#include <Quotient/e2ee/sssshandler.h>
|
||||||
|
#include <Quotient/keyimport.h>
|
||||||
#include <Quotient/keyverificationsession.h>
|
#include <Quotient/keyverificationsession.h>
|
||||||
#include <Quotient/roommember.h>
|
#include <Quotient/roommember.h>
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
#include <Quotient/keyimport.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
#include "neochatconfig.h"
|
#include "neochatconfig.h"
|
||||||
|
|
||||||
@@ -43,11 +40,9 @@ struct ForeignSSSSHandler {
|
|||||||
QML_NAMED_ELEMENT(SSSSHandler)
|
QML_NAMED_ELEMENT(SSSSHandler)
|
||||||
};
|
};
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
struct ForeignKeyImport {
|
struct ForeignKeyImport {
|
||||||
Q_GADGET
|
Q_GADGET
|
||||||
QML_SINGLETON
|
QML_SINGLETON
|
||||||
QML_FOREIGN(Quotient::KeyImport)
|
QML_FOREIGN(Quotient::KeyImport)
|
||||||
QML_NAMED_ELEMENT(KeyImport)
|
QML_NAMED_ELEMENT(KeyImport)
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -163,11 +163,7 @@ void AccountEmoticonModel::setEmoticonImage(int index, const QUrl &source)
|
|||||||
QCoro::Task<void> AccountEmoticonModel::doSetEmoticonImage(int index, QUrl source)
|
QCoro::Task<void> AccountEmoticonModel::doSetEmoticonImage(int index, QUrl source)
|
||||||
{
|
{
|
||||||
auto job = m_connection->uploadFile(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
auto job = m_connection->uploadFile(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
co_await qCoro(job.get(), &BaseJob::finished);
|
co_await qCoro(job.get(), &BaseJob::finished);
|
||||||
#else
|
|
||||||
co_await qCoro(job, &BaseJob::finished);
|
|
||||||
#endif
|
|
||||||
if (job->error() != BaseJob::NoError) {
|
if (job->error() != BaseJob::NoError) {
|
||||||
co_return;
|
co_return;
|
||||||
}
|
}
|
||||||
@@ -189,11 +185,7 @@ QCoro::Task<void> AccountEmoticonModel::doSetEmoticonImage(int index, QUrl sourc
|
|||||||
QCoro::Task<void> AccountEmoticonModel::doAddEmoticon(QUrl source, QString shortcode, QString description, QString type)
|
QCoro::Task<void> AccountEmoticonModel::doAddEmoticon(QUrl source, QString shortcode, QString description, QString type)
|
||||||
{
|
{
|
||||||
auto job = m_connection->uploadFile(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
auto job = m_connection->uploadFile(source.isLocalFile() ? source.toLocalFile() : source.toString());
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
co_await qCoro(job.get(), &BaseJob::finished);
|
co_await qCoro(job.get(), &BaseJob::finished);
|
||||||
#else
|
|
||||||
co_await qCoro(job, &BaseJob::finished);
|
|
||||||
#endif
|
|
||||||
if (job->error() != BaseJob::NoError) {
|
if (job->error() != BaseJob::NoError) {
|
||||||
co_return;
|
co_return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -593,19 +593,10 @@ bool ActionsModel::handleQuickEditAction(NeoChatRoom *room, const QString &messa
|
|||||||
|
|
||||||
for (auto it = room->messageEvents().crbegin(); it != room->messageEvents().crend(); it++) {
|
for (auto it = room->messageEvents().crbegin(); it != room->messageEvents().crend(); it++) {
|
||||||
if (const auto event = eventCast<const RoomMessageEvent>(&**it)) {
|
if (const auto event = eventCast<const RoomMessageEvent>(&**it)) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (event->senderId() == room->localMember().id() && event->has<EventContent::TextContent>()) {
|
if (event->senderId() == room->localMember().id() && event->has<EventContent::TextContent>()) {
|
||||||
#else
|
|
||||||
if (event->senderId() == room->localMember().id() && event->hasTextContent()) {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
QString originalString;
|
QString originalString;
|
||||||
if (event->content()) {
|
if (event->content()) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
originalString = static_cast<const Quotient::EventContent::TextContent *>(event->content().get())->body;
|
originalString = static_cast<const Quotient::EventContent::TextContent *>(event->content().get())->body;
|
||||||
#else
|
|
||||||
originalString = static_cast<const Quotient::EventContent::TextContent *>(event->content())->body;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
originalString = event->plainBody();
|
originalString = event->plainBody();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,11 +129,7 @@ void DevicesModel::logout(const QString &deviceId, const QString &password)
|
|||||||
QJsonObject identifier = {{"type"_ls, "m.id.user"_ls}, {"user"_ls, m_connection->user()->id()}};
|
QJsonObject identifier = {{"type"_ls, "m.id.user"_ls}, {"user"_ls, m_connection->user()->id()}};
|
||||||
authData["identifier"_ls] = identifier;
|
authData["identifier"_ls] = identifier;
|
||||||
auto innerJob = m_connection->callApi<NeochatDeleteDeviceJob>(m_devices[index].deviceId, authData);
|
auto innerJob = m_connection->callApi<NeochatDeleteDeviceJob>(m_devices[index].deviceId, authData);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
connect(innerJob.get(), &BaseJob::success, this, onSuccess);
|
connect(innerJob.get(), &BaseJob::success, this, onSuccess);
|
||||||
#else
|
|
||||||
connect(innerJob, &BaseJob::success, this, onSuccess);
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
onSuccess();
|
onSuccess();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -522,19 +522,10 @@ QList<MessageComponent> MessageContentModel::componentsForType(MessageComponentT
|
|||||||
auto fileTransferInfo = m_room->cachedFileTransferInfo(event);
|
auto fileTransferInfo = m_room->cachedFileTransferInfo(event);
|
||||||
|
|
||||||
#ifndef Q_OS_ANDROID
|
#ifndef Q_OS_ANDROID
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
Q_ASSERT(roomMessageEvent->content() != nullptr && roomMessageEvent->has<EventContent::FileContent>());
|
Q_ASSERT(roomMessageEvent->content() != nullptr && roomMessageEvent->has<EventContent::FileContent>());
|
||||||
const QMimeType mimeType = roomMessageEvent->get<EventContent::FileContent>()->mimeType;
|
const QMimeType mimeType = roomMessageEvent->get<EventContent::FileContent>()->mimeType;
|
||||||
#else
|
|
||||||
Q_ASSERT(roomMessageEvent->content() != nullptr && roomMessageEvent->hasFileContent());
|
|
||||||
const QMimeType mimeType = roomMessageEvent->content()->fileInfo()->mimeType;
|
|
||||||
#endif
|
|
||||||
if (mimeType.name() == QStringLiteral("text/plain") || mimeType.parentMimeTypes().contains(QStringLiteral("text/plain"))) {
|
if (mimeType.name() == QStringLiteral("text/plain") || mimeType.parentMimeTypes().contains(QStringLiteral("text/plain"))) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
QString originalName = roomMessageEvent->get<EventContent::FileContent>()->originalName;
|
QString originalName = roomMessageEvent->get<EventContent::FileContent>()->originalName;
|
||||||
#else
|
|
||||||
QString originalName = roomMessageEvent->content()->fileInfo()->originalName;
|
|
||||||
#endif
|
|
||||||
if (originalName.isEmpty()) {
|
if (originalName.isEmpty()) {
|
||||||
originalName = roomMessageEvent->plainBody();
|
originalName = roomMessageEvent->plainBody();
|
||||||
}
|
}
|
||||||
@@ -666,11 +657,7 @@ void MessageContentModel::updateItineraryModel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event)) {
|
if (auto roomMessageEvent = eventCast<const Quotient::RoomMessageEvent>(event)) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (roomMessageEvent->has<EventContent::FileContent>()) {
|
if (roomMessageEvent->has<EventContent::FileContent>()) {
|
||||||
#else
|
|
||||||
if (roomMessageEvent->hasFileContent()) {
|
|
||||||
#endif
|
|
||||||
auto filePath = m_room->cachedFileTransferInfo(event).localPath;
|
auto filePath = m_room->cachedFileTransferInfo(event).localPath;
|
||||||
if (filePath.isEmpty() && m_itineraryModel != nullptr) {
|
if (filePath.isEmpty() && m_itineraryModel != nullptr) {
|
||||||
delete m_itineraryModel;
|
delete m_itineraryModel;
|
||||||
|
|||||||
@@ -505,11 +505,7 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
|
|||||||
|
|
||||||
if (role == ProgressInfoRole) {
|
if (role == ProgressInfoRole) {
|
||||||
if (auto e = eventCast<const RoomMessageEvent>(&evt)) {
|
if (auto e = eventCast<const RoomMessageEvent>(&evt)) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (e->has<EventContent::FileContent>()) {
|
if (e->has<EventContent::FileContent>()) {
|
||||||
#else
|
|
||||||
if (e->hasFileContent()) {
|
|
||||||
#endif
|
|
||||||
return QVariant::fromValue(m_currentRoom->cachedFileTransferInfo(&evt));
|
return QVariant::fromValue(m_currentRoom->cachedFileTransferInfo(&evt));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,12 +311,7 @@ void PushRuleModel::addKeyword(const QString &keyword, const QString &roomId)
|
|||||||
pushConditions.append(keywordCondition);
|
pushConditions.append(keywordCondition);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
auto job = m_connection->callApi<Quotient::SetPushRuleJob>(PushRuleKind::kindString(kind),
|
auto job = m_connection->callApi<Quotient::SetPushRuleJob>(PushRuleKind::kindString(kind),
|
||||||
#else
|
|
||||||
auto job = m_connection->callApi<Quotient::SetPushRuleJob>(QLatin1String("global"),
|
|
||||||
PushRuleKind::kindString(kind),
|
|
||||||
#endif
|
|
||||||
keyword,
|
keyword,
|
||||||
actions,
|
actions,
|
||||||
QString(),
|
QString(),
|
||||||
@@ -341,11 +336,7 @@ void PushRuleModel::removeKeyword(const QString &keyword)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto kind = PushRuleKind::kindString(m_rules[index].kind);
|
auto kind = PushRuleKind::kindString(m_rules[index].kind);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
auto job = m_connection->callApi<Quotient::DeletePushRuleJob>(kind, m_rules[index].id);
|
auto job = m_connection->callApi<Quotient::DeletePushRuleJob>(kind, m_rules[index].id);
|
||||||
#else
|
|
||||||
auto job = m_connection->callApi<Quotient::DeletePushRuleJob>(QStringLiteral("global"), kind, m_rules[index].id);
|
|
||||||
#endif
|
|
||||||
connect(job, &Quotient::BaseJob::failure, this, [this, job, index]() {
|
connect(job, &Quotient::BaseJob::failure, this, [this, job, index]() {
|
||||||
qWarning() << QLatin1String("Unable to remove push rule for keyword %1: ").arg(m_rules[index].id) << job->errorString();
|
qWarning() << QLatin1String("Unable to remove push rule for keyword %1: ").arg(m_rules[index].id) << job->errorString();
|
||||||
});
|
});
|
||||||
@@ -353,18 +344,10 @@ void PushRuleModel::removeKeyword(const QString &keyword)
|
|||||||
|
|
||||||
void PushRuleModel::setNotificationRuleEnabled(const QString &kind, const QString &ruleId, bool enabled)
|
void PushRuleModel::setNotificationRuleEnabled(const QString &kind, const QString &ruleId, bool enabled)
|
||||||
{
|
{
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
auto job = m_connection->callApi<Quotient::IsPushRuleEnabledJob>(kind, ruleId);
|
auto job = m_connection->callApi<Quotient::IsPushRuleEnabledJob>(kind, ruleId);
|
||||||
#else
|
|
||||||
auto job = m_connection->callApi<Quotient::IsPushRuleEnabledJob>(QStringLiteral("global"), kind, ruleId);
|
|
||||||
#endif
|
|
||||||
connect(job, &Quotient::BaseJob::success, this, [job, kind, ruleId, enabled, this]() {
|
connect(job, &Quotient::BaseJob::success, this, [job, kind, ruleId, enabled, this]() {
|
||||||
if (job->enabled() != enabled) {
|
if (job->enabled() != enabled) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
m_connection->callApi<Quotient::SetPushRuleEnabledJob>(kind, ruleId, enabled);
|
m_connection->callApi<Quotient::SetPushRuleEnabledJob>(kind, ruleId, enabled);
|
||||||
#else
|
|
||||||
m_connection->callApi<Quotient::SetPushRuleEnabledJob>(QStringLiteral("global"), kind, ruleId, enabled);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -378,11 +361,7 @@ void PushRuleModel::setNotificationRuleActions(const QString &kind, const QStrin
|
|||||||
actions = actionToVariant(action);
|
actions = actionToVariant(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
m_connection->callApi<Quotient::SetPushRuleActionsJob>(kind, ruleId, actions);
|
m_connection->callApi<Quotient::SetPushRuleActionsJob>(kind, ruleId, actions);
|
||||||
#else
|
|
||||||
m_connection->callApi<Quotient::SetPushRuleActionsJob>(QStringLiteral("global"), kind, ruleId, actions);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PushRuleAction::Action PushRuleModel::variantToAction(const QList<QVariant> &actions, bool enabled)
|
PushRuleAction::Action PushRuleModel::variantToAction(const QList<QVariant> &actions, bool enabled)
|
||||||
|
|||||||
@@ -93,11 +93,7 @@ void SpaceChildrenModel::refreshModel()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR >= 9
|
|
||||||
void SpaceChildrenModel::insertChildren(std::vector<Quotient::GetSpaceHierarchyJob::SpaceHierarchyRoomsChunk> children, const QModelIndex &parent)
|
void SpaceChildrenModel::insertChildren(std::vector<Quotient::GetSpaceHierarchyJob::SpaceHierarchyRoomsChunk> children, const QModelIndex &parent)
|
||||||
#else
|
|
||||||
void SpaceChildrenModel::insertChildren(std::vector<Quotient::GetSpaceHierarchyJob::ChildRoomsChunk> children, const QModelIndex &parent)
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
SpaceTreeItem *parentItem = getItem(parent);
|
SpaceTreeItem *parentItem = getItem(parent);
|
||||||
|
|
||||||
|
|||||||
@@ -144,9 +144,5 @@ private:
|
|||||||
|
|
||||||
void refreshModel();
|
void refreshModel();
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR >= 9
|
|
||||||
void insertChildren(std::vector<Quotient::GetSpaceHierarchyJob::SpaceHierarchyRoomsChunk> children, const QModelIndex &parent = QModelIndex());
|
void insertChildren(std::vector<Quotient::GetSpaceHierarchyJob::SpaceHierarchyRoomsChunk> children, const QModelIndex &parent = QModelIndex());
|
||||||
#else
|
|
||||||
void insertChildren(std::vector<Quotient::GetSpaceHierarchyJob::ChildRoomsChunk> children, const QModelIndex &parent = QModelIndex());
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -87,11 +87,7 @@ QVariant UserListModel::data(const QModelIndex &index, int role) const
|
|||||||
return memberId;
|
return memberId;
|
||||||
}
|
}
|
||||||
if (role == AvatarRole) {
|
if (role == AvatarRole) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
return m_currentRoom->member(memberId).avatarUrl();
|
return m_currentRoom->member(memberId).avatarUrl();
|
||||||
#else
|
|
||||||
return m_currentRoom->memberAvatar(memberId).url();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if (role == ObjectRole) {
|
if (role == ObjectRole) {
|
||||||
return QVariant::fromValue(memberId);
|
return QVariant::fromValue(memberId);
|
||||||
@@ -176,11 +172,7 @@ void UserListModel::refreshAllMembers()
|
|||||||
|
|
||||||
if (m_currentRoom != nullptr) {
|
if (m_currentRoom != nullptr) {
|
||||||
m_members = m_currentRoom->joinedMemberIds();
|
m_members = m_currentRoom->joinedMemberIds();
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
MemberSorter sorter;
|
MemberSorter sorter;
|
||||||
#else
|
|
||||||
MemberSorter sorter(m_currentRoom);
|
|
||||||
#endif
|
|
||||||
std::sort(m_members.begin(), m_members.end(), [&sorter, this](const auto &left, const auto &right) {
|
std::sort(m_members.begin(), m_members.end(), [&sorter, this](const auto &left, const auto &right) {
|
||||||
const auto leftPl = m_currentRoom->getUserPowerLevel(left);
|
const auto leftPl = m_currentRoom->getUserPowerLevel(left);
|
||||||
const auto rightPl = m_currentRoom->getUserPowerLevel(right);
|
const auto rightPl = m_currentRoom->getUserPowerLevel(right);
|
||||||
|
|||||||
@@ -533,7 +533,6 @@ LinkPreviewer *NeoChatConnection::previewerForLink(const QUrl &link)
|
|||||||
return previewer;
|
return previewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
KeyImport::Error NeoChatConnection::exportMegolmSessions(const QString &passphrase, const QString &path)
|
KeyImport::Error NeoChatConnection::exportMegolmSessions(const QString &passphrase, const QString &path)
|
||||||
{
|
{
|
||||||
KeyImport keyImport;
|
KeyImport keyImport;
|
||||||
@@ -548,6 +547,5 @@ KeyImport::Error NeoChatConnection::exportMegolmSessions(const QString &passphra
|
|||||||
file.close();
|
file.close();
|
||||||
return KeyImport::Success;
|
return KeyImport::Success;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "moc_neochatconnection.cpp"
|
#include "moc_neochatconnection.cpp"
|
||||||
|
|||||||
@@ -10,9 +10,7 @@
|
|||||||
#include <QCoroTask>
|
#include <QCoroTask>
|
||||||
#include <Quotient/connection.h>
|
#include <Quotient/connection.h>
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
#include <Quotient/keyimport.h>
|
#include <Quotient/keyimport.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "enums/messagetype.h"
|
#include "enums/messagetype.h"
|
||||||
#include "linkpreviewer.h"
|
#include "linkpreviewer.h"
|
||||||
@@ -160,9 +158,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
Q_INVOKABLE QString accountDataJsonString(const QString &type) const;
|
Q_INVOKABLE QString accountDataJsonString(const QString &type) const;
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
Q_INVOKABLE Quotient::KeyImport::Error exportMegolmSessions(const QString &passphrase, const QString &path);
|
Q_INVOKABLE Quotient::KeyImport::Error exportMegolmSessions(const QString &passphrase, const QString &path);
|
||||||
#endif
|
|
||||||
|
|
||||||
qsizetype directChatNotifications() const;
|
qsizetype directChatNotifications() const;
|
||||||
bool directChatsHaveHighlightNotifications() const;
|
bool directChatsHaveHighlightNotifications() const;
|
||||||
|
|||||||
@@ -74,13 +74,8 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
|
|||||||
const auto m_event = evtIt->viewAs<RoomEvent>();
|
const auto m_event = evtIt->viewAs<RoomEvent>();
|
||||||
QString mxcUrl;
|
QString mxcUrl;
|
||||||
if (auto event = eventCast<const Quotient::RoomMessageEvent>(m_event)) {
|
if (auto event = eventCast<const Quotient::RoomMessageEvent>(m_event)) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (event->has<EventContent::FileContentBase>()) {
|
if (event->has<EventContent::FileContentBase>()) {
|
||||||
mxcUrl = event->get<EventContent::FileContentBase>()->url().toString();
|
mxcUrl = event->get<EventContent::FileContentBase>()->url().toString();
|
||||||
#else
|
|
||||||
if (event->hasFileContent()) {
|
|
||||||
mxcUrl = event->content()->fileInfo()->url().toString();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} else if (auto event = eventCast<const Quotient::StickerEvent>(m_event)) {
|
} else if (auto event = eventCast<const Quotient::StickerEvent>(m_event)) {
|
||||||
mxcUrl = event->image().url().toString();
|
mxcUrl = event->image().url().toString();
|
||||||
@@ -221,11 +216,7 @@ QCoro::Task<void> NeoChatRoom::doUploadFile(QUrl url, QString body)
|
|||||||
auto mime = QMimeDatabase().mimeTypeForUrl(url);
|
auto mime = QMimeDatabase().mimeTypeForUrl(url);
|
||||||
url.setScheme("file"_ls);
|
url.setScheme("file"_ls);
|
||||||
QFileInfo fileInfo(url.isLocalFile() ? url.toLocalFile() : url.toString());
|
QFileInfo fileInfo(url.isLocalFile() ? url.toLocalFile() : url.toString());
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
EventContent::FileContentBase *content;
|
EventContent::FileContentBase *content;
|
||||||
#else
|
|
||||||
EventContent::TypedBase *content;
|
|
||||||
#endif
|
|
||||||
if (mime.name().startsWith("image/"_ls)) {
|
if (mime.name().startsWith("image/"_ls)) {
|
||||||
QImage image(url.toLocalFile());
|
QImage image(url.toLocalFile());
|
||||||
content = new EventContent::ImageContent(url, fileInfo.size(), mime, image.size(), fileInfo.fileName());
|
content = new EventContent::ImageContent(url, fileInfo.size(), mime, image.size(), fileInfo.fileName());
|
||||||
@@ -240,11 +231,7 @@ QCoro::Task<void> NeoChatRoom::doUploadFile(QUrl url, QString body)
|
|||||||
} else {
|
} else {
|
||||||
content = new EventContent::FileContent(url, fileInfo.size(), mime, fileInfo.fileName());
|
content = new EventContent::FileContent(url, fileInfo.size(), mime, fileInfo.fileName());
|
||||||
}
|
}
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
QString txnId = postFile(body.isEmpty() ? url.fileName() : body, std::unique_ptr<EventContent::FileContentBase>(content));
|
QString txnId = postFile(body.isEmpty() ? url.fileName() : body, std::unique_ptr<EventContent::FileContentBase>(content));
|
||||||
#else
|
|
||||||
QString txnId = postFile(body.isEmpty() ? url.fileName() : body, content);
|
|
||||||
#endif
|
|
||||||
setHasFileUploading(true);
|
setHasFileUploading(true);
|
||||||
connect(this, &Room::fileTransferCompleted, [this, txnId](const QString &id, FileSourceInfo) {
|
connect(this, &Room::fileTransferCompleted, [this, txnId](const QString &id, FileSourceInfo) {
|
||||||
if (id == txnId) {
|
if (id == txnId) {
|
||||||
@@ -376,13 +363,8 @@ bool NeoChatRoom::lastEventIsSpoiler() const
|
|||||||
{
|
{
|
||||||
if (auto event = lastEvent()) {
|
if (auto event = lastEvent()) {
|
||||||
if (auto e = eventCast<const RoomMessageEvent>(event)) {
|
if (auto e = eventCast<const RoomMessageEvent>(event)) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (e->has<EventContent::TextContent>() && e->content() && e->mimeType().name() == "text/html"_ls) {
|
if (e->has<EventContent::TextContent>() && e->content() && e->mimeType().name() == "text/html"_ls) {
|
||||||
auto htmlBody = e->get<EventContent::TextContent>()->body;
|
auto htmlBody = e->get<EventContent::TextContent>()->body;
|
||||||
#else
|
|
||||||
if (e->hasTextContent() && e->content() && e->mimeType().name() == "text/html"_ls) {
|
|
||||||
auto htmlBody = static_cast<const Quotient::EventContent::TextContent *>(e->content())->body;
|
|
||||||
#endif
|
|
||||||
return htmlBody.contains("data-mx-spoiler"_ls);
|
return htmlBody.contains("data-mx-spoiler"_ls);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -914,11 +896,7 @@ QCoro::Task<void> NeoChatRoom::doDeleteMessagesByUser(const QString &user, QStri
|
|||||||
}
|
}
|
||||||
for (const auto &e : events) {
|
for (const auto &e : events) {
|
||||||
auto job = connection()->callApi<RedactEventJob>(id(), QString::fromLatin1(QUrl::toPercentEncoding(e)), connection()->generateTxnId(), reason);
|
auto job = connection()->callApi<RedactEventJob>(id(), QString::fromLatin1(QUrl::toPercentEncoding(e)), connection()->generateTxnId(), reason);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
co_await qCoro(job.get(), &BaseJob::finished);
|
co_await qCoro(job.get(), &BaseJob::finished);
|
||||||
#else
|
|
||||||
co_await qCoro(job, &BaseJob::finished);
|
|
||||||
#endif
|
|
||||||
if (job->error() != BaseJob::Success) {
|
if (job->error() != BaseJob::Success) {
|
||||||
qWarning() << "Error: \"" << job->error() << "\" while deleting messages. Aborting";
|
qWarning() << "Error: \"" << job->error() << "\" while deleting messages. Aborting";
|
||||||
break;
|
break;
|
||||||
@@ -1217,11 +1195,7 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
|
|||||||
for (const auto &i : roomRuleArray) {
|
for (const auto &i : roomRuleArray) {
|
||||||
QJsonObject roomRule = i.toObject();
|
QJsonObject roomRule = i.toObject();
|
||||||
if (roomRule["rule_id"_ls] == id()) {
|
if (roomRule["rule_id"_ls] == id()) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
connection()->callApi<DeletePushRuleJob>("room"_ls, id());
|
connection()->callApi<DeletePushRuleJob>("room"_ls, id());
|
||||||
#else
|
|
||||||
connection()->callApi<DeletePushRuleJob>(QLatin1String("global"), "room"_ls, id());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1232,11 +1206,7 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
|
|||||||
for (const auto &i : overrideRuleArray) {
|
for (const auto &i : overrideRuleArray) {
|
||||||
QJsonObject overrideRule = i.toObject();
|
QJsonObject overrideRule = i.toObject();
|
||||||
if (overrideRule["rule_id"_ls] == id()) {
|
if (overrideRule["rule_id"_ls] == id()) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
connection()->callApi<DeletePushRuleJob>("override"_ls, id());
|
connection()->callApi<DeletePushRuleJob>("override"_ls, id());
|
||||||
#else
|
|
||||||
connection()->callApi<DeletePushRuleJob>("global"_ls, "override"_ls, id());
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1272,17 +1242,9 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
|
|||||||
const QList<PushCondition> conditions = {pushCondition};
|
const QList<PushCondition> conditions = {pushCondition};
|
||||||
|
|
||||||
// Add new override rule and make sure it's enabled
|
// Add new override rule and make sure it's enabled
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
auto job = connection()->callApi<SetPushRuleJob>("override"_ls, id(), actions, QString(), QString(), conditions, QString());
|
auto job = connection()->callApi<SetPushRuleJob>("override"_ls, id(), actions, QString(), QString(), conditions, QString());
|
||||||
#else
|
|
||||||
auto job = connection()->callApi<SetPushRuleJob>("global"_ls, "override"_ls, id(), actions, QString(), QString(), conditions, QString());
|
|
||||||
#endif
|
|
||||||
connect(job, &BaseJob::success, this, [this]() {
|
connect(job, &BaseJob::success, this, [this]() {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("override"_ls, id(), true);
|
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("override"_ls, id(), true);
|
||||||
#else
|
|
||||||
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("global"_ls, "override"_ls, id(), true);
|
|
||||||
#endif
|
|
||||||
connect(enableJob, &BaseJob::success, this, [this]() {
|
connect(enableJob, &BaseJob::success, this, [this]() {
|
||||||
m_pushNotificationStateUpdating = false;
|
m_pushNotificationStateUpdating = false;
|
||||||
});
|
});
|
||||||
@@ -1306,17 +1268,9 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
|
|||||||
// No conditions for a room rule
|
// No conditions for a room rule
|
||||||
const QList<PushCondition> conditions;
|
const QList<PushCondition> conditions;
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
auto setJob = connection()->callApi<SetPushRuleJob>("room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
auto setJob = connection()->callApi<SetPushRuleJob>("room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
||||||
#else
|
|
||||||
auto setJob = connection()->callApi<SetPushRuleJob>("global"_ls, "room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
|
||||||
#endif
|
|
||||||
connect(setJob, &BaseJob::success, this, [this]() {
|
connect(setJob, &BaseJob::success, this, [this]() {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("room"_ls, id(), true);
|
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("room"_ls, id(), true);
|
||||||
#else
|
|
||||||
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("global"_ls, "room"_ls, id(), true);
|
|
||||||
#endif
|
|
||||||
connect(enableJob, &BaseJob::success, this, [this]() {
|
connect(enableJob, &BaseJob::success, this, [this]() {
|
||||||
m_pushNotificationStateUpdating = false;
|
m_pushNotificationStateUpdating = false;
|
||||||
});
|
});
|
||||||
@@ -1345,17 +1299,9 @@ void NeoChatRoom::setPushNotificationState(PushNotificationState::State state)
|
|||||||
const QList<PushCondition> conditions;
|
const QList<PushCondition> conditions;
|
||||||
|
|
||||||
// Add new room rule and make sure enabled
|
// Add new room rule and make sure enabled
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
auto setJob = connection()->callApi<SetPushRuleJob>("room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
auto setJob = connection()->callApi<SetPushRuleJob>("room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
||||||
#else
|
|
||||||
auto setJob = connection()->callApi<SetPushRuleJob>("global"_ls, "room"_ls, id(), actions, QString(), QString(), conditions, QString());
|
|
||||||
#endif
|
|
||||||
connect(setJob, &BaseJob::success, this, [this]() {
|
connect(setJob, &BaseJob::success, this, [this]() {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("room"_ls, id(), true);
|
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("room"_ls, id(), true);
|
||||||
#else
|
|
||||||
auto enableJob = connection()->callApi<SetPushRuleEnabledJob>("global"_ls, "room"_ls, id(), true);
|
|
||||||
#endif
|
|
||||||
connect(enableJob, &BaseJob::success, this, [this]() {
|
connect(enableJob, &BaseJob::success, this, [this]() {
|
||||||
m_pushNotificationStateUpdating = false;
|
m_pushNotificationStateUpdating = false;
|
||||||
});
|
});
|
||||||
@@ -1446,11 +1392,7 @@ void NeoChatRoom::openEventMediaExternally(const QString &eventId)
|
|||||||
const auto evtIt = findInTimeline(eventId);
|
const auto evtIt = findInTimeline(eventId);
|
||||||
if (evtIt != messageEvents().rend() && is<RoomMessageEvent>(**evtIt)) {
|
if (evtIt != messageEvents().rend() && is<RoomMessageEvent>(**evtIt)) {
|
||||||
const auto event = evtIt->viewAs<RoomMessageEvent>();
|
const auto event = evtIt->viewAs<RoomMessageEvent>();
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (event->has<EventContent::FileContent>()) {
|
if (event->has<EventContent::FileContent>()) {
|
||||||
#else
|
|
||||||
if (event->hasFileContent()) {
|
|
||||||
#endif
|
|
||||||
const auto transferInfo = cachedFileTransferInfo(event);
|
const auto transferInfo = cachedFileTransferInfo(event);
|
||||||
if (transferInfo.completed()) {
|
if (transferInfo.completed()) {
|
||||||
UrlHelper helper;
|
UrlHelper helper;
|
||||||
@@ -1483,11 +1425,7 @@ void NeoChatRoom::copyEventMedia(const QString &eventId)
|
|||||||
const auto evtIt = findInTimeline(eventId);
|
const auto evtIt = findInTimeline(eventId);
|
||||||
if (evtIt != messageEvents().rend() && is<RoomMessageEvent>(**evtIt)) {
|
if (evtIt != messageEvents().rend() && is<RoomMessageEvent>(**evtIt)) {
|
||||||
const auto event = evtIt->viewAs<RoomMessageEvent>();
|
const auto event = evtIt->viewAs<RoomMessageEvent>();
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (event->has<EventContent::FileContent>()) {
|
if (event->has<EventContent::FileContent>()) {
|
||||||
#else
|
|
||||||
if (event->hasFileContent()) {
|
|
||||||
#endif
|
|
||||||
const auto transferInfo = fileTransferInfo(eventId);
|
const auto transferInfo = fileTransferInfo(eventId);
|
||||||
if (transferInfo.completed()) {
|
if (transferInfo.completed()) {
|
||||||
Clipboard clipboard;
|
Clipboard clipboard;
|
||||||
@@ -1520,13 +1458,8 @@ FileTransferInfo NeoChatRoom::cachedFileTransferInfo(const Quotient::RoomEvent *
|
|||||||
QString mxcUrl;
|
QString mxcUrl;
|
||||||
int total = 0;
|
int total = 0;
|
||||||
if (auto evt = eventCast<const Quotient::RoomMessageEvent>(event)) {
|
if (auto evt = eventCast<const Quotient::RoomMessageEvent>(event)) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
if (evt->has<EventContent::FileContent>()) {
|
if (evt->has<EventContent::FileContent>()) {
|
||||||
const auto fileContent = evt->get<EventContent::FileContent>();
|
const auto fileContent = evt->get<EventContent::FileContent>();
|
||||||
#else
|
|
||||||
if (evt->hasFileContent()) {
|
|
||||||
const auto fileContent = evt->content()->fileInfo();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mxcUrl = fileContent->url().toString();
|
mxcUrl = fileContent->url().toString();
|
||||||
total = fileContent->payloadSize;
|
total = fileContent->payloadSize;
|
||||||
@@ -1884,13 +1817,4 @@ void NeoChatRoom::setRoomState(const QString &type, const QString &stateKey, con
|
|||||||
setState(type, stateKey, QJsonDocument::fromJson(content).object());
|
setState(type, stateKey, QJsonDocument::fromJson(content).object());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR == 8
|
|
||||||
QList<RoomMember> NeoChatRoom::otherMembersTyping() const
|
|
||||||
{
|
|
||||||
auto memberTyping = membersTyping();
|
|
||||||
memberTyping.removeAll(localMember());
|
|
||||||
return memberTyping;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "moc_neochatroom.cpp"
|
#include "moc_neochatroom.cpp"
|
||||||
|
|||||||
@@ -208,10 +208,6 @@ class NeoChatRoom : public Quotient::Room
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(ChatBarCache *threadCache READ threadCache CONSTANT)
|
Q_PROPERTY(ChatBarCache *threadCache READ threadCache CONSTANT)
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR == 8
|
|
||||||
Q_PROPERTY(QList<Quotient::RoomMember> otherMembersTyping READ otherMembersTyping NOTIFY typingChanged)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit NeoChatRoom(Quotient::Connection *connection, QString roomId, Quotient::JoinState joinState = {});
|
explicit NeoChatRoom(Quotient::Connection *connection, QString roomId, Quotient::JoinState joinState = {});
|
||||||
|
|
||||||
@@ -623,10 +619,6 @@ private:
|
|||||||
void cleanupExtraEventRange(Quotient::RoomEventsRange events);
|
void cleanupExtraEventRange(Quotient::RoomEventsRange events);
|
||||||
void cleanupExtraEvent(const QString &eventId);
|
void cleanupExtraEvent(const QString &eventId);
|
||||||
|
|
||||||
#if Quotient_VERSION_MINOR == 8
|
|
||||||
QList<Quotient::RoomMember> otherMembersTyping() const;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void updatePushNotificationState(QString type);
|
void updatePushNotificationState(QString type);
|
||||||
|
|
||||||
|
|||||||
@@ -73,11 +73,7 @@ QString NeochatRoomMember::displayName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto memberObject = m_room->member(m_memberId);
|
const auto memberObject = m_room->member(m_memberId);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
return memberObject.isEmpty() ? id() : memberObject.displayName();
|
return memberObject.isEmpty() ? id() : memberObject.displayName();
|
||||||
#else
|
|
||||||
return memberObject.id().isEmpty() ? id() : memberObject.displayName();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NeochatRoomMember::htmlSafeDisplayName() const
|
QString NeochatRoomMember::htmlSafeDisplayName() const
|
||||||
@@ -87,11 +83,7 @@ QString NeochatRoomMember::htmlSafeDisplayName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto memberObject = m_room->member(m_memberId);
|
const auto memberObject = m_room->member(m_memberId);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
return memberObject.isEmpty() ? id() : memberObject.htmlSafeDisplayName();
|
return memberObject.isEmpty() ? id() : memberObject.htmlSafeDisplayName();
|
||||||
#else
|
|
||||||
return memberObject.id().isEmpty() ? id() : memberObject.htmlSafeDisplayName();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NeochatRoomMember::fullName() const
|
QString NeochatRoomMember::fullName() const
|
||||||
@@ -101,11 +93,7 @@ QString NeochatRoomMember::fullName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto memberObject = m_room->member(m_memberId);
|
const auto memberObject = m_room->member(m_memberId);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
return memberObject.isEmpty() ? id() : memberObject.fullName();
|
return memberObject.isEmpty() ? id() : memberObject.fullName();
|
||||||
#else
|
|
||||||
return memberObject.id().isEmpty() ? id() : memberObject.fullName();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NeochatRoomMember::htmlSafeFullName() const
|
QString NeochatRoomMember::htmlSafeFullName() const
|
||||||
@@ -115,11 +103,7 @@ QString NeochatRoomMember::htmlSafeFullName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto memberObject = m_room->member(m_memberId);
|
const auto memberObject = m_room->member(m_memberId);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
return memberObject.isEmpty() ? id() : memberObject.htmlSafeFullName();
|
return memberObject.isEmpty() ? id() : memberObject.htmlSafeFullName();
|
||||||
#else
|
|
||||||
return memberObject.id().isEmpty() ? id() : memberObject.htmlSafeFullName();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NeochatRoomMember::disambiguatedName() const
|
QString NeochatRoomMember::disambiguatedName() const
|
||||||
@@ -129,11 +113,7 @@ QString NeochatRoomMember::disambiguatedName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto memberObject = m_room->member(m_memberId);
|
const auto memberObject = m_room->member(m_memberId);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
return memberObject.isEmpty() ? id() : memberObject.disambiguatedName();
|
return memberObject.isEmpty() ? id() : memberObject.disambiguatedName();
|
||||||
#else
|
|
||||||
return memberObject.id().isEmpty() ? id() : memberObject.disambiguatedName();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NeochatRoomMember::htmlSafeDisambiguatedName() const
|
QString NeochatRoomMember::htmlSafeDisambiguatedName() const
|
||||||
@@ -143,11 +123,7 @@ QString NeochatRoomMember::htmlSafeDisambiguatedName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const auto memberObject = m_room->member(m_memberId);
|
const auto memberObject = m_room->member(m_memberId);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
return memberObject.isEmpty() ? id() : memberObject.htmlSafeDisambiguatedName();
|
return memberObject.isEmpty() ? id() : memberObject.htmlSafeDisambiguatedName();
|
||||||
#else
|
|
||||||
return memberObject.id().isEmpty() ? id() : memberObject.htmlSafeDisambiguatedName();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int NeochatRoomMember::hue() const
|
int NeochatRoomMember::hue() const
|
||||||
|
|||||||
@@ -148,11 +148,7 @@ void NotificationsManager::processNotificationJob(QPointer<NeoChatConnection> co
|
|||||||
|
|
||||||
QImage avatar_image;
|
QImage avatar_image;
|
||||||
if (!sender.avatarUrl().isEmpty()) {
|
if (!sender.avatarUrl().isEmpty()) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
avatar_image = room->member(sender.id()).avatar(128, 128, {});
|
avatar_image = room->member(sender.id()).avatar(128, 128, {});
|
||||||
#else
|
|
||||||
avatar_image = room->memberAvatar(sender.id()).get(connection, 128, {});
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
avatar_image = room->avatar(128);
|
avatar_image = room->avatar(128);
|
||||||
}
|
}
|
||||||
@@ -298,11 +294,7 @@ void NotificationsManager::doPostInviteNotification(QPointer<NeoChatRoom> room)
|
|||||||
|
|
||||||
QImage avatar_image;
|
QImage avatar_image;
|
||||||
if (roomMemberEvent && !room->member(roomMemberEvent->senderId()).avatarUrl().isEmpty()) {
|
if (roomMemberEvent && !room->member(roomMemberEvent->senderId()).avatarUrl().isEmpty()) {
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
avatar_image = room->member(roomMemberEvent->senderId()).avatar(128, 128, {});
|
avatar_image = room->member(roomMemberEvent->senderId()).avatar(128, 128, {});
|
||||||
#else
|
|
||||||
avatar_image = room->memberAvatar(roomMemberEvent->senderId()).get(room->connection(), 128, [] {});
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "using this room's avatar";
|
qWarning() << "using this room's avatar";
|
||||||
avatar_image = room->avatar(128);
|
avatar_image = room->avatar(128);
|
||||||
|
|||||||
@@ -324,19 +324,11 @@ void RoomManager::visitRoom(Room *r, const QString &eventId)
|
|||||||
void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers)
|
void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers)
|
||||||
{
|
{
|
||||||
auto job = account->joinRoom(roomAliasOrId, viaServers);
|
auto job = account->joinRoom(roomAliasOrId, viaServers);
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
connect(
|
connect(
|
||||||
job.get(),
|
job.get(),
|
||||||
&Quotient::BaseJob::finished,
|
&Quotient::BaseJob::finished,
|
||||||
this,
|
this,
|
||||||
[this, account](Quotient::BaseJob *finish) {
|
[this, account](Quotient::BaseJob *finish) {
|
||||||
#else
|
|
||||||
connect(
|
|
||||||
job,
|
|
||||||
&Quotient::BaseJob::finished,
|
|
||||||
this,
|
|
||||||
[this, account](Quotient::BaseJob *finish) {
|
|
||||||
#endif
|
|
||||||
if (finish->status() == Quotient::BaseJob::Success) {
|
if (finish->status() == Quotient::BaseJob::Success) {
|
||||||
connect(
|
connect(
|
||||||
account,
|
account,
|
||||||
@@ -355,28 +347,16 @@ void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAli
|
|||||||
|
|
||||||
void RoomManager::knockRoom(NeoChatConnection *account, const QString &roomAliasOrId, const QString &reason, const QStringList &viaServers)
|
void RoomManager::knockRoom(NeoChatConnection *account, const QString &roomAliasOrId, const QString &reason, const QStringList &viaServers)
|
||||||
{
|
{
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
auto job = account->callApi<KnockRoomJob>(roomAliasOrId, viaServers, viaServers, reason);
|
auto job = account->callApi<KnockRoomJob>(roomAliasOrId, viaServers, viaServers, reason);
|
||||||
#else
|
|
||||||
auto job = account->callApi<KnockRoomJob>(roomAliasOrId, viaServers, reason);
|
|
||||||
#endif
|
|
||||||
// Upon completion, ensure a room object is created in case it hasn't come
|
// Upon completion, ensure a room object is created in case it hasn't come
|
||||||
// with a sync yet. If the room object is not there, provideRoom() will
|
// with a sync yet. If the room object is not there, provideRoom() will
|
||||||
// create it in Join state. finished() is used here instead of success()
|
// create it in Join state. finished() is used here instead of success()
|
||||||
// to overtake clients that may add their own slots to finished().
|
// to overtake clients that may add their own slots to finished().
|
||||||
#if Quotient_VERSION_MINOR > 8
|
|
||||||
connect(
|
connect(
|
||||||
job.get(),
|
job.get(),
|
||||||
&BaseJob::finished,
|
&BaseJob::finished,
|
||||||
this,
|
this,
|
||||||
[this, job, account] {
|
[this, job, account] {
|
||||||
#else
|
|
||||||
connect(
|
|
||||||
job,
|
|
||||||
&BaseJob::finished,
|
|
||||||
this,
|
|
||||||
[this, job, account] {
|
|
||||||
#endif
|
|
||||||
if (job->status() == Quotient::BaseJob::Success) {
|
if (job->status() == Quotient::BaseJob::Success) {
|
||||||
connect(
|
connect(
|
||||||
account,
|
account,
|
||||||
|
|||||||
Reference in New Issue
Block a user