Rename g_enum_to_string to _g_enum_to_string
This is to avoid name clashes and exclude it from introspection and documentation.
This commit is contained in:
parent
372e989ee2
commit
ad265c310d
@ -192,7 +192,6 @@ MATRIX_TYPE_API_PUSHER
|
|||||||
matrix_api_pusher_get_type
|
matrix_api_pusher_get_type
|
||||||
MATRIX_TYPE_API_STATE_EVENT
|
MATRIX_TYPE_API_STATE_EVENT
|
||||||
matrix_api_state_event_get_type
|
matrix_api_state_event_get_type
|
||||||
g_enum_to_string
|
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
<SECTION>
|
<SECTION>
|
||||||
|
@ -43,6 +43,11 @@
|
|||||||
* is not a JSON object
|
* is not a JSON object
|
||||||
* @MATRIX_API_ERROR_INVALID_ROOM_ID: the provided string doesn’t
|
* @MATRIX_API_ERROR_INVALID_ROOM_ID: the provided string doesn’t
|
||||||
* contain a valid room ID
|
* contain a valid room ID
|
||||||
|
* @MATRIX_API_ERROR_UNKNOWN_VALUE: the response from the Matrix.org
|
||||||
|
* server contains a value unknown to
|
||||||
|
* this library. These should be
|
||||||
|
* reported to the Matrix GLib SDK
|
||||||
|
* developers
|
||||||
* @MATRIX_API_ERROR_MISSING_TOKEN: authorization token is missing
|
* @MATRIX_API_ERROR_MISSING_TOKEN: authorization token is missing
|
||||||
* from the request
|
* from the request
|
||||||
* @MATRIX_API_ERROR_FORBIDDEN: access was forbidden (e.g. due to a
|
* @MATRIX_API_ERROR_FORBIDDEN: access was forbidden (e.g. due to a
|
||||||
@ -1561,7 +1566,7 @@ matrix_api_filter_get_json_node(MatrixAPIFilter *filter)
|
|||||||
|
|
||||||
json_builder_set_member_name(builder, "event_format");
|
json_builder_set_member_name(builder, "event_format");
|
||||||
json_builder_add_string_value(builder,
|
json_builder_add_string_value(builder,
|
||||||
g_enum_to_string(
|
_g_enum_to_string(
|
||||||
MATRIX_TYPE_API_EVENT_FORMAT,
|
MATRIX_TYPE_API_EVENT_FORMAT,
|
||||||
filter->event_format,
|
filter->event_format,
|
||||||
TRUE));
|
TRUE));
|
||||||
|
@ -31,6 +31,7 @@ typedef enum {
|
|||||||
MATRIX_API_ERROR_BAD_REQUEST,
|
MATRIX_API_ERROR_BAD_REQUEST,
|
||||||
MATRIX_API_ERROR_BAD_RESPONSE,
|
MATRIX_API_ERROR_BAD_RESPONSE,
|
||||||
MATRIX_API_ERROR_INVALID_ROOM_ID,
|
MATRIX_API_ERROR_INVALID_ROOM_ID,
|
||||||
|
MATRIX_API_ERROR_UNKNOWN_VALUE,
|
||||||
|
|
||||||
/* Add Matrix-defined error codes under here, changing `M_` to
|
/* Add Matrix-defined error codes under here, changing `M_` to
|
||||||
* `MATRIX_API_ERROR`, i.e. `M_FORBIDDEN` =>
|
* `MATRIX_API_ERROR`, i.e. `M_FORBIDDEN` =>
|
||||||
|
@ -971,7 +971,7 @@ i_create_room(MatrixAPI *api,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (preset != MATRIX_API_ROOM_PRESET_NONE) {
|
if (preset != MATRIX_API_ROOM_PRESET_NONE) {
|
||||||
gchar *preset_string = g_enum_to_string(
|
gchar *preset_string = _g_enum_to_string(
|
||||||
MATRIX_TYPE_API_ROOM_PRESET, preset, TRUE);
|
MATRIX_TYPE_API_ROOM_PRESET, preset, TRUE);
|
||||||
|
|
||||||
if (preset_string) {
|
if (preset_string) {
|
||||||
@ -994,7 +994,7 @@ i_create_room(MatrixAPI *api,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (visibility != MATRIX_API_ROOM_VISIBILITY_DEFAULT) {
|
if (visibility != MATRIX_API_ROOM_VISIBILITY_DEFAULT) {
|
||||||
gchar *visibility_string = g_enum_to_string(
|
gchar *visibility_string = _g_enum_to_string(
|
||||||
MATRIX_TYPE_API_ROOM_VISIBILITY, visibility, TRUE);
|
MATRIX_TYPE_API_ROOM_VISIBILITY, visibility, TRUE);
|
||||||
|
|
||||||
if (visibility_string) {
|
if (visibility_string) {
|
||||||
@ -1348,7 +1348,7 @@ i_set_user_presence(MatrixAPI *api,
|
|||||||
json_builder_begin_object(builder);
|
json_builder_begin_object(builder);
|
||||||
|
|
||||||
json_builder_set_member_name(builder, "presence");
|
json_builder_set_member_name(builder, "presence");
|
||||||
presence_string = g_enum_to_string(MATRIX_TYPE_API_PRESENCE, presence, TRUE);
|
presence_string = _g_enum_to_string(MATRIX_TYPE_API_PRESENCE, presence, TRUE);
|
||||||
json_builder_add_string_value(builder, presence_string);
|
json_builder_add_string_value(builder, presence_string);
|
||||||
g_free(presence_string);
|
g_free(presence_string);
|
||||||
|
|
||||||
@ -1416,7 +1416,7 @@ i_delete_pusher(MatrixAPI *api,
|
|||||||
|
|
||||||
encoded_scope = soup_uri_encode(scope, NULL);
|
encoded_scope = soup_uri_encode(scope, NULL);
|
||||||
encoded_rule_id = soup_uri_encode(rule_id, NULL);
|
encoded_rule_id = soup_uri_encode(rule_id, NULL);
|
||||||
kind_string = g_enum_to_string(MATRIX_TYPE_API_PUSHER_KIND, kind, TRUE);
|
kind_string = _g_enum_to_string(MATRIX_TYPE_API_PUSHER_KIND, kind, TRUE);
|
||||||
|
|
||||||
path = g_strdup_printf("pushrules/%s/%s/%s",
|
path = g_strdup_printf("pushrules/%s/%s/%s",
|
||||||
encoded_scope,
|
encoded_scope,
|
||||||
@ -1448,7 +1448,7 @@ i_get_pusher(MatrixAPI *api,
|
|||||||
|
|
||||||
encoded_scope = soup_uri_encode(scope, NULL);
|
encoded_scope = soup_uri_encode(scope, NULL);
|
||||||
encoded_rule_id = soup_uri_encode(rule_id, NULL);
|
encoded_rule_id = soup_uri_encode(rule_id, NULL);
|
||||||
kind_string = g_enum_to_string(MATRIX_TYPE_API_PUSHER_KIND, kind, TRUE);
|
kind_string = _g_enum_to_string(MATRIX_TYPE_API_PUSHER_KIND, kind, TRUE);
|
||||||
|
|
||||||
path = g_strdup_printf("pushrules/%s/%s/%s",
|
path = g_strdup_printf("pushrules/%s/%s/%s",
|
||||||
encoded_scope,
|
encoded_scope,
|
||||||
@ -1471,7 +1471,7 @@ static void
|
|||||||
add_condition_kind_object(MatrixAPIPusherConditionKind kind,
|
add_condition_kind_object(MatrixAPIPusherConditionKind kind,
|
||||||
JsonBuilder *builder)
|
JsonBuilder *builder)
|
||||||
{
|
{
|
||||||
gchar *kind_string = g_enum_to_string(
|
gchar *kind_string = _g_enum_to_string(
|
||||||
MATRIX_TYPE_API_PUSHER_CONDITION_KIND, kind, TRUE);
|
MATRIX_TYPE_API_PUSHER_CONDITION_KIND, kind, TRUE);
|
||||||
|
|
||||||
if (!kind_string) {
|
if (!kind_string) {
|
||||||
@ -1507,7 +1507,7 @@ static void i_add_pusher(MatrixAPI *api,
|
|||||||
|
|
||||||
encoded_scope = soup_uri_encode(scope, NULL);
|
encoded_scope = soup_uri_encode(scope, NULL);
|
||||||
encoded_rule_id = soup_uri_encode(rule_id, NULL);
|
encoded_rule_id = soup_uri_encode(rule_id, NULL);
|
||||||
kind_string = g_enum_to_string(MATRIX_TYPE_API_PUSHER_KIND, kind, TRUE);
|
kind_string = _g_enum_to_string(MATRIX_TYPE_API_PUSHER_KIND, kind, TRUE);
|
||||||
|
|
||||||
path = g_strdup_printf("pushrules/%s/%s/%s",
|
path = g_strdup_printf("pushrules/%s/%s/%s",
|
||||||
encoded_scope,
|
encoded_scope,
|
||||||
@ -1571,7 +1571,7 @@ i_toggle_pusher(MatrixAPI *api,
|
|||||||
|
|
||||||
encoded_scope = soup_uri_encode(scope, NULL);
|
encoded_scope = soup_uri_encode(scope, NULL);
|
||||||
encoded_rule_id = soup_uri_encode(rule_id, NULL);
|
encoded_rule_id = soup_uri_encode(rule_id, NULL);
|
||||||
kind_string = g_enum_to_string(MATRIX_TYPE_API_PUSHER_KIND, kind, TRUE);
|
kind_string = _g_enum_to_string(MATRIX_TYPE_API_PUSHER_KIND, kind, TRUE);
|
||||||
|
|
||||||
path = g_strdup_printf("pushrules/%s/%s/%s",
|
path = g_strdup_printf("pushrules/%s/%s/%s",
|
||||||
encoded_scope,
|
encoded_scope,
|
||||||
@ -1955,7 +1955,7 @@ i_send_event_receipt(MatrixAPI *api,
|
|||||||
|
|
||||||
encoded_room_id = soup_uri_encode(room_id, NULL);
|
encoded_room_id = soup_uri_encode(room_id, NULL);
|
||||||
encoded_event_id = soup_uri_encode(event_id, NULL);
|
encoded_event_id = soup_uri_encode(event_id, NULL);
|
||||||
receipt_type_string = g_enum_to_string(MATRIX_TYPE_API_RECEIPT_TYPE,
|
receipt_type_string = _g_enum_to_string(MATRIX_TYPE_API_RECEIPT_TYPE,
|
||||||
receipt_type,
|
receipt_type,
|
||||||
TRUE);
|
TRUE);
|
||||||
path = g_strdup_printf("rooms/%s/receipt/%s/%s",
|
path = g_strdup_printf("rooms/%s/receipt/%s/%s",
|
||||||
@ -2605,7 +2605,7 @@ i_register_account(MatrixAPI *api,
|
|||||||
g_object_unref(builder);
|
g_object_unref(builder);
|
||||||
|
|
||||||
if (account_kind != MATRIX_API_ACCOUNT_KIND_DEFAULT) {
|
if (account_kind != MATRIX_API_ACCOUNT_KIND_DEFAULT) {
|
||||||
gchar *kind_string = g_enum_to_string(MATRIX_TYPE_API_ACCOUNT_KIND,
|
gchar *kind_string = _g_enum_to_string(MATRIX_TYPE_API_ACCOUNT_KIND,
|
||||||
account_kind, TRUE);
|
account_kind, TRUE);
|
||||||
|
|
||||||
params = create_query_params();
|
params = create_query_params();
|
||||||
|
13
src/utils.c
13
src/utils.c
@ -18,19 +18,8 @@
|
|||||||
|
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
/**
|
|
||||||
* g_enum_to_string: (skip)
|
|
||||||
* @type: a #GEnumType
|
|
||||||
* @value: a value from @type
|
|
||||||
* @convert_dashes: convert dashes to underscores
|
|
||||||
*
|
|
||||||
* Get the value nick for @value, optionally converting dashes to
|
|
||||||
* underscores.
|
|
||||||
*
|
|
||||||
* Returns: (transfer full): :the value nick
|
|
||||||
*/
|
|
||||||
gchar *
|
gchar *
|
||||||
g_enum_to_string(GType enum_type, gint value, gboolean convert_dashes)
|
_g_enum_to_string(GType enum_type, gint value, gboolean convert_dashes)
|
||||||
{
|
{
|
||||||
GEnumClass *enum_class = g_type_class_ref(enum_type);
|
GEnumClass *enum_class = g_type_class_ref(enum_type);
|
||||||
GEnumValue *enum_value = g_enum_get_value(enum_class, value);
|
GEnumValue *enum_value = g_enum_get_value(enum_class, value);
|
||||||
|
@ -22,6 +22,6 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
|
|
||||||
gchar *g_enum_to_string(GType enum_type, gint value, gboolean convert_dash);
|
gchar *_g_enum_to_string(GType enum_type, gint value, gboolean convert_dash);
|
||||||
|
|
||||||
#endif /* __MATRIX_UTILS_H__ */
|
#endif /* __MATRIX_UTILS_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user