Add event handler for m.call.hangup
This commit is contained in:
parent
b6b5bbf567
commit
11de94b822
1
.gitignore
vendored
1
.gitignore
vendored
@ -78,3 +78,4 @@ Makefile.in
|
||||
/src/matrix-event-call-invite.c
|
||||
/src/matrix-event-call-candidates.c
|
||||
/src/matrix-event-call-answer.c
|
||||
/src/matrix-event-call-hangup.c
|
||||
|
@ -48,6 +48,7 @@ libmatrix_glib_0_0_la_VALA_SOURCES = \
|
||||
matrix-event-call-invite.vala \
|
||||
matrix-event-call-candidates.vala \
|
||||
matrix-event-call-answer.vala \
|
||||
matrix-event-call-hangup.vala \
|
||||
$(NULL)
|
||||
|
||||
AM_CPPFLAGS += \
|
||||
|
80
src/matrix-event-call-hangup.vala
Normal file
80
src/matrix-event-call-hangup.vala
Normal file
@ -0,0 +1,80 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sent by either party to signal their termination of the call. This
|
||||
* can be sent either once the call has has been established or before
|
||||
* to abort the call.
|
||||
*/
|
||||
public class Matrix.Event.CallHangup : Matrix.Event.Room {
|
||||
/**
|
||||
* The ID of the call this event relates to.
|
||||
*/
|
||||
public string? call_id { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* The version of the VoIP specification this message adheres to.
|
||||
*/
|
||||
public int? version { get; set; default = null; }
|
||||
|
||||
protected override void
|
||||
from_json(Json.Node json_data)
|
||||
throws Matrix.Error
|
||||
{
|
||||
var content_root = json_data.get_object()
|
||||
.get_member("content").get_object();
|
||||
Json.Node? node;
|
||||
|
||||
if ((node = content_root.get_member("call_id")) != null) {
|
||||
_call_id = node.get_string();
|
||||
} else {
|
||||
warning("content.call_id is missing from a m.call.hangup event");
|
||||
}
|
||||
|
||||
if ((node = content_root.get_member("version")) != null) {
|
||||
_version = (int)node.get_int();
|
||||
} else {
|
||||
warning("content.version is missing from a m.call.hangup event");
|
||||
}
|
||||
|
||||
base.from_json(json_data);
|
||||
}
|
||||
|
||||
protected override void
|
||||
to_json(Json.Node json_data)
|
||||
throws Matrix.Error
|
||||
{
|
||||
if (_call_id == null) {
|
||||
throw new Matrix.Error.INCOMPLETE(
|
||||
"Won't generate a m.call.hangup event without call_id");
|
||||
}
|
||||
|
||||
if (_version == null) {
|
||||
throw new Matrix.Error.INCOMPLETE(
|
||||
"Won't generate a m.call.hangup event without version");
|
||||
}
|
||||
|
||||
var content_root = json_data.get_object()
|
||||
.get_member("content").get_object();
|
||||
|
||||
content_root.set_string_member("call_id", _call_id);
|
||||
content_root.set_int_member("version", version);
|
||||
|
||||
base.to_json(json_data);
|
||||
}
|
||||
}
|
@ -218,6 +218,9 @@ matrix_event_types_ctor(void)
|
||||
matrix_event_register_type("m.call.answer",
|
||||
MATRIX_EVENT_TYPE_CALL_ANSWER,
|
||||
NULL);
|
||||
matrix_event_register_type("m.call.hangup",
|
||||
MATRIX_EVENT_TYPE_CALL_HANGUP,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user