Compare commits
1 Commits
master
...
object-gen
Author | SHA1 | Date | |
---|---|---|---|
|
0d024b6885 |
19
.gitignore
vendored
19
.gitignore
vendored
@ -37,15 +37,26 @@ Makefile.in
|
||||
/INSTALL
|
||||
/ChangeLog
|
||||
/src/matrix-version.h
|
||||
/src/matrix-enumtypes.[ch]
|
||||
/src/matrix-marshalers.[ch]
|
||||
/src/stamp-matrix-marshalers
|
||||
/docs/valadoc/gtk-doc/gtk-doc
|
||||
|
||||
# Vala related files
|
||||
/src/Matrix-0.0.vapi
|
||||
/src/vala-temp
|
||||
/src/vala-stamp
|
||||
/src/matrix-glib.h
|
||||
/src/namespace-info.vala
|
||||
/src/namespace-info.c
|
||||
/src/matrix-glib-0.0.pc
|
||||
/src/matrix-api.c
|
||||
/src/matrix-client.c
|
||||
/src/matrix-enums.c
|
||||
/src/matrix-http-api.c
|
||||
/src/matrix-http-client.c
|
||||
/src/matrix-compacts.c
|
||||
/src/matrix-event.c
|
||||
/src/matrix-presence-event.c
|
||||
/src/matrix-room-event.c
|
||||
/src/matrix-room-member-event.c
|
||||
/src/matrix-state-event.c
|
||||
/src/matrix-room-message-event.c
|
||||
|
||||
/src/object-generator
|
||||
|
@ -1,79 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
In the interest of fostering an open and welcoming environment, we as
|
||||
contributors and maintainers pledge to making participation in our
|
||||
project and our community a harassment-free experience for everyone,
|
||||
regardless of age, body size, disability, ethnicity, gender identity
|
||||
and expression, level of experience, nationality, personal appearance,
|
||||
race, religion, or sexual identity and orientation.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to creating a positive
|
||||
environment include:
|
||||
|
||||
* Using welcoming and inclusive language
|
||||
* Being respectful of differing viewpoints and experiences
|
||||
* Gracefully accepting constructive criticism
|
||||
* Focusing on what is best for the community
|
||||
* Showing empathy towards other community members
|
||||
|
||||
Examples of unacceptable behavior by participants include:
|
||||
|
||||
* The use of sexualized language or imagery and unwelcome sexual
|
||||
attention or advances
|
||||
* Trolling, insulting/derogatory comments, and personal or political
|
||||
attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or
|
||||
electronic address, without explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in
|
||||
a professional setting
|
||||
|
||||
## Our Responsibilities
|
||||
|
||||
Project maintainers are responsible for clarifying the standards of
|
||||
acceptable behavior and are expected to take appropriate and fair
|
||||
corrective action in response to any instances of unacceptable
|
||||
behavior.
|
||||
|
||||
Project maintainers have the right and responsibility to remove, edit,
|
||||
or reject comments, commits, code, wiki edits, issues, and other
|
||||
contributions that are not aligned to this Code of Conduct, or to ban
|
||||
temporarily or permanently any contributor for other behaviors that
|
||||
they deem inappropriate, threatening, offensive, or harmful.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies both within project spaces and in public
|
||||
spaces when an individual is representing the project or its
|
||||
community. Examples of representing a project or community include
|
||||
using an official project e-mail address, posting via an official
|
||||
social media account, or acting as an appointed representative at an
|
||||
online or offline event. Representation of a project may be further
|
||||
defined and clarified by project maintainers.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior
|
||||
may be reported by contacting the project team at
|
||||
gergely@polonkai.eu. All complaints will be reviewed and investigated
|
||||
and will result in a response that is deemed necessary and appropriate
|
||||
to the circumstances. The project team is obligated to maintain
|
||||
confidentiality with regard to the reporter of an incident. Further
|
||||
details of specific enforcement policies may be posted separately.
|
||||
|
||||
Project maintainers who do not follow or enforce the Code of Conduct
|
||||
in good faith may face temporary or permanent repercussions as
|
||||
determined by other members of the project's leadership.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the
|
||||
[Contributor Covenant][homepage], version 1.4, available at
|
||||
[http://contributor-covenant.org/version/1/4][version]
|
||||
|
||||
[homepage]: http://contributor-covenant.org
|
||||
[version]: http://contributor-covenant.org/version/1/4/
|
114
CONTRIBUTING.md
114
CONTRIBUTING.md
@ -1,114 +0,0 @@
|
||||
# Contributing code to the Matrix GLib SDK
|
||||
|
||||
Everyone is welcome to contribute code to this SDK, provided that they
|
||||
are willing to license their contributions under the same license as
|
||||
the project itself. We follow a simple 'inbound=outbound' model for
|
||||
contributions: the act of submitting an 'inbound' contribution means
|
||||
that the contributor agrees to license the code under the same terms
|
||||
as the project's overall 'outbound' license - which is the GNU Lesser
|
||||
General Public License (see COPYING).
|
||||
|
||||
## How to contribute
|
||||
|
||||
The preferred and easiest way to contribute changes to the Matrix GLib
|
||||
SDK is to fork the project on GitHub, and then create a pull request
|
||||
to ask us to pull your changes into our repo
|
||||
(https://help.github.com/articles/using-pull-requests/)
|
||||
|
||||
**The single biggest thing you need to know is: please base your changes on
|
||||
the develop branch - /not/ master.**
|
||||
|
||||
We use the master branch to track the most recent release, so that
|
||||
folks who blindly clone the repo and automatically check out master
|
||||
get something that works. Develop is the unstable branch where all the
|
||||
development actually happens: the workflow is that contributors should
|
||||
fork the develop branch to make a 'feature' branch for a particular
|
||||
contribution, and then make a pull request to merge this back into the
|
||||
matrix.org 'official' develop branch. We use GitHub's pull request
|
||||
workflow to review the contribution, and either ask you to make any
|
||||
refinements needed or merge it and make them ourselves. The changes
|
||||
will then land on master when we next do a release.
|
||||
|
||||
## Code style
|
||||
|
||||
The projects have a loosely-defined code-style, which is close to
|
||||
GNOME's with a few differences. Check the source files for a hint.
|
||||
|
||||
Please ensure your changes match the cosmetic style of the project,
|
||||
and **never** mix cosmetic and functional changes in the same commit,
|
||||
as it makes it horribly hard to review otherwise.
|
||||
|
||||
## Attribution
|
||||
|
||||
Everyone who contributes anything to this SDK is welcome to be listed in the
|
||||
AUTHORS file for the project in question. Please feel free to include a
|
||||
change to AUTHORS in your pull request to list yourself and a short
|
||||
description of the area(s) you've worked on.
|
||||
|
||||
## Sign off
|
||||
|
||||
In order to have a concrete record that your contribution is
|
||||
intentional and you agree to license it under the same terms as the
|
||||
project's license, we've adopted the same lightweight approach that
|
||||
the
|
||||
[Linux Kernel](https://www.kernel.org/doc/Documentation/SubmittingPatches),
|
||||
[Docker](https://github.com/docker/docker/blob/master/CONTRIBUTING.md),
|
||||
and many other projects use: the DCO
|
||||
([Developer Certificate of Origin](http://developercertificate.org/)). This
|
||||
is a simple declaration that you wrote the contribution or otherwise
|
||||
have the right to contribute it to the SDK:
|
||||
|
||||
Developer Certificate of Origin
|
||||
Version 1.1
|
||||
|
||||
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
|
||||
660 York Street, Suite 102,
|
||||
San Francisco, CA 94110 USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
|
||||
(a) The contribution was created in whole or in part by me and I
|
||||
have the right to submit it under the open source license
|
||||
indicated in the file; or
|
||||
|
||||
(b) The contribution is based upon previous work that, to the best
|
||||
of my knowledge, is covered under an appropriate open source
|
||||
license and I have the right under that license to submit that
|
||||
work with modifications, whether created in whole or in part
|
||||
by me, under the same open source license (unless I am
|
||||
permitted to submit under a different license), as indicated
|
||||
in the file; or
|
||||
|
||||
(c) The contribution was provided directly to me by some other
|
||||
person who certified (a), (b) or (c) and I have not modified
|
||||
it.
|
||||
|
||||
(d) I understand and agree that this project and the contribution
|
||||
are public and that a record of the contribution (including all
|
||||
personal information I submit with it, including my sign-off) is
|
||||
maintained indefinitely and may be redistributed consistent with
|
||||
this project or the open source license(s) involved.
|
||||
|
||||
If you agree to this for your contribution, then all that's needed is
|
||||
to include the line in your commit or pull request comment:
|
||||
|
||||
Signed-off-by: Your Name <your@email.example.org>
|
||||
|
||||
using your real name; unfortunately pseudonyms and anonymous
|
||||
contributions can't be accepted. Git makes this trivial - just use the
|
||||
`-s` flag when you do `git commit`, having first set `user.name` and
|
||||
`user.email` git configs (which you should have done anyway :)
|
||||
|
||||
## Conclusion
|
||||
|
||||
That's it! Similar to Matrix, this SDK is a very open and project as
|
||||
you might expect given our obsession with open communication. If we're
|
||||
going to successfully matrix together all the fragmented communication
|
||||
technologies out there we are reliant on contributions and
|
||||
collaboration from the community to do so. So please get involved -
|
||||
and we hope you have as much fun hacking on Matrix as we do!
|
66
Makefile.am
Normal file
66
Makefile.am
Normal file
@ -0,0 +1,66 @@
|
||||
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
|
||||
|
||||
# Set up subdirectories to traverse
|
||||
SUBDIRS = src
|
||||
|
||||
if ENABLE_DOCS
|
||||
SUBDIRS += docs
|
||||
endif
|
||||
|
||||
# Specify files to include in dist
|
||||
|
||||
# in share/doc/
|
||||
matrixglibdocdir = ${prefix}/doc/matrix-glib
|
||||
matrixglibdoc_DATA = \
|
||||
README \
|
||||
COPYING \
|
||||
AUTHORS \
|
||||
ChangeLog \
|
||||
INSTALL \
|
||||
NEWS
|
||||
|
||||
# with make dist
|
||||
|
||||
EXTRA_DIST = $(matrixglibdoc_DATA) \
|
||||
autogen.sh \
|
||||
config.rpath
|
||||
|
||||
# Lists of generated files you want to be able to clean
|
||||
|
||||
MAINTAINERCLEANFILES = \
|
||||
$(srcdir)/aclocal.m4 \
|
||||
$(srcdir)/compile \
|
||||
$(srcdir)/config.guess \
|
||||
$(srcdir)/config.h.in \
|
||||
$(srcdir)/config.rpath \
|
||||
$(srcdir)/config.sub \
|
||||
$(srcdir)/depcomp \
|
||||
$(srcdir)/install-sh \
|
||||
$(srcdir)/ltmain.sh \
|
||||
$(srcdir)/missing \
|
||||
$(srcdir)/mkinstalldirs \
|
||||
$(srcdir)/ChangeLog \
|
||||
`find "$(srcdir)" -type f -name Makefile.in -print` \
|
||||
$(NULL)
|
||||
|
||||
DISTCLEANFILES = \
|
||||
ChangeLog
|
||||
|
||||
# Automatically generate ChangeLog from git
|
||||
|
||||
ChangeLog:
|
||||
@echo Creating $@
|
||||
@touch ChangeLog
|
||||
@if test -d "$(srcdir)/.git"; then \
|
||||
(GIT_DIR=$(top_srcdir)/.git ./missing --run git log --stat) | fmt > $@.tmp \
|
||||
&& mv -f $@.tmp $@ \
|
||||
|| ($(RM) $@.tmp; \
|
||||
echo Failed to generate ChangeLog, your ChangeLog may be outdated >&2; \
|
||||
(test -f $@ || echo git-log is required to generate this file >> $@)); \
|
||||
else \
|
||||
test -f $@ || \
|
||||
(echo A git checkout and git-log is required to generate ChangeLog >&2 && \
|
||||
echo A git checkout and git-log is required to generate this file >> $@); \
|
||||
fi
|
||||
|
||||
.PHONY: ChangeLog
|
30
README.md
30
README.md
@ -22,34 +22,8 @@ object model to perform actions on.
|
||||
|
||||
## Client
|
||||
|
||||
For a working example, see [test-client.c](src/test-client.c).
|
||||
|
||||
// Create a client object
|
||||
MatrixClient *client = MATRIX_CLIENT(matrix_http_client_new("http://localhost:8008"));
|
||||
|
||||
// Set tokens for the session. Alternatively you may want to login with matrix_api_login() or matrix_client_login_with_password()
|
||||
matrix_api_set_token(MATRIX_API(client), "your_access_token");
|
||||
|
||||
// Connect a callback that gets called when a m.room.message event arrives
|
||||
matrix_client_connect_event(client, MATRIX_EVENT_TYPE_ROOM_MESSAGE, message_callback, NULL);
|
||||
|
||||
// Enter polling mode. This continuously calls the /sync API
|
||||
matrix_client_begin_polling(client);
|
||||
|
||||
// Now enter a main loop with g_main_loop_run() so polling for events can actually begin
|
||||
The `MatrixClient` interface is not fully planned yet.
|
||||
|
||||
## API
|
||||
|
||||
For a full blown example, see [test-api-client.c](src/test-api-client.c).
|
||||
|
||||
# Contribution
|
||||
|
||||
See the file [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
||||
|
||||
# Code of Conduct
|
||||
|
||||
See the file [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) for details.
|
||||
|
||||
# Contact
|
||||
|
||||
Should you need any help, join us in Matrix at #matrix-glib-sdk:polonkai.eu.
|
||||
For a full blown example, see [test-client.c](src/test-client.c).
|
||||
|
116
autogen.sh
Executable file
116
autogen.sh
Executable file
@ -0,0 +1,116 @@
|
||||
#! /bin/sh
|
||||
# Run this to generate all the initial makefiles, etc.
|
||||
|
||||
srcdir=`dirname "$0"`
|
||||
test -z "$srcdir" && srcdir=.
|
||||
|
||||
DIE=0
|
||||
PKG_NAME="matrix-glib"
|
||||
|
||||
(test -f "$srcdir/configure.ac" \
|
||||
&& test -f "$srcdir/src/matrix-client.vala") || {
|
||||
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
|
||||
echo " top-level $PKG_NAME directory"
|
||||
|
||||
exit 1
|
||||
}
|
||||
|
||||
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "**Error**: You must have \`autoconf' installed."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
|
||||
DIE=1
|
||||
}
|
||||
|
||||
(grep "^LT_INIT" $srcdir/configure.ac >/dev/null) && {
|
||||
(libtool --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "**Error**: You must have \`libtool' installed."
|
||||
echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
|
||||
|
||||
DIE=1
|
||||
}
|
||||
}
|
||||
|
||||
(automake --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "**Error**: You must have \`automake' installed."
|
||||
echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/"
|
||||
|
||||
DIE=1
|
||||
NO_AUTOMAKE=yes
|
||||
}
|
||||
|
||||
# if no automake, don't bother testing for aclocal
|
||||
test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "**Error**: Missing \`aclocal'. The version of \`automake'"
|
||||
echo "installed doesn't appear recent enough."
|
||||
echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/"
|
||||
|
||||
DIE=1
|
||||
}
|
||||
|
||||
if test "$DIE" -eq 1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$*"; then
|
||||
echo "**Warning**: I am going to run \`configure' with no arguments."
|
||||
echo "If you wish to pass any to it, please specify them on the"
|
||||
echo \`$0\'" command line."
|
||||
echo
|
||||
fi
|
||||
|
||||
case $CC in
|
||||
xlc )
|
||||
am_opt=--include-deps;;
|
||||
esac
|
||||
|
||||
coin="$srcdir/configure.ac"
|
||||
dr=`dirname $coin`
|
||||
|
||||
cd $dr
|
||||
|
||||
m4dir=`grep '^AC_CONFIG_MACRO_DIR' configure.ac \
|
||||
| sed -n -e 's/AC_CONFIG_MACRO_DIR(\([^()]*\))/\1/p' \
|
||||
| sed -e 's/^\[\(.*\)\]$/\1/' \
|
||||
| sed -e 1q`
|
||||
m4_dir=$m4dir
|
||||
|
||||
if test -n "$m4dir"]; then
|
||||
m4dir="-I $m4dir"
|
||||
fi
|
||||
|
||||
aclocalinclude="$ACLOCAL_FLAGS"
|
||||
|
||||
if grep "^LT_INIT" "$coin" > /dev/null; then
|
||||
if test -z "$NO_LIBTOOLIZE"; then
|
||||
echo "Running libtoolize ..."
|
||||
libtoolize --force --copy || exit $?
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "Running aclocal $aclocalinclude ..."
|
||||
aclocal $m4dir $ACLOCAL_FLAGS $aclocalinclude || exit $?
|
||||
|
||||
if grep "^A[CM]_CONFIG_HEADER" "$coin" > /dev/null; then
|
||||
echo "Running autoheader ..."
|
||||
autoheader || exit $?
|
||||
fi
|
||||
|
||||
echo "Running automake --gnu $am_opt ..."
|
||||
automake --add-missing --copy --gnu $am_opt -Wno-portability || exit $?
|
||||
|
||||
echo "Running autoconf ..."
|
||||
autoconf || exit $?
|
||||
|
||||
if test x$NOCONFIGURE = x; then
|
||||
echo Running "$srcdir/configure" "$@" ...
|
||||
"$srcdir/configure" "$@" \
|
||||
&& echo Now type \`make\' to compile. || exit 1
|
||||
else
|
||||
echo Skipping configure process.
|
||||
fi
|
217
configure.ac
Normal file
217
configure.ac
Normal file
@ -0,0 +1,217 @@
|
||||
# Process this file with autoconf to produce a configure script
|
||||
|
||||
# Sections
|
||||
# Version numbers
|
||||
# Setup
|
||||
# Dependencies
|
||||
# Output
|
||||
|
||||
### Version numbers
|
||||
|
||||
# Release Version
|
||||
m4_define([matrix_glib_major_version], [0])
|
||||
m4_define([matrix_glib_minor_version], [0])
|
||||
m4_define([matrix_glib_micro_version], [1])
|
||||
m4_define([matrix_glib_nano_version], [0])
|
||||
|
||||
# LT_VERSION
|
||||
# If library source has changed since last release, increment revision
|
||||
# If public symbols have been added, removed or changed since last
|
||||
# release, increment current and set revision to 0
|
||||
# If public symbols have been added since last release, increment age
|
||||
# If public symbols have been removed since last release, set age to 0
|
||||
m4_define([matrix_glib_lt_current], [0])
|
||||
m4_define([matrix_glib_lt_revision], [0])
|
||||
m4_define([matrix_glib_lt_age], [0])
|
||||
|
||||
# Combine numbers to various version variables (different uses)
|
||||
# Display the nano_version only if it's not '0'
|
||||
m4_define([matrix_glib_base_version],
|
||||
matrix_glib_major_version.matrix_glib_minor_version.matrix_glib_micro_version)
|
||||
m4_define([matrix_glib_full_version],
|
||||
[m4_if(matrix_glib_nano_version, [0],
|
||||
matrix_glib_base_version,
|
||||
matrix_glib_base_version.matrix_glib_nano_version)])
|
||||
|
||||
# You should set project_released to one in order to mark this as a
|
||||
# released version and to avoid date on version numbers
|
||||
m4_define(matrix_glib_released, [0])
|
||||
m4_define([matrix_glib_maybe_datestamp],
|
||||
m4_if(matrix_glib_released, [1],
|
||||
[],
|
||||
[m4_esyscmd([date +.%Y%m%d | tr -d '\n\r'])]))
|
||||
|
||||
m4_define([matrix_glib_version], matrix_glib_full_version[]matrix_glib_maybe_datestamp)
|
||||
m4_define([matrix_glib_major_minor_version], matrix_glib_major_version.matrix_glib_minor_version)
|
||||
m4_define([matrix_glib_module_version], matrix_glib_lt_current)
|
||||
m4_define([matrix_glib_api_version], [matrix_glib_major_version.0])
|
||||
|
||||
### Setup
|
||||
|
||||
# Initialise autoconf with project details, version
|
||||
AC_INIT([MatrixGlib], matrix_glib_version,
|
||||
[gergely@polonkai.eu], [matrix-glib])
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
AC_PREREQ([2.65])
|
||||
AC_COPYRIGHT([Copyright (C) 2015,2016 Gergely Polonkai])
|
||||
|
||||
# Configure various files and settings for autoconf/automake
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_SRCDIR([Makefile.am])
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
AC_CONFIG_SRCDIR([configure.ac])
|
||||
AM_INIT_AUTOMAKE([1.11 dist-xz no-define
|
||||
no-dist-gzip tar-ustar -Wno-portability])
|
||||
AM_MAINTAINER_MODE([enable])
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_CC_C_O
|
||||
AM_PROG_AR
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
# Initialise libtool (handles library creation) with versions from above
|
||||
LT_INIT(win32-dll)
|
||||
|
||||
PKG_PROG_PKG_CONFIG([0.21])
|
||||
|
||||
AC_SUBST([CFLAGS])
|
||||
AC_SUBST([CPPFLAGS])
|
||||
AC_SUBST([LDFLAGS])
|
||||
|
||||
AC_SUBST([LT_CURRENT], matrix_glib_lt_current)
|
||||
AC_SUBST([LT_REVISION], matrix_glib_lt_revision)
|
||||
AC_SUBST([LT_AGE], matrix_glib_lt_age)
|
||||
|
||||
AC_SUBST([MATRIX_GLIB_VERSION], matrix_glib_base_version)
|
||||
|
||||
### Dependencies
|
||||
|
||||
GLIB_REQUIRED=2.40.0
|
||||
VALA_REQUIRED=0.30.0
|
||||
LIBVALA_REQUIRED=0.30
|
||||
GEE_REQUIRED=0.10.5
|
||||
GIO_REQUIRED=2.22
|
||||
SOUP_REQUIRED=2.44.2
|
||||
JSON_REQUIRED=0.16.2
|
||||
VALADOC_REQUIRED=0.3.1
|
||||
|
||||
# Check GLib
|
||||
PKG_CHECK_MODULES([GLIB],
|
||||
[glib-2.0 >= $GLIB_REQUIRED
|
||||
gobject-2.0 >= $GLIB_REQUIRED])
|
||||
|
||||
# Check for vala
|
||||
VALAC_CHECK
|
||||
|
||||
# Check for libgee
|
||||
PKG_CHECK_MODULES([GEE], [gee-0.8 >= $GEE_REQUIRED])
|
||||
|
||||
# Check for GIO
|
||||
PKG_CHECK_MODULES([GIO], [gio-2.0 >= $GIO_REQUIRED])
|
||||
|
||||
# Check for libSoup
|
||||
PKG_CHECK_MODULES([SOUP], [libsoup-2.4 >= $SOUP_REQUIRED])
|
||||
|
||||
# Check for JSON-GLib
|
||||
PKG_CHECK_MODULES([JSON], [json-glib-1.0 >= $JSON_REQUIRED])
|
||||
|
||||
# Check for GObject Introspection
|
||||
GOBJECT_INTROSPECTION_CHECK([1.32.0])
|
||||
|
||||
# Documentation with Valadoc
|
||||
AC_ARG_ENABLE([docs],
|
||||
AS_HELP_STRING([--enable-docs],
|
||||
[Enable documentation generation]),
|
||||
[enable_docs=$enableval], [enable_docs=no])
|
||||
AM_CONDITIONAL([ENABLE_DOCS], [test x$enable_docs = xyes])
|
||||
|
||||
have_valadoc=no
|
||||
if test x$enable_docs = xyes; then
|
||||
# Make sure the library is new enough and the program exists
|
||||
AC_PATH_PROG([VALADOC], [valadoc], [no])
|
||||
if test "x$VALADOC" = "xno"; then
|
||||
AC_MSG_RESULT([valadoc documentation will not build because valadoc is not found])
|
||||
else
|
||||
VAPIDIR=`$PKG_CONFIG --variable=vapidir libvala-$LIBVALA_REQUIRED`
|
||||
have_valadoc="yes"
|
||||
AC_SUBST([VALADOC])
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL([HAVE_VALADOC], [test x$have_valadoc = xyes])
|
||||
|
||||
AC_ARG_ENABLE([gtk-doc],
|
||||
AS_HELP_STRING([--enable-gtk-doc],
|
||||
[Enable GTK-Doc documentation generation]),
|
||||
[enable_gtk_docs=$enableval], [enable_gtk_docs=no])
|
||||
|
||||
have_gtkdoc=no
|
||||
if test x$enable_gtk_docs = xyes; then
|
||||
if test x$have_valadoc = xyes; then
|
||||
PKG_CHECK_MODULES([GTKDOC], gtk-doc)
|
||||
have_gtkdoc=yes
|
||||
else
|
||||
AC_MSG_ERROR([valadoc is required to generate GTK-Doc documentation. Use --enable-valadoc])
|
||||
fi
|
||||
fi
|
||||
|
||||
gtkdocs=no
|
||||
|
||||
if test x$enable_docs = xyes; then
|
||||
if test x$enable_gtk_docs = xyes; then
|
||||
gtkdocs=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([ENABLE_GTK_DOCS], [test "x$gtkdocs" = "xyes"])
|
||||
|
||||
debug=no
|
||||
AC_ARG_ENABLE(debug,
|
||||
AS_HELP_STRING([--enable-debug],
|
||||
[compile with debugging support]),
|
||||
[debug=$enableval], [debug=no])
|
||||
AM_CONDITIONAL([DEBUG], [test $debug = yes])
|
||||
|
||||
if test x"$debug" = x"$enableval"; then
|
||||
AC_DEFINE([DEBUG], [1], [Define if debugging should be enabled])
|
||||
|
||||
if test x"$cflags_set" != x"set"; then
|
||||
case " $CFLAGS " in
|
||||
*[[\ \ ]]-g[[\ \ ]]*) ;;
|
||||
*) CFLAGS="$CFLAGS -g" ;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST([MATRIX_GLIB_MAJOR_VERSION], matrix_glib_major_version)
|
||||
AC_SUBST([MATRIX_GLIB_MINOR_VERSION], matrix_glib_minor_version)
|
||||
AC_SUBST([MATRIX_GLIB_MICRO_VERSION], matrix_glib_micro_version)
|
||||
|
||||
# This is used to identify a set of API compatible between versions
|
||||
# - If new versions are compatible with the actual one, just leave
|
||||
# this untouched
|
||||
# - If new version breaks API change it in order to allow parallel
|
||||
# installations with old versions. Change name of pc files to use
|
||||
# a new API, too
|
||||
AC_SUBST([MATRIX_GLIB_API_VERSION], matrix_glib_api_version)
|
||||
|
||||
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
Makefile
|
||||
src/Makefile
|
||||
src/matrix-version.h
|
||||
docs/Makefile
|
||||
docs/valadoc/Makefile
|
||||
docs/valadoc/gtk-doc/Makefile
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
# Print configuration summary
|
||||
echo ""
|
||||
echo " Configuration summary for Matrix-$MATRIX_GLIB_VERSION"
|
||||
echo " Installation prefix: $prefix"
|
||||
echo " Documentation: ${enable_docs}"
|
||||
echo " Gtk-Doc: `if test x${gtkdocs} = xyes; then echo yes; else echo no; fi`"
|
||||
echo " Debug: $debug"
|
||||
echo ""
|
5
docs/Makefile.am
Normal file
5
docs/Makefile.am
Normal file
@ -0,0 +1,5 @@
|
||||
SUBDIRS =
|
||||
|
||||
if HAVE_VALADOC
|
||||
SUBDIRS += valadoc
|
||||
endif
|
@ -1,3 +0,0 @@
|
||||
if get_option('gtk-doc')
|
||||
subdir('reference')
|
||||
endif
|
@ -1,91 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
|
||||
[
|
||||
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
|
||||
]>
|
||||
<book id="index">
|
||||
<bookinfo>
|
||||
<title>Matrix-GLib-SDK Reference Manual</title>
|
||||
<releaseinfo>
|
||||
for Matrix-GLib-SDK 0.0.1.
|
||||
The latest version of this documentation can be found on-line at
|
||||
<ulink role="online-location" url="https://gergely.polonkai.eu/matrxix-glib-sdk/">https://gergely.polonkai.eu/matrix-glib-sdk/</ulink>.
|
||||
</releaseinfo>
|
||||
</bookinfo>
|
||||
|
||||
<chapter id="matrix-glib-sdk-basic-types">
|
||||
<title>Basic types</title>
|
||||
<xi:include href="xml/matrix-enumtypes.xml"/>
|
||||
<xi:include href="xml/matrix-compacts.xml"/>
|
||||
<xi:include href="xml/matrix-profile.xml"/>
|
||||
<xi:include href="xml/matrix-room.xml"/>
|
||||
<xi:include href="xml/matrix-types.xml"/>
|
||||
<xi:include href="xml/matrix-version.xml"/>
|
||||
</chapter>
|
||||
|
||||
<chapter id="matrix-glib-sdk-events">
|
||||
<title>Event types</title>
|
||||
<xi:include href="xml/event-handling.xml"/>
|
||||
<xi:include href="xml/matrix-event-base.xml"/>
|
||||
<xi:include href="xml/matrix-event-call-base.xml"/>
|
||||
<xi:include href="xml/matrix-event-call-answer.xml"/>
|
||||
<xi:include href="xml/matrix-event-call-candidates.xml"/>
|
||||
<xi:include href="xml/matrix-event-call-hangup.xml"/>
|
||||
<xi:include href="xml/matrix-event-call-invite.xml"/>
|
||||
<xi:include href="xml/matrix-event-presence.xml"/>
|
||||
<xi:include href="xml/matrix-event-receipt.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-aliases.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-avatar.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-base.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-canonical-alias.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-create.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-guest-access.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-history-visibility.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-join-rules.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-member.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-message.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-message-feedback.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-name.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-power-levels.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-redaction.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-third-party-invite.xml"/>
|
||||
<xi:include href="xml/matrix-event-room-topic.xml"/>
|
||||
<xi:include href="xml/matrix-event-state-base.xml"/>
|
||||
<xi:include href="xml/matrix-event-tag.xml"/>
|
||||
<xi:include href="xml/matrix-event-typing.xml"/>
|
||||
</chapter>
|
||||
|
||||
<chapter id="matrix-glib-sdk-messages">
|
||||
<title>Message types</title>
|
||||
<xi:include href="xml/message-handling.xml"/>
|
||||
<xi:include href="xml/matrix-message-base.xml"/>
|
||||
<xi:include href="xml/matrix-message-text.xml"/>
|
||||
<xi:include href="xml/matrix-message-emote.xml"/>
|
||||
<xi:include href="xml/matrix-message-notice.xml"/>
|
||||
<xi:include href="xml/matrix-message-file.xml"/>
|
||||
<xi:include href="xml/matrix-message-audio.xml"/>
|
||||
<xi:include href="xml/matrix-message-image.xml"/>
|
||||
<xi:include href="xml/matrix-message-video.xml"/>
|
||||
<xi:include href="xml/matrix-message-location.xml"/>
|
||||
</chapter>
|
||||
|
||||
<chapter>
|
||||
<title>Communicating with homeservers</title>
|
||||
<xi:include href="xml/matrix-api.xml"/>
|
||||
<xi:include href="xml/matrix-client.xml"/>
|
||||
<xi:include href="xml/matrix-http-api.xml"/>
|
||||
<xi:include href="xml/matrix-http-client.xml"/>
|
||||
</chapter>
|
||||
|
||||
<index id="api-index-full">
|
||||
<title>API Index</title>
|
||||
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
|
||||
</index>
|
||||
|
||||
<index id="deprecated-api-index" role="deprecated">
|
||||
<title>Index of deprecated API</title>
|
||||
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
|
||||
</index>
|
||||
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
|
||||
</book>
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +0,0 @@
|
||||
gnome.gtkdoc('matrix-glib-sdk',
|
||||
main_xml : 'matrix-glib-sdk-docs.xml',
|
||||
src_dir : join_paths(meson.source_root(), 'src'),
|
||||
mkdb_args : ['--xml-mode', '--output-format=xml'],
|
||||
ignore_headers : 'utils.h',
|
||||
install : true)
|
105
docs/reference/matrix-glib/Makefile.am
Normal file
105
docs/reference/matrix-glib/Makefile.am
Normal file
@ -0,0 +1,105 @@
|
||||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
# We require automake 1.6 at least.
|
||||
AUTOMAKE_OPTIONS = 1.6
|
||||
|
||||
# This is a blank Makefile.am for using gtk-doc.
|
||||
# Copy this to your project's API docs directory and modify the variables to
|
||||
# suit your project. See the GTK+ Makefiles in gtk+/docs/reference for examples
|
||||
# of using the various options.
|
||||
|
||||
# The name of the module, e.g. 'glib'.
|
||||
DOC_MODULE=matrix-glib
|
||||
|
||||
# Uncomment for versioned docs and specify the version of the module, e.g. '2'.
|
||||
DOC_MODULE_VERSION=$(MATRIX_GLIB_API_VERSION)
|
||||
|
||||
|
||||
# The top-level XML file (SGML in the past). You can change this if you want to.
|
||||
DOC_MAIN_SGML_FILE=$(DOC_MODULE)-docs.xml
|
||||
|
||||
# Directories containing the source code.
|
||||
# gtk-doc will search all .c and .h files beneath these paths
|
||||
# for inline comments documenting functions and macros.
|
||||
# e.g. DOC_SOURCE_DIR=$(top_srcdir)/gtk $(top_srcdir)/gdk
|
||||
DOC_SOURCE_DIR=$(top_srcdir)/src
|
||||
|
||||
# Extra options to pass to gtkdoc-scangobj. Not normally needed.
|
||||
SCANGOBJ_OPTIONS=
|
||||
|
||||
# Extra options to supply to gtkdoc-scan.
|
||||
# e.g. SCAN_OPTIONS=--deprecated-guards="GTK_DISABLE_DEPRECATED"
|
||||
SCAN_OPTIONS=--rebuild-types --deprecated-guards="MATRIX_DISABLE_DEPRECATED"
|
||||
|
||||
# Extra options to supply to gtkdoc-mkdb.
|
||||
# e.g. MKDB_OPTIONS=--xml-mode --output-format=xml
|
||||
MKDB_OPTIONS=--xml-mode --output-format=xml
|
||||
|
||||
# Extra options to supply to gtkdoc-mktmpl
|
||||
# e.g. MKTMPL_OPTIONS=--only-section-tmpl
|
||||
MKTMPL_OPTIONS=
|
||||
|
||||
# Extra options to supply to gtkdoc-mkhtml
|
||||
MKHTML_OPTIONS=
|
||||
|
||||
# Extra options to supply to gtkdoc-fixref. Not normally needed.
|
||||
# e.g. FIXXREF_OPTIONS=--extra-dir=../gdk-pixbuf/html --extra-dir=../gdk/html
|
||||
FIXXREF_OPTIONS=
|
||||
|
||||
# Used for dependencies. The docs will be rebuilt if any of these change.
|
||||
# e.g. HFILE_GLOB=$(top_srcdir)/gtk/*.h
|
||||
# e.g. CFILE_GLOB=$(top_srcdir)/gtk/*.c
|
||||
HFILE_GLOB=$(top_srcdir)/src/*.h
|
||||
CFILE_GLOB=$(top_srcdir)/src/*.c
|
||||
|
||||
# Extra header to include when scanning, which are not under DOC_SOURCE_DIR
|
||||
# e.g. EXTRA_HFILES=$(top_srcdir}/contrib/extra.h
|
||||
EXTRA_HFILES=
|
||||
|
||||
# Header files or dirs to ignore when scanning. Use base file/dir names
|
||||
# e.g. IGNORE_HFILES=gtkdebug.h gtkintl.h private_code
|
||||
IGNORE_HFILES =
|
||||
|
||||
# Images to copy into HTML directory.
|
||||
# e.g. HTML_IMAGES=$(top_srcdir)/gtk/stock-icons/stock_about_24.png
|
||||
HTML_IMAGES=
|
||||
|
||||
# Extra SGML files that are included by $(DOC_MAIN_SGML_FILE).
|
||||
# e.g. content_files=running.sgml building.sgml changes-2.0.sgml
|
||||
content_files=
|
||||
|
||||
# SGML files where gtk-doc abbrevations (#GtkWidget) are expanded
|
||||
# These files must be listed here *and* in content_files
|
||||
# e.g. expand_content_files=running.sgml
|
||||
expand_content_files=
|
||||
|
||||
# CFLAGS and LDFLAGS for compiling gtkdoc-scangobj with your library.
|
||||
# Only needed if you are using gtkdoc-scangobj to dynamically query widget
|
||||
# signals and properties.
|
||||
# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
|
||||
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
|
||||
GTKDOC_CFLAGS=
|
||||
GTKDOC_LIBS = \
|
||||
$(top_builddir)/src/libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la \
|
||||
$(NULL)
|
||||
|
||||
# This includes the standard gtk-doc make rules, copied by gtkdocize.
|
||||
include $(top_srcdir)/gtk-doc.make
|
||||
|
||||
# Other files to distribute
|
||||
# e.g. EXTRA_DIST += version.xml.in
|
||||
EXTRA_DIST += version.xml.in
|
||||
|
||||
# Files not to distribute
|
||||
# for --rebuild-types in $(SCAN_OPTIONS), e.g. $(DOC_MODULE).types
|
||||
# for --rebuild-sections in $(SCAN_OPTIONS) e.g. $(DOC_MODULE)-sections.txt
|
||||
DISTCLEANFILES = $(DOC_MODULE).types
|
||||
|
||||
# Comment this out if you want 'make check' to test you doc status
|
||||
# and run some sanity checks
|
||||
if ENABLE_GTK_DOC
|
||||
TESTS_ENVIRONMENT = cd $(srcdir) && \
|
||||
DOC_MODULE=$(DOC_MODULE) DOC_MAIN_SGML_FILE=$(DOC_MAIN_SGML_FILE) \
|
||||
SRCDIR=$(abs_srcdir) BUILDDIR=$(abs_builddir)
|
||||
#TESTS = $(GTKDOC_CHECK)
|
||||
endif
|
49
docs/reference/matrix-glib/matrix-glib-docs.xml
Normal file
49
docs/reference/matrix-glib/matrix-glib-docs.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
|
||||
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
|
||||
[
|
||||
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
|
||||
<!ENTITY version SYSTEM "version.xml">
|
||||
<!ENTITY server "gergely.polonkai.eu">
|
||||
]>
|
||||
<book id="index">
|
||||
<bookinfo>
|
||||
<title>Matrix.org GLib SDK Reference Manual</title>
|
||||
<releaseinfo>
|
||||
for Matrix.org GLib SDK &version;.
|
||||
The latest version of this documentation can be found on-line at
|
||||
<ulink role="online-location" url="http://&server;/matrix-glib-sdk/index.html">http://&server;/matrix-glib-sdk/</ulink>.
|
||||
</releaseinfo>
|
||||
</bookinfo>
|
||||
|
||||
<chapter>
|
||||
<title>Matrix Client</title>
|
||||
<section>
|
||||
<title>Types</title>
|
||||
<xi:include href="xml/matrix-types.xml"/>
|
||||
<xi:include href="xml/matrix-event.xml"/>
|
||||
<xi:include href="xml/matrix-presence-event.xml"/>
|
||||
<xi:include href="xml/matrix-room-member-event.xml"/>
|
||||
</section>
|
||||
|
||||
<xi:include href="xml/matrix-client.xml"/>
|
||||
<xi:include href="xml/matrix-http-client.xml"/>
|
||||
<xi:include href="xml/matrix-api.xml"/>
|
||||
<xi:include href="xml/matrix-http-api.xml"/>
|
||||
<xi:include href="xml/matrix-version.xml"/>
|
||||
</chapter>
|
||||
<chapter id="object-tree">
|
||||
<title>Object Hierarchy</title>
|
||||
<xi:include href="xml/tree_index.sgml"/>
|
||||
</chapter>
|
||||
<index id="api-index-full">
|
||||
<title>API Index</title>
|
||||
<xi:include href="xml/api-index-full.xml"><xi:fallback /></xi:include>
|
||||
</index>
|
||||
<index id="deprecated-api-index" role="deprecated">
|
||||
<title>Index of deprecated API</title>
|
||||
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback /></xi:include>
|
||||
</index>
|
||||
|
||||
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
|
||||
</book>
|
462
docs/reference/matrix-glib/matrix-glib-sections.txt
Normal file
462
docs/reference/matrix-glib/matrix-glib-sections.txt
Normal file
@ -0,0 +1,462 @@
|
||||
<FILE>matrix-presence-event</FILE>
|
||||
<TITLE>MatrixPresenceEvent</TITLE>
|
||||
matrix_presence_event_set_display_name
|
||||
matrix_presence_event_get_display_name
|
||||
matrix_presence_event_set_avatar_url
|
||||
matrix_presence_event_get_avatar_url
|
||||
matrix_presence_event_set_last_active_ago
|
||||
matrix_presence_event_get_last_active_ago
|
||||
matrix_presence_event_set_presence
|
||||
matrix_presence_event_get_presence
|
||||
|
||||
<SUBSECTION Standard>
|
||||
MatrixPresenceEvent
|
||||
MatrixPresenceEventPrivate
|
||||
MATRIX_TYPE_PRESENCE_EVENT
|
||||
MATRIX_IS_PRESENCE_EVENT
|
||||
MATRIX_IS_PRESENCE_EVENT_CLASS
|
||||
MATRIX_PRESENCE_EVENT
|
||||
MATRIX_PRESENCE_EVENT_CLASS
|
||||
MATRIX_PRESENCE_EVENT_GET_CLASS
|
||||
matrix_presence_event_get_type
|
||||
matrix_presence_event_construct
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>matrix-room-member-event</FILE>
|
||||
<TITLE>MatrixRoomMemberEvent</TITLE>
|
||||
matrix_room_member_event_set_membership
|
||||
matrix_room_member_event_get_membership
|
||||
matrix_room_member_event_set_state_key
|
||||
matrix_room_member_event_get_state_key
|
||||
matrix_room_member_event_set_avatar_url
|
||||
matrix_room_member_event_get_avatar_url
|
||||
matrix_room_member_event_set_display_name
|
||||
matrix_room_member_event_get_display_name
|
||||
|
||||
<SUBSECTION Standard>
|
||||
MATRIX_IS_ROOM_MEMBER_EVENT
|
||||
MATRIX_IS_ROOM_MEMBER_EVENT_CLASS
|
||||
MATRIX_ROOM_MEMBER_EVENT
|
||||
MATRIX_ROOM_MEMBER_EVENT_CLASS
|
||||
MATRIX_ROOM_MEMBER_EVENT_GET_CLASS
|
||||
MATRIX_TYPE_ROOM_MEMBER_EVENT
|
||||
MatrixRoomMemberEvent
|
||||
MatrixRoomMemberEventPrivate
|
||||
MatrixRoomMemberEventClass
|
||||
matrix_room_member_event_get_type
|
||||
matrix_room_member_event_construct
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>matrix-event</FILE>
|
||||
<TITLE>MatrixEvent</TITLE>
|
||||
MatrixEventClass
|
||||
matrix_event_register_type
|
||||
matrix_event_unregister_type
|
||||
matrix_event_get_handler
|
||||
matrix_event_new
|
||||
matrix_event_get_event_type
|
||||
matrix_event_set_room_id
|
||||
matrix_event_get_room_id
|
||||
matrix_event_set_origin_server_ts
|
||||
matrix_event_get_origin_server_ts
|
||||
matrix_event_set_sender
|
||||
matrix_event_get_sender
|
||||
matrix_event_set_unsigned_data
|
||||
matrix_event_get_unsigned_data
|
||||
matrix_event_set_custom_field
|
||||
matrix_event_get_custom_field
|
||||
matrix_event_delete_custom_field
|
||||
matrix_event_to_json
|
||||
<SUBSECTION Standard>
|
||||
MatrixEvent
|
||||
MATRIX_EVENT
|
||||
MATRIX_EVENT_CLASS
|
||||
MATRIX_IS_EVENT
|
||||
MATRIX_IS_EVENT_CLASS
|
||||
MATRIX_EVENT_GET_CLASS
|
||||
MATRIX_TYPE_EVENT
|
||||
matrix_event_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>matrix-client</FILE>
|
||||
<TITLE>MatrixClient</TITLE>
|
||||
MatrixClient
|
||||
MatrixClientInterface
|
||||
matrix_client_login_finished
|
||||
matrix_client_incoming_event
|
||||
matrix_client_register_with_password
|
||||
matrix_client_login_with_password
|
||||
matrix_client_logout
|
||||
matrix_client_begin_polling
|
||||
matrix_client_stop_polling
|
||||
matrix_client_connect_event
|
||||
|
||||
<SUBSECTION Standard>
|
||||
MATRIX_CLIENT_GET_IFACE
|
||||
MATRIX_CLIENT
|
||||
MATRIX_IS_CLIENT
|
||||
MATRIX_TYPE_CLIENT
|
||||
matrix_client_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>matrix-http-client</FILE>
|
||||
<TITLE>MatrixHTTPClient</TITLE>
|
||||
MatrixHTTPClient
|
||||
matrix_http_client_new
|
||||
|
||||
<SUBSECTION Standard>
|
||||
MATRIX_HTTP_CLIENT
|
||||
MATRIX_HTTP_CLIENT_CLASS
|
||||
MATRIX_HTTP_CLIENT_GET_CLASS
|
||||
MATRIX_IS_HTTP_CLIENT
|
||||
MATRIX_IS_HTTP_CLIENT_CLASS
|
||||
MATRIX_TYPE_HTTP_CLIENT
|
||||
MatrixHTTPClientClass
|
||||
matrix_http_client_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>matrix-types</FILE>
|
||||
<TITLE>Fundamental types for the Matrix GLib SDK</TITLE>
|
||||
|
||||
<SUBSECTION>
|
||||
MatrixError
|
||||
MATRIX_ERROR
|
||||
|
||||
<SUBSECTION>
|
||||
MatrixEventFormat
|
||||
MatrixRoomPreset
|
||||
MatrixRoomVisibility
|
||||
MatrixResizeMethod
|
||||
MatrixPresence
|
||||
MatrixPusherKind
|
||||
MatrixPusherConditionKind
|
||||
MatrixEventDirection
|
||||
MatrixReceiptType
|
||||
MatrixAccountKind
|
||||
MatrixRoomMembership
|
||||
|
||||
<SUBSECTION>
|
||||
MatrixFilterRules
|
||||
matrix_filter_rules_new
|
||||
matrix_filter_rules_ref
|
||||
matrix_filter_rules_unref
|
||||
matrix_filter_rules_set_limit
|
||||
matrix_filter_rules_get_limit
|
||||
matrix_filter_rules_set_rooms
|
||||
matrix_filter_rules_add_room
|
||||
matrix_filter_rules_delete_room
|
||||
matrix_filter_rules_get_rooms
|
||||
matrix_filter_rules_set_excluded_rooms
|
||||
matrix_filter_rules_add_excluded_room
|
||||
matrix_filter_rules_delete_excluded_room
|
||||
matrix_filter_rules_get_excluded_rooms
|
||||
matrix_filter_rules_set_senders
|
||||
matrix_filter_rules_add_sender
|
||||
matrix_filter_rules_delete_sender
|
||||
matrix_filter_rules_get_senders
|
||||
matrix_filter_rules_set_excluded_senders
|
||||
matrix_filter_rules_add_excluded_sender
|
||||
matrix_filter_rules_delete_excluded_sender
|
||||
matrix_filter_rules_get_excluded_senders
|
||||
matrix_filter_rules_set_types
|
||||
matrix_filter_rules_add_type
|
||||
matrix_filter_rules_delete_type
|
||||
matrix_filter_rules_get_types
|
||||
matrix_filter_rules_set_excluded_types
|
||||
matrix_filter_rules_add_excluded_type
|
||||
matrix_filter_rules_delete_excluded_type
|
||||
matrix_filter_rules_get_excluded_types
|
||||
matrix_filter_rules_get_json_node
|
||||
matrix_filter_rules_get_json_data
|
||||
|
||||
<SUBSECTION>
|
||||
MatrixRoomFilter
|
||||
matrix_room_filter_new
|
||||
matrix_room_filter_ref
|
||||
matrix_room_filter_unref
|
||||
matrix_room_filter_set_include_leave
|
||||
matrix_room_filter_get_include_leave
|
||||
matrix_room_filter_set_ephemeral
|
||||
matrix_room_filter_get_ephemeral
|
||||
matrix_room_filter_set_state
|
||||
matrix_room_filter_get_state
|
||||
matrix_room_filter_set_timeline
|
||||
matrix_room_filter_get_timeline
|
||||
matrix_room_filter_get_json_node
|
||||
matrix_room_filter_get_json_data
|
||||
|
||||
<SUBSECTION>
|
||||
MatrixFilter
|
||||
matrix_filter_new
|
||||
matrix_filter_ref
|
||||
matrix_filter_unref
|
||||
matrix_filter_set_event_fields
|
||||
matrix_filter_add_event_field
|
||||
matrix_filter_delete_event_field
|
||||
matrix_filter_get_event_fields
|
||||
matrix_filter_set_event_format
|
||||
matrix_filter_get_event_format
|
||||
matrix_filter_set_presence_filter
|
||||
matrix_filter_get_presence_filter
|
||||
matrix_filter_set_room_filter
|
||||
matrix_filter_get_room_filter
|
||||
matrix_filter_get_json_node
|
||||
matrix_filter_get_json_data
|
||||
|
||||
<SUBSECTION>
|
||||
Matrix3PidCredential
|
||||
matrix_3pid_credential_new
|
||||
matrix_3pid_credential_ref
|
||||
matrix_3pid_credential_unref
|
||||
matrix_3pid_credential_set_id_server
|
||||
matrix_3pid_credential_get_id_server
|
||||
matrix_3pid_credential_set_session_id
|
||||
matrix_3pid_credential_get_session_id
|
||||
matrix_3pid_credential_set_client_secret
|
||||
matrix_3pid_credential_get_client_secret
|
||||
matrix_3pid_credential_get_json_node
|
||||
matrix_3pid_credential_get_json_data
|
||||
|
||||
<SUBSECTION>
|
||||
MatrixPusher
|
||||
matrix_pusher_new
|
||||
matrix_pusher_ref
|
||||
matrix_pusher_unref
|
||||
matrix_pusher_set_device_display_name
|
||||
matrix_pusher_get_device_display_name
|
||||
matrix_pusher_set_app_display_name
|
||||
matrix_pusher_get_app_display_name
|
||||
matrix_pusher_set_app_id
|
||||
matrix_pusher_get_app_id
|
||||
matrix_pusher_set_append
|
||||
matrix_pusher_get_append
|
||||
matrix_pusher_set_kind
|
||||
matrix_pusher_get_kind
|
||||
matrix_pusher_set_lang
|
||||
matrix_pusher_get_lang
|
||||
matrix_pusher_set_profile_tag
|
||||
matrix_pusher_get_profile_tag
|
||||
matrix_pusher_set_pushkey
|
||||
matrix_pusher_get_pushkey
|
||||
matrix_pusher_set_data
|
||||
matrix_pusher_take_data
|
||||
matrix_pusher_get_data
|
||||
matrix_pusher_get_json_node
|
||||
matrix_pusher_get_json_data
|
||||
|
||||
<SUBSECTION>
|
||||
MatrixStateEvent
|
||||
matrix_state_event_new
|
||||
matrix_state_event_ref
|
||||
matrix_state_event_unref
|
||||
matrix_state_event_set_event_type
|
||||
matrix_state_event_get_event_type
|
||||
matrix_state_event_set_state_key
|
||||
matrix_state_event_get_state_key
|
||||
matrix_state_event_set_content
|
||||
matrix_state_event_get_content
|
||||
matrix_state_event_get_json_node
|
||||
matrix_state_event_get_json_data
|
||||
|
||||
<SUBSECTION>
|
||||
MatrixUnsignedEventData
|
||||
matrix_unsigned_event_data_new
|
||||
matrix_unsigned_event_data_new_from_json
|
||||
matrix_unsigned_event_data_ref
|
||||
matrix_unsigned_event_data_unref
|
||||
matrix_unsigned_event_data_set_age
|
||||
matrix_unsigned_event_data_get_age
|
||||
matrix_unsigned_event_data_set_redact_reason
|
||||
matrix_unsigned_event_data_get_redact_reason
|
||||
matrix_unsigned_event_data_set_transaction_id
|
||||
matrix_unsigned_event_data_get_transaction_id
|
||||
matrix_unsigned_event_data_get_json_node
|
||||
|
||||
<SUBSECTION Standard>
|
||||
MATRIX_TYPE_EVENT_FORMAT
|
||||
matrix_event_format_get_type
|
||||
MATRIX_TYPE_ROOM_PRESET
|
||||
matrix_room_preset_get_type
|
||||
MATRIX_TYPE_ROOM_VISIBILITY
|
||||
matrix_room_visibility_get_type
|
||||
MATRIX_TYPE_RESIZE_METHOD
|
||||
matrix_resize_method_get_type
|
||||
MATRIX_TYPE_PRESENCE
|
||||
matrix_presence_get_type
|
||||
MATRIX_TYPE_PUSHER_KIND
|
||||
matrix_pusher_kind_get_type
|
||||
MATRIX_TYPE_PUSHER_CONDITION_KIND
|
||||
matrix_pusher_condition_kind_get_type
|
||||
MATRIX_TYPE_EVENT_DIRECTION
|
||||
matrix_event_direction_get_type
|
||||
MATRIX_TYPE_RECEIPT_TYPE
|
||||
matrix_receipt_type_get_type
|
||||
MATRIX_TYPE_ACCOUNT_KIND
|
||||
matrix_account_kind_get_type
|
||||
MATRIX_TYPE_ROOM_MEMBERSHIP
|
||||
matrix_room_membership_get_type
|
||||
MATRIX_TYPE_FILTER_RULES
|
||||
matrix_filter_rules_get_type
|
||||
MATRIX_TYPE_ROOM_FILTER
|
||||
matrix_room_filter_get_type
|
||||
MATRIX_TYPE_FILTER
|
||||
matrix_filter_get_type
|
||||
MATRIX_TYPE_3PID_CREDENTIAL
|
||||
matrix_3pid_credential_get_type
|
||||
MATRIX_TYPE_PUSHER
|
||||
matrix_pusher_get_type
|
||||
MATRIX_TYPE_STATE_EVENT
|
||||
matrix_state_event_get_type
|
||||
MATRIX_TYPE_UNSIGNED_EVENT_DATA
|
||||
matrix_unsigned_event_data_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>matrix-api</FILE>
|
||||
<TITLE>MatrixAPI</TITLE>
|
||||
MatrixAPIInterface
|
||||
MatrixAPICallback
|
||||
MATRIX_API_CALLBACK
|
||||
MATRIX_API_CALLBACK_PROTO
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_set_token
|
||||
matrix_api_get_token
|
||||
matrix_api_set_refresh_token
|
||||
matrix_api_get_refresh_token
|
||||
matrix_api_get_user_id
|
||||
matrix_api_get_homeserver
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_media_download
|
||||
matrix_api_media_thumbnail
|
||||
matrix_api_media_upload
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_get_presence_list
|
||||
matrix_api_update_presence_list
|
||||
matrix_api_get_user_presence
|
||||
matrix_api_set_user_presence
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_update_pusher
|
||||
matrix_api_get_pushers
|
||||
matrix_api_delete_pusher
|
||||
matrix_api_get_pusher
|
||||
matrix_api_add_pusher
|
||||
matrix_api_toggle_pusher
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_create_room
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_delete_room_alias
|
||||
matrix_api_get_room_id
|
||||
matrix_api_create_room_alias
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_list_public_rooms
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_ban_user
|
||||
matrix_api_forget_room
|
||||
matrix_api_invite_user_3rdparty
|
||||
matrix_api_invite_user
|
||||
matrix_api_join_room
|
||||
matrix_api_leave_room
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_event_stream
|
||||
matrix_api_get_event
|
||||
matrix_api_initial_sync
|
||||
matrix_api_get_event_context
|
||||
matrix_api_initial_sync_room
|
||||
matrix_api_list_room_members
|
||||
matrix_api_list_room_messages
|
||||
matrix_api_send_event_receipt
|
||||
matrix_api_redact_event
|
||||
matrix_api_send_message_event
|
||||
matrix_api_get_room_state
|
||||
matrix_api_send_room_event
|
||||
matrix_api_notify_room_typing
|
||||
matrix_api_sync
|
||||
matrix_api_create_filter
|
||||
matrix_api_download_filter
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_whois
|
||||
matrix_api_versions
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_login
|
||||
matrix_api_token_refresh
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_get_3pids
|
||||
matrix_api_add_3pid
|
||||
matrix_api_change_password
|
||||
matrix_api_get_profile
|
||||
matrix_api_get_avatar_url
|
||||
matrix_api_set_avatar_url
|
||||
matrix_api_get_display_name
|
||||
matrix_api_set_display_name
|
||||
matrix_api_register_account
|
||||
matrix_api_set_account_data
|
||||
matrix_api_get_room_tags
|
||||
matrix_api_delete_room_tag
|
||||
matrix_api_add_room_tag
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_get_turn_server
|
||||
|
||||
<SUBSECTION>
|
||||
matrix_api_abort_pending
|
||||
|
||||
<SUBSECTION Standard>
|
||||
MatrixAPI
|
||||
MATRIX_TYPE_ERROR
|
||||
matrix_error_get_type
|
||||
MATRIX_TYPE_API
|
||||
MATRIX_API
|
||||
MATRIX_IS_API
|
||||
MATRIX_API_GET_IFACE
|
||||
MatrixApiPrivate
|
||||
matrix_api_get_type
|
||||
|
||||
<SUBSECTION Private>
|
||||
matrix_error_quark
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>matrix-http-api</FILE>
|
||||
matrix_http_api_new
|
||||
matrix_http_api_set_validate_certificate
|
||||
matrix_http_api_get_validate_certificate
|
||||
matrix_http_api_set_base_url
|
||||
matrix_http_api_get_base_url
|
||||
|
||||
<SUBSECTION Standard>
|
||||
MatrixHTTPAPI
|
||||
MatrixHTTPAPIClass
|
||||
MATRIX_TYPE_HTTP_API
|
||||
MATRIX_HTTP_API
|
||||
MATRIX_HTTP_API_CLASS
|
||||
MATRIX_IS_HTTP_API
|
||||
MATRIX_IS_HTTP_API_CLASS
|
||||
MATRIX_HTTP_API_GET_CLASS
|
||||
matrix_http_api_get_type
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>matrix-version</FILE>
|
||||
MATRIX_GLIB_MAJOR_VERSION
|
||||
MATRIX_GLIB_MINOR_VERSION
|
||||
MATRIX_GLIB_MICRO_VERSION
|
||||
MATRIX_GLIB_CHECK_VERSION
|
||||
matrix_glib_check_version
|
||||
</SECTION>
|
1
docs/reference/matrix-glib/version.xml.in
Normal file
1
docs/reference/matrix-glib/version.xml.in
Normal file
@ -0,0 +1 @@
|
||||
@MATRIX_GLIB_API_VERSION@
|
@ -1 +0,0 @@
|
||||
subdir('matrix-glib-sdk')
|
5
docs/valadoc/Makefile.am
Normal file
5
docs/valadoc/Makefile.am
Normal file
@ -0,0 +1,5 @@
|
||||
SUBDIRS =
|
||||
|
||||
if ENABLE_GTK_DOCS
|
||||
SUBDIRS += gtk-doc
|
||||
endif
|
28
docs/valadoc/gtk-doc/Makefile.am
Normal file
28
docs/valadoc/gtk-doc/Makefile.am
Normal file
@ -0,0 +1,28 @@
|
||||
include $(top_srcdir)/vala-globals.mk
|
||||
CLEANFILES =
|
||||
|
||||
sources = $(top_srcdir)/src/*.vala
|
||||
|
||||
gtkdocdir = $(datadir)/gtk-doc/html/matrix-glib
|
||||
gtkdoc_DATA = \
|
||||
gtk-doc/matrix-glib/*.txt \
|
||||
gtk-doc/matrix-glib/*.xml \
|
||||
gtk-doc/matrix-glib/xml/*.xml \
|
||||
gtk-doc/matrix-glib/xml/*.top \
|
||||
gtk-doc/matrix-glib/xml/*.bottom \
|
||||
gtk-doc/matrix-glib/*.types \
|
||||
gtk-doc/matrix-glib/sgml.stamp \
|
||||
$(NULL)
|
||||
|
||||
$(gtkdoc_DATA): matrix-glib-gtk-doc
|
||||
|
||||
matrix-glib-gtk-doc:
|
||||
$(VALADOC) -o gtk-doc/matrix-glib --doclet=gtkdoc \
|
||||
-X $(top_builddir)/src/matrix-glib.h \
|
||||
$(VALADOC_FLAGS) $(sources)
|
||||
|
||||
all: matrix-glib-gtk-doc
|
||||
|
||||
clean-local:
|
||||
rm -rf gtk-doc
|
||||
rm -rf matrix-glib
|
76
m4/valac.m4
Normal file
76
m4/valac.m4
Normal file
@ -0,0 +1,76 @@
|
||||
dnl vapigen.m4
|
||||
dnl
|
||||
dnl Copyright 2014 Daniel Espinosa
|
||||
dnl
|
||||
dnl This library is free software; you can redistribute it and/or
|
||||
dnl modify it under the terms of the GNU Lesser General Public
|
||||
dnl License as published by the Free Software Foundation; either
|
||||
dnl version 2.1 of the License, or (at your option) any later version.
|
||||
dnl
|
||||
dnl This library is distributed in the hope that it will be useful,
|
||||
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
dnl Lesser General Public License for more details.
|
||||
dnl
|
||||
dnl You should have received a copy of the GNU Lesser General Public
|
||||
dnl License along with this library; if not, write to the Free Software
|
||||
dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
# VALAC_CHECK([VERSION], [API_VERSION])
|
||||
# --------------------------------------
|
||||
# Check valac existence and version.
|
||||
m4_define([_VALAC_CHECK_INTERNAL],
|
||||
[
|
||||
AC_REQUIRE([PKG_PROG_PKG_CONFIG])
|
||||
AS_IF([ test "x$2" = "x" ], [
|
||||
AM_PROG_VALAC($1)
|
||||
AS_IF([ test "x$VALAC" = "xno"], [
|
||||
check_prog=no
|
||||
AC_MSG_ERROR([valac is not installed])
|
||||
], [
|
||||
check_prog=yes
|
||||
VALAC_VERSION=`$VALAC --api-version`
|
||||
VAPIDIR=$datadir/vala-$VALAC_VERSION/vapi
|
||||
VAPIDIR_UNVERSIONED=$datadir/vala-$VALAC_VERSION/vapi
|
||||
])
|
||||
], [
|
||||
AS_IF([ test "x$1" = "x"], [
|
||||
vala_pkg="libvala-$2"
|
||||
], [
|
||||
vala_pkg="libvala-$2 >= $1"
|
||||
])
|
||||
AC_MSG_CHECKING([for $vala_pkg])
|
||||
PKG_CHECK_EXISTS([ $vala_pkg ], [
|
||||
vala_pkg_found=yes
|
||||
VAPIGEN=`$PKG_CONFIG --variable=vapigen libvala-$2`
|
||||
VAPIGEN_MAKEFILE=`$PKG_CONFIG --variable=datadir libvala-$2`/vala/Makefile.vapigen
|
||||
VAPIDIR=`$PKG_CONFIG --variable=vapidir libvala-$2`
|
||||
GEN_INTROSPECT=`$PKG_CONFIG --variable=gen_introspect libvala-$2`
|
||||
vala_datadir=`$PKG_CONFIG --variable=datadir libvala-$2`
|
||||
VAPIDIR_UNVERSIONED=$vala_datadir/vala/vapi
|
||||
VALA_GEN_INTROSPECT=`$PKG_CONFIG --variable=vala_gen_introspect libvala-$2`
|
||||
], [
|
||||
vala_pkg_found=no
|
||||
AC_MSG_ERROR([no package libvala-$2 is installed])
|
||||
])
|
||||
AC_MSG_RESULT([$vala_pkg_found])
|
||||
])
|
||||
AC_SUBST([VAPIGEN])
|
||||
AC_SUBST([VAPIGEN_VAPIDIR])
|
||||
AC_SUBST([VAPIDIR])
|
||||
AC_SUBST([VAPIDIR_UNVERSIONED])
|
||||
AC_SUBST([VAPIGEN_MAKEFILE])
|
||||
AC_SUBST([GEN_INTROSPECT])
|
||||
AC_SUBST([VALA_GEN_INTROSPECT])
|
||||
AC_SUBST([VALAC_VERSION])
|
||||
])
|
||||
|
||||
dnl Check VAPIGEN
|
||||
# VALAC_CHECK([VERSION], [API_VERSION], [DEFAULT])
|
||||
# --------------------------------------
|
||||
# Check vapigen existence and version.
|
||||
AC_DEFUN([VALAC_CHECK],
|
||||
[
|
||||
_VALAC_CHECK_INTERNAL($1,$2,$3)
|
||||
]
|
||||
)
|
72
meson.build
72
meson.build
@ -1,72 +0,0 @@
|
||||
project('matrix-glib', 'c', version : '0.0.1')
|
||||
|
||||
gnome = import('gnome')
|
||||
pkg = import('pkgconfig')
|
||||
|
||||
sdk_version = meson.project_version()
|
||||
ver_arr = sdk_version.split('.')
|
||||
|
||||
matrix_glib_major_version = ver_arr[0]
|
||||
matrix_glib_minor_version = ver_arr[1]
|
||||
matrix_glib_micro_version = ver_arr[2]
|
||||
matrix_glib_nano_version = '0'
|
||||
|
||||
lt_current = ver_arr[0]
|
||||
matrix_glib_lt_revision = '0'
|
||||
matrix_glib_lt_age = '0'
|
||||
|
||||
matrix_glib_base_version = meson.project_version()
|
||||
matrix_glib_full_version = meson.project_version()
|
||||
|
||||
if matrix_glib_nano_version != '0'
|
||||
matrix_glib_full_version += '.' + matrix_glib_nano_version
|
||||
endif
|
||||
|
||||
matrix_glib_released = '0'
|
||||
|
||||
if matrix_glib_released == '1'
|
||||
matrix_glib_maybe_datestamp = ''
|
||||
else
|
||||
datestamp = run_command('date', '+.%Y%m%d')
|
||||
matrix_glib_maybe_datestamp = datestamp.stdout().strip()
|
||||
endif
|
||||
|
||||
matrix_glib_version = matrix_glib_full_version + matrix_glib_maybe_datestamp
|
||||
matrix_glib_major_minor_version = matrix_glib_major_version + '.' + matrix_glib_minor_version
|
||||
matrix_glib_module_version = lt_current
|
||||
matrix_glib_api_version = matrix_glib_major_version + '.0'
|
||||
|
||||
|
||||
glib_required = '>= 2.40.0'
|
||||
vala_required = '>= 0.30.0'
|
||||
libvala_required = '>= 0.30'
|
||||
gio_required = '>= 2.22'
|
||||
soup_required = '>= 2.44.2'
|
||||
json_required = '>= 0.16.2'
|
||||
|
||||
glib = dependency('glib-2.0', version : glib_required)
|
||||
gobject = dependency('gobject-2.0', version : glib_required)
|
||||
gio = dependency('gio-2.0', version : gio_required)
|
||||
soup = dependency('libsoup-2.4', version : soup_required)
|
||||
json = dependency('json-glib-1.0', version : json_required)
|
||||
|
||||
conf = configuration_data()
|
||||
|
||||
if get_option('debug')
|
||||
conf.set('DEBUG', 1)
|
||||
add_global_arguments('-g', language : 'c')
|
||||
|
||||
if get_option('maintainer-mode')
|
||||
add_global_arguments('-O0', language : 'c')
|
||||
endif
|
||||
else
|
||||
conf.set('DEBUG', 0)
|
||||
endif
|
||||
|
||||
configure_file(output : 'config.h',
|
||||
configuration : conf)
|
||||
|
||||
config_inc = include_directories('.')
|
||||
|
||||
subdir('src')
|
||||
subdir('docs')
|
@ -1,24 +0,0 @@
|
||||
option('debug',
|
||||
type : 'boolean',
|
||||
value : false,
|
||||
description : 'compile with debugging support')
|
||||
|
||||
option('maintainer-mode',
|
||||
type : 'boolean',
|
||||
value : false,
|
||||
description : 'enable maintainer mode')
|
||||
|
||||
option('gtk-doc',
|
||||
type : 'boolean',
|
||||
value : false,
|
||||
description : 'generate API reference')
|
||||
|
||||
option('introspection',
|
||||
type : 'boolean',
|
||||
value : true,
|
||||
description : 'generate GObject Introspection data')
|
||||
|
||||
option('test-clients',
|
||||
type : 'boolean',
|
||||
value : false,
|
||||
description : 'compile the test clients')
|
44
schemas/m.call.answer
Normal file
44
schemas/m.call.answer
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"type": "object",
|
||||
"description": "This event is sent by the callee when they wish to answer the call.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"call_id": {
|
||||
"type": "string",
|
||||
"description": "The ID of the call this event relates to."
|
||||
},
|
||||
"answer": {
|
||||
"type": "object",
|
||||
"title": "Answer",
|
||||
"description": "The session description object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["answer"],
|
||||
"description": "The type of session description."
|
||||
},
|
||||
"sdp": {
|
||||
"type": "string",
|
||||
"description": "The SDP text of the session description."
|
||||
}
|
||||
},
|
||||
"required": ["type", "sdp"]
|
||||
},
|
||||
"version": {
|
||||
"type": "number",
|
||||
"description": ""
|
||||
}
|
||||
},
|
||||
"required": ["call_id", "answer", "version"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.call.answer"]
|
||||
}
|
||||
}
|
||||
}
|
50
schemas/m.call.candidates
Normal file
50
schemas/m.call.candidates
Normal file
@ -0,0 +1,50 @@
|
||||
{
|
||||
"type": "object",
|
||||
"description": "This event is sent by callers after sending an invite and by the callee after answering. Its purpose is to give the other party additional ICE candidates to try using to communicate.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"call_id": {
|
||||
"type": "string",
|
||||
"description": "The ID of the call this event relates to."
|
||||
},
|
||||
"candidates": {
|
||||
"type": "array",
|
||||
"description": "Array of objects describing the candidates.",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"title": "Candidate",
|
||||
"properties": {
|
||||
"sdpMid": {
|
||||
"type": "string",
|
||||
"description": "The SDP media type this candidate is intended for."
|
||||
},
|
||||
"sdpMLineIndex": {
|
||||
"type": "number",
|
||||
"description": "The index of the SDP 'm' line this candidate is intended for."
|
||||
},
|
||||
"candidate": {
|
||||
"type": "string",
|
||||
"description": "The SDP 'a' line of the candidate."
|
||||
}
|
||||
},
|
||||
"required": ["candidate", "sdpMLineIndex", "sdpMid"]
|
||||
}
|
||||
},
|
||||
"version": {
|
||||
"type": "integer",
|
||||
"description": "The version of the VoIP specification this messages adheres to. This specification is version 0."
|
||||
}
|
||||
},
|
||||
"required": ["call_id", "candidates", "version"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.call.candidates"]
|
||||
}
|
||||
}
|
||||
}
|
27
schemas/m.call.hangup
Normal file
27
schemas/m.call.hangup
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"type": "object",
|
||||
"description": "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.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"call_id": {
|
||||
"type": "string",
|
||||
"description": "The ID of the call this event relates to."
|
||||
},
|
||||
"version": {
|
||||
"type": "integer",
|
||||
"description": "The version of the VoIP specification this message adheres to. This specification is version 0."
|
||||
}
|
||||
},
|
||||
"required": ["call_id", "version"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.call.hangup"]
|
||||
}
|
||||
}
|
||||
}
|
48
schemas/m.call.invite
Normal file
48
schemas/m.call.invite
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"type": "object",
|
||||
"description": "This event is sent by the caller when they wish to establish a call.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"call_id": {
|
||||
"type": "string",
|
||||
"description": "A unique identifer for the call."
|
||||
},
|
||||
"offer": {
|
||||
"type": "object",
|
||||
"title": "Offer",
|
||||
"description": "The session description object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["offer"],
|
||||
"description": "The type of session description."
|
||||
},
|
||||
"sdp": {
|
||||
"type": "string",
|
||||
"description": "The SDP text of the session description."
|
||||
}
|
||||
},
|
||||
"required": ["type", "sdp"]
|
||||
},
|
||||
"version": {
|
||||
"type": "integer",
|
||||
"description": "The version of the VoIP specification this message adheres to. This specification is version 0."
|
||||
},
|
||||
"lifetime": {
|
||||
"type": "integer",
|
||||
"description": "The time in milliseconds that the invite is valid for. Once the invite age exceeds this value, clients should discard it. They should also no longer show the call as awaiting an answer in the UI."
|
||||
}
|
||||
},
|
||||
"required": ["call_id", "offer", "version", "lifetime"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.call.invite"]
|
||||
}
|
||||
}
|
||||
}
|
42
schemas/m.presence
Normal file
42
schemas/m.presence
Normal file
@ -0,0 +1,42 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Presence Event",
|
||||
"description": "Informs the client of a user's presence state change.",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"avatar_url": {
|
||||
"type": "string",
|
||||
"description": "The current avatar URL for this user, if any."
|
||||
},
|
||||
"displayname": {
|
||||
"type": "string",
|
||||
"description": "The current display name for this user, if any."
|
||||
},
|
||||
"last_active_ago": {
|
||||
"type": "number",
|
||||
"description": "The last time since this used performed some action, in milliseconds."
|
||||
},
|
||||
"presence": {
|
||||
"type": "string",
|
||||
"description": "The presence state for this user.",
|
||||
"enum": ["online", "offline", "unavailable", "free_for_chat", "hidden"]
|
||||
},
|
||||
"user_id": {
|
||||
"type": "string",
|
||||
"description": "The user's ID."
|
||||
}
|
||||
},
|
||||
"required": ["presence", "user_id"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.presence"]
|
||||
},
|
||||
"event_id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["event_id", "type", "content"]
|
||||
}
|
48
schemas/m.receipt
Normal file
48
schemas/m.receipt
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Receipt Event",
|
||||
"description": "Informs the client of new receipts.",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"patternProperties": {
|
||||
"^\\$": {
|
||||
"type": "object",
|
||||
"x-pattern": "$EVENT_ID",
|
||||
"title": "Receipts",
|
||||
"description": "The mapping of event ID to a collection of receipts for this event ID. The event ID is the ID of the event being acknowledged and *not* an ID for the receipt itself.",
|
||||
"properties": {
|
||||
"m.read": {
|
||||
"type": "object",
|
||||
"title": "Users",
|
||||
"description": "A collection of users who have sent ``m.read`` receipts for this event.",
|
||||
"patternProperties": {
|
||||
"^@": {
|
||||
"type": "object",
|
||||
"title": "Receipt",
|
||||
"description": "The mapping of user ID to receipt. The user ID is the entity who sent this receipt.",
|
||||
"x-pattern": "$USER_ID",
|
||||
"properties": {
|
||||
"ts": {
|
||||
"type": "number",
|
||||
"description": "The timestamp the receipt was sent at."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.receipt"]
|
||||
},
|
||||
"room_id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["room_id", "type", "content"]
|
||||
}
|
31
schemas/m.room.aliases
Normal file
31
schemas/m.room.aliases
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Informs the room about what room aliases it has been given.",
|
||||
"description": "This event is sent by a homeserver directly to inform of changes to the list of aliases it knows about for that room. The ``state_key`` for this event is set to the homeserver which owns the room alias. The entire set of known aliases for the room is the union of all the ``m.room.aliases`` events, one for each homeserver. Clients **should** check the validity of any room alias given in this list before presenting it to the user as trusted fact. The lists given by this event should be considered simply as advice on which aliases might exist, for which the client can perform the lookup to confirm whether it receives the correct room ID.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"aliases": {
|
||||
"type": "array",
|
||||
"description": "A list of room aliases.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["aliases"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "The homeserver domain which owns these room aliases."
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.aliases"]
|
||||
}
|
||||
}
|
||||
}
|
64
schemas/m.room.avatar
Normal file
64
schemas/m.room.avatar
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
"title": "RoomAvatar",
|
||||
"description": "A picture that is associated with the room. This can be displayed alongside the room information.",
|
||||
"type": "object",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"url": {
|
||||
"type": "string",
|
||||
"description": "The URL to the image."
|
||||
},
|
||||
"thumbnail_url": {
|
||||
"type": "string",
|
||||
"description": "The URL to the thumbnail of the image."
|
||||
},
|
||||
"thumbnail_info": {
|
||||
"type": "object",
|
||||
"title": "ImageInfo",
|
||||
"description": "Metadata about the image referred to in ``thumbnail_url``.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/msgtype_infos/image_info.yaml"
|
||||
}]
|
||||
},
|
||||
"info": {
|
||||
"type": "object",
|
||||
"title": "ImageInfo",
|
||||
"description": "Metadata about the image referred to in ``url``.",
|
||||
"properties": {
|
||||
"size": {
|
||||
"type": "integer",
|
||||
"description": "Size of the image in bytes."
|
||||
},
|
||||
"w": {
|
||||
"type": "integer",
|
||||
"description": "The width of the image in pixels."
|
||||
},
|
||||
"h": {
|
||||
"type": "integer",
|
||||
"description": "The height of the image in pixels."
|
||||
},
|
||||
"mimetype": {
|
||||
"type": "string",
|
||||
"description": "The mimetype of the image, e.g. ``image/jpeg``."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["url"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "A zero-length string.",
|
||||
"pattern": "^$"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.avatar"]
|
||||
}
|
||||
}
|
||||
}
|
28
schemas/m.room.canonical_alias
Normal file
28
schemas/m.room.canonical_alias
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Informs the room as to which alias is the canonical one.",
|
||||
"description": "This event is used to inform the room about which alias should be considered the canonical one. This could be for display purposes or as suggestion to users which alias to use to advertise the room.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"alias": {
|
||||
"type": "string",
|
||||
"description": "The canonical alias."
|
||||
}
|
||||
}
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "A zero-length string.",
|
||||
"pattern": "^$"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.canonical_alias"]
|
||||
}
|
||||
}
|
||||
}
|
33
schemas/m.room.create
Normal file
33
schemas/m.room.create
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "The first event in the room.",
|
||||
"description": "This is the first event in a room and cannot be changed. It acts as the root of all other events.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"creator": {
|
||||
"type": "string",
|
||||
"description": "The ``user_id`` of the room creator. This is set by the homeserver."
|
||||
},
|
||||
"m.federate": {
|
||||
"type": "boolean",
|
||||
"description": "Whether users on other servers can join this room. Defaults to ``true`` if key does not exist."
|
||||
}
|
||||
},
|
||||
"required": ["creator"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "A zero-length string.",
|
||||
"pattern": "^$"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.create"]
|
||||
}
|
||||
}
|
||||
}
|
30
schemas/m.room.guest_access
Normal file
30
schemas/m.room.guest_access
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Controls whether guest users are allowed to join rooms.",
|
||||
"description": "This event controls whether guest users are allowed to join rooms. If this event is absent, servers should act as if it is present and has the guest_access value \"forbidden\".",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"guest_access": {
|
||||
"type": "string",
|
||||
"description": "Whether guests can join the room.",
|
||||
"enum": ["can_join", "forbidden"]
|
||||
}
|
||||
},
|
||||
"required": ["guest_access"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "A zero-length string.",
|
||||
"pattern": "^$"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.guest_access"]
|
||||
}
|
||||
}
|
||||
}
|
30
schemas/m.room.history_visibility
Normal file
30
schemas/m.room.history_visibility
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Controls visibility of history.",
|
||||
"description": "This event controls whether a user can see the events that happened in a room from before they joined.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"history_visibility": {
|
||||
"type": "string",
|
||||
"description": "Who can see the room history.",
|
||||
"enum": ["invited","joined","shared","world_readable"]
|
||||
}
|
||||
},
|
||||
"required": ["history_visibility"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "A zero-length string.",
|
||||
"pattern": "^$"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.history_visibility"]
|
||||
}
|
||||
}
|
||||
}
|
30
schemas/m.room.join_rules
Normal file
30
schemas/m.room.join_rules
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Describes how users are allowed to join the room.",
|
||||
"description": "A room may be ``public`` meaning anyone can join the room without any prior action. Alternatively, it can be ``invite`` meaning that a user who wishes to join the room must first receive an invite to the room from someone already inside of the room. Currently, ``knock`` and ``private`` are reserved keywords which are not implemented.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"join_rule": {
|
||||
"type": "string",
|
||||
"description": "The type of rules used for users wishing to join this room.",
|
||||
"enum": ["public","knock","invite","private"]
|
||||
}
|
||||
},
|
||||
"required": ["join_rule"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "A zero-length string.",
|
||||
"pattern": "^$"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.join_rules"]
|
||||
}
|
||||
}
|
||||
}
|
96
schemas/m.room.member
Normal file
96
schemas/m.room.member
Normal file
@ -0,0 +1,96 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "The current membership state of a user in the room.",
|
||||
"description": "Adjusts the membership state for a user in a room. It is preferable to use the membership APIs (``/rooms/<room id>/invite`` etc) when performing membership actions rather than adjusting the state directly as there are a restricted set of valid transformations. For example, user A cannot force user B to join a room, and trying to force this state change directly will fail. \n\nThe following membership states are specified:\n\n- ``invite`` - The user has been invited to join a room, but has not yet joined it. They may not participate in the room until they join.\n\n- ``join`` - The user has joined the room (possibly after accepting an invite), and may participate in it.\n\n- ``leave`` - The user was once joined to the room, but has since left (possibly by choice, or possibly by being kicked).\n\n- ``ban`` - The user has been banned from the room, and is no longer allowed to join it until they are un-banned from the room (by having their membership state set to a value other than ``ban``).\n\n- ``knock`` - This is a reserved word, which currently has no meaning.\n\nThe ``third_party_invite`` property will be set if this invite is an ``invite`` event and is the successor of an ``m.room.third_party_invite`` event, and absent otherwise.\n\nThis event may also include an ``invite_room_state`` key **outside the** ``content`` **key**. If present, this contains an array of ``StrippedState`` Events. These events provide information on a few select state events such as the room name.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"title": "EventContent",
|
||||
"properties": {
|
||||
"membership": {
|
||||
"type": "string",
|
||||
"description": "The membership state of the user.",
|
||||
"enum": ["invite","join","knock","leave","ban"]
|
||||
},
|
||||
"avatar_url": {
|
||||
"type": "string",
|
||||
"description": "The avatar URL for this user, if any. This is added by the homeserver."
|
||||
},
|
||||
"displayname": {
|
||||
"type": ["string", "null"],
|
||||
"description": "The display name for this user, if any. This is added by the homeserver."
|
||||
},
|
||||
"third_party_invite": {
|
||||
"type": "object",
|
||||
"title": "Invite",
|
||||
"properties": {
|
||||
"display_name": {
|
||||
"type": "string",
|
||||
"description": "A name which can be displayed to represent the user instead of their third party identifier"
|
||||
},
|
||||
"signed": {
|
||||
"type": "object",
|
||||
"title": "signed",
|
||||
"description": "A block of content which has been signed, which servers can use to verify the event. Clients should ignore this.",
|
||||
"properties": {
|
||||
"mxid": {
|
||||
"type": "string",
|
||||
"description": "The invited matrix user ID. Must be equal to the user_id property of the event."
|
||||
},
|
||||
"token": {
|
||||
"type": "string",
|
||||
"description": "The token property of the containing third_party_invite object."
|
||||
},
|
||||
"signatures": {
|
||||
"type": "object",
|
||||
"description": "A single signature from the verifying server, in the format specified by the Signing Events section of the server-server API.",
|
||||
"title": "Signatures"
|
||||
}
|
||||
},
|
||||
"required": ["mxid", "signatures", "token"]
|
||||
}
|
||||
},
|
||||
"required": ["display_name", "signed"]
|
||||
}
|
||||
},
|
||||
"required": ["membership"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "The ``user_id`` this membership event relates to."
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.member"]
|
||||
},
|
||||
"invite_room_state": {
|
||||
"type": "array",
|
||||
"description": "A subset of the state of the room at the time of the invite, if ``membership`` is ``invite``",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"title": "StrippedState",
|
||||
"description": "A stripped down state event, with only the ``type``, ``state_key`` and ``content`` keys.",
|
||||
"required": ["type", "state_key", "content"],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "The ``type`` for the event.",
|
||||
"enum": ["m.room.join_rules", "m.room.canonical_alias", "m.room.avatar", "m.room.name"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "The ``state_key`` for the event."
|
||||
},
|
||||
"content": {
|
||||
"title": "EventContent",
|
||||
"type": "object",
|
||||
"description": "The ``content`` for the event."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
28
schemas/m.room.message
Normal file
28
schemas/m.room.message
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Message",
|
||||
"description": "This event is used when sending messages in a room. Messages are not limited to be text. The ``msgtype`` key outlines the type of message, e.g. text, audio, image, video, etc. The ``body`` key is text and MUST be used with every kind of ``msgtype`` as a fallback mechanism for when a client cannot render a message. This allows clients to display *something* even if it is just plain text.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"msgtype": {
|
||||
"type": "string",
|
||||
"description": "The type of message, e.g. ``m.image``, ``m.text``"
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "The textual representation of this message."
|
||||
}
|
||||
},
|
||||
"required": ["msgtype", "body"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.message"]
|
||||
}
|
||||
}
|
||||
}
|
51
schemas/m.room.message#m.audio
Normal file
51
schemas/m.room.message#m.audio
Normal file
@ -0,0 +1,51 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "AudioMessage",
|
||||
"description": "This message represents a single audio clip.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"msgtype": {
|
||||
"type": "string",
|
||||
"enum": ["m.audio"]
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "A description of the audio e.g. 'Bee Gees - Stayin' Alive', or some kind of content description for accessibility e.g. 'audio attachment'."
|
||||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"description": "The URL to the audio clip."
|
||||
},
|
||||
"info": {
|
||||
"type": "object",
|
||||
"title": "AudioInfo",
|
||||
"description": "Metadata for the audio clip referred to in ``url``.",
|
||||
"properties": {
|
||||
"mimetype": {
|
||||
"type": "string",
|
||||
"description": "The mimetype of the audio e.g. ``audio/aac``."
|
||||
},
|
||||
"size": {
|
||||
"type": "integer",
|
||||
"description": "The size of the audio clip in bytes."
|
||||
},
|
||||
"duration": {
|
||||
"type": "integer",
|
||||
"description": "The duration of the audio in milliseconds."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["msgtype", "body", "url"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.message"]
|
||||
}
|
||||
}
|
||||
}
|
28
schemas/m.room.message#m.emote
Normal file
28
schemas/m.room.message#m.emote
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "EmoteMessage",
|
||||
"description": "This message is similar to ``m.text`` except that the sender is 'performing' the action contained in the ``body`` key, similar to ``/me`` in IRC. This message should be prefixed by the name of the sender. This message could also be represented in a different colour to distinguish it from regular ``m.text`` messages.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"msgtype": {
|
||||
"type": "string",
|
||||
"enum": ["m.emote"]
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "The emote action to perform."
|
||||
}
|
||||
},
|
||||
"required": ["msgtype", "body"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.message"]
|
||||
}
|
||||
}
|
||||
}
|
63
schemas/m.room.message#m.file
Normal file
63
schemas/m.room.message#m.file
Normal file
@ -0,0 +1,63 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "FileMessage",
|
||||
"description": "This message represents a generic file.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"msgtype": {
|
||||
"type": "string",
|
||||
"enum": ["m.file"]
|
||||
},
|
||||
"filename": {
|
||||
"type": "string",
|
||||
"description": "The original filename of the uploaded file."
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "A human-readable description of the file. This is recommended to be the filename of the original upload."
|
||||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"description": "The URL to the file."
|
||||
},
|
||||
"info": {
|
||||
"type": "object",
|
||||
"title": "FileInfo",
|
||||
"description": "Information about the file referred to in ``url``.",
|
||||
"properties": {
|
||||
"size": {
|
||||
"type": "integer",
|
||||
"description": "The size of the file in bytes."
|
||||
},
|
||||
"mimetype": {
|
||||
"type": "string",
|
||||
"description": "The mimetype of the file e.g. ``application/msword``."
|
||||
}
|
||||
}
|
||||
},
|
||||
"thumbnail_url": {
|
||||
"type": "string",
|
||||
"description": "The URL to the thumbnail of the file."
|
||||
},
|
||||
"thumbnail_info": {
|
||||
"type": "object",
|
||||
"title": "ImageInfo",
|
||||
"description": "Metadata about the image referred to in ``thumbnail_url``.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/msgtype_infos/image_info.yaml"
|
||||
}]
|
||||
}
|
||||
},
|
||||
"required": ["msgtype", "body", "url", "filename"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.message"]
|
||||
}
|
||||
}
|
||||
}
|
67
schemas/m.room.message#m.image
Normal file
67
schemas/m.room.message#m.image
Normal file
@ -0,0 +1,67 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "ImageMessage",
|
||||
"description": "This message represents a single image and an optional thumbnail.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"msgtype": {
|
||||
"type": "string",
|
||||
"enum": ["m.image"]
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "A textual representation of the image. This could be the alt text of the image, the filename of the image, or some kind of content description for accessibility e.g. 'image attachment'."
|
||||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"description": "The URL to the image."
|
||||
},
|
||||
"thumbnail_url": {
|
||||
"type": "string",
|
||||
"description": "The URL to the thumbnail of the image."
|
||||
},
|
||||
"thumbnail_info": {
|
||||
"type": "object",
|
||||
"title": "ImageInfo",
|
||||
"description": "Metadata about the image referred to in ``thumbnail_url``.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/msgtype_infos/image_info.yaml"
|
||||
}]
|
||||
},
|
||||
"info": {
|
||||
"type": "object",
|
||||
"title": "ImageInfo",
|
||||
"description": "Metadata about the image referred to in ``url``.",
|
||||
"properties": {
|
||||
"size": {
|
||||
"type": "integer",
|
||||
"description": "Size of the image in bytes."
|
||||
},
|
||||
"w": {
|
||||
"type": "integer",
|
||||
"description": "The width of the image in pixels."
|
||||
},
|
||||
"h": {
|
||||
"type": "integer",
|
||||
"description": "The height of the image in pixels."
|
||||
},
|
||||
"mimetype": {
|
||||
"type": "string",
|
||||
"description": "The mimetype of the image, e.g. ``image/jpeg``."
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["msgtype", "body", "url"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.message"]
|
||||
}
|
||||
}
|
||||
}
|
43
schemas/m.room.message#m.location
Normal file
43
schemas/m.room.message#m.location
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "LocationMessage",
|
||||
"description": "This message represents a real-world location.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"msgtype": {
|
||||
"type": "string",
|
||||
"enum": ["m.location"]
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "A description of the location e.g. 'Big Ben, London, UK', or some kind of content description for accessibility e.g. 'location attachment'."
|
||||
},
|
||||
"geo_uri": {
|
||||
"type": "string",
|
||||
"description": "A geo URI representing this location."
|
||||
},
|
||||
"thumbnail_url": {
|
||||
"type": "string",
|
||||
"description": "The URL to a thumbnail of the location being represented."
|
||||
},
|
||||
"thumbnail_info": {
|
||||
"type": "object",
|
||||
"title": "ImageInfo",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/msgtype_infos/image_info.yaml"
|
||||
}]
|
||||
}
|
||||
},
|
||||
"required": ["msgtype", "body", "geo_uri"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.message"]
|
||||
}
|
||||
}
|
||||
}
|
28
schemas/m.room.message#m.notice
Normal file
28
schemas/m.room.message#m.notice
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "NoticeMessage",
|
||||
"description": "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.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"msgtype": {
|
||||
"type": "string",
|
||||
"enum": ["m.notice"]
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "The notice text to send."
|
||||
}
|
||||
},
|
||||
"required": ["msgtype", "body"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.message"]
|
||||
}
|
||||
}
|
||||
}
|
28
schemas/m.room.message#m.text
Normal file
28
schemas/m.room.message#m.text
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "TextMessage",
|
||||
"description": "This message is the most basic message and is used to represent text.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"msgtype": {
|
||||
"type": "string",
|
||||
"enum": ["m.text"]
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "The body of the message."
|
||||
}
|
||||
},
|
||||
"required": ["msgtype", "body"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.message"]
|
||||
}
|
||||
}
|
||||
}
|
70
schemas/m.room.message#m.video
Normal file
70
schemas/m.room.message#m.video
Normal file
@ -0,0 +1,70 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "VideoMessage",
|
||||
"description": "This message represents a single video clip.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"msgtype": {
|
||||
"type": "string",
|
||||
"enum": ["m.video"]
|
||||
},
|
||||
"body": {
|
||||
"type": "string",
|
||||
"description": "A description of the video e.g. 'Gangnam style', or some kind of content description for accessibility e.g. 'video attachment'."
|
||||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"description": "The URL to the video clip."
|
||||
},
|
||||
"info": {
|
||||
"type": "object",
|
||||
"title": "VideoInfo",
|
||||
"description": "Metadata about the video clip referred to in ``url``.",
|
||||
"properties": {
|
||||
"mimetype": {
|
||||
"type": "string",
|
||||
"description": "The mimetype of the video e.g. ``video/mp4``."
|
||||
},
|
||||
"size": {
|
||||
"type": "integer",
|
||||
"description": "The size of the video in bytes."
|
||||
},
|
||||
"duration": {
|
||||
"type": "integer",
|
||||
"description": "The duration of the video in milliseconds."
|
||||
},
|
||||
"w": {
|
||||
"type": "integer",
|
||||
"description": "The width of the video in pixels."
|
||||
},
|
||||
"h": {
|
||||
"type": "integer",
|
||||
"description": "The height of the video in pixels."
|
||||
},
|
||||
"thumbnail_url": {
|
||||
"type": "string",
|
||||
"description": "The URL to a thumbnail of the video clip."
|
||||
},
|
||||
"thumbnail_info": {
|
||||
"type": "object",
|
||||
"title": "ImageInfo",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/msgtype_infos/image_info.yaml"
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["msgtype", "body", "url"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.message"]
|
||||
}
|
||||
}
|
||||
}
|
29
schemas/m.room.message.feedback
Normal file
29
schemas/m.room.message.feedback
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "MessageFeedback",
|
||||
"description": "**NB: Usage of this event is discouraged in favour of the** `receipts module`_. **Most clients will not recognise this event.** Feedback events are events sent to acknowledge a message in some way. There are two supported acknowledgements: ``delivered`` (sent when the event has been received) and ``read`` (sent when the event has been observed by the end-user). The ``target_event_id`` should reference the ``m.room.message`` event being acknowledged.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"description": "The type of feedback.",
|
||||
"enum": ["delivered", "read"]
|
||||
},
|
||||
"target_event_id": {
|
||||
"type": "string",
|
||||
"description": "The event that this feedback is related to."
|
||||
}
|
||||
},
|
||||
"required": ["type", "target_event_id"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.message.feedback"]
|
||||
}
|
||||
}
|
||||
}
|
29
schemas/m.room.name
Normal file
29
schemas/m.room.name
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"title": "RoomName",
|
||||
"description": "A room has an opaque room ID which is not human-friendly to read. A room alias is human-friendly, but not all rooms have room aliases. The room name is a human-friendly string designed to be displayed to the end-user. The room name is not unique, as multiple rooms can have the same room name set. The room name can also be set when creating a room using ``/createRoom`` with the ``name`` key.",
|
||||
"type": "object",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The name of the room. This MUST NOT exceed 255 bytes."
|
||||
}
|
||||
},
|
||||
"required": ["name"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "A zero-length string.",
|
||||
"pattern": "^$"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.name"]
|
||||
}
|
||||
}
|
||||
}
|
66
schemas/m.room.power_levels
Normal file
66
schemas/m.room.power_levels
Normal file
@ -0,0 +1,66 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Defines the power levels (privileges) of users in the room.",
|
||||
"description": "This event specifies the minimum level a user must have in order to perform a certain action. It also specifies the levels of each user in the room. If a ``user_id`` is in the ``users`` list, then that ``user_id`` has the associated power level. Otherwise they have the default level ``users_default``. If ``users_default`` is not supplied, it is assumed to be 0. The level required to send a certain event is governed by ``events``, ``state_default`` and ``events_default``. If an event type is specified in ``events``, then the user must have at least the level specified in order to send that event. If the event type is not supplied, it defaults to ``events_default`` for Message Events and ``state_default`` for State Events.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"ban": {
|
||||
"type": "number",
|
||||
"description": "The level required to ban a user."
|
||||
},
|
||||
"events_default": {
|
||||
"type": "number",
|
||||
"description": "The default level required to send message events. Can be overridden by the ``events`` key."
|
||||
},
|
||||
"kick": {
|
||||
"type": "number",
|
||||
"description": "The level required to kick a user."
|
||||
},
|
||||
"redact": {
|
||||
"type": "number",
|
||||
"description": "The level required to redact an event."
|
||||
},
|
||||
"state_default": {
|
||||
"type": "number",
|
||||
"description": "The default level required to send state events. Can be overridden by the ``events`` key."
|
||||
},
|
||||
"users_default": {
|
||||
"type": "number",
|
||||
"description": "The default power level for every user in the room, unless their ``user_id`` is mentioned in the ``users`` key."
|
||||
},
|
||||
"events": {
|
||||
"type": "object",
|
||||
"title": "Event power levels",
|
||||
"description": "The level required to send specific event types. This is a mapping from event type to power level required.",
|
||||
"additionalProperties": {
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"users": {
|
||||
"type": "object",
|
||||
"title": "User power levels",
|
||||
"description": "The power levels for specific users. This is a mapping from ``user_id`` to power level for that user.",
|
||||
"additionalProperties": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["ban","events","events_default","kick","redact",
|
||||
"state_default","users"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "A zero-length string.",
|
||||
"pattern": "^$"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.power_levels"]
|
||||
}
|
||||
}
|
||||
}
|
28
schemas/m.room.redaction
Normal file
28
schemas/m.room.redaction
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Redaction",
|
||||
"description": "Events can be redacted by either room or server admins. Redacting an event means that all keys not required by the protocol are stripped off, allowing admins to remove offensive or illegal content that may have been attached to any event. This cannot be undone, allowing server owners to physically delete the offending data. There is also a concept of a moderator hiding a message event, which can be undone, but cannot be applied to state events. The event that has been redacted is specified in the ``redacts`` event level key.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/room_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"reason": {
|
||||
"type": "string",
|
||||
"description": "The reason for the redaction, if any."
|
||||
}
|
||||
}
|
||||
},
|
||||
"redacts": {
|
||||
"type": "string",
|
||||
"description": "The event ID that was redacted."
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.redaction"]
|
||||
}
|
||||
},
|
||||
"required": ["redacts"]
|
||||
}
|
56
schemas/m.room.third_party_invite
Normal file
56
schemas/m.room.third_party_invite
Normal file
@ -0,0 +1,56 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "object",
|
||||
"title": "An invitation to a room issued to a third party identifier, rather than a matrix user ID.",
|
||||
"description": "Acts as an ``m.room.member`` invite event, where there isn't a target user_id to invite. This event contains a token and a public key whose private key must be used to sign the token. Any user who can present that signature may use this invitation to join the target room.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"display_name": {
|
||||
"type": "string",
|
||||
"description": "A user-readable string which represents the user who has been invited. This should not contain the user's third party ID, as otherwise when the invite is accepted it would leak the association between the matrix ID and the third party ID."
|
||||
},
|
||||
"key_validity_url": {
|
||||
"type": "string",
|
||||
"description": "A URL which can be fetched, with querystring public_key=public_key, to validate whether the key has been revoked. The URL must return a JSON object containing a boolean property named 'valid'."
|
||||
},
|
||||
"public_key": {
|
||||
"type": "string",
|
||||
"description": "A base64-encoded ed25519 key with which token must be signed (though a signature from any entry in public_keys is also sufficient). This exists for backwards compatibility."
|
||||
},
|
||||
"public_keys": {
|
||||
"type": "array",
|
||||
"description": "Keys with which the token may be signed.",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"title": "PublicKeys",
|
||||
"properties": {
|
||||
"public_key": {
|
||||
"type": "string",
|
||||
"description": "A base-64 encoded ed25519 key with which token may be signed."
|
||||
},
|
||||
"key_validity_url": {
|
||||
"type": "string",
|
||||
"description": "An optional URL which can be fetched, with querystring public_key=public_key, to validate whether the key has been revoked. The URL must return a JSON object containing a boolean property named 'valid'. If this URL is absent, the key must be considered valid indefinitely."
|
||||
}
|
||||
},
|
||||
"required": ["public_key"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["display_name", "key_validity_url", "public_key"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "The token, of which a signature must be produced in order to join the room."
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.third_party_invite"]
|
||||
}
|
||||
}
|
||||
}
|
29
schemas/m.room.topic
Normal file
29
schemas/m.room.topic
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Topic",
|
||||
"description": "A topic is a short message detailing what is currently being discussed in the room. It can also be used as a way to display extra information about the room, which may not be suitable for the room name. The room topic can also be set when creating a room using ``/createRoom`` with the ``topic`` key.",
|
||||
"allOf": [{
|
||||
"$ref": "core-event-schema/state_event.yaml"
|
||||
}],
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"topic": {
|
||||
"type": "string",
|
||||
"description": "The topic text."
|
||||
}
|
||||
},
|
||||
"required": ["topic"]
|
||||
},
|
||||
"state_key": {
|
||||
"type": "string",
|
||||
"description": "A zero-length string.",
|
||||
"pattern": "^$"
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.room.topic"]
|
||||
}
|
||||
}
|
||||
}
|
25
schemas/m.tag
Normal file
25
schemas/m.tag
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Tag Event",
|
||||
"description": "Informs the client of tags on a room.",
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.tag"]
|
||||
},
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"tags": {
|
||||
"type": "object",
|
||||
"description": "The tags on the room and their contents.",
|
||||
"additionalProperties": {
|
||||
"title": "Tag",
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["type", "content"]
|
||||
}
|
28
schemas/m.typing
Normal file
28
schemas/m.typing
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"type": "object",
|
||||
"title": "Typing Event",
|
||||
"description": "Informs the client of the list of users currently typing.",
|
||||
"properties": {
|
||||
"content": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"user_ids": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "The list of user IDs typing in this room, if any."
|
||||
}
|
||||
},
|
||||
"required": ["user_ids"]
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": ["m.typing"]
|
||||
},
|
||||
"room_id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": ["type", "room_id", "content"]
|
||||
}
|
192
src/Makefile.am
Normal file
192
src/Makefile.am
Normal file
@ -0,0 +1,192 @@
|
||||
include $(top_srcdir)/vala-globals.mk
|
||||
|
||||
AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Matrix-GLib\"
|
||||
|
||||
# Empty variables for elements to be added later
|
||||
CLEANFILES =
|
||||
BUILT_SOURCES =
|
||||
EXTRA_DIST =
|
||||
AM_VALAFLAGS =
|
||||
|
||||
# Name of the public header file
|
||||
PUBLIC_HEADER = matrix-glib.h
|
||||
|
||||
# Libraries to create
|
||||
lib_LTLIBRARIES = libmatrix-glib-0.0.la
|
||||
|
||||
# Vala source files
|
||||
libmatrix_glib_0_0_la_VALA_SOURCES = \
|
||||
matrix-api.vala \
|
||||
matrix-client.vala \
|
||||
matrix-enums.vala \
|
||||
matrix-http-api.vala \
|
||||
matrix-http-client.vala \
|
||||
matrix-compacts.vala \
|
||||
matrix-event.vala \
|
||||
matrix-presence-event.vala \
|
||||
matrix-state-event.vala \
|
||||
matrix-room-event.vala \
|
||||
matrix-room-member-event.vala \
|
||||
matrix-room-message-event.vala \
|
||||
$(NULL)
|
||||
|
||||
AM_CPPFLAGS += \
|
||||
-include $(CONFIG_HEADER) \
|
||||
-I$(top_srcdir) \
|
||||
-g \
|
||||
-Wall \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(GOBJECT_CFLAGS) \
|
||||
$(SOUP_CFLAGS) \
|
||||
$(JSON_CFLAGS) \
|
||||
$(GEE_CFLAGS) \
|
||||
$(VALA_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
AM_VALAFLAGS += \
|
||||
--library=Matrix-$(MATRIX_GLIB_API_VERSION) \
|
||||
$(VALA_PKG_LIST) \
|
||||
--vapi=Matrix-$(MATRIX_GLIB_API_VERSION).vapi \
|
||||
-H $(PUBLIC_HEADER) \
|
||||
-C \
|
||||
--use-header \
|
||||
--gir=Matrix-$(MATRIX_GLIB_API_VERSION).gir \
|
||||
$(top_srcdir)/src/c-api.vapi \
|
||||
$(NULL)
|
||||
|
||||
vala-stamp: $(libmatrix_glib_0_0_la_VALA_SOURCES)
|
||||
@rm -f vala-temp
|
||||
@touch vala-temp
|
||||
$(AM_V_GEN) $(VALAC) $(AM_VALAFLAGS) $^
|
||||
@mv -f vala-temp $@
|
||||
|
||||
CLEANFILES += \
|
||||
$(PUBLIC_HEADER) \
|
||||
$(libmatrix_glib_0_0_la_VALA_SOURCES:.vala=.c) \
|
||||
$(NULL)
|
||||
|
||||
$(libmatrix_glib_0_0_la_VALA_SOURCES:.vala=.c): vala-stamp
|
||||
@if test -f $@; then :; else \
|
||||
trap 'rm -rf vala-lock vala-stamp' 1 2 13 15; \
|
||||
if mkdir vala-lock 2> /dev/null; then \
|
||||
rm -f vala-stamp; \
|
||||
$(MAKE) $(AM_MAKEFLAGS) vala-stamp; \
|
||||
rmdir vala-lock; \
|
||||
else \
|
||||
while test -d vala-lock; do sleep 1; done; \
|
||||
test -f vala-stamp; exit $$?; \
|
||||
fi \
|
||||
fi
|
||||
|
||||
# Binaries to create
|
||||
bin_PROGRAMS = test-api-client test-client
|
||||
|
||||
INST_H_SRC_FILES = \
|
||||
$(NULL)
|
||||
|
||||
INST_H_BUILT_FILES = \
|
||||
matrix-version.h \
|
||||
matrix-marshalers.h \
|
||||
$(NULL)
|
||||
|
||||
libmatrix_glib_0_0_la_SOURCES = \
|
||||
$(INST_H_BUILT_FILES) \
|
||||
matrix-marshalers.c \
|
||||
$(libmatrix_glib_0_0_la_VALA_SOURCES:.vala=.c) \
|
||||
matrix-event-types.c \
|
||||
matrix-version.c \
|
||||
$(INST_H_SRC_FILES) \
|
||||
$(NULL)
|
||||
|
||||
libmatrix_glib_0_0_la_CFLAGS = \
|
||||
$(GLIB_CFLAGS) \
|
||||
$(GOBJECT_CFLAGS) \
|
||||
$(SOUP_CFLAGS) \
|
||||
$(JSON_CFLAGS) \
|
||||
$(GEE_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
libmatrix_glib_0_0_la_LIBADD = \
|
||||
$(GLIB_LIBS) \
|
||||
$(GOBJECT_LIBS) \
|
||||
$(SOUP_LIBS) \
|
||||
$(JSON_LIBS) \
|
||||
$(GEE_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
libmatrix_glib_0_0_la_LDFLAGS = \
|
||||
-version-info "$(LT_CURRENT)":"$(LT_REVISION)":"$(LT_AGE)"
|
||||
|
||||
$(PUBLIC_HEADER): vala-stamp
|
||||
|
||||
Matrix-0.0.vapi: libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la
|
||||
vapidir = $(datadir)/vala/vapi
|
||||
dist_vapi_DATA = \
|
||||
Matrix-$(MATRIX_GLIB_API_VERSION).vapi \
|
||||
Matrix-$(MATRIX_GLIB_API_VERSION).deps \
|
||||
$(NULL)
|
||||
|
||||
BUILT_SOURCES += \
|
||||
matrix-marshalers.c \
|
||||
matrix-marshalers.h \
|
||||
$(NULL)
|
||||
|
||||
test_api_client_SOURCES = test-api-client.c
|
||||
test_api_client_CFLAGS = $(libmatrix_glib_0_0_la_CFLAGS) $(AM_CFLAGS)
|
||||
test_api_client_LDADD = \
|
||||
$(libmatrix_glib_0_0_la_LIBADD) \
|
||||
libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la \
|
||||
$(NULL)
|
||||
|
||||
test_client_SOURCES = test-client.c
|
||||
test_client_CFLAGS = $(libmatrix_glib_0_0_la_CFLAGS) $(AM_CFLAGS)
|
||||
test_client_LDADD = \
|
||||
$(libmatrix_glib_0_0_la_LIBADD) \
|
||||
libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la \
|
||||
$(NULL)
|
||||
|
||||
CLEANFILES += $(BUILT_SOURCES)
|
||||
EXTRA_DIST += \
|
||||
matrix-marshalers.list \
|
||||
$(INST_H_SRC_FILES) \
|
||||
$(NULL)
|
||||
|
||||
matrix-marshalers.h: stamp-matrix-marshalers
|
||||
@true
|
||||
|
||||
stamp-matrix-marshalers: matrix-marshalers.list
|
||||
$(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_matrix_marshal \
|
||||
$(srcdir)/matrix-marshalers.list \
|
||||
--header \
|
||||
--valist-marshallers >> xgen-gmlh \
|
||||
&& (cmp -s xgen-gmlh matrix-marshalers.h \
|
||||
|| cp xgen-gmlh matrix-marshalers.h) \
|
||||
&& rm -f xgen-gmlh \
|
||||
&& echo timestamp > $(@F)
|
||||
|
||||
matrix-marshalers.c: matrix-marshalers.h
|
||||
$(AM_V_GEN) (echo "#include \"matrix-marshalers.h\""; \
|
||||
echo "#undef G_ENABLE_DEBUG"; \
|
||||
$(GLIB_GENMARSHAL) --prefix=_matrix_marshal \
|
||||
$(srcdir)/matrix-marshalers.list \
|
||||
--body \
|
||||
--valist-marshallers) >> xgen-gmlc \
|
||||
&& cp xgen-gmlc matrix-marshalers.c \
|
||||
&& rm -f xgen-gmlc
|
||||
|
||||
CLEANFILES += stamp-matrix-marshalers
|
||||
|
||||
include $(INTROSPECTION_MAKEFILE)
|
||||
Matrix-0.0.gir: libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la
|
||||
|
||||
typelibsdir = $(libdir)/girepository-1.0
|
||||
typelibs_DATA = Matrix-$(MATRIX_GLIB_API_VERSION).typelib
|
||||
|
||||
headerdir = $(includedir)/matrix-glib-$(MATRIX_GLIB_API_VERSION)
|
||||
header_DATA = \
|
||||
$(PUBLIC_HEADER) \
|
||||
$(INST_H_SRC_FILES) \
|
||||
$(INST_H_BUILT_FILES) \
|
||||
$(NULL)
|
||||
|
||||
CLEANFILES += $(typelibs_DATA)
|
4
src/Matrix-0.0.deps
Normal file
4
src/Matrix-0.0.deps
Normal file
@ -0,0 +1,4 @@
|
||||
gio-2.0
|
||||
Json-1.0
|
||||
gee-0.8
|
||||
libsoup-2.4
|
52
src/c-api.vapi
Normal file
52
src/c-api.vapi
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
[CCode (cprefix = "Matrix", gir_namespace = "Matrix", gir_version = "0.0", lower_case_cprefix = "matrix_")]
|
||||
namespace Matrix {
|
||||
/**
|
||||
* The major version number of the Matrix.org GLib SDK.
|
||||
*/
|
||||
[CCode (cheader_filename = "matrix-version.h", cname = "MATRIX_GLIB_MAJOR_VERSION")]
|
||||
public const int GLIB_MAJOR_VERSION;
|
||||
|
||||
/**
|
||||
* The micro (patch) version number of the Matrix.org GLib SDK.
|
||||
*/
|
||||
[CCode (cheader_filename = "matrix-version.h", cname = "MATRIX_GLIB_MINOR_VERSION")]
|
||||
public const int GLIB_MINOR_VERSION;
|
||||
|
||||
/**
|
||||
* The minor version number of the Matrix.org GLib SDK.
|
||||
*/
|
||||
[CCode (cheader_filename = "matrix-version.h", cname = "MATRIX_GLIB_MICRO_VERSION")]
|
||||
public const int GLIB_MICRO_VERSION;
|
||||
|
||||
/**
|
||||
* Check that the Matrix.org GLib SDK in use is compatible with
|
||||
* the given version.
|
||||
*
|
||||
* @param required_major the required major version
|
||||
* @param required_minor the required minor version
|
||||
* @param required_micro the required micro version
|
||||
* @return {{{true}}} if the required version is satisfied; {{{false}}} otherwise.
|
||||
*/
|
||||
[CCode (cheader_filename = "matrix-version.h", cname = "matrix_glib_check_version")]
|
||||
public bool glib_check_version(uint required_major,
|
||||
uint required_minor,
|
||||
uint required_micro);
|
||||
}
|
2126
src/matrix-api.c
2126
src/matrix-api.c
File diff suppressed because it is too large
Load Diff
932
src/matrix-api.h
932
src/matrix-api.h
@ -1,932 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_API_H__
|
||||
# define __MATRIX_GLIB_SDK_API_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include <json-glib/json-glib.h>
|
||||
# include "matrix-compacts.h"
|
||||
# include "matrix-event-state-base.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# ifdef __MATRIX_GLIB_SDK_COMPILATION
|
||||
# define MATRIX_DEPRECATED_FOR(f)
|
||||
# else
|
||||
# define MATRIX_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f)
|
||||
# endif
|
||||
|
||||
# define MATRIX_TYPE_API matrix_api_get_type()
|
||||
G_DECLARE_INTERFACE(MatrixAPI, matrix_api, MATRIX, API, GObject)
|
||||
|
||||
typedef void (*MatrixAPICallback)(MatrixAPI *api,
|
||||
const gchar *content_type,
|
||||
JsonNode *json_content,
|
||||
GByteArray *raw_content,
|
||||
GError *err,
|
||||
gpointer user_data);
|
||||
|
||||
struct _MatrixAPIInterface {
|
||||
GTypeInterface parent_iface;
|
||||
void (*abort_pending)(MatrixAPI *api);
|
||||
void (*get_3pids)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void (*add_3pid)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
gboolean bind_creds,
|
||||
Matrix3PidCredential *threepid_creds,
|
||||
GError **error);
|
||||
void (*deactivate_account)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *session,
|
||||
const gchar *login_type,
|
||||
GError **error);
|
||||
void (*change_password)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *new_password,
|
||||
GError **error);
|
||||
void (*whoami)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void (*get_profile)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
GError **error);
|
||||
void (*get_avatar_url)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
GError **error);
|
||||
void (*set_avatar_url)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
const gchar *avatar_url,
|
||||
GError **error);
|
||||
void (*get_display_name)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
GError **error);
|
||||
void (*set_display_name)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
const gchar *display_name,
|
||||
GError **error);
|
||||
void (*register_account)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
MatrixAccountKind account_kind,
|
||||
gboolean bind_email,
|
||||
const gchar *username,
|
||||
const gchar *password,
|
||||
GError **error);
|
||||
void (*register_account_email)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *id_server,
|
||||
const gchar *client_secret,
|
||||
const gchar *email,
|
||||
guint send_attempt,
|
||||
GError **error);
|
||||
void (*set_account_data)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
const gchar *event_type,
|
||||
JsonNode *content,
|
||||
GError **error);
|
||||
void (*get_room_tags)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
GError **error);
|
||||
void (*delete_room_tag)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
const gchar *tag,
|
||||
GError **error);
|
||||
void (*add_room_tag)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
const gchar *tag,
|
||||
JsonNode *content,
|
||||
GError **error);
|
||||
void (*whois)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
GError **error);
|
||||
void (*versions)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void (*create_room)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
MatrixRoomPreset preset,
|
||||
const gchar *room_name,
|
||||
const gchar *room_alias,
|
||||
const gchar *topic,
|
||||
MatrixRoomVisibility visibility,
|
||||
JsonNode *creation_content,
|
||||
MatrixEventState **initial_state,
|
||||
int n_initial_state,
|
||||
gchar **invitees,
|
||||
int n_invitees,
|
||||
Matrix3PidCredential **invite_3pids,
|
||||
int n_invite_3pids,
|
||||
GError **error);
|
||||
void (*delete_room_alias)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_alias,
|
||||
GError **error);
|
||||
void (*get_joined_rooms)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void (*get_room_id)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_alias,
|
||||
GError **error);
|
||||
void (*create_room_alias)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
const gchar *room_alias,
|
||||
GError **error);
|
||||
void (*event_stream)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *from_token,
|
||||
gulong timeout,
|
||||
GError **error);
|
||||
void (*get_event)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *event_id,
|
||||
GError **error);
|
||||
void (*initial_sync)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
guint limit,
|
||||
gboolean archived,
|
||||
GError **error);
|
||||
void (*get_event_context)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
const gchar *event_id,
|
||||
guint limit,
|
||||
GError **error);
|
||||
void (*initial_sync_room)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
GError **error);
|
||||
void (*list_room_members)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
GError **error);
|
||||
void (*list_room_messages)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
const gchar *from_token,
|
||||
MatrixEventDirection direction,
|
||||
guint limit,
|
||||
GError **error);
|
||||
void (*send_event_receipt)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
MatrixReceiptType receipt_type,
|
||||
const gchar *event_id,
|
||||
JsonNode *receipt,
|
||||
GError **error);
|
||||
void (*redact_event)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
const gchar *event_id,
|
||||
const gchar *txn_id,
|
||||
const gchar *reason,
|
||||
GError **error);
|
||||
void (*send_event)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
const gchar *event_type,
|
||||
const gchar *txn_id,
|
||||
JsonNode *content,
|
||||
GError **error);
|
||||
void (*get_room_state)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
const gchar *event_type,
|
||||
const gchar *state_key,
|
||||
GError **error);
|
||||
void (*send_state_event)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
const gchar *event_type,
|
||||
const gchar *state_key,
|
||||
JsonNode *content,
|
||||
GError **error);
|
||||
void (*notify_room_typing)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
guint timeout,
|
||||
gboolean typing,
|
||||
GError **error);
|
||||
void (*sync)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *filter_id,
|
||||
MatrixFilter *filter,
|
||||
const gchar *since,
|
||||
gboolean full_state,
|
||||
gboolean set_presence,
|
||||
gulong timeout,
|
||||
GError **error);
|
||||
void (*create_filter)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
MatrixFilter *filter,
|
||||
GError **error);
|
||||
void (*download_filter)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
const gchar *filter_id,
|
||||
GError **error);
|
||||
void (*join_room_id_or_alias)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id_or_alias,
|
||||
GError **error);
|
||||
void (*ban_user)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
const gchar *user_id,
|
||||
const gchar *reason,
|
||||
GError **error);
|
||||
void (*forget_room)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
GError **error);
|
||||
void (*invite_user_3rdparty)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
Matrix3PidCredential *credential,
|
||||
GError **error);
|
||||
void (*invite_user)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
const gchar *user_id,
|
||||
GError **error);
|
||||
void (*join_room)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
GError **error);
|
||||
void (*kick_user)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
const gchar *user_id,
|
||||
const gchar *reason,
|
||||
GError **error);
|
||||
void (*leave_room)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
GError **error);
|
||||
void (*unban_user)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *room_id,
|
||||
const gchar *user_id,
|
||||
GError **error);
|
||||
void (*login)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *login_type,
|
||||
JsonNode *content,
|
||||
GError **error);
|
||||
void (*logout)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void (*get_presence_list)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
GError **error);
|
||||
void (*update_presence_list)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
gchar **drop_ids,
|
||||
int n_drop_ids,
|
||||
gchar **invite_ids,
|
||||
int n_invite_ids,
|
||||
GError **error);
|
||||
void (*get_presence)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
GError **error);
|
||||
void (*set_presence)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *user_id,
|
||||
MatrixPresence presence,
|
||||
const gchar *status_message,
|
||||
GError **error);
|
||||
void (*list_public_rooms)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void (*get_pushers)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void (*update_pusher)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
MatrixPusher *pusher,
|
||||
GError **error);
|
||||
void (*get_notifications)(MatrixAPI *api,
|
||||
const gchar *from_token,
|
||||
guint limit,
|
||||
const gchar *filter,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void (*get_pushrules)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void (*delete_pushrule)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *scope,
|
||||
MatrixPusherKind kind,
|
||||
const gchar *rule_id,
|
||||
GError **error);
|
||||
void (*get_pushrule)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *scope,
|
||||
MatrixPusherKind kind,
|
||||
const gchar *rule_id,
|
||||
GError **error);
|
||||
void (*add_pushrule)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *scope,
|
||||
MatrixPusherKind kind,
|
||||
const gchar *rule_id,
|
||||
const gchar *before,
|
||||
const gchar *after,
|
||||
gchar **actions,
|
||||
int n_actions,
|
||||
MatrixPusherConditionKind *conditions,
|
||||
int n_conditions,
|
||||
GError **error);
|
||||
void (*toggle_pushrule)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *scope,
|
||||
MatrixPusherKind kind,
|
||||
const gchar *rule_id,
|
||||
gboolean enabled,
|
||||
GError **error);
|
||||
void (*search)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *next_batch,
|
||||
MatrixSearchCategories *search_categories,
|
||||
GError **error);
|
||||
void (*get_turn_server)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void (*media_download)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *server_name,
|
||||
const gchar *media_id,
|
||||
GError **error);
|
||||
void (*media_thumbnail)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *server_name,
|
||||
const gchar *media_id,
|
||||
guint width,
|
||||
guint height,
|
||||
MatrixResizeMethod method,
|
||||
GError **error);
|
||||
void (*media_upload)(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
const gchar *content_type,
|
||||
GByteArray *content,
|
||||
GError **error);
|
||||
const gchar *(*get_token)(MatrixAPI *api);
|
||||
void (*set_token)(MatrixAPI *api, const gchar *token);
|
||||
const gchar *(*get_user_id)(MatrixAPI *api);
|
||||
void (*set_user_id)(MatrixAPI *api, const gchar *user_id);
|
||||
const gchar *(*get_homeserver)(MatrixAPI *api);
|
||||
void (*set_homeserver)(MatrixAPI *api, const gchar *homeserver);
|
||||
};
|
||||
|
||||
void matrix_api_abort_pending(MatrixAPI *api);
|
||||
void matrix_api_get_3pids(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_add_3pid(MatrixAPI *api,
|
||||
gboolean bind_creds,
|
||||
Matrix3PidCredential *threepid_creds,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_deactivate_account(MatrixAPI *api,
|
||||
const gchar *session,
|
||||
const gchar *login_type,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_change_password(MatrixAPI *api,
|
||||
const gchar *new_password,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_whoami(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_profile(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_avatar_url(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_set_avatar_url(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
const gchar *avatar_url,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_display_name(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_set_display_name(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
const gchar *display_name,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_register_account(MatrixAPI *api,
|
||||
MatrixAccountKind account_kind,
|
||||
gboolean bind_email,
|
||||
const gchar *username,
|
||||
const gchar *password,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_register_account_email(MatrixAPI *api,
|
||||
const gchar *id_server,
|
||||
const gchar *client_secret,
|
||||
const gchar *email,
|
||||
guint send_attempt,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_set_account_data(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
const gchar *event_type,
|
||||
JsonNode *content,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_room_tags(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_delete_room_tag(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
const gchar *tag,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_add_room_tag(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
const gchar *tag,
|
||||
JsonNode *content,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_whois(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_versions(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_create_room(MatrixAPI *api,
|
||||
MatrixRoomPreset preset,
|
||||
const gchar *room_name,
|
||||
const gchar *room_alias,
|
||||
const gchar *topic,
|
||||
MatrixRoomVisibility visibility,
|
||||
JsonNode *creation_content,
|
||||
MatrixEventState **initial_state,
|
||||
int n_initial_state,
|
||||
gchar **invitees,
|
||||
int n_invitees,
|
||||
Matrix3PidCredential **invite_3pids,
|
||||
int n_invite_3pids,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_delete_room_alias(MatrixAPI *api,
|
||||
const gchar *room_alias,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_joined_rooms(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_room_id(MatrixAPI *api,
|
||||
const gchar *room_alias,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_create_room_alias(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
const gchar *room_alias,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_event_stream(MatrixAPI *api,
|
||||
const gchar *from_token,
|
||||
gulong timeout,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
MATRIX_DEPRECATED_FOR(matrix_api_sync);
|
||||
void matrix_api_get_event(MatrixAPI *api,
|
||||
const gchar *event_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
MATRIX_DEPRECATED_FOR(matrix_api_sync);
|
||||
void matrix_api_initial_sync(MatrixAPI *api,
|
||||
guint limit,
|
||||
gboolean archived,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
MATRIX_DEPRECATED_FOR(matrix_api_sync);
|
||||
void matrix_api_get_event_context(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
const gchar *event_id,
|
||||
guint limit,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_initial_sync_room(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
MATRIX_DEPRECATED_FOR(matrix_api_sync);
|
||||
void matrix_api_list_room_members(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_list_room_messages(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
const gchar *from_token,
|
||||
MatrixEventDirection direction,
|
||||
guint limit,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_send_event_receipt(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
MatrixReceiptType receipt_type,
|
||||
const gchar *event_id,
|
||||
JsonNode *receipt,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_redact_event(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
const gchar *event_id,
|
||||
const gchar *txn_id,
|
||||
const gchar *reason,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_send_event(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
const gchar *event_type,
|
||||
const gchar *txn_id,
|
||||
JsonNode *content,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_room_state(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
const gchar *event_type,
|
||||
const gchar *state_key,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_send_state_event(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
const gchar *event_type,
|
||||
const gchar *state_key,
|
||||
JsonNode *content,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_notify_room_typing(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
guint timeout,
|
||||
gboolean typing,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_sync(MatrixAPI *api,
|
||||
const gchar *filter_id,
|
||||
MatrixFilter *filter,
|
||||
const gchar *since,
|
||||
gboolean full_state,
|
||||
gboolean set_presence,
|
||||
gulong timeout,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_create_filter(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
MatrixFilter *filter,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_download_filter(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
const gchar *filter_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_join_room_id_or_alias(MatrixAPI *api,
|
||||
const gchar *room_id_or_alias,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_ban_user(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
const gchar *user_id,
|
||||
const gchar *reason,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_forget_room(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_invite_user_3rdparty(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
Matrix3PidCredential *credential,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_invite_user(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
const gchar *user_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_join_room(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_kick_user(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
const gchar *user_id,
|
||||
const gchar *reason,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_leave_room(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_unban_user(MatrixAPI *api,
|
||||
const gchar *room_id,
|
||||
const gchar *user_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_login(MatrixAPI *api,
|
||||
const gchar *login_type,
|
||||
JsonNode *content,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_logout(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_presence_list(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_update_presence_list(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
gchar **drop_ids,
|
||||
int n_drop_ids,
|
||||
gchar **invite_ids,
|
||||
int n_invite_ids,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_presence(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_set_presence(MatrixAPI *api,
|
||||
const gchar *user_id,
|
||||
MatrixPresence presence,
|
||||
const gchar *status_message,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_list_public_rooms(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_pushers(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_update_pusher(MatrixAPI *api,
|
||||
MatrixPusher *pusher,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_notifications(MatrixAPI *api,
|
||||
const gchar *from_token,
|
||||
guint limit,
|
||||
const gchar *filter,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_pushrules(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_delete_pushrule(MatrixAPI *api,
|
||||
const gchar *scope,
|
||||
MatrixPusherKind kind,
|
||||
const gchar *rule_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_pushrule(MatrixAPI *api,
|
||||
const gchar *scope,
|
||||
MatrixPusherKind kind,
|
||||
const gchar *rule_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_add_pushrule(MatrixAPI *api,
|
||||
const gchar *scope,
|
||||
MatrixPusherKind kind,
|
||||
const gchar *rule_id,
|
||||
const gchar *before,
|
||||
const gchar *after,
|
||||
gchar **actions,
|
||||
int n_actions,
|
||||
MatrixPusherConditionKind *conditions,
|
||||
int n_conditions,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_toggle_pushrule(MatrixAPI *api,
|
||||
const gchar *scope,
|
||||
MatrixPusherKind kind,
|
||||
const gchar *rule_id,
|
||||
gboolean enabled,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_search(MatrixAPI *api,
|
||||
const gchar *next_batch,
|
||||
MatrixSearchCategories *search_categories,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_get_turn_server(MatrixAPI *api,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_media_download(MatrixAPI *api,
|
||||
const gchar *server_name,
|
||||
const gchar *media_id,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_media_thumbnail(MatrixAPI *api,
|
||||
const gchar *server_name,
|
||||
const gchar *media_id,
|
||||
guint width,
|
||||
guint height,
|
||||
MatrixResizeMethod method,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_api_media_upload(MatrixAPI *api,
|
||||
const gchar *content_type,
|
||||
GByteArray *content,
|
||||
MatrixAPICallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
const gchar *matrix_api_get_token(MatrixAPI *api);
|
||||
void matrix_api_set_token(MatrixAPI *api, const gchar *token);
|
||||
const gchar *matrix_api_get_user_id(MatrixAPI *api);
|
||||
void matrix_api_set_user_id(MatrixAPI *api, const gchar *user_id);
|
||||
const gchar *matrix_api_get_homeserver(MatrixAPI *api);
|
||||
void matrix_api_set_homeserver(MatrixAPI *api, const gchar *homeserver);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_API_H__ */
|
1308
src/matrix-api.vala
Normal file
1308
src/matrix-api.vala
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,496 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-client.h"
|
||||
#include "matrix-marshalers.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-client
|
||||
* @short_description: Interface for Matrix client implementations
|
||||
* @title: Interface for Matrix client implementations
|
||||
*/
|
||||
|
||||
enum {
|
||||
SIGNAL_LOGIN_FINISHED,
|
||||
SIGNAL_EVENT,
|
||||
SIGNAL_POLLING_STARTED,
|
||||
SIGNAL_POLLING_STOPPED,
|
||||
NUM_SIGNALS
|
||||
};
|
||||
static guint matrix_client_signals[NUM_SIGNALS] = {0};
|
||||
|
||||
/**
|
||||
* MatrixClientInterface:
|
||||
* @login_with_password: the virtual function pointer for matrix_client_login_with_password()
|
||||
* @register_with_password: the virtual function pointer for matrix_client_register_with_password()
|
||||
* @logout: the virtual function pointer for matrix_client_logout()
|
||||
* @begin_polling: the virtual function pointer for matrix_client_begin_polling()
|
||||
* @stop_polling: the virtual function pointer for matrix_client_stop_polling()
|
||||
* @get_user_profile: the virtual function pointer for matrix_client_get_user_profile()
|
||||
* @get_user_presence: the virtual function pointer for matrix_client_get_user_presence()
|
||||
* @get_room_by_id: the virtual function pointer for matrix_client_get_room_by_id()
|
||||
* @get_room_by_alias: the virtual function pointer for matrix_client_get_room_by_alias()
|
||||
* @send: the virtual function pointer for matrix_client_send()
|
||||
* @save_state: the virtual function pointer for matrix_client_save_state()
|
||||
* @load_state: the virtual function pointer for matrix_client_load_state()
|
||||
* @login_finished: the class closure for the #MatrixClient::login-finished signal
|
||||
* @event: the class closure for the #MatrixClient::event signal
|
||||
*
|
||||
* Base interface for client communication with a Matrix.org homeserver
|
||||
*/
|
||||
G_DEFINE_INTERFACE(MatrixClient, matrix_client, G_TYPE_OBJECT);
|
||||
|
||||
/**
|
||||
* MatrixClientSendCallback:
|
||||
* @client: the #MatrixClient that initiated the request
|
||||
* @event_id: the event ID of the event just sent
|
||||
* @error: (nullable): a #GError holding errors that happened during sending, if any
|
||||
* @user_data: (nullable): user data set when event sending was initiated
|
||||
*
|
||||
* Callback function type for matrix_client_send().
|
||||
*/
|
||||
|
||||
/**
|
||||
* MatrixClientEventCallback:
|
||||
* @client: the #MatrixClient that sent the signal
|
||||
* @room_id: the room ID from which the event originated
|
||||
* @raw_event: the raw event
|
||||
* @matrix_event: (nullable): a #MatrixMessageBase derived object
|
||||
* @user_data: (nullable): user data set when the signal was connected
|
||||
*
|
||||
* Callback function type for matrix_client_connect_event().
|
||||
*
|
||||
* @matrix_event may be unset if there was no message handler registered for the message type
|
||||
* (using matrix_message_register_type()), or if the message couldn’t be deserialised by the
|
||||
* message handler.
|
||||
*/
|
||||
|
||||
/**
|
||||
* matrix_client_login_with_password:
|
||||
* @client: a #MatrixClient
|
||||
* @username: the username to login with
|
||||
* @password: the password to use
|
||||
* @error: a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Authenticate with the Matrix.org server with a username and password.
|
||||
*/
|
||||
void
|
||||
matrix_client_login_with_password(MatrixClient *matrix_client, const gchar *username, const gchar *password, GError **error)
|
||||
{
|
||||
g_return_if_fail(matrix_client != NULL);
|
||||
|
||||
MATRIX_CLIENT_GET_IFACE(matrix_client)->login_with_password(matrix_client, username, password, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_register_with_password:
|
||||
* @client: a #MatrixClient
|
||||
* @username: the username to register. If omitted, the server will generate one
|
||||
* @password: the password to use with the registration
|
||||
* @error: a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Register @username with the homeserver as a normal user. Upon success, the user is registered
|
||||
* and authenticated.
|
||||
*
|
||||
* Implementations must emit the #MatrixClient::login-finished signal when a response arrives.
|
||||
*
|
||||
* This method registers a normal user account. If you want to register a different kind of user,
|
||||
* use matrix_api_register_account().
|
||||
*/
|
||||
void
|
||||
matrix_client_register_with_password(MatrixClient *matrix_client, const gchar *username, const gchar *password, GError **error)
|
||||
{
|
||||
g_return_if_fail(matrix_client != NULL);
|
||||
|
||||
MATRIX_CLIENT_GET_IFACE(matrix_client)->register_with_password(matrix_client, username, password, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_logout:
|
||||
* @client: an object implementing the #MatrixClient interface
|
||||
* @error: a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Logout from the homeserver. As Matrix.org doesn’t have such a concept, this cancels all ongoing
|
||||
* requests and clears the authentication data (e.g. tokens).
|
||||
*/
|
||||
void
|
||||
matrix_client_logout(MatrixClient *matrix_client, GError **error)
|
||||
{
|
||||
g_return_if_fail(matrix_client != NULL);
|
||||
|
||||
MATRIX_CLIENT_GET_IFACE(matrix_client)->logout(matrix_client, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_begin_polling:
|
||||
* @client: an object implementing the #MatrixClient interface
|
||||
* @error: a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Begin polling the event stream.
|
||||
*/
|
||||
void
|
||||
matrix_client_begin_polling(MatrixClient *matrix_client, GError **error)
|
||||
{
|
||||
g_return_if_fail(matrix_client != NULL);
|
||||
|
||||
MATRIX_CLIENT_GET_IFACE(matrix_client)->begin_polling(matrix_client, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_stop_polling:
|
||||
* @client: a #MatrixClient
|
||||
* @cancel_ongoing: if %TRUE, ongoing requests will be cancelled, too
|
||||
* @error: a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Stop polling the event stream. If @cancel_ongoing is %TRUE, ongoing requests will be cancelled,
|
||||
* too.
|
||||
*/
|
||||
void
|
||||
matrix_client_stop_polling(MatrixClient *matrix_client, gboolean cancel_ongoing, GError **error)
|
||||
{
|
||||
g_return_if_fail(matrix_client != NULL);
|
||||
|
||||
MATRIX_CLIENT_GET_IFACE(matrix_client)->stop_polling(matrix_client, cancel_ongoing, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_emit_login_finished:
|
||||
* @client: a #MatrixClient
|
||||
* @success: set to %TRUE if login was successful
|
||||
*
|
||||
* Convenience function to emit the #MatrixClient::login-finished signal.
|
||||
*/
|
||||
void
|
||||
matrix_client_emit_login_finished(MatrixClient *matrix_client, gboolean success)
|
||||
{
|
||||
g_signal_emit(matrix_client, matrix_client_signals[SIGNAL_LOGIN_FINISHED], 0, success);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_incoming_event:
|
||||
* @client: an object implementing the #MatrixClient interface
|
||||
* @room_id: the room the event is associated with
|
||||
* @raw_event: the raw event
|
||||
* @matrix_event: the event as a Matrix.Event
|
||||
*
|
||||
* Emits the #MatrixClient::event signal.
|
||||
*/
|
||||
void
|
||||
matrix_client_incoming_event(MatrixClient *matrix_client, const gchar *room_id, JsonNode *raw_event, MatrixEventBase *matrix_event)
|
||||
{
|
||||
GQuark equark;
|
||||
|
||||
g_return_if_fail(raw_event != NULL);
|
||||
|
||||
if (matrix_event == NULL) {
|
||||
equark = g_type_qname(MATRIX_EVENT_TYPE_BASE);
|
||||
} else {
|
||||
equark = g_type_qname(G_TYPE_FROM_INSTANCE((GObject*)matrix_event));
|
||||
}
|
||||
|
||||
g_signal_emit(matrix_client, matrix_client_signals[SIGNAL_EVENT], equark, room_id, raw_event, matrix_event);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_get_user_profile:
|
||||
* @client: an object implementing the #MatrixClient interface
|
||||
* @user_id: (not nullable): the user ID to get the profile for
|
||||
* @room_id: (nullable): the room ID to get the profile from, or %NULL to get the global profile
|
||||
* @error: (nullable): a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Get the profile of a user specified by @user_id. If @room_id is not %NULL, return the
|
||||
* room-specific profile. If the user’s profile is not cached yet, @error is set to
|
||||
* #MATRIX_ERROR_UNAVAILABLE.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): a #MatrixProfile object
|
||||
*/
|
||||
MatrixProfile *
|
||||
matrix_client_get_user_profile(MatrixClient *matrix_client, const gchar *user_id, const gchar *room_id, GError **error)
|
||||
{
|
||||
g_return_val_if_fail(matrix_client != NULL, NULL);
|
||||
|
||||
return MATRIX_CLIENT_GET_IFACE(matrix_client)->get_user_profile(matrix_client, user_id, room_id, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_get_user_presence:
|
||||
* @client: an object implementing the #MatrixClient interface
|
||||
* @user_id: (not nullable): the user ID to get presence info for
|
||||
* @room_id: (nullable): the room ID to get the presence info from, or %NULL to get the global
|
||||
* presence info
|
||||
* @error: (nullable): a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Get the presence state of a user specified by @user_id. If @room_id is %NULL, return the room
|
||||
* specific presence state. If the user's presence state is not cached yet, @error is set to
|
||||
* #MATRIX_ERROR_UNAVAILABLE.
|
||||
*
|
||||
* Returns: the presence of @user_id
|
||||
*/
|
||||
MatrixPresence
|
||||
matrix_client_get_user_presence(MatrixClient *matrix_client, const gchar *user_id, const gchar *room_id, GError **error)
|
||||
{
|
||||
g_return_val_if_fail(matrix_client != NULL, 0);
|
||||
|
||||
return MATRIX_CLIENT_GET_IFACE(matrix_client)->get_user_presence(matrix_client, user_id, room_id, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_get_room_by_id:
|
||||
* @client: an object implementing the #MatrixClient interface
|
||||
* @room_id: (not nullable): the room ID to get the room information for
|
||||
* @error: (nullable): a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Get a room object by the room ID specified in @room_id. If room data is not cached yet, error
|
||||
* is set to #MATRIX_ERROR_UNAVAILABLE and %NULL is returned.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): a #MatrixRoom object corresponding to @room_id
|
||||
*/
|
||||
MatrixRoom *
|
||||
matrix_client_get_room_by_id(MatrixClient *matrix_client, const gchar *room_id, GError **error)
|
||||
{
|
||||
g_return_val_if_fail(matrix_client != NULL, NULL);
|
||||
|
||||
return MATRIX_CLIENT_GET_IFACE(matrix_client)->get_room_by_id(matrix_client, room_id, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_get_room_by_alias:
|
||||
* @client: an object implementing the #MatrixClient interface
|
||||
* @room_alias: (not nullable): a room alias
|
||||
* @error: (nullable): a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Get a room object by the room alias specified in @room_alias. If room data is not cached yet,
|
||||
* @error is set to #MATRIX_ERROR_UNAVAILABLE and %NULL is returned.
|
||||
*
|
||||
* Please note that this may be a lengthy operation, especially if there are many rooms with many
|
||||
* aliases.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): a #MatrixRoom object with @room_alias
|
||||
*/
|
||||
MatrixRoom *
|
||||
matrix_client_get_room_by_alias(MatrixClient *matrix_client, const gchar *room_alias, GError **error)
|
||||
{
|
||||
g_return_val_if_fail(matrix_client != NULL, NULL);
|
||||
|
||||
return MATRIX_CLIENT_GET_IFACE(matrix_client)->get_room_by_alias(matrix_client, room_alias, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_send:
|
||||
* @client: a #MatrixClient
|
||||
* @room_id: the room to send the event to
|
||||
* @evt: the event to send
|
||||
* @callback: (scope async): the callback function to call when the request is finished
|
||||
* @user_data: user data to pass to the callback function
|
||||
* @txn_id: the transaction ID to be used during this request. In case of a state event, it will be
|
||||
* untouched
|
||||
* @error: (nullable): a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Send an event to the given room. This should use the correct endpoint (e.g. the
|
||||
* `/room/{roomId}/send` or the `/room/{roomId}/state` API in case of a HTTP connection) depending
|
||||
* on the event: if the event has a state key (there is a state_key key in the generated JSON),
|
||||
* even if an empty one, it will use the latter.
|
||||
*/
|
||||
void
|
||||
matrix_client_send(MatrixClient *matrix_client,
|
||||
const gchar *room_id,
|
||||
MatrixEventBase *evt,
|
||||
gulong txn_id,
|
||||
MatrixClientSendCallback cb,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
g_return_if_fail(matrix_client != NULL);
|
||||
|
||||
MATRIX_CLIENT_GET_IFACE(matrix_client)->send(matrix_client, room_id, evt, cb, user_data, txn_id, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_save_state:
|
||||
* @client: an object implementing the #MatrixClient interface
|
||||
* @filename: the filename to save state info to
|
||||
* @error: a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Save the client state to a file. This may include server addresses and credentials, too, so a
|
||||
* secure storage is highly recommended.
|
||||
*/
|
||||
void
|
||||
matrix_client_save_state(MatrixClient *matrix_client, const gchar *filename, GError **error)
|
||||
{
|
||||
g_return_if_fail(matrix_client != NULL);
|
||||
|
||||
MATRIX_CLIENT_GET_IFACE(matrix_client)->save_state(matrix_client, filename, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_load_state:
|
||||
* @client: an object implementing the #MatrixClient interface
|
||||
* @filename: the name of the file to load state from
|
||||
* @error: (nullable): a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Load the state of the client, as saved by matrix_client_save_state().
|
||||
*/
|
||||
void
|
||||
matrix_client_load_state(MatrixClient *matrix_client, const gchar *filename, GError **error)
|
||||
{
|
||||
g_return_if_fail(matrix_client != NULL);
|
||||
|
||||
MATRIX_CLIENT_GET_IFACE(matrix_client)->load_state(matrix_client, filename, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_client_real_login_finished(MatrixClient *matrix_client, gboolean success)
|
||||
{}
|
||||
|
||||
static void
|
||||
matrix_client_real_event(MatrixClient *matrix_client, const gchar *room_id, JsonNode *raw_event, MatrixEventBase *matrix_event)
|
||||
{
|
||||
g_return_if_fail(raw_event != NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_client_default_init(MatrixClientInterface *iface)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
if (!initialized) {
|
||||
initialized = TRUE;
|
||||
iface->login_finished = matrix_client_real_login_finished;
|
||||
iface->event = matrix_client_real_event;
|
||||
/**
|
||||
* MatrixClient::login-finished:
|
||||
* @client: the #MatrixClient that emitted the signal
|
||||
* @success: if %TRUE, login was successful
|
||||
*
|
||||
* This signal is a sign for a finished login request.
|
||||
*
|
||||
* Implementations are responsible for emitting this signal when they get a response for a
|
||||
* login request.
|
||||
*/
|
||||
matrix_client_signals[SIGNAL_LOGIN_FINISHED] = g_signal_new(
|
||||
"login-finished",
|
||||
MATRIX_TYPE_CLIENT,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
G_STRUCT_OFFSET(MatrixClientInterface, login_finished),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__BOOLEAN,
|
||||
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
||||
|
||||
/**
|
||||
* MatrixClient::event:
|
||||
* @client: the #MatrixClient that emitted the signal
|
||||
* @room_id: the ID of the room associated with this event
|
||||
* @raw_event: the raw event as a JSON object
|
||||
* @matrix_event: the event as a #MatrixEventBase derived object
|
||||
*
|
||||
* This signal is a sign of an incoming event.
|
||||
*
|
||||
* It gets emitted for every event, regardless if it is handled by other event signals,
|
||||
* before other signals.
|
||||
*
|
||||
* Implementations are responsible for emitting this signal when any kind of event arrives
|
||||
* from the event stream or the history.
|
||||
*/
|
||||
matrix_client_signals[SIGNAL_EVENT] = g_signal_new(
|
||||
"event",
|
||||
MATRIX_TYPE_CLIENT,
|
||||
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
|
||||
G_STRUCT_OFFSET(MatrixClientInterface, event),
|
||||
NULL, NULL,
|
||||
_matrix_marshal_VOID__STRING_BOXED_OBJECT,
|
||||
G_TYPE_NONE, 3, G_TYPE_STRING, JSON_TYPE_NODE, MATRIX_EVENT_TYPE_BASE);
|
||||
|
||||
/**
|
||||
* MatrixClient::polling-started:
|
||||
* @client: the #MatrixClient that emitted the signal
|
||||
*
|
||||
* This signal is emitted when polling is started.
|
||||
*/
|
||||
matrix_client_signals[SIGNAL_POLLING_STARTED] = g_signal_new(
|
||||
"polling-started",
|
||||
MATRIX_TYPE_CLIENT,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
/**
|
||||
* MatrixClient::polling-stopped:
|
||||
* @client: the object that sent the signal
|
||||
* @error: gets set to an actual error if polling is stopped due to one
|
||||
*
|
||||
* This signal gets invoked when polling is stopped due to any reason.
|
||||
*/
|
||||
matrix_client_signals[SIGNAL_POLLING_STOPPED] = g_signal_new(
|
||||
"polling-stopped",
|
||||
MATRIX_TYPE_CLIENT,
|
||||
G_SIGNAL_RUN_LAST,
|
||||
0,
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__BOXED,
|
||||
G_TYPE_NONE, 1, G_TYPE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_connect_event:
|
||||
* @client: a #MatrixClient
|
||||
* @event_gtype: the #GType of a #MatrixEventBase derived type
|
||||
* @callback: (scope async): the callback function to connect
|
||||
* @user_data: user data passed to the callback function
|
||||
* @destroy_notify: function to call on @user_data when it can be destroyed
|
||||
*
|
||||
* Connect a handler for events. If @event_gtype is #MATRIX_EVENT_TYPE_BASE, all events will be
|
||||
* sent to the callback function, otherwise only events that match the specified event type.
|
||||
*
|
||||
* If @event_gtype is not derived from #MatrixEventBase, @callback won’t get connected.
|
||||
*/
|
||||
void
|
||||
matrix_client_connect_event(MatrixClient *client,
|
||||
GType event_gtype,
|
||||
MatrixClientEventCallback callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify destroy_notify)
|
||||
{
|
||||
GClosure *closure;
|
||||
GQuark equark;
|
||||
MatrixEventBaseClass *event_class = MATRIX_EVENT_BASE_CLASS(
|
||||
g_type_class_ref(event_gtype));
|
||||
guint event_signal_id = g_signal_lookup("event", MATRIX_TYPE_CLIENT);
|
||||
|
||||
if (!MATRIX_EVENT_IS_BASE_CLASS(event_class)) {
|
||||
g_warning("Trying to connect to a type that is not derived from MatrixEvent");
|
||||
g_type_class_unref(event_class);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
g_type_class_unref(event_class);
|
||||
equark = g_type_qname(event_gtype);
|
||||
|
||||
closure = g_closure_ref(g_cclosure_new(G_CALLBACK(callback),
|
||||
user_data,
|
||||
(GClosureNotify)destroy_notify));
|
||||
g_closure_set_marshal(closure,
|
||||
_matrix_marshal_VOID__STRING_BOXED_OBJECT);
|
||||
g_closure_sink(closure);
|
||||
|
||||
g_signal_connect_closure_by_id(client,
|
||||
event_signal_id, equark,
|
||||
closure, FALSE);
|
||||
}
|
@ -1,127 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_CLIENT_H__
|
||||
# define __MATRIX_GLIB_SDK_CLIENT_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-enumtypes.h"
|
||||
# include "matrix-profile.h"
|
||||
# include "matrix-room.h"
|
||||
# include "matrix-event-base.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# define MATRIX_TYPE_CLIENT matrix_client_get_type()
|
||||
G_DECLARE_INTERFACE(MatrixClient, matrix_client, MATRIX, CLIENT, GObject)
|
||||
|
||||
typedef void (*MatrixClientSendCallback)(MatrixClient *client, const gchar *event_id, GError *error, void *user_data);
|
||||
typedef void (*MatrixClientEventCallback)(MatrixClient *client, const gchar *room_id, JsonNode *raw_event, MatrixEventBase *matrix_event, void *user_data);
|
||||
|
||||
struct _MatrixClientInterface {
|
||||
GTypeInterface parent_iface;
|
||||
void (*login_with_password)(MatrixClient *client,
|
||||
const gchar *username,
|
||||
const gchar *password,
|
||||
GError **error);
|
||||
void (*register_with_password)(MatrixClient *client,
|
||||
const gchar *username,
|
||||
const gchar *password,
|
||||
GError **error);
|
||||
void (*logout)(MatrixClient *client, GError **error);
|
||||
void (*begin_polling)(MatrixClient *client, GError **error);
|
||||
void (*stop_polling)(MatrixClient *client, gboolean cancel_ongoing, GError **error);
|
||||
MatrixProfile *(*get_user_profile)(MatrixClient *client,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
GError **error);
|
||||
MatrixPresence (*get_user_presence)(MatrixClient *client,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
GError **error);
|
||||
MatrixRoom *(*get_room_by_id)(MatrixClient *client, const gchar *room_id, GError **error);
|
||||
MatrixRoom *(*get_room_by_alias)(MatrixClient *client,
|
||||
const gchar *room_alias,
|
||||
GError **error);
|
||||
void (*send)(MatrixClient *client,
|
||||
const gchar *room_id,
|
||||
MatrixEventBase *evt,
|
||||
MatrixClientSendCallback callback, void *user_data,
|
||||
gulong txn_id,
|
||||
GError **error);
|
||||
void (*save_state)(MatrixClient *client,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
void (*load_state)(MatrixClient *client,
|
||||
const gchar *filename,
|
||||
GError **error);
|
||||
void (*login_finished)(MatrixClient *client, gboolean success);
|
||||
void (*event)(MatrixClient *client,
|
||||
const gchar *room_id,
|
||||
JsonNode *raw_event,
|
||||
MatrixEventBase *matrix_event);
|
||||
};
|
||||
|
||||
void matrix_client_login_with_password(MatrixClient *client,
|
||||
const gchar *username,
|
||||
const gchar *password,
|
||||
GError **error);
|
||||
void matrix_client_register_with_password(MatrixClient *client,
|
||||
const gchar *username,
|
||||
const gchar *password,
|
||||
GError **error);
|
||||
void matrix_client_logout(MatrixClient *client, GError **error);
|
||||
void matrix_client_begin_polling(MatrixClient *client, GError **error);
|
||||
void matrix_client_stop_polling(MatrixClient *client, gboolean cancel_ongoing, GError **error);
|
||||
void matrix_client_emit_login_finished(MatrixClient *client, gboolean success);
|
||||
void matrix_client_incoming_event(MatrixClient *client,
|
||||
const gchar *room_id,
|
||||
JsonNode *raw_event,
|
||||
MatrixEventBase *matrix_event);
|
||||
void matrix_client_connect_event(MatrixClient *client,
|
||||
GType event_gtype,
|
||||
MatrixClientEventCallback callback,
|
||||
gpointer user_data,
|
||||
GDestroyNotify destroy_notify);
|
||||
MatrixProfile *matrix_client_get_user_profile(MatrixClient *client,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
GError **error);
|
||||
MatrixPresence matrix_client_get_user_presence(MatrixClient *client,
|
||||
const gchar *user_id,
|
||||
const gchar *room_id,
|
||||
GError **error);
|
||||
MatrixRoom *matrix_client_get_room_by_id(MatrixClient *client,
|
||||
const gchar *room_id,
|
||||
GError **error);
|
||||
MatrixRoom *matrix_client_get_room_by_alias(MatrixClient *client,
|
||||
const gchar *room_alias,
|
||||
GError **error);
|
||||
void matrix_client_send(MatrixClient *client,
|
||||
const gchar *room_id,
|
||||
MatrixEventBase *evt,
|
||||
gulong txn_id,
|
||||
MatrixClientSendCallback callback,
|
||||
gpointer user_data,
|
||||
GError **error);
|
||||
void matrix_client_save_state(MatrixClient *client, const gchar *filename, GError **error);
|
||||
void matrix_client_load_state(MatrixClient *client, const gchar *filename, GError **error);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /*__MATRIX_GLIB_SDK_CLIENT_H__ */
|
169
src/matrix-client.vala
Normal file
169
src/matrix-client.vala
Normal file
@ -0,0 +1,169 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base interface for client communication with a Matrix.org
|
||||
* homeserver
|
||||
*/
|
||||
public interface Matrix.Client : GLib.Object {
|
||||
/**
|
||||
* This signal is a sign for a finished login request.
|
||||
*
|
||||
* Implementations are responsible for emitting this signal when
|
||||
* they get a response for a login request.
|
||||
*
|
||||
* @param success if %TRUE, login was successful
|
||||
*/
|
||||
public virtual signal void
|
||||
login_finished(bool success)
|
||||
{}
|
||||
|
||||
/**
|
||||
* This signal is a sign of an incoming event. It gets emitted for
|
||||
* every signal, regardless if it is handled by other event
|
||||
* signals, before other signals.
|
||||
*
|
||||
* Implementations are responsible for emitting this signal when
|
||||
* any kind of event arrives from the event stream or the history.
|
||||
*
|
||||
* @param room_id the ID of the room associated with this event
|
||||
* @param raw_event the raw event as a JSON object
|
||||
* @param matrix_event the event as a {@link Matrix.Event}
|
||||
*/
|
||||
[Signal (detailed=true)]
|
||||
public virtual signal void
|
||||
@event(string? room_id, Json.Node raw_event, Matrix.Event matrix_event)
|
||||
{}
|
||||
|
||||
/**
|
||||
* Callback function delegate for the event signal.
|
||||
*
|
||||
* @param room_id the room the event associated with
|
||||
* @param raw_event the event as a raw JSON object
|
||||
* @param matrix_event the event as a Matrix.Event object
|
||||
*/
|
||||
public delegate void
|
||||
EventCallback(Matrix.Client client,
|
||||
string? room_id,
|
||||
Json.Node raw_event,
|
||||
Matrix.Event matrix_event);
|
||||
|
||||
/**
|
||||
* Authenticate with the Matrix.org server with a username and
|
||||
* password.
|
||||
*
|
||||
* @param username the username to login with
|
||||
* @param password the password to use
|
||||
*/
|
||||
public abstract void
|
||||
login_with_password(string username,
|
||||
string password)
|
||||
throws Matrix.Error;
|
||||
|
||||
/**
|
||||
* Register @username with the homeserver as a normal user.
|
||||
*
|
||||
* Upon success, the user is registered and authenticated.
|
||||
*
|
||||
* Implementations must emit the login-finished signal when a
|
||||
* response arrives.
|
||||
*
|
||||
* This method registers a normal user account. If you want to
|
||||
* register a different kind of user, use
|
||||
* matrix_api_register_account().
|
||||
*
|
||||
* @param username the username to register. If omitted, the
|
||||
* server will generate one
|
||||
* @param password the password to use with the registration
|
||||
*/
|
||||
public abstract void
|
||||
register_with_password(string? username,
|
||||
string password)
|
||||
throws Matrix.Error;
|
||||
|
||||
/**
|
||||
* Logout from the homeserver. As Matrix.org doesn’t have such a
|
||||
* concept, this cancels all ongoing requests and clears the
|
||||
* authentication data (e.g. tokens).
|
||||
*/
|
||||
public abstract void
|
||||
logout()
|
||||
throws Matrix.Error;
|
||||
|
||||
/**
|
||||
* Begin polling the event stream.
|
||||
*/
|
||||
public abstract void
|
||||
begin_polling()
|
||||
throws Matrix.Error;
|
||||
|
||||
/**
|
||||
* Stop polling the event stream. If @param cancel_ongoing is
|
||||
* {{{true}}}, ongoing requests will be cancelled, too.
|
||||
*
|
||||
* @param cancel_ongoing if {{{true}}}, ongoing requests will be
|
||||
* cancelled, too
|
||||
*/
|
||||
public abstract void
|
||||
stop_polling(bool cancel_ongoing)
|
||||
throws Matrix.Error;
|
||||
|
||||
/**
|
||||
* Convenience function to emits the login-finished signal.
|
||||
*
|
||||
* @param success set to {{{true}}} if login was successful
|
||||
*/
|
||||
public void
|
||||
emit_login_finished(bool success)
|
||||
{
|
||||
login_finished(success);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits the #MatrixClient::event signal.
|
||||
*
|
||||
* @param room_id the room this event is associated with
|
||||
* @param raw_event the raw event
|
||||
* @param matrix_event the event as a Matrix.Event
|
||||
*/
|
||||
public void
|
||||
incoming_event(string? room_id,
|
||||
Json.Node raw_event,
|
||||
Matrix.Event matrix_event)
|
||||
{
|
||||
Quark equark = matrix_event.get_type().qname();
|
||||
|
||||
this.@event[equark.to_string()](room_id, raw_event, matrix_event);
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect a handler for events. If @param event_gtype is
|
||||
* Matrix.Event, all events will be sent to the callback function,
|
||||
* otherwise only events that match the specified event type.
|
||||
*
|
||||
* If @event_gtype is not derived from
|
||||
* {@link Matrix.Event}, @param callback won’t get connected.
|
||||
*
|
||||
* @param event_gtype the {@link GLib.Type} of a
|
||||
* {@link Matrix.Event} derivative
|
||||
* @param callback the allback function to connect
|
||||
*/
|
||||
public extern void
|
||||
connect_event(GLib.Type event_gtype,
|
||||
owned EventCallback event_callback);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,236 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_COMPACTS_H__
|
||||
# define __MATRIX_GLIB_SDK_COMPACTS_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include <json-glib/json-glib.h>
|
||||
|
||||
# include "matrix-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# define MATRIX_TYPE_JSON_COMPACT matrix_json_compact_get_type()
|
||||
# define MATRIX_JSON_COMPACT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), MATRIX_TYPE_JSON_COMPACT, MatrixJsonCompact))
|
||||
# define MATRIX_JSON_COMPACT_CLASS(c) (G_TYPE_CHECK_CLASS_CAST((c), MATRIX_TYPE_JSON_COMPACT, MatrixJsonCompactClass))
|
||||
# define MATRIX_IS_JSON_COMPACT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_TYPE_JSON_COMPACT))
|
||||
# define MATRIX_IS_JSON_COMPACT_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE((c), MATRIX_TYPE_JSON_COMPACT))
|
||||
# define MATRIX_JSON_COMPACT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MATRIX_TYPE_JSON_COMPACT, MatrixJsonCompactClass))
|
||||
|
||||
typedef struct _MatrixJsonCompactClass MatrixJsonCompactClass;
|
||||
typedef struct _MatrixJsonCompact MatrixJsonCompact;
|
||||
void matrix_json_compact_unref(MatrixJsonCompact *json_compact);
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(MatrixJsonCompact, matrix_json_compact_unref)
|
||||
|
||||
struct _MatrixJsonCompact {
|
||||
GTypeInstance parent_instance;
|
||||
|
||||
/* < private > */
|
||||
volatile int refcount;
|
||||
};
|
||||
|
||||
struct _MatrixJsonCompactClass {
|
||||
GTypeClass parent_class;
|
||||
|
||||
void (*finalize)(MatrixJsonCompact *json_compact);
|
||||
JsonNode *(*get_json_node)(MatrixJsonCompact *json_compact, GError **error);
|
||||
};
|
||||
|
||||
GType matrix_json_compact_get_type(void) G_GNUC_CONST;
|
||||
MatrixJsonCompact *matrix_json_compact_construct(GType object_type);
|
||||
MatrixJsonCompact *matrix_json_compact_ref(MatrixJsonCompact *json_compact);
|
||||
JsonNode *matrix_json_compact_get_json_node(MatrixJsonCompact *json_compact, GError **error);
|
||||
gchar *matrix_json_compact_get_json_data(MatrixJsonCompact *json_compact, gsize *datalen, GError **error);
|
||||
|
||||
#define MATRIX_TYPE_FILTER_RULES matrix_filter_rules_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixFilterRules, matrix_filter_rules, MATRIX, FILTER_RULES, MatrixJsonCompact)
|
||||
|
||||
struct _MatrixFilterRulesClass {
|
||||
MatrixJsonCompactClass parent_class;
|
||||
};
|
||||
|
||||
MatrixFilterRules *matrix_filter_rules_new(void);
|
||||
MatrixFilterRules *matrix_filter_rules_construct(GType object_type);
|
||||
void matrix_filter_rules_set_limit(MatrixFilterRules *filter_rules, guint limit);
|
||||
guint matrix_filter_rules_get_limit(MatrixFilterRules *filter_rules);
|
||||
void matrix_filter_rules_set_types(MatrixFilterRules *filter_rules, gchar **types, int n_types);
|
||||
gchar **matrix_filter_rules_get_types(MatrixFilterRules *filter_rules, int *n_types);
|
||||
void matrix_filter_rules_set_excluded_types(MatrixFilterRules *filter_rules, gchar **excluded_types, int n_excluded_types);
|
||||
gchar **matrix_filter_rules_get_excluded_types(MatrixFilterRules *filter_rules, int *n_excluded_types);
|
||||
void matrix_filter_rules_set_senders(MatrixFilterRules *filter_rules, gchar **senders, int n_senders);
|
||||
gchar **matrix_filter_rules_get_senders(MatrixFilterRules *filter_rules, int *n_senders);
|
||||
void matrix_filter_rules_set_excluded_senders(MatrixFilterRules *filter_rules, gchar **excluded_senders, int n_excluded_senders);
|
||||
gchar **matrix_filter_rules_get_excluded_senders(MatrixFilterRules *filter_rules, int *n_excluded_senders);
|
||||
void matrix_filter_rules_set_rooms(MatrixFilterRules *filter_rules, gchar **rooms, int n_rooms);
|
||||
gchar **matrix_filter_rules_get_rooms(MatrixFilterRules *filter_rules, int *n_rooms);
|
||||
void matrix_filter_rules_set_excluded_rooms(MatrixFilterRules *filter_rules, gchar **excluded_rooms, int n_excluded_rooms);
|
||||
gchar **matrix_filter_rules_get_excluded_rooms(MatrixFilterRules *filter_rules, int *n_excluded_rooms);
|
||||
|
||||
# define MATRIX_TYPE_ROOM_FILTER matrix_room_filter_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixRoomFilter, matrix_room_filter, MATRIX, ROOM_FILTER, MatrixJsonCompact)
|
||||
|
||||
struct _MatrixRoomFilterClass {
|
||||
MatrixJsonCompactClass parent_class;
|
||||
};
|
||||
|
||||
MatrixRoomFilter *matrix_room_filter_new(void);
|
||||
gboolean matrix_room_filter_get_include_leave(MatrixRoomFilter *room_filter);
|
||||
void matrix_room_filter_set_include_leave(MatrixRoomFilter *room_filter, gboolean include_leave);
|
||||
MatrixFilterRules *matrix_room_filter_get_ephemeral(MatrixRoomFilter *room_filter);
|
||||
void matrix_room_filter_set_ephemeral(MatrixRoomFilter *room_filter, MatrixFilterRules *ephemeral_rules);
|
||||
MatrixFilterRules *matrix_room_filter_get_state(MatrixRoomFilter *room_filter);
|
||||
void matrix_room_filter_set_state(MatrixRoomFilter *room_filter, MatrixFilterRules *state_rules);
|
||||
MatrixFilterRules *matrix_room_filter_get_timeline(MatrixRoomFilter *room_filter);
|
||||
void matrix_room_filter_set_timeline(MatrixRoomFilter *room_filter, MatrixFilterRules *timeline_rules);
|
||||
|
||||
# define MATRIX_TYPE_FILTER matrix_filter_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixFilter, matrix_filter, MATRIX, FILTER, MatrixJsonCompact)
|
||||
|
||||
struct _MatrixFilterClass {
|
||||
MatrixJsonCompactClass parent_class;
|
||||
};
|
||||
|
||||
MatrixFilter *matrix_filter_new(void);
|
||||
gchar **matrix_filter_get_event_fields(MatrixFilter *filter, int *n_event_fields);
|
||||
void matrix_filter_set_event_fields(MatrixFilter *filter, gchar **event_fields, int n_event_fields);
|
||||
MatrixEventFormat matrix_filter_get_event_format(MatrixFilter *filter);
|
||||
void matrix_filter_set_event_format(MatrixFilter *filter, MatrixEventFormat event_format);
|
||||
MatrixFilterRules *matrix_filter_get_presence_filter(MatrixFilter *filter);
|
||||
void matrix_filter_set_presence_filter(MatrixFilter *filter, MatrixFilterRules *presence_filter);
|
||||
MatrixRoomFilter *matrix_filter_get_room_filter(MatrixFilter *filter);
|
||||
void matrix_filter_set_room_filter(MatrixFilter *filter, MatrixRoomFilter *room_filter);
|
||||
|
||||
# define MATRIX_TYPE_3PID_CREDENTIAL matrix_3pid_credential_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(Matrix3PidCredential, matrix_3pid_credential, MATRIX, 3PID_CREDENTIAL, MatrixJsonCompact)
|
||||
|
||||
struct _Matrix3PidCredentialClass {
|
||||
MatrixJsonCompactClass parent_class;
|
||||
};
|
||||
|
||||
Matrix3PidCredential *matrix_3pid_credential_new(void);
|
||||
const gchar *matrix_3pid_credential_get_id_server(Matrix3PidCredential *credential);
|
||||
void matrix_3pid_credential_set_id_server(Matrix3PidCredential *credential, const gchar *id_server);
|
||||
const gchar *matrix_3pid_credential_get_session_id(Matrix3PidCredential *credential);
|
||||
void matrix_3pid_credential_set_session_id(Matrix3PidCredential *credential, const gchar *session_id);
|
||||
const gchar *matrix_3pid_credential_get_client_secret(Matrix3PidCredential *credential);
|
||||
void matrix_3pid_credential_set_client_secret(Matrix3PidCredential *credential, const gchar *client_secret);
|
||||
|
||||
# define MATRIX_TYPE_PUSHER matrix_pusher_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixPusher, matrix_pusher, MATRIX, PUSHER, MatrixJsonCompact)
|
||||
|
||||
struct _MatrixPusherClass {
|
||||
MatrixJsonCompactClass parent_class;
|
||||
};
|
||||
|
||||
MatrixPusher *matrix_pusher_new(void);
|
||||
const gchar *matrix_pusher_get_device_display_name(MatrixPusher *pusher);
|
||||
void matrix_pusher_set_device_display_name(MatrixPusher *pusher, const gchar *device_display_name);
|
||||
const gchar *matrix_pusher_get_app_display_name(MatrixPusher *pusher);
|
||||
void matrix_pusher_set_app_display_name(MatrixPusher *pusher, const gchar *app_display_name);
|
||||
const gchar *matrix_pusher_get_app_id(MatrixPusher *pusher);
|
||||
void matrix_pusher_set_app_id(MatrixPusher *pusher, const gchar *app_id);
|
||||
gboolean matrix_pusher_get_append(MatrixPusher *pusher);
|
||||
void matrix_pusher_set_append(MatrixPusher *pusher, gboolean append);
|
||||
const gchar *matrix_pusher_get_kind(MatrixPusher *pusher);
|
||||
void matrix_pusher_set_kind(MatrixPusher *pusher, const gchar *kind);
|
||||
const gchar *matrix_pusher_get_lang(MatrixPusher *pusher);
|
||||
void matrix_pusher_set_lang(MatrixPusher *pusher, const gchar *lang);
|
||||
const gchar *matrix_pusher_get_profile_tag(MatrixPusher *pusher);
|
||||
void matrix_pusher_set_profile_tag(MatrixPusher *pusher, const gchar *profile_tag);
|
||||
const gchar *matrix_pusher_get_pushkey(MatrixPusher *pusher);
|
||||
void matrix_pusher_set_pushkey(MatrixPusher *pusher, const gchar *pushkey);
|
||||
JsonNode *matrix_pusher_get_data(MatrixPusher *pusher);
|
||||
void matrix_pusher_set_data(MatrixPusher *pusher, JsonNode *data);
|
||||
|
||||
# define MATRIX_TYPE_EVENT_CONTEXT matrix_event_context_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventContext, matrix_event_context, MATRIX, EVENT_CONTEXT, MatrixJsonCompact)
|
||||
|
||||
struct _MatrixEventContextClass {
|
||||
MatrixJsonCompactClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventContext *matrix_event_context_new (void);
|
||||
gint matrix_event_context_get_before_limit (MatrixEventContext *event_context);
|
||||
void matrix_event_context_set_before_limit (MatrixEventContext *event_context, gint before_limit);
|
||||
gint matrix_event_context_get_after_limit (MatrixEventContext *event_context);
|
||||
void matrix_event_context_set_after_limit (MatrixEventContext *event_context, gint after_limit);
|
||||
gboolean matrix_event_context_get_include_profile (MatrixEventContext *event_context);
|
||||
void matrix_event_context_set_include_profile (MatrixEventContext *event_context, gboolean include_profile);
|
||||
|
||||
# define MATRIX_TYPE_SEARCH_GROUPING matrix_search_grouping_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixSearchGrouping, matrix_search_grouping, MATRIX, SEARCH_GROUPING, MatrixJsonCompact)
|
||||
|
||||
struct _MatrixSearchGroupingClass {
|
||||
MatrixJsonCompactClass parent_class;
|
||||
};
|
||||
|
||||
MatrixSearchGrouping *matrix_search_grouping_new(void);
|
||||
MatrixSearchGroupBy matrix_search_grouping_get_key(MatrixSearchGrouping *search_grouping);
|
||||
void matrix_search_grouping_set_key(MatrixSearchGrouping *search_grouping, MatrixSearchGroupBy key);
|
||||
|
||||
# define MATRIX_TYPE_SEARCH_GROUPINGS matrix_search_groupings_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixSearchGroupings, matrix_search_groupings, MATRIX, SEARCH_GROUPINGS, MatrixJsonCompact)
|
||||
|
||||
struct _MatrixSearchGroupingsClass {
|
||||
MatrixJsonCompactClass parent_class;
|
||||
};
|
||||
|
||||
MatrixSearchGroupings *matrix_search_groupings_new(void);
|
||||
MatrixSearchGrouping **matrix_search_groupings_get_group_by(MatrixSearchGroupings *search_groupings, int *n_group_by);
|
||||
void matrix_search_groupings_set_group_by(MatrixSearchGroupings *search_groupings, MatrixSearchGrouping **group_by, int n_group_by);
|
||||
|
||||
# define MATRIX_TYPE_SEARCH_ROOM_EVENTS matrix_search_room_events_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixSearchRoomEvents, matrix_search_room_events, MATRIX, SEARCH_ROOM_EVENTS, MatrixJsonCompact)
|
||||
|
||||
struct _MatrixSearchRoomEventsClass {
|
||||
MatrixJsonCompactClass parent_class;
|
||||
};
|
||||
|
||||
MatrixSearchRoomEvents *matrix_search_room_events_new(void);
|
||||
MatrixSearchOrder matrix_search_room_events_get_order_by(MatrixSearchRoomEvents *search_room_events);
|
||||
void matrix_search_room_events_set_order_by(MatrixSearchRoomEvents *search_room_events, MatrixSearchOrder order_by);
|
||||
MatrixSearchKey *matrix_search_room_events_get_keys(MatrixSearchRoomEvents *search_room_events, guint *n_keys);
|
||||
void matrix_search_room_events_set_keys(MatrixSearchRoomEvents *search_room_events, MatrixSearchKey *keys, guint n_keys);
|
||||
MatrixEventContext *matrix_search_room_events_get_event_context(MatrixSearchRoomEvents *search_room_events);
|
||||
void matrix_search_room_events_set_event_context(MatrixSearchRoomEvents *search_room_events, MatrixEventContext *event_context);
|
||||
gboolean matrix_search_room_events_get_include_state(MatrixSearchRoomEvents *search_room_events);
|
||||
void matrix_search_room_events_set_include_state(MatrixSearchRoomEvents *search_room_events, gboolean include_state);
|
||||
const gchar *matrix_search_room_events_get_filter_id(MatrixSearchRoomEvents *search_room_events);
|
||||
void matrix_search_room_events_set_filter_id(MatrixSearchRoomEvents *search_room_events, const gchar *filter_id);
|
||||
MatrixFilter *matrix_search_room_events_get_filter(MatrixSearchRoomEvents *search_room_events);
|
||||
void matrix_search_room_events_set_filter(MatrixSearchRoomEvents *search_room_events, MatrixFilter *filter);
|
||||
const gchar *matrix_search_room_events_get_search_term(MatrixSearchRoomEvents *search_room_events);
|
||||
void matrix_search_room_events_set_search_term(MatrixSearchRoomEvents *search_room_events, const gchar *search_term);
|
||||
MatrixSearchGroupings *matrix_search_room_events_get_groupings(MatrixSearchRoomEvents *search_room_events);
|
||||
void matrix_search_room_events_set_groupings(MatrixSearchRoomEvents *search_room_events, MatrixSearchGroupings *groupings);
|
||||
|
||||
# define MATRIX_TYPE_SEARCH_CATEGORIES matrix_search_categories_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixSearchCategories, matrix_search_categories, MATRIX, SEARCH_CATEGORIES, MatrixJsonCompact)
|
||||
|
||||
struct _MatrixSearchCategoriesClass {
|
||||
MatrixJsonCompactClass parent_class;
|
||||
};
|
||||
|
||||
MatrixSearchCategories *matrix_search_categories_new(void);
|
||||
MatrixSearchRoomEvents *matrix_search_categories_get_room_events(MatrixSearchCategories *search_categories);
|
||||
void matrix_search_categories_set_room_events(MatrixSearchCategories *search_categories, MatrixSearchRoomEvents *room_events);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_COMPACTS_H__ */
|
941
src/matrix-compacts.vala
Normal file
941
src/matrix-compacts.vala
Normal file
@ -0,0 +1,941 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
namespace Matrix {
|
||||
/**
|
||||
* Abstract parent class for classes that can be saved to JSON.
|
||||
*/
|
||||
public abstract class JsonCompact {
|
||||
public abstract Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error;
|
||||
|
||||
public string
|
||||
get_json_data(out size_t datalen)
|
||||
throws Matrix.Error
|
||||
{
|
||||
var generator = new Json.Generator();
|
||||
|
||||
generator.set_root(get_json_node());
|
||||
|
||||
return generator.to_data(out datalen);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to hold a filter.
|
||||
*/
|
||||
public class Filter : JsonCompact {
|
||||
private List<string>? _event_fields;
|
||||
|
||||
/**
|
||||
* The event fields to include in the filtered events.
|
||||
*/
|
||||
public List<string>? event_fields {
|
||||
get {
|
||||
return _event_fields;
|
||||
}
|
||||
|
||||
set {
|
||||
_event_fields = value.copy();
|
||||
}
|
||||
|
||||
default = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The desired event format for the filtered events (e.g. for
|
||||
* matrix_api_sync())
|
||||
*/
|
||||
public EventFormat event_format {
|
||||
get; set;
|
||||
default = Matrix.EventFormat.CLIENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* A filtering ruleset for presence events.
|
||||
*/
|
||||
public FilterRules? presence_filter { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* A filtering ruleset for room events.
|
||||
*/
|
||||
public RoomFilter? room_filter { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* Get the filter as a JSON node.
|
||||
*/
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
var builder = new Json.Builder();
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
builder.set_member_name("event_fields");
|
||||
builder.begin_array();
|
||||
|
||||
foreach (var entry in event_fields) {
|
||||
builder.add_string_value(entry);
|
||||
}
|
||||
|
||||
builder.end_array();
|
||||
|
||||
builder.set_member_name("event_format");
|
||||
builder.add_string_value(
|
||||
_g_enum_value_to_nick(typeof(EventFormat), event_format));
|
||||
|
||||
builder.set_member_name("presence");
|
||||
builder.add_value(presence_filter.get_json_node());
|
||||
|
||||
builder.set_member_name("room");
|
||||
builder.add_value(room_filter.get_json_node());
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to hold room filters.
|
||||
*/
|
||||
public class RoomFilter : JsonCompact {
|
||||
/**
|
||||
* If {{{true}}}, events for rooms that the user has left will
|
||||
* be included in the filtered event list.
|
||||
*/
|
||||
public bool include_leave { get; set; default=true; }
|
||||
|
||||
/**
|
||||
* Filtering rules for ephemeral events, i.e. events that are
|
||||
* not recorded in the room history (typing notifications,
|
||||
* receipts, etc.)
|
||||
*/
|
||||
public FilterRules? ephemeral { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* Filtering rules for state events.
|
||||
*/
|
||||
public FilterRules? state { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* Filtering rules for timeline events.
|
||||
*/
|
||||
public FilterRules? timeline { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* Get the room filters as a JSON node.
|
||||
*/
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
var builder = new Json.Builder();
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
builder.set_member_name("include_leave");
|
||||
builder.add_boolean_value(include_leave);
|
||||
|
||||
if (ephemeral != null) {
|
||||
builder.set_member_name("ephemeral");
|
||||
builder.add_value(ephemeral.get_json_node());
|
||||
}
|
||||
|
||||
if (state != null) {
|
||||
builder.set_member_name("state");
|
||||
builder.add_value(state.get_json_node());
|
||||
}
|
||||
|
||||
if (timeline != null) {
|
||||
builder.set_member_name("timeline");
|
||||
builder.add_value(timeline.get_json_node());
|
||||
}
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to hold filtering rules.
|
||||
*/
|
||||
public class FilterRules : JsonCompact {
|
||||
private List<string>? _types;
|
||||
private List<string>? _excluded_types;
|
||||
private List<string>? _senders;
|
||||
private List<string>? _excluded_senders;
|
||||
private List<string>? _rooms;
|
||||
private List<string>? _excluded_rooms;
|
||||
|
||||
/**
|
||||
* The limit of the count of returned events.
|
||||
*/
|
||||
public uint limit { get; set; }
|
||||
|
||||
/**
|
||||
* List of message types to include in the filtered result.
|
||||
*/
|
||||
public List<string>? types {
|
||||
get {
|
||||
return _types;
|
||||
}
|
||||
|
||||
set {
|
||||
_types = value.copy();
|
||||
}
|
||||
|
||||
default = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of message types to exclude from the filtered
|
||||
* result. A matching type will be excluded from the result
|
||||
* even if it is listed in the types to include.
|
||||
*/
|
||||
public List<string>? excluded_types {
|
||||
get {
|
||||
return _excluded_types;
|
||||
}
|
||||
|
||||
set {
|
||||
_excluded_types = value.copy();
|
||||
}
|
||||
|
||||
default = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of senders to include in the filtered results.
|
||||
*/
|
||||
public List<string>? senders {
|
||||
get {
|
||||
return _senders;
|
||||
}
|
||||
|
||||
set {
|
||||
_senders = value.copy();
|
||||
}
|
||||
|
||||
default = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of senders to exclude from the filtered result. A
|
||||
* matching sender will be excluded from the result even if it
|
||||
* is listed in the senders to include.
|
||||
*/
|
||||
public List<string>? excluded_senders {
|
||||
get {
|
||||
return _excluded_senders;
|
||||
}
|
||||
|
||||
set {
|
||||
_excluded_senders = value.copy();
|
||||
}
|
||||
|
||||
default = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of rooms to include in the filtered results.
|
||||
*/
|
||||
public List<string>? rooms {
|
||||
get {
|
||||
return _rooms;
|
||||
}
|
||||
|
||||
set {
|
||||
_rooms = value.copy();
|
||||
}
|
||||
|
||||
default = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of rooms to exclude from the filtered result. A
|
||||
* matching room will be excluded from the result even if it
|
||||
* is listed in the rooms to include.
|
||||
*/
|
||||
public List<string>? excluded_rooms {
|
||||
get {
|
||||
return _excluded_rooms;
|
||||
}
|
||||
|
||||
set {
|
||||
_excluded_rooms = value.copy();
|
||||
}
|
||||
|
||||
default = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filtering rules as a JSON node.
|
||||
*/
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
var builder = new Json.Builder();
|
||||
builder.begin_object();
|
||||
|
||||
builder.set_member_name("limit");
|
||||
builder.add_int_value(limit);
|
||||
|
||||
if (rooms != null) {
|
||||
builder.set_member_name("rooms");
|
||||
builder.begin_array();
|
||||
foreach (var entry in rooms) {
|
||||
builder.add_string_value(entry);
|
||||
}
|
||||
builder.end_array();
|
||||
}
|
||||
|
||||
if (excluded_rooms != null) {
|
||||
builder.set_member_name("not_rooms");
|
||||
builder.begin_array();
|
||||
foreach (var entry in excluded_rooms) {
|
||||
builder.add_string_value(entry);
|
||||
}
|
||||
builder.end_array();
|
||||
}
|
||||
|
||||
if (senders != null) {
|
||||
builder.set_member_name("senders");
|
||||
builder.begin_array();
|
||||
foreach (var entry in senders) {
|
||||
builder.add_string_value(entry);
|
||||
}
|
||||
builder.end_array();
|
||||
}
|
||||
|
||||
if (excluded_senders != null) {
|
||||
builder.set_member_name("not_senders");
|
||||
builder.begin_array();
|
||||
foreach (var entry in excluded_senders) {
|
||||
builder.add_string_value(entry);
|
||||
}
|
||||
builder.end_array();
|
||||
}
|
||||
|
||||
if (types != null) {
|
||||
builder.set_member_name("types");
|
||||
builder.begin_array();
|
||||
foreach (var entry in types) {
|
||||
builder.add_string_value(entry);
|
||||
}
|
||||
builder.end_array();
|
||||
}
|
||||
|
||||
if (excluded_types != null) {
|
||||
builder.set_member_name("not_types");
|
||||
builder.begin_array();
|
||||
foreach(var entry in types) {
|
||||
builder.add_string_value(entry);
|
||||
}
|
||||
builder.end_array();
|
||||
}
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to hold 3rd party credential related data.
|
||||
*/
|
||||
public class @3PidCredential : JsonCompact {
|
||||
/**
|
||||
* The Identity Server used for this credential.
|
||||
*/
|
||||
public string? id_server { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* The session identifier got from the Identity Server.
|
||||
*/
|
||||
public string? session_id { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* The client secret that was used in the session with the
|
||||
* Identity Server.
|
||||
*/
|
||||
public string? client_secret { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* Get 3rd party credential related data as a JSON node.
|
||||
*/
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
if ((id_server == null)
|
||||
|| (session_id == null)
|
||||
|| (client_secret == null))
|
||||
{
|
||||
throw new Matrix.Error.INCOMPLETE(
|
||||
"All fields of a 3PID credential must be filled!");
|
||||
}
|
||||
|
||||
var builder = new Json.Builder();
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
builder.set_member_name("id_server");
|
||||
builder.add_string_value(id_server);
|
||||
|
||||
builder.set_member_name("session_id");
|
||||
builder.add_string_value(session_id);
|
||||
|
||||
builder.set_member_name("client_secret");
|
||||
builder.add_string_value(client_secret);
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to hold pusher related data.
|
||||
*/
|
||||
public class Pusher : JsonCompact {
|
||||
/**
|
||||
* A device display name.
|
||||
*/
|
||||
public string? device_display_name { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* An application display name.
|
||||
*/
|
||||
public string? app_display_name { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* An application ID.
|
||||
*/
|
||||
public string? app_id { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* If {{{true}}}, the homeserver should add another pusher
|
||||
* with the given push key and app ID in addition to any
|
||||
* others with different user IDs. Otherwise, the homeserver
|
||||
* must remove any other pushers with the same App ID and
|
||||
* pushkey for different users.
|
||||
*/
|
||||
public bool append { get; set; default = true; }
|
||||
|
||||
/**
|
||||
* The kind of the pusher. {{{http}}} makes a pusher that
|
||||
* sends HTTP pokes. {{{null}}} deletes the pusher.
|
||||
*/
|
||||
public string? kind { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* The preferred language for receiving notifications,
|
||||
* e.g. {{{en}}} or {{{en-US}}}.
|
||||
*/
|
||||
public string? lang { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* A string that determines what set of device rules will be
|
||||
* matched when evaluating push rules for this pusher. It is
|
||||
* an arbitrary string. Multiple devices may use the same
|
||||
* profile tag. It is advised that when an app's data is
|
||||
* copied or restored to a different device, this value remain
|
||||
* the same. Client apps should offer ways to change the
|
||||
* profile tag, optionally copying rules from the old profile
|
||||
* tag. Maximum length is 32 bytes. If the profile tag is
|
||||
* longer than this, it will be truncated
|
||||
*/
|
||||
public string? profile_tag { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* A unique identifier for this pusher. The value you should
|
||||
* use for this is the routing or destination address
|
||||
* information for the notification, for example, the APNS
|
||||
* token for APNS or the Registration ID for GCM. If your
|
||||
* notification client has no such concept, use any unique
|
||||
* identifier. Maximum length is 512 bytes. If pushkey is
|
||||
* longer than this, it will be truncated
|
||||
*/
|
||||
public string? pushkey { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* a dictionary of information for the pusher implementation
|
||||
* itself. For example, if kind is {{{http}}}, this should
|
||||
* contain an {{{url}}} member, which is the URL to use to
|
||||
* send notifications to. This function creates a deep copy of
|
||||
* the data, so it can be freed after this call.
|
||||
*/
|
||||
public Json.Node? data { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* Get the pusher data as a JSON node.
|
||||
*/
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
if ((device_display_name == null)
|
||||
|| (app_display_name == null)
|
||||
|| (app_id == null)
|
||||
|| (data == null)
|
||||
|| (kind == null)
|
||||
|| (lang == null)
|
||||
|| (profile_tag == null)
|
||||
|| (pushkey == null)) {
|
||||
throw new Matrix.Error.INCOMPLETE("Pusher data incomplete");
|
||||
}
|
||||
|
||||
var builder = new Json.Builder();
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
builder.set_member_name("device_display_name");
|
||||
builder.add_string_value(device_display_name);
|
||||
|
||||
builder.set_member_name("app_display_name");
|
||||
builder.add_string_value(app_display_name);
|
||||
|
||||
builder.set_member_name("app_id");
|
||||
builder.add_string_value(app_id);
|
||||
|
||||
builder.set_member_name("append");
|
||||
builder.add_boolean_value(append);
|
||||
|
||||
builder.set_member_name("kind");
|
||||
builder.add_string_value(kind);
|
||||
|
||||
builder.set_member_name("lang");
|
||||
builder.add_string_value(lang);
|
||||
|
||||
builder.set_member_name("profile_tag");
|
||||
builder.add_string_value(profile_tag);
|
||||
|
||||
builder.set_member_name("pushkey");
|
||||
builder.add_string_value(pushkey);
|
||||
|
||||
builder.set_member_name("data");
|
||||
builder.add_value(data);
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to hold unsigned event data, like event age, redact
|
||||
* reason or a transaction ID.
|
||||
*/
|
||||
public class UnsignedEventData : JsonCompact {
|
||||
/**
|
||||
* The age of the event, in seconds.
|
||||
*/
|
||||
public uint age { get; set; default = 0; }
|
||||
|
||||
/**
|
||||
* The reason of redaction, if any.
|
||||
*/
|
||||
public string? redact_reason { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* The transaction ID of the message.
|
||||
*/
|
||||
public string? transaction_id { get; set; default = null; }
|
||||
|
||||
/**
|
||||
* Create an UnsignedEventData object based
|
||||
* on @param json_data.
|
||||
*/
|
||||
public
|
||||
UnsignedEventData.from_json(Json.Node json_data)
|
||||
requires(json_data.get_node_type() == Json.NodeType.OBJECT)
|
||||
{
|
||||
var root = json_data.get_object();
|
||||
Json.Node node;
|
||||
|
||||
if ((node = root.get_member("age")) != null) {
|
||||
age = (uint)node.get_int();
|
||||
}
|
||||
|
||||
if ((node = root.get_member("redacted_because")) != null) {
|
||||
redact_reason = node.get_string();
|
||||
}
|
||||
|
||||
if ((node = root.get_member("transaction_id")) != null) {
|
||||
transaction_id = node.get_string();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unsigned event data as a JSON node.
|
||||
*/
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
var builder = new Json.Builder();
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
builder.set_member_name("age");
|
||||
builder.add_int_value(age);
|
||||
|
||||
if (redact_reason != null) {
|
||||
builder.set_member_name("redacted_because");
|
||||
builder.add_string_value(redact_reason);
|
||||
}
|
||||
|
||||
if (transaction_id != null) {
|
||||
builder.set_member_name("transaction_id");
|
||||
builder.add_string_value(transaction_id);
|
||||
}
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
public class EventContext : JsonCompact {
|
||||
public int? before_limit { get; set; default = null; }
|
||||
public int? after_limit { get; set; default = null; }
|
||||
public bool? include_profile { get; set; default = null; }
|
||||
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
if ((before_limit == null)
|
||||
&& (after_limit == null)
|
||||
&& (include_profile == null))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var builder = new Json.Builder();
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
if (before_limit != null) {
|
||||
builder.set_member_name("before_limit");
|
||||
builder.add_int_value(before_limit);
|
||||
}
|
||||
|
||||
if (after_limit != null) {
|
||||
builder.set_member_name("after_limit");
|
||||
builder.add_int_value(after_limit);
|
||||
}
|
||||
|
||||
if (include_profile != null) {
|
||||
builder.set_member_name("include_profile");
|
||||
builder.add_boolean_value(include_profile);
|
||||
}
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
public class SearchGrouping : JsonCompact {
|
||||
public SearchGroupBy? key { get; set; default = null; }
|
||||
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
if (key == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var builder = new Json.Builder();
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
builder.set_member_name("key");
|
||||
builder.add_string_value(
|
||||
_g_enum_value_to_nick(typeof(SearchGroupBy), key, true));
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
public class SearchGroupings : JsonCompact {
|
||||
private List<SearchGrouping>? _group_by = null;
|
||||
public List<SearchGrouping>? group_by {
|
||||
get {
|
||||
return _group_by;
|
||||
}
|
||||
|
||||
set {
|
||||
_group_by = value.copy();
|
||||
}
|
||||
|
||||
default = null;
|
||||
}
|
||||
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
if (group_by == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var builder = new Json.Builder();
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
builder.set_member_name("group_by");
|
||||
builder.begin_array();
|
||||
|
||||
foreach (var entry in group_by) {
|
||||
var node = entry.get_json_node();
|
||||
|
||||
if (node != null) {
|
||||
builder.add_value(node);
|
||||
}
|
||||
}
|
||||
|
||||
builder.end_array();
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
public class SearchRoomEvents : JsonCompact {
|
||||
private List<SearchKey?>? _keys = null;
|
||||
|
||||
public SearchOrder? order_by { get; set; default = SearchOrder.RECENT; }
|
||||
public List<SearchKey?>? keys {
|
||||
get {
|
||||
return _keys;
|
||||
}
|
||||
|
||||
set {
|
||||
_keys = value.copy();
|
||||
}
|
||||
|
||||
default = null; }
|
||||
public EventContext? event_context { get; set; default = null; }
|
||||
public bool? include_state { get; set; default = false; }
|
||||
public string? filter_id { get; set; default = null; }
|
||||
public Filter? filter { get; set; default = null; }
|
||||
public string search_term { get; set; }
|
||||
public SearchGroupings? groupings { get; set; default = null; }
|
||||
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
Json.Node? node = null;
|
||||
|
||||
var builder = new Json.Builder();
|
||||
|
||||
if ((filter_id != null) && (filter != null)) {
|
||||
throw new Matrix.Error.INCOMPLETE(
|
||||
"filter and filter_id is exclusive to each other");
|
||||
}
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
if (order_by != null) {
|
||||
builder.set_member_name("order_by");
|
||||
builder.add_string_value(
|
||||
_g_enum_value_to_nick(typeof(SearchOrder), order_by));
|
||||
}
|
||||
|
||||
if (keys != null) {
|
||||
EnumClass key_class = (EnumClass)(typeof(SearchKey).class_ref());
|
||||
var key_array = new Json.Array();
|
||||
|
||||
foreach (var entry in keys) {
|
||||
if (entry != null) {
|
||||
unowned EnumValue? key_value = key_class.get_value(entry);
|
||||
|
||||
if (key_value != null) {
|
||||
key_array.add_string_element(
|
||||
key_value.value_nick.replace("-", "."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key_array.get_length() > 0) {
|
||||
node = new Json.Node(Json.NodeType.ARRAY);
|
||||
node.set_array(key_array);
|
||||
|
||||
builder.set_member_name("keys");
|
||||
builder.add_value(node);
|
||||
}
|
||||
}
|
||||
|
||||
if ((event_context != null)
|
||||
&& ((node = event_context.get_json_node()) != null)) {
|
||||
builder.set_member_name("event_context");
|
||||
builder.add_value(node);
|
||||
}
|
||||
|
||||
if (include_state != null) {
|
||||
builder.set_member_name("include_state");
|
||||
builder.add_boolean_value(include_state);
|
||||
}
|
||||
|
||||
if ((filter != null)
|
||||
&& ((node = filter.get_json_node()) != null)) {
|
||||
builder.set_member_name("filter");
|
||||
builder.add_value(node);
|
||||
}
|
||||
|
||||
if (filter_id != null) {
|
||||
builder.set_member_name("filter");
|
||||
builder.add_string_value(filter_id);
|
||||
}
|
||||
|
||||
builder.set_member_name("search_term");
|
||||
builder.add_string_value(search_term);
|
||||
|
||||
if ((groupings != null)
|
||||
&& ((node = groupings.get_json_node()) != null)) {
|
||||
builder.set_member_name("groupings");
|
||||
builder.add_value(node);
|
||||
}
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
public class SearchCategories : JsonCompact {
|
||||
public SearchRoomEvents? room_events { get; set; default = null; }
|
||||
|
||||
public override Json.Node?
|
||||
get_json_node()
|
||||
throws Matrix.Error
|
||||
{
|
||||
Json.Node? node = null;
|
||||
|
||||
if ((room_events == null)
|
||||
&& ((node = room_events.get_json_node()) != null)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var builder = new Json.Builder();
|
||||
|
||||
builder.begin_object();
|
||||
|
||||
builder.set_member_name("room_events");
|
||||
builder.add_value(node);
|
||||
|
||||
builder.end_object();
|
||||
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
||||
private Json.Node?
|
||||
_json_object_node_ensure_field(Json.Node node,
|
||||
string field_name,
|
||||
Json.NodeType field_type)
|
||||
requires(node.get_node_type() == Json.NodeType.OBJECT)
|
||||
{
|
||||
var root = node.get_object();
|
||||
Json.Node? new_node;
|
||||
|
||||
if ((new_node = root.get_member(field_name)) == null) {
|
||||
new_node = new Json.Node(field_type);
|
||||
|
||||
switch (field_type) {
|
||||
case Json.NodeType.OBJECT:
|
||||
new_node.set_object(new Json.Object());
|
||||
|
||||
break;
|
||||
|
||||
case Json.NodeType.ARRAY:
|
||||
new_node.set_array(new Json.Array());
|
||||
|
||||
break;
|
||||
|
||||
// Other node types don’t need special treatment
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
root.set_member(field_name, new_node);
|
||||
}
|
||||
|
||||
return new_node;
|
||||
}
|
||||
|
||||
public Json.Node?
|
||||
_json_node_deep_copy(Json.Node? node)
|
||||
{
|
||||
Json.Node ret;
|
||||
|
||||
if (node == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ret = new Json.Node(node.get_node_type());
|
||||
|
||||
switch (node.get_node_type()) {
|
||||
case Json.NodeType.OBJECT:
|
||||
var new_obj = new Json.Object();
|
||||
|
||||
node.get_object().foreach_member(
|
||||
(old_obj, member_name, member_node) => {
|
||||
new_obj.set_member(
|
||||
member_name,
|
||||
_json_node_deep_copy(member_node));
|
||||
});
|
||||
|
||||
ret.set_object(new_obj);
|
||||
|
||||
break;
|
||||
|
||||
case Json.NodeType.ARRAY:
|
||||
var new_ary = new Json.Array();
|
||||
|
||||
node.get_array().foreach_element(
|
||||
(old_ary, idx, element_node) => {
|
||||
new_ary.add_element(
|
||||
_json_node_deep_copy(element_node));
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case Json.NodeType.VALUE:
|
||||
ret.set_value(node.get_value());
|
||||
|
||||
break;
|
||||
|
||||
case Json.NodeType.NULL:
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
227
src/matrix-enums.vala
Normal file
227
src/matrix-enums.vala
Normal file
@ -0,0 +1,227 @@
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Matrix {
|
||||
public errordomain Error {
|
||||
NONE, /// no error
|
||||
COMMUNICATION_ERROR, /// there was a problem in communication (e.g. connection error)
|
||||
INCOMPLETE, /// the passed/generated data is incomplete
|
||||
BAD_REQUEST, /// the request is invalid
|
||||
BAD_RESPONSE, /// malformed response, or the response is not a JSON object
|
||||
INVALID_ROOM_ID, /// the provided string doesn’t contain a valid room ID
|
||||
UNKNOWN_VALUE, /// the response from the Matrix.org server contains a value unknown to this library. These should be reported to the Matrix GLib SDK developers
|
||||
INVALID_TYPE, /// the provided type is invalid
|
||||
UNSUPPORTED, ///the operation is unsupported
|
||||
INVALID_FORMAT, /// the format of the JSON node is invalid (e.g. it is an array instead of an object)
|
||||
|
||||
/* Add Matrix-defined error codes under here, prefixing them with
|
||||
* `MATRIX_ERROR_`, i.e. `M_FORBIDDEN` =>
|
||||
* `MATRIX_ERROR_M_FORBIDDEN` */
|
||||
M_MISSING_TOKEN = 500, /// authorization token is missing from the request
|
||||
M_FORBIDDEN, /// access was forbidden (e.g. due to a missing/invalid token, or using a bad password during login)
|
||||
M_UNKNOWN, /// an error unknown to the Matrix homeserver
|
||||
M_UNKNOWN_TOKEN, /// the token provided is not known for the homeserver
|
||||
M_NOT_JSON, /// illegal request, the content is not valid JSON
|
||||
M_UNRECOGNIZED, /// the homeserver didn't understand the request
|
||||
M_UNAUTHORIZED, /// the request is unauthorized
|
||||
M_BAD_JSON, /// the JSON data is not in the required format
|
||||
M_USER_IN_USE, /// the specified username is in use
|
||||
M_ROOM_IN_USE, /// the specified room is in use
|
||||
M_BAD_PAGINATION, /// invalid pagination parameters
|
||||
M_BAD_STATE, /// invalid state event
|
||||
M_NOT_FOUND, /// the requested resource is not found
|
||||
M_GUEST_ACCESS_FORBIDDEN, /// guest access was requested, but it is forbidden
|
||||
M_LIMIT_EXCEEDED, /// the request was rate limited
|
||||
M_CAPTCHA_NEEDED, /// a captcha is needed to continue
|
||||
M_CAPTCHA_INVALID, /// the provided captcha is invalid
|
||||
M_MISSING_PARAM, /// a parameter is missing from the request
|
||||
M_TOO_LARGE, /// the request data is too large
|
||||
M_EXCLUSIVE, /// the desired user ID is in an exclusive namespace claimed by an application server
|
||||
M_THREEPID_AUTH_FAILED, /// 3rd party authentication failed
|
||||
M_THREEPID_IN_USE, /// the provided 3rd party ID is already in use
|
||||
M_INVALID_USERNAME, /// the given username is invalid
|
||||
|
||||
/* Allow for a lot of Matrix.org defined codes
|
||||
* Do not define error codes after this! */
|
||||
UNSPECIFIED = 16383, /// no error code was sent by the homeserver. If you see this error, that usually indicates a homeserver bug
|
||||
UNKNOWN_ERROR; /// an error unknown to this library
|
||||
|
||||
public static GLib.Quark
|
||||
quark ()
|
||||
{
|
||||
return Quark.from_string("matrix-error-quark");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* User account types.
|
||||
*/
|
||||
public enum AccountKind {
|
||||
DEFAULT, /// use the server default (usually {{{USER}}})
|
||||
USER, /// normal user
|
||||
GUEST; /// guest user
|
||||
}
|
||||
|
||||
/**
|
||||
* Direction of events when requesting an event context.
|
||||
*/
|
||||
public enum EventDirection {
|
||||
FORWARD, /// List events after the specified one
|
||||
BACKWARD; /// List events before the specified one
|
||||
}
|
||||
|
||||
/**
|
||||
* Event format received when synchronizing.
|
||||
*/
|
||||
public enum EventFormat {
|
||||
DEFAULT, /// event format will be omitted from the filter, so the server will use its default (usually {{{FEDERATION}}})
|
||||
CLIENT, /// return the events in a format suitable for clients
|
||||
FEDERATION; /// return the raw event as receieved over federation
|
||||
}
|
||||
|
||||
/**
|
||||
* Presence values for matrix_api_set_user_presence() and other
|
||||
* presence related queries.
|
||||
*/
|
||||
public enum Presence {
|
||||
UNKNOWN, /// user's presence is unknown
|
||||
ONLINE, /// user is online
|
||||
OFFLINE, /// user is offline
|
||||
UNAVAILABLE, /// user is unavailable (i.e. busy)
|
||||
FREE_FOR_CHAT; /// user is free for chat
|
||||
}
|
||||
|
||||
/**
|
||||
* Condition types for pushers.
|
||||
*/
|
||||
public enum PusherConditionKind {
|
||||
EVENT_MATCH, /// glob pattern match on a field of the event. Requires a {{{key}}} and a {{{pattern}}} parameter
|
||||
PROFILE_TAG, /// matches the profile tag of the device that the notification would be delivered to. Requires a {{{profile_tag}}} parameter
|
||||
CONTAINS_DISPLAY_NAME, /// matches unencrypted messages where the content's body contains the owner's display name in that room.
|
||||
ROOM_MEMBER_COUNT; /// matches the current number of members in the room. Requires an {{{is}}} parameter, which must be an integer, optionally prefixed by {{==}}}, {{{<}}}, {{{>}}}, {{{<=}}} or {{{>=}}}. If the prefix is omitted, it defaults to {{{==}}}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pusher types.
|
||||
*/
|
||||
public enum PusherKind {
|
||||
OVERRIDE, /// highest priority rules
|
||||
SENDER, /// for (unencrypted) messages that match certain patterns
|
||||
ROOM, /// for all messages for a given room. The rule ID of a room rule is always the ID of the room that it affects
|
||||
CONTENT, /// for messages from a specific Matrix user ID. The rule ID of such rules is always the Matrix ID of the user whose messages they'd apply to
|
||||
UNDERRIDE; /// lowest priority rules
|
||||
}
|
||||
|
||||
/**
|
||||
* Receipt types of acknowledgment.
|
||||
*/
|
||||
public enum ReceiptType {
|
||||
READ; /// indicate that the message has been read
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizing methods for matrix_api_media_thumbnail().
|
||||
*/
|
||||
public enum ResizeMethod {
|
||||
DEFAULT, /// use the server default value
|
||||
CROP, /// crop thumbnail to the requested size
|
||||
SCALE; /// scale thumbnail to the requested size
|
||||
}
|
||||
|
||||
/**
|
||||
* Room membership types.
|
||||
*/
|
||||
public enum RoomMembership {
|
||||
UNKNOWN, /// the membership sent by the server is unknown to this SDK
|
||||
INVITE, /// the user has been invited to join a room, but has not yet joined it. They may not participate in the room until they join
|
||||
JOIN, /// the user has joined the room (possibly after accepting an invite), and may participate in it
|
||||
LEAVE, /// the user was once joined to the room, but has since left (possibly by choice, or possibly by being kicked)
|
||||
BAN, /// the user has been banned from the room, and is no longer allowed to join it until they are un-banned from the room (by having their membership state set to a value other than {{{BAN}}})
|
||||
KNOCK; /// this is a reserved word, which currently has no meaning
|
||||
}
|
||||
|
||||
/**
|
||||
* Preset values for matrix_api_create_room() calls.
|
||||
*/
|
||||
public enum RoomPreset {
|
||||
NONE, /// no preset
|
||||
PRIVATE, /// preset for private rooms
|
||||
TRUSTED_PRIVATE, /// same as private rooms, but all users get the same power level as the room creator
|
||||
PUBLIC; /// preset for public rooms
|
||||
}
|
||||
|
||||
/**
|
||||
* Visibility values for room creation. Not to be confused with
|
||||
* join rules.
|
||||
*/
|
||||
public enum RoomVisibility {
|
||||
DEFAULT, /// use a server-assigned value (usually {{{private}}}
|
||||
PUBLIC, /// make the room visible in the public room list
|
||||
PRIVATE; /// hide the room from the public room list
|
||||
}
|
||||
|
||||
public enum SearchOrder {
|
||||
RECENT,
|
||||
RANK
|
||||
}
|
||||
|
||||
public enum SearchKey {
|
||||
CONTENT_BODY,
|
||||
CONTENT_NAME,
|
||||
CONTENT_TOPIC
|
||||
}
|
||||
|
||||
public enum SearchGroupBy {
|
||||
ROOM_ID,
|
||||
SENDER
|
||||
}
|
||||
|
||||
private int?
|
||||
_g_enum_nick_to_value(Type enum_type, string nick)
|
||||
{
|
||||
EnumClass enum_class = (EnumClass)enum_type.class_ref();
|
||||
unowned EnumValue? enum_val = enum_class.get_value_by_nick(nick);
|
||||
|
||||
if (enum_val != null) {
|
||||
return enum_val.value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private string?
|
||||
_g_enum_value_to_nick(Type enum_type,
|
||||
int value,
|
||||
bool convert_dashes = true)
|
||||
{
|
||||
EnumClass enum_class = (EnumClass)enum_type.class_ref();
|
||||
unowned EnumValue? enum_val = enum_class.get_value(value);
|
||||
|
||||
if (enum_val != null) {
|
||||
var nick = enum_val.value_nick;
|
||||
|
||||
if (convert_dashes) {
|
||||
return nick.replace("-", "_");
|
||||
}
|
||||
|
||||
return nick;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,603 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-base.h"
|
||||
#include "matrix-types.h"
|
||||
#include "matrix-enumtypes.h"
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-base
|
||||
* @short_description: abstract base class for Matrix events
|
||||
* @title: Base class for events
|
||||
*
|
||||
* #MatrixEventBase is the abstract base class of Matrix events. All event classes in this
|
||||
* library are derived from it, and custom classes should derived from it, too, if one wants to
|
||||
* benefit from #MatrixClient’s (de)serialization capabilities.
|
||||
*
|
||||
* This class only defines the MatrixEventBase:event-type property, which is tied to the
|
||||
* `event_type` field in a JSON representation. Subclasses should not get or set this property.
|
||||
*
|
||||
* Event objects can be created from JSON data (a #JsonNode) by calling
|
||||
* matrix_event_base_new_from_json(), which will return the correct GObject type as long as
|
||||
* it was registered with matrix_event_register_type().
|
||||
*/
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_EVENT_TYPE,
|
||||
PROP_JSON,
|
||||
NUM_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec* matrix_event_base_properties[NUM_PROPS];
|
||||
static GHashTable *matrix_event_type_handlers = NULL;
|
||||
|
||||
typedef struct {
|
||||
GError* _construct_error;
|
||||
gboolean _inited;
|
||||
JsonNode* _json;
|
||||
gchar *_event_type;
|
||||
} MatrixEventBasePrivate;
|
||||
|
||||
static void matrix_event_base_g_initable_interface_init (GInitableIface *iface);
|
||||
|
||||
/**
|
||||
* MatrixEventBase:
|
||||
*
|
||||
* Abstract base class for event handlers.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MatrixEventBaseClass:
|
||||
* @from_json: function to initialize themselves from JSON data
|
||||
* @to_json: function to export their data to JSON
|
||||
*
|
||||
* Class structure for #MatrixEventBase.
|
||||
*/
|
||||
G_DEFINE_TYPE_EXTENDED(MatrixEventBase, matrix_event_base, G_TYPE_OBJECT, G_TYPE_FLAG_ABSTRACT, G_ADD_PRIVATE (MatrixEventBase) G_IMPLEMENT_INTERFACE(G_TYPE_INITABLE, matrix_event_base_g_initable_interface_init));
|
||||
|
||||
static gboolean
|
||||
matrix_event_base_initable_init(GInitable *g_initable, GCancellable *cancellable, GError **error)
|
||||
{
|
||||
MatrixEventBasePrivate *priv;
|
||||
|
||||
if (cancellable != NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_UNSUPPORTED,
|
||||
"Cancellable initialization not supported");
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv = matrix_event_base_get_instance_private(MATRIX_EVENT_BASE(g_initable));
|
||||
|
||||
if (priv->_construct_error != NULL) {
|
||||
g_propagate_error(error, priv->_construct_error);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv->_inited = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_base_initialize_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventBasePrivate *priv = matrix_event_base_get_instance_private(matrix_event_base);
|
||||
JsonObject *root;
|
||||
JsonNode *node;
|
||||
const gchar *json_event_type;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_if_fail(matrix_event_base != NULL);
|
||||
|
||||
if (json_node_get_node_type(json_data) != JSON_NODE_OBJECT) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INVALID_FORMAT,
|
||||
"The event is not valid");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
|
||||
if ((node = json_object_get_member(root, "type")) == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Event type is not specified");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
json_event_type = json_node_get_string(node);
|
||||
|
||||
if ((priv->_event_type != NULL) && (g_strcmp0(priv->_event_type, json_event_type) != 0)) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INVALID_TYPE,
|
||||
"Changing event type is not supported");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(root, "content")) == NULL) {
|
||||
g_warning("content key is missing from an %s event", json_event_type);
|
||||
|
||||
// As event type objects depend on having this node, let’s add it now.
|
||||
JsonNode *content_node = json_node_new(JSON_NODE_OBJECT);
|
||||
json_node_set_object(content_node, json_object_new());
|
||||
json_object_set_member(root, "content", content_node);
|
||||
}
|
||||
|
||||
matrix_event_base_from_json(matrix_event_base, json_data, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
g_free(priv->_event_type);
|
||||
priv->_event_type = g_strdup(json_event_type);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_base_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventBasePrivate *priv = matrix_event_base_get_instance_private(matrix_event_base);
|
||||
JsonObject *root;
|
||||
JsonNode *node;
|
||||
|
||||
g_return_if_fail(matrix_event_base != NULL);
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
|
||||
if ((node = json_object_get_member(root, "type")) != NULL) {
|
||||
g_free(priv->_event_type);
|
||||
priv->_event_type = g_strdup(json_node_get_string(node));
|
||||
} else if (DEBUG) {
|
||||
g_warning("type is not present in an event");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_base_from_json:
|
||||
* @event: a #MatrixEventBase (or derived) object
|
||||
* @json_data: a #JsonNode to load data from. It must hold a #JsonObject
|
||||
* @error: a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Load data from a JSON object to the fields of @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_base_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
g_return_if_fail(matrix_event_base != NULL);
|
||||
g_return_if_fail(json_data != NULL);
|
||||
g_return_if_fail(json_node_get_node_type(json_data) != JSON_NODE_OBJECT);
|
||||
|
||||
MATRIX_EVENT_BASE_GET_CLASS(matrix_event_base)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_base_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventBasePrivate *priv = matrix_event_base_get_instance_private(matrix_event_base);
|
||||
JsonObject *root;
|
||||
|
||||
g_return_if_fail(matrix_event_base != NULL);
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
|
||||
if (priv->_event_type == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate an event without type");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
json_object_set_string_member(root, "type", priv->_event_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_base_to_json:
|
||||
* @event: a #MatrixEventBase (or derived) object
|
||||
* @json_data: a #JsonNode initialised to hold a #JsonObject
|
||||
* @error: a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Export event data to a JSON object.
|
||||
*/
|
||||
void
|
||||
matrix_event_base_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
g_return_if_fail(matrix_event_base != NULL);
|
||||
g_return_if_fail(json_data != NULL);
|
||||
g_return_if_fail(json_node_get_node_type(json_data) != JSON_NODE_OBJECT);
|
||||
|
||||
MATRIX_EVENT_BASE_GET_CLASS(matrix_event_base)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_base_new_from_json:
|
||||
* @event_type: (nullable) (transfer none): an event type
|
||||
* @json_data: (not nullable) (transfer none): a #JsonNode, holding a #JsonObject
|
||||
* @error: (nullable): a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Create a new #MatrixEventBase derived object based on @event_type. If @event_type is %NULL,
|
||||
* the event type is taken directly from the JSON data, namely the `"event_type"` field.
|
||||
*
|
||||
* After figuring out the event type (either from @event_type or from the event itself), this
|
||||
* function calls matrix_event_get_handler() to get the handler #GType for this event. If
|
||||
* none found, @error is set to #MATRIX_ERROR_INVALID_TYPE, and this function returns %NULL.
|
||||
*
|
||||
* The actual return type of this function is the same as the handling class (which is
|
||||
* required to be a subclass of #MatrixEventBase).
|
||||
*
|
||||
* When object initialisation is done, matrix_event_base_from_json() is called to populate
|
||||
* the event object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventBase devired object
|
||||
*/
|
||||
MatrixEventBase *
|
||||
matrix_event_base_new_from_json(const gchar *event_type, JsonNode *json_data, GError **error)
|
||||
{
|
||||
GType event_gtype;
|
||||
MatrixEventBase *ret = NULL;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
if (event_type == NULL) {
|
||||
JsonNode *node;
|
||||
|
||||
if (json_data == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Either event_type or json_data must be set!");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (json_node_get_node_type(json_data) != JSON_NODE_OBJECT) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INVALID_FORMAT,
|
||||
"Event is not a JSON object!");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(json_node_get_object(json_data), "type")) == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"event_type is null and JSON object doesn't contain type!");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
event_type = (gchar *)json_node_get_string(node);
|
||||
}
|
||||
|
||||
if ((event_gtype = matrix_event_get_handler(event_type)) == G_TYPE_NONE) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INVALID_TYPE,
|
||||
"No registered type for event type %s",
|
||||
event_type);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = (MatrixEventBase *)g_object_new(event_gtype,
|
||||
"event_type", event_type,
|
||||
"json", json_data);
|
||||
|
||||
matrix_event_base_initable_init(G_INITABLE(ret), NULL, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_base_construct:
|
||||
* @object_type: a #GType to construct
|
||||
*
|
||||
* Returns: (transfer full): a new instance of @object_type
|
||||
*/
|
||||
MatrixEventBase *
|
||||
matrix_event_base_construct(GType object_type)
|
||||
{
|
||||
return (MatrixEventBase *)g_object_new(object_type, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_base_get_event_type:
|
||||
* @event: a #MatrixEventBase (or derived) object
|
||||
*
|
||||
* Get the event type of @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none): the event type
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_base_get_event_type(MatrixEventBase *matrix_event_base)
|
||||
{
|
||||
MatrixEventBasePrivate *priv = matrix_event_base_get_instance_private(matrix_event_base);
|
||||
|
||||
g_return_val_if_fail(matrix_event_base != NULL, NULL);
|
||||
|
||||
return priv->_event_type;
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_base_set_event_type(MatrixEventBase *matrix_event_base, const gchar *event_type)
|
||||
{
|
||||
MatrixEventBasePrivate *priv = matrix_event_base_get_instance_private(matrix_event_base);
|
||||
|
||||
g_return_if_fail(matrix_event_base != NULL);
|
||||
|
||||
g_free(priv->_event_type);
|
||||
priv->_event_type = g_strdup (event_type);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_base,
|
||||
matrix_event_base_properties[PROP_EVENT_TYPE]);
|
||||
}
|
||||
|
||||
JsonNode *
|
||||
matrix_event_base_get_json(MatrixEventBase *matrix_event_base)
|
||||
{
|
||||
MatrixEventBasePrivate *priv;
|
||||
JsonNode *result;
|
||||
JsonNode *content_node;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_val_if_fail(matrix_event_base != NULL, NULL);
|
||||
|
||||
priv = matrix_event_base_get_instance_private(matrix_event_base);
|
||||
|
||||
result = json_node_new (JSON_NODE_OBJECT);
|
||||
root = json_object_new();
|
||||
json_node_set_object(priv->_json, root);
|
||||
|
||||
content_node = json_node_new(JSON_NODE_OBJECT);
|
||||
content_root = json_object_new();
|
||||
json_node_set_object(content_node, content_root);
|
||||
json_object_set_member(root, "content", content_node);
|
||||
|
||||
matrix_event_base_to_json(matrix_event_base, priv->_json, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_error("Unable to generate JSON content: %s", inner_error->message);
|
||||
g_error_free(inner_error);
|
||||
g_object_unref(result);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
json_node_unref(priv->_json);
|
||||
|
||||
priv->_json = result;
|
||||
|
||||
return priv->_json;
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_base_set_json(MatrixEventBase *matrix_event_base, JsonNode *json)
|
||||
{
|
||||
GError* inner_error = NULL;
|
||||
|
||||
g_return_if_fail(matrix_event_base != NULL);
|
||||
|
||||
if (json != NULL) {
|
||||
matrix_event_base_initialize_from_json(matrix_event_base, json, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_error("Unable to initialise from JSON data: %s", inner_error->message);
|
||||
g_error_free(inner_error);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_base, matrix_event_base_properties[PROP_JSON]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_base_get_property(GObject *gobject, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventBase *matrix_event_base = MATRIX_EVENT_BASE(gobject);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_EVENT_TYPE:
|
||||
g_value_set_string(value, matrix_event_base_get_event_type(matrix_event_base));
|
||||
|
||||
break;
|
||||
case PROP_JSON:
|
||||
g_value_set_boxed(value, matrix_event_base_get_json(matrix_event_base));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_base_set_property(GObject *gobject, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventBase *matrix_event_base = MATRIX_EVENT_BASE(gobject);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_EVENT_TYPE:
|
||||
matrix_event_base_set_event_type(matrix_event_base, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_JSON:
|
||||
matrix_event_base_set_json(matrix_event_base, g_value_get_boxed(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_base_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventBase *matrix_event_base = MATRIX_EVENT_BASE(gobject);
|
||||
MatrixEventBasePrivate *priv = matrix_event_base_get_instance_private(matrix_event_base);
|
||||
|
||||
if (priv->_construct_error) {
|
||||
g_error_free(priv->_construct_error);
|
||||
}
|
||||
|
||||
priv->_json = (json_node_unref(priv->_json), NULL);
|
||||
|
||||
g_free(priv->_event_type);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_base_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_base_class_init(MatrixEventBaseClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_base_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_base_real_to_json;
|
||||
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_base_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_base_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_base_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventBase:event-type:
|
||||
*
|
||||
* The type of the event. It should be namespaced similar to the Java package naming
|
||||
* conventions, e.g. `com.example.subdomain.event.type`. It cannot be changed after object
|
||||
* initialization.
|
||||
*/
|
||||
matrix_event_base_properties[PROP_EVENT_TYPE] = g_param_spec_string(
|
||||
"event-type", "event-type", "event-type",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass),
|
||||
PROP_EVENT_TYPE,
|
||||
matrix_event_base_properties[PROP_EVENT_TYPE]);
|
||||
|
||||
/**
|
||||
* MatrixEventBase:json:
|
||||
*
|
||||
* The event as a JSON node.
|
||||
*/
|
||||
matrix_event_base_properties[PROP_JSON] = g_param_spec_boxed(
|
||||
"json", "json", "json",
|
||||
JSON_TYPE_NODE,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass),
|
||||
PROP_JSON,
|
||||
matrix_event_base_properties[PROP_JSON]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_base_g_initable_interface_init(GInitableIface *iface)
|
||||
{
|
||||
iface->init = matrix_event_base_initable_init;
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_base_init(MatrixEventBase *matrix_event_base)
|
||||
{
|
||||
MatrixEventBasePrivate *priv = matrix_event_base_get_instance_private(matrix_event_base);
|
||||
|
||||
priv->_construct_error = NULL;
|
||||
priv->_inited = FALSE;
|
||||
priv->_event_type = NULL;
|
||||
|
||||
matrix_event_base_set_event_type(matrix_event_base, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_get_handler:
|
||||
* @event_type: (transfer none) (not nullable): the event type to look up
|
||||
*
|
||||
* Get the #GType of the class that is registered to handle events with type @event_type.
|
||||
*
|
||||
* Returns: a #GType, or #G_TYPE_NONE if no handler is registered
|
||||
*/
|
||||
GType
|
||||
matrix_event_get_handler(const gchar *event_type)
|
||||
{
|
||||
GTypeClass *klass;
|
||||
|
||||
g_return_val_if_fail(event_type != NULL, G_TYPE_NONE);
|
||||
|
||||
if ((klass = (GTypeClass *)g_hash_table_lookup(matrix_event_type_handlers, event_type)) != NULL) {
|
||||
return G_TYPE_FROM_CLASS(klass);
|
||||
}
|
||||
|
||||
if (DEBUG) {
|
||||
g_warning ("matrix-event-base.vala:243: No registered type for %s", event_type);
|
||||
}
|
||||
|
||||
return G_TYPE_NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_register_type:
|
||||
* @event_type: (transfer none): the type of the event
|
||||
* @event_gtype: the #GType of the event’s handler
|
||||
* @error: a #GError, or %NULL to ignore errors
|
||||
*
|
||||
* Registers @event_type to be handled by the type @event_gtype.
|
||||
*/
|
||||
void
|
||||
matrix_event_register_type(const gchar *event_type, GType event_gtype, GError **error)
|
||||
{
|
||||
gchar *key;
|
||||
GTypeClass *klass;
|
||||
|
||||
g_return_if_fail(event_type != NULL);
|
||||
|
||||
if (!g_type_is_a (event_gtype, MATRIX_EVENT_TYPE_BASE)) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INVALID_TYPE,
|
||||
"Invalid event type handler. It must be a subclass of MatrixEvent");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (matrix_event_type_handlers == NULL) {
|
||||
matrix_event_type_handlers = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_type_class_unref);
|
||||
}
|
||||
|
||||
key = g_strdup (event_type);
|
||||
klass = g_type_class_ref (event_gtype);
|
||||
|
||||
g_hash_table_replace(matrix_event_type_handlers, key, klass);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_unregister_type:
|
||||
* @event_type: (transfer none): the event type to remove
|
||||
*
|
||||
* Unregister @param event_type.
|
||||
*/
|
||||
void
|
||||
matrix_event_unregister_type(const gchar *event_type)
|
||||
{
|
||||
g_return_if_fail(event_type != NULL && matrix_event_type_handlers != NULL);
|
||||
|
||||
g_hash_table_remove (matrix_event_type_handlers, event_type);
|
||||
}
|
@ -1,59 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIX_SDK_EVENT_BASE_H__
|
||||
# define __MATRIX_GLIX_SDK_EVENT_BASE_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include <json-glib/json-glib.h>
|
||||
|
||||
# define MATRIX_EVENT_TYPE_BASE (matrix_event_base_get_type ())
|
||||
# define MATRIX_EVENT_BASE(o) (G_TYPE_CHECK_INSTANCE_CAST((o), MATRIX_EVENT_TYPE_BASE, MatrixEventBase))
|
||||
# define MATRIX_EVENT_BASE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST((c), MATRIX_EVENT_TYPE_BASE, MatrixEventBaseClass))
|
||||
# define MATRIX_EVENT_IS_BASE(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_EVENT_TYPE_BASE))
|
||||
# define MATRIX_EVENT_IS_BASE_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE((c), MATRIX_EVENT_TYPE_BASE))
|
||||
# define MATRIX_EVENT_BASE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MATRIX_EVENT_TYPE_BASE, MatrixEventBaseClass))
|
||||
|
||||
typedef struct _MatrixEventBase MatrixEventBase;
|
||||
typedef struct _MatrixEventBaseClass MatrixEventBaseClass;
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(MatrixEventBase, g_object_unref)
|
||||
|
||||
struct _MatrixEventBase {
|
||||
GObject parent_instance;
|
||||
};
|
||||
|
||||
struct _MatrixEventBaseClass {
|
||||
GObjectClass parent_instance;
|
||||
|
||||
void (*from_json)(MatrixEventBase *event, JsonNode *json_data, GError **error);
|
||||
void (*to_json)(MatrixEventBase *event, JsonNode *json_data, GError **error);
|
||||
};
|
||||
|
||||
GType matrix_event_get_handler(const gchar *event_type);
|
||||
void matrix_event_register_type(const gchar *event_type, GType event_gtype, GError **error);
|
||||
void matrix_event_unregister_type(const gchar *event_type);
|
||||
|
||||
GType matrix_event_base_get_type(void) G_GNUC_CONST;
|
||||
void matrix_event_base_from_json(MatrixEventBase *event, JsonNode *json_data, GError **error);
|
||||
void matrix_event_base_to_json(MatrixEventBase *event, JsonNode *json_data, GError **error);
|
||||
MatrixEventBase *matrix_event_base_new_from_json(const gchar *event_type, JsonNode *json_data, GError **error);
|
||||
MatrixEventBase *matrix_event_base_construct(GType object_type);
|
||||
const gchar *matrix_event_base_get_event_type(MatrixEventBase *event);
|
||||
JsonNode *matrix_event_base_get_json(MatrixEventBase *event);
|
||||
|
||||
#endif /* __MATRIX_GLIX_SDK_EVENT_BASE_H__ */
|
@ -1,338 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-call-answer.h"
|
||||
#include "utils.h"
|
||||
#include "matrix-enumtypes.h"
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-call-answer
|
||||
* @short_description: event sent when a callee wishes to answer the call
|
||||
*
|
||||
* This event is sent by the callee when they wish to answer the call.
|
||||
*/
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ANSWER_TYPE,
|
||||
PROP_ANSWER_SDP,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *matrix_event_call_answer_properties[NUM_PROPERTIES];
|
||||
|
||||
typedef struct {
|
||||
MatrixCallAnswerType _answer_type;
|
||||
gchar* _answer_sdp;
|
||||
} MatrixEventCallAnswerPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventCallAnswer:
|
||||
*
|
||||
* Object structure.
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventCallAnswer, matrix_event_call_answer, MATRIX_EVENT_TYPE_CALL);
|
||||
|
||||
static void
|
||||
matrix_event_call_answer_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventCallAnswerPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_call_answer_get_instance_private(MATRIX_EVENT_CALL_ANSWER(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
if ((node = json_object_get_member(content_root, "answer")) != NULL) {
|
||||
JsonObject *answer_root = json_node_get_object(node);
|
||||
|
||||
if ((node = json_object_get_member(answer_root, "type")) != NULL) {
|
||||
GError *inner_error = NULL;
|
||||
MatrixCallAnswerType answer_type = _matrix_g_enum_nick_to_value(MATRIX_TYPE_CALL_ANSWER_TYPE, json_node_get_string(node), &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
priv->_answer_type = MATRIX_CALL_ANSWER_TYPE_UNKNOWN;
|
||||
|
||||
#if DEBUG
|
||||
g_warning("Unknown value %s for content.answer.type in a m.call.answer event", json_node_get_string(node));
|
||||
#endif
|
||||
} else {
|
||||
priv->_answer_type = answer_type;
|
||||
}
|
||||
} else {
|
||||
g_warning("content.answer.type is missing from a m.call.answer event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(answer_root, "sdp")) != NULL) {
|
||||
g_free(priv->_answer_sdp);
|
||||
priv->_answer_sdp = g_strdup(json_node_get_string(node));
|
||||
} else {
|
||||
g_warning("content.answer.sdp is missing from a m.call.answer event");
|
||||
}
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_call_answer_parent_class)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_answer_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventCallAnswerPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonObject *answer_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *answer_node;
|
||||
gchar *answer_type;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_call_answer_get_instance_private(MATRIX_EVENT_CALL_ANSWER(matrix_event_base));
|
||||
|
||||
if (priv->_answer_type == MATRIX_CALL_ANSWER_TYPE_UNKNOWN) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.call.answer event without a valid answer.type");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->_answer_sdp == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.call.answer event without answer.sdp");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
answer_root = json_object_new();
|
||||
answer_node = json_node_new(JSON_NODE_OBJECT);
|
||||
json_node_set_object(answer_node, answer_root);
|
||||
|
||||
answer_type = _matrix_g_enum_to_string(MATRIX_TYPE_CALL_ANSWER_TYPE, priv->_answer_type, '_');
|
||||
json_object_set_string_member(answer_root, "type", answer_type);
|
||||
g_free(answer_type);
|
||||
|
||||
json_object_set_string_member(answer_root, "sdp", priv->_answer_sdp);
|
||||
|
||||
json_object_set_member(content_root, "answer", answer_node);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_call_answer_parent_class)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_answer_new:
|
||||
*
|
||||
* Create a new #MatrixEventCallAnswer object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventCallAnswer object
|
||||
*/
|
||||
MatrixEventCallAnswer *
|
||||
matrix_event_call_answer_new(void)
|
||||
{
|
||||
return (MatrixEventCallAnswer *)matrix_event_call_construct(MATRIX_EVENT_TYPE_CALL_ANSWER);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_answer_get_answer_type:
|
||||
* @event: a #MatrixEventCallAnswer
|
||||
*
|
||||
* Get the answer type from @event.
|
||||
*
|
||||
* Returns: the answer type.
|
||||
*/
|
||||
MatrixCallAnswerType
|
||||
matrix_event_call_answer_get_answer_type(MatrixEventCallAnswer *matrix_event_call_answer)
|
||||
{
|
||||
MatrixEventCallAnswerPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_call_answer != NULL, 0);
|
||||
|
||||
priv = matrix_event_call_answer_get_instance_private(matrix_event_call_answer);
|
||||
|
||||
return priv->_answer_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_answer_set_answer_type:
|
||||
* @event: a #MatrixEventCallAnswer
|
||||
* @answer_type: the answer type to set
|
||||
*
|
||||
* Set the answer type in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_call_answer_set_answer_type(MatrixEventCallAnswer *matrix_event_call_answer, MatrixCallAnswerType answer_type)
|
||||
{
|
||||
MatrixEventCallAnswerPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_call_answer != NULL);
|
||||
|
||||
priv = matrix_event_call_answer_get_instance_private(matrix_event_call_answer);
|
||||
|
||||
if (priv->_answer_type != answer_type) {
|
||||
priv->_answer_type = answer_type;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_call_answer, matrix_event_call_answer_properties[PROP_ANSWER_TYPE]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_answer_get_answer_sdp:
|
||||
* @event: a #MatrixEventCallAnswer
|
||||
*
|
||||
* Get the answer SDP of @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the answer SDP
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_call_answer_get_answer_sdp(MatrixEventCallAnswer *matrix_event_call_answer)
|
||||
{
|
||||
MatrixEventCallAnswerPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_call_answer != NULL, NULL);
|
||||
|
||||
priv = matrix_event_call_answer_get_instance_private(matrix_event_call_answer);
|
||||
|
||||
return priv->_answer_sdp;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_answer_set_answer_sdp:
|
||||
* @event: a #MatrixEventCallAnswer
|
||||
* @answer_sdp: (transfer none): an answew SDP
|
||||
*
|
||||
* Set the answer SDP in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_call_answer_set_answer_sdp(MatrixEventCallAnswer *matrix_event_call_answer, const gchar *answer_sdp)
|
||||
{
|
||||
MatrixEventCallAnswerPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_call_answer != NULL);
|
||||
|
||||
priv = matrix_event_call_answer_get_instance_private(matrix_event_call_answer);
|
||||
|
||||
if (g_strcmp0(answer_sdp, priv->_answer_sdp) != 0) {
|
||||
g_free(priv->_answer_sdp);
|
||||
priv->_answer_sdp = g_strdup(answer_sdp);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_call_answer, matrix_event_call_answer_properties[PROP_ANSWER_SDP]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_answer_finalize(GObject *gobject) {
|
||||
MatrixEventCallAnswerPrivate *priv = matrix_event_call_answer_get_instance_private(MATRIX_EVENT_CALL_ANSWER(gobject));
|
||||
|
||||
g_free(priv->_answer_sdp);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_call_answer_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_answer_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventCallAnswer *matrix_event_call_answer = MATRIX_EVENT_CALL_ANSWER(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ANSWER_TYPE:
|
||||
g_value_set_enum(value, matrix_event_call_answer_get_answer_type(matrix_event_call_answer));
|
||||
|
||||
break;
|
||||
case PROP_ANSWER_SDP:
|
||||
g_value_set_string(value, matrix_event_call_answer_get_answer_sdp(matrix_event_call_answer));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_answer_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventCallAnswer *matrix_event_call_answer = MATRIX_EVENT_CALL_ANSWER(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ANSWER_TYPE:
|
||||
matrix_event_call_answer_set_answer_type(matrix_event_call_answer, g_value_get_enum(value));
|
||||
|
||||
break;
|
||||
case PROP_ANSWER_SDP:
|
||||
matrix_event_call_answer_set_answer_sdp(matrix_event_call_answer, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_answer_class_init(MatrixEventCallAnswerClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_call_answer_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_call_answer_real_to_json;
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_call_answer_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_call_answer_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_call_answer_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventCallAnswer:answer-type:
|
||||
*
|
||||
* The type of session description.
|
||||
*/
|
||||
matrix_event_call_answer_properties[PROP_ANSWER_TYPE] = g_param_spec_enum(
|
||||
"answer-type", "answer-type", "answer-type",
|
||||
MATRIX_TYPE_CALL_ANSWER_TYPE, MATRIX_CALL_ANSWER_TYPE_UNKNOWN,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_ANSWER_TYPE, matrix_event_call_answer_properties[PROP_ANSWER_TYPE]);
|
||||
|
||||
/**
|
||||
* MatrixEventCallAnswer:answer-sdp:
|
||||
* The SDP text of the session description.
|
||||
*/
|
||||
matrix_event_call_answer_properties[PROP_ANSWER_SDP] = g_param_spec_string(
|
||||
"answer-sdp", "answer-sdp", "answer-sdp",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_ANSWER_SDP, matrix_event_call_answer_properties[PROP_ANSWER_SDP]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_answer_init(MatrixEventCallAnswer *matrix_event_call_answer)
|
||||
{
|
||||
MatrixEventCallAnswerPrivate *priv = matrix_event_call_answer_get_instance_private(matrix_event_call_answer);
|
||||
|
||||
priv->_answer_type = MATRIX_CALL_ANSWER_TYPE_UNKNOWN;
|
||||
priv->_answer_sdp = NULL;
|
||||
}
|
@ -1,43 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_CALL_ANSWER_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_CALL_ANSWER_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-call-base.h"
|
||||
# include "matrix-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# define MATRIX_EVENT_TYPE_CALL_ANSWER (matrix_event_call_answer_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventCallAnswer, matrix_event_call_answer, MATRIX_EVENT, CALL_ANSWER, MatrixEventCall)
|
||||
|
||||
struct _MatrixEventCallAnswerClass {
|
||||
MatrixEventCallClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventCallAnswer* matrix_event_call_answer_new (void);
|
||||
MatrixCallAnswerType matrix_event_call_answer_get_answer_type (MatrixEventCallAnswer *event);
|
||||
void matrix_event_call_answer_set_answer_type (MatrixEventCallAnswer *event, MatrixCallAnswerType answer_type);
|
||||
const gchar* matrix_event_call_answer_get_answer_sdp (MatrixEventCallAnswer *event);
|
||||
void matrix_event_call_answer_set_answer_sdp (MatrixEventCallAnswer *event, const gchar *answer_sdp);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_CALL_ANSWER_H__ */
|
@ -1,311 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-call-base.h"
|
||||
#include "matrix-types.h"
|
||||
#include "matrix-enumtypes.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-call-base
|
||||
* @short_description: Abstract base class for call related events
|
||||
*
|
||||
* Base class for m.call.* events.
|
||||
*/
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CALL_ID,
|
||||
PROP_VERSION,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *matrix_event_call_properties[NUM_PROPERTIES];
|
||||
|
||||
typedef struct {
|
||||
gchar *call_id;
|
||||
gint _version;
|
||||
} MatrixEventCallPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventCall:
|
||||
*
|
||||
* Object structure.
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventCall, matrix_event_call, MATRIX_EVENT_TYPE_ROOM);
|
||||
|
||||
static void
|
||||
matrix_event_call_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventCallPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_call_get_instance_private(MATRIX_EVENT_CALL(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
if ((node = json_object_get_member(content_root, "call_id")) != NULL) {
|
||||
g_free(priv->call_id);
|
||||
priv->call_id = g_strdup(json_node_get_string(node));
|
||||
} else {
|
||||
g_warning("content.call_id is missing from a m.call.* event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "version")) != NULL) {
|
||||
priv->_version = json_node_get_int(node);
|
||||
} else {
|
||||
g_warning("content.version is missing from a m.call.* event");
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_call_parent_class)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventCallPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_call_get_instance_private(MATRIX_EVENT_CALL(matrix_event_base));
|
||||
|
||||
if (priv->call_id == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.call.hangup event without call_id");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->_version < 0) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.call.hangup event without version");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
json_object_set_string_member(content_root, "call_id", priv->call_id);
|
||||
json_object_set_int_member(content_root, "version", priv->_version);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_call_parent_class)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_construct:
|
||||
* @object_type: the #GType of the object to be created
|
||||
*
|
||||
* Returns: (transfer full): a new instance of @object_type
|
||||
*/
|
||||
MatrixEventCall *
|
||||
matrix_event_call_construct(GType object_type)
|
||||
{
|
||||
return (MatrixEventCall *)matrix_event_room_construct(object_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_get_call_id:
|
||||
* @event: a #MatrixEventCall
|
||||
*
|
||||
* Get the identifier of the call.
|
||||
*
|
||||
* The value returned is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the call ID
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_call_get_call_id(MatrixEventCall *matrix_event_call)
|
||||
{
|
||||
MatrixEventCallPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_call != NULL, NULL);
|
||||
|
||||
priv = matrix_event_call_get_instance_private(matrix_event_call);
|
||||
|
||||
return priv->call_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_set_call_id:
|
||||
* @event: a #MatrixEventCall
|
||||
* @call_id: a call identifier
|
||||
*
|
||||
* Set the identifier of the call represented by @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_call_set_call_id(MatrixEventCall *matrix_event_call, const gchar *call_id)
|
||||
{
|
||||
MatrixEventCallPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_call != NULL);
|
||||
|
||||
priv = matrix_event_call_get_instance_private(matrix_event_call);
|
||||
|
||||
if (g_strcmp0(call_id, priv->call_id) != 0) {
|
||||
g_free(priv->call_id);
|
||||
priv->call_id = g_strdup(call_id);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_call, matrix_event_call_properties[PROP_CALL_ID]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_get_version:
|
||||
* @event: a #MatrixEventCall
|
||||
*
|
||||
* Get the version of the call.
|
||||
*
|
||||
* Returns: the call version
|
||||
*/
|
||||
gint
|
||||
matrix_event_call_get_version(MatrixEventCall *matrix_event_call)
|
||||
{
|
||||
MatrixEventCallPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_call != NULL, 0);
|
||||
|
||||
priv = matrix_event_call_get_instance_private(matrix_event_call);
|
||||
|
||||
return priv->_version;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_set_version:
|
||||
* @event: a #MatrixEventCall
|
||||
* @version: a call version
|
||||
*
|
||||
* Set the version of the call.
|
||||
*/
|
||||
void
|
||||
matrix_event_call_set_version(MatrixEventCall *matrix_event_call, gint version)
|
||||
{
|
||||
MatrixEventCallPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_call != NULL);
|
||||
|
||||
priv = matrix_event_call_get_instance_private(matrix_event_call);
|
||||
|
||||
if (priv->_version != version) {
|
||||
priv->_version = version;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_call, matrix_event_call_properties[PROP_VERSION]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventCallPrivate *priv = matrix_event_call_get_instance_private(MATRIX_EVENT_CALL(gobject));
|
||||
|
||||
g_free(priv->call_id);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_call_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventCall *matrix_event_call = MATRIX_EVENT_CALL(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CALL_ID:
|
||||
g_value_set_string(value, matrix_event_call_get_call_id(matrix_event_call));
|
||||
|
||||
break;
|
||||
case PROP_VERSION:
|
||||
g_value_set_int(value, matrix_event_call_get_version(matrix_event_call));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventCall *matrix_event_call = MATRIX_EVENT_CALL(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CALL_ID:
|
||||
matrix_event_call_set_call_id(matrix_event_call, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_VERSION:
|
||||
matrix_event_call_set_version(matrix_event_call, g_value_get_int(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_class_init(MatrixEventCallClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_call_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_call_real_to_json;
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_call_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_call_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_call_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventCall:call-id:
|
||||
*
|
||||
* The ID of the call this event relates to.
|
||||
*/
|
||||
matrix_event_call_properties[PROP_CALL_ID] = g_param_spec_string(
|
||||
"call-id", "call-id", "call-id",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_CALL_ID, matrix_event_call_properties[PROP_CALL_ID]);
|
||||
|
||||
/**
|
||||
* MatrixEventCall:version:
|
||||
*
|
||||
* The version of the VoIP specification this message adheres to.
|
||||
*/
|
||||
matrix_event_call_properties[PROP_VERSION] = g_param_spec_int(
|
||||
"version", "version", "version",
|
||||
-1, G_MAXINT, -1,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_VERSION, matrix_event_call_properties[PROP_VERSION]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_init(MatrixEventCall *matrix_event_call)
|
||||
{
|
||||
MatrixEventCallPrivate *priv = matrix_event_call_get_instance_private(matrix_event_call);
|
||||
|
||||
priv->call_id = NULL;
|
||||
priv->_version = -1;
|
||||
}
|
@ -1,55 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_CALL_BASE_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_CALL_BASE_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-room-base.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# define MATRIX_EVENT_TYPE_CALL (matrix_event_call_get_type ())
|
||||
# define MATRIX_EVENT_CALL(o) (G_TYPE_CHECK_INSTANCE_CAST((o), MATRIX_EVENT_TYPE_CALL, MatrixEventCall))
|
||||
# define MATRIX_EVENT_CALL_CLASS(c) (G_TYPE_CHECK_CLASS_CAST((c), MATRIX_EVENT_TYPE_CALL, MatrixEventCallClass))
|
||||
# define MATRIX_EVENT_IS_CALL(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_EVENT_TYPE_CALL))
|
||||
# define MATRIX_EVENT_IS_CALL_CLASS(c) (G_TYPE_CHECK_CLASS_TYPE((c), MATRIX_EVENT_TYPE_CALL))
|
||||
# define MATRIX_EVENT_CALL_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MATRIX_EVENT_TYPE_CALL, MatrixEventCallClass))
|
||||
|
||||
typedef struct _MatrixEventCall MatrixEventCall;
|
||||
typedef struct _MatrixEventCallClass MatrixEventCallClass;
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC(MatrixEventCall, g_object_unref)
|
||||
|
||||
struct _MatrixEventCall {
|
||||
MatrixEventRoom parent_instance;
|
||||
};
|
||||
|
||||
struct _MatrixEventCallClass {
|
||||
MatrixEventRoomClass parent_class;
|
||||
};
|
||||
|
||||
GType matrix_event_call_get_type (void) G_GNUC_CONST;
|
||||
MatrixEventCall* matrix_event_call_construct (GType object_type);
|
||||
const gchar *matrix_event_call_get_call_id (MatrixEventCall *event);
|
||||
void matrix_event_call_set_call_id (MatrixEventCall *event, const gchar *call_id);
|
||||
gint matrix_event_call_get_version (MatrixEventCall *event);
|
||||
void matrix_event_call_set_version (MatrixEventCall *event, gint version);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_CALL_BASE_H__ */
|
@ -1,497 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-call-candidates.h"
|
||||
#include "matrix-types.h"
|
||||
#include "matrix-enumtypes.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-call-candidates
|
||||
* @short_description: Event to represent call candidates
|
||||
*
|
||||
*/
|
||||
|
||||
struct _MatrixCallCandidate {
|
||||
gchar *sdp_mid; /// The SDP media type this candidate is intended for.
|
||||
gint *sdp_line_index; /// The index of the SDP 'm' line this candidate is intended for.
|
||||
gchar *candidate; /// The SDP 'a' line of the candidate.
|
||||
|
||||
guint refcount;
|
||||
};
|
||||
|
||||
/**
|
||||
* MatrixCallCandidate:
|
||||
*
|
||||
* An opaque data structure to represent a call candidate.
|
||||
*/
|
||||
G_DEFINE_BOXED_TYPE(MatrixCallCandidate, matrix_call_candidate, (GBoxedCopyFunc)matrix_call_candidate_unref, (GBoxedFreeFunc)matrix_call_candidate_unref);
|
||||
|
||||
/**
|
||||
* matrix_call_candidate_new:
|
||||
*
|
||||
* Create a new #MatrixCallCandidate object with a reference count of 1.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixCallCandidate object
|
||||
*/
|
||||
MatrixCallCandidate *
|
||||
matrix_call_candidate_new(void)
|
||||
{
|
||||
MatrixCallCandidate *ret;
|
||||
|
||||
ret = g_new0(MatrixCallCandidate, 1);
|
||||
ret->refcount = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_call_candidate_ref:
|
||||
* @candidate: a #MatrixCallCandidate
|
||||
*
|
||||
* Increment reference count on @candidate.
|
||||
*
|
||||
* Returns: (transfer full): the same object
|
||||
*/
|
||||
MatrixCallCandidate *
|
||||
matrix_call_candidate_ref(MatrixCallCandidate *matrix_call_candidate)
|
||||
{
|
||||
g_return_val_if_fail(matrix_call_candidate != NULL, NULL);
|
||||
|
||||
matrix_call_candidate->refcount++;
|
||||
|
||||
return matrix_call_candidate;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_call_candidate_unref:
|
||||
* @candidate: a #MatrixCallCandidate
|
||||
*
|
||||
* Decrement reference count on @candidate.
|
||||
*
|
||||
* If reference count reaches zero, @candidate gets freed.
|
||||
*/
|
||||
void
|
||||
matrix_call_candidate_unref(MatrixCallCandidate *matrix_call_candidate)
|
||||
{
|
||||
g_return_if_fail(matrix_call_candidate != NULL);
|
||||
|
||||
g_free(matrix_call_candidate->sdp_mid);
|
||||
g_free(matrix_call_candidate->candidate);
|
||||
g_free(matrix_call_candidate);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_call_candidate_get_sdp_mid:
|
||||
* @candidate: a #MatrixCallCandidate
|
||||
*
|
||||
* Get the SDP mid of @candidate.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the SDP mid
|
||||
*/
|
||||
const gchar *
|
||||
matrix_call_candidate_get_sdp_mid(MatrixCallCandidate *matrix_call_candidate)
|
||||
{
|
||||
g_return_val_if_fail(matrix_call_candidate != NULL, NULL);
|
||||
|
||||
return matrix_call_candidate->sdp_mid;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_call_candidate_set_sdp_mid:
|
||||
* @candidate: a #MatrixCallCandidate
|
||||
* @sdp_mid: an SDP mid
|
||||
*
|
||||
* Set the SDP mid for @candidate.
|
||||
*/
|
||||
void
|
||||
matrix_call_candidate_set_sdp_mid(MatrixCallCandidate *matrix_call_candidate, const gchar *sdp_mid)
|
||||
{
|
||||
g_return_if_fail(matrix_call_candidate);
|
||||
|
||||
g_free(matrix_call_candidate->sdp_mid);
|
||||
matrix_call_candidate->sdp_mid = g_strdup(sdp_mid);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_call_candidate_get_sdp_line_index:
|
||||
* @candidate: a #MatrixCallCandidate
|
||||
*
|
||||
* Get the SDP line of @candidate.
|
||||
*
|
||||
* The value returned is owned by @candidate and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the SDP line
|
||||
*/
|
||||
gint *
|
||||
matrix_call_candidate_get_sdp_line_index(MatrixCallCandidate *matrix_call_candidate)
|
||||
{
|
||||
g_return_val_if_fail(matrix_call_candidate != NULL, 0);
|
||||
|
||||
return matrix_call_candidate->sdp_line_index;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_call_candidate_set_sdp_line_index:
|
||||
* @candidate: a #MatrixCallCandidate
|
||||
* @sdp_line_index: (nullable) (transfer none): an SDP line index
|
||||
*
|
||||
* Set the SDP line index of @candidate.
|
||||
*/
|
||||
void
|
||||
matrix_call_candidate_set_sdp_line_index(MatrixCallCandidate *matrix_call_candidate, gint *sdp_line_index)
|
||||
{
|
||||
g_return_if_fail(matrix_call_candidate != NULL);
|
||||
|
||||
matrix_call_candidate->sdp_line_index = (g_free(matrix_call_candidate->sdp_line_index), NULL);
|
||||
|
||||
if (sdp_line_index != NULL) {
|
||||
matrix_call_candidate->sdp_line_index = g_new0(gint, 1);
|
||||
|
||||
*(matrix_call_candidate->sdp_line_index) = *sdp_line_index;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_call_candidate_get_candidate:
|
||||
* @candidate: a #MatrixCallCandidate
|
||||
*
|
||||
* Get the call candidate from @candidate.
|
||||
*
|
||||
* The returned value is owned by @candidate and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the candidate name
|
||||
*/
|
||||
const gchar *
|
||||
matrix_call_candidate_get_candidate(MatrixCallCandidate *matrix_call_candidate)
|
||||
{
|
||||
g_return_val_if_fail(matrix_call_candidate != NULL, NULL);
|
||||
|
||||
return matrix_call_candidate->candidate;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_call_candidate_set_candidate:
|
||||
* @candidate: a #MatrixCallCandidate
|
||||
* @candidate_name: (transfer none) (nullable): the name of the candidate
|
||||
*
|
||||
* Set the name of the call candidate.
|
||||
*/
|
||||
void
|
||||
matrix_call_candidate_set_candidate(MatrixCallCandidate *matrix_call_candidate, const gchar *candidate)
|
||||
{
|
||||
g_return_if_fail(matrix_call_candidate != NULL);
|
||||
|
||||
g_free(matrix_call_candidate->candidate);
|
||||
matrix_call_candidate->candidate = g_strdup(candidate);
|
||||
}
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CANDIDATES,
|
||||
NUM_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *matrix_event_call_candidates_properties[NUM_PROPS];
|
||||
|
||||
typedef struct {
|
||||
MatrixCallCandidate** _candidates;
|
||||
gint _candidates_len;
|
||||
} MatrixEventCallCandidatesPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventCallCandidates:
|
||||
*
|
||||
* This event is sent by callers after sending an invite and by the callee after answering.
|
||||
* Its purpose is to give the other party additional ICE candidates to try using to communicate.
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventCallCandidates, matrix_event_call_candidates, MATRIX_EVENT_TYPE_CALL);
|
||||
|
||||
static void
|
||||
matrix_event_call_candidates_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventCallCandidatesPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_call_candidates_get_instance_private(MATRIX_EVENT_CALL_CANDIDATES(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
if ((node = json_object_get_member(content_root, "candidates")) != NULL) {
|
||||
JsonArray *candidates = json_node_get_array(node);
|
||||
gint len = json_array_get_length(candidates);
|
||||
|
||||
priv->_candidates = g_new(MatrixCallCandidate *, len);
|
||||
|
||||
for (gint i = 0; i < len; i++) {
|
||||
JsonNode *cand_node = json_array_get_element(candidates, i);
|
||||
JsonObject *cand_root = json_node_get_object(cand_node);
|
||||
priv->_candidates[i] = matrix_call_candidate_new();
|
||||
|
||||
if ((node = json_object_get_member(cand_root, "sdpMid")) != NULL) {
|
||||
priv->_candidates[i]->sdp_mid = g_strdup(json_node_get_string(node));
|
||||
} else {
|
||||
g_warning("sdpMid is missing from a candidate of a m.call.candidates event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(cand_root, "sdpMLineIndex")) != NULL) {
|
||||
gint line_index = json_node_get_int(node);
|
||||
|
||||
matrix_call_candidate_set_sdp_line_index(priv->_candidates[i], &line_index);
|
||||
} else {
|
||||
g_warning("sdpMLineIndex is missing from a candidate of a m.call.candidates event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(cand_root, "candidate")) != NULL) {
|
||||
priv->_candidates[i]->candidate = g_strdup(json_node_get_string(node));
|
||||
} else {
|
||||
g_warning("candidate is missing from a candidate of a m.call.candidates event");
|
||||
}
|
||||
};
|
||||
} else {
|
||||
g_warning("content.candidates is missing from a m.call.candidates event");
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_call_candidates_parent_class)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_candidates_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventCallCandidatesPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonArray *cands;
|
||||
JsonNode *content_node;
|
||||
JsonNode *cands_node;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_call_candidates_get_instance_private(MATRIX_EVENT_CALL_CANDIDATES(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
if (priv->_candidates_len < 1) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.call.candidates event without candidates");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
cands = json_array_new();
|
||||
cands_node = json_node_new(JSON_NODE_ARRAY);
|
||||
json_node_set_array(cands_node, cands);
|
||||
json_object_set_member(content_root, "candidates", cands_node);
|
||||
|
||||
for (gint i = 0; i < priv->_candidates_len; i++) {
|
||||
MatrixCallCandidate *entry = priv->_candidates[i];
|
||||
JsonObject *cand_root;
|
||||
JsonNode *cand_node;
|
||||
|
||||
if (entry->sdp_mid == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.call.candidates event with a missing sdpMid for candidates");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (entry->candidate == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.call.candidates event with a missing candidate for candidates");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
cand_root = json_object_new();
|
||||
cand_node = json_node_new(JSON_NODE_OBJECT);
|
||||
json_node_set_object(cand_node, cand_root);
|
||||
|
||||
json_object_set_string_member(cand_root, "sdpMid", entry->sdp_mid);
|
||||
json_object_set_string_member(cand_root, "candidate", entry->candidate);
|
||||
|
||||
if (entry->sdp_line_index != NULL) {
|
||||
json_object_set_int_member(cand_root, "sdpMLineIndex", *(entry->sdp_line_index));
|
||||
}
|
||||
|
||||
json_array_add_element(cands, cand_node);
|
||||
}
|
||||
|
||||
if (json_array_get_length(cands) < 1) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.call.candidates event with empty candidates list");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_call_candidates_parent_class)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_candidates_new:
|
||||
*
|
||||
* Create a new #MatrixEventCallCandidates object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventCallCandidates object
|
||||
*/
|
||||
MatrixEventCallCandidates *
|
||||
matrix_event_call_candidates_new(void)
|
||||
{
|
||||
return (MatrixEventCallCandidates *)matrix_event_call_construct(MATRIX_EVENT_TYPE_CALL_CANDIDATES);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_candidates_get_candidates:
|
||||
* @event: a #MatrixEventCallCandidates:
|
||||
* @n_candidates: (nullable): placeholder for the length of the list, or %NULL to ignore
|
||||
*
|
||||
* Get the list of the candidates from @event.
|
||||
*
|
||||
* The returned value is owned by @event, and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the list of candidates
|
||||
*/
|
||||
MatrixCallCandidate **
|
||||
matrix_event_call_candidates_get_candidates(MatrixEventCallCandidates *matrix_event_call_candidates, int *n_candidates)
|
||||
{
|
||||
MatrixEventCallCandidatesPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_call_candidates != NULL, NULL);
|
||||
|
||||
priv = matrix_event_call_candidates_get_instance_private(matrix_event_call_candidates);
|
||||
|
||||
if (n_candidates != NULL) {
|
||||
*n_candidates = priv->_candidates_len;
|
||||
}
|
||||
|
||||
return priv->_candidates;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_candidates_set_candidates:
|
||||
* @event: a #MatrixEventCallCandidates
|
||||
* @candidates: a list of #MatrixCallCandidate objects
|
||||
* @n_candidates: the number of elements in @candidates
|
||||
*
|
||||
* Set the list of call candidates in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_call_candidates_set_candidates(MatrixEventCallCandidates *matrix_event_call_candidates, MatrixCallCandidate **candidates, int n_candidates)
|
||||
{
|
||||
MatrixEventCallCandidatesPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_call_candidates != NULL);
|
||||
|
||||
priv = matrix_event_call_candidates_get_instance_private(matrix_event_call_candidates);
|
||||
|
||||
for (gint i = 0; i < priv->_candidates_len; i++) {
|
||||
matrix_call_candidate_unref(priv->_candidates[i]);
|
||||
}
|
||||
|
||||
g_free(priv->_candidates);
|
||||
|
||||
priv->_candidates = (MatrixCallCandidate **)g_new(MatrixCallCandidate, n_candidates);
|
||||
priv->_candidates_len = n_candidates;
|
||||
|
||||
for (gint i = 0; i < n_candidates; i++) {
|
||||
priv->_candidates[i] = matrix_call_candidate_ref(candidates[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_candidates_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventCallCandidatesPrivate *priv = matrix_event_call_candidates_get_instance_private(MATRIX_EVENT_CALL_CANDIDATES(gobject));
|
||||
|
||||
for (gint i = 0; i < priv->_candidates_len; i++) {
|
||||
matrix_call_candidate_unref(priv->_candidates[i]);
|
||||
}
|
||||
|
||||
g_free(priv->_candidates);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_call_candidates_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_candidates_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventCallCandidates *matrix_event_call_candidates = MATRIX_EVENT_CALL_CANDIDATES(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CANDIDATES:
|
||||
g_value_set_boxed(value, matrix_event_call_candidates_get_candidates(matrix_event_call_candidates, NULL));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_candidates_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventCallCandidates *matrix_event_call_candidates = MATRIX_EVENT_CALL_CANDIDATES(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CANDIDATES:
|
||||
{
|
||||
gpointer boxed = g_value_get_boxed(value);
|
||||
|
||||
matrix_event_call_candidates_set_candidates(matrix_event_call_candidates, g_value_get_boxed(value), (boxed == NULL) ? 0 : g_strv_length(boxed));
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_candidates_class_init(MatrixEventCallCandidatesClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_call_candidates_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_call_candidates_real_to_json;
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_call_candidates_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_call_candidates_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_call_candidates_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventCallCandidates:candidates:
|
||||
*
|
||||
* The list of call candidates.
|
||||
*/
|
||||
matrix_event_call_candidates_properties[PROP_CANDIDATES] = g_param_spec_boxed(
|
||||
"candidates", "candidates", "candidates",
|
||||
MATRIX_TYPE_CALL_CANDIDATE,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_CANDIDATES, matrix_event_call_candidates_properties[PROP_CANDIDATES]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_candidates_init(MatrixEventCallCandidates *matrix_event_call_candidates)
|
||||
{
|
||||
MatrixEventCallCandidatesPrivate *priv = matrix_event_call_candidates_get_instance_private(matrix_event_call_candidates);
|
||||
|
||||
priv->_candidates = NULL;
|
||||
}
|
@ -1,55 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_CALL_CANDIDATES_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_CALL_CANDIDATES_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-call-base.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# define MATRIX_TYPE_CALL_CANDIDATE matrix_call_candidate_get_type()
|
||||
typedef struct _MatrixCallCandidate MatrixCallCandidate;
|
||||
|
||||
GType matrix_call_candidate_get_type(void) G_GNUC_CONST;
|
||||
MatrixCallCandidate *matrix_call_candidate_new(void);
|
||||
MatrixCallCandidate *matrix_call_candidate_ref(MatrixCallCandidate *candidate);
|
||||
void matrix_call_candidate_unref(MatrixCallCandidate *candidate);
|
||||
const gchar *matrix_call_candidate_get_sdp_mid(MatrixCallCandidate *candidate);
|
||||
void matrix_call_candidate_set_sdp_mid(MatrixCallCandidate *candidate, const gchar *sdp_mid);
|
||||
gint *matrix_call_candidate_get_sdp_line_index(MatrixCallCandidate *candidate);
|
||||
void matrix_call_candidate_set_sdp_line_index(MatrixCallCandidate *candidate, gint *sdp_line_index);
|
||||
const gchar *matrix_call_candidate_get_candidate(MatrixCallCandidate *candidate);
|
||||
void matrix_call_candidate_set_candidate(MatrixCallCandidate *candidate, const gchar *candidate_name);
|
||||
|
||||
#define MATRIX_EVENT_TYPE_CALL_CANDIDATES (matrix_event_call_candidates_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventCallCandidates, matrix_event_call_candidates, MATRIX_EVENT, CALL_CANDIDATES, MatrixEventCall)
|
||||
|
||||
struct _MatrixEventCallCandidatesClass {
|
||||
MatrixEventCallClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventCallCandidates* matrix_event_call_candidates_new (void);
|
||||
MatrixCallCandidate* matrix_event_call_candidates_candidate_dup (const MatrixCallCandidate *event);
|
||||
MatrixCallCandidate** matrix_event_call_candidates_get_candidates (MatrixEventCallCandidates *event, int *n_candidates);
|
||||
void matrix_event_call_candidates_set_candidates (MatrixEventCallCandidates *event, MatrixCallCandidate **candidates, int n_candidates);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_CALL_CANDIDATES_H__ */
|
@ -1,73 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-call-hangup.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-call-hangup
|
||||
* @short_description: event to signal that a calling party has hung up the line
|
||||
*
|
||||
* This event is 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MatrixEventCallHangup:
|
||||
*
|
||||
*/
|
||||
G_DEFINE_TYPE(MatrixEventCallHangup, matrix_event_call_hangup, MATRIX_EVENT_TYPE_CALL);
|
||||
|
||||
static void
|
||||
matrix_event_call_hangup_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_call_hangup_parent_class)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_hangup_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_call_hangup_parent_class)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_hangup_new:
|
||||
*
|
||||
* Create a new #MatrixEventCallHangup object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventCallHangup object
|
||||
*/
|
||||
MatrixEventCallHangup *
|
||||
matrix_event_call_hangup_new(void)
|
||||
{
|
||||
return (MatrixEventCallHangup *)matrix_event_call_construct(MATRIX_EVENT_TYPE_CALL_HANGUP);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_hangup_class_init(MatrixEventCallHangupClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_call_hangup_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_call_hangup_real_to_json;
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_hangup_init(MatrixEventCallHangup *matrix_event_call_hangup)
|
||||
{}
|
@ -1,38 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_CALL_HANGUP_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_CALL_HANGUP_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-call-base.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# define MATRIX_EVENT_TYPE_CALL_HANGUP matrix_event_call_hangup_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventCallHangup, matrix_event_call_hangup, MATRIX_EVENT, CALL_HANGUP, MatrixEventCall)
|
||||
|
||||
struct _MatrixEventCallHangupClass {
|
||||
MatrixEventCallClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventCallHangup* matrix_event_call_hangup_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_CALL_HANGUP_H__ */
|
@ -1,420 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-call-invite.h"
|
||||
#include "utils.h"
|
||||
#include "config.h"
|
||||
#include "matrix-enumtypes.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-call-invite
|
||||
* @short_description: event to signal a call request
|
||||
*
|
||||
* This event is sent by the caller when they wish to establish a call.
|
||||
*/
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_OFFER_TYPE,
|
||||
PROP_SDP,
|
||||
PROP_LIFETIME,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *matrix_event_call_invite_properties[NUM_PROPERTIES];
|
||||
|
||||
typedef struct {
|
||||
MatrixCallOfferType _offer_type;
|
||||
gchar* _sdp;
|
||||
gint _lifetime;
|
||||
} MatrixEventCallInvitePrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventCallInvite:
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventCallInvite, matrix_event_call_invite, MATRIX_EVENT_TYPE_CALL);
|
||||
|
||||
static void
|
||||
matrix_event_call_invite_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventCallInvitePrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
|
||||
g_return_if_fail (json_data != NULL);
|
||||
|
||||
priv = matrix_event_call_invite_get_instance_private(MATRIX_EVENT_CALL_INVITE(matrix_event_base));
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
if ((node = json_object_get_member(content_root, "offer")) != NULL) {
|
||||
JsonObject *offer_root = json_node_get_object(node);
|
||||
|
||||
if ((node = json_object_get_member(offer_root, "type")) != NULL) {
|
||||
GError *inner_error = NULL;
|
||||
MatrixCallOfferType offer_type = _matrix_g_enum_nick_to_value(MATRIX_TYPE_CALL_OFFER_TYPE, json_node_get_string(node), &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
priv->_offer_type = MATRIX_CALL_OFFER_TYPE_UNKNOWN;
|
||||
|
||||
#ifdef DEBUG
|
||||
g_warning("Unknown value %s in content.offer.type of a m.call.invite event", json_node_get_string(node));
|
||||
#endif
|
||||
} else {
|
||||
priv->_offer_type = offer_type;
|
||||
}
|
||||
} else {
|
||||
g_warning("content.offer.type is missing from a m.call.invite event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(offer_root, "sdp")) != NULL) {
|
||||
g_free(priv->_sdp);
|
||||
priv->_sdp = g_strdup(json_node_get_string(node));
|
||||
} else {
|
||||
g_warning("content.offer.sdp is missing from a m.call.invite event");
|
||||
}
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "lifetime")) != NULL) {
|
||||
priv->_lifetime = json_node_get_int(node);
|
||||
} else {
|
||||
g_warning("content.lifetime is missing from a m.call.invite event");
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_call_invite_parent_class)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_invite_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventCallInvitePrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonObject *offer_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *offer_node;
|
||||
gchar *offer_type;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_call_invite_get_instance_private(MATRIX_EVENT_CALL_INVITE(matrix_event_base));
|
||||
|
||||
if (priv->_offer_type == MATRIX_CALL_OFFER_TYPE_UNKNOWN) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.call.invite without a valid offer.type");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->_sdp == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.call.invite without offer.sdp");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->_lifetime < 0) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.call.invite without lifetime");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
json_object_set_int_member(content_root, "lifetime", priv->_lifetime);
|
||||
|
||||
offer_root = json_object_new();
|
||||
offer_node = json_node_new(JSON_NODE_OBJECT);
|
||||
json_node_set_object(offer_node, offer_root);
|
||||
|
||||
offer_type = _matrix_g_enum_to_string(MATRIX_TYPE_CALL_OFFER_TYPE, priv->_offer_type, '_');
|
||||
json_object_set_string_member(offer_root, "type", offer_type);
|
||||
g_free(offer_type);
|
||||
|
||||
json_object_set_string_member(offer_root, "sdp", priv->_sdp);
|
||||
|
||||
json_object_set_member(content_root, "offer", offer_node);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_call_invite_parent_class)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_invite_new:
|
||||
*
|
||||
* Create a new #MatrixEventCallInvite object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventCallInvite object
|
||||
*/
|
||||
MatrixEventCallInvite *
|
||||
matrix_event_call_invite_new(void) {
|
||||
return (MatrixEventCallInvite *)matrix_event_call_construct(MATRIX_EVENT_TYPE_CALL_INVITE);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_invite_get_offer_type:
|
||||
* @event: a #MatrixEventCallInvite
|
||||
*
|
||||
* Get the offer type of @event.
|
||||
*
|
||||
* Returns: the call offer type
|
||||
*/
|
||||
MatrixCallOfferType
|
||||
matrix_event_call_invite_get_offer_type(MatrixEventCallInvite *matrix_event_call_invite)
|
||||
{
|
||||
MatrixEventCallInvitePrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_call_invite != NULL, 0);
|
||||
|
||||
priv = matrix_event_call_invite_get_instance_private(matrix_event_call_invite);
|
||||
|
||||
return priv->_offer_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_invite_set_offer_type:
|
||||
* @event: a #MatrixEventCallInvite
|
||||
* @offer_type: the type of the call offer
|
||||
*
|
||||
* Set the offer type of the call in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_call_invite_set_offer_type(MatrixEventCallInvite *matrix_event_call_invite, MatrixCallOfferType offer_type)
|
||||
{
|
||||
MatrixEventCallInvitePrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_call_invite != NULL);
|
||||
|
||||
|
||||
priv = matrix_event_call_invite_get_instance_private(matrix_event_call_invite);
|
||||
|
||||
if (priv->_offer_type != offer_type) {
|
||||
priv->_offer_type = offer_type;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_call_invite, matrix_event_call_invite_properties[PROP_OFFER_TYPE]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_invite_get_sdp:
|
||||
* @event: a #MatrixEventCallInvite
|
||||
*
|
||||
* Get the SDP line of the call.
|
||||
*
|
||||
* The returned value is owned by @event and should not by freed.
|
||||
*.
|
||||
* Returns: (transfer none): the SDP line of the call
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_call_invite_get_sdp(MatrixEventCallInvite *matrix_event_call_invite)
|
||||
{
|
||||
MatrixEventCallInvitePrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_call_invite != NULL, NULL);
|
||||
|
||||
priv = matrix_event_call_invite_get_instance_private(matrix_event_call_invite);
|
||||
|
||||
return priv->_sdp;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_invite_set_sdp:
|
||||
* @event: a #MatrixEventCallInvite
|
||||
* @sdp: an SDP line
|
||||
*
|
||||
* Set the SDP line ID of the call.
|
||||
*/
|
||||
void
|
||||
matrix_event_call_invite_set_sdp(MatrixEventCallInvite *matrix_event_call_invite, const gchar *sdp)
|
||||
{
|
||||
MatrixEventCallInvitePrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_call_invite != NULL);
|
||||
|
||||
priv = matrix_event_call_invite_get_instance_private(matrix_event_call_invite);
|
||||
|
||||
if (g_strcmp0(sdp, priv->_sdp) != 0) {
|
||||
g_free(priv->_sdp);
|
||||
priv->_sdp = g_strdup(sdp);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_call_invite, matrix_event_call_invite_properties[PROP_SDP]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_invite_get_lifetime:
|
||||
* @event: a #MatrixEventCallInvite
|
||||
*
|
||||
* Get the lifetime of the call in @event.
|
||||
*
|
||||
* Returns: the lifetime, in milliseconds.
|
||||
*/
|
||||
gint
|
||||
matrix_event_call_invite_get_lifetime(MatrixEventCallInvite *matrix_event_call_invite)
|
||||
{
|
||||
MatrixEventCallInvitePrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_call_invite != NULL, 0);
|
||||
|
||||
priv = matrix_event_call_invite_get_instance_private(matrix_event_call_invite);
|
||||
|
||||
return priv->_lifetime;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_call_invite_set_lifetime:
|
||||
* @event: a #MatrixEventCallInvite
|
||||
* @lifetime: the lifetime of @event
|
||||
*
|
||||
* Set the lifetime of @event, in milliseconds.
|
||||
*/
|
||||
void
|
||||
matrix_event_call_invite_set_lifetime(MatrixEventCallInvite *matrix_event_call_invite, gint lifetime)
|
||||
{
|
||||
MatrixEventCallInvitePrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_call_invite != NULL);
|
||||
|
||||
priv = matrix_event_call_invite_get_instance_private(matrix_event_call_invite);
|
||||
|
||||
if (priv->_lifetime != lifetime) {
|
||||
priv->_lifetime = lifetime;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_call_invite, matrix_event_call_invite_properties[PROP_LIFETIME]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_invite_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventCallInvitePrivate *priv = matrix_event_call_invite_get_instance_private(MATRIX_EVENT_CALL_INVITE(gobject));
|
||||
|
||||
g_free(priv->_sdp);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_call_invite_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_invite_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventCallInvite *matrix_event_call_invite = MATRIX_EVENT_CALL_INVITE(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_OFFER_TYPE:
|
||||
g_value_set_enum(value, matrix_event_call_invite_get_offer_type(matrix_event_call_invite));
|
||||
|
||||
break;
|
||||
case PROP_SDP:
|
||||
g_value_set_string(value, matrix_event_call_invite_get_sdp(matrix_event_call_invite));
|
||||
|
||||
break;
|
||||
case PROP_LIFETIME:
|
||||
g_value_set_int(value, matrix_event_call_invite_get_lifetime(matrix_event_call_invite));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_invite_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventCallInvite *matrix_event_call_invite = MATRIX_EVENT_CALL_INVITE(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_OFFER_TYPE:
|
||||
matrix_event_call_invite_set_offer_type(matrix_event_call_invite, g_value_get_enum(value));
|
||||
|
||||
break;
|
||||
case PROP_SDP:
|
||||
matrix_event_call_invite_set_sdp(matrix_event_call_invite, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_LIFETIME:
|
||||
matrix_event_call_invite_set_lifetime(matrix_event_call_invite, g_value_get_int(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_invite_class_init(MatrixEventCallInviteClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_call_invite_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_call_invite_real_to_json;
|
||||
G_OBJECT_CLASS (klass)->get_property = matrix_event_call_invite_get_property;
|
||||
G_OBJECT_CLASS (klass)->set_property = matrix_event_call_invite_set_property;
|
||||
G_OBJECT_CLASS (klass)->finalize = matrix_event_call_invite_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventCallInvite:offer-type:
|
||||
*
|
||||
* The type of session description.
|
||||
*/
|
||||
matrix_event_call_invite_properties[PROP_OFFER_TYPE] = g_param_spec_enum(
|
||||
"offer-type", "offer-type", "offer-type",
|
||||
MATRIX_TYPE_CALL_OFFER_TYPE, MATRIX_CALL_OFFER_TYPE_UNKNOWN,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_OFFER_TYPE, matrix_event_call_invite_properties[PROP_OFFER_TYPE]);
|
||||
|
||||
/**
|
||||
* MatrixEventCallInvite:sdp:
|
||||
*
|
||||
* The SDP text of the session description.
|
||||
*/
|
||||
matrix_event_call_invite_properties[PROP_SDP] = g_param_spec_string(
|
||||
"sdp", "sdp", "sdp",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_SDP, matrix_event_call_invite_properties[PROP_SDP]);
|
||||
|
||||
/**
|
||||
* MatrixEventCallInvite:lifetime:
|
||||
*
|
||||
* The time in milliseconds that the invite is valid for. Once the invite age exceeds this
|
||||
* value, clients should discard it. They should also no longer show the call as awaiting
|
||||
* an answer in the UI.
|
||||
*/
|
||||
matrix_event_call_invite_properties[PROP_LIFETIME] = g_param_spec_int(
|
||||
"lifetime", "lifetime", "lifetime",
|
||||
G_MININT, G_MAXINT, -1,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_LIFETIME, matrix_event_call_invite_properties[PROP_LIFETIME]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_call_invite_init(MatrixEventCallInvite *matrix_event_call_invite)
|
||||
{
|
||||
MatrixEventCallInvitePrivate *priv = matrix_event_call_invite_get_instance_private(matrix_event_call_invite);
|
||||
|
||||
priv->_offer_type = MATRIX_CALL_OFFER_TYPE_UNKNOWN;
|
||||
priv->_sdp = NULL;
|
||||
priv->_lifetime = -1;
|
||||
}
|
@ -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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_CALL_INVITE_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_CALL_INVITE_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-call-base.h"
|
||||
# include "matrix-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MATRIX_EVENT_TYPE_CALL_INVITE (matrix_event_call_invite_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventCallInvite, matrix_event_call_invite, MATRIX_EVENT, CALL_INVITE, MatrixEventCall)
|
||||
|
||||
struct _MatrixEventCallInviteClass {
|
||||
MatrixEventCallClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventCallInvite* matrix_event_call_invite_new (void);
|
||||
MatrixCallOfferType matrix_event_call_invite_get_offer_type (MatrixEventCallInvite *event);
|
||||
void matrix_event_call_invite_set_offer_type (MatrixEventCallInvite *event, MatrixCallOfferType offer_type);
|
||||
const gchar* matrix_event_call_invite_get_sdp (MatrixEventCallInvite *event);
|
||||
void matrix_event_call_invite_set_sdp (MatrixEventCallInvite *event, const gchar* sdp);
|
||||
gint matrix_event_call_invite_get_lifetime (MatrixEventCallInvite *event);
|
||||
void matrix_event_call_invite_set_lifetime (MatrixEventCallInvite *event, gint lifetime);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_CALL_INVITE_H__ */
|
@ -1,574 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-presence.h"
|
||||
#include "matrix-event-room-base.h"
|
||||
#include "matrix-enumtypes.h"
|
||||
#include "config.h"
|
||||
#include "utils.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-presence
|
||||
* @short_description: event to inform the client of a users’s presence change
|
||||
*
|
||||
* Informs the client of a user's presence state change.
|
||||
*/
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_AVATAR_URL,
|
||||
PROP_DISPLAY_NAME,
|
||||
PROP_LAST_ACTIVE_AGO,
|
||||
PROP_USER_ID,
|
||||
PROP_PRESENCE,
|
||||
NUM_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *matrix_event_presence_properties[NUM_PROPS];
|
||||
|
||||
typedef struct {
|
||||
gchar *_avatar_url;
|
||||
gchar *_display_name;
|
||||
glong _last_active_ago;
|
||||
gchar *_user_id;
|
||||
gchar *_event_id;
|
||||
MatrixPresence _presence;
|
||||
} MatrixEventPresencePrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventPresence:
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventPresence, matrix_event_presence, MATRIX_EVENT_TYPE_BASE);
|
||||
|
||||
static void
|
||||
matrix_event_presence_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventPresencePrivate *priv;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_presence_get_instance_private(MATRIX_EVENT_PRESENCE(matrix_event_base));
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
if ((node = json_object_get_member(root, "event_id")) != NULL) {
|
||||
g_free(priv->_event_id);
|
||||
priv->_event_id = g_strdup(json_node_get_string(node));
|
||||
} else if (DEBUG) {
|
||||
g_warning("event_id is missing from a m.presence event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "user_id")) != NULL) {
|
||||
g_free(priv->_user_id);
|
||||
priv->_user_id = g_strdup(json_node_get_string(node));
|
||||
} else if (DEBUG) {
|
||||
g_warning("content.user_id is missing from the m.presence event");
|
||||
|
||||
// Workaround for having sender instead of content.user_id
|
||||
// in most (room-dependent) presence events
|
||||
if ((node = json_object_get_member(root, "sender")) != NULL) {
|
||||
g_free(priv->_user_id);
|
||||
priv->_user_id = g_strdup(json_node_get_string(node));
|
||||
}
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "last_active_ago")) != NULL) {
|
||||
priv->_last_active_ago = json_node_get_int(node);
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "avatar_url")) != NULL) {
|
||||
g_free(priv->_avatar_url);
|
||||
priv->_avatar_url = g_strdup(json_node_get_string(node));
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "displayname")) != NULL) {
|
||||
g_free(priv->_display_name);
|
||||
priv->_display_name = g_strdup(json_node_get_string(node));
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "presence")) != NULL) {
|
||||
MatrixPresence presence;
|
||||
|
||||
presence = _matrix_g_enum_nick_to_value(MATRIX_TYPE_PRESENCE, json_node_get_string(node), &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_clear_error(&inner_error);
|
||||
priv->_presence = MATRIX_PRESENCE_UNKNOWN;
|
||||
|
||||
if (DEBUG) {
|
||||
g_warning("Unknown value %s for content.presence in a m.presence event", json_node_get_string(node));
|
||||
}
|
||||
} else {
|
||||
priv->_presence = presence;
|
||||
}
|
||||
} else if (DEBUG) {
|
||||
g_warning("content.presence is missing from the m.presence event");
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_presence_parent_class)->from_json(matrix_event_base, json_data, &inner_error);
|
||||
|
||||
if ((inner_error != NULL)) {
|
||||
g_propagate_error(error, inner_error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_presence_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventPresencePrivate *priv;
|
||||
JsonNode *content_node;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_presence_get_instance_private(MATRIX_EVENT_PRESENCE(matrix_event_base));
|
||||
|
||||
if (priv->_presence == MATRIX_PRESENCE_UNKNOWN) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_UNKNOWN_VALUE,
|
||||
"Won't generate a m.presence event with an unkwnown presence");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->_user_id == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.presence event without sender");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->_event_id == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.presence event without event_id");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
json_object_set_string_member(root, "event_id", priv->_event_id);
|
||||
|
||||
json_object_set_string_member(content_root, "user_id", priv->_user_id);
|
||||
json_object_set_string_member(content_root, "presence", _matrix_g_enum_to_string(MATRIX_TYPE_PRESENCE, priv->_presence, '_'));
|
||||
|
||||
if (priv->_last_active_ago >= 0) {
|
||||
json_object_set_int_member(content_root, "last_active_ago", priv->_last_active_ago);
|
||||
}
|
||||
|
||||
if (priv->_avatar_url != NULL) {
|
||||
json_object_set_string_member(content_root, "avatar_url", priv->_avatar_url);
|
||||
}
|
||||
|
||||
if (priv->_display_name != NULL) {
|
||||
json_object_set_string_member(content_root, "displayname", priv->_display_name);
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_presence_parent_class)->to_json(matrix_event_base, json_data, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_presence_new:
|
||||
*
|
||||
* Create a new #MatrixEventPresence object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventPresence object
|
||||
*/
|
||||
MatrixEventPresence *
|
||||
matrix_event_presence_new(void)
|
||||
{
|
||||
return (MatrixEventPresence *)matrix_event_base_construct(MATRIX_EVENT_TYPE_PRESENCE);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_presence_get_avatar_url:
|
||||
* @event: a #MatrixEventPresence
|
||||
*
|
||||
* Get the URL of the user’s avatar in @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none): the avatar URL
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_presence_get_avatar_url(MatrixEventPresence *matrix_event_presence)
|
||||
{
|
||||
MatrixEventPresencePrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_presence != NULL, NULL);
|
||||
|
||||
priv = matrix_event_presence_get_instance_private(matrix_event_presence);
|
||||
|
||||
return priv->_avatar_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_presence_set_avatar_url:
|
||||
* @event: a #MatrixEventPresence
|
||||
* @avatar_url: (transfer none): an URL to the media of the user’s avatar
|
||||
*
|
||||
* Set the URL af the user’s avatar in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_presence_set_avatar_url(MatrixEventPresence *matrix_event_presence, const gchar *avatar_url)
|
||||
{
|
||||
MatrixEventPresencePrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_presence != NULL);
|
||||
|
||||
priv = matrix_event_presence_get_instance_private(matrix_event_presence);
|
||||
|
||||
if (g_strcmp0(avatar_url, priv->_avatar_url) != 0) {
|
||||
g_free(priv->_avatar_url);
|
||||
priv->_avatar_url = g_strdup (avatar_url);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_presence, matrix_event_presence_properties[PROP_AVATAR_URL]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_presence_get_display_name:
|
||||
* @event: a #MatrixEventPresence
|
||||
*
|
||||
* Get the display name of the user in @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none): a display name
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_presence_get_display_name(MatrixEventPresence *matrix_event_presence)
|
||||
{
|
||||
MatrixEventPresencePrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_presence != NULL, NULL);
|
||||
|
||||
priv = matrix_event_presence_get_instance_private(matrix_event_presence);
|
||||
|
||||
return priv->_display_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_presence_set_display_name:
|
||||
* @event: a #MatrixEventPresence
|
||||
* @display_name: (transfer none): a display name
|
||||
*
|
||||
* Set the display name of the user in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_presence_set_display_name (MatrixEventPresence *matrix_event_presence, const gchar *display_name)
|
||||
{
|
||||
MatrixEventPresencePrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_presence != NULL);
|
||||
|
||||
priv = matrix_event_presence_get_instance_private(matrix_event_presence);
|
||||
|
||||
if (g_strcmp0(display_name, priv->_display_name) != 0) {
|
||||
g_free(priv->_display_name);
|
||||
priv->_display_name = g_strdup(display_name);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_presence, matrix_event_presence_properties[PROP_DISPLAY_NAME]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_presence_get_last_active_ago:
|
||||
* @event: a #MatrixEventPresence
|
||||
*
|
||||
* Get the number of milliseconds since this user was last active.
|
||||
*
|
||||
* Returns: the number of milliseconds
|
||||
*/
|
||||
glong
|
||||
matrix_event_presence_get_last_active_ago(MatrixEventPresence *matrix_event_presence)
|
||||
{
|
||||
MatrixEventPresencePrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_presence != NULL, -1);
|
||||
|
||||
priv = matrix_event_presence_get_instance_private(matrix_event_presence);
|
||||
|
||||
return priv->_last_active_ago;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_presence_set_last_active_ago:
|
||||
* @event: a #MatrixEventPresence
|
||||
* @last_active_ago: the number of milliseconds since the user is inactive
|
||||
*
|
||||
* Set the number of milliseconds since the user in @event is inactive.
|
||||
*/
|
||||
void
|
||||
matrix_event_presence_set_last_active_ago(MatrixEventPresence *matrix_event_presence, glong last_active_ago)
|
||||
{
|
||||
MatrixEventPresencePrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_presence != NULL);
|
||||
|
||||
priv = matrix_event_presence_get_instance_private(matrix_event_presence);
|
||||
|
||||
if (priv->_last_active_ago != last_active_ago) {
|
||||
priv->_last_active_ago = last_active_ago;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_presence, matrix_event_presence_properties[PROP_LAST_ACTIVE_AGO]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_presence_get_user_id:
|
||||
* @event: a #MatrixEventPresence
|
||||
*
|
||||
* Get the user ID @event belongs to.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none): a user ID
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_presence_get_user_id(MatrixEventPresence *event)
|
||||
{
|
||||
return matrix_event_room_get_sender(MATRIX_EVENT_ROOM(event));
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_presence_set_user_id:
|
||||
* @event: a #MatrixEventPresence
|
||||
* @user_id: (transfer none): the user ID @event should belong to
|
||||
*
|
||||
* Set the user ID in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_presence_set_user_id(MatrixEventPresence *event, const gchar *user_id)
|
||||
{
|
||||
matrix_event_room_set_sender(MATRIX_EVENT_ROOM(event), user_id);
|
||||
|
||||
// TODO: Send this only if the property actually changed
|
||||
g_object_notify_by_pspec((GObject *)event, matrix_event_presence_properties[PROP_USER_ID]);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_presence_get_presence:
|
||||
* @event: a #MatrixEventPresence
|
||||
*
|
||||
* Get the presence state of the user in @event.
|
||||
*
|
||||
* Returns: the presence state in @event
|
||||
*/
|
||||
MatrixPresence
|
||||
matrix_event_presence_get_presence (MatrixEventPresence *matrix_event_presence) {
|
||||
MatrixEventPresencePrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_presence != NULL, MATRIX_PRESENCE_UNKNOWN);
|
||||
|
||||
priv = matrix_event_presence_get_instance_private(matrix_event_presence);
|
||||
|
||||
return priv->_presence;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_presence_set_presence:
|
||||
* @event: a #MatrixEventPresence
|
||||
* @presence: a #MatrixPresence value
|
||||
*
|
||||
* Set the presence state in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_presence_set_presence(MatrixEventPresence *matrix_event_presence, MatrixPresence presence)
|
||||
{
|
||||
MatrixEventPresencePrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_presence != NULL);
|
||||
|
||||
priv = matrix_event_presence_get_instance_private(matrix_event_presence);
|
||||
|
||||
if (priv->_presence != presence) {
|
||||
priv->_presence = presence;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_presence, matrix_event_presence_properties[PROP_PRESENCE]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_presence_get_property(GObject *gobject, guint property_id, GValue* value, GParamSpec* pspec)
|
||||
{
|
||||
MatrixEventPresencePrivate *priv = matrix_event_presence_get_instance_private(MATRIX_EVENT_PRESENCE(gobject));
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_AVATAR_URL:
|
||||
g_value_set_string(value, priv->_avatar_url);
|
||||
|
||||
break;
|
||||
case PROP_DISPLAY_NAME:
|
||||
g_value_set_string(value, priv->_display_name);
|
||||
|
||||
break;
|
||||
case PROP_LAST_ACTIVE_AGO:
|
||||
g_value_set_long(value, priv->_last_active_ago);
|
||||
|
||||
break;
|
||||
case PROP_USER_ID:
|
||||
g_value_set_string(value, priv->_user_id);
|
||||
|
||||
break;
|
||||
case PROP_PRESENCE:
|
||||
g_value_set_enum(value, priv->_presence);
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_presence_set_property(GObject *gobject, guint property_id, const GValue* value, GParamSpec* pspec)
|
||||
{
|
||||
MatrixEventPresence *matrix_event_presence = MATRIX_EVENT_PRESENCE(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_AVATAR_URL:
|
||||
matrix_event_presence_set_avatar_url(matrix_event_presence, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_DISPLAY_NAME:
|
||||
matrix_event_presence_set_display_name(matrix_event_presence, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_LAST_ACTIVE_AGO:
|
||||
matrix_event_presence_set_last_active_ago(matrix_event_presence, g_value_get_long(value));
|
||||
|
||||
break;
|
||||
case PROP_USER_ID:
|
||||
matrix_event_presence_set_user_id(matrix_event_presence, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_PRESENCE:
|
||||
matrix_event_presence_set_presence(matrix_event_presence, g_value_get_enum(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_presence_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventPresencePrivate *priv = matrix_event_presence_get_instance_private(MATRIX_EVENT_PRESENCE(gobject));
|
||||
|
||||
g_free(priv->_avatar_url);
|
||||
g_free(priv->_display_name);
|
||||
g_free(priv->_user_id);
|
||||
g_free(priv->_event_id);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_presence_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_presence_class_init(MatrixEventPresenceClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_presence_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_presence_real_to_json;
|
||||
G_OBJECT_CLASS (klass)->get_property = matrix_event_presence_get_property;
|
||||
G_OBJECT_CLASS (klass)->set_property = matrix_event_presence_set_property;
|
||||
G_OBJECT_CLASS (klass)->finalize = matrix_event_presence_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventPresence:avatar-url:
|
||||
*
|
||||
* The current avatar URL for this user, if any.
|
||||
*/
|
||||
matrix_event_presence_properties[PROP_AVATAR_URL] = g_param_spec_string(
|
||||
"avatar-url", "avatar-url", "avatar-url",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_AVATAR_URL, matrix_event_presence_properties[PROP_AVATAR_URL]);
|
||||
|
||||
/**
|
||||
* MatrixEventPresence:display-name:
|
||||
*
|
||||
* The current display name for this user, if any.
|
||||
*/
|
||||
matrix_event_presence_properties[PROP_DISPLAY_NAME] = g_param_spec_string(
|
||||
"display-name", "display-name", "display-name",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_DISPLAY_NAME, matrix_event_presence_properties[PROP_DISPLAY_NAME]);
|
||||
|
||||
/**
|
||||
* MatrixEventPresence:last-active-ago:
|
||||
*
|
||||
* The last time since this used performed some action, in milliseconds.
|
||||
*
|
||||
* This won’t get into the generated event JSON if negative.
|
||||
*/
|
||||
matrix_event_presence_properties[PROP_LAST_ACTIVE_AGO] = g_param_spec_long(
|
||||
"last-active-ago", "last-active-ago", "last-active-ago",
|
||||
G_MINLONG, G_MAXLONG, -1,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_LAST_ACTIVE_AGO, matrix_event_presence_properties[PROP_LAST_ACTIVE_AGO]);
|
||||
|
||||
/**
|
||||
* MatrixEventPresence:user-id:
|
||||
*
|
||||
* The user's ID.
|
||||
*/
|
||||
matrix_event_presence_properties[PROP_USER_ID] = g_param_spec_string(
|
||||
"user-id", "user-id", "user-id",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_USER_ID, matrix_event_presence_properties[PROP_USER_ID]);
|
||||
|
||||
/**
|
||||
* MatrixEventPresence:presence:
|
||||
*
|
||||
* The presence state for this user.
|
||||
*/
|
||||
matrix_event_presence_properties[PROP_PRESENCE] = g_param_spec_enum(
|
||||
"presence", "presence", "presence",
|
||||
MATRIX_TYPE_PRESENCE, MATRIX_PRESENCE_UNKNOWN,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_PRESENCE, matrix_event_presence_properties[PROP_PRESENCE]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_presence_init(MatrixEventPresence *matrix_event_presence) {
|
||||
MatrixEventPresencePrivate *priv = matrix_event_presence_get_instance_private(matrix_event_presence);
|
||||
|
||||
priv->_last_active_ago = -1;
|
||||
priv->_user_id = NULL;
|
||||
priv->_event_id = NULL;
|
||||
priv->_presence = MATRIX_PRESENCE_UNKNOWN;
|
||||
}
|
@ -1,49 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_PRESENCE_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_PRESENCE_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-base.h"
|
||||
# include "matrix-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# define MATRIX_EVENT_TYPE_PRESENCE matrix_event_presence_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventPresence, matrix_event_presence, MATRIX_EVENT, PRESENCE, MatrixEventBase)
|
||||
|
||||
struct _MatrixEventPresenceClass {
|
||||
MatrixEventBaseClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventPresence* matrix_event_presence_new (void);
|
||||
const gchar* matrix_event_presence_get_avatar_url (MatrixEventPresence *event);
|
||||
void matrix_event_presence_set_avatar_url (MatrixEventPresence *event, const gchar *avatar_url);
|
||||
const gchar* matrix_event_presence_get_display_name (MatrixEventPresence *event);
|
||||
void matrix_event_presence_set_display_name (MatrixEventPresence *event, const gchar *display_name);
|
||||
glong matrix_event_presence_get_last_active_ago (MatrixEventPresence *event);
|
||||
void matrix_event_presence_set_last_active_ago (MatrixEventPresence *event, glong last_active_ago);
|
||||
const gchar* matrix_event_presence_get_user_id (MatrixEventPresence *event);
|
||||
void matrix_event_presence_set_user_id (MatrixEventPresence *event, const gchar *user_id);
|
||||
MatrixPresence matrix_event_presence_get_presence (MatrixEventPresence *event);
|
||||
void matrix_event_presence_set_presence (MatrixEventPresence *event, MatrixPresence presence);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_PRESENCE_H__ */
|
@ -1,396 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-receipt.h"
|
||||
#include "matrix-types.h"
|
||||
#include "matrix-enumtypes.h"
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-receipt
|
||||
* @short_description: event to inform clients of new receipts
|
||||
*
|
||||
* This is the default event handler for `m.receipt` events.
|
||||
*/
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ROOM_ID,
|
||||
NUM_PROPS
|
||||
};
|
||||
static GParamSpec* matrix_event_receipt_properties[NUM_PROPS];
|
||||
|
||||
typedef struct {
|
||||
gchar *_room_id;
|
||||
GHashTable *_receipt_data;
|
||||
} MatrixEventReceiptPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventReceipt:
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventReceipt, matrix_event_receipt, MATRIX_EVENT_TYPE_BASE);
|
||||
|
||||
typedef struct {
|
||||
gchar *event_id;
|
||||
gchar *typ;
|
||||
gchar *user;
|
||||
guint refcount;
|
||||
} ReceiptData;
|
||||
|
||||
static gboolean
|
||||
_rd_equal(ReceiptData *k1, ReceiptData *k2) {
|
||||
if ((k1 == NULL) && (k2 == NULL)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if ((k1 == NULL) || (k2 == NULL)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return ((g_strcmp0(k1->event_id, k2->event_id) == 0) &&
|
||||
(g_strcmp0(k1->typ, k2->typ) == 0) &&
|
||||
(g_strcmp0(k1->user, k2->user) == 0));
|
||||
}
|
||||
|
||||
static void
|
||||
_rd_free(ReceiptData *receipt_data) {
|
||||
g_return_if_fail(receipt_data != NULL);
|
||||
|
||||
if ( --receipt_data->refcount == 0) {
|
||||
g_free(receipt_data->event_id);
|
||||
g_free(receipt_data->typ);
|
||||
g_free(receipt_data->user);
|
||||
|
||||
g_free(receipt_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
process_event(JsonObject *obj, const gchar *key, JsonNode *member_node, gpointer user_data)
|
||||
{
|
||||
JsonNode *node;
|
||||
MatrixEventReceiptPrivate *priv = user_data;
|
||||
|
||||
if ((node = json_object_get_member(json_node_get_object(member_node), "m.read")) != NULL) {
|
||||
JsonObject *read_obj = json_node_get_object(node);
|
||||
JsonObjectIter inner_iter;
|
||||
JsonNode *inner_node;
|
||||
const gchar *inner_key;
|
||||
|
||||
json_object_iter_init(&inner_iter, read_obj);
|
||||
|
||||
while (json_object_iter_next(&inner_iter, &inner_key, &inner_node)) {
|
||||
gulong *value;
|
||||
ReceiptData *rd_key;
|
||||
|
||||
if (priv->_receipt_data == NULL) {
|
||||
priv->_receipt_data = g_hash_table_new_full(g_direct_hash, (GEqualFunc)_rd_equal, (GDestroyNotify)_rd_free, g_free);
|
||||
}
|
||||
|
||||
rd_key = g_new(ReceiptData, 1);
|
||||
rd_key->event_id = g_strdup(key);
|
||||
rd_key->typ = g_strdup("m.read");
|
||||
rd_key->user = g_strdup(inner_key);
|
||||
|
||||
value = g_new(gulong, 1);
|
||||
*value = json_node_get_int(json_object_get_member(json_node_get_object(inner_node), "ts"));
|
||||
|
||||
g_hash_table_replace(priv->_receipt_data, rd_key, value);
|
||||
}
|
||||
} else {
|
||||
g_warning("content.$event-id.m.read is missing from a m.presence event");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_receipt_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventReceiptPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_receipt_get_instance_private(MATRIX_EVENT_RECEIPT(matrix_event_base));
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
if ((node = json_object_get_member(root, "room_id")) != NULL) {
|
||||
g_free(priv->_room_id);
|
||||
priv->_room_id = g_strdup(json_node_get_string(node));
|
||||
} else if (DEBUG) {
|
||||
g_warning("room_id is missing from a m.receipt event");
|
||||
}
|
||||
|
||||
json_object_foreach_member(content_root, process_event, priv);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_receipt_parent_class)->from_json(matrix_event_base, json_data, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_receipt_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventReceiptPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
GHashTableIter iter;
|
||||
gpointer gh_key;
|
||||
gpointer gh_value;
|
||||
gint i = 0;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_receipt_get_instance_private(MATRIX_EVENT_RECEIPT(matrix_event_base));
|
||||
|
||||
if (priv->_room_id == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.receipt without room_id");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
g_hash_table_iter_init(&iter, priv->_receipt_data);
|
||||
|
||||
while (g_hash_table_iter_next(&iter, &gh_key, &gh_value)) {
|
||||
ReceiptData *key = gh_key;
|
||||
gulong value = *(gulong *)gh_value;
|
||||
JsonObject *event_object;
|
||||
JsonObject *type_object;
|
||||
JsonObject *user_object;
|
||||
JsonNode *node;
|
||||
|
||||
if (key->event_id == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.receipt event with an empty event ID");
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (key->typ == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.receipt event with an empty receipt type");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (key->user == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.receipt event with an empty user ID");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
i++;
|
||||
|
||||
if ((node = json_object_get_member(content_root, key->event_id)) == NULL) {
|
||||
event_object = json_object_new();
|
||||
node = json_node_new(JSON_TYPE_OBJECT);
|
||||
json_node_set_object(node, event_object);
|
||||
json_object_set_member(content_root, key->event_id, node);
|
||||
} else {
|
||||
event_object = json_node_get_object(node);
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(event_object, key->typ)) == NULL) {
|
||||
type_object = json_object_new();
|
||||
node = json_node_new(JSON_TYPE_OBJECT);
|
||||
json_node_set_object(node, type_object);
|
||||
json_object_set_member(event_object, key->typ, node);
|
||||
} else {
|
||||
type_object = json_node_get_object(node);
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(type_object, key->user)) == NULL) {
|
||||
user_object = json_object_new();
|
||||
node = json_node_new(JSON_TYPE_OBJECT);
|
||||
json_node_set_object(node, user_object);
|
||||
json_object_set_member(type_object, key->user, node);
|
||||
} else {
|
||||
user_object = json_node_get_object(node);
|
||||
}
|
||||
|
||||
json_object_set_int_member(user_object, "ts", value);
|
||||
}
|
||||
|
||||
if (i == 0) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.receipt event with no receipts");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
json_object_set_string_member(root, "room_id", priv->_room_id);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_receipt_parent_class)->to_json(matrix_event_base, json_data, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_receipt_new:
|
||||
*
|
||||
* Create a new #MatrixEventReceipt object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventReceipt object
|
||||
*/
|
||||
MatrixEventReceipt *
|
||||
matrix_event_receipt_new(void)
|
||||
{
|
||||
return (MatrixEventReceipt *)matrix_event_base_construct(MATRIX_EVENT_TYPE_RECEIPT);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_receipt_get_room_id:
|
||||
* @event: a #MatrixEventReceipt
|
||||
*
|
||||
* Get the room ID @event belongs to.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a room ID
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_receipt_get_room_id(MatrixEventReceipt *matrix_event_receipt)
|
||||
{
|
||||
MatrixEventReceiptPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_receipt != NULL, NULL);
|
||||
|
||||
priv = matrix_event_receipt_get_instance_private(matrix_event_receipt);
|
||||
|
||||
return priv->_room_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_receipt_set_room_id:
|
||||
* @event: a #MatrixEventReceipt
|
||||
* @room_id: (transfer none) (nullable): a room ID
|
||||
*
|
||||
* Set the room ID for @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_receipt_set_room_id(MatrixEventReceipt *matrix_event_receipt, const gchar *room_id)
|
||||
{
|
||||
MatrixEventReceiptPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_receipt != NULL);
|
||||
|
||||
priv = matrix_event_receipt_get_instance_private(matrix_event_receipt);
|
||||
|
||||
if (g_strcmp0(room_id, priv->_room_id) != 0) {
|
||||
g_free(priv->_room_id);
|
||||
priv->_room_id = g_strdup(room_id);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_receipt, matrix_event_receipt_properties[PROP_ROOM_ID]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_receipt_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventReceiptPrivate *priv = matrix_event_receipt_get_instance_private(MATRIX_EVENT_RECEIPT(gobject));
|
||||
|
||||
g_free(priv->_room_id);
|
||||
g_hash_table_unref(priv->_receipt_data);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_receipt_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_receipt_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventReceipt *matrix_event_receipt = MATRIX_EVENT_RECEIPT(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ROOM_ID:
|
||||
g_value_set_string(value, matrix_event_receipt_get_room_id(matrix_event_receipt));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_receipt_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventReceipt *matrix_event_receipt = MATRIX_EVENT_RECEIPT(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ROOM_ID:
|
||||
matrix_event_receipt_set_room_id(matrix_event_receipt, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_receipt_class_init(MatrixEventReceiptClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_receipt_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_receipt_real_to_json;
|
||||
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_receipt_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_receipt_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_receipt_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventReceipt:room-id:
|
||||
*
|
||||
* The room ID.
|
||||
*/
|
||||
matrix_event_receipt_properties[PROP_ROOM_ID] = g_param_spec_string(
|
||||
"room-id", "room-id", "room-id",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_ROOM_ID, matrix_event_receipt_properties[PROP_ROOM_ID]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_receipt_init(MatrixEventReceipt *matrix_event_receipt)
|
||||
{
|
||||
MatrixEventReceiptPrivate *priv;
|
||||
|
||||
priv = matrix_event_receipt_get_instance_private(matrix_event_receipt);
|
||||
|
||||
priv->_room_id = NULL;
|
||||
priv->_receipt_data = NULL;
|
||||
}
|
@ -1,40 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_RECEIPT_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_RECEIPT_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-base.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# define MATRIX_EVENT_TYPE_RECEIPT matrix_event_receipt_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventReceipt, matrix_event_receipt, MATRIX_EVENT, RECEIPT, MatrixEventBase)
|
||||
|
||||
struct _MatrixEventReceiptClass {
|
||||
MatrixEventBaseClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventReceipt* matrix_event_receipt_new (void);
|
||||
const gchar* matrix_event_receipt_get_room_id (MatrixEventReceipt *event);
|
||||
void matrix_event_receipt_set_room_id (MatrixEventReceipt *event, const gchar *room_id);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_RECEIPT_H__ */
|
@ -1,292 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-room-aliases.h"
|
||||
#include "matrix-types.h"
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-room-aliases
|
||||
* @short_description: event to list the aliases of a room
|
||||
*
|
||||
* This is the default event handler for `m.room.aliases` events.
|
||||
*
|
||||
* This event is sent by a homeserver directly to inform of changes to the list of aliases it
|
||||
* knows about for that room.
|
||||
*
|
||||
* The state_key for this event is set to the homeserver which owns the room alias.
|
||||
*
|
||||
* The entire set of known aliases for the room is the union of all the `m.room.aliases`
|
||||
* events, one for each homeserver. Clients should check the validity of any room alias given
|
||||
* in this list before presenting it to the user as trusted fact. The lists given by this
|
||||
* event should be considered simply as advice on which aliases might exist, for which the
|
||||
* client can perform the lookup to confirm whether it receives the correct room ID.
|
||||
*/
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_ALIASES,
|
||||
NUM_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec* matrix_event_room_aliases_properties[NUM_PROPS];
|
||||
|
||||
typedef struct {
|
||||
gchar** _aliases;
|
||||
gint _aliases_len;
|
||||
gint __aliases_size_;
|
||||
} MatrixEventRoomAliasesPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomAliases:
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventRoomAliases, matrix_event_room_aliases, MATRIX_EVENT_TYPE_STATE);
|
||||
|
||||
static void
|
||||
matrix_event_room_aliases_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomAliasesPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_if_fail (json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_aliases_get_instance_private(MATRIX_EVENT_ROOM_ALIASES(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
if ((node = json_object_get_member(content_root, "aliases")) != NULL) {
|
||||
JsonArray *aliases;
|
||||
gint n_aliases;
|
||||
|
||||
aliases = json_node_get_array(node);
|
||||
n_aliases = json_array_get_length(aliases);
|
||||
|
||||
for (gint i = 0; i < priv->_aliases_len; i++) {
|
||||
g_free(priv->_aliases[i]);
|
||||
}
|
||||
g_free(priv->_aliases);
|
||||
|
||||
priv->_aliases = g_new(gchar *, n_aliases);
|
||||
|
||||
for (gint i = 0; i < n_aliases; i++) {
|
||||
JsonNode *element = json_array_get_element(aliases, i);
|
||||
|
||||
priv->_aliases[i] = g_strdup(json_node_get_string(element));
|
||||
}
|
||||
} else if (DEBUG) {
|
||||
g_warning("content.aliases is missing from a m.room.aliases event");
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_aliases_parent_class)->from_json(matrix_event_base, json_data, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_aliases_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomAliasesPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonArray *aliases_ary;
|
||||
JsonNode *content_node;
|
||||
JsonNode *aliases_node;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
priv = matrix_event_room_aliases_get_instance_private(MATRIX_EVENT_ROOM_ALIASES(matrix_event_base));
|
||||
|
||||
if (priv->_aliases_len == 0) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.room.aliases event without aliases");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
aliases_ary = json_array_new();
|
||||
|
||||
for (gint i = 0; i < priv->_aliases_len; i++) {
|
||||
json_array_add_string_element(aliases_ary, priv->_aliases[i]);
|
||||
}
|
||||
|
||||
aliases_node = json_node_new(JSON_TYPE_ARRAY);
|
||||
json_node_set_array(aliases_node, aliases_ary);
|
||||
json_object_set_member(content_root, "aliases", aliases_node);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_aliases_parent_class)->to_json(matrix_event_base, json_data, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_aliases_new:
|
||||
*
|
||||
* Create a new #MatrixEventRoomAliases object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventRoomAliases object
|
||||
*/
|
||||
MatrixEventRoomAliases *
|
||||
matrix_event_room_aliases_new(void)
|
||||
{
|
||||
return (MatrixEventRoomAliases *)matrix_event_state_construct(MATRIX_EVENT_TYPE_ROOM_ALIASES);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_aliases_get_aliases:
|
||||
* @event: a MatrixEventRoomAliases
|
||||
* @n_aliases: placeholder for the length of the list, or %NULL to ignore
|
||||
*
|
||||
* Get the list of aliases from @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the list of aliases
|
||||
*/
|
||||
const gchar **
|
||||
matrix_event_room_aliases_get_aliases(MatrixEventRoomAliases *matrix_event_room_aliases, int *n_aliases)
|
||||
{
|
||||
MatrixEventRoomAliasesPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_aliases != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_aliases_get_instance_private(matrix_event_room_aliases);
|
||||
|
||||
if (n_aliases != NULL) {
|
||||
*n_aliases = priv->_aliases_len;
|
||||
}
|
||||
|
||||
return (const gchar **)priv->_aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_aliases_set_aliases:
|
||||
* @event: a #MatrixEventRoomAliases
|
||||
* @aliases: a list of aliases
|
||||
* @n_aliases: the length of @aliases
|
||||
*
|
||||
* Set the list of aliases in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_aliases_set_aliases(MatrixEventRoomAliases *matrix_event_room_aliases, const gchar **aliases, int n_aliases)
|
||||
{
|
||||
MatrixEventRoomAliasesPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_aliases != NULL);
|
||||
|
||||
priv = matrix_event_room_aliases_get_instance_private(matrix_event_room_aliases);
|
||||
|
||||
for (gint i = 0; i < priv->_aliases_len; i++) {
|
||||
g_free(priv->_aliases[i]);
|
||||
}
|
||||
|
||||
g_free(priv->_aliases);
|
||||
priv->_aliases = g_new(gchar *, n_aliases);
|
||||
|
||||
for (gint i = 0; i < n_aliases; i++) {
|
||||
priv->_aliases[i] = g_strdup(aliases[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_aliases_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventRoomAliasesPrivate *priv = matrix_event_room_aliases_get_instance_private(MATRIX_EVENT_ROOM_ALIASES(gobject));
|
||||
|
||||
for (gint i = 0; i < priv->_aliases_len; i++) {
|
||||
g_free(priv->_aliases[i]);
|
||||
}
|
||||
|
||||
g_free(priv->_aliases);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_room_aliases_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_aliases_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomAliases *self = MATRIX_EVENT_ROOM_ALIASES(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ALIASES:
|
||||
g_value_set_boxed(value, matrix_event_room_aliases_get_aliases(self, NULL));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_aliases_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomAliases *self = MATRIX_EVENT_ROOM_ALIASES(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_ALIASES:
|
||||
{
|
||||
gpointer boxed;
|
||||
|
||||
boxed = g_value_get_boxed(value);
|
||||
matrix_event_room_aliases_set_aliases(self, boxed, (boxed == NULL) ? 0 : g_strv_length (boxed));
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_aliases_class_init(MatrixEventRoomAliasesClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_room_aliases_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_room_aliases_real_to_json;
|
||||
G_OBJECT_CLASS (klass)->get_property = matrix_event_room_aliases_get_property;
|
||||
G_OBJECT_CLASS (klass)->set_property = matrix_event_room_aliases_set_property;
|
||||
G_OBJECT_CLASS (klass)->finalize = matrix_event_room_aliases_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomAliases:aliases:
|
||||
*
|
||||
* A list of room aliases.
|
||||
*/
|
||||
matrix_event_room_aliases_properties[PROP_ALIASES] = g_param_spec_boxed(
|
||||
"aliases", "aliases", "aliases",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_ALIASES, matrix_event_room_aliases_properties[PROP_ALIASES]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_aliases_init(MatrixEventRoomAliases *matrix_event_room_aliases)
|
||||
{}
|
@ -1,40 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_ROOM_ALIASES_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_ROOM_ALIASES_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-state-base.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# define MATRIX_EVENT_TYPE_ROOM_ALIASES matrix_event_room_aliases_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventRoomAliases, matrix_event_room_aliases, MATRIX_EVENT, ROOM_ALIASES, MatrixEventState)
|
||||
|
||||
struct _MatrixEventRoomAliasesClass {
|
||||
MatrixEventStateClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventRoomAliases* matrix_event_room_aliases_new (void);
|
||||
const gchar** matrix_event_room_aliases_get_aliases (MatrixEventRoomAliases *event, int *n_aliases);
|
||||
void matrix_event_room_aliases_set_aliases (MatrixEventRoomAliases *event, const gchar **aliases, int n_aliases);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_ROOM_ALIASES_H__ */
|
@ -1,506 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-room-avatar.h"
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-room-avatar
|
||||
* @short_description: event holding the room avatar
|
||||
*
|
||||
* This is the default handler for `m.room.avatar` events.
|
||||
*
|
||||
* A picture that is associated with the room. This can be displayed alongside the room
|
||||
* information.
|
||||
*/
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_URL,
|
||||
PROP_THUMBNAIL_URL,
|
||||
PROP_INFO,
|
||||
PROP_THUMBNAIL_INFO,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *matrix_event_room_avatar_properties[NUM_PROPERTIES];
|
||||
|
||||
typedef struct {
|
||||
gchar* _url;
|
||||
gchar* _thumbnail_url;
|
||||
MatrixImageInfo* _info;
|
||||
MatrixImageInfo* _thumbnail_info;
|
||||
} MatrixEventRoomAvatarPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomAvatar:
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventRoomAvatar, matrix_event_room_avatar, MATRIX_EVENT_TYPE_STATE);
|
||||
|
||||
static void
|
||||
matrix_event_room_avatar_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_avatar_get_instance_private(MATRIX_EVENT_ROOM_AVATAR(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
if (DEBUG) {
|
||||
if ((node = json_object_get_member(root, "state_key")) != NULL) {
|
||||
const char *sk = json_node_get_string(node);
|
||||
|
||||
if ((sk != NULL) && (*sk != 0)) {
|
||||
g_warning("state_key of a m.room.avatar event is non-empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "url")) != NULL) {
|
||||
g_free(priv->_url);
|
||||
priv->_url = g_strdup(json_node_get_string(node));
|
||||
} else {
|
||||
g_warning("content.url is missing from a m.room.avatar event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "thumbnail_url")) != NULL) {
|
||||
g_free(priv->_thumbnail_url);
|
||||
priv->_thumbnail_url = g_strdup(json_node_get_string(node));
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "info")) != NULL) {
|
||||
matrix_image_info_unref(priv->_info);
|
||||
priv->_info = matrix_image_info_new();
|
||||
matrix_image_info_set_from_json(priv->_info, node);
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "thumbnail_info")) != NULL) {
|
||||
matrix_image_info_unref(priv->_thumbnail_info);
|
||||
priv->_thumbnail_info = matrix_image_info_new();
|
||||
matrix_image_info_set_from_json(priv->_thumbnail_info, node);
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_avatar_parent_class)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_avatar_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
const gchar *state_key;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_if_fail (json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_avatar_get_instance_private(MATRIX_EVENT_ROOM_AVATAR(matrix_event_base));
|
||||
|
||||
if (priv->_url == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.room.avatar event without url");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
state_key = matrix_event_state_get_state_key(MATRIX_EVENT_STATE(matrix_event_base));
|
||||
|
||||
if ((state_key == NULL) || (*state_key == 0)) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.room.avatar event with a non-empty state_key");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
json_object_set_string_member(content_root, "url", priv->_url);
|
||||
|
||||
if (priv->_thumbnail_url != NULL) {
|
||||
json_object_set_string_member(content_root, "thumbnail_url", priv->_thumbnail_url);
|
||||
}
|
||||
|
||||
if (priv->_info != NULL) {
|
||||
node = matrix_image_info_get_json_node(priv->_info, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
json_object_set_member(content_root, "info", node);
|
||||
}
|
||||
|
||||
if (priv->_thumbnail_info != NULL) {
|
||||
node = matrix_image_info_get_json_node(priv->_thumbnail_info, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
json_object_set_member(content_root, "thumbnail_info", node);
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_avatar_parent_class)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_avatar_new:
|
||||
*
|
||||
* Create a new #MatrixEventRoomAvatar object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventRoomAvatar object
|
||||
*/
|
||||
MatrixEventRoomAvatar *
|
||||
matrix_event_room_avatar_new(void)
|
||||
{
|
||||
return (MatrixEventRoomAvatar *)matrix_event_state_construct(MATRIX_EVENT_TYPE_ROOM_AVATAR);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_avatar_get_url:
|
||||
* @event: a #MatrixEventRoomAvatar
|
||||
*
|
||||
* Get the URL of the room avatar from @event.
|
||||
*
|
||||
* The returned value is owned by @event and should no be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): an avatar URL
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_avatar_get_url(MatrixEventRoomAvatar *matrix_event_room_avatar)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_avatar != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_avatar_get_instance_private(matrix_event_room_avatar);
|
||||
|
||||
return priv->_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_avatar_set_url:
|
||||
* @event: a #MatrixEventRoomAvatar
|
||||
* @url: (transfer none) (nullable): an URL to set as the room avatar
|
||||
*
|
||||
* Set the room avatar URL.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_avatar_set_url(MatrixEventRoomAvatar *matrix_event_room_avatar, const gchar *url)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_avatar != NULL);
|
||||
|
||||
priv = matrix_event_room_avatar_get_instance_private(matrix_event_room_avatar);
|
||||
|
||||
if (g_strcmp0(url, priv->_url) != 0) {
|
||||
g_free(priv->_url);
|
||||
priv->_url = g_strdup(url);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_avatar, matrix_event_room_avatar_properties[PROP_URL]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_avatar_get_thumbnail_url:
|
||||
* @event: a #MatrixEventRoomAvatar
|
||||
*
|
||||
* Get the URL of the avatar’s thumbnail.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the URL of the avatar thumbnail
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_avatar_get_thumbnail_url(MatrixEventRoomAvatar *matrix_event_room_avatar)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_avatar != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_avatar_get_instance_private(matrix_event_room_avatar);
|
||||
|
||||
return priv->_thumbnail_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_avatar_set_thumbnail_url:
|
||||
* @event: a #MatrixEventRoomAvatar
|
||||
* @thumbnail_url: (transfer none) (nullable): the URL of the room avatar’s thumbnail
|
||||
*
|
||||
* Set the URL of the room avatar’s thumbnail.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_avatar_set_thumbnail_url(MatrixEventRoomAvatar *matrix_event_room_avatar, const gchar *thumbnail_url)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_avatar != NULL);
|
||||
|
||||
priv = matrix_event_room_avatar_get_instance_private(matrix_event_room_avatar);
|
||||
|
||||
if (g_strcmp0(thumbnail_url, priv->_thumbnail_url) != 0) {
|
||||
g_free(priv->_thumbnail_url);
|
||||
priv->_thumbnail_url = g_strdup(thumbnail_url);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_avatar, matrix_event_room_avatar_properties[PROP_THUMBNAIL_URL]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_avatar_get_info:
|
||||
* @event: a #MatrixEventRoomAvatar
|
||||
*
|
||||
* Get the image info for the room avatar.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the image info for the room avatar image.
|
||||
*/
|
||||
MatrixImageInfo *
|
||||
matrix_event_room_avatar_get_info(MatrixEventRoomAvatar *matrix_event_room_avatar)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_avatar != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_avatar_get_instance_private(matrix_event_room_avatar);
|
||||
|
||||
return priv->_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_avatar_set_info:
|
||||
* @event: a #MatrixEventRoomAvatar
|
||||
* @info: a #MatrixImageInfo
|
||||
*
|
||||
* Set the image information for the avatar image.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_avatar_set_info(MatrixEventRoomAvatar *matrix_event_room_avatar, MatrixImageInfo *info)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_avatar != NULL);
|
||||
|
||||
priv = matrix_event_room_avatar_get_instance_private(matrix_event_room_avatar);
|
||||
|
||||
if (priv->_info != info) {
|
||||
matrix_image_info_unref(priv->_info);
|
||||
priv->_info = matrix_image_info_ref(info);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_avatar, matrix_event_room_avatar_properties[PROP_INFO]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_avatar_get_thumbnail_info:
|
||||
* @event: a #MatrixEventRoomAvatar
|
||||
*
|
||||
* Get the image info for the room avatar’s thumbnail.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the image info for the avatar’s thumbnail
|
||||
*/
|
||||
MatrixImageInfo *
|
||||
matrix_event_room_avatar_get_thumbnail_info(MatrixEventRoomAvatar *matrix_event_room_avatar)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_avatar != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_avatar_get_instance_private(matrix_event_room_avatar);
|
||||
|
||||
return priv->_thumbnail_info;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_avatar_set_thumbnail_info:
|
||||
* @event: a #MatrixEventRoomAvatar
|
||||
* @thumbnail_info: (transfer none) (nullable): a #MatrixImageInfo
|
||||
*
|
||||
* Set the image info for the room avatar’s thumbnail.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_avatar_set_thumbnail_info(MatrixEventRoomAvatar *matrix_event_room_avatar, MatrixImageInfo *thumbnail_info)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_avatar != NULL);
|
||||
|
||||
priv = matrix_event_room_avatar_get_instance_private(matrix_event_room_avatar);
|
||||
|
||||
if (priv->_thumbnail_info != thumbnail_info) {
|
||||
matrix_image_info_unref(priv->_thumbnail_info);
|
||||
priv->_thumbnail_info = matrix_image_info_ref(thumbnail_info);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_avatar, matrix_event_room_avatar_properties[PROP_THUMBNAIL_INFO]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_avatar_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv = matrix_event_room_avatar_get_instance_private(MATRIX_EVENT_ROOM_AVATAR(gobject));
|
||||
|
||||
g_free(priv->_url);
|
||||
g_free(priv->_thumbnail_url);
|
||||
matrix_image_info_unref(priv->_info);
|
||||
matrix_image_info_unref(priv->_thumbnail_info);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_room_avatar_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_avatar_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomAvatar *matrix_event_room_avatar = MATRIX_EVENT_ROOM_AVATAR(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_URL:
|
||||
g_value_set_string(value, matrix_event_room_avatar_get_url(matrix_event_room_avatar));
|
||||
|
||||
break;
|
||||
case PROP_THUMBNAIL_URL:
|
||||
g_value_set_string(value, matrix_event_room_avatar_get_thumbnail_url(matrix_event_room_avatar));
|
||||
|
||||
break;
|
||||
case PROP_INFO:
|
||||
g_value_set_boxed(value, matrix_event_room_avatar_get_info(matrix_event_room_avatar));
|
||||
|
||||
break;
|
||||
case PROP_THUMBNAIL_INFO:
|
||||
g_value_set_boxed(value, matrix_event_room_avatar_get_thumbnail_info(matrix_event_room_avatar));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_avatar_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomAvatar *matrix_event_room_avatar = MATRIX_EVENT_ROOM_AVATAR(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_URL:
|
||||
matrix_event_room_avatar_set_url(matrix_event_room_avatar, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_THUMBNAIL_URL:
|
||||
matrix_event_room_avatar_set_thumbnail_url(matrix_event_room_avatar, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_INFO:
|
||||
matrix_event_room_avatar_set_info(matrix_event_room_avatar, g_value_get_boxed(value));
|
||||
|
||||
break;
|
||||
case PROP_THUMBNAIL_INFO:
|
||||
matrix_event_room_avatar_set_thumbnail_info(matrix_event_room_avatar, g_value_get_boxed(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_avatar_class_init(MatrixEventRoomAvatarClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_room_avatar_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_room_avatar_real_to_json;
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_room_avatar_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_room_avatar_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_room_avatar_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomAvatar:url:
|
||||
*
|
||||
* The URL to the image.
|
||||
*/
|
||||
matrix_event_room_avatar_properties[PROP_URL] = g_param_spec_string(
|
||||
"url", "url", "url",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_URL, matrix_event_room_avatar_properties[PROP_URL]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoomAvatar:thumbnail-url:
|
||||
*
|
||||
* The URL to the thumbnail of the image.
|
||||
*/
|
||||
matrix_event_room_avatar_properties[PROP_THUMBNAIL_URL] = g_param_spec_string(
|
||||
"thumbnail-url", "thumbnail-url", "thumbnail-url",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_THUMBNAIL_URL, matrix_event_room_avatar_properties[PROP_THUMBNAIL_URL]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoomAvatar:info:
|
||||
*
|
||||
* The image info for the room avatar.
|
||||
*/
|
||||
matrix_event_room_avatar_properties[PROP_INFO] = g_param_spec_boxed(
|
||||
"info", "info", "info",
|
||||
MATRIX_TYPE_IMAGE_INFO,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_INFO, matrix_event_room_avatar_properties[PROP_INFO]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoomAvatar:thumbnail-info:
|
||||
*
|
||||
* The image info for the room avatar’s thumbnail.
|
||||
*/
|
||||
matrix_event_room_avatar_properties[PROP_INFO] = g_param_spec_boxed(
|
||||
"thumbnail-info", "thumbnail-info", "thumbnail-info",
|
||||
MATRIX_TYPE_IMAGE_INFO,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_INFO, matrix_event_room_avatar_properties[PROP_INFO]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_avatar_init(MatrixEventRoomAvatar *matrix_event_room_avatar)
|
||||
{
|
||||
MatrixEventRoomAvatarPrivate *priv = matrix_event_room_avatar_get_instance_private(matrix_event_room_avatar);
|
||||
|
||||
priv->_url = NULL;
|
||||
priv->_thumbnail_url = NULL;
|
||||
priv->_info = NULL;
|
||||
priv->_thumbnail_info = NULL;
|
||||
}
|
@ -1,47 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_ROOM_AVATAR_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_ROOM_AVATAR_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-state-base.h"
|
||||
# include "matrix-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# define MATRIX_EVENT_TYPE_ROOM_AVATAR matrix_event_room_avatar_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventRoomAvatar, matrix_event_room_avatar, MATRIX_EVENT, ROOM_AVATAR, MatrixEventState)
|
||||
|
||||
struct _MatrixEventRoomAvatarClass {
|
||||
MatrixEventStateClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventRoomAvatar* matrix_event_room_avatar_new (void);
|
||||
const gchar *matrix_event_room_avatar_get_url (MatrixEventRoomAvatar *event);
|
||||
void matrix_event_room_avatar_set_url (MatrixEventRoomAvatar *event, const gchar *url);
|
||||
const gchar *matrix_event_room_avatar_get_thumbnail_url (MatrixEventRoomAvatar *event);
|
||||
void matrix_event_room_avatar_set_thumbnail_url (MatrixEventRoomAvatar *event, const gchar *thumbnail_url);
|
||||
MatrixImageInfo *matrix_event_room_avatar_get_info (MatrixEventRoomAvatar *event);
|
||||
void matrix_event_room_avatar_set_info (MatrixEventRoomAvatar *event, MatrixImageInfo *info);
|
||||
MatrixImageInfo *matrix_event_room_avatar_get_thumbnail_info (MatrixEventRoomAvatar *event);
|
||||
void matrix_event_room_avatar_set_thumbnail_info (MatrixEventRoomAvatar *event, MatrixImageInfo *thumbnail_info);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_ROOM_AVATAR_H__ */
|
@ -1,678 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-room-base.h"
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-room-base
|
||||
* @short_description: abstract base class for room events
|
||||
* @title: room event base class
|
||||
*
|
||||
* #MatrixEventRoom is the abstract base class for room events. It handles the `event_id`,
|
||||
* `room_id`, `sender`, `age`, `redacted_because`, and `transaction_id` field of an event’s
|
||||
* JSON representation, so subclasses don’t have to care about them.
|
||||
*/
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_EVENT_ID,
|
||||
PROP_ROOM_ID,
|
||||
PROP_SENDER,
|
||||
PROP_AGE,
|
||||
PROP_REDACTED_BECAUSE,
|
||||
PROP_TRANSACTION_ID,
|
||||
NUM_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec* matrix_event_room_properties[NUM_PROPS];
|
||||
|
||||
typedef struct {
|
||||
gchar* _event_id;
|
||||
gchar* _room_id;
|
||||
gchar* _sender;
|
||||
glong _age;
|
||||
gchar* _redacted_because;
|
||||
gchar* _transaction_id;
|
||||
} MatrixEventRoomPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventRoom:
|
||||
*
|
||||
* Abstract base class for room events.
|
||||
*/
|
||||
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(MatrixEventRoom, matrix_event_room, MATRIX_EVENT_TYPE_BASE);
|
||||
|
||||
static void
|
||||
matrix_event_room_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoom *matrix_event_room;
|
||||
MatrixEventRoomPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonNode *node;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
matrix_event_room = MATRIX_EVENT_ROOM(matrix_event_base);
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
|
||||
if ((node = json_object_get_member (root, "event_id")) != NULL) {
|
||||
g_free(priv->_event_id);
|
||||
priv->_event_id = g_strdup(json_node_get_string(node));
|
||||
} else if (DEBUG) {
|
||||
g_warning ("matrix-event-room-base.vala:71: event_id is missing from a Room event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(root, "room_id")) != NULL) {
|
||||
g_free(priv->_room_id);
|
||||
priv->_room_id = g_strdup(json_node_get_string(node));
|
||||
} else if (DEBUG) {
|
||||
g_warning ("matrix-event-room-base.vala:77: room_id is missing from a Room event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(root, "sender")) != NULL) {
|
||||
g_free(priv->_sender);
|
||||
priv->_sender = g_strdup(json_node_get_string(node));
|
||||
} else if (DEBUG) {
|
||||
g_warning ("matrix-event-room-base.vala:83: sender is missing from a Room event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(root, "unsigned")) != NULL) {
|
||||
JsonObject* unsigned_root = NULL;
|
||||
|
||||
unsigned_root = json_node_get_object(node);
|
||||
|
||||
if ((node = json_object_get_member (unsigned_root, "age")) != NULL) {
|
||||
priv->_age = json_node_get_int(node);
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(unsigned_root, "redacted_because")) != NULL) {
|
||||
g_free(priv->_redacted_because);
|
||||
priv->_redacted_because = g_strdup(json_node_get_string(node));
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(unsigned_root, "transaction_id")) != NULL) {
|
||||
g_free(priv->_transaction_id);
|
||||
priv->_transaction_id = g_strdup(json_node_get_string(node));
|
||||
}
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_parent_class)->from_json(matrix_event_base, json_data, &inner_error);
|
||||
|
||||
json_object_unref(root);
|
||||
json_node_unref(node);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoom *matrix_event_room;
|
||||
MatrixEventRoomPrivate *priv;
|
||||
JsonObject *root_obj;
|
||||
JsonObject *unsigned_obj;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
matrix_event_room = MATRIX_EVENT_ROOM(matrix_event_base);
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
root_obj = json_node_get_object (json_data);
|
||||
|
||||
if (priv->_event_id != NULL) {
|
||||
json_object_set_string_member (root_obj, "event_id", priv->_event_id);
|
||||
}
|
||||
|
||||
if (priv->_room_id!= NULL) {
|
||||
json_object_set_string_member(root_obj, "room_id", priv->_room_id);
|
||||
}
|
||||
|
||||
if (priv->_sender != NULL) {
|
||||
json_object_set_string_member (root_obj, "sender", priv->_sender);
|
||||
}
|
||||
|
||||
unsigned_obj = json_object_new();
|
||||
|
||||
if (priv->_age >= 0) {
|
||||
json_object_set_int_member (unsigned_obj, "age", priv->_age);
|
||||
}
|
||||
|
||||
if (priv->_redacted_because != NULL) {
|
||||
json_object_set_string_member (unsigned_obj, "redacted_because", priv->_redacted_because);
|
||||
}
|
||||
|
||||
if (priv->_transaction_id != NULL) {
|
||||
json_object_set_string_member (unsigned_obj, "transaction_id", priv->_transaction_id);
|
||||
}
|
||||
|
||||
if (json_object_get_size(unsigned_obj) > 0) {
|
||||
JsonNode* unsigned_node = NULL;
|
||||
|
||||
unsigned_node = json_node_new (JSON_NODE_OBJECT);
|
||||
json_node_set_object (unsigned_node, unsigned_obj);
|
||||
json_object_set_member (root_obj, "unsigned", unsigned_node);
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_parent_class)->to_json(MATRIX_EVENT_BASE(matrix_event_base), json_data, &inner_error);
|
||||
|
||||
json_object_unref(unsigned_obj);
|
||||
json_object_unref(root_obj);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_construct:
|
||||
* @object_type: the #GType of the object to be created
|
||||
*
|
||||
* Returns: (transfer full): a new instance of @object_type
|
||||
*/
|
||||
MatrixEventRoom *
|
||||
matrix_event_room_construct(GType object_type)
|
||||
{
|
||||
return (MatrixEventRoom *)matrix_event_base_construct(object_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_get_event_id:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
*
|
||||
* Get the event ID.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the event ID
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_get_event_id(MatrixEventRoom *matrix_event_room)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
return priv->_event_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_set_event_id:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
* @event_id: (transfer none) (nullable): an event ID
|
||||
*
|
||||
* Set the event ID in @event.
|
||||
*
|
||||
* As the event sending process will strip away this field, setting the event ID is usually
|
||||
* useless.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_set_event_id(MatrixEventRoom *matrix_event_room, const gchar *event_id)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room != NULL);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
if (g_strcmp0(event_id, priv->_event_id) != 0) {
|
||||
g_free(priv->_event_id);
|
||||
priv->_event_id = g_strdup(event_id);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room, matrix_event_room_properties[PROP_EVENT_ID]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_get_room_id:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
*
|
||||
* Get the room ID from @event.
|
||||
*
|
||||
* The returned value is owned by @event, and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the room ID
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_get_room_id(MatrixEventRoom *matrix_event_room)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
return priv->_room_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_set_room_id:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
* @room_id: (transfer none) (nullable): a room ID
|
||||
*
|
||||
* Set the room ID for @event.
|
||||
*
|
||||
* This field is actually the target of any message, so it is really important to set
|
||||
* correctly. Room IDs, as per the Matrix specification, look like
|
||||
* `!random-string:homeserver`. This function doesn’t check for validity, though.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_set_room_id(MatrixEventRoom *matrix_event_room, const gchar *room_id)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room != NULL);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
if (g_strcmp0(room_id, priv->_room_id) != 0) {
|
||||
g_free(priv->_room_id);
|
||||
priv->_room_id = g_strdup(room_id);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room, matrix_event_room_properties[PROP_ROOM_ID]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_get_sender:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
*
|
||||
* Get the user ID of @event’s sender.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a user ID in MXID format
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_get_sender(MatrixEventRoom *matrix_event_room)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
return priv->_sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_set_sender:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
* @sender: (transfer none) (nullable): a user ID in MXID format
|
||||
*
|
||||
* Set the sender of @event.
|
||||
*
|
||||
* @sender must be in MXID format (`\@user_id:homeserver`). This function doesn’t check for
|
||||
* user ID validity.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_set_sender(MatrixEventRoom *matrix_event_room, const gchar *sender)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room != NULL);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
if (g_strcmp0(sender, priv->_sender) != 0) {
|
||||
g_free(priv->_sender);
|
||||
priv->_sender = g_strdup(sender);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room, matrix_event_room_properties[PROP_SENDER]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_get_age:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
*
|
||||
* Get the age of the event.
|
||||
*
|
||||
* The age is reported by the homeserver, not calculated by this library.
|
||||
*
|
||||
* Returns: the age, in milliseconds
|
||||
*/
|
||||
glong
|
||||
matrix_event_room_get_age (MatrixEventRoom *matrix_event_room) {
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room != NULL, -1);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
return priv->_age;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_set_age:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
* @age: the age of the event, in milliseconds
|
||||
*
|
||||
* Set the age of @event.
|
||||
*
|
||||
* As age is calculated by the homeserver based on the timestamp it received the event,
|
||||
* setting this property explicitly has no point.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_set_age(MatrixEventRoom *matrix_event_room, glong age)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room != NULL);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
if (priv->_age != age) {
|
||||
priv->_age = age;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room, matrix_event_room_properties[PROP_AGE]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_get_redacted_because:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
*
|
||||
* Get the redaction reason of @event.
|
||||
*
|
||||
* This will be %NULL if the event is not redacted, but may also be %NULL if the event is
|
||||
* redacted without reason.
|
||||
*
|
||||
* The value returned is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the redaction reason
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_get_redacted_because(MatrixEventRoom *matrix_event_room) {
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
return priv->_redacted_because;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_set_redacted_because:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
* @redacted_because: (transfer none) (nullable): the reason @event got redacted
|
||||
*
|
||||
* Set the redaction reason for @event.
|
||||
*
|
||||
* Redacting events must be done via the corresponding API (eg. matrix_api_redact_event()).
|
||||
* Merely setting this field has no effect on the Matrix network.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_set_redacted_because(MatrixEventRoom *matrix_event_room, const gchar *redacted_because)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room != NULL);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
if (g_strcmp0(redacted_because, priv->_redacted_because) != 0) {
|
||||
g_free(priv->_redacted_because);
|
||||
priv->_redacted_because = g_strdup(redacted_because);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room, matrix_event_room_properties[PROP_REDACTED_BECAUSE]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_get_transaction_id:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
*
|
||||
* Get the transaction ID of @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the transaction ID
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_get_transaction_id(MatrixEventRoom *matrix_event_room)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
return priv->_transaction_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_set_transaction_id:
|
||||
* @event: a #MatrixEventRoom derived object
|
||||
* @transaction_id: (transfer none) (nullable): a transction ID
|
||||
*
|
||||
* Set the transaction ID of the event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_set_transaction_id(MatrixEventRoom *matrix_event_room, const gchar *transaction_id)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room != NULL);
|
||||
|
||||
priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
if (g_strcmp0(transaction_id, priv->_transaction_id) != 0) {
|
||||
g_free(priv->_transaction_id);
|
||||
priv->_transaction_id = g_strdup(transaction_id);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room, matrix_event_room_properties[PROP_TRANSACTION_ID]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_get_property(GObject *gobject, guint property_id, GValue* value, GParamSpec* pspec)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv = matrix_event_room_get_instance_private(MATRIX_EVENT_ROOM(gobject));
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_EVENT_ID:
|
||||
g_value_set_string(value, priv->_event_id);
|
||||
|
||||
break;
|
||||
case PROP_ROOM_ID:
|
||||
g_value_set_string(value, priv->_room_id);
|
||||
|
||||
break;
|
||||
case PROP_SENDER:
|
||||
g_value_set_string(value, priv->_sender);
|
||||
|
||||
break;
|
||||
case PROP_AGE:
|
||||
g_value_set_long(value, priv->_age);
|
||||
|
||||
break;
|
||||
case PROP_REDACTED_BECAUSE:
|
||||
g_value_set_string(value, priv->_redacted_because);
|
||||
|
||||
break;
|
||||
case PROP_TRANSACTION_ID:
|
||||
g_value_set_string(value, priv->_transaction_id);
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_set_property(GObject *gobject, guint property_id, const GValue* value, GParamSpec* pspec)
|
||||
{
|
||||
MatrixEventRoom *matrix_event_room = MATRIX_EVENT_ROOM(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_EVENT_ID:
|
||||
matrix_event_room_set_event_id(matrix_event_room, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_ROOM_ID:
|
||||
matrix_event_room_set_room_id(matrix_event_room, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_SENDER:
|
||||
matrix_event_room_set_sender(matrix_event_room, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_AGE:
|
||||
matrix_event_room_set_age(matrix_event_room, g_value_get_long(value));
|
||||
|
||||
break;
|
||||
case PROP_REDACTED_BECAUSE:
|
||||
matrix_event_room_set_redacted_because(matrix_event_room, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_TRANSACTION_ID:
|
||||
matrix_event_room_set_transaction_id(matrix_event_room, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv = matrix_event_room_get_instance_private(MATRIX_EVENT_ROOM(gobject));
|
||||
|
||||
g_free(priv->_event_id);
|
||||
g_free(priv->_room_id);
|
||||
g_free(priv->_sender);
|
||||
g_free(priv->_redacted_because);
|
||||
g_free(priv->_transaction_id);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_room_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_class_init(MatrixEventRoomClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_room_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_room_real_to_json;
|
||||
G_OBJECT_CLASS (klass)->get_property = matrix_event_room_get_property;
|
||||
G_OBJECT_CLASS (klass)->set_property = matrix_event_room_set_property;
|
||||
G_OBJECT_CLASS (klass)->finalize = matrix_event_room_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventRoom:event-id:
|
||||
*
|
||||
* A globally unique event ID. Required.
|
||||
*/
|
||||
matrix_event_room_properties[PROP_EVENT_ID] = g_param_spec_string(
|
||||
"event-id", "event-id", "event-id",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_EVENT_ID, matrix_event_room_properties[PROP_EVENT_ID]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoom:room-id:
|
||||
*
|
||||
* The ID of the room associated with this event. Required, but it
|
||||
* may be stripped by HS implementations from some APIs if they
|
||||
* reside under a key marked with the room ID.
|
||||
*/
|
||||
matrix_event_room_properties[PROP_ROOM_ID] = g_param_spec_string(
|
||||
"room-id", "room-id", "room-id",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_ROOM_ID, matrix_event_room_properties[PROP_ROOM_ID]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoom:sender:
|
||||
*
|
||||
* The fully qualified Matrix ID of the user who sent the
|
||||
* event. Required.
|
||||
*/
|
||||
matrix_event_room_properties[PROP_SENDER] = g_param_spec_string(
|
||||
"sender", "sender", "sender",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_SENDER, matrix_event_room_properties[PROP_SENDER]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoom:age:
|
||||
*
|
||||
* The time, in milliseconds, that has elapsed since the event was sent. This is part of
|
||||
* the unsigned event data.
|
||||
*
|
||||
* This value will be omitted from the generated event JSON if less than zero.
|
||||
*/
|
||||
matrix_event_room_properties[PROP_AGE] = g_param_spec_long(
|
||||
"age", "age", "age",
|
||||
G_MINLONG, G_MAXLONG, 0,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_AGE, matrix_event_room_properties[PROP_AGE]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoom:redacted-because:
|
||||
*
|
||||
* The reason this event was redacted, if it was redacted.
|
||||
*/
|
||||
matrix_event_room_properties[PROP_REDACTED_BECAUSE] = g_param_spec_string(
|
||||
"redacted-because", "redacted-because", "redacted-because",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_REDACTED_BECAUSE, matrix_event_room_properties[PROP_REDACTED_BECAUSE]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoom:transaction-id:
|
||||
*
|
||||
* The client-supplied transaction ID. This should only be set if
|
||||
* the client being given the event is the same one which sent it.
|
||||
*/
|
||||
matrix_event_room_properties[PROP_TRANSACTION_ID] = g_param_spec_string(
|
||||
"transaction-id", "transaction-id", "transaction-id",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_TRANSACTION_ID, matrix_event_room_properties[PROP_TRANSACTION_ID]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_init(MatrixEventRoom *matrix_event_room)
|
||||
{
|
||||
MatrixEventRoomPrivate *priv = matrix_event_room_get_instance_private(matrix_event_room);
|
||||
|
||||
priv->_event_id = NULL;
|
||||
priv->_room_id = NULL;
|
||||
priv->_sender = NULL;
|
||||
priv->_age = 0;
|
||||
priv->_redacted_because = NULL;
|
||||
priv->_transaction_id = NULL;
|
||||
}
|
@ -1,46 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_ROOM_BASE_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_ROOM_BASE_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-base.h"
|
||||
|
||||
# define MATRIX_EVENT_TYPE_ROOM matrix_event_room_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventRoom, matrix_event_room, MATRIX_EVENT, ROOM, MatrixEventBase)
|
||||
|
||||
struct _MatrixEventRoomClass {
|
||||
MatrixEventBaseClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventRoom *matrix_event_room_construct(GType object_type);
|
||||
const gchar *matrix_event_room_get_event_id(MatrixEventRoom *event);
|
||||
void matrix_event_room_set_event_id(MatrixEventRoom *event, const gchar *event_id);
|
||||
const gchar *matrix_event_room_get_room_id(MatrixEventRoom *event);
|
||||
void matrix_event_room_set_room_id(MatrixEventRoom *event, const gchar *room_id);
|
||||
const gchar *matrix_event_room_get_sender(MatrixEventRoom *event);
|
||||
void matrix_event_room_set_sender(MatrixEventRoom *event, const gchar *sender);
|
||||
glong matrix_event_room_get_age(MatrixEventRoom *event);
|
||||
void matrix_event_room_set_age(MatrixEventRoom *event, glong age);
|
||||
const gchar *matrix_event_room_get_redacted_because(MatrixEventRoom *event);
|
||||
void matrix_event_room_set_redacted_because(MatrixEventRoom *event, const gchar *redacted_because);
|
||||
const gchar *matrix_event_room_get_transaction_id(MatrixEventRoom *event);
|
||||
void matrix_event_room_set_transaction_id(MatrixEventRoom *event, const gchar *transaction_id);
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_ROOM_BASE_H__ */
|
@ -1,245 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-room-canonical-alias.h"
|
||||
#include "matrix-types.h"
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-room-canonical-alias
|
||||
* @short_description: event to set a room’s canonical alias
|
||||
*
|
||||
* This is the default handler for `m.room.canonical_alias` events.
|
||||
*
|
||||
* This event is used to inform the room about which alias should be considered the canonical
|
||||
* one. This could be for display purposes or as suggestion to users which alias to use to
|
||||
* advertise the room.
|
||||
*/
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CANONICAL_ALIAS,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *matrix_event_room_canonical_alias_properties[NUM_PROPERTIES];
|
||||
|
||||
typedef struct {
|
||||
gchar* _canonical_alias;
|
||||
} MatrixEventRoomCanonicalAliasPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomCanonicalAlias:
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventRoomCanonicalAlias, matrix_event_room_canonical_alias, MATRIX_EVENT_TYPE_STATE);
|
||||
|
||||
static void
|
||||
matrix_event_room_canonical_alias_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomCanonicalAliasPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
|
||||
g_return_if_fail (json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_canonical_alias_get_instance_private(MATRIX_EVENT_ROOM_CANONICAL_ALIAS(matrix_event_base));
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
#if DEBUG
|
||||
if ((node = json_object_get_member(root, "state_key")) != NULL) {
|
||||
const gchar *state_key = json_node_get_string(node);
|
||||
|
||||
if ((state_key == NULL) || (*state_key == 0)) {
|
||||
g_warning("state_key of a m.room.canonical_alias event is non-empty");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((node = json_object_get_member(content_root, "alias")) != NULL) {
|
||||
g_free(priv->_canonical_alias);
|
||||
priv->_canonical_alias = g_strdup(json_node_get_string(node));
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_canonical_alias_parent_class)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_canonical_alias_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomCanonicalAliasPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
const gchar *state_key;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_canonical_alias_get_instance_private(MATRIX_EVENT_ROOM_CANONICAL_ALIAS(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
state_key = matrix_event_state_get_state_key(MATRIX_EVENT_STATE(matrix_event_base));
|
||||
if ((state_key == NULL) || (*state_key == 0)) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.room.canonical_alias event with a non-empty state_key");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->_canonical_alias != NULL) {
|
||||
json_object_set_string_member(content_root, "alias", priv->_canonical_alias);
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_canonical_alias_parent_class)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_canonical_alias_new:
|
||||
*
|
||||
* Create a new #MatrixEventRoomCanonicalAlias object
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventRoomCanonicalAlias
|
||||
*/
|
||||
MatrixEventRoomCanonicalAlias *
|
||||
matrix_event_room_canonical_alias_new(void)
|
||||
{
|
||||
return (MatrixEventRoomCanonicalAlias *)matrix_event_state_construct(MATRIX_EVENT_TYPE_ROOM_CANONICAL_ALIAS);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_canonical_alias_get_canonical_alias:
|
||||
* @event: a #MatrixEventRoomCanonicalAlias
|
||||
*
|
||||
* Get the canonical alias from @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the canonical alias
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_canonical_alias_get_canonical_alias(MatrixEventRoomCanonicalAlias *matrix_event_room_canonical_alias)
|
||||
{
|
||||
MatrixEventRoomCanonicalAliasPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_canonical_alias != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_canonical_alias_get_instance_private(matrix_event_room_canonical_alias);
|
||||
|
||||
return priv->_canonical_alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_canonical_alias_set_canonical_alias:
|
||||
* @event: a #MatrixEventRoomCanonicalAlias
|
||||
* @canonical_alias: (transfer none) (nullable): a canonical alias
|
||||
*
|
||||
* Set the canonical alias in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_canonical_alias_set_canonical_alias(MatrixEventRoomCanonicalAlias *matrix_event_room_canonical_alias, const gchar *canonical_alias)
|
||||
{
|
||||
MatrixEventRoomCanonicalAliasPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_canonical_alias != NULL);
|
||||
|
||||
priv = matrix_event_room_canonical_alias_get_instance_private(matrix_event_room_canonical_alias);
|
||||
|
||||
if (g_strcmp0(canonical_alias, priv->_canonical_alias) != 0) {
|
||||
g_free(priv->_canonical_alias);
|
||||
priv->_canonical_alias = g_strdup(canonical_alias);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_canonical_alias, matrix_event_room_canonical_alias_properties[PROP_CANONICAL_ALIAS]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_canonical_alias_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventRoomCanonicalAliasPrivate *priv = matrix_event_room_canonical_alias_get_instance_private(MATRIX_EVENT_ROOM_CANONICAL_ALIAS(gobject));
|
||||
|
||||
g_free(priv->_canonical_alias);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_room_canonical_alias_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_canonical_alias_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomCanonicalAlias *matrix_event_room_canonical_alias = MATRIX_EVENT_ROOM_CANONICAL_ALIAS(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CANONICAL_ALIAS:
|
||||
g_value_set_string(value, matrix_event_room_canonical_alias_get_canonical_alias(matrix_event_room_canonical_alias));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_canonical_alias_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomCanonicalAlias *matrix_event_room_canonical_alias = MATRIX_EVENT_ROOM_CANONICAL_ALIAS(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CANONICAL_ALIAS:
|
||||
matrix_event_room_canonical_alias_set_canonical_alias(matrix_event_room_canonical_alias, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_canonical_alias_class_init(MatrixEventRoomCanonicalAliasClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_room_canonical_alias_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_room_canonical_alias_real_to_json;
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_room_canonical_alias_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_room_canonical_alias_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_room_canonical_alias_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomCanonicalAlias:canonical-alias:
|
||||
*
|
||||
* The canonical alias.
|
||||
*/
|
||||
matrix_event_room_canonical_alias_properties[PROP_CANONICAL_ALIAS] = g_param_spec_string(
|
||||
"canonical-alias", "canonical-alias", "canonical-alias",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_CANONICAL_ALIAS, matrix_event_room_canonical_alias_properties[PROP_CANONICAL_ALIAS]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_canonical_alias_init(MatrixEventRoomCanonicalAlias *matrix_event_room_canonical_alias)
|
||||
{
|
||||
MatrixEventRoomCanonicalAliasPrivate *priv = matrix_event_room_canonical_alias_get_instance_private(matrix_event_room_canonical_alias);
|
||||
|
||||
priv->_canonical_alias = NULL;
|
||||
}
|
@ -1,40 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_ROOM_CANONICAL_ALIAS_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_ROOM_CANONICAL_ALIAS_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-state-base.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MATRIX_EVENT_TYPE_ROOM_CANONICAL_ALIAS (matrix_event_room_canonical_alias_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventRoomCanonicalAlias, matrix_event_room_canonical_alias, MATRIX_EVENT, ROOM_CANONICAL_ALIAS, MatrixEventState)
|
||||
|
||||
struct _MatrixEventRoomCanonicalAliasClass {
|
||||
MatrixEventStateClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventRoomCanonicalAlias *matrix_event_room_canonical_alias_new (void);
|
||||
const gchar *matrix_event_room_canonical_alias_get_canonical_alias (MatrixEventRoomCanonicalAlias *event);
|
||||
void matrix_event_room_canonical_alias_set_canonical_alias (MatrixEventRoomCanonicalAlias *event, const gchar *canonical_alias);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_ROOM_CANONICAL_ALIAS_H__ */
|
@ -1,326 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-room-create.h"
|
||||
#include "matrix-types.h"
|
||||
#include "config.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-room-create
|
||||
* @short_description: event describing the creation of a room
|
||||
*
|
||||
* This is the default event handler for `m.room.create` events.
|
||||
*
|
||||
* This is the first event in a room and cannot be changed. It acts as the root of all other
|
||||
* events.
|
||||
*/
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_CREATOR,
|
||||
PROP_FEDERATE,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *matrix_event_room_create_properties[NUM_PROPERTIES];
|
||||
|
||||
typedef struct {
|
||||
gchar* _creator;
|
||||
gboolean _federate;
|
||||
} MatrixEventRoomCreatePrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomCreate:
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventRoomCreate, matrix_event_room_create, MATRIX_EVENT_TYPE_STATE);
|
||||
|
||||
static void
|
||||
matrix_event_room_create_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomCreatePrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_create_get_instance_private(MATRIX_EVENT_ROOM_CREATE(matrix_event_base));
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
#if DEBUG
|
||||
if ((node = json_object_get_member(root, "state_key")) != NULL) {
|
||||
const gchar *state_key = json_node_get_string(node);
|
||||
|
||||
if ((state_key == NULL) || (*state_key == 0)) {
|
||||
g_warning("state_key of a m.room.create event is non-empty");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((node = json_object_get_member(content_root, "creator")) != NULL) {
|
||||
g_free(priv->_creator);
|
||||
priv->_creator = g_strdup(json_node_get_string(node));
|
||||
} else {
|
||||
g_warning("content.creator is missing from a m.room.create event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "m.federate")) != NULL) {
|
||||
priv->_federate = json_node_get_boolean(node);
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_create_parent_class)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_create_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomCreatePrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
const gchar *state_key;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_create_get_instance_private(MATRIX_EVENT_ROOM_CREATE(matrix_event_base));
|
||||
|
||||
if (priv->_creator == NULL) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.room.create event without a creator key");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
state_key = matrix_event_state_get_state_key(MATRIX_EVENT_STATE(matrix_event_base));
|
||||
|
||||
if ((state_key == NULL) || (*state_key == 0)) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generater a m.root.create event with a non-empty state_key");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
json_object_set_string_member(content_root, "creator", priv->_creator);
|
||||
json_object_set_boolean_member(content_root, "m.federate", priv->_federate);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS (matrix_event_room_create_parent_class)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_create_new:
|
||||
*
|
||||
* Create a new #MatrixEventRoomCreate object.
|
||||
*
|
||||
* Returns: (transfer none): a new #MatrixEventRoomCreate object
|
||||
*/
|
||||
MatrixEventRoomCreate *
|
||||
matrix_event_room_create_new(void)
|
||||
{
|
||||
return (MatrixEventRoomCreate *)matrix_event_state_construct(MATRIX_EVENT_TYPE_ROOM_CREATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_create_get_creator:
|
||||
* @event: a #MatrixEventRoomCreate
|
||||
*
|
||||
* Get the creator of the room.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the creator of the room
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_create_get_creator(MatrixEventRoomCreate *matrix_event_room_create)
|
||||
{
|
||||
MatrixEventRoomCreatePrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_create != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_create_get_instance_private(matrix_event_room_create);
|
||||
|
||||
return priv->_creator;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_create_set_creator:
|
||||
* @event: a #MatrixEventRoomCreate
|
||||
* @creator: (transfer none) (nullable): the user ID of the room’s creator
|
||||
*
|
||||
* Set the creator of the room in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_create_set_creator(MatrixEventRoomCreate *matrix_event_room_create, const gchar *creator)
|
||||
{
|
||||
MatrixEventRoomCreatePrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_create != NULL);
|
||||
|
||||
priv = matrix_event_room_create_get_instance_private(matrix_event_room_create);
|
||||
|
||||
if (g_strcmp0(creator, priv->_creator) != 0) {
|
||||
g_free(priv->_creator);
|
||||
priv->_creator = g_strdup(creator);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_create, matrix_event_room_create_properties[PROP_CREATOR]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_create_get_federate:
|
||||
* @event: a #MatrixEventRoomCreate
|
||||
*
|
||||
* Get the federation status of the room. If this function returns %TRUE, the room may be
|
||||
* federated to other homeservers.
|
||||
*
|
||||
* Returns: the federation status of the room
|
||||
*/
|
||||
gboolean
|
||||
matrix_event_room_create_get_federate(MatrixEventRoomCreate *matrix_event_room_create)
|
||||
{
|
||||
MatrixEventRoomCreatePrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_create != NULL, FALSE);
|
||||
|
||||
priv = matrix_event_room_create_get_instance_private(matrix_event_room_create);
|
||||
|
||||
return priv->_federate;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_create_set_federate:
|
||||
* @event: a #MatrixEventRoomCreate
|
||||
* @federate: a federation status
|
||||
*
|
||||
* Set the federation status of the room. See matrix_event_room_create_get_federate() for
|
||||
* more information.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_create_set_federate(MatrixEventRoomCreate *matrix_event_room_create, gboolean federate)
|
||||
{
|
||||
MatrixEventRoomCreatePrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_create != NULL);
|
||||
|
||||
priv = matrix_event_room_create_get_instance_private(matrix_event_room_create);
|
||||
|
||||
if (priv->_federate != federate) {
|
||||
priv->_federate = federate;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_create, matrix_event_room_create_properties[PROP_FEDERATE]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_create_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventRoomCreatePrivate *priv = matrix_event_room_create_get_instance_private(MATRIX_EVENT_ROOM_CREATE(gobject));
|
||||
|
||||
g_free(priv->_creator);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_room_create_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_create_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomCreate *matrix_event_room_create = MATRIX_EVENT_ROOM_CREATE(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CREATOR:
|
||||
g_value_set_string(value, matrix_event_room_create_get_creator(matrix_event_room_create));
|
||||
|
||||
break;
|
||||
case PROP_FEDERATE:
|
||||
g_value_set_boolean(value, matrix_event_room_create_get_federate(matrix_event_room_create));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_create_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomCreate *matrix_event_room_create = MATRIX_EVENT_ROOM_CREATE(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_CREATOR:
|
||||
matrix_event_room_create_set_creator(matrix_event_room_create, g_value_get_string(value));
|
||||
|
||||
break;
|
||||
case PROP_FEDERATE:
|
||||
matrix_event_room_create_set_federate(matrix_event_room_create, g_value_get_boolean(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_create_class_init(MatrixEventRoomCreateClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_room_create_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_room_create_real_to_json;
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_room_create_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_room_create_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_room_create_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomCreate:creator:
|
||||
*
|
||||
* The user_id of the room creator. This is set by the homeserver.
|
||||
*/
|
||||
matrix_event_room_create_properties[PROP_CREATOR] = g_param_spec_string(
|
||||
"creator", "creator", "creator",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_CREATOR, matrix_event_room_create_properties[PROP_CREATOR]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoomCreate:federate:
|
||||
*
|
||||
* Whether users on other servers can join this room. Defaults to %TRUE if key does not exist.
|
||||
*/
|
||||
matrix_event_room_create_properties[PROP_FEDERATE] = g_param_spec_boolean(
|
||||
"federate", "federate", "federate",
|
||||
FALSE,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_FEDERATE, matrix_event_room_create_properties[PROP_FEDERATE]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_create_init(MatrixEventRoomCreate *matrix_event_room_create)
|
||||
{
|
||||
MatrixEventRoomCreatePrivate *priv = matrix_event_room_create_get_instance_private(matrix_event_room_create);
|
||||
|
||||
priv->_creator = NULL;
|
||||
priv->_federate = FALSE;
|
||||
}
|
@ -1,42 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_ROOM_CREATE_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_ROOM_CREATE_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-state-base.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MATRIX_EVENT_TYPE_ROOM_CREATE (matrix_event_room_create_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventRoomCreate, matrix_event_room_create, MATRIX_EVENT, ROOM_CREATE, MatrixEventState)
|
||||
|
||||
struct _MatrixEventRoomCreateClass {
|
||||
MatrixEventStateClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventRoomCreate *matrix_event_room_create_new (void);
|
||||
const gchar *matrix_event_room_create_get_creator (MatrixEventRoomCreate *event);
|
||||
void matrix_event_room_create_set_creator (MatrixEventRoomCreate *event, const gchar *creator);
|
||||
gboolean matrix_event_room_create_get_federate (MatrixEventRoomCreate *event);
|
||||
void matrix_event_room_create_set_federate (MatrixEventRoomCreate *event, gboolean federate);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_ROOM_CREATE_H__ */
|
@ -1,255 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-room-guest-access.h"
|
||||
#include "utils.h"
|
||||
#include "matrix-enumtypes.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-room-guest-access
|
||||
* @short_description: event describing guest access to a room
|
||||
*
|
||||
* This is the default event handler for `m.room.guest_access` events.
|
||||
*
|
||||
* This event controls whether guest users are allowed to join rooms. If this event is absent,
|
||||
* servers should act as if it is present and has the `guest_access` value set to `forbidden`.
|
||||
*/
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_GUEST_ACCESS,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *matrix_event_room_guest_access_properties[NUM_PROPERTIES];
|
||||
|
||||
typedef struct {
|
||||
MatrixGuestAccess _guest_access;
|
||||
} MatrixEventRoomGuestAccessPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomGuestAccess:
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventRoomGuestAccess, matrix_event_room_guest_access, MATRIX_EVENT_TYPE_STATE);
|
||||
|
||||
static void
|
||||
matrix_event_room_guest_access_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomGuestAccessPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_guest_access_get_instance_private(MATRIX_EVENT_ROOM_GUEST_ACCESS(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
#if DEBUG
|
||||
if ((node = json_object_get_member(root, "state_key")) != NULL) {
|
||||
const gchar *state_key = json_node_get_string(node);
|
||||
|
||||
if ((state_key == NULL) || (*state_key == 0)) {
|
||||
g_warning("state_key of a m.room.guest_access is non-empty");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((node = json_object_get_member(content_root, "guest_access")) != NULL) {
|
||||
GError *inner_error = NULL;
|
||||
MatrixGuestAccess guest_access = _matrix_g_enum_nick_to_value(MATRIX_TYPE_GUEST_ACCESS, json_node_get_string(node), &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
priv->_guest_access = MATRIX_GUEST_ACCESS_UNKNOWN;
|
||||
|
||||
#if DEBUG
|
||||
g_warning("Unknown value '%s' in a m.room.guest_access event", json_node_get_string(node));
|
||||
#endif
|
||||
} else {
|
||||
priv->_guest_access = guest_access;
|
||||
}
|
||||
} else {
|
||||
g_warning("content.guest_access is missing from a m.room.guest_access event");
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_guest_access_parent_class)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_guest_access_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomGuestAccessPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
const gchar *state_key;
|
||||
gchar *guest_access;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_guest_access_get_instance_private(MATRIX_EVENT_ROOM_GUEST_ACCESS(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
state_key = matrix_event_state_get_state_key(MATRIX_EVENT_STATE(matrix_event_base));
|
||||
|
||||
if ((state_key == NULL) || (*state_key == 0)) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.room.guest_access event with a non-empty state key");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->_guest_access == MATRIX_GUEST_ACCESS_UNKNOWN) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_UNKNOWN_VALUE,
|
||||
"Won't generate a m.room.guest_access event with an unknown content.guest_access key");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
guest_access = _matrix_g_enum_to_string(MATRIX_TYPE_GUEST_ACCESS, priv->_guest_access, '_');
|
||||
json_object_set_string_member(content_root, "guest_access", guest_access);
|
||||
g_free(guest_access);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_guest_access_parent_class)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_guest_access_new:
|
||||
*
|
||||
* Create a new #MatrixEventRoomGuestAccess object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventRoomGuestAccess object
|
||||
*/
|
||||
MatrixEventRoomGuestAccess *
|
||||
matrix_event_room_guest_access_new(void)
|
||||
{
|
||||
return (MatrixEventRoomGuestAccess *)matrix_event_state_construct(MATRIX_EVENT_TYPE_ROOM_GUEST_ACCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_guest_access_get_guest_access:
|
||||
* @event: a #MatrixEventRoomGuestAccess
|
||||
*
|
||||
* Get the guest access status of the room from @event.
|
||||
*
|
||||
* Returns: the guest access status
|
||||
*/
|
||||
MatrixGuestAccess
|
||||
matrix_event_room_guest_access_get_guest_access(MatrixEventRoomGuestAccess *matrix_event_room_guest_access)
|
||||
{
|
||||
MatrixEventRoomGuestAccessPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_guest_access != NULL, 0);
|
||||
|
||||
priv = matrix_event_room_guest_access_get_instance_private(matrix_event_room_guest_access);
|
||||
|
||||
return priv->_guest_access;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_guest_access_set_guest_access:
|
||||
* @event: a #MatrixEventRoomGuestAccess
|
||||
* @guest_access: a #MatrixGuestAccess value
|
||||
*
|
||||
* Set the guest access status for the room in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_guest_access_set_guest_access(MatrixEventRoomGuestAccess *matrix_event_room_guest_access, MatrixGuestAccess guest_access)
|
||||
{
|
||||
MatrixEventRoomGuestAccessPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_guest_access != NULL);
|
||||
|
||||
priv = matrix_event_room_guest_access_get_instance_private(matrix_event_room_guest_access);
|
||||
|
||||
if (priv->_guest_access != guest_access) {
|
||||
priv->_guest_access = guest_access;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_guest_access, matrix_event_room_guest_access_properties[PROP_GUEST_ACCESS]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_guest_access_finalize (GObject *gobject)
|
||||
{
|
||||
G_OBJECT_CLASS(matrix_event_room_guest_access_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_guest_access_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomGuestAccess *matrix_event_room_guest_access = MATRIX_EVENT_ROOM_GUEST_ACCESS(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_GUEST_ACCESS:
|
||||
g_value_set_enum(value, matrix_event_room_guest_access_get_guest_access(matrix_event_room_guest_access));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_guest_access_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec) {
|
||||
MatrixEventRoomGuestAccess *matrix_event_room_guest_access = MATRIX_EVENT_ROOM_GUEST_ACCESS(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_GUEST_ACCESS:
|
||||
matrix_event_room_guest_access_set_guest_access(matrix_event_room_guest_access, g_value_get_enum(value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_guest_access_class_init(MatrixEventRoomGuestAccessClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_room_guest_access_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_room_guest_access_real_to_json;
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_room_guest_access_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_room_guest_access_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_room_guest_access_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomGuestAccess:guest-access:
|
||||
*
|
||||
* Whether guests can join the room.
|
||||
*/
|
||||
matrix_event_room_guest_access_properties[PROP_GUEST_ACCESS] = g_param_spec_enum(
|
||||
"guest-access", "guest-access", "guest-access",
|
||||
MATRIX_TYPE_GUEST_ACCESS, MATRIX_GUEST_ACCESS_UNKNOWN,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_GUEST_ACCESS, matrix_event_room_guest_access_properties[PROP_GUEST_ACCESS]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_guest_access_init(MatrixEventRoomGuestAccess *matrix_event_room_guest_access)
|
||||
{
|
||||
MatrixEventRoomGuestAccessPrivate *priv = matrix_event_room_guest_access_get_instance_private(matrix_event_room_guest_access);
|
||||
|
||||
priv->_guest_access = MATRIX_GUEST_ACCESS_UNKNOWN;
|
||||
}
|
@ -1,41 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_ROOM_GUEST_ACCESS_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_ROOM_GUEST_ACCESS_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-state-base.h"
|
||||
# include "matrix-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MATRIX_EVENT_TYPE_ROOM_GUEST_ACCESS (matrix_event_room_guest_access_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventRoomGuestAccess, matrix_event_room_guest_access, MATRIX_EVENT, ROOM_GUEST_ACCESS, MatrixEventState)
|
||||
|
||||
struct _MatrixEventRoomGuestAccessClass {
|
||||
MatrixEventStateClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventRoomGuestAccess *matrix_event_room_guest_access_new(void);
|
||||
MatrixGuestAccess matrix_event_room_guest_access_get_guest_access(MatrixEventRoomGuestAccess *event);
|
||||
void matrix_event_room_guest_access_set_guest_access(MatrixEventRoomGuestAccess *event, MatrixGuestAccess guest_access);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_ROOM_GUEST_ACCESS_H__ */
|
@ -1,257 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-room-history-visibility.h"
|
||||
#include "matrix-enumtypes.h"
|
||||
#include "utils.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-room-history-visibility
|
||||
* @short_description: event to control history visibility to room members
|
||||
*
|
||||
* This is the default event handler for `m.room.history_visibility` events.
|
||||
*
|
||||
* This event controls whether a user can see the events that happened in a room from before
|
||||
* they joined.
|
||||
*/
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_VISIBILITY,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *matrix_event_room_history_visibility_properties[NUM_PROPERTIES];
|
||||
|
||||
typedef struct {
|
||||
MatrixHistoryVisibility _visibility;
|
||||
} MatrixEventRoomHistoryVisibilityPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomHistoryVisibility:
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventRoomHistoryVisibility, matrix_event_room_history_visibility, MATRIX_EVENT_TYPE_STATE);
|
||||
|
||||
static void
|
||||
matrix_event_room_history_visibility_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomHistoryVisibilityPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
|
||||
g_return_if_fail (json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_history_visibility_get_instance_private(MATRIX_EVENT_ROOM_HISTORY_VISIBILITY(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
#ifdef DEBUG
|
||||
if ((node = json_object_get_member(root, "state_key")) != NULL) {
|
||||
const gchar *state_key = json_node_get_string(node);
|
||||
|
||||
if ((state_key == NULL) || (*state_key == 0)) {
|
||||
g_warning("state_key of a m.room.history_visibility event is non-empty");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((node = json_object_get_member(content_root, "history_visibility")) != NULL) {
|
||||
GError *inner_error = NULL;
|
||||
MatrixHistoryVisibility visibility = _matrix_g_enum_nick_to_value(MATRIX_TYPE_HISTORY_VISIBILITY, json_node_get_string(node), &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
priv->_visibility = MATRIX_HISTORY_VISIBILITY_UNKNOWN;
|
||||
#ifdef DEBUG
|
||||
g_warning("Unknown history_visibility value %s", json_node_get_string(node));
|
||||
#endif
|
||||
} else {
|
||||
priv->_visibility = visibility;
|
||||
}
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_history_visibility_parent_class)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_history_visibility_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomHistoryVisibilityPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
const gchar *state_key;
|
||||
gchar *visibility_str;
|
||||
|
||||
g_return_if_fail (json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_history_visibility_get_instance_private(MATRIX_EVENT_ROOM_HISTORY_VISIBILITY(matrix_event_base));
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
state_key = matrix_event_state_get_state_key(MATRIX_EVENT_STATE(matrix_event_base));
|
||||
|
||||
if ((state_key == NULL) || (*state_key == 0)) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.room.history_visibility event with a non-empty state key");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->_visibility == MATRIX_HISTORY_VISIBILITY_UNKNOWN) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_UNKNOWN_VALUE,
|
||||
"Won't send m.room.history_visibility event with unknown visibility value");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
visibility_str = _matrix_g_enum_to_string(MATRIX_TYPE_HISTORY_VISIBILITY, priv->_visibility, '_');
|
||||
|
||||
json_object_set_string_member(content_root, "history_visibility", visibility_str);
|
||||
|
||||
g_free(visibility_str);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_history_visibility_parent_class)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_history_visibility_new:
|
||||
*
|
||||
* Create a new #MatrixEventRoomHistoryVisibility object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventRoomHistoryVisibility object
|
||||
*/
|
||||
MatrixEventRoomHistoryVisibility *
|
||||
matrix_event_room_history_visibility_new(void)
|
||||
{
|
||||
return (MatrixEventRoomHistoryVisibility *)matrix_event_state_construct(MATRIX_EVENT_TYPE_ROOM_HISTORY_VISIBILITY);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_history_visibility_get_visibility:
|
||||
* @event: a #MatrixEventRoomHistoryVisibility
|
||||
*
|
||||
* Get the history visibility status of the room.
|
||||
*
|
||||
* Returns: a #MatrixHistoryVisibility value
|
||||
*/
|
||||
MatrixHistoryVisibility
|
||||
matrix_event_room_history_visibility_get_visibility(MatrixEventRoomHistoryVisibility *matrix_event_room_history_visibility)
|
||||
{
|
||||
MatrixEventRoomHistoryVisibilityPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_history_visibility != NULL, 0);
|
||||
|
||||
priv = matrix_event_room_history_visibility_get_instance_private(matrix_event_room_history_visibility);
|
||||
|
||||
return priv->_visibility;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_history_visibility_set_visibility:
|
||||
* @event: a #MatrixEventRoomHistoryVisibility
|
||||
* @history_visibility: a #MatrixHistoryVisibility value
|
||||
*
|
||||
* Set the history visibility in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_history_visibility_set_visibility(MatrixEventRoomHistoryVisibility *matrix_event_room_history_visibility, MatrixHistoryVisibility visibility)
|
||||
{
|
||||
MatrixEventRoomHistoryVisibilityPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_history_visibility != NULL);
|
||||
|
||||
priv = matrix_event_room_history_visibility_get_instance_private(matrix_event_room_history_visibility);
|
||||
|
||||
if (priv->_visibility != visibility) {
|
||||
priv->_visibility = visibility;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_history_visibility, matrix_event_room_history_visibility_properties[PROP_VISIBILITY]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_history_visibility_finalize(GObject *gobject) {
|
||||
G_OBJECT_CLASS(matrix_event_room_history_visibility_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_history_visibility_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomHistoryVisibility *matrix_event_room_history_visibility = MATRIX_EVENT_ROOM_HISTORY_VISIBILITY(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_VISIBILITY:
|
||||
g_value_set_enum(value, matrix_event_room_history_visibility_get_visibility(matrix_event_room_history_visibility));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_history_visibility_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomHistoryVisibility *matrix_event_room_history_visibility = MATRIX_EVENT_ROOM_HISTORY_VISIBILITY(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_VISIBILITY:
|
||||
matrix_event_room_history_visibility_set_visibility(matrix_event_room_history_visibility, g_value_get_enum(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_history_visibility_class_init(MatrixEventRoomHistoryVisibilityClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_room_history_visibility_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_room_history_visibility_real_to_json;
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_room_history_visibility_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_room_history_visibility_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_room_history_visibility_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomHistoryVisibiliy:visibility:
|
||||
*
|
||||
* Who can see the room history.
|
||||
*/
|
||||
matrix_event_room_history_visibility_properties[PROP_VISIBILITY] = g_param_spec_enum(
|
||||
"visibility", "visibility", "visibility",
|
||||
MATRIX_TYPE_HISTORY_VISIBILITY, MATRIX_HISTORY_VISIBILITY_UNKNOWN,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_VISIBILITY, matrix_event_room_history_visibility_properties[PROP_VISIBILITY]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_history_visibility_init(MatrixEventRoomHistoryVisibility *matrix_event_room_history_visibility)
|
||||
{
|
||||
MatrixEventRoomHistoryVisibilityPrivate *priv = matrix_event_room_history_visibility_get_instance_private(matrix_event_room_history_visibility);
|
||||
|
||||
priv->_visibility = MATRIX_HISTORY_VISIBILITY_UNKNOWN;
|
||||
}
|
@ -1,41 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_ROOM_HISTORY_VISIBILITY_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_ROOM_HISTORY_VISIBILITY_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-state-base.h"
|
||||
# include "matrix-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MATRIX_EVENT_TYPE_ROOM_HISTORY_VISIBILITY (matrix_event_room_history_visibility_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventRoomHistoryVisibility, matrix_event_room_history_visibility, MATRIX_EVENT, ROOM_HISTORY_VISIBILITY, MatrixEventState)
|
||||
|
||||
struct _MatrixEventRoomHistoryVisibilityClass {
|
||||
MatrixEventStateClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventRoomHistoryVisibility *matrix_event_room_history_visibility_new(void);
|
||||
MatrixHistoryVisibility matrix_event_room_history_visibility_get_visibility(MatrixEventRoomHistoryVisibility *event);
|
||||
void matrix_event_room_history_visibility_set_visibility(MatrixEventRoomHistoryVisibility *event, MatrixHistoryVisibility history_visibility);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_ROOM_HISTORY_VISIBILITY_H__ */
|
@ -1,262 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-room-join-rules.h"
|
||||
#include "matrix-enumtypes.h"
|
||||
#include "utils.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-room-join-rules
|
||||
* @short_description: event to hold the join rules for a room
|
||||
*
|
||||
* This is the default event handler for `m.room.join_rules` events.
|
||||
*
|
||||
* A room may be `public` meaning anyone can join the room without any prior action.
|
||||
* Alternatively, it can be `invite` meaning that a user who wishes to join the room must
|
||||
* first receive an invite to the room from someone already inside of the room. Currently,
|
||||
* `knock` and `private` are reserved keywords which are not implemented.
|
||||
*/
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_JOIN_RULES,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *matrix_event_room_join_rules_properties[NUM_PROPERTIES];
|
||||
|
||||
typedef struct {
|
||||
MatrixJoinRules _join_rules;
|
||||
} MatrixEventRoomJoinRulesPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomJoinRules:
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventRoomJoinRules, matrix_event_room_join_rules, MATRIX_EVENT_TYPE_STATE);
|
||||
|
||||
static void
|
||||
matrix_event_room_join_rules_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomJoinRulesPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_join_rules_get_instance_private(MATRIX_EVENT_ROOM_JOIN_RULES(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
#ifdef DEBUG
|
||||
if ((node = json_object_get_member(root, "state_key")) != NULL) {
|
||||
const gchar *state_key = json_node_get_string(node);
|
||||
|
||||
if ((state_key == NULL) || (*state_key != 0)) {
|
||||
g_warning("state_key of a m.room.join_rules is non-empty");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ((node = json_object_get_member(content_root, "join_rule")) != NULL) {
|
||||
GError *inner_error = NULL;
|
||||
MatrixJoinRules join_rules = _matrix_g_enum_nick_to_value(MATRIX_TYPE_JOIN_RULES, json_node_get_string(node), &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
priv->_join_rules = MATRIX_JOIN_RULES_UNKNOWN;
|
||||
|
||||
#ifdef DEBUG
|
||||
g_warning("Unknown value %s in a m.room.join_rules event", json_node_get_string(node));
|
||||
#endif
|
||||
} else {
|
||||
priv->_join_rules = join_rules;
|
||||
}
|
||||
} else {
|
||||
priv->_join_rules = MATRIX_JOIN_RULES_UNKNOWN;
|
||||
|
||||
g_warning("content.join_rules is missing from a m.room.join_rules event.");
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_join_rules_parent_class)->from_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_join_rules_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomJoinRulesPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
const gchar *state_key;
|
||||
gchar *join_rules;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_join_rules_get_instance_private(MATRIX_EVENT_ROOM_JOIN_RULES(matrix_event_base));
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
state_key = matrix_event_state_get_state_key(MATRIX_EVENT_STATE(matrix_event_base));
|
||||
|
||||
if ((state_key == NULL) || (*state_key == 0)) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.room.join_rules event with a non-empty state_key");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (priv->_join_rules == MATRIX_JOIN_RULES_UNKNOWN) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_UNKNOWN_VALUE,
|
||||
"Won't send a m.room.join_rules event with an unknown rule");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
join_rules = _matrix_g_enum_to_string(MATRIX_TYPE_JOIN_RULES, priv->_join_rules, '_');
|
||||
json_object_set_string_member(content_root, "join_rule", join_rules);
|
||||
g_free(join_rules);
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_join_rules_parent_class)->to_json(matrix_event_base, json_data, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_join_rules_new:
|
||||
*
|
||||
* Create a new #MatrixEventRoomJoinRules object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventRoomJoinRules object
|
||||
*/
|
||||
MatrixEventRoomJoinRules *
|
||||
matrix_event_room_join_rules_new(void) {
|
||||
return (MatrixEventRoomJoinRules *)matrix_event_state_construct(MATRIX_EVENT_TYPE_ROOM_JOIN_RULES);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_join_rules_get_join_rules:
|
||||
* @event: a #MatrixEventRoomJoinRules
|
||||
*
|
||||
* Get the join rules for the room in @event.
|
||||
*
|
||||
* Returns: a #MatrixJoinRules value
|
||||
*/
|
||||
MatrixJoinRules
|
||||
matrix_event_room_join_rules_get_join_rules(MatrixEventRoomJoinRules *matrix_event_room_join_rules)
|
||||
{
|
||||
MatrixEventRoomJoinRulesPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_join_rules != NULL, 0);
|
||||
|
||||
priv = matrix_event_room_join_rules_get_instance_private(matrix_event_room_join_rules);
|
||||
|
||||
return priv->_join_rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_join_rules_set_join_rules:
|
||||
* @event: a #MatrixEventRoomJoinRules
|
||||
* @join_rules: a #MatrixJoinRules value
|
||||
*
|
||||
* Set the join rules for the room in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_join_rules_set_join_rules(MatrixEventRoomJoinRules *matrix_event_room_join_rules, MatrixJoinRules join_rules)
|
||||
{
|
||||
MatrixEventRoomJoinRulesPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_join_rules != NULL);
|
||||
|
||||
priv = matrix_event_room_join_rules_get_instance_private(matrix_event_room_join_rules);
|
||||
|
||||
if (priv->_join_rules != join_rules) {
|
||||
priv->_join_rules = join_rules;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_join_rules, matrix_event_room_join_rules_properties[PROP_JOIN_RULES]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_join_rules_finalize(GObject *gobject)
|
||||
{
|
||||
G_OBJECT_CLASS(matrix_event_room_join_rules_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_join_rules_get_property(GObject *gobject, guint property_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomJoinRules *matrix_event_room_join_rules = MATRIX_EVENT_ROOM_JOIN_RULES(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_JOIN_RULES:
|
||||
g_value_set_enum(value, matrix_event_room_join_rules_get_join_rules(matrix_event_room_join_rules));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_join_rules_set_property(GObject *gobject, guint property_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
MatrixEventRoomJoinRules *matrix_event_room_join_rules = MATRIX_EVENT_ROOM_JOIN_RULES(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_JOIN_RULES:
|
||||
matrix_event_room_join_rules_set_join_rules(matrix_event_room_join_rules, g_value_get_enum(value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_join_rules_class_init(MatrixEventRoomJoinRulesClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_room_join_rules_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_room_join_rules_real_to_json;
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_room_join_rules_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_room_join_rules_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_room_join_rules_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomJoinRules:join-rules:
|
||||
*
|
||||
* The join rules.
|
||||
*/
|
||||
matrix_event_room_join_rules_properties[PROP_JOIN_RULES] = g_param_spec_enum(
|
||||
"join-rules", "join-rules", "join-rules",
|
||||
MATRIX_TYPE_JOIN_RULES, MATRIX_JOIN_RULES_UNKNOWN,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_JOIN_RULES, matrix_event_room_join_rules_properties[PROP_JOIN_RULES]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_join_rules_init(MatrixEventRoomJoinRules *matrix_event_room_join_rules)
|
||||
{
|
||||
MatrixEventRoomJoinRulesPrivate *priv = matrix_event_room_join_rules_get_instance_private(matrix_event_room_join_rules);
|
||||
|
||||
priv->_join_rules = MATRIX_JOIN_RULES_UNKNOWN;
|
||||
}
|
@ -1,41 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_GLIB_SDK_EVENT_ROOM_JOIN_RULES_H__
|
||||
# define __MATRIX_GLIB_SDK_EVENT_ROOM_JOIN_RULES_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-state-base.h"
|
||||
# include "matrix-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MATRIX_EVENT_TYPE_ROOM_JOIN_RULES (matrix_event_room_join_rules_get_type ())
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventRoomJoinRules, matrix_event_room_join_rules, MATRIX_EVENT, ROOM_JOIN_RULES, MatrixEventState)
|
||||
|
||||
struct _MatrixEventRoomJoinRulesClass {
|
||||
MatrixEventStateClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventRoomJoinRules *matrix_event_room_join_rules_new (void);
|
||||
MatrixJoinRules matrix_event_room_join_rules_get_join_rules (MatrixEventRoomJoinRules *event);
|
||||
void matrix_event_room_join_rules_set_join_rules (MatrixEventRoomJoinRules *event, MatrixJoinRules join_rules);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_GLIB_SDK_EVENT_ROOM_JOIN_RULES_H__ */
|
@ -1,994 +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/>.
|
||||
*/
|
||||
|
||||
#include "matrix-event-room-member.h"
|
||||
#include "config.h"
|
||||
#include "matrix-enumtypes.h"
|
||||
#include "utils.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-event-room-member
|
||||
* @short_description: event representing room membership
|
||||
*
|
||||
* This is the default event handler for `m.room.member` events.
|
||||
*
|
||||
* Adjusts the membership state for a user in a room. It is preferable to use the membership
|
||||
* APIs like matrix_api_invite_user() when performing membership actions rather than adjusting
|
||||
* the state directly as there are a restricted set of valid transformations. For example,
|
||||
* user A cannot force user B to join a room, and trying to force this state change directly
|
||||
* will fail.
|
||||
*
|
||||
* The following membership states are specified:
|
||||
*
|
||||
* * `invite` - The user has been invited to join a room, but has not yet joined it. They may
|
||||
* not participate in the room until they join.
|
||||
* * `join` - The user has joined the room (possibly after accepting an invite), and may
|
||||
* participate in it.
|
||||
* * `leave` - The user was once joined to the room, but has since left (possibly by choice,
|
||||
* or possibly by being kicked).
|
||||
* * `ban` - The user has been banned from the room, and is no longer allowed to join it until
|
||||
* they are un-banned from the room (by having their membership state set to a value other
|
||||
* than ban).
|
||||
* * `knock` - This is a reserved word, which currently has no meaning.
|
||||
*
|
||||
* See also #MatrixRoomMembership for more information.
|
||||
*
|
||||
* The MatrixEventRoomMember:third-party-invite property will be set if this invite is an
|
||||
* invite event and is the successor of an `m.room.third_party_invite` event, and absent
|
||||
* otherwise.
|
||||
*
|
||||
* This event may also include an `invite_room_state` key outside the content key. If present,
|
||||
* this contains an array of stripped state events. These events provide information on a few
|
||||
* select state events such as the room name.
|
||||
*/
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_MEMBERSHIP,
|
||||
PROP_AVATAR_URL,
|
||||
PROP_DISPLAY_NAME,
|
||||
PROP_TPI_DISPLAY_NAME,
|
||||
PROP_TPI_SIGNED_MXID,
|
||||
PROP_TPI_SIGNED_TOKEN,
|
||||
PROP_TPI_SIGNATURE,
|
||||
PROP_USER_ID,
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec* matrix_event_room_member_properties[NUM_PROPERTIES];
|
||||
|
||||
typedef struct {
|
||||
MatrixRoomMembership _membership;
|
||||
gchar* _avatar_url;
|
||||
gchar* _display_name;
|
||||
gchar* _tpi_display_name;
|
||||
gchar* _tpi_signed_mxid;
|
||||
gchar* _tpi_signed_token;
|
||||
JsonNode* _tpi_signature;
|
||||
MatrixEventState** _invite_room_state;
|
||||
gint _invite_room_state_len;
|
||||
gint __invite_room_state_size_;
|
||||
} MatrixEventRoomMemberPrivate;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomMember:
|
||||
*/
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixEventRoomMember, matrix_event_room_member, MATRIX_EVENT_TYPE_STATE);
|
||||
|
||||
static void
|
||||
matrix_event_room_member_real_from_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonNode *content_node;
|
||||
JsonNode *node;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
g_return_if_fail(json_data != NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(MATRIX_EVENT_ROOM_MEMBER(matrix_event_base));
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
|
||||
// Even though the state_key is handled by the parent class,
|
||||
// in this event type this actually means the sender
|
||||
if ((node = json_object_get_member(root, "state_key")) != NULL) {
|
||||
matrix_event_state_set_state_key(MATRIX_EVENT_STATE(matrix_event_base), json_node_get_string(node));
|
||||
} else {
|
||||
g_warning("state_key is missing from a m.room.member event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "membership")) != NULL) {
|
||||
MatrixRoomMembership membership;
|
||||
|
||||
membership = _matrix_g_enum_nick_to_value(MATRIX_TYPE_ROOM_MEMBERSHIP, json_node_get_string(node), &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_clear_error(&inner_error);
|
||||
priv->_membership = MATRIX_ROOM_MEMBERSHIP_UNKNOWN;
|
||||
|
||||
if (DEBUG) {
|
||||
g_warning("Unknown membership value %s", json_node_get_string(node));
|
||||
}
|
||||
} else {
|
||||
priv->_membership = membership;
|
||||
}
|
||||
} else if (DEBUG) {
|
||||
g_warning("membership key is missing from the m.room.member event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "avatar_url")) != NULL) {
|
||||
g_free(priv->_avatar_url);
|
||||
priv->_avatar_url = g_strdup(json_node_get_string(node));
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "displayname")) != NULL) {
|
||||
g_free(priv->_display_name);
|
||||
priv->_display_name = g_strdup(json_node_get_string(node));
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(content_root, "third_party_invite")) != NULL) {
|
||||
JsonObject *tpi_root = json_node_get_object(node);
|
||||
|
||||
if ((node = json_object_get_member(tpi_root, "display_name")) != NULL) {
|
||||
g_free(priv->_tpi_display_name);
|
||||
priv->_tpi_display_name = g_strdup(json_node_get_string(node));
|
||||
} else {
|
||||
g_warning("content.third_party_invite.display_name is missing from a m.room.member event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(tpi_root, "signed")) != NULL) {
|
||||
JsonObject *signed_root = json_node_get_object(node);
|
||||
|
||||
if ((node = json_object_get_member(signed_root, "mxid")) != NULL) {
|
||||
g_free(priv->_tpi_signed_mxid);
|
||||
priv->_tpi_signed_mxid = g_strdup(json_node_get_string(node));
|
||||
} else {
|
||||
g_warning("content.third_party_invit.signed.mxid is missing from a m.room.member event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(signed_root, "token")) != NULL) {
|
||||
g_free(priv->_tpi_signed_token);
|
||||
priv->_tpi_signed_token = g_strdup(json_node_get_string(node));
|
||||
} else {
|
||||
g_warning("content.third_party_invite.signed.token is missing from a m.room.member event");
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(signed_root, "signatures")) != NULL) {
|
||||
json_node_unref(priv->_tpi_signature);
|
||||
priv->_tpi_signature = json_node_ref(node);
|
||||
} else {
|
||||
g_warning("content.third_party_invite.signed.signatures is missing from a m.room.member event");
|
||||
}
|
||||
} else {
|
||||
g_warning("content.third_party_invite.signed is missing from a m.room.member event");
|
||||
}
|
||||
}
|
||||
|
||||
if ((node = json_object_get_member(root, "invite_room_state")) != NULL) {
|
||||
JsonArray *events = json_node_get_array(node);
|
||||
gint events_len;
|
||||
|
||||
if ((events_len = json_array_get_length(events)) > 0) {
|
||||
for (gint i = 0; i < priv->_invite_room_state_len; i++) {
|
||||
g_object_unref(priv->_invite_room_state[i]);
|
||||
}
|
||||
|
||||
g_free(priv->_invite_room_state);
|
||||
|
||||
priv->_invite_room_state_len = events_len;
|
||||
priv->_invite_room_state = g_new(MatrixEventState *, events_len);
|
||||
|
||||
for (gint i = 0; i < events_len; i++) {
|
||||
JsonNode *member_node = json_array_get_element(events, i);
|
||||
MatrixEventState *event;
|
||||
GError *error = NULL;
|
||||
|
||||
event = (MatrixEventState *)matrix_event_base_new_from_json(NULL, member_node, &error);
|
||||
|
||||
if (error == NULL) {
|
||||
priv->_invite_room_state[i] = g_object_ref(event);
|
||||
}
|
||||
|
||||
g_object_unref(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Chain up
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_member_parent_class)->from_json(matrix_event_base, json_data, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_member_real_to_json(MatrixEventBase *matrix_event_base, JsonNode *json_data, GError **error)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
const gchar *state_key;
|
||||
gchar *membership;
|
||||
JsonObject *root;
|
||||
JsonObject *content_root;
|
||||
JsonObject *tpi_root;
|
||||
JsonObject *tpi_signed_root;
|
||||
JsonNode *content_node;
|
||||
GError *inner_error = NULL;
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(MATRIX_EVENT_ROOM_MEMBER(matrix_event_base));
|
||||
|
||||
if (priv->_membership == MATRIX_ROOM_MEMBERSHIP_UNKNOWN) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_UNKNOWN_VALUE,
|
||||
"Unknown membership value cannot be added to a room member event");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
state_key = matrix_event_state_get_state_key(MATRIX_EVENT_STATE(matrix_event_base));
|
||||
|
||||
if ((state_key == NULL) || (*state_key == 0)) {
|
||||
g_set_error(error, MATRIX_ERROR, MATRIX_ERROR_INCOMPLETE,
|
||||
"Won't generate a m.room.member event with an empty state_key");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
root = json_node_get_object(json_data);
|
||||
content_node = json_object_get_member(root, "content");
|
||||
content_root = json_node_get_object(content_node);
|
||||
membership = _matrix_g_enum_to_string(MATRIX_TYPE_ROOM_MEMBERSHIP, priv->_membership, '_');
|
||||
|
||||
if (membership != NULL) {
|
||||
json_object_set_string_member(content_root, "membership", membership);
|
||||
g_free(membership);
|
||||
} else {
|
||||
g_critical("Won't generate a m.room.member event with an unknown membership");
|
||||
}
|
||||
|
||||
if (priv->_avatar_url != NULL) {
|
||||
json_object_set_string_member(content_root, "avatar_url", priv->_avatar_url);
|
||||
}
|
||||
|
||||
if (priv->_display_name != NULL) {
|
||||
json_object_set_string_member(content_root, "displayname", priv->_display_name);
|
||||
}
|
||||
|
||||
tpi_root = json_object_new();
|
||||
|
||||
if (priv->_tpi_display_name != NULL) {
|
||||
json_object_set_string_member(tpi_root, "display_name", priv->_tpi_display_name);
|
||||
}
|
||||
|
||||
tpi_signed_root = json_object_new();
|
||||
|
||||
if (priv->_tpi_signed_mxid != NULL) {
|
||||
json_object_set_string_member(tpi_signed_root, "mxid", priv->_tpi_signed_mxid);
|
||||
}
|
||||
|
||||
if (priv->_tpi_signed_token != NULL) {
|
||||
json_object_set_string_member(tpi_signed_root, "token", priv->_tpi_signed_token);
|
||||
}
|
||||
|
||||
if (priv->_tpi_signature != NULL) {
|
||||
json_object_set_member(tpi_signed_root, "signature", priv->_tpi_signature);
|
||||
}
|
||||
|
||||
if ((json_object_get_size(tpi_signed_root) != 3) &&
|
||||
(json_object_get_size(tpi_signed_root) != 0)) {
|
||||
g_warning("3rd party invite data is not filled; ignoring");
|
||||
|
||||
tpi_signed_root = (json_object_unref(tpi_signed_root), NULL);
|
||||
}
|
||||
|
||||
if ((tpi_signed_root != NULL) && (priv->_tpi_display_name != NULL)) {
|
||||
JsonNode *tpi_signed_node = json_node_new(JSON_NODE_OBJECT);
|
||||
|
||||
json_node_set_object(tpi_signed_node, tpi_signed_root);
|
||||
json_object_set_member(tpi_root, "signed", tpi_signed_node);
|
||||
}
|
||||
|
||||
if (json_object_get_size(tpi_root) == 2) {
|
||||
JsonNode *tpi_node = json_node_new(JSON_NODE_OBJECT);
|
||||
|
||||
json_node_set_object(tpi_node, tpi_root);
|
||||
json_object_set_member(content_root, "third_party_invite", tpi_node);
|
||||
} else if (json_object_get_size(tpi_root) != 0) {
|
||||
tpi_root = (json_object_unref(tpi_root), NULL);
|
||||
g_warning("3rd party invite data is incomplete; ignoring");
|
||||
}
|
||||
|
||||
if (priv->_invite_room_state != NULL) {
|
||||
JsonArray *state_ary = json_array_new();
|
||||
|
||||
for (gint i = 0; i < priv->_invite_room_state_len; i++) {
|
||||
JsonNode *state_node = matrix_event_state_get_stripped_node(priv->_invite_room_state[i]);
|
||||
|
||||
json_array_add_element(state_ary, state_node);
|
||||
}
|
||||
|
||||
if (json_array_get_length(state_ary) > 0) {
|
||||
JsonNode *state_node = json_node_new(JSON_TYPE_ARRAY);
|
||||
|
||||
json_node_set_array(state_node, state_ary);
|
||||
json_object_set_member(root, "invite_room_state", state_node);
|
||||
}
|
||||
}
|
||||
|
||||
MATRIX_EVENT_BASE_CLASS(matrix_event_room_member_parent_class)->to_json(matrix_event_base, json_data, &inner_error);
|
||||
|
||||
if (inner_error != NULL) {
|
||||
g_propagate_error(error, inner_error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_new:
|
||||
*
|
||||
* Create a new #MatrixEventRoomMember object.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixEventRoomMember object
|
||||
*/
|
||||
MatrixEventRoomMember *
|
||||
matrix_event_room_member_new(void)
|
||||
{
|
||||
return (MatrixEventRoomMember *)matrix_event_state_construct(MATRIX_EVENT_TYPE_ROOM_MEMBER);
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_get_membership:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
*
|
||||
* Get the membership status from @event.
|
||||
*
|
||||
* Returns: a #MatrixRoomMembership value
|
||||
*/
|
||||
MatrixRoomMembership
|
||||
matrix_event_room_member_get_membership(MatrixEventRoomMember *matrix_event_room_member)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_member != NULL, 0);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
return priv->_membership;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_set_membership:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
* @membership: a #MatrixRoomMembership value
|
||||
*
|
||||
* Set the membership value in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_member_set_membership(MatrixEventRoomMember *matrix_event_room_member, MatrixRoomMembership membership)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_member != NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
if (priv->_membership != membership) {
|
||||
priv->_membership = membership;
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_member, matrix_event_room_member_properties[PROP_MEMBERSHIP]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_get_avatar_url:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
*
|
||||
* Get the avatar URL from @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): an avatar URL
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_member_get_avatar_url(MatrixEventRoomMember *matrix_event_room_member)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_member != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
return priv->_avatar_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_set_avatar_url:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
* @avatar_url: (transfer none) (nullable): the avatar URL for @event
|
||||
*
|
||||
* Set the avatar URL in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_member_set_avatar_url(MatrixEventRoomMember *matrix_event_room_member, const gchar *avatar_url)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_member != NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
if (g_strcmp0(avatar_url, priv->_avatar_url) != 0) {
|
||||
g_free(priv->_avatar_url);
|
||||
priv->_avatar_url = g_strdup(avatar_url);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_member, matrix_event_room_member_properties[PROP_AVATAR_URL]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_get_display_name:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
*
|
||||
* Get the display name from @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a display name
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_member_get_display_name(MatrixEventRoomMember *matrix_event_room_member)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_member != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
return priv->_display_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_set_display_name:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
* @display_name: (transfer none) (nullable): a display name
|
||||
*
|
||||
* Set the display name in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_member_set_display_name(MatrixEventRoomMember *matrix_event_room_member, const gchar *display_name)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_member != NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
if (g_strcmp0(display_name, priv->_display_name) != 0) {
|
||||
g_free(priv->_display_name);
|
||||
priv->_display_name = g_strdup(display_name);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_member, matrix_event_room_member_properties[PROP_DISPLAY_NAME]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_get_tpi_display_name:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
*
|
||||
* Get the 3rd party display name from @event. It will be %NULL if the member was not invited
|
||||
* by a 3rd party ID.
|
||||
*
|
||||
* The returned value is owned by @event, and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a 3rd party display name
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_member_get_tpi_display_name(MatrixEventRoomMember *matrix_event_room_member)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_member != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
return priv->_tpi_display_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_set_tpi_display_name:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
* @tpi_display_name: a 3rd party display name
|
||||
*
|
||||
* Set the 3rd party display name in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_member_set_tpi_display_name(MatrixEventRoomMember *matrix_event_room_member, const gchar *tpi_display_name)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_member != NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
if (g_strcmp0(tpi_display_name, priv->_tpi_display_name) != 0) {
|
||||
g_free(priv->_tpi_display_name);
|
||||
priv->_tpi_display_name = g_strdup(tpi_display_name);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_member, matrix_event_room_member_properties[PROP_TPI_DISPLAY_NAME]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_get_tpi_signed_mxid:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
*
|
||||
* Get the signed 3rd party Matrix ID.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a 3rd party Matrix ID
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_member_get_tpi_signed_mxid(MatrixEventRoomMember *matrix_event_room_member)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_member != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
return priv->_tpi_signed_mxid;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_set_tpi_signed_mxid:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
* @tpi_signed_mxid: a 3rd party signed Matrix ID
|
||||
*
|
||||
* Set the signed 3rd party Matrix ID.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_member_set_tpi_signed_mxid(MatrixEventRoomMember *matrix_event_room_member, const gchar *tpi_signed_mxid)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_member != NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
if (g_strcmp0(tpi_signed_mxid, priv->_tpi_signed_mxid) != 0) {
|
||||
g_free(priv->_tpi_signed_mxid);
|
||||
priv->_tpi_signed_mxid = g_strdup(tpi_signed_mxid);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_member, matrix_event_room_member_properties[PROP_TPI_SIGNED_MXID]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_get_tpi_signed_token:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
*
|
||||
* Get the signed 3rd party token.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a signed 3rd party token
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_member_get_tpi_signed_token(MatrixEventRoomMember *matrix_event_room_member)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_member != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
return priv->_tpi_signed_token;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_set_tpi_signed_token:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
* @tpi_signed_token: a signed 3rd party token
|
||||
*
|
||||
* Set the signed 3rd party token in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_member_set_tpi_signed_token(MatrixEventRoomMember *matrix_event_room_member, const gchar *tpi_signed_token)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_member != NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
if (g_strcmp0(tpi_signed_token, priv->_tpi_signed_token) != 0) {
|
||||
g_free(priv->_tpi_signed_token);
|
||||
priv->_tpi_signed_token = g_strdup(tpi_signed_token);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_member, matrix_event_room_member_properties[PROP_TPI_SIGNED_TOKEN]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_get_tpi_signature:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
*
|
||||
* Get the 3rd party signature from @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a 3rd party signature.
|
||||
*/
|
||||
JsonNode *
|
||||
matrix_event_room_member_get_tpi_signature(MatrixEventRoomMember *matrix_event_room_member)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_member != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
return priv->_tpi_signature;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_set_tpi_signature:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
* @tpi_signature: a 3rd party signature
|
||||
*
|
||||
* Set the 3rd party signature in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_member_set_tpi_signature(MatrixEventRoomMember *matrix_event_room_member, JsonNode *tpi_signature)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_member != NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
if (priv->_tpi_signature != tpi_signature) {
|
||||
json_node_unref(priv->_tpi_signature);
|
||||
priv->_tpi_signature = json_node_ref(tpi_signature);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_member, matrix_event_room_member_properties[PROP_TPI_SIGNATURE]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_get_invite_room_state:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
* @n_invite_room_state: placeholder for the returned list, or %NULL to ignore
|
||||
*
|
||||
* Get the initial state events from @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): the list of initial state events
|
||||
*/
|
||||
MatrixEventState **
|
||||
matrix_event_room_member_get_invite_room_state(MatrixEventRoomMember *matrix_event_room_member, int *n_invite_room_state)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_val_if_fail(matrix_event_room_member != NULL, NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
if (n_invite_room_state != NULL) {
|
||||
*n_invite_room_state = priv->_invite_room_state_len;
|
||||
}
|
||||
|
||||
return priv->_invite_room_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_set_invite_room_state:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
* @invite_room_state: a list of initial state events
|
||||
* @n_invite_room_state: the length of @invite_room_state
|
||||
*
|
||||
* Set the initial state events in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_member_set_invite_room_state(MatrixEventRoomMember *matrix_event_room_member, MatrixEventState **invite_room_state, int n_invite_room_state)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv;
|
||||
|
||||
g_return_if_fail(matrix_event_room_member != NULL);
|
||||
|
||||
priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
for (gint i = 0; i < priv->_invite_room_state_len; i++) {
|
||||
g_object_unref(priv->_invite_room_state[i]);
|
||||
}
|
||||
|
||||
g_free(priv->_invite_room_state);
|
||||
|
||||
priv->_invite_room_state = g_new(MatrixEventState *, n_invite_room_state);
|
||||
|
||||
for (gint i = 0; i < n_invite_room_state; i++) {
|
||||
priv->_invite_room_state[i] = g_object_ref(invite_room_state[i]);
|
||||
}
|
||||
|
||||
priv->_invite_room_state_len = n_invite_room_state;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_get_user_id:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
*
|
||||
* Get the user ID from @event.
|
||||
*
|
||||
* The returned value is owned by @event and should not be freed.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a user ID
|
||||
*/
|
||||
const gchar *
|
||||
matrix_event_room_member_get_user_id(MatrixEventRoomMember *matrix_event_room_member)
|
||||
{
|
||||
g_return_val_if_fail(matrix_event_room_member != NULL, NULL);
|
||||
|
||||
return matrix_event_state_get_state_key(MATRIX_EVENT_STATE(matrix_event_room_member));
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_event_room_member_set_user_id:
|
||||
* @event: a #MatrixEventRoomMember
|
||||
* @user_id: a Matrix user ID
|
||||
*
|
||||
* Set the user ID in @event.
|
||||
*/
|
||||
void
|
||||
matrix_event_room_member_set_user_id(MatrixEventRoomMember *matrix_event_room_member, const gchar *user_id)
|
||||
{
|
||||
const gchar *state_key = matrix_event_state_get_state_key(MATRIX_EVENT_STATE(matrix_event_room_member));
|
||||
|
||||
if (g_strcmp0(state_key, user_id) != 0) {
|
||||
matrix_event_state_set_state_key(MATRIX_EVENT_STATE(matrix_event_room_member), user_id);
|
||||
|
||||
g_object_notify_by_pspec((GObject *)matrix_event_room_member, matrix_event_room_member_properties[PROP_USER_ID]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_member_finalize(GObject *gobject)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv = matrix_event_room_member_get_instance_private(MATRIX_EVENT_ROOM_MEMBER(gobject));
|
||||
|
||||
g_free(priv->_avatar_url);
|
||||
g_free(priv->_display_name);
|
||||
g_free(priv->_tpi_display_name);
|
||||
g_free(priv->_tpi_signed_mxid);
|
||||
g_free(priv->_tpi_signed_token);
|
||||
json_node_unref(priv->_tpi_signature);
|
||||
|
||||
for (gint i = 0; i < priv->_invite_room_state_len; i++) {
|
||||
g_object_unref(priv->_invite_room_state[i]);
|
||||
}
|
||||
|
||||
g_free(priv->_invite_room_state);
|
||||
|
||||
G_OBJECT_CLASS(matrix_event_room_member_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_member_get_property(GObject *gobject, guint property_id, GValue* value, GParamSpec* pspec)
|
||||
{
|
||||
MatrixEventRoomMember *matrix_event_room_member = MATRIX_EVENT_ROOM_MEMBER(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_MEMBERSHIP:
|
||||
g_value_set_enum(value, matrix_event_room_member_get_membership(matrix_event_room_member));
|
||||
|
||||
break;
|
||||
case PROP_AVATAR_URL:
|
||||
g_value_set_string(value, matrix_event_room_member_get_avatar_url(matrix_event_room_member));
|
||||
|
||||
break;
|
||||
case PROP_DISPLAY_NAME:
|
||||
g_value_set_string(value, matrix_event_room_member_get_display_name(matrix_event_room_member));
|
||||
|
||||
break;
|
||||
case PROP_TPI_DISPLAY_NAME:
|
||||
g_value_set_string(value, matrix_event_room_member_get_tpi_display_name(matrix_event_room_member));
|
||||
|
||||
break;
|
||||
case PROP_TPI_SIGNED_MXID:
|
||||
g_value_set_string(value, matrix_event_room_member_get_tpi_signed_mxid(matrix_event_room_member));
|
||||
|
||||
break;
|
||||
case PROP_TPI_SIGNED_TOKEN:
|
||||
g_value_set_string(value, matrix_event_room_member_get_tpi_signed_token(matrix_event_room_member));
|
||||
|
||||
break;
|
||||
case PROP_TPI_SIGNATURE:
|
||||
g_value_set_boxed(value, matrix_event_room_member_get_tpi_signature(matrix_event_room_member));
|
||||
|
||||
break;
|
||||
case PROP_USER_ID:
|
||||
g_value_set_string(value, matrix_event_room_member_get_user_id(matrix_event_room_member));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_member_set_property(GObject *gobject, guint property_id, const GValue* value, GParamSpec* pspec)
|
||||
{
|
||||
MatrixEventRoomMember * matrix_event_room_member = MATRIX_EVENT_ROOM_MEMBER(gobject);
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_MEMBERSHIP:
|
||||
matrix_event_room_member_set_membership (matrix_event_room_member, g_value_get_enum (value));
|
||||
|
||||
break;
|
||||
case PROP_AVATAR_URL:
|
||||
matrix_event_room_member_set_avatar_url (matrix_event_room_member, g_value_get_string (value));
|
||||
|
||||
break;
|
||||
case PROP_DISPLAY_NAME:
|
||||
matrix_event_room_member_set_display_name (matrix_event_room_member, g_value_get_string (value));
|
||||
|
||||
break;
|
||||
case PROP_TPI_DISPLAY_NAME:
|
||||
matrix_event_room_member_set_tpi_display_name (matrix_event_room_member, g_value_get_string (value));
|
||||
|
||||
break;
|
||||
case PROP_TPI_SIGNED_MXID:
|
||||
matrix_event_room_member_set_tpi_signed_mxid (matrix_event_room_member, g_value_get_string (value));
|
||||
|
||||
break;
|
||||
case PROP_TPI_SIGNED_TOKEN:
|
||||
matrix_event_room_member_set_tpi_signed_token (matrix_event_room_member, g_value_get_string (value));
|
||||
|
||||
break;
|
||||
case PROP_TPI_SIGNATURE:
|
||||
matrix_event_room_member_set_tpi_signature (matrix_event_room_member, g_value_get_boxed (value));
|
||||
|
||||
break;
|
||||
case PROP_USER_ID:
|
||||
matrix_event_room_member_set_user_id (matrix_event_room_member, g_value_get_string (value));
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, property_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_member_class_init (MatrixEventRoomMemberClass *klass)
|
||||
{
|
||||
((MatrixEventBaseClass *)klass)->from_json = matrix_event_room_member_real_from_json;
|
||||
((MatrixEventBaseClass *)klass)->to_json = matrix_event_room_member_real_to_json;
|
||||
G_OBJECT_CLASS(klass)->get_property = matrix_event_room_member_get_property;
|
||||
G_OBJECT_CLASS(klass)->set_property = matrix_event_room_member_set_property;
|
||||
G_OBJECT_CLASS(klass)->finalize = matrix_event_room_member_finalize;
|
||||
|
||||
/**
|
||||
* MatrixEventRoomMember:membership:
|
||||
*
|
||||
* The membership state of the user.
|
||||
*/
|
||||
matrix_event_room_member_properties[PROP_MEMBERSHIP] = g_param_spec_enum(
|
||||
"membership", "membership", "membership",
|
||||
MATRIX_TYPE_ROOM_MEMBERSHIP, MATRIX_ROOM_MEMBERSHIP_UNKNOWN,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_MEMBERSHIP, matrix_event_room_member_properties[PROP_MEMBERSHIP]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoomMember:avatar-url:
|
||||
*
|
||||
* The avatar URL for this user, if any. This is added by the homeserver.
|
||||
*/
|
||||
matrix_event_room_member_properties[PROP_AVATAR_URL] = g_param_spec_string(
|
||||
"avatar-url", "avatar-url", "avatar-url",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_AVATAR_URL, matrix_event_room_member_properties[PROP_AVATAR_URL]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoomMember:display-name:
|
||||
*
|
||||
* The display name for this user, if any. This is added by the homeserver.
|
||||
*/
|
||||
matrix_event_room_member_properties[PROP_DISPLAY_NAME] = g_param_spec_string(
|
||||
"display-name", "display-name", "display-name",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_DISPLAY_NAME, matrix_event_room_member_properties[PROP_DISPLAY_NAME]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoomMember:tpi-display-name:
|
||||
*
|
||||
* A name which can be displayed to represent the user instead of their third party identifier.
|
||||
*/
|
||||
matrix_event_room_member_properties[PROP_TPI_DISPLAY_NAME] = g_param_spec_string(
|
||||
"tpi-display-name", "tpi-display-name", "tpi-display-name",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_TPI_DISPLAY_NAME, matrix_event_room_member_properties[PROP_TPI_DISPLAY_NAME]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoomMember:tpi-signed-mxid:
|
||||
* The invited matrix user ID. Must be equal to the `user_id` property of the event.
|
||||
*/
|
||||
matrix_event_room_member_properties[PROP_TPI_SIGNED_MXID] = g_param_spec_string(
|
||||
"tpi-signed-mxid", "tpi-signed-mxid", "tpi-signed-mxid",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_TPI_SIGNED_MXID, matrix_event_room_member_properties[PROP_TPI_SIGNED_MXID]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoomMember:tpi-signed-token:
|
||||
*
|
||||
* The token property of the containing third_party_invite object.
|
||||
*/
|
||||
matrix_event_room_member_properties[PROP_TPI_SIGNED_TOKEN] = g_param_spec_string(
|
||||
"tpi-signed-token", "tpi-signed-token", "tpi-signed-token",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_TPI_SIGNED_TOKEN, matrix_event_room_member_properties[PROP_TPI_SIGNED_TOKEN]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoomMember:tpi-signature:
|
||||
*
|
||||
* A single signature from the verifying server, in the format specified by the Signing
|
||||
* Events section of the server-server API.
|
||||
*/
|
||||
matrix_event_room_member_properties[PROP_TPI_SIGNATURE] = g_param_spec_boxed(
|
||||
"tpi-signature", "tpi-signature", "tpi-signature",
|
||||
JSON_TYPE_NODE,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_TPI_SIGNATURE, matrix_event_room_member_properties[PROP_TPI_SIGNATURE]);
|
||||
|
||||
/**
|
||||
* MatrixEventRoomMember:user-id:
|
||||
*
|
||||
* The user ID whom this event relates to.
|
||||
*/
|
||||
matrix_event_room_member_properties[PROP_USER_ID] = g_param_spec_string(
|
||||
"user-id", "user-id", "user-id",
|
||||
NULL,
|
||||
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
|
||||
g_object_class_install_property(G_OBJECT_CLASS(klass), PROP_USER_ID, matrix_event_room_member_properties[PROP_USER_ID]);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_event_room_member_init(MatrixEventRoomMember *matrix_event_room_member)
|
||||
{
|
||||
MatrixEventRoomMemberPrivate *priv = matrix_event_room_member_get_instance_private(matrix_event_room_member);
|
||||
|
||||
priv->_membership = MATRIX_ROOM_MEMBERSHIP_UNKNOWN;
|
||||
priv->_avatar_url = NULL;
|
||||
priv->_display_name = NULL;
|
||||
priv->_tpi_display_name = NULL;
|
||||
priv->_tpi_signed_mxid = NULL;
|
||||
priv->_tpi_signed_token = NULL;
|
||||
priv->_tpi_signature = NULL;
|
||||
|
||||
matrix_event_room_member_set_user_id(matrix_event_room_member, NULL);
|
||||
}
|
@ -1,57 +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/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRX_GLIB_SDK_EVENT_ROOM_MEMBER_H__
|
||||
# define __MATRX_GLIB_SDK_EVENT_ROOM_MEMBER_H__
|
||||
|
||||
# include <glib-object.h>
|
||||
# include "matrix-event-state-base.h"
|
||||
# include "matrix-types.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
# define MATRIX_EVENT_TYPE_ROOM_MEMBER matrix_event_room_member_get_type()
|
||||
G_DECLARE_DERIVABLE_TYPE(MatrixEventRoomMember, matrix_event_room_member, MATRIX_EVENT, ROOM_MEMBER, MatrixEventState)
|
||||
|
||||
struct _MatrixEventRoomMemberClass {
|
||||
MatrixEventStateClass parent_class;
|
||||
};
|
||||
|
||||
MatrixEventRoomMember *matrix_event_room_member_new (void);
|
||||
MatrixRoomMembership matrix_event_room_member_get_membership (MatrixEventRoomMember *event);
|
||||
void matrix_event_room_member_set_membership (MatrixEventRoomMember *event, MatrixRoomMembership membership);
|
||||
const gchar *matrix_event_room_member_get_avatar_url (MatrixEventRoomMember *event);
|
||||
void matrix_event_room_member_set_avatar_url (MatrixEventRoomMember *event, const gchar *avatar_url);
|
||||
const gchar *matrix_event_room_member_get_display_name (MatrixEventRoomMember *event);
|
||||
void matrix_event_room_member_set_display_name (MatrixEventRoomMember *event, const gchar *display_name);
|
||||
const gchar *matrix_event_room_member_get_tpi_display_name (MatrixEventRoomMember *event);
|
||||
void matrix_event_room_member_set_tpi_display_name (MatrixEventRoomMember *event, const gchar *tpi_display_name);
|
||||
const gchar *matrix_event_room_member_get_tpi_signed_mxid (MatrixEventRoomMember *event);
|
||||
void matrix_event_room_member_set_tpi_signed_mxid (MatrixEventRoomMember *event, const gchar *tpi_signed_mxid);
|
||||
const gchar *matrix_event_room_member_get_tpi_signed_token (MatrixEventRoomMember *event);
|
||||
void matrix_event_room_member_set_tpi_signed_token (MatrixEventRoomMember *event, const gchar *tpi_signed_token);
|
||||
JsonNode *matrix_event_room_member_get_tpi_signature (MatrixEventRoomMember *event);
|
||||
void matrix_event_room_member_set_tpi_signature (MatrixEventRoomMember *event, JsonNode *tpi_signature);
|
||||
MatrixEventState **matrix_event_room_member_get_invite_room_state (MatrixEventRoomMember *event, int *n_invite_room_state);
|
||||
void matrix_event_room_member_set_invite_room_state (MatrixEventRoomMember *event, MatrixEventState **invite_room_state, int n_invite_room_state);
|
||||
const gchar *matrix_event_room_member_get_user_id (MatrixEventRoomMember *event);
|
||||
void matrix_event_room_member_set_user_id (MatrixEventRoomMember *event, const gchar *user_id);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRX_GLIB_SDK_EVENT_ROOM_MEMBER_H__ */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user