Add the MatrixClient::login-finished signal

This commit is contained in:
Gergely Polonkai 2016-01-22 11:40:12 +01:00
parent ad265c310d
commit 19a5ab01a0
7 changed files with 65 additions and 3 deletions

1
.gitignore vendored
View File

@ -34,6 +34,7 @@ Makefile.in
/GTAGS
/src/matrix-version.h
/src/matrix-enumtypes.[ch]
/src/matrix-marshalers.[ch]
/docs/reference/matrix-glib/version.xml
/docs/reference/matrix-glib/html/
/docs/reference/matrix-glib/xml/

View File

@ -51,6 +51,7 @@ GOBJECT_INTROSPECTION_CHECK([1.0])
PKG_PROG_PKG_CONFIG
AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums])
AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal])
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.38])
PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.38])

View File

@ -3,6 +3,7 @@
<TITLE>MatrixClient</TITLE>
MatrixClient
MatrixClientInterface
matrix_client_login_finished
matrix_client_register_with_password
matrix_client_login_with_password
matrix_client_logout

View File

@ -4,10 +4,10 @@ lib_LTLIBRARIES = libmatrix-glib-0.0.la
bin_PROGRAMS = test-api-client
INST_H_SRC_FILES = \
matrix-client.h \
matrix-api.h \
matrix-api-types.h \
matrix-http-api.h \
matrix-client.h \
$(NULL)
INST_H_BUILT_FILES = \
@ -21,13 +21,14 @@ matrix_enum_headers = \
$(NULL)
libmatrix_glib_0_0_la_SOURCES = \
matrix-client.c \
matrix-version.c \
matrix-api.c \
matrix-api-types.c \
matrix-http-api.c \
matrix-enumtypes.c \
utils.c \
matrix-marshalers.c \
matrix-client.c \
$(INST_H_SRC_FILES) \
$(INST_H_BUILT_FILES) \
$(NULL)
@ -36,7 +37,12 @@ libmatrix_glib_0_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) $(SOUP_CFLAGS) $
libmatrix_glib_0_0_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) $(SOUP_LIBS) $(JSON_LIBS)
libmatrix_glib_0_0_la_DEPENDENCIES =
BUILT_SOURCES = matrix-enumtypes.c matrix-enumtypes.h
BUILT_SOURCES = \
matrix-enumtypes.c \
matrix-enumtypes.h \
matrix-marshalers.c \
matrix-marshalers.h \
$(NULL)
test_api_client_SOURCES = test-api-client.c $(libmatrix_glib_0_0_la_SOURCES)
test_api_client_CFLAGS = $(libmatrix_glib_0_0_la_CFLAGS)
@ -46,6 +52,7 @@ CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = \
matrix-enumtypes.h.template \
matrix-enumtypes.c.template \
matrix-marshalers.list \
$(INST_H_SRC_FILES) \
$(NULL)
@ -57,6 +64,17 @@ matrix-enumtypes.c: $(matrix_enum_headers) matrix-enumtypes.h matrix-enumtypes.c
$(AM_V_GEN) $(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > $@.tmp \
&& mv $@.tmp $@
matrix-marshalers.h: 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
matrix-marshalers.c: matrix-marshalers.list
$(AM_V_GEN) (echo "#include \"matrix-marshalers.h\""; \
$(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)
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))

View File

@ -17,6 +17,7 @@
*/
#include "matrix-client.h"
#include "matrix-marshalers.h"
/**
* SECTION:matrix-client
@ -31,6 +32,7 @@
/**
* 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
@ -53,6 +55,25 @@ 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);
}
/**
@ -160,3 +181,18 @@ matrix_client_stop_polling(MatrixClient *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);
}

View File

@ -54,6 +54,8 @@ struct _MatrixClientInterface {
void (*stop_polling)(MatrixClient *client,
gboolean cancel_ongoing,
GError **error);
void (*login_finished)(MatrixClient *client, gboolean success);
};
struct _MatrixClientClass {
@ -63,6 +65,8 @@ struct _MatrixClientClass {
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,

View File

@ -0,0 +1 @@
VOID:BOOLEAN