From 18c1fe6ed8adf7c6f2b7cdbbc560404324da9fd3 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sat, 23 May 2020 17:28:33 +0200 Subject: [PATCH] keyfile: merge NMKeyfile{Read,Write}Type as NMKeyfileHandlerType This will become public API. The enum for read and write callback serves very similar purposes. Merge them so that we have fewer types in the public API. --- shared/nm-keyfile/nm-keyfile-internal.h | 21 ++++++++----------- shared/nm-keyfile/nm-keyfile.c | 4 ++-- .../plugins/keyfile/nms-keyfile-reader.c | 4 ++-- .../plugins/keyfile/nms-keyfile-writer.c | 4 ++-- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/shared/nm-keyfile/nm-keyfile-internal.h b/shared/nm-keyfile/nm-keyfile-internal.h index 42003a5f5f..2aef0d53e6 100644 --- a/shared/nm-keyfile/nm-keyfile-internal.h +++ b/shared/nm-keyfile/nm-keyfile-internal.h @@ -32,8 +32,9 @@ char *nm_keyfile_detect_unqualified_path_scheme (const char *base_dir, gboolean *out_exists); typedef enum { - NM_KEYFILE_READ_TYPE_WARN = 1, -} NMKeyfileReadType; + NM_KEYFILE_HANDLER_TYPE_WARN = 1, + NM_KEYFILE_HANDLER_TYPE_WRITE_CERT = 2, +} NMKeyfileHandlerType; /** * NMKeyfileReadHandler: @@ -43,11 +44,11 @@ typedef enum { * * Returns: should return TRUE, if the reading was handled. Otherwise, * a default action will be performed that depends on the @type. - * For %NM_KEYFILE_READ_TYPE_WARN type, the default action is doing nothing. + * For %NM_KEYFILE_HANDLER_TYPE_WARN type, the default action is doing nothing. */ typedef gboolean (*NMKeyfileReadHandler) (GKeyFile *keyfile, NMConnection *connection, - NMKeyfileReadType type, + NMKeyfileHandlerType type, void *type_data, void *user_data, GError **error); @@ -63,7 +64,7 @@ typedef enum { * NMKeyfileReadTypeDataWarn: * * this struct is passed as @type_data for the @NMKeyfileReadHandler of - * type %NM_KEYFILE_READ_TYPE_WARN. + * type %NM_KEYFILE_HANDLER_TYPE_WARN. */ typedef struct { /* might be %NULL, if the warning is not about a group. */ @@ -93,10 +94,6 @@ gboolean nm_keyfile_read_ensure_uuid (NMConnection *connection, /*****************************************************************************/ -typedef enum { - NM_KEYFILE_WRITE_TYPE_CERT = 1, -} NMKeyfileWriteType; - /** * NMKeyfileWriteHandler: * @@ -106,7 +103,7 @@ typedef enum { * within the keyfile or that might be serialized differently. The @type and * @type_data arguments tell which kind of argument we have at hand. * - * Currently only the type %NM_KEYFILE_WRITE_TYPE_CERT is supported, which provides + * Currently only the type %NM_KEYFILE_HANDLER_TYPE_WRITE_CERT is supported, which provides * @type_data as %NMKeyfileWriteTypeDataCert. However, this handler should be generic enough * to support other types as well. * @@ -122,7 +119,7 @@ typedef enum { */ typedef gboolean (*NMKeyfileWriteHandler) (NMConnection *connection, GKeyFile *keyfile, - NMKeyfileWriteType type, + NMKeyfileHandlerType type, void *type_data, void *user_data, GError **error); @@ -131,7 +128,7 @@ typedef gboolean (*NMKeyfileWriteHandler) (NMConnection *connection, * NMKeyfileWriteTypeDataCert: * * this struct is passed as @type_data for the @NMKeyfileWriteHandler of - * type %NM_KEYFILE_WRITE_TYPE_CERT. + * type %NM_KEYFILE_HANDLER_TYPE_WRITE_CERT. */ typedef struct { const NMSetting8021xSchemeVtable *vtable; diff --git a/shared/nm-keyfile/nm-keyfile.c b/shared/nm-keyfile/nm-keyfile.c index 63a6bf9343..3797717e66 100644 --- a/shared/nm-keyfile/nm-keyfile.c +++ b/shared/nm-keyfile/nm-keyfile.c @@ -65,7 +65,7 @@ _handle_warn (KeyfileReaderInfo *info, info->handler (info->keyfile, info->connection, - NM_KEYFILE_READ_TYPE_WARN, + NM_KEYFILE_HANDLER_TYPE_WARN, &type_data, info->user_data, &info->error); @@ -2434,7 +2434,7 @@ cert_writer (KeyfileWriterInfo *info, if (info->handler) { if (info->handler (info->connection, info->keyfile, - NM_KEYFILE_WRITE_TYPE_CERT, + NM_KEYFILE_HANDLER_TYPE_WRITE_CERT, &type_data, info->user_data, &info->error)) diff --git a/src/settings/plugins/keyfile/nms-keyfile-reader.c b/src/settings/plugins/keyfile/nms-keyfile-reader.c index e8c9f9fe2a..c4b12b8e0c 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-reader.c +++ b/src/settings/plugins/keyfile/nms-keyfile-reader.c @@ -48,14 +48,14 @@ typedef struct { static gboolean _handler_read (GKeyFile *keyfile, NMConnection *connection, - NMKeyfileReadType type, + NMKeyfileHandlerType type, void *type_data, void *user_data, GError **error) { const HandlerReadData *handler_data = user_data; - if (type == NM_KEYFILE_READ_TYPE_WARN) { + if (type == NM_KEYFILE_HANDLER_TYPE_WARN) { NMKeyfileReadTypeDataWarn *warn_data = type_data; NMLogLevel level; char *message_free = NULL; diff --git a/src/settings/plugins/keyfile/nms-keyfile-writer.c b/src/settings/plugins/keyfile/nms-keyfile-writer.c index 7554becc24..4859dd157a 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-writer.c +++ b/src/settings/plugins/keyfile/nms-keyfile-writer.c @@ -146,12 +146,12 @@ cert_writer (NMConnection *connection, static gboolean _handler_write (NMConnection *connection, GKeyFile *keyfile, - NMKeyfileWriteType type, + NMKeyfileHandlerType type, void *type_data, void *user_data, GError **error) { - if (type == NM_KEYFILE_WRITE_TYPE_CERT) { + if (type == NM_KEYFILE_HANDLER_TYPE_WRITE_CERT) { cert_writer (connection, keyfile, (NMKeyfileWriteTypeDataCert *) type_data, (WriteInfo *) user_data, error);