Add our own error quark
This commit is contained in:
parent
444161ec1b
commit
9552136059
1
.gitignore
vendored
1
.gitignore
vendored
@ -33,6 +33,7 @@ Makefile.in
|
||||
/GSYMS
|
||||
/GTAGS
|
||||
/src/matrix-version.h
|
||||
/src/matrix-enumtypes.[ch]
|
||||
/docs/reference/matrix-glib/version.xml
|
||||
/docs/reference/matrix-glib/html/
|
||||
/docs/reference/matrix-glib/xml/
|
||||
|
@ -40,15 +40,22 @@ matrix_api_send_message
|
||||
matrix_api_send_message_event
|
||||
matrix_api_send_state_event
|
||||
matrix_api_set_membership
|
||||
<SUBSECTION>
|
||||
MatrixAPIError
|
||||
MATRIX_API_ERROR
|
||||
<SUBSECTION Standard>
|
||||
MatrixAPI
|
||||
MatrixAPIInterface
|
||||
MATRIX_TYPE_API_ERROR
|
||||
matrix_api_error_get_type
|
||||
MATRIX_TYPE_API
|
||||
MATRIX_API
|
||||
MATRIX_IS_API
|
||||
MATRIX_API_GET_IFACE
|
||||
MatrixApiPrivate
|
||||
matrix_api_get_type
|
||||
<SUBSECTION Private>
|
||||
matrix_api_error_quark
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
|
@ -9,13 +9,19 @@ INST_H_SRC_FILES = \
|
||||
matrix-http-api.h \
|
||||
$(NULL)
|
||||
|
||||
INST_H_BUILT_FILES = matrix-version.h
|
||||
INST_H_BUILT_FILES = \
|
||||
matrix-version.h \
|
||||
matrix-enumtypes.h \
|
||||
$(NULL)
|
||||
|
||||
matrix_enum_headers = matrix-api.h
|
||||
|
||||
libmatrix_glib_0_0_la_SOURCES = \
|
||||
matrix-client.c \
|
||||
matrix-version.c \
|
||||
matrix-api.c \
|
||||
matrix-http-api.c \
|
||||
matrix-enumtypes.c \
|
||||
$(INST_H_SRC_FILES) \
|
||||
$(INST_H_BUILT_FILES) \
|
||||
$(NULL)
|
||||
@ -24,12 +30,26 @@ 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
|
||||
|
||||
test_client_SOURCES = test-client.c $(libmatrix_glib_0_0_la_SOURCES)
|
||||
test_client_CFLAGS = $(libmatrix_glib_0_0_la_CFLAGS)
|
||||
test_client_LDADD = $(libmatrix_glib_0_0_la_LIBADD)
|
||||
|
||||
CLEANFILES =
|
||||
EXTRA_DIST = $(INST_H_SRC_FILES)
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
EXTRA_DIST = \
|
||||
matrix-enumtypes.h.template \
|
||||
matrix-enumtypes.c.template \
|
||||
$(INST_H_SRC_FILES) \
|
||||
$(NULL)
|
||||
|
||||
matrix-enumtypes.h: $(matrix_enum_headers) matrix-enumtypes.h.template
|
||||
$(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
|
||||
$@.tmp && mv $@.tmp $@
|
||||
|
||||
matrix-enumtypes.c: $(matrix_enum_headers) matrix-enumtypes.h matrix-enumtypes.c.template
|
||||
$(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > \
|
||||
$@.tmp && mv $@.tmp $@
|
||||
|
||||
include $(INTROSPECTION_MAKEFILE)
|
||||
MatrixGlib-$(MATRIX_GLIB_API_VERSION).gir: libmatrix-glib-0.0.la
|
||||
|
@ -75,6 +75,36 @@
|
||||
* A callback function to use with API calls.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MatrixAPIError:
|
||||
* @MATRIX_API_ERROR_NONE: no error
|
||||
* @MATRIX_API_ERROR_MISSING_TOKEN: authorization token is missing
|
||||
* from the request
|
||||
* @MATRIX_API_ERROR_FORBIDDEN: access was forbidden (e.g. due to a
|
||||
* missing/invalid token, or using a bad
|
||||
* password during login)
|
||||
* @MATRIX_API_ERROR_UNKNOWN: an error unknown to the Matrix server
|
||||
* @MATRIX_API_ERROR_UNKNOWN_ERROR: an error unknown to this library
|
||||
*
|
||||
* Value mappings from Matrix.org API error codes
|
||||
* (e.g. <code>M_MISSING_TOKEN</code>). They should be set
|
||||
* automatically by API calls, if the response contains an error code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* MATRIX_API_ERROR:
|
||||
*
|
||||
* Error domain for Matrix GLib SDK API. See #GError for more
|
||||
* information on error domains.
|
||||
*/
|
||||
|
||||
/**
|
||||
* matrix_api_error_quark:
|
||||
*
|
||||
* Gets the Matrix API error #GQuark
|
||||
*/
|
||||
G_DEFINE_QUARK(matrix-api-error-quark, matrix_api_error);
|
||||
|
||||
G_DEFINE_INTERFACE(MatrixAPI, matrix_api, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
|
@ -24,6 +24,19 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef enum {
|
||||
MATRIX_API_ERROR_NONE,
|
||||
MATRIX_API_ERROR_MISSING_TOKEN,
|
||||
MATRIX_API_ERROR_FORBIDDEN,
|
||||
MATRIX_API_ERROR_UNKNOWN,
|
||||
/* Allow for a lot of Matrix.org defined codes
|
||||
Do not define error codes after this! */
|
||||
MATRIX_API_ERROR_UNKNOWN_ERROR = 16384
|
||||
} MatrixAPIError;
|
||||
|
||||
#define MATRIX_API_ERROR matrix_api_error_quark()
|
||||
GQuark matrix_api_error_quark(void);
|
||||
|
||||
#define MATRIX_TYPE_API (matrix_api_get_type())
|
||||
#define MATRIX_API(o) (G_TYPE_CHECK_INSTANCE_CAST((o), MATRIX_TYPE_API, MatrixAPI))
|
||||
#define MATRIX_IS_API(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), MATRIX_TYPE_API))
|
||||
|
59
src/matrix-enumtypes.c.template
Normal file
59
src/matrix-enumtypes.c.template
Normal file
@ -0,0 +1,59 @@
|
||||
/*** BEGIN file-header ***/
|
||||
/*
|
||||
* 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-enumtypes.h"
|
||||
/*** END file-header ***/
|
||||
|
||||
/*** BEGIN file-production ***/
|
||||
|
||||
/* enumerations from @filename@ */
|
||||
/*** END file-production ***/
|
||||
|
||||
/*** BEGIN value-header ***/
|
||||
|
||||
GType
|
||||
@enum_name@_get_type(void)
|
||||
{
|
||||
static volatile gsize g_define_type_id__volatile = 0;
|
||||
|
||||
if (g_once_init_enter(&g_define_type_id__volatile)) {
|
||||
static const G@Type@Value values[] = {
|
||||
/*** END value-header ***/
|
||||
|
||||
/*** BEGIN value-production ***/
|
||||
{
|
||||
@VALUENAME@,
|
||||
"@VALUENAME@",
|
||||
"@valuenick@"
|
||||
},
|
||||
/*** END value-production ***/
|
||||
|
||||
/*** BEGIN value-tail ***/
|
||||
{0, NULL, NULL}
|
||||
};
|
||||
|
||||
GType g_define_type_id = g_@type@_register_static(
|
||||
g_intern_static_string("@EnumName@"),
|
||||
values);
|
||||
g_once_init_leave(&g_define_type_id__volatile, g_define_type_id);
|
||||
}
|
||||
|
||||
return g_define_type_id__volatile;
|
||||
}
|
||||
/*** END value-tail ***/
|
42
src/matrix-enumtypes.h.template
Normal file
42
src/matrix-enumtypes.h.template
Normal file
@ -0,0 +1,42 @@
|
||||
/*** BEGIN file-header ***/
|
||||
/*
|
||||
* 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_ENUMTYPES_H__
|
||||
#define __MATRIX_ENUMTYPES_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
/*** END file-header ***/
|
||||
|
||||
/*** BEGIN file-production ***/
|
||||
/* enumerations from "@filename@" */
|
||||
|
||||
#include "@filename@"
|
||||
/*** END file-production ***/
|
||||
|
||||
/*** BEGIN value-header ***/
|
||||
|
||||
GType @enum_name@_get_type(void);
|
||||
#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
|
||||
/*** END value-header ***/
|
||||
|
||||
/*** BEGIN file-tail ***/
|
||||
|
||||
#endif /* __MATRIX_ENUMTYPES_H__ */
|
||||
/*** END file-tail ***/
|
Loading…
Reference in New Issue
Block a user