Port MatrixMessageNotice to C
This commit is contained in:
parent
57bbfa43a1
commit
10e4c0d7f0
1
.gitignore
vendored
1
.gitignore
vendored
@ -68,4 +68,3 @@ Makefile.in
|
|||||||
/src/matrix-event-call-answer.c
|
/src/matrix-event-call-answer.c
|
||||||
/src/matrix-event-call-hangup.c
|
/src/matrix-event-call-hangup.c
|
||||||
/src/matrix-glib-0.0.pc
|
/src/matrix-glib-0.0.pc
|
||||||
/src/matrix-message-notice.c
|
|
||||||
|
@ -35,7 +35,6 @@ libmatrix_glib_0_0_la_VALA_SOURCES = \
|
|||||||
matrix-event-call-candidates.vala \
|
matrix-event-call-candidates.vala \
|
||||||
matrix-event-call-answer.vala \
|
matrix-event-call-answer.vala \
|
||||||
matrix-event-call-hangup.vala \
|
matrix-event-call-hangup.vala \
|
||||||
matrix-message-notice.vala \
|
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
AM_CPPFLAGS += \
|
AM_CPPFLAGS += \
|
||||||
@ -101,6 +100,7 @@ INST_H_SRC_FILES = \
|
|||||||
matrix-message-image.h \
|
matrix-message-image.h \
|
||||||
matrix-message-audio.h \
|
matrix-message-audio.h \
|
||||||
matrix-message-video.h \
|
matrix-message-video.h \
|
||||||
|
matrix-message-notice.h \
|
||||||
matrix-event-room-base.h \
|
matrix-event-room-base.h \
|
||||||
matrix-event-state-base.h \
|
matrix-event-state-base.h \
|
||||||
matrix-event-tag.h \
|
matrix-event-tag.h \
|
||||||
@ -145,6 +145,7 @@ libmatrix_glib_0_0_la_SOURCES = \
|
|||||||
matrix-message-image.c \
|
matrix-message-image.c \
|
||||||
matrix-message-audio.c \
|
matrix-message-audio.c \
|
||||||
matrix-message-video.c \
|
matrix-message-video.c \
|
||||||
|
matrix-message-notice.c \
|
||||||
matrix-event-tag.c \
|
matrix-event-tag.c \
|
||||||
matrix-event-presence.c \
|
matrix-event-presence.c \
|
||||||
matrix-event-room-member.c \
|
matrix-event-room-member.c \
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "matrix-message-image.h"
|
#include "matrix-message-image.h"
|
||||||
#include "matrix-message-audio.h"
|
#include "matrix-message-audio.h"
|
||||||
#include "matrix-message-video.h"
|
#include "matrix-message-video.h"
|
||||||
|
#include "matrix-message-notice.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Borrowed from GLib
|
Borrowed from GLib
|
||||||
|
62
src/matrix-message-notice.c
Normal file
62
src/matrix-message-notice.c
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* 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-notice.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:matrix-message-notice
|
||||||
|
* @short_description: message type representing notices
|
||||||
|
*
|
||||||
|
* This is the default message handler for `m.notice` messages.
|
||||||
|
*
|
||||||
|
* A notice should be considered similar to a plain text messages except that clients should
|
||||||
|
* visually distinguish it in some way. It is intended to be used by automated clients, such
|
||||||
|
* as bots, bridges, and other entities, rather than humans. Additionally, such automated
|
||||||
|
* agents which watch a room for messages and respond to them ought to ignore notices. This
|
||||||
|
* helps to prevent infinite loop situations where two automated clients continuously exchange
|
||||||
|
* messages, as each responds to the other.
|
||||||
|
*/
|
||||||
|
G_DEFINE_TYPE(MatrixMessageNotice, matrix_message_notice, MATRIX_MESSAGE_TYPE_BASE);
|
||||||
|
|
||||||
|
static void
|
||||||
|
matrix_message_notice_real_from_json(MatrixMessageBase *matrix_message_base, JsonNode *json_data, GError **error)
|
||||||
|
{
|
||||||
|
MATRIX_MESSAGE_BASE_CLASS(matrix_message_notice_parent_class)->from_json(matrix_message_base, json_data, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
matrix_message_notice_real_to_json(MatrixMessageBase *matrix_message_base, JsonNode *json_data, GError **error)
|
||||||
|
{
|
||||||
|
MATRIX_MESSAGE_BASE_CLASS(matrix_message_notice_parent_class)->to_json(matrix_message_base, json_data, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
MatrixMessageNotice *
|
||||||
|
matrix_message_notice_new(void) {
|
||||||
|
return (MatrixMessageNotice *)matrix_message_base_construct(MATRIX_MESSAGE_TYPE_NOTICE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
matrix_message_notice_class_init(MatrixMessageNoticeClass *klass)
|
||||||
|
{
|
||||||
|
((MatrixMessageBaseClass *)klass)->from_json = matrix_message_notice_real_from_json;
|
||||||
|
((MatrixMessageBaseClass *)klass)->to_json = matrix_message_notice_real_to_json;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
matrix_message_notice_init(MatrixMessageNotice *matrix_message_notice)
|
||||||
|
{}
|
38
src/matrix-message-notice.h
Normal file
38
src/matrix-message-notice.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __MATRIX_GLIB_SDK_MESSAGE_NOTICE_H__
|
||||||
|
# define __MATRIX_GLIB_SDK_MESSAGE_NOTICE_H__
|
||||||
|
|
||||||
|
# include <glib-object.h>
|
||||||
|
# include "matrix-message-base.h"
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define MATRIX_MESSAGE_TYPE_NOTICE (matrix_message_notice_get_type ())
|
||||||
|
G_DECLARE_DERIVABLE_TYPE(MatrixMessageNotice, matrix_message_notice, MATRIX_MESSAGE, NOTICE, MatrixMessageBase)
|
||||||
|
|
||||||
|
struct _MatrixMessageNoticeClass {
|
||||||
|
MatrixMessageBaseClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
MatrixMessageNotice* matrix_message_notice_new (void);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __MATRIX_GLIB_SDK_MESSAGE_NOTICE_H__ */
|
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Message type to hold a m.notice message
|
|
||||||
*
|
|
||||||
* A m.notice message should be considered similar to a plain m.text
|
|
||||||
* message except that clients should visually distinguish it in some
|
|
||||||
* way. It is intended to be used by automated clients, such as bots,
|
|
||||||
* bridges, and other entities, rather than humans. Additionally, such
|
|
||||||
* automated agents which watch a room for messages and respond to
|
|
||||||
* them ought to ignore m.notice messages. This helps to prevent
|
|
||||||
* infinite-loop situations where two automated clients continuously
|
|
||||||
* exchange messages, as each responds to the other.
|
|
||||||
*/
|
|
||||||
public class Matrix.Message.Notice : Matrix.Message.Base {
|
|
||||||
public override void
|
|
||||||
from_json(Json.Node json_data)
|
|
||||||
throws Matrix.Error
|
|
||||||
{
|
|
||||||
base.from_json(json_data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void
|
|
||||||
to_json(Json.Node json_data)
|
|
||||||
throws Matrix.Error
|
|
||||||
{
|
|
||||||
base.to_json(json_data);
|
|
||||||
}
|
|
||||||
}
|
|
@ -837,5 +837,16 @@ namespace Matrix {
|
|||||||
to_json(Json.Node json_data)
|
to_json(Json.Node json_data)
|
||||||
throws Matrix.Error;
|
throws Matrix.Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CCode (cheader_filename = "matrix-message-notice.h")]
|
||||||
|
public class Notice : 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