From 3e9a12e4cb4fa958d6ea1bafd49194471d40c7c6 Mon Sep 17 00:00:00 2001 From: Black Hat Date: Fri, 3 Aug 2018 17:27:21 +0800 Subject: [PATCH] Update libqmatrixclient. This update brings some changes, and more debugging is needed. --- include/libqmatrixclient | 2 +- qml/form/RoomForm.qml | 10 +++++----- src/controller.cpp | 6 ++++++ src/controller.h | 1 + src/main.cpp | 1 - 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/libqmatrixclient b/include/libqmatrixclient index dc3acd3..527a12e 160000 --- a/include/libqmatrixclient +++ b/include/libqmatrixclient @@ -1 +1 @@ -Subproject commit dc3acd336e30a17d6b5d0cbe6cde2838737c9030 +Subproject commit 527a12eb5b6009f679b7e18eceda782f3f5747b7 diff --git a/qml/form/RoomForm.qml b/qml/form/RoomForm.qml index a694a41..bd54d24 100644 --- a/qml/form/RoomForm.qml +++ b/qml/form/RoomForm.qml @@ -230,12 +230,12 @@ Item { if (text.indexOf(PREFIX_ME) === 0) { text = text.substr(PREFIX_ME.length) - currentRoom.postMessage("m.emote", text) + matriqueController.postMessage(currentRoom, "m.emote", text) return } if (text.indexOf(PREFIX_NOTICE) === 0) { text = text.substr(PREFIX_NOTICE.length) - currentRoom.postMessage("m.notice", text) + matriqueController.postMessage(currentRoom, "m.notice", text) return } if (text.indexOf(PREFIX_RAINBOW) === 0) { @@ -246,7 +246,7 @@ Item { for (var i = 0; i < text.length; i++) { parsedText = parsedText + "" + text.charAt(i) + "" } - currentRoom.postHtmlMessage(text, parsedText, "m.text") + currentRoom.postHtmlMessage(text, parsedText) return } if (text.indexOf(PREFIX_HTML) === 0) { @@ -259,11 +259,11 @@ Item { if (text.indexOf(PREFIX_MARKDOWN) === 0) { text = text.substr(PREFIX_MARKDOWN.length) var parsedText = Markdown.markdown_parser(text) - currentRoom.postHtmlMessage(text, parsedText, "m.text") + currentRoom.postHtmlMessage(text, parsedText) return } - currentRoom.postMessage("m.text", text) + matriqueController.postMessage(currentRoom, "m.text", text) } } diff --git a/src/controller.cpp b/src/controller.cpp index 2c6e4e7..de49bcf 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -73,6 +73,12 @@ void Controller::reconnect() { m_connection->connectWithToken(userID, token, ""); } +void Controller::postMessage(Room* room, const QString& type, + const QString& text) { + room->postMessage("m.room.message", + QJsonObject{{"msgtype", type}, {"body", text}}); +} + void Controller::postFile(Room* room, const QUrl& localFile, const QUrl& mxcUrl) { const QString mime = getMIME(localFile); diff --git a/src/controller.h b/src/controller.h index 563c010..fbdfae1 100644 --- a/src/controller.h +++ b/src/controller.h @@ -95,6 +95,7 @@ class Controller : public QObject { void errorOccured(); public slots: + void postMessage(Room* room, const QString& type, const QString& text); void postFile(Room* room, const QUrl& localFile, const QUrl& mxcUrl); QString getMIME(const QUrl& fileUrl) const; void forgetRoom(const QString& roomID); diff --git a/src/main.cpp b/src/main.cpp index 08034c3..0021fb8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -22,7 +22,6 @@ int main(int argc, char *argv[]) { QApplication app(argc, argv); qRegisterMetaType("Room*"); - qRegisterMetaType("User*"); qmlRegisterType("Matrique", 0, 1, "Controller");