Port MatrixMessageText to C
This commit is contained in:
parent
93154a3e5e
commit
3e7979b905
1
.gitignore
vendored
1
.gitignore
vendored
@ -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
|
||||
|
@ -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 \
|
||||
|
@ -26,6 +26,8 @@
|
||||
#include "matrix-event-room-topic.h"
|
||||
#include "matrix-event-room-aliases.h"
|
||||
|
||||
#include "matrix-message-text.h"
|
||||
|
||||
/*
|
||||
Borrowed from GLib
|
||||
|
||||
|
70
src/matrix-message-text.c
Normal file
70
src/matrix-message-text.c
Normal file
@ -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
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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)
|
||||
{}
|
@ -16,23 +16,23 @@
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 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 <glib-object.h>
|
||||
# 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__ */
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user