diff options
author | Thomas Haller <thaller@redhat.com> | 2016-10-05 18:12:23 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-10-06 20:41:20 +0200 |
commit | 5d80a8a78b6764656dfa03e1c8af17d7f77b6dce (patch) | |
tree | 7e72ddb8683056e2a4b48899715934650a626a21 | |
parent | 93c8381965890eb388a5d576cf36f12209b09471 (diff) | |
download | NetworkManager-5d80a8a78b6764656dfa03e1c8af17d7f77b6dce.tar.gz |
keyfile: rename public keyfile functions and names
-rw-r--r-- | src/settings/nm-settings.c | 2 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/nms-keyfile-connection.c | 60 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/nms-keyfile-connection.h | 30 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/nms-keyfile-plugin.c | 136 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/nms-keyfile-plugin.h | 26 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/nms-keyfile-reader.c | 2 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/nms-keyfile-reader.h | 8 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/nms-keyfile-utils.c | 6 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/nms-keyfile-utils.h | 29 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/nms-keyfile-writer.c | 28 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/nms-keyfile-writer.h | 26 | ||||
-rw-r--r-- | src/settings/plugins/keyfile/tests/test-keyfile.c | 68 |
12 files changed, 210 insertions, 211 deletions
diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c index 229e252440..6e52b2db3e 100644 --- a/src/settings/nm-settings.c +++ b/src/settings/nm-settings.c @@ -800,7 +800,7 @@ add_keyfile_plugin (NMSettings *self) { gs_unref_object GObject *keyfile_plugin = NULL; - keyfile_plugin = nm_settings_keyfile_plugin_new (); + keyfile_plugin = nms_keyfile_plugin_new (); g_assert (keyfile_plugin); if (!add_plugin (self, NM_SETTINGS_PLUGIN (keyfile_plugin))) g_return_if_reached (); diff --git a/src/settings/plugins/keyfile/nms-keyfile-connection.c b/src/settings/plugins/keyfile/nms-keyfile-connection.c index 1cda3c0edd..0a80073a8f 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-connection.c +++ b/src/settings/plugins/keyfile/nms-keyfile-connection.c @@ -36,12 +36,12 @@ #include "nms-keyfile-writer.h" #include "nms-keyfile-utils.h" -G_DEFINE_TYPE (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SETTINGS_CONNECTION) +G_DEFINE_TYPE (NMSKeyfileConnection, nms_keyfile_connection, NM_TYPE_SETTINGS_CONNECTION) -NMKeyfileConnection * -nm_keyfile_connection_new (NMConnection *source, - const char *full_path, - GError **error) +NMSKeyfileConnection * +nms_keyfile_connection_new (NMConnection *source, + const char *full_path, + GError **error) { GObject *object; NMConnection *tmp; @@ -54,7 +54,7 @@ nm_keyfile_connection_new (NMConnection *source, if (source) tmp = g_object_ref (source); else { - tmp = nm_keyfile_plugin_connection_from_file (full_path, error); + tmp = nms_keyfile_reader_from_file (full_path, error); if (!tmp) return NULL; @@ -70,7 +70,7 @@ nm_keyfile_connection_new (NMConnection *source, update_unsaved = FALSE; } - object = (GObject *) g_object_new (NM_TYPE_KEYFILE_CONNECTION, + object = (GObject *) g_object_new (NMS_TYPE_KEYFILE_CONNECTION, NM_SETTINGS_CONNECTION_FILENAME, full_path, NULL); @@ -85,7 +85,7 @@ nm_keyfile_connection_new (NMConnection *source, } g_object_unref (tmp); - return (NMKeyfileConnection *) object; + return (NMSKeyfileConnection *) object; } static void @@ -97,12 +97,12 @@ commit_changes (NMSettingsConnection *connection, char *path = NULL; GError *error = NULL; - if (!nm_keyfile_plugin_write_connection (NM_CONNECTION (connection), - nm_settings_connection_get_filename (connection), - NM_FLAGS_ALL (commit_reason, NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION - | NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED), - &path, - &error)) { + if (!nms_keyfile_writer_connection (NM_CONNECTION (connection), + nm_settings_connection_get_filename (connection), + NM_FLAGS_ALL (commit_reason, NM_SETTINGS_CONNECTION_COMMIT_REASON_USER_ACTION + | NM_SETTINGS_CONNECTION_COMMIT_REASON_ID_CHANGED), + &path, + &error)) { callback (connection, error, user_data); g_clear_error (&error); return; @@ -115,27 +115,27 @@ commit_changes (NMSettingsConnection *connection, nm_settings_connection_set_filename (connection, path); if (old_path) { - nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" and rename from \"%s\"", - NM_KEYFILE_CONNECTION_LOG_ARG (connection), + nm_log_info (LOGD_SETTINGS, "keyfile: update "NMS_KEYFILE_CONNECTION_LOG_FMT" and rename from \"%s\"", + NMS_KEYFILE_CONNECTION_LOG_ARG (connection), old_path); } else { - nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" and persist connection", - NM_KEYFILE_CONNECTION_LOG_ARG (connection)); + nm_log_info (LOGD_SETTINGS, "keyfile: update "NMS_KEYFILE_CONNECTION_LOG_FMT" and persist connection", + NMS_KEYFILE_CONNECTION_LOG_ARG (connection)); } } else { - nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT, - NM_KEYFILE_CONNECTION_LOG_ARG (connection)); + nm_log_info (LOGD_SETTINGS, "keyfile: update "NMS_KEYFILE_CONNECTION_LOG_FMT, + NMS_KEYFILE_CONNECTION_LOG_ARG (connection)); } g_free (path); - NM_SETTINGS_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->commit_changes (connection, - commit_reason, - callback, - user_data); + NM_SETTINGS_CONNECTION_CLASS (nms_keyfile_connection_parent_class)->commit_changes (connection, + commit_reason, + callback, + user_data); } -static void +static void do_delete (NMSettingsConnection *connection, NMSettingsConnectionDeleteFunc callback, gpointer user_data) @@ -146,20 +146,20 @@ do_delete (NMSettingsConnection *connection, if (path) g_unlink (path); - NM_SETTINGS_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->delete (connection, - callback, - user_data); + NM_SETTINGS_CONNECTION_CLASS (nms_keyfile_connection_parent_class)->delete (connection, + callback, + user_data); } /* GObject */ static void -nm_keyfile_connection_init (NMKeyfileConnection *connection) +nms_keyfile_connection_init (NMSKeyfileConnection *connection) { } static void -nm_keyfile_connection_class_init (NMKeyfileConnectionClass *keyfile_connection_class) +nms_keyfile_connection_class_init (NMSKeyfileConnectionClass *keyfile_connection_class) { NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (keyfile_connection_class); diff --git a/src/settings/plugins/keyfile/nms-keyfile-connection.h b/src/settings/plugins/keyfile/nms-keyfile-connection.h index 31dbe754a8..95f503dc1a 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-connection.h +++ b/src/settings/plugins/keyfile/nms-keyfile-connection.h @@ -19,30 +19,30 @@ * Copyright (C) 2008 - 2012 Red Hat, Inc. */ -#ifndef __NETWORKMANAGER_KEYFILE_CONNECTION_H__ -#define __NETWORKMANAGER_KEYFILE_CONNECTION_H__ +#ifndef __NMS_KEYFILE_CONNECTION_H__ +#define __NMS_KEYFILE_CONNECTION_H__ #include <nm-settings-connection.h> -#define NM_TYPE_KEYFILE_CONNECTION (nm_keyfile_connection_get_type ()) -#define NM_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnection)) -#define NM_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnectionClass)) -#define NM_IS_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_KEYFILE_CONNECTION)) -#define NM_IS_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_KEYFILE_CONNECTION)) -#define NM_KEYFILE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnectionClass)) +#define NMS_TYPE_KEYFILE_CONNECTION (nms_keyfile_connection_get_type ()) +#define NMS_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_KEYFILE_CONNECTION, NMSKeyfileConnection)) +#define NMS_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_KEYFILE_CONNECTION, NMSKeyfileConnectionClass)) +#define NMS_IS_KEYFILE_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_KEYFILE_CONNECTION)) +#define NMS_IS_KEYFILE_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_KEYFILE_CONNECTION)) +#define NMS_KEYFILE_CONNECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_KEYFILE_CONNECTION, NMSKeyfileConnectionClass)) typedef struct { NMSettingsConnection parent; -} NMKeyfileConnection; +} NMSKeyfileConnection; typedef struct { NMSettingsConnectionClass parent; -} NMKeyfileConnectionClass; +} NMSKeyfileConnectionClass; -GType nm_keyfile_connection_get_type (void); +GType nms_keyfile_connection_get_type (void); -NMKeyfileConnection *nm_keyfile_connection_new (NMConnection *source, - const char *filename, - GError **error); +NMSKeyfileConnection *nms_keyfile_connection_new (NMConnection *source, + const char *filename, + GError **error); -#endif /* __NETWORKMANAGER_KEYFILE_CONNECTION_H__ */ +#endif /* __NMS_KEYFILE_CONNECTION_H__ */ diff --git a/src/settings/plugins/keyfile/nms-keyfile-plugin.c b/src/settings/plugins/keyfile/nms-keyfile-plugin.c index 94c7e81e9f..e3414bb5a5 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-plugin.c +++ b/src/settings/plugins/keyfile/nms-keyfile-plugin.c @@ -53,49 +53,49 @@ typedef struct { gulong monitor_id; NMConfig *config; -} SettingsPluginKeyfilePrivate; +} NMSKeyfilePluginPrivate; -struct _SettingsPluginKeyfile { +struct _NMSKeyfilePlugin { GObject parent; - SettingsPluginKeyfilePrivate _priv; + NMSKeyfilePluginPrivate _priv; }; -struct _SettingsPluginKeyfileClass { +struct _NMSKeyfilePluginClass { GObjectClass parent; }; static void settings_plugin_interface_init (NMSettingsPluginInterface *plugin_iface); -G_DEFINE_TYPE_EXTENDED (SettingsPluginKeyfile, settings_plugin_keyfile, G_TYPE_OBJECT, 0, +G_DEFINE_TYPE_EXTENDED (NMSKeyfilePlugin, nms_keyfile_plugin, G_TYPE_OBJECT, 0, G_IMPLEMENT_INTERFACE (NM_TYPE_SETTINGS_PLUGIN, settings_plugin_interface_init)) -#define SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE(self) _NM_GET_PRIVATE (self, SettingsPluginKeyfile, SETTINGS_IS_PLUGIN_KEYFILE) +#define NMS_KEYFILE_PLUGIN_GET_PRIVATE(self) _NM_GET_PRIVATE (self, NMSKeyfilePlugin, NMS_IS_KEYFILE_PLUGIN) /*****************************************************************************/ static void connection_removed_cb (NMSettingsConnection *obj, gpointer user_data) { - g_hash_table_remove (SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) user_data)->connections, + g_hash_table_remove (NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) user_data)->connections, nm_connection_get_uuid (NM_CONNECTION (obj))); } /* Monitoring */ static void -remove_connection (SettingsPluginKeyfile *self, NMKeyfileConnection *connection) +remove_connection (NMSKeyfilePlugin *self, NMSKeyfileConnection *connection) { gboolean removed; g_return_if_fail (connection != NULL); - nm_log_info (LOGD_SETTINGS, "keyfile: removed " NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection)); + nm_log_info (LOGD_SETTINGS, "keyfile: removed " NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection)); /* Removing from the hash table should drop the last reference */ g_object_ref (connection); g_signal_handlers_disconnect_by_func (connection, connection_removed_cb, self); - removed = g_hash_table_remove (SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self)->connections, + removed = g_hash_table_remove (NMS_KEYFILE_PLUGIN_GET_PRIVATE (self)->connections, nm_connection_get_uuid (NM_CONNECTION (connection))); nm_settings_connection_signal_remove (NM_SETTINGS_CONNECTION (connection)); g_object_unref (connection); @@ -103,10 +103,10 @@ remove_connection (SettingsPluginKeyfile *self, NMKeyfileConnection *connection) g_return_if_fail (removed); } -static NMKeyfileConnection * -find_by_path (SettingsPluginKeyfile *self, const char *path) +static NMSKeyfileConnection * +find_by_path (NMSKeyfilePlugin *self, const char *path) { - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (self); GHashTableIter iter; NMSettingsConnection *candidate = NULL; @@ -115,7 +115,7 @@ find_by_path (SettingsPluginKeyfile *self, const char *path) g_hash_table_iter_init (&iter, priv->connections); while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) { if (g_strcmp0 (path, nm_settings_connection_get_filename (candidate)) == 0) - return NM_KEYFILE_CONNECTION (candidate); + return NMS_KEYFILE_CONNECTION (candidate); } return NULL; } @@ -151,18 +151,18 @@ find_by_path (SettingsPluginKeyfile *self, const char *path) * * Returns: the updated connection. * */ -static NMKeyfileConnection * -update_connection (SettingsPluginKeyfile *self, +static NMSKeyfileConnection * +update_connection (NMSKeyfilePlugin *self, NMConnection *source, const char *full_path, - NMKeyfileConnection *connection, + NMSKeyfileConnection *connection, gboolean protect_existing_connection, GHashTable *protected_connections, GError **error) { - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); - NMKeyfileConnection *connection_new; - NMKeyfileConnection *connection_by_uuid; + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (self); + NMSKeyfileConnection *connection_new; + NMSKeyfileConnection *connection_by_uuid; GError *local = NULL; const char *uuid; @@ -172,7 +172,7 @@ update_connection (SettingsPluginKeyfile *self, if (full_path) nm_log_dbg (LOGD_SETTINGS, "keyfile: loading from file \"%s\"...", full_path); - connection_new = nm_keyfile_connection_new (source, full_path, &local); + connection_new = nms_keyfile_connection_new (source, full_path, &local); if (!connection_new) { /* Error; remove the connection */ if (source) @@ -195,12 +195,12 @@ update_connection (SettingsPluginKeyfile *self, if ( (protect_existing_connection && connection_by_uuid != NULL) || (protected_connections && g_hash_table_contains (protected_connections, connection))) { - NMKeyfileConnection *conflicting = (protect_existing_connection && connection_by_uuid != NULL) ? connection_by_uuid : connection; + NMSKeyfileConnection *conflicting = (protect_existing_connection && connection_by_uuid != NULL) ? connection_by_uuid : connection; if (source) - nm_log_warn (LOGD_SETTINGS, "keyfile: cannot update protected "NM_KEYFILE_CONNECTION_LOG_FMT" connection due to conflicting UUID %s", NM_KEYFILE_CONNECTION_LOG_ARG (conflicting), uuid); + nm_log_warn (LOGD_SETTINGS, "keyfile: cannot update protected "NMS_KEYFILE_CONNECTION_LOG_FMT" connection due to conflicting UUID %s", NMS_KEYFILE_CONNECTION_LOG_ARG (conflicting), uuid); else - nm_log_warn (LOGD_SETTINGS, "keyfile: cannot load %s due to conflicting UUID for "NM_KEYFILE_CONNECTION_LOG_FMT, full_path, NM_KEYFILE_CONNECTION_LOG_ARG (conflicting)); + nm_log_warn (LOGD_SETTINGS, "keyfile: cannot load %s due to conflicting UUID for "NMS_KEYFILE_CONNECTION_LOG_FMT, full_path, NMS_KEYFILE_CONNECTION_LOG_ARG (conflicting)); g_object_unref (connection_new); g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Cannot update protected connection due to conflicting UUID"); @@ -216,9 +216,9 @@ update_connection (SettingsPluginKeyfile *self, && ( (!connection && protect_existing_connection) || (protected_connections && g_hash_table_contains (protected_connections, connection_by_uuid)))) { if (source) - nm_log_warn (LOGD_SETTINGS, "keyfile: cannot update connection due to conflicting UUID for "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid)); + nm_log_warn (LOGD_SETTINGS, "keyfile: cannot update connection due to conflicting UUID for "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid)); else - nm_log_warn (LOGD_SETTINGS, "keyfile: cannot load %s due to conflicting UUID for "NM_KEYFILE_CONNECTION_LOG_FMT, full_path, NM_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid)); + nm_log_warn (LOGD_SETTINGS, "keyfile: cannot load %s due to conflicting UUID for "NMS_KEYFILE_CONNECTION_LOG_FMT, full_path, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_by_uuid)); g_object_unref (connection_new); g_set_error_literal (error, NM_SETTINGS_ERROR, NM_SETTINGS_ERROR_FAILED, "Skip updating protected connection during reload"); @@ -236,17 +236,17 @@ update_connection (SettingsPluginKeyfile *self, NM_SETTING_COMPARE_FLAG_IGNORE_NOT_SAVED_SECRETS)) { /* Nothing to do... except updating the path. */ if (old_path && g_strcmp0 (old_path, full_path) != 0) - nm_log_info (LOGD_SETTINGS, "keyfile: rename \"%s\" to "NM_KEYFILE_CONNECTION_LOG_FMT" without other changes", old_path, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + nm_log_info (LOGD_SETTINGS, "keyfile: rename \"%s\" to "NMS_KEYFILE_CONNECTION_LOG_FMT" without other changes", old_path, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); } else { /* An existing connection changed. */ if (source) - nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT" from %s", NM_KEYFILE_CONNECTION_LOG_ARG (connection_new), NM_KEYFILE_CONNECTION_LOG_PATH (old_path)); + nm_log_info (LOGD_SETTINGS, "keyfile: update "NMS_KEYFILE_CONNECTION_LOG_FMT" from %s", NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new), NMS_KEYFILE_CONNECTION_LOG_PATH (old_path)); else if (!g_strcmp0 (old_path, nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection_new)))) - nm_log_info (LOGD_SETTINGS, "keyfile: update "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + nm_log_info (LOGD_SETTINGS, "keyfile: update "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); else if (old_path) - nm_log_info (LOGD_SETTINGS, "keyfile: rename \"%s\" to "NM_KEYFILE_CONNECTION_LOG_FMT, old_path, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + nm_log_info (LOGD_SETTINGS, "keyfile: rename \"%s\" to "NMS_KEYFILE_CONNECTION_LOG_FMT, old_path, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); else - nm_log_info (LOGD_SETTINGS, "keyfile: update and persist "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + nm_log_info (LOGD_SETTINGS, "keyfile: update and persist "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection_by_uuid), NM_CONNECTION (connection_new), @@ -264,9 +264,9 @@ update_connection (SettingsPluginKeyfile *self, return connection_by_uuid; } else { if (source) - nm_log_info (LOGD_SETTINGS, "keyfile: add connection "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + nm_log_info (LOGD_SETTINGS, "keyfile: add connection "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); else - nm_log_info (LOGD_SETTINGS, "keyfile: new connection "NM_KEYFILE_CONNECTION_LOG_FMT, NM_KEYFILE_CONNECTION_LOG_ARG (connection_new)); + nm_log_info (LOGD_SETTINGS, "keyfile: new connection "NMS_KEYFILE_CONNECTION_LOG_FMT, NMS_KEYFILE_CONNECTION_LOG_ARG (connection_new)); g_hash_table_insert (priv->connections, g_strdup (uuid), connection_new); g_signal_connect (connection_new, NM_SETTINGS_CONNECTION_REMOVED, @@ -290,13 +290,13 @@ dir_changed (GFileMonitor *monitor, gpointer user_data) { NMSettingsPlugin *config = NM_SETTINGS_PLUGIN (user_data); - SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); - NMKeyfileConnection *connection; + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN (config); + NMSKeyfileConnection *connection; char *full_path; gboolean exists; full_path = g_file_get_path (file); - if (nm_keyfile_plugin_utils_should_ignore_file (full_path)) { + if (nms_keyfile_utils_should_ignore_file (full_path)) { g_free (full_path); return; } @@ -309,12 +309,12 @@ dir_changed (GFileMonitor *monitor, switch (event_type) { case G_FILE_MONITOR_EVENT_DELETED: if (!exists && connection) - remove_connection (SETTINGS_PLUGIN_KEYFILE (config), connection); + remove_connection (NMS_KEYFILE_PLUGIN (config), connection); break; case G_FILE_MONITOR_EVENT_CREATED: case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: if (exists) - update_connection (SETTINGS_PLUGIN_KEYFILE (config), NULL, full_path, connection, TRUE, NULL, NULL); + update_connection (NMS_KEYFILE_PLUGIN (config), NULL, full_path, connection, TRUE, NULL, NULL); break; default: break; @@ -328,7 +328,7 @@ config_changed_cb (NMConfig *config, NMConfigData *config_data, NMConfigChangeFlags changes, NMConfigData *old_data, - SettingsPluginKeyfile *self) + NMSKeyfilePlugin *self) { gs_free char *old_value = NULL, *new_value = NULL; @@ -342,12 +342,12 @@ config_changed_cb (NMConfig *config, static void setup_monitoring (NMSettingsPlugin *config) { - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) config); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) config); GFile *file; GFileMonitor *monitor; if (nm_config_get_monitor_connection_files (nm_config_get ())) { - file = g_file_new_for_path (nm_keyfile_plugin_get_path ()); + file = g_file_new_for_path (nms_keyfile_utils_get_path ()); monitor = g_file_monitor_directory (file, G_FILE_MONITOR_NONE, NULL, NULL); g_object_unref (file); @@ -367,7 +367,7 @@ static GHashTable * _paths_from_connections (GHashTable *connections) { GHashTableIter iter; - NMKeyfileConnection *connection; + NMSKeyfileConnection *connection; GHashTable *paths = g_hash_table_new (g_str_hash, g_str_equal); g_hash_table_iter_init (&iter, connections); @@ -403,23 +403,23 @@ _sort_paths (const char **f1, const char **f2, GHashTable *paths) static void read_connections (NMSettingsPlugin *config) { - SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (self); + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN (config); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (self); GDir *dir; GError *error = NULL; const char *item; GHashTable *alive_connections; GHashTableIter iter; - NMKeyfileConnection *connection; + NMSKeyfileConnection *connection; GPtrArray *dead_connections = NULL; guint i; GPtrArray *filenames; GHashTable *paths; - dir = g_dir_open (nm_keyfile_plugin_get_path (), 0, &error); + dir = g_dir_open (nms_keyfile_utils_get_path (), 0, &error); if (!dir) { nm_log_warn (LOGD_SETTINGS, "keyfile: cannot read directory '%s': %s", - nm_keyfile_plugin_get_path (), + nms_keyfile_utils_get_path (), error->message); g_clear_error (&error); return; @@ -429,9 +429,9 @@ read_connections (NMSettingsPlugin *config) filenames = g_ptr_array_new_with_free_func (g_free); while ((item = g_dir_read_name (dir))) { - if (nm_keyfile_plugin_utils_should_ignore_file (item)) + if (nms_keyfile_utils_should_ignore_file (item)) continue; - g_ptr_array_add (filenames, g_build_filename (nm_keyfile_plugin_get_path (), item, NULL)); + g_ptr_array_add (filenames, g_build_filename (nms_keyfile_utils_get_path (), item, NULL)); } g_dir_close (dir); @@ -475,7 +475,7 @@ read_connections (NMSettingsPlugin *config) static GSList * get_connections (NMSettingsPlugin *config) { - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) config); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) config); if (!priv->initialized) { setup_monitoring (config); @@ -489,16 +489,16 @@ static gboolean load_connection (NMSettingsPlugin *config, const char *filename) { - SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE ((SettingsPluginKeyfile *) config); - NMKeyfileConnection *connection; - int dir_len = strlen (nm_keyfile_plugin_get_path ()); + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN ((NMSKeyfilePlugin *) config); + NMSKeyfileConnection *connection; + int dir_len = strlen (nms_keyfile_utils_get_path ()); - if ( strncmp (filename, nm_keyfile_plugin_get_path (), dir_len) != 0 + if ( strncmp (filename, nms_keyfile_utils_get_path (), dir_len) != 0 || filename[dir_len] != '/' || strchr (filename + dir_len + 1, '/') != NULL) return FALSE; - if (nm_keyfile_plugin_utils_should_ignore_file (filename + dir_len + 1)) + if (nms_keyfile_utils_should_ignore_file (filename + dir_len + 1)) return FALSE; connection = update_connection (self, NULL, filename, find_by_path (self, filename), TRUE, NULL, NULL); @@ -518,11 +518,11 @@ add_connection (NMSettingsPlugin *config, gboolean save_to_disk, GError **error) { - SettingsPluginKeyfile *self = SETTINGS_PLUGIN_KEYFILE (config); + NMSKeyfilePlugin *self = NMS_KEYFILE_PLUGIN (config); gs_free char *path = NULL; if (save_to_disk) { - if (!nm_keyfile_plugin_write_connection (connection, NULL, FALSE, &path, error)) + if (!nms_keyfile_writer_connection (connection, NULL, FALSE, &path, error)) return NULL; } return NM_SETTINGS_CONNECTION (update_connection (self, connection, path, NULL, FALSE, NULL, error)); @@ -531,7 +531,7 @@ add_connection (NMSettingsPlugin *config, static GSList * get_unmanaged_specs (NMSettingsPlugin *config) { - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) config); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) config); gs_free char *value = NULL; value = nm_config_data_get_value (nm_config_get_data (priv->config), @@ -549,10 +549,10 @@ get_property (GObject *object, guint prop_id, { switch (prop_id) { case NM_SETTINGS_PLUGIN_PROP_NAME: - g_value_set_string (value, KEYFILE_PLUGIN_NAME); + g_value_set_string (value, NMS_KEYFILE_PLUGIN_NAME); break; case NM_SETTINGS_PLUGIN_PROP_INFO: - g_value_set_string (value, KEYFILE_PLUGIN_INFO); + g_value_set_string (value, NMS_KEYFILE_PLUGIN_INFO); break; case NM_SETTINGS_PLUGIN_PROP_CAPABILITIES: g_value_set_uint (value, NM_SETTINGS_PLUGIN_CAP_MODIFY_CONNECTIONS); @@ -566,9 +566,9 @@ get_property (GObject *object, guint prop_id, /*****************************************************************************/ static void -settings_plugin_keyfile_init (SettingsPluginKeyfile *plugin) +nms_keyfile_plugin_init (NMSKeyfilePlugin *plugin) { - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE (plugin); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE (plugin); priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref); } @@ -576,7 +576,7 @@ settings_plugin_keyfile_init (SettingsPluginKeyfile *plugin) static void constructed (GObject *object) { - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) object); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) object); priv->config = g_object_ref (nm_config_get ()); if (nm_config_data_has_value (nm_config_get_data_orig (priv->config), @@ -587,15 +587,15 @@ constructed (GObject *object) } GObject * -nm_settings_keyfile_plugin_new (void) +nms_keyfile_plugin_new (void) { - return g_object_new (SETTINGS_TYPE_PLUGIN_KEYFILE, NULL); + return g_object_new (NMS_TYPE_KEYFILE_PLUGIN, NULL); } static void dispose (GObject *object) { - SettingsPluginKeyfilePrivate *priv = SETTINGS_PLUGIN_KEYFILE_GET_PRIVATE ((SettingsPluginKeyfile *) object); + NMSKeyfilePluginPrivate *priv = NMS_KEYFILE_PLUGIN_GET_PRIVATE ((NMSKeyfilePlugin *) object); if (priv->monitor) { nm_clear_g_signal_handler (priv->monitor, &priv->monitor_id); @@ -614,11 +614,11 @@ dispose (GObject *object) g_clear_object (&priv->config); } - G_OBJECT_CLASS (settings_plugin_keyfile_parent_class)->dispose (object); + G_OBJECT_CLASS (nms_keyfile_plugin_parent_class)->dispose (object); } static void -settings_plugin_keyfile_class_init (SettingsPluginKeyfileClass *req_class) +nms_keyfile_plugin_class_init (NMSKeyfilePluginClass *req_class) { GObjectClass *object_class = G_OBJECT_CLASS (req_class); diff --git a/src/settings/plugins/keyfile/nms-keyfile-plugin.h b/src/settings/plugins/keyfile/nms-keyfile-plugin.h index 21f41c88d1..ba62a88b94 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-plugin.h +++ b/src/settings/plugins/keyfile/nms-keyfile-plugin.h @@ -19,21 +19,21 @@ * Copyright (C) 2008 - 2011 Red Hat, Inc. */ -#ifndef __NMKF_PLUGIN_H__ -#define __NMKF_PLUGIN_H__ +#ifndef __NMS_KEYFILE_PLUGIN_H__ +#define __NMS_KEYFILE_PLUGIN_H__ -#define SETTINGS_TYPE_PLUGIN_KEYFILE (settings_plugin_keyfile_get_type ()) -#define SETTINGS_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfile)) -#define SETTINGS_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfileClass)) -#define SETTINGS_IS_PLUGIN_KEYFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE)) -#define SETTINGS_IS_PLUGIN_KEYFILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SETTINGS_TYPE_PLUGIN_KEYFILE)) -#define SETTINGS_PLUGIN_KEYFILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SETTINGS_TYPE_PLUGIN_KEYFILE, SettingsPluginKeyfileClass)) +#define NMS_TYPE_KEYFILE_PLUGIN (nms_keyfile_plugin_get_type ()) +#define NMS_KEYFILE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMS_TYPE_KEYFILE_PLUGIN, NMSKeyfilePlugin)) +#define NMS_KEYFILE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMS_TYPE_KEYFILE_PLUGIN, NMSKeyfilePluginClass)) +#define NMS_IS_KEYFILE_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMS_TYPE_KEYFILE_PLUGIN)) +#define NMS_IS_KEYFILE_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NMS_TYPE_KEYFILE_PLUGIN)) +#define NMS_KEYFILE_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMS_TYPE_KEYFILE_PLUGIN, NMSKeyfilePluginClass)) -typedef struct _SettingsPluginKeyfile SettingsPluginKeyfile; -typedef struct _SettingsPluginKeyfileClass SettingsPluginKeyfileClass; +typedef struct _NMSKeyfilePlugin NMSKeyfilePlugin; +typedef struct _NMSKeyfilePluginClass NMSKeyfilePluginClass; -GType settings_plugin_keyfile_get_type (void); +GType nms_keyfile_plugin_get_type (void); -GObject *nm_settings_keyfile_plugin_new (void); +GObject *nms_keyfile_plugin_new (void); -#endif /* __NMKF_PLUGIN_H__ */ +#endif /* __NMS_KEYFILE_PLUGIN_H__ */ diff --git a/src/settings/plugins/keyfile/nms-keyfile-reader.c b/src/settings/plugins/keyfile/nms-keyfile-reader.c index 0373157308..84bd3fece4 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-reader.c +++ b/src/settings/plugins/keyfile/nms-keyfile-reader.c @@ -87,7 +87,7 @@ _handler_read (GKeyFile *keyfile, } NMConnection * -nm_keyfile_plugin_connection_from_file (const char *filename, GError **error) +nms_keyfile_reader_from_file (const char *filename, GError **error) { GKeyFile *key_file; struct stat statbuf; diff --git a/src/settings/plugins/keyfile/nms-keyfile-reader.h b/src/settings/plugins/keyfile/nms-keyfile-reader.h index 7bbc6005c2..c52fea31d2 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-reader.h +++ b/src/settings/plugins/keyfile/nms-keyfile-reader.h @@ -19,11 +19,11 @@ * Copyright (C) 2008 Red Hat, Inc. */ -#ifndef _KEYFILE_PLUGIN_READER_H -#define _KEYFILE_PLUGIN_READER_H +#ifndef __NMS_KEYFILE_READER_H__ +#define __NMS_KEYFILE_READER_H__ #include <nm-connection.h> -NMConnection *nm_keyfile_plugin_connection_from_file (const char *filename, GError **error); +NMConnection *nms_keyfile_reader_from_file (const char *filename, GError **error); -#endif /* _KEYFILE_PLUGIN_READER_H */ +#endif /* __NMS_KEYFILE_READER_H__ */ diff --git a/src/settings/plugins/keyfile/nms-keyfile-utils.c b/src/settings/plugins/keyfile/nms-keyfile-utils.c index 8b955f53f6..5b9fd69e6f 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-utils.c +++ b/src/settings/plugins/keyfile/nms-keyfile-utils.c @@ -88,7 +88,7 @@ check_suffix (const char *base, const char *tag) #define DER_TAG ".der" gboolean -nm_keyfile_plugin_utils_should_ignore_file (const char *filename) +nms_keyfile_utils_should_ignore_file (const char *filename) { gs_free char *base = NULL; @@ -112,7 +112,7 @@ nm_keyfile_plugin_utils_should_ignore_file (const char *filename) } char * -nm_keyfile_plugin_utils_escape_filename (const char *filename) +nms_keyfile_utils_escape_filename (const char *filename) { GString *str; const char *f = filename; @@ -151,7 +151,7 @@ nm_keyfile_plugin_utils_escape_filename (const char *filename) /*****************************************************************************/ const char * -nm_keyfile_plugin_get_path (void) +nms_keyfile_utils_get_path (void) { static char *path = NULL; diff --git a/src/settings/plugins/keyfile/nms-keyfile-utils.h b/src/settings/plugins/keyfile/nms-keyfile-utils.h index 85aa545842..be7d668acc 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-utils.h +++ b/src/settings/plugins/keyfile/nms-keyfile-utils.h @@ -15,28 +15,27 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * - * (C) Copyright 2010 Red Hat, Inc. + * (C) Copyright 2010-2016 Red Hat, Inc. */ -#ifndef _UTILS_H_ -#define _UTILS_H_ +#ifndef __NMS_KEYFILE_UTILS_H__ +#define __NMS_KEYFILE_UTILS_H__ #include "NetworkManagerUtils.h" -#define KEYFILE_PLUGIN_NAME "keyfile" -#define KEYFILE_PLUGIN_INFO "(c) 2007 - 2015 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." +#define NMS_KEYFILE_PLUGIN_NAME "keyfile" +#define NMS_KEYFILE_PLUGIN_INFO "(c) 2007 - 2016 Red Hat, Inc. To report bugs please use the NetworkManager mailing list." -#define NM_KEYFILE_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory") -#define NM_KEYFILE_CONNECTION_LOG_FMT "%s (%s,\"%s\")" -#define NM_KEYFILE_CONNECTION_LOG_ARG(con) NM_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)) -#define NM_KEYFILE_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)" -#define NM_KEYFILE_CONNECTION_LOG_ARGD(con) NM_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)), (con) +#define NMS_KEYFILE_CONNECTION_LOG_PATH(path) ((path) ?: "in-memory") +#define NMS_KEYFILE_CONNECTION_LOG_FMT "%s (%s,\"%s\")" +#define NMS_KEYFILE_CONNECTION_LOG_ARG(con) NMS_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)) +#define NMS_KEYFILE_CONNECTION_LOG_FMTD "%s (%s,\"%s\",%p)" +#define NMS_KEYFILE_CONNECTION_LOG_ARGD(con) NMS_KEYFILE_CONNECTION_LOG_PATH (nm_settings_connection_get_filename ((NMSettingsConnection *) (con))), nm_connection_get_uuid ((NMConnection *) (con)), nm_connection_get_id ((NMConnection *) (con)), (con) -gboolean nm_keyfile_plugin_utils_should_ignore_file (const char *filename); +gboolean nms_keyfile_utils_should_ignore_file (const char *filename); -char *nm_keyfile_plugin_utils_escape_filename (const char *filename); +char *nms_keyfile_utils_escape_filename (const char *filename); -const char *nm_keyfile_plugin_get_path (void); - -#endif /* _UTILS_H_ */ +const char *nms_keyfile_utils_get_path (void); +#endif /* __NMS_KEYFILE_UTILS_H__ */ diff --git a/src/settings/plugins/keyfile/nms-keyfile-writer.c b/src/settings/plugins/keyfile/nms-keyfile-writer.c index ec472aaa4d..a9a8122fe2 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-writer.c +++ b/src/settings/plugins/keyfile/nms-keyfile-writer.c @@ -264,7 +264,7 @@ _internal_write_connection (NMConnection *connection, if (existing_path != NULL && !force_rename) { path = g_strdup (existing_path); } else { - char *filename_escaped = nm_keyfile_plugin_utils_escape_filename (id); + char *filename_escaped = nms_keyfile_utils_escape_filename (id); path = g_build_filename (keyfile_dir, filename_escaped, NULL); g_free (filename_escaped); @@ -290,7 +290,7 @@ _internal_write_connection (NMConnection *connection, else filename = g_strdup_printf ("%s-%s-%u", id, nm_connection_get_uuid (connection), i); - filename_escaped = nm_keyfile_plugin_utils_escape_filename (filename); + filename_escaped = nms_keyfile_utils_escape_filename (filename); g_free (path); path = g_strdup_printf ("%s/%s", keyfile_dir, filename_escaped); @@ -353,14 +353,14 @@ out: } gboolean -nm_keyfile_plugin_write_connection (NMConnection *connection, - const char *existing_path, - gboolean force_rename, - char **out_path, - GError **error) +nms_keyfile_writer_connection (NMConnection *connection, + const char *existing_path, + gboolean force_rename, + char **out_path, + GError **error) { return _internal_write_connection (connection, - nm_keyfile_plugin_get_path (), + nms_keyfile_utils_get_path (), 0, 0, existing_path, force_rename, @@ -369,12 +369,12 @@ nm_keyfile_plugin_write_connection (NMConnection *connection, } gboolean -nm_keyfile_plugin_write_test_connection (NMConnection *connection, - const char *keyfile_dir, - uid_t owner_uid, - pid_t owner_grp, - char **out_path, - GError **error) +nms_keyfile_writer_test_connection (NMConnection *connection, + const char *keyfile_dir, + uid_t owner_uid, + pid_t owner_grp, + char **out_path, + GError **error) { return _internal_write_connection (connection, keyfile_dir, diff --git a/src/settings/plugins/keyfile/nms-keyfile-writer.h b/src/settings/plugins/keyfile/nms-keyfile-writer.h index 894356518d..4f43455d07 100644 --- a/src/settings/plugins/keyfile/nms-keyfile-writer.h +++ b/src/settings/plugins/keyfile/nms-keyfile-writer.h @@ -19,22 +19,22 @@ * Copyright (C) 2008 - 2011 Red Hat, Inc. */ -#ifndef _KEYFILE_PLUGIN_WRITER_H -#define _KEYFILE_PLUGIN_WRITER_H +#ifndef __NMS_KEYFILE_WRITER_H__ +#define __NMS_KEYFILE_WRITER_H__ #include <nm-connection.h> -gboolean nm_keyfile_plugin_write_connection (NMConnection *connection, - const char *existing_path, - gboolean force_rename, +gboolean nms_keyfile_writer_connection (NMConnection *connection, + const char *existing_path, + gboolean force_rename, + char **out_path, + GError **error); + +gboolean nms_keyfile_writer_test_connection (NMConnection *connection, + const char *keyfile_dir, + uid_t owner_uid, + pid_t owner_grp, char **out_path, GError **error); -gboolean nm_keyfile_plugin_write_test_connection (NMConnection *connection, - const char *keyfile_dir, - uid_t owner_uid, - pid_t owner_grp, - char **out_path, - GError **error); - -#endif /* _KEYFILE_PLUGIN_WRITER_H */ +#endif /* __NMS_KEYFILE_WRITER_H__ */ diff --git a/src/settings/plugins/keyfile/tests/test-keyfile.c b/src/settings/plugins/keyfile/tests/test-keyfile.c index 4eebf04a96..d9d70437bb 100644 --- a/src/settings/plugins/keyfile/tests/test-keyfile.c +++ b/src/settings/plugins/keyfile/tests/test-keyfile.c @@ -69,7 +69,7 @@ keyfile_read_connection_from_file (const char *filename) g_assert (filename); - connection = nm_keyfile_plugin_connection_from_file (filename, &error); + connection = nms_keyfile_reader_from_file (filename, &error); g_assert_no_error (error); nmtst_assert_connection_verifies_without_normalization (connection); @@ -89,7 +89,7 @@ assert_reread (NMConnection *connection, gboolean normalize_connection, const ch g_assert (NM_IS_CONNECTION (connection)); g_assert (testfile && testfile[0]); - reread = nm_keyfile_plugin_connection_from_file (testfile, p_error); + reread = nms_keyfile_reader_from_file (testfile, p_error); g_assert_no_error (error); g_assert (NM_IS_CONNECTION (reread)); @@ -127,7 +127,7 @@ write_test_connection (NMConnection *connection, char **testfile) owner_uid = geteuid (); owner_grp = getegid (); - success = nm_keyfile_plugin_write_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, testfile, p_error); + success = nms_keyfile_writer_test_connection (connection, TEST_SCRATCH_DIR, owner_uid, owner_grp, testfile, p_error); g_assert_no_error (error); g_assert (success); g_assert (*testfile && (*testfile)[0]); @@ -204,7 +204,7 @@ test_read_valid_wired_connection (void) "*ipv6.routes*semicolon at the end*routes1*"); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*ipv6.route*semicolon at the end*route6*"); - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection", NULL); g_test_assert_expected_messages (); g_assert (connection); @@ -465,7 +465,7 @@ test_read_ip6_wired_connection (void) gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_IP6", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_IP6", NULL); g_assert (connection); success = nm_connection_verify (connection, &error); g_assert_no_error (error); @@ -576,7 +576,7 @@ test_read_wired_mac_case (void) "*ipv4.addresses*semicolon at the end*addresses2*"); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_INFO, "*ipv6.routes*semicolon at the end*routes1*"); - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_MAC_Case", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_Connection_MAC_Case", NULL); g_test_assert_expected_messages (); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -608,7 +608,7 @@ test_read_mac_old_format (void) char expected_mac[ETH_ALEN] = { 0x00, 0x11, 0xaa, 0xbb, 0xcc, 0x55 }; char expected_cloned_mac[ETH_ALEN] = { 0x00, 0x16, 0xaa, 0xbb, 0xcc, 0xfe }; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_MAC_Old_Format", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_MAC_Old_Format", &error); g_assert_no_error (error); g_assert (connection); @@ -642,7 +642,7 @@ test_read_mac_ib_old_format (void) 0x77, 0x88, 0x99, 0x01, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x90 }; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_MAC_IB_Old_Format", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_MAC_IB_Old_Format", &error); g_assert_no_error (error); g_assert (connection); @@ -671,7 +671,7 @@ test_read_valid_wireless_connection (void) const guint8 expected_bssid[ETH_ALEN] = { 0x00, 0x1a, 0x33, 0x44, 0x99, 0x82 }; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wireless_Connection", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wireless_Connection", NULL); g_assert (connection); success = nm_connection_verify (connection, &error); g_assert_no_error (error); @@ -775,7 +775,7 @@ test_read_string_ssid (void) const char *expected_ssid = "blah blah ssid 1234"; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_String_SSID", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_String_SSID", NULL); g_assert (connection); success = nm_connection_verify (connection, &error); g_assert_no_error (error); @@ -859,7 +859,7 @@ test_read_intlist_ssid (void) gsize ssid_len; const char *expected_ssid = "blah1234"; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Intlist_SSID", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Intlist_SSID", &error); g_assert_no_error (error); g_assert (connection); @@ -952,7 +952,7 @@ test_read_intlike_ssid (void) gsize ssid_len; const char *expected_ssid = "101"; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID", &error); g_assert_no_error (error); g_assert (connection); @@ -983,7 +983,7 @@ test_read_intlike_ssid_2 (void) gsize ssid_len; const char *expected_ssid = "11;12;13;"; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID_2", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Intlike_SSID_2", &error); g_assert_no_error (error); g_assert (connection); @@ -1132,7 +1132,7 @@ test_read_bt_dun_connection (void) const guint8 expected_bdaddr[ETH_ALEN] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_BT", NULL); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_BT", NULL); g_assert (connection); success = nm_connection_verify (connection, &error); g_assert_no_error (error); @@ -1235,7 +1235,7 @@ test_read_gsm_connection (void) gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_Plain", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/ATT_Data_Connect_Plain", &error); g_assert_no_error (error); g_assert (connection); @@ -1340,7 +1340,7 @@ test_read_wired_8021x_tls_blob_connection (void) "*<warn> * keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*<warn> * keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Blob", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Blob", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -1399,7 +1399,7 @@ test_read_wired_8021x_tls_bad_path_connection (void) g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*does not exist*"); - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Path_Missing", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Path_Missing", &error); g_test_assert_expected_messages (); g_assert_no_error (error); g_assert (connection); @@ -1457,7 +1457,7 @@ test_read_wired_8021x_tls_old_connection (void) "*<warn> * keyfile: 802-1x.client-cert: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); g_test_expect_message ("NetworkManager", G_LOG_LEVEL_MESSAGE, "*<warn> * keyfile: 802-1x.private-key: certificate or key file '/CASA/dcbw/Desktop/certinfra/client.pem' does not exist*"); - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Old", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_Old", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -1503,7 +1503,7 @@ test_read_wired_8021x_tls_new_connection (void) char *tmp2; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_New", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Wired_TLS_New", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -1645,7 +1645,7 @@ test_write_wired_8021x_tls_connection_path (void) write_test_connection (connection, &testfile); /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); + reread = nms_keyfile_reader_from_file (testfile, &error); if (!reread) { g_assert (error); g_warning ("Failed to re-read test connection: %s", error->message); @@ -1753,7 +1753,7 @@ test_write_wired_8021x_tls_connection_blob (void) g_assert (g_file_test (new_priv_key, G_FILE_TEST_EXISTS)); /* Read the connection back in and compare it to the one we just wrote out */ - reread = nm_keyfile_plugin_connection_from_file (testfile, &error); + reread = nms_keyfile_reader_from_file (testfile, &error); if (!reread) { g_assert (error); g_warning ("Failed to re-read test connection: %s", error->message); @@ -1800,7 +1800,7 @@ test_read_infiniband_connection (void) const char *expected_uuid = "4e80a56d-c99f-4aad-a6dd-b449bc398c57"; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_InfiniBand_Connection", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_InfiniBand_Connection", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -1886,7 +1886,7 @@ test_read_bridge_main (void) const char *expected_uuid = "8f061643-fe41-4d4c-a8d9-097d26e2ad3a"; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Main", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Main", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -1983,7 +1983,7 @@ test_read_bridge_component (void) const char *expected_uuid = "d7b4f96c-c45e-4298-bef8-f48574f8c1c0"; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Component", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR "/Test_Bridge_Component", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2073,7 +2073,7 @@ test_read_new_wired_group_name (void) gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_New_Wired_Group_Name", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_New_Wired_Group_Name", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2155,7 +2155,7 @@ test_read_new_wireless_group_names (void) gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_New_Wireless_Group_Names", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_New_Wireless_Group_Names", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2262,7 +2262,7 @@ test_read_missing_vlan_setting (void) gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Setting", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Setting", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2284,7 +2284,7 @@ test_read_missing_vlan_flags (void) gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Flags", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Missing_Vlan_Flags", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2307,7 +2307,7 @@ test_read_missing_id_uuid (void) gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Missing_ID_UUID", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Missing_ID_UUID", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2411,7 +2411,7 @@ test_read_enum_property (void) gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Enum_Property", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Enum_Property", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2471,7 +2471,7 @@ test_read_flags_property (void) gs_free_error GError *error = NULL; gboolean success; - connection = nm_keyfile_plugin_connection_from_file (TEST_KEYFILES_DIR"/Test_Flags_Property", &error); + connection = nms_keyfile_reader_from_file (TEST_KEYFILES_DIR"/Test_Flags_Property", &error); g_assert_no_error (error); g_assert (connection); success = nm_connection_verify (connection, &error); @@ -2530,18 +2530,18 @@ _escape_filename (const char *filename, gboolean would_be_ignored) g_assert (filename && filename[0]); - if (!!would_be_ignored != !!nm_keyfile_plugin_utils_should_ignore_file (filename)) { + if (!!would_be_ignored != !!nms_keyfile_utils_should_ignore_file (filename)) { if (would_be_ignored) g_error ("We expect filename \"%s\" to be ignored, but it isn't", filename); else g_error ("We expect filename \"%s\" not to be ignored, but it is", filename); } - esc = nm_keyfile_plugin_utils_escape_filename (filename); + esc = nms_keyfile_utils_escape_filename (filename); g_assert (esc && esc[0]); g_assert (!strchr (esc, '/')); - if (nm_keyfile_plugin_utils_should_ignore_file (esc)) + if (nms_keyfile_utils_should_ignore_file (esc)) g_error ("Escaping filename \"%s\" yielded \"%s\", but this is ignored", filename, esc); } |