diff --git a/.gitignore b/.gitignore
index 9e7925a..805088b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -71,7 +71,6 @@ Makefile.in
/src/matrix-event-call-hangup.c
/src/matrix-event-call-base.c
/src/matrix-glib-0.0.pc
-/src/matrix-message-text.c
/src/matrix-message-emote.c
/src/matrix-message-notice.c
/src/matrix-message-file.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 07c3503..e73bee5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,7 +38,6 @@ libmatrix_glib_0_0_la_VALA_SOURCES = \
matrix-event-call-candidates.vala \
matrix-event-call-answer.vala \
matrix-event-call-hangup.vala \
- matrix-message-text.vala \
matrix-message-emote.vala \
matrix-message-notice.vala \
matrix-message-file.vala \
@@ -104,6 +103,7 @@ INST_H_SRC_FILES = \
matrix-compacts.h \
matrix-event-base.h \
matrix-message-base.h \
+ matrix-message-text.h \
matrix-event-room-base.h \
matrix-event-state-base.h \
matrix-event-tag.h \
@@ -137,6 +137,7 @@ libmatrix_glib_0_0_la_SOURCES = \
matrix-compacts.c \
matrix-event-base.c \
matrix-message-base.c \
+ matrix-message-text.c \
matrix-event-tag.c \
matrix-event-presence.c \
matrix-event-room-member.c \
diff --git a/src/matrix-event-types.c b/src/matrix-event-types.c
index 8415232..e00b129 100644
--- a/src/matrix-event-types.c
+++ b/src/matrix-event-types.c
@@ -26,6 +26,8 @@
#include "matrix-event-room-topic.h"
#include "matrix-event-room-aliases.h"
+#include "matrix-message-text.h"
+
/*
Borrowed from GLib
diff --git a/src/matrix-message-text.c b/src/matrix-message-text.c
new file mode 100644
index 0000000..486a4c5
--- /dev/null
+++ b/src/matrix-message-text.c
@@ -0,0 +1,70 @@
+/*
+ * This file is part of matrix-glib-sdk
+ *
+ * matrix-glib-sdk is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * matrix-glib-sdk is distributed in the hope that it will be
+ * useful, but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with matrix-glib-sdk. If not, see
+ * .
+ */
+
+#include "matrix-message-text.h"
+
+/**
+ * SECTION:matrix-message-text
+ * @short_description: message handler for plain text messages
+ *
+ * This is the default message handler for `m.text` messages.
+ */
+G_DEFINE_TYPE(MatrixMessageText, matrix_message_text, MATRIX_MESSAGE_TYPE_BASE);
+
+static void
+matrix_message_text_real_from_json(MatrixMessageBase *matrix_message_base, JsonNode *json_data, GError **error)
+{
+ GError *inner_error = NULL;
+
+ g_return_if_fail(json_data != NULL);
+
+ MATRIX_MESSAGE_BASE_CLASS(matrix_message_text_parent_class)->from_json(matrix_message_base, json_data, &inner_error);
+
+ if (inner_error != NULL) {
+ g_propagate_error(error, inner_error);
+ }
+}
+
+static void
+matrix_message_text_real_to_json(MatrixMessageBase *matrix_message_base, JsonNode *json_data, GError **error)
+{
+ GError *inner_error = NULL;
+
+ g_return_if_fail(json_data != NULL);
+
+ MATRIX_MESSAGE_BASE_CLASS(matrix_message_text_parent_class)->to_json(matrix_message_base, json_data, &inner_error);
+
+ if (inner_error != NULL) {
+ g_propagate_error(error, inner_error);
+ }
+}
+
+MatrixMessageText *
+matrix_message_text_new(void) {
+ return (MatrixMessageText *)matrix_message_base_construct(MATRIX_MESSAGE_TYPE_TEXT);
+}
+
+static void
+matrix_message_text_class_init(MatrixMessageTextClass *klass)
+{
+ ((MatrixMessageBaseClass *)klass)->from_json = matrix_message_text_real_from_json;
+ ((MatrixMessageBaseClass *)klass)->to_json = matrix_message_text_real_to_json;
+}
+
+static void matrix_message_text_init(MatrixMessageText *matrix_message_text)
+{}
diff --git a/src/matrix-message-text.vala b/src/matrix-message-text.h
similarity index 58%
rename from src/matrix-message-text.vala
rename to src/matrix-message-text.h
index 91ae5f4..b1d27f7 100644
--- a/src/matrix-message-text.vala
+++ b/src/matrix-message-text.h
@@ -16,23 +16,23 @@
* .
*/
-/**
- * Message handler for plain text messages
- *
- * Handle plain text messages.
- */
-public class Matrix.Message.Text : Matrix.Message.Base {
- public override void
- from_json(Json.Node json_data)
- throws Matrix.Error
- {
- base.from_json(json_data);
- }
+#ifndef __MATRIX_GLIB_SDK_MESSAGE_TEXT_H__
+# define __MATRIX_GLIB_SDK_MESSAGE_TEXT_H__
- public override void
- to_json(Json.Node json_data)
- throws Matrix.Error
- {
- base.to_json(json_data);
- }
-}
+# include
+# include "matrix-message-base.h"
+
+G_BEGIN_DECLS
+
+# define MATRIX_MESSAGE_TYPE_TEXT matrix_message_text_get_type()
+G_DECLARE_DERIVABLE_TYPE(MatrixMessageText, matrix_message_text, MATRIX_MESSAGE, TEXT, MatrixMessageBase)
+
+struct _MatrixMessageTextClass {
+ MatrixMessageBaseClass parent_class;
+};
+
+MatrixMessageText* matrix_message_text_new (void);
+
+G_END_DECLS
+
+#endif /* __MATRIX_GLIB_SDK_MESSAGE_TEXT_H__ */
diff --git a/vapi/c-api.vapi b/vapi/c-api.vapi
index dfa316c..2d95658 100644
--- a/vapi/c-api.vapi
+++ b/vapi/c-api.vapi
@@ -641,5 +641,14 @@ namespace Matrix {
public virtual void to_json(Json.Node json_data)
throws Matrix.Error;
}
+
+ [CCode (cheader_filename = "matrix-message-text.h")]
+ public class Text : Base {
+ public override void from_json(Json.Node json_data)
+ throws Matrix.Error;
+
+ public override void to_json(Json.Node json_data)
+ throws Matrix.Error;
+ }
}
}