diff --git a/docs/reference/matrix-glib/matrix-glib-docs.xml b/docs/reference/matrix-glib/matrix-glib-docs.xml index 658e1c1..b4884d1 100644 --- a/docs/reference/matrix-glib/matrix-glib-docs.xml +++ b/docs/reference/matrix-glib/matrix-glib-docs.xml @@ -20,6 +20,7 @@ Matrix Client + diff --git a/docs/reference/matrix-glib/matrix-glib-sections.txt b/docs/reference/matrix-glib/matrix-glib-sections.txt index 2d86c82..96c68e0 100644 --- a/docs/reference/matrix-glib/matrix-glib-sections.txt +++ b/docs/reference/matrix-glib/matrix-glib-sections.txt @@ -17,6 +17,23 @@ MATRIX_TYPE_CLIENT matrix_client_get_type +
+matrix-http-client +MatrixHTTPClient +MatrixHTTPClient +matrix_http_client_new + + +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 +
+
matrix-types Fundamental types for the Matrix GLib SDK diff --git a/src/Makefile.am b/src/Makefile.am index 387b8b6..41fa410 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -8,6 +8,7 @@ INST_H_SRC_FILES = \ matrix-api.h \ matrix-http-api.h \ matrix-client.h \ + matrix-http-client.h \ $(NULL) INST_H_BUILT_FILES = \ @@ -29,6 +30,7 @@ libmatrix_glib_0_0_la_SOURCES = \ utils.c \ matrix-marshalers.c \ matrix-client.c \ + matrix-http-client.c \ $(INST_H_SRC_FILES) \ $(INST_H_BUILT_FILES) \ $(NULL) diff --git a/src/matrix-http-client.c b/src/matrix-http-client.c new file mode 100644 index 0000000..ac7ee36 --- /dev/null +++ b/src/matrix-http-client.c @@ -0,0 +1,94 @@ +/* + * 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 + * . + */ + +#include "matrix-http-client.h" + +/** + * SECTION:matrix-http-client + * @short_description: A HTTP based Matrix.org client + * @title: MatrixHTTPClient + * @stability: Unstable + * + * An event-driven client class to communicate with HTTP based + * Matrix.org servers. + */ + +/** + * MatrixHTTPClient: + * + * The client instance definition. + */ + +/** + * MatrixHTTPClientClass: + * + * Class definition for #MatrixHTTPClient. + */ + +enum { + PROP_BASE_URL = 1, + PROP_VALIDATE_CERTIFICATE, + N_PROPERTIES +}; + +static GParamSpec *obj_properties[N_PROPERTIES] = {NULL,}; + +static void matrix_http_client_matrix_client_init(MatrixClientInterface *iface); + +G_DEFINE_TYPE_WITH_CODE(MatrixHTTPClient, matrix_http_client, MATRIX_TYPE_HTTP_API, + G_IMPLEMENT_INTERFACE(MATRIX_TYPE_CLIENT, + matrix_http_client_matrix_client_init)); + +static void +matrix_http_client_matrix_client_init(MatrixClientInterface *iface) +{ + iface->login_with_password = NULL; + iface->register_with_password = NULL; + iface->logout = NULL; + iface->begin_polling = NULL; + iface->stop_polling = NULL; +} + +static void +matrix_http_client_init(MatrixHTTPClient *client) +{} + +static void +matrix_http_client_class_init(MatrixHTTPClientClass *klass) +{} + +/** + * matrix_http_client_new: + * @base_url: the base URL to use for API communication + * + * Creates a new #MatrixHTTPClient object. + * + * Returns: (transfer full): a new #MatrixHTTPClient. The object is + * cast to #MatrixClient for easier interface usage. + */ +MatrixClient * +matrix_http_client_new(const gchar *base_url) +{ + MatrixHTTPClient *client; + + client = g_object_new(MATRIX_TYPE_HTTP_CLIENT, + "base-url", base_url, + NULL); + + return MATRIX_CLIENT(client); +} diff --git a/src/matrix-http-client.h b/src/matrix-http-client.h new file mode 100644 index 0000000..c9f793a --- /dev/null +++ b/src/matrix-http-client.h @@ -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 + * . + */ + +#ifndef __MATRIX_HTTP_CLIENT_H__ +#define __MATRIX_HTTP_CLIENT_H__ + +#include +#include "matrix-client.h" +#include "matrix-http-api.h" + +G_BEGIN_DECLS + +#define MATRIX_TYPE_HTTP_CLIENT (matrix_http_client_get_type()) +#define MATRIX_HTTP_CLIENT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), MATRIX_TYPE_HTTP_CLIENT, MatrixHTTPClient)) +#define MATRIX_HTTP_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MATRIX_TYPE_HTTP_CLIENT, MatrixHTTPClientClass)) +#define MATRIX_IS_HTTP_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_TYPE_HTTP_CLIENT)) +#define MATRIX_IS_HTTP_CLIENT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), MATRIX_TYPE_HTTP_CLIENT)) +#define MATRIX_HTTP_CLIENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), MATRIX_TYPE_HTTP_CLIENT, MatrixHTTPClientClass)) + +typedef struct _MatrixHTTPClient MatrixHTTPClient; +typedef struct _MatrixHTTPClientClass MatrixHTTPClientClass; + +struct _MatrixHTTPClient { + GObject parent_instance; +}; + +struct _MatrixHTTPClientClass { + GObjectClass parent_class; +}; + +GType matrix_http_client_get_type(void) G_GNUC_CONST; + +MatrixClient *matrix_http_client_new(const gchar *base_url); + +G_END_DECLS + +#endif /* __MATRIX_HTTP_CLIENT_H__ */