Page MenuHomePhorge

D143.1732286708.diff
No OneTemporary

Size
12 KB
Referenced Files
None
Subscribers
None

D143.1732286708.diff

diff --git a/src/contents/ui/SendMessageBox.qml b/src/contents/ui/SendMessageBox.qml
--- a/src/contents/ui/SendMessageBox.qml
+++ b/src/contents/ui/SendMessageBox.qml
@@ -66,17 +66,17 @@
Control {
visible: !!sendMessageBox.draftRelatedTo
Layout.fillWidth: true
-
+
background: Rectangle {
color: Kirigami.Theme.alternateBackgroundColor
}
-
+
contentItem: RowLayout {
spacing: 0
-
+
ColumnLayout {
Layout.fillWidth: true
-
+
Label {
id: replyLabel
Layout.leftMargin: Kirigami.Units.largeSpacing
@@ -84,7 +84,7 @@
Layout.fillWidth: true
text: getRelationPrompt(sendMessageBox.draftRelType)
}
-
+
Item {
id: replyItem
Layout.minimumHeight: Math.min(replyToEventView.implicitHeight, Kirigami.Units.gridUnit * 5)
@@ -209,7 +209,7 @@
if (mouse.button === Qt.RightButton)
textAreaMenu.popup();
}
-
+
Menu {
id: textAreaMenu
MenuItem {
@@ -352,8 +352,11 @@
function uploadFile(fileUrl) {
kazvIOManager.startNewUploadJob(
matrixSdk.serverUrl, fileUrl, matrixSdk.token,
- room.roomId, sdkVars.roomList, room.encrypted
+ room.roomId, sdkVars.roomList, room.encrypted,
+ draftRelType, draftRelatedTo
);
+ sendMessageBox.draftRelType = '';
+ sendMessageBox.draftRelatedTo = '';
}
property var stickerPopup: Kirigami.OverlaySheet {
diff --git a/src/kazv-io-job.hpp b/src/kazv-io-job.hpp
--- a/src/kazv-io-job.hpp
+++ b/src/kazv-io-job.hpp
@@ -142,10 +142,14 @@
bool setFile(const QString fileName);
public:
- KazvIOUploadJob(std::optional<Kazv::AES256CTRDesc> aes = std::nullopt, QObject *parent = 0);
+ KazvIOUploadJob(std::optional<Kazv::AES256CTRDesc> aes = std::nullopt,
+ const QString &relType = QStringLiteral(""),
+ const QString &relatedTo = QStringLiteral(""), QObject *parent = 0);
KazvIOUploadJob(const QString fileName, const QUrl serverUrl, MatrixRoomList *roomList,
const QString &roomId, const QString token,
- std::optional<Kazv::AES256CTRDesc> aes = std::nullopt, QObject *parent = 0);
+ std::optional<Kazv::AES256CTRDesc> aes = std::nullopt,
+ const QString &relType = QStringLiteral(""),
+ const QString &relatedTo = QStringLiteral(""), QObject *parent = 0);
~KazvIOUploadJob();
Q_INVOKABLE QString fileName();
diff --git a/src/kazv-io-job.cpp b/src/kazv-io-job.cpp
--- a/src/kazv-io-job.cpp
+++ b/src/kazv-io-job.cpp
@@ -238,20 +238,28 @@
QSharedPointer<MatrixRoom> room;
QString mimeType;
QString mxcUri;
+ QString relType;
+ QString relatedTo;
};
-KazvIOUploadJob::KazvIOUploadJob(std::optional<Kazv::AES256CTRDesc> aes, QObject *parent)
+KazvIOUploadJob::KazvIOUploadJob(std::optional<Kazv::AES256CTRDesc> aes,
+ const QString &relType, const QString &relatedTo, QObject *parent)
: KazvIOBaseJob(aes, parent)
, m_d(new KazvIOUploadJobPrivate)
{
+ m_d->relType = relType;
+ m_d->relatedTo = relatedTo;
}
KazvIOUploadJob::KazvIOUploadJob(const QString fileName, const QUrl serverUrl,
MatrixRoomList *roomList, const QString &roomId, const QString token,
- std::optional<Kazv::AES256CTRDesc> aes, QObject *parent)
+ std::optional<Kazv::AES256CTRDesc> aes,
+ const QString &relType, const QString &relatedTo, QObject *parent)
: KazvIOBaseJob(aes, parent)
, m_d(new KazvIOUploadJobPrivate)
{
+ m_d->relType = relType;
+ m_d->relatedTo = relatedTo;
if (setFile(fileName)) {
auto kazvUploadJob = Kazv::Api::UploadContentJob(serverUrl.toString().toStdString(),
token.toStdString(), Kazv::FileDesc(std::string()));
@@ -321,10 +329,11 @@
QMimeDatabase().mimeTypeForFile(m_d->file.data()->fileName()).name(),
m_d->file->size(), mxcUri,
QString::fromStdString(aes.value().key()), QString::fromStdString(aes.value().iv()),
- m_d->file->hash());
+ m_d->file->hash(), m_d->relType, m_d->relatedTo);
} else {
m_d->room->sendMediaFileMessage(QUrl::fromLocalFile(m_d->file->fileName()).fileName(),
- QMimeDatabase().mimeTypeForData(m_d->file.data()).name(), m_d->file->size(), mxcUri);
+ QMimeDatabase().mimeTypeForData(m_d->file.data()).name(),
+ m_d->file->size(), mxcUri, m_d->relType, m_d->relatedTo);
}
}
diff --git a/src/kazv-io-manager.hpp b/src/kazv-io-manager.hpp
--- a/src/kazv-io-manager.hpp
+++ b/src/kazv-io-manager.hpp
@@ -51,8 +51,10 @@
Q_INVOKABLE KazvIOBaseJob *startNewDownloadJob(const QUrl &serverUrl, const QUrl &localFileName,
const QString &jobId, const QString &hash,
const QString &key = QStringLiteral(""), const QString &iv = QStringLiteral(""));
- Q_INVOKABLE KazvIOBaseJob *startNewUploadJob(const QUrl &serverUrl, const QUrl &localFileName,
- const QString &token, const QString &roomId, MatrixRoomList *roomList, const bool encrypted);
+ Q_INVOKABLE KazvIOBaseJob *startNewUploadJob(
+ const QUrl &serverUrl, const QUrl &localFileName, const QString &token,
+ const QString &roomId, MatrixRoomList *roomList, const bool encrypted,
+ const QString &relType, const QString &relatedTo);
Q_INVOKABLE KazvIOBaseJob *startNewRoomlessUploadJob(const QUrl &serverUrl, const QUrl &localFileName, const QString &token);
Q_INVOKABLE KazvIOBaseJob *getCacheJob(const QString &jobId) const;
Q_INVOKABLE KazvIOBaseJob *getDownloadJob(const QString &jobId);
diff --git a/src/kazv-io-manager.cpp b/src/kazv-io-manager.cpp
--- a/src/kazv-io-manager.cpp
+++ b/src/kazv-io-manager.cpp
@@ -96,18 +96,20 @@
return downloadJob.data();
}
-KazvIOBaseJob *KazvIOManager::startNewUploadJob(const QUrl &serverUrl, const QUrl &localFileUrl,
- const QString &token, const QString &roomId, MatrixRoomList *roomList, const bool encrypted)
+KazvIOBaseJob *KazvIOManager::startNewUploadJob(
+ const QUrl &serverUrl, const QUrl &localFileUrl, const QString &token,
+ const QString &roomId, MatrixRoomList *roomList, const bool encrypted,
+ const QString &relType, const QString &relatedTo)
{
auto uploadJob = QPointer<KazvIOUploadJob>();
if (encrypted) {
auto aes = Kazv::AES256CTRDesc::fromRandom(
m_d->randomGenerator.generateRange<Kazv::RandomData>(Kazv::AES256CTRDesc::randomSize));
uploadJob = new KazvIOUploadJob(localFileUrl.toLocalFile(), serverUrl,
- roomList, roomId, token, aes);
+ roomList, roomId, token, aes, relType, relatedTo);
} else {
uploadJob = new KazvIOUploadJob(localFileUrl.toLocalFile(), serverUrl,
- roomList, roomId, token, std::nullopt);
+ roomList, roomId, token, std::nullopt, relType, relatedTo);
}
if (!m_d->uploadJobs.contains(roomId) || m_d->uploadJobs[roomId].isNull()) {
m_d->uploadJobs[roomId].reset(new UploadJobModel());
@@ -119,7 +121,9 @@
KazvIOBaseJob *KazvIOManager::startNewRoomlessUploadJob(const QUrl &serverUrl, const QUrl &localFileUrl, const QString &token)
{
- return startNewUploadJob(serverUrl, localFileUrl, token, ROOMLESS, 0, false);
+ return startNewUploadJob(
+ serverUrl, localFileUrl, token, ROOMLESS, 0, false,
+ QStringLiteral(""), QStringLiteral(""));
}
KazvIOBaseJob *KazvIOManager::getCacheJob(const QString &jobId) const
diff --git a/src/matrix-room.hpp b/src/matrix-room.hpp
--- a/src/matrix-room.hpp
+++ b/src/matrix-room.hpp
@@ -77,11 +77,13 @@
Q_INVOKABLE void sendTextMessage(QString text, const QString &relType, QString relatedTo) const;
Q_INVOKABLE void sendMediaFileMessage(QString fileName, QString mimeType,
- qint64 fileSize, QString mxcUri) const;
+ qint64 fileSize, QString mxcUri,
+ const QString &relType, const QString &relatedTo) const;
Q_INVOKABLE void sendEncryptedFileMessage(const QString &fileName, const QString& mimeType,
const qint64 fileSize, const QString& mxcUri,
- const QString &key, const QString &iv, const QByteArray &hash) const;
+ const QString &key, const QString &iv, const QByteArray &hash,
+ const QString &relType, const QString &relatedTo) const;
Q_INVOKABLE void sendReaction(QString text, QString relatedTo) const;
@@ -144,10 +146,12 @@
protected:
nlohmann::json makeMediaFileMessageJson(QString fileName, QString mimeType,
- qint64 fileSize, QString mxcUri) const;
+ qint64 fileSize, QString mxcUri,
+ const QString &relType, const QString &relatedTo) const;
nlohmann::json makeEncryptedFileMessageJson(const QString &fileName, const QString &mimeType,
const qint64 fileSize, const QString &mxcUri,
- const QString &key, const QString &iv, const QByteArray &hash) const;
+ const QString &key, const QString &iv, const QByteArray &hash,
+ const QString &relType, const QString &relatedTo) const;
private Q_SLOTS:
void setTypingImpl();
diff --git a/src/matrix-room.cpp b/src/matrix-room.cpp
--- a/src/matrix-room.cpp
+++ b/src/matrix-room.cpp
@@ -207,18 +207,24 @@
m_room.sendMessage(Event(j));
}
-void MatrixRoom::sendMediaFileMessage(QString fileName, QString mimeType, qint64 fileSize, QString mxcUri) const
+void MatrixRoom::sendMediaFileMessage(
+ QString fileName, QString mimeType, qint64 fileSize, QString mxcUri,
+ const QString &relType, const QString &relatedTo) const
{
- auto j = makeMediaFileMessageJson(fileName, mimeType, fileSize, mxcUri);
+ auto j = makeMediaFileMessageJson(
+ fileName, mimeType, fileSize, mxcUri, relType, relatedTo);
Kazv::Event e{j};
m_room.sendMessage(e);
}
void MatrixRoom::sendEncryptedFileMessage(const QString &fileName, const QString &mimeType,
const qint64 fileSize, const QString &mxcUri,
- const QString &key, const QString &iv, const QByteArray &hash) const
+ const QString &key, const QString &iv, const QByteArray &hash,
+ const QString &relType, const QString &relatedTo) const
{
- auto j = makeEncryptedFileMessageJson(fileName, mimeType, fileSize, mxcUri, key, iv, hash);
+ auto j = makeEncryptedFileMessageJson(
+ fileName, mimeType, fileSize, mxcUri,
+ key, iv, hash, relType, relatedTo);
Kazv::Event e{j};
m_room.sendMessage(e);
}
@@ -255,7 +261,9 @@
return new MatrixPromise(m_room.sendStateEvent(Event(json(eventJson))));
}
-nlohmann::json MatrixRoom::makeMediaFileMessageJson(QString fileName, QString mimeType, qint64 fileSize, QString mxcUri) const
+nlohmann::json MatrixRoom::makeMediaFileMessageJson(
+ QString fileName, QString mimeType, qint64 fileSize, QString mxcUri,
+ const QString &relType, const QString &relatedTo) const
{
static auto available_msgtype = std::array<std::string, 3>{"m.audio", "m.video", "m.image"};
auto try_msgtype = std::find(available_msgtype.begin(), available_msgtype.end(),
@@ -266,7 +274,7 @@
} else {
msgtype = *try_msgtype;
}
- return nlohmann::json {
+ auto msg = nlohmann::json {
{"type", "m.room.message"},
{"content", {
{"msgtype", msgtype},
@@ -278,12 +286,17 @@
}}
}}
};
+ maybeAddRelations(msg, relType, relatedTo);
+ return msg;
}
nlohmann::json MatrixRoom::makeEncryptedFileMessageJson(const QString &fileName, const QString &mimeType,
const qint64 fileSize, const QString &mxcUri,
- const QString &key, const QString &iv, const QByteArray &hash) const
+ const QString &key, const QString &iv, const QByteArray &hash,
+ const QString &relType, const QString &relatedTo) const
{
+ qDebug() << relType;
+ qDebug() << relatedTo;
static auto available_msgtype = std::array<std::string, 3>{"m.audio", "m.video", "m.image"};
auto try_msgtype = std::find(available_msgtype.begin(), available_msgtype.end(),
QStringLiteral("m.").append(mimeType.split(QChar('/'))[0]).toStdString());
@@ -293,7 +306,7 @@
} else {
msgtype = *try_msgtype;
}
- return nlohmann::json {
+ auto msg = nlohmann::json {
{"type", "m.room.message"},
{"content", {
{"msgtype", msgtype},
@@ -319,6 +332,8 @@
}}
}}
};
+ maybeAddRelations(msg, relType, relatedTo);
+ return msg;
}
MatrixPromise *MatrixRoom::redactEvent(QString eventId, QString reason) const

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 22, 6:45 AM (18 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38884
Default Alt Text
D143.1732286708.diff (12 KB)

Event Timeline