Initial commit with empty objects
This commit is contained in:
49
src/Makefile.am
Normal file
49
src/Makefile.am
Normal file
@@ -0,0 +1,49 @@
|
||||
AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Matrix-GLib\"
|
||||
|
||||
lib_LTLIBRARIES = libmatrix-glib-0.0.la
|
||||
|
||||
INST_H_SRC_FILES = \
|
||||
matrix-client.h \
|
||||
matrix-api.h \
|
||||
$(NULL)
|
||||
|
||||
INST_H_BUILT_FILES = matrix-version.h
|
||||
|
||||
libmatrix_glib_0_0_la_SOURCES = \
|
||||
matrix-client.c \
|
||||
matrix-version.c \
|
||||
matrix-api.c \
|
||||
$(INST_H_SRC_FILES) \
|
||||
$(INST_H_BUILT_FILES) \
|
||||
$(NULL)
|
||||
|
||||
libmatrix_glib_0_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) $(SOUP_CFLAGS)
|
||||
libmatrix_glib_0_0_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) $(SOUP_LIBS)
|
||||
libmatrix_glib_0_0_la_DEPENDENCIES =
|
||||
|
||||
CLEANFILES =
|
||||
EXTRA_DIST = $(INST_H_SRC_FILES)
|
||||
|
||||
include $(INTROSPECTION_MAKEFILE)
|
||||
MatrixGlib-$(MATRIX_GLIB_API_VERSION).gir: libmatrix-glib-0.0.la
|
||||
Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_FILES = $(INST_H_SRC_FILES) $(INST_H_BUILT_FILES) $(filter %.c,$(libmatrix_glib_0_0_la_SOURCES))
|
||||
Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_LIBS = libmatrix-glib-0.0.la
|
||||
Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_SCANNERFLAGS = --identifier-prefix=Matrix --symbol-prefix=matrix --warn-all
|
||||
Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_INCLUDES = GLib-2.0 GObject-2.0 Soup-2.4
|
||||
Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_CFLAGS = -D__MATRIX_GLIB_BUILDING__ -I$(top_srcdir) -I$(srcdir) -I$(builddir)
|
||||
Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_EXPORT_PACKAGES = matrix-glib
|
||||
INTROSPECTION_GIRS = Matrix-$(MATRIX_GLIB_API_VERSION).gir
|
||||
|
||||
girdir = $(datadir)/gir-1.0
|
||||
gir_DATA = Matrix-$(MATRIX_GLIB_API_VERSION).gir
|
||||
|
||||
typelibsdir = $(libdir)/girepository-1.0
|
||||
typelibs_DATA = Matrix-$(MATRIX_GLIB_API_VERSION).typelib
|
||||
|
||||
headerdir = $(includedir)/swe-glib
|
||||
header_DATA = \
|
||||
$(INST_H_SRC_FILES) \
|
||||
$(INST_H_BUILT_FILES) \
|
||||
$(NULL)
|
||||
|
||||
CLEANFILES += $(gir_DATA) $(typelibs_DATA)
|
185
src/matrix-api.c
Normal file
185
src/matrix-api.c
Normal file
@@ -0,0 +1,185 @@
|
||||
/*
|
||||
* 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-api.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <libsoup/soup.h>
|
||||
|
||||
/**
|
||||
* SECTION:matrix-api
|
||||
* @short_description: Low level API calls to communicate with a
|
||||
* Matrix.org server
|
||||
* @title: MatrixAPI
|
||||
* @stability: Unstable
|
||||
* @include: matrix-glib/matrix.h
|
||||
*
|
||||
* This is a class for low level communication with a Matrix.org
|
||||
* server.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MatrixAPI:
|
||||
*
|
||||
* The MatrixAPI object’s instance definition.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MatrixAPIClass:
|
||||
* @parent_class: the parent class structure (#GObjectClass)
|
||||
*
|
||||
* The MatrixAPI object’s class definition.
|
||||
*/
|
||||
|
||||
#define API_ENDPOINT "/_matrix/client/api/v1"
|
||||
|
||||
typedef struct _MatrixAPIPrivate {
|
||||
SoupSession *soup_session;
|
||||
guint txn_id;
|
||||
gchar *url;
|
||||
gchar *token;
|
||||
gboolean validate_cert;
|
||||
} MatrixAPIPrivate;
|
||||
|
||||
enum {
|
||||
PROP_URL = 1,
|
||||
N_PROPERTIES
|
||||
};
|
||||
|
||||
GParamSpec *obj_properties[N_PROPERTIES] = {NULL,};
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixAPI, matrix_api, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
matrix_api_finalize(GObject *gobject)
|
||||
{
|
||||
g_signal_handlers_destroy(gobject);
|
||||
G_OBJECT_CLASS(matrix_api_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_api_set_property(GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MatrixAPI *api = MATRIX_API(gobject);
|
||||
MatrixAPIPrivate *priv = matrix_api_get_instance_private(api);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_URL:
|
||||
{
|
||||
const gchar *base_url;
|
||||
gchar *last_occurence;
|
||||
|
||||
base_url = g_value_get_string(value);
|
||||
|
||||
if (!g_str_is_ascii(base_url)) {
|
||||
g_warning("URL specified (%s) is not ASCII", base_url);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
last_occurence = g_strrstr(base_url, API_ENDPOINT);
|
||||
|
||||
if ((g_strcmp0(last_occurence, API_ENDPOINT) == 0) ||
|
||||
(g_strcmp0(last_occurence, API_ENDPOINT"/") == 0)) {
|
||||
priv->url = g_strdup(base_url);
|
||||
} else {
|
||||
priv->url = g_strdup_printf(
|
||||
"%s%s%s",
|
||||
base_url,
|
||||
(base_url[strlen(base_url) - 1] == '/') ? "" : "/",
|
||||
API_ENDPOINT);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_api_get_property(GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
MatrixAPI *api = MATRIX_API(gobject);
|
||||
MatrixAPIPrivate *priv = matrix_api_get_instance_private(api);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_URL:
|
||||
g_value_set_string(value, priv->url);
|
||||
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_api_class_init(MatrixAPIClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
gobject_class->set_property = matrix_api_set_property;
|
||||
gobject_class->get_property = matrix_api_get_property;
|
||||
gobject_class->finalize = matrix_api_finalize;
|
||||
|
||||
/**
|
||||
* MatrixAPI:url:
|
||||
*
|
||||
* The base URL to use for communication with the Matrix.org
|
||||
* server.
|
||||
*/
|
||||
obj_properties[PROP_URL] = g_param_spec_string(
|
||||
"url", "Server URL",
|
||||
"Matrix.org home server to connect to.",
|
||||
NULL,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties(gobject_class,
|
||||
N_PROPERTIES,
|
||||
obj_properties);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_api_init(MatrixAPI *api)
|
||||
{
|
||||
MatrixAPIPrivate *priv = matrix_api_get_instance_private(api);
|
||||
|
||||
priv->txn_id = 0;
|
||||
priv->url = NULL;
|
||||
priv->token = NULL;
|
||||
priv->validate_cert = TRUE;
|
||||
priv->soup_session = soup_session_new_with_options(
|
||||
SOUP_SESSION_ADD_FEATURE_BY_TYPE, SOUP_TYPE_CONTENT_SNIFFER,
|
||||
NULL);
|
||||
}
|
||||
|
||||
MatrixAPI *
|
||||
matrix_api_new(const gchar *base_url, const gchar *token)
|
||||
{
|
||||
return g_object_new(MATRIX_TYPE_API,
|
||||
"base-url", base_url,
|
||||
"token", token,
|
||||
NULL);
|
||||
}
|
51
src/matrix-api.h
Normal file
51
src/matrix-api.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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_API_H__
|
||||
#define __MATRIX_API_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MATRIX_TYPE_API (matrix_api_get_type())
|
||||
#define MATRIX_API(o) (G_TYPE_CHECK_INSTANCE_CAST((o), MATRIX_TYPE_API, MatrixAPI))
|
||||
#define MATRIX_API_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MATRIX_TYPE_API, MatrixAPIClass))
|
||||
#define MATRIX_IS_API(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_TYPE_API))
|
||||
#define MATRIX_IS_API_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), MATRIX_TYPE_API))
|
||||
#define MATRIX_API_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MATRIX_TYPE_API, MatrixAPIClass))
|
||||
|
||||
typedef struct _MatrixAPI MatrixAPI;
|
||||
typedef struct _MatrixAPIClass MatrixAPIClass;
|
||||
|
||||
struct _MatrixAPI {
|
||||
/* Parent instance structure */
|
||||
GObject parent_instance;
|
||||
|
||||
/* Instance members */
|
||||
};
|
||||
|
||||
struct _MatrixAPIClass {
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType matrix_api_get_type(void) G_GNUC_CONST;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_API_H__ */
|
177
src/matrix-client.c
Normal file
177
src/matrix-client.c
Normal file
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* 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-api.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-client
|
||||
* @short_description: Base class for communication with a Matrix.org server
|
||||
* @title: MatrixClient
|
||||
* @stability: Unstable
|
||||
* @include: matrix-glib/matrix.h
|
||||
*
|
||||
* This is the base class for client communication with a Matrix.org server.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MatrixClient:
|
||||
*
|
||||
* The MatrixClient object’s instance definition.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MatrixClientClass:
|
||||
* @parent_class: the parent class structure (#GObjectClass)
|
||||
*
|
||||
* The MatrixClient object’s class definition.
|
||||
*/
|
||||
|
||||
typedef struct _MatrixClientPrivate {
|
||||
MatrixAPI *api;
|
||||
} MatrixClientPrivate;
|
||||
|
||||
G_DEFINE_TYPE_WITH_PRIVATE(MatrixClient, matrix_client, G_TYPE_OBJECT);
|
||||
|
||||
enum {
|
||||
PROP_HOMESERVER = 1,
|
||||
PROP_TOKEN,
|
||||
N_PROPERTIES
|
||||
};
|
||||
|
||||
static GParamSpec *obj_properties[N_PROPERTIES] = {NULL,};
|
||||
|
||||
static void
|
||||
matrix_client_finalize(GObject *gobject)
|
||||
{
|
||||
g_signal_handlers_destroy(gobject);
|
||||
G_OBJECT_CLASS(matrix_client_parent_class)->finalize(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_client_dispose(GObject *gobject)
|
||||
{
|
||||
MatrixClientPrivate *priv = matrix_client_get_instance_private(
|
||||
MATRIX_CLIENT(gobject));
|
||||
|
||||
g_clear_object(&priv->api);
|
||||
|
||||
G_OBJECT_CLASS(matrix_client_parent_class)->dispose(gobject);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_client_set_property(GObject *gobject,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (prop_id) {
|
||||
case PROP_HOMESERVER:
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_client_get_property(GObject *gobject,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
switch (prop_id) {
|
||||
case PROP_HOMESERVER:
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_client_class_init(MatrixClientClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
gobject_class->set_property = matrix_client_set_property;
|
||||
gobject_class->get_property = matrix_client_get_property;
|
||||
gobject_class->finalize = matrix_client_finalize;
|
||||
gobject_class->dispose = matrix_client_dispose;
|
||||
|
||||
/**
|
||||
* MatrixClient:homeserver:
|
||||
*
|
||||
* The address of the home server to connect to.
|
||||
*/
|
||||
obj_properties[PROP_HOMESERVER] = g_param_spec_string(
|
||||
"homeserver", "Home server",
|
||||
"Matrix.org home server to connect to",
|
||||
NULL,
|
||||
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* MatrixClient:token:
|
||||
*
|
||||
* The token to use for authorization.
|
||||
*/
|
||||
obj_properties[PROP_TOKEN] = g_param_spec_string(
|
||||
"token", "Token",
|
||||
"Authentication token to use",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties(gobject_class,
|
||||
N_PROPERTIES,
|
||||
obj_properties);
|
||||
}
|
||||
|
||||
static void
|
||||
matrix_client_init(MatrixClient *client)
|
||||
{
|
||||
MatrixClientPrivate *priv = matrix_client_get_instance_private(client);
|
||||
|
||||
priv->api = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* matrix_client_new:
|
||||
* @homeserver: the home server to connect to
|
||||
* @token: (allow-none): the authentication token to use
|
||||
*
|
||||
* Creates a new #MatrixClient instance for the specified home
|
||||
* server. The token, if specified, will be used for authorization
|
||||
* throughout communication with that server. The token gets
|
||||
* autogenerated by matrix_client_login_password() and
|
||||
* matrix_client_register_password(). No other communication is
|
||||
* allowed with the server before the token is set.
|
||||
*
|
||||
* Returns: (transfer full): a new #MatrixClient instance
|
||||
*/
|
||||
MatrixClient *
|
||||
matrix_client_new(const gchar *homeserver, const gchar *token)
|
||||
{
|
||||
return g_object_new(MATRIX_TYPE_CLIENT,
|
||||
"homeserver", homeserver,
|
||||
"token", token,
|
||||
NULL);
|
||||
}
|
53
src/matrix-client.h
Normal file
53
src/matrix-client.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* 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_CLIENT_H__
|
||||
#define __MATRIX_CLIENT_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define MATRIX_TYPE_CLIENT (matrix_client_get_type())
|
||||
#define MATRIX_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), MATRIX_TYPE_CLIENT, MatrixClient))
|
||||
#define MATRIX_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MATRIX_TYPE_CLIENT, MatrixClientClass))
|
||||
#define MATRIX_IS_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_TYPE_CLIENT))
|
||||
#define MATRIX_IS_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), MATRIX_TYPE_CLIENT))
|
||||
#define MATRIX_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MATRIX_TYPE_CLIENT, MatrixClientClass))
|
||||
|
||||
typedef struct _MatrixClient MatrixClient;
|
||||
typedef struct _MatrixClientClass MatrixClientClass;
|
||||
|
||||
struct _MatrixClient {
|
||||
/* Parent instance structure */
|
||||
GObject parent_instance;
|
||||
|
||||
/* Instance members */
|
||||
};
|
||||
|
||||
struct _MatrixClientClass {
|
||||
/* Parent class */
|
||||
GObjectClass parent_class;
|
||||
};
|
||||
|
||||
GType matrix_client_get_type(void) G_GNUC_CONST;
|
||||
MatrixClient *matrix_client_new(const gchar *homeserver, const gchar *token);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __MATRIX_CLIENT_H__ */
|
79
src/matrix-version.c
Normal file
79
src/matrix-version.c
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* 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-version.h"
|
||||
|
||||
/**
|
||||
* SECTION:matrix-version
|
||||
* @short_description: Matrix.org GLib SDK version information
|
||||
* @title: Version information
|
||||
* @stability: Stable
|
||||
* @include: matrix-client/matrix-client.h
|
||||
*
|
||||
* Version information for the Matrix.org GLib SDK.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MATRIX_GLIB_MAJOR_VERSION:
|
||||
*
|
||||
* The major version number of the Matrix.org GLib SDK.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MATRIX_GLIB_MINOR_VERSION:
|
||||
*
|
||||
* The minor version number of the Matrix.org GLib SDK.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MATRIX_GLIB_MICRO_VERSION:
|
||||
*
|
||||
* The micro (patch) version number of the Matrix.org GLib SDK.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MATRIX_GLIB_CHECK_VERSION:
|
||||
* @major: the major version to check for
|
||||
* @minor: the minor version to check for
|
||||
* @micro: the micro version to check for
|
||||
*
|
||||
* Checks the version number of the Matrix.org GLib SDK that is being
|
||||
* compiled against.
|
||||
*
|
||||
* Returns: TRUE if the required version is satisfied; FALSE otherwise.
|
||||
*/
|
||||
|
||||
/**
|
||||
* matrix_glib_check_version:
|
||||
* @required_major: the required major version
|
||||
* @required_minor: the required minor version
|
||||
* @required_micro: the required micro version
|
||||
*
|
||||
* Check that the Matrix.org GLib SDK in use is compatible with the
|
||||
* given version.
|
||||
*
|
||||
* Returns: TRUE if the required version is satisfied; FALSE otherwise.
|
||||
*/
|
||||
|
||||
gboolean
|
||||
matrix_glib_check_version(guint required_major,
|
||||
guint required_minor,
|
||||
guint required_micro)
|
||||
{
|
||||
return MATRIX_GLIB_CHECK_VERSION(required_major, required_minor, required_micro);
|
||||
}
|
38
src/matrix-version.h.in
Normal file
38
src/matrix-version.h.in
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of matrix-glib-sdk
|
||||
*
|
||||
* matrix-glib-sdk is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* matrix-glib-sdk is distributed in the hope that it will be
|
||||
* useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with matrix-glib-sdk. If not, see
|
||||
* <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef __MATRIX_VERSION_H__
|
||||
#define __MATRIX_VERSION_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#define MATRIX_GLIB_MAJOR_VERSION @MATRIX_GLIB_MAJOR_VERSION@
|
||||
#define MATRIX_GLIB_MINOR_VERSION @MATRIX_GLIB_MINOR_VERSION@
|
||||
#define MATRIX_GLIB_MICRO_VERSION @MATRIX_GLIB_MICRO_VERSION@
|
||||
|
||||
gboolean
|
||||
matrix_glib_check_version(guint required_major,
|
||||
guint required_minor,
|
||||
guint required_micro);
|
||||
|
||||
#define MATRIX_GLIB_CHECK_VERSION(major, minor, micro) \
|
||||
(MATRIX_GLIB_MAJOR_VERSION > (major) || \
|
||||
(MATRIX_GLIB_MAJOR_VERSION == (major) && MATRIX_GLIB_MINOR_VERSION > (minor)) || \
|
||||
(MATRIX_GLIB_MAJOR_VERSION == (major) && MATRIX_GLIB_MINOR_VERSION == (minor) && MATRIX_GLIB_MICRO_VERSION >= (micro)))
|
||||
|
||||
#endif /* __MATRIX_VERSION_H__ */
|
Reference in New Issue
Block a user