Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F112282
D143.1732288395.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
12 KB
Referenced Files
None
Subscribers
None
D143.1732288395.diff
View Options
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)
@@ -193,7 +193,7 @@
if (mouse.button === Qt.RightButton)
textAreaMenu.popup();
}
-
+
Menu {
id: textAreaMenu
MenuItem {
@@ -337,7 +337,10 @@
kazvIOManager.startNewUploadJob(
matrixSdk.serverUrl, fileUrl, matrixSdk.token,
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
@@ -75,11 +75,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;
@@ -142,10 +144,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
@@ -196,18 +196,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);
}
@@ -244,7 +250,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(),
@@ -255,7 +263,7 @@
} else {
msgtype = *try_msgtype;
}
- return nlohmann::json {
+ auto msg = nlohmann::json {
{"type", "m.room.message"},
{"content", {
{"msgtype", msgtype},
@@ -267,12 +275,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());
@@ -282,7 +295,7 @@
} else {
msgtype = *try_msgtype;
}
- return nlohmann::json {
+ auto msg = nlohmann::json {
{"type", "m.room.message"},
{"content", {
{"msgtype", msgtype},
@@ -308,6 +321,8 @@
}}
}}
};
+ maybeAddRelations(msg, relType, relatedTo);
+ return msg;
}
MatrixPromise *MatrixRoom::redactEvent(QString eventId, QString reason) const
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 7:13 AM (18 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38891
Default Alt Text
D143.1732288395.diff (12 KB)
Attached To
Mode
D143: Enable upload file for reply
Attached
Detach File
Event Timeline
Log In to Comment