Rework MatrixClient in Vala
This commit is contained in:
parent
d5833c4cee
commit
bd4efee0cf
1
.gitignore
vendored
1
.gitignore
vendored
@ -62,3 +62,4 @@ Makefile.in
|
|||||||
/src/vala-stamp
|
/src/vala-stamp
|
||||||
/src/matrix-glib.h
|
/src/matrix-glib.h
|
||||||
/src/matrix-api.c
|
/src/matrix-api.c
|
||||||
|
/src/matrix-client.c
|
||||||
|
@ -8,7 +8,7 @@ DIE=0
|
|||||||
PKG_NAME="matrix-glib"
|
PKG_NAME="matrix-glib"
|
||||||
|
|
||||||
(test -f "$srcdir/configure.ac" \
|
(test -f "$srcdir/configure.ac" \
|
||||||
&& test -f "$srcdir/src/matrix-client.c") || {
|
&& test -f "$srcdir/src/matrix-client.vala") || {
|
||||||
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
|
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
|
||||||
echo " top-level $PKG_NAME directory"
|
echo " top-level $PKG_NAME directory"
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ lib_LTLIBRARIES = libmatrix-glib-0.0.la
|
|||||||
# Vala source files
|
# Vala source files
|
||||||
libmatrix_glib_0_0_la_VALA_SOURCES = \
|
libmatrix_glib_0_0_la_VALA_SOURCES = \
|
||||||
matrix-api.vala \
|
matrix-api.vala \
|
||||||
|
matrix-client.vala \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
AM_CPPFLAGS += \
|
AM_CPPFLAGS += \
|
||||||
@ -72,7 +73,6 @@ bin_PROGRAMS = test-api-client
|
|||||||
INST_H_SRC_FILES = \
|
INST_H_SRC_FILES = \
|
||||||
matrix-types.h \
|
matrix-types.h \
|
||||||
matrix-http-api.h \
|
matrix-http-api.h \
|
||||||
matrix-client.h \
|
|
||||||
matrix-http-client.h \
|
matrix-http-client.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
@ -87,14 +87,12 @@ matrix_enum_headers = \
|
|||||||
|
|
||||||
libmatrix_glib_0_0_la_SOURCES = \
|
libmatrix_glib_0_0_la_SOURCES = \
|
||||||
$(INST_H_BUILT_FILES) \
|
$(INST_H_BUILT_FILES) \
|
||||||
matrix-marshalers.c \
|
|
||||||
$(libmatrix_glib_0_0_la_VALA_SOURCES:.vala=.c) \
|
$(libmatrix_glib_0_0_la_VALA_SOURCES:.vala=.c) \
|
||||||
matrix-version.c \
|
matrix-version.c \
|
||||||
matrix-types.c \
|
matrix-types.c \
|
||||||
matrix-http-api.c \
|
matrix-http-api.c \
|
||||||
matrix-enumtypes.c \
|
matrix-enumtypes.c \
|
||||||
utils.c \
|
utils.c \
|
||||||
matrix-client.c \
|
|
||||||
matrix-http-client.c \
|
matrix-http-client.c \
|
||||||
$(INST_H_SRC_FILES) \
|
$(INST_H_SRC_FILES) \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
@ -121,8 +119,6 @@ $(PUBLIC_HEADER): vala-stamp
|
|||||||
BUILT_SOURCES += \
|
BUILT_SOURCES += \
|
||||||
matrix-enumtypes.c \
|
matrix-enumtypes.c \
|
||||||
matrix-enumtypes.h \
|
matrix-enumtypes.h \
|
||||||
matrix-marshalers.c \
|
|
||||||
matrix-marshalers.h \
|
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
test_api_client_SOURCES = test-api-client.c
|
test_api_client_SOURCES = test-api-client.c
|
||||||
@ -136,7 +132,6 @@ CLEANFILES += $(BUILT_SOURCES)
|
|||||||
EXTRA_DIST += \
|
EXTRA_DIST += \
|
||||||
matrix-enumtypes.h.template \
|
matrix-enumtypes.h.template \
|
||||||
matrix-enumtypes.c.template \
|
matrix-enumtypes.c.template \
|
||||||
matrix-marshalers.list \
|
|
||||||
$(INST_H_SRC_FILES) \
|
$(INST_H_SRC_FILES) \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
@ -150,29 +145,6 @@ matrix-enumtypes.c: $(matrix_enum_headers) matrix-enumtypes.h matrix-enumtypes.c
|
|||||||
$(filter-out %.template,$^) > $@.tmp \
|
$(filter-out %.template,$^) > $@.tmp \
|
||||||
&& mv $@.tmp $@
|
&& mv $@.tmp $@
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
include $(INTROSPECTION_MAKEFILE)
|
include $(INTROSPECTION_MAKEFILE)
|
||||||
Matrix-0.0.gir: libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la
|
Matrix-0.0.gir: libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la
|
||||||
|
|
||||||
|
@ -1,198 +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: Base interface for communication with a Matrix.org server
|
|
||||||
* @title: MatrixClient
|
|
||||||
* @stability: Unstable
|
|
||||||
* @include: matrix-glib/matrix-client.h
|
|
||||||
*
|
|
||||||
* This is the base interface for client communication with a
|
|
||||||
* Matrix.org server.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MatrixClientInterface:
|
|
||||||
* @login_finished: signal is a sign of a finished login request
|
|
||||||
* @login_with_password: virtual function for
|
|
||||||
* matrix_client_login_with_password()
|
|
||||||
* @register_with_password: virtual function for
|
|
||||||
* matrix_client_register_with_password()
|
|
||||||
* @logout: virtual function for matrix_client_logout()
|
|
||||||
* @begin_polling: virtual function for matrix_client_begin_polling()
|
|
||||||
* @stop_polling: virtual function for matrix_client_stop_polling()
|
|
||||||
*
|
|
||||||
* The interface vtable for #MatrixClient
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MatrixClient:
|
|
||||||
*
|
|
||||||
* The MatrixClient object’s interface definition.
|
|
||||||
*/
|
|
||||||
|
|
||||||
G_DEFINE_INTERFACE(MatrixClient, matrix_client, G_TYPE_OBJECT);
|
|
||||||
|
|
||||||
static void
|
|
||||||
matrix_client_default_init(MatrixClientInterface *iface)
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* MatrixClient::login-finished:
|
|
||||||
* @client: a #MatrixClient
|
|
||||||
* @success: if %TRUE, login was successful
|
|
||||||
*
|
|
||||||
* This signal is a sign for a finished login request.
|
|
||||||
*
|
|
||||||
* Implementations of #MatrixClient are responsible for emitting
|
|
||||||
* this signal when they get a response for a login request.
|
|
||||||
*
|
|
||||||
* matrix_client_login_finished() is a convenience function for
|
|
||||||
* emitting #MatrixClient::login-finished.
|
|
||||||
*/
|
|
||||||
g_signal_new("login-finished",
|
|
||||||
MATRIX_TYPE_CLIENT,
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET(MatrixClientInterface, login_finished),
|
|
||||||
NULL, NULL, _matrix_marshal_VOID__BOOLEAN,
|
|
||||||
G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* matrix_client_login_with_password:
|
|
||||||
* @client: a #MatrixClient
|
|
||||||
* @username: the username to login with
|
|
||||||
* @password: the password to use
|
|
||||||
* @error: a location for a #GError, or %NULL
|
|
||||||
*
|
|
||||||
* Authenticate with the Matrix.org server with a username and
|
|
||||||
* password.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
matrix_client_login_with_password(MatrixClient *client,
|
|
||||||
const gchar *username,
|
|
||||||
const gchar *password,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
g_return_if_fail(MATRIX_IS_CLIENT(client));
|
|
||||||
|
|
||||||
MATRIX_CLIENT_GET_IFACE(client)
|
|
||||||
->login_with_password(client, username, password, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* matrix_client_register_with_password:
|
|
||||||
* @client: a #MatrixClient
|
|
||||||
* @username: (allow-none): the username to register. If omitted, the
|
|
||||||
* server will generate one
|
|
||||||
* @password: the password to use with the registration
|
|
||||||
* @error: a location for a #GError, or %NULL
|
|
||||||
*
|
|
||||||
* Register @username with the homeserver as a normal user.
|
|
||||||
*
|
|
||||||
* Upon success, the user is registered and authenticated.
|
|
||||||
*
|
|
||||||
* Implementations of #MatrixClient must emit
|
|
||||||
* MatrixClient::login-finished when a response arrives.
|
|
||||||
*
|
|
||||||
* If you want to register a different kind of user, use
|
|
||||||
* matrix_api_register_account().
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
matrix_client_register_with_password(MatrixClient *client,
|
|
||||||
const gchar *username,
|
|
||||||
const gchar *password,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
g_return_if_fail(MATRIX_IS_CLIENT(client));
|
|
||||||
|
|
||||||
MATRIX_CLIENT_GET_IFACE(client)
|
|
||||||
->register_with_password(client, username, password, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* matrix_client_logout:
|
|
||||||
* @client: a #MatrixClient
|
|
||||||
* @error: a location for a #GError, or %NULL
|
|
||||||
*
|
|
||||||
* Logout from the homeserver. As Matrix.org doesn’t have such an
|
|
||||||
* option, this cancels all ongoing requests and clears the
|
|
||||||
* authentication data (e.g. tokens).
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
matrix_client_logout(MatrixClient *client, GError **error)
|
|
||||||
{
|
|
||||||
g_return_if_fail(MATRIX_IS_CLIENT(client));
|
|
||||||
|
|
||||||
MATRIX_CLIENT_GET_IFACE(client)
|
|
||||||
->logout(client, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* matrix_client_begin_polling:
|
|
||||||
* @client: a #MatrixClient
|
|
||||||
* @error: a location for a #GError, or %NULL
|
|
||||||
*
|
|
||||||
* Begin polling the event stream.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
matrix_client_begin_polling(MatrixClient *client, GError **error)
|
|
||||||
{
|
|
||||||
g_return_if_fail(MATRIX_IS_CLIENT(client));
|
|
||||||
|
|
||||||
MATRIX_CLIENT_GET_IFACE(client)
|
|
||||||
->begin_polling(client, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* matrix_client_stop_polling:
|
|
||||||
* @client: a #MatrixClient
|
|
||||||
* @cancel_ongoing: if %TRUE, ongoing requests will be cancelled, too
|
|
||||||
* @error: a location for a #GError, or %NULL
|
|
||||||
*
|
|
||||||
* Stop polling the event stream. If @cancel_ongoing is %TRUE, ongoing
|
|
||||||
* requests will be cancelled, too.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
matrix_client_stop_polling(MatrixClient *client,
|
|
||||||
gboolean cancel_ongoing,
|
|
||||||
GError **error)
|
|
||||||
{
|
|
||||||
g_return_if_fail(MATRIX_IS_CLIENT(client));
|
|
||||||
|
|
||||||
MATRIX_CLIENT_GET_IFACE(client)
|
|
||||||
->stop_polling(client, cancel_ongoing, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* matrix_client_login_finished:
|
|
||||||
* @client: a #MatrixClient
|
|
||||||
* @success: if %TRUE, login was successful
|
|
||||||
*
|
|
||||||
* Emits the #MatrixClient::login-finished signal.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
matrix_client_login_finished(MatrixClient *client, gboolean success)
|
|
||||||
{
|
|
||||||
g_return_if_fail(MATRIX_IS_CLIENT(client));
|
|
||||||
|
|
||||||
g_signal_emit_by_name(client, "login-finished", success);
|
|
||||||
}
|
|
@ -1,87 +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_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_IS_CLIENT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_TYPE_CLIENT))
|
|
||||||
#define MATRIX_CLIENT_GET_IFACE(o) (G_TYPE_INSTANCE_GET_INTERFACE((o), MATRIX_TYPE_CLIENT, MatrixClientInterface))
|
|
||||||
|
|
||||||
typedef struct _MatrixClientInterface MatrixClientInterface;
|
|
||||||
typedef struct _MatrixClient MatrixClient;
|
|
||||||
|
|
||||||
struct _MatrixClientInterface {
|
|
||||||
/*< private >*/
|
|
||||||
/* Parent instance structure */
|
|
||||||
GTypeInterface g_iface;
|
|
||||||
|
|
||||||
/*< public >*/
|
|
||||||
/* Instance members */
|
|
||||||
|
|
||||||
/* Virtual table */
|
|
||||||
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);
|
|
||||||
|
|
||||||
void (*login_finished)(MatrixClient *client, gboolean success);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _MatrixClientClass {
|
|
||||||
/* Parent class */
|
|
||||||
GObjectClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
GType matrix_client_get_type(void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
void matrix_client_login_finished(MatrixClient *client, gboolean success);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __MATRIX_CLIENT_H__ */
|
|
106
src/matrix-client.vala
Normal file
106
src/matrix-client.vala
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
/*
|
||||||
|
* 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)
|
||||||
|
{}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
@ -45,7 +45,7 @@ typedef struct _MatrixHTTPClientPrivate {
|
|||||||
guint event_timeout;
|
guint event_timeout;
|
||||||
} MatrixHTTPClientPrivate;
|
} MatrixHTTPClientPrivate;
|
||||||
|
|
||||||
static void matrix_http_client_matrix_client_init(MatrixClientInterface *iface);
|
static void matrix_http_client_matrix_client_init(MatrixClientIface *iface);
|
||||||
static void i_begin_polling(MatrixClient *client, GError **error);
|
static void i_begin_polling(MatrixClient *client, GError **error);
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_CODE(MatrixHTTPClient, matrix_http_client, MATRIX_TYPE_HTTP_API,
|
G_DEFINE_TYPE_WITH_CODE(MatrixHTTPClient, matrix_http_client, MATRIX_TYPE_HTTP_API,
|
||||||
@ -61,7 +61,7 @@ cb_login(MatrixAPI *api,
|
|||||||
GError *error,
|
GError *error,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
matrix_client_login_finished(MATRIX_CLIENT(api), (error == NULL));
|
matrix_client_emit_login_finished(MATRIX_CLIENT(api), (error == NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -100,7 +100,7 @@ cb_register_account(MatrixAPI *api,
|
|||||||
GError *error,
|
GError *error,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
matrix_client_login_finished(MATRIX_CLIENT(api), (error == NULL));
|
matrix_client_emit_login_finished(MATRIX_CLIENT(api), (error == NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -211,7 +211,7 @@ i_stop_polling(MatrixClient *client, gboolean cancel_ongoing, GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
matrix_http_client_matrix_client_init(MatrixClientInterface *iface)
|
matrix_http_client_matrix_client_init(MatrixClientIface *iface)
|
||||||
{
|
{
|
||||||
iface->login_with_password = i_login_with_password;
|
iface->login_with_password = i_login_with_password;
|
||||||
iface->register_with_password = i_register_with_password;
|
iface->register_with_password = i_register_with_password;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define __MATRIX_HTTP_CLIENT_H__
|
#define __MATRIX_HTTP_CLIENT_H__
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include "matrix-client.h"
|
#include "matrix-glib.h"
|
||||||
#include "matrix-http-api.h"
|
#include "matrix-http-api.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
@ -1 +0,0 @@
|
|||||||
VOID:BOOLEAN
|
|
Loading…
Reference in New Issue
Block a user