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");