mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 14:38:09 +02:00
settings: add NMSettingsConnection:filename
Add a "filename" property to NMSettingsConnection, and set it from keyfile and ifcfg-rh (replacing the existing priv->path variables in those connection types). (The other plugins either don't use files, or don't use per-connection files.) (cherry picked from commits24a464a7daandc9002c041d)
This commit is contained in:
parent
318d0077d9
commit
3572160f55
8 changed files with 119 additions and 121 deletions
|
|
@ -84,6 +84,7 @@ enum {
|
|||
PROP_UNSAVED,
|
||||
PROP_READY,
|
||||
PROP_FLAGS,
|
||||
PROP_FILENAME,
|
||||
};
|
||||
|
||||
enum {
|
||||
|
|
@ -131,6 +132,8 @@ typedef struct {
|
|||
gint32 autoconnect_retry_time;
|
||||
NMDeviceStateReason autoconnect_blocked_reason;
|
||||
|
||||
char *filename;
|
||||
|
||||
} NMSettingsConnectionPrivate;
|
||||
|
||||
/**************************************************************/
|
||||
|
|
@ -2187,6 +2190,45 @@ nm_settings_connection_set_ready (NMSettingsConnection *connection,
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_settings_connection_set_filename:
|
||||
* @connection: an #NMSettingsConnection
|
||||
* @filename: @connection's filename
|
||||
*
|
||||
* Called by a backend to sets the filename that @connection is read
|
||||
* from/written to.
|
||||
*/
|
||||
void
|
||||
nm_settings_connection_set_filename (NMSettingsConnection *connection,
|
||||
const char *filename)
|
||||
{
|
||||
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
if (g_strcmp0 (filename, priv->filename) != 0) {
|
||||
g_free (priv->filename);
|
||||
priv->filename = g_strdup (filename);
|
||||
g_object_notify (G_OBJECT (connection), NM_SETTINGS_CONNECTION_FILENAME);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_settings_connection_get_filename:
|
||||
* @connection: an #NMSettingsConnection
|
||||
*
|
||||
* Gets the filename that @connection was read from/written to. This may be
|
||||
* %NULL if @connection is unsaved, or if it is associated with a backend that
|
||||
* does not store each connection in a separate file.
|
||||
*
|
||||
* Returns: @connection's filename.
|
||||
*/
|
||||
const char *
|
||||
nm_settings_connection_get_filename (NMSettingsConnection *connection)
|
||||
{
|
||||
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (connection);
|
||||
|
||||
return priv->filename;
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -2280,6 +2322,9 @@ get_property (GObject *object, guint prop_id,
|
|||
case PROP_FLAGS:
|
||||
g_value_set_uint (value, nm_settings_connection_get_flags (self));
|
||||
break;
|
||||
case PROP_FILENAME:
|
||||
g_value_set_string (value, nm_settings_connection_get_filename (self));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -2299,6 +2344,9 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_FLAGS:
|
||||
nm_settings_connection_set_flags_all (self, g_value_get_uint (value));
|
||||
break;
|
||||
case PROP_FILENAME:
|
||||
nm_settings_connection_set_filename (self, g_value_get_string (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
|
@ -2352,6 +2400,13 @@ nm_settings_connection_class_init (NMSettingsConnectionClass *class)
|
|||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_FILENAME,
|
||||
g_param_spec_string (NM_SETTINGS_CONNECTION_FILENAME, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/* Signals */
|
||||
|
||||
/* Emitted when the connection is changed for any reason */
|
||||
|
|
|
|||
|
|
@ -46,10 +46,11 @@ G_BEGIN_DECLS
|
|||
#define NM_SETTINGS_CONNECTION_UPDATED_BY_USER "updated-by-user"
|
||||
|
||||
/* Properties */
|
||||
#define NM_SETTINGS_CONNECTION_VISIBLE "visible"
|
||||
#define NM_SETTINGS_CONNECTION_UNSAVED "unsaved"
|
||||
#define NM_SETTINGS_CONNECTION_READY "ready"
|
||||
#define NM_SETTINGS_CONNECTION_FLAGS "flags"
|
||||
#define NM_SETTINGS_CONNECTION_VISIBLE "visible"
|
||||
#define NM_SETTINGS_CONNECTION_UNSAVED "unsaved"
|
||||
#define NM_SETTINGS_CONNECTION_READY "ready"
|
||||
#define NM_SETTINGS_CONNECTION_FLAGS "flags"
|
||||
#define NM_SETTINGS_CONNECTION_FILENAME "filename"
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -201,6 +202,10 @@ gboolean nm_settings_connection_get_ready (NMSettingsConnection *connection);
|
|||
void nm_settings_connection_set_ready (NMSettingsConnection *connection,
|
||||
gboolean ready);
|
||||
|
||||
void nm_settings_connection_set_filename (NMSettingsConnection *connection,
|
||||
const char *filename);
|
||||
const char *nm_settings_connection_get_filename (NMSettingsConnection *connection);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NETWORKMANAGER_SETTINGS_CONNECTION_H__ */
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ G_DEFINE_TYPE (NMIfcfgConnection, nm_ifcfg_connection, NM_TYPE_SETTINGS_CONNECTI
|
|||
typedef struct {
|
||||
gulong ih_event_id;
|
||||
|
||||
char *path;
|
||||
int file_wd;
|
||||
|
||||
char *keyfile;
|
||||
|
|
@ -157,7 +156,7 @@ nm_ifcfg_connection_check_devtimeout (NMIfcfgConnection *self)
|
|||
ifname = nm_setting_connection_get_interface_name (s_con);
|
||||
if (!ifname)
|
||||
return;
|
||||
devtimeout = devtimeout_from_file (nm_ifcfg_connection_get_path (self));
|
||||
devtimeout = devtimeout_from_file (nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (self)));
|
||||
if (!devtimeout)
|
||||
return;
|
||||
|
||||
|
|
@ -228,6 +227,7 @@ nm_ifcfg_connection_new (NMConnection *source,
|
|||
unrecognized_spec = unhandled_spec + strlen ("unrecognized:");
|
||||
|
||||
object = (GObject *) g_object_new (NM_TYPE_IFCFG_CONNECTION,
|
||||
NM_SETTINGS_CONNECTION_FILENAME, full_path,
|
||||
NM_IFCFG_CONNECTION_UNMANAGED_SPEC, unmanaged_spec,
|
||||
NM_IFCFG_CONNECTION_UNRECOGNIZED_SPEC, unrecognized_spec,
|
||||
NULL);
|
||||
|
|
@ -235,13 +235,9 @@ nm_ifcfg_connection_new (NMConnection *source,
|
|||
if (nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
|
||||
tmp,
|
||||
update_unsaved,
|
||||
error)) {
|
||||
/* Set the path and start monitoring */
|
||||
if (full_path) {
|
||||
nm_ifcfg_connection_set_path (NM_IFCFG_CONNECTION (object), full_path);
|
||||
nm_ifcfg_connection_check_devtimeout (NM_IFCFG_CONNECTION (object));
|
||||
}
|
||||
} else
|
||||
error))
|
||||
nm_ifcfg_connection_check_devtimeout (NM_IFCFG_CONNECTION (object));
|
||||
else
|
||||
g_clear_object (&object);
|
||||
|
||||
g_object_unref (tmp);
|
||||
|
|
@ -249,14 +245,6 @@ nm_ifcfg_connection_new (NMConnection *source,
|
|||
return (NMIfcfgConnection *) object;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_ifcfg_connection_get_path (NMIfcfgConnection *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_IFCFG_CONNECTION (self), NULL);
|
||||
|
||||
return NM_IFCFG_CONNECTION_GET_PRIVATE (self)->path;
|
||||
}
|
||||
|
||||
static void
|
||||
path_watch_stop (NMIfcfgConnection *self)
|
||||
{
|
||||
|
|
@ -297,17 +285,21 @@ path_watch_stop (NMIfcfgConnection *self)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
nm_ifcfg_connection_set_path (NMIfcfgConnection *self, const char *ifcfg_path)
|
||||
static void
|
||||
filename_changed (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMIfcfgConnection *self = NM_IFCFG_CONNECTION (object);
|
||||
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (self);
|
||||
|
||||
g_return_if_fail (ifcfg_path != NULL);
|
||||
const char *ifcfg_path;
|
||||
|
||||
path_watch_stop (self);
|
||||
g_free (priv->path);
|
||||
|
||||
priv->path = g_strdup (ifcfg_path);
|
||||
ifcfg_path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (self));
|
||||
if (!ifcfg_path)
|
||||
return;
|
||||
|
||||
priv->keyfile = utils_get_keys_path (ifcfg_path);
|
||||
priv->routefile = utils_get_route_path (ifcfg_path);
|
||||
priv->route6file = utils_get_route6_path (ifcfg_path);
|
||||
|
|
@ -349,13 +341,15 @@ commit_changes (NMSettingsConnection *connection,
|
|||
NMConnection *reread;
|
||||
gboolean same = FALSE, success = FALSE;
|
||||
char *ifcfg_path = NULL;
|
||||
const char *filename;
|
||||
|
||||
/* To ensure we don't rewrite files that are only changed from other
|
||||
* processes on-disk, read the existing connection back in and only rewrite
|
||||
* it if it's really changed.
|
||||
*/
|
||||
if (priv->path) {
|
||||
reread = connection_from_file (priv->path, NULL, NULL);
|
||||
filename = nm_settings_connection_get_filename (connection);
|
||||
if (filename) {
|
||||
reread = connection_from_file (filename, NULL, NULL);
|
||||
if (reread) {
|
||||
same = nm_connection_compare (NM_CONNECTION (connection),
|
||||
reread,
|
||||
|
|
@ -373,7 +367,7 @@ commit_changes (NMSettingsConnection *connection,
|
|||
|
||||
success = writer_update_connection (NM_CONNECTION (connection),
|
||||
IFCFG_DIR,
|
||||
priv->path,
|
||||
filename,
|
||||
priv->keyfile,
|
||||
&error);
|
||||
} else {
|
||||
|
|
@ -382,7 +376,7 @@ commit_changes (NMSettingsConnection *connection,
|
|||
&ifcfg_path,
|
||||
&error);
|
||||
if (success) {
|
||||
nm_ifcfg_connection_set_path (NM_IFCFG_CONNECTION (connection), ifcfg_path);
|
||||
nm_settings_connection_set_filename (connection, ifcfg_path);
|
||||
g_free (ifcfg_path);
|
||||
}
|
||||
}
|
||||
|
|
@ -403,14 +397,15 @@ do_delete (NMSettingsConnection *connection,
|
|||
gpointer user_data)
|
||||
{
|
||||
NMIfcfgConnectionPrivate *priv = NM_IFCFG_CONNECTION_GET_PRIVATE (connection);
|
||||
const char *filename;
|
||||
|
||||
if (priv->path) {
|
||||
g_unlink (priv->path);
|
||||
filename = nm_settings_connection_get_filename (connection);
|
||||
if (filename) {
|
||||
g_unlink (filename);
|
||||
if (priv->keyfile)
|
||||
g_unlink (priv->keyfile);
|
||||
if (priv->routefile)
|
||||
g_unlink (priv->routefile);
|
||||
|
||||
if (priv->route6file)
|
||||
g_unlink (priv->route6file);
|
||||
}
|
||||
|
|
@ -423,6 +418,8 @@ do_delete (NMSettingsConnection *connection,
|
|||
static void
|
||||
nm_ifcfg_connection_init (NMIfcfgConnection *connection)
|
||||
{
|
||||
g_signal_connect (connection, "notify::" NM_SETTINGS_CONNECTION_FILENAME,
|
||||
G_CALLBACK (filename_changed), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -483,14 +480,6 @@ dispose (GObject *object)
|
|||
G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
g_free (NM_IFCFG_CONNECTION_GET_PRIVATE (object)->path);
|
||||
|
||||
G_OBJECT_CLASS (nm_ifcfg_connection_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class)
|
||||
{
|
||||
|
|
@ -503,7 +492,6 @@ nm_ifcfg_connection_class_init (NMIfcfgConnectionClass *ifcfg_connection_class)
|
|||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
settings_class->delete = do_delete;
|
||||
settings_class->commit_changes = commit_changes;
|
||||
|
||||
|
|
|
|||
|
|
@ -50,11 +50,6 @@ NMIfcfgConnection *nm_ifcfg_connection_new (NMConnection *source,
|
|||
const char *full_path,
|
||||
GError **error);
|
||||
|
||||
const char *nm_ifcfg_connection_get_path (NMIfcfgConnection *self);
|
||||
|
||||
void nm_ifcfg_connection_set_path (NMIfcfgConnection *self,
|
||||
const char *ifcfg_path);
|
||||
|
||||
const char *nm_ifcfg_connection_get_unmanaged_spec (NMIfcfgConnection *self);
|
||||
const char *nm_ifcfg_connection_get_unrecognized_spec (NMIfcfgConnection *self);
|
||||
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data)
|
|||
SCPluginIfcfg *plugin = SC_PLUGIN_IFCFG (user_data);
|
||||
const char *path;
|
||||
|
||||
path = nm_ifcfg_connection_get_path (connection);
|
||||
path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection));
|
||||
g_return_if_fail (path != NULL);
|
||||
|
||||
connection_new_or_changed (plugin, path, connection, NULL);
|
||||
|
|
@ -202,14 +202,14 @@ find_by_path (SCPluginIfcfg *self, const char *path)
|
|||
{
|
||||
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (self);
|
||||
GHashTableIter iter;
|
||||
NMIfcfgConnection *candidate = NULL;
|
||||
NMSettingsConnection *candidate = NULL;
|
||||
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
|
||||
g_hash_table_iter_init (&iter, priv->connections);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) {
|
||||
if (g_strcmp0 (path, nm_ifcfg_connection_get_path (candidate)) == 0)
|
||||
return candidate;
|
||||
if (g_strcmp0 (path, nm_settings_connection_get_filename (candidate)) == 0)
|
||||
return NM_IFCFG_CONNECTION (candidate);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -252,11 +252,11 @@ connection_new_or_changed (SCPluginIfcfg *self,
|
|||
/* See if it's a rename */
|
||||
existing = find_by_uuid_from_path (self, path);
|
||||
if (existing) {
|
||||
const char *old_path = nm_ifcfg_connection_get_path (existing);
|
||||
const char *old_path = nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (existing));
|
||||
nm_log_info (LOGD_SETTINGS, "renaming %s -> %s", old_path, path);
|
||||
if (out_old_path)
|
||||
*out_old_path = g_strdup (old_path);
|
||||
nm_ifcfg_connection_set_path (existing, path);
|
||||
nm_settings_connection_set_filename (NM_SETTINGS_CONNECTION (existing), path);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -440,7 +440,7 @@ read_connections (SCPluginIfcfg *plugin)
|
|||
oldconns = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
g_hash_table_iter_init (&iter, priv->connections);
|
||||
while (g_hash_table_iter_next (&iter, NULL, &value)) {
|
||||
const char *ifcfg_path = nm_ifcfg_connection_get_path (value);
|
||||
const char *ifcfg_path = nm_settings_connection_get_filename (value);
|
||||
if (ifcfg_path)
|
||||
g_hash_table_insert (oldconns, g_strdup (ifcfg_path), value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,19 +36,12 @@
|
|||
|
||||
G_DEFINE_TYPE (NMKeyfileConnection, nm_keyfile_connection, NM_TYPE_SETTINGS_CONNECTION)
|
||||
|
||||
#define NM_KEYFILE_CONNECTION_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_KEYFILE_CONNECTION, NMKeyfileConnectionPrivate))
|
||||
|
||||
typedef struct {
|
||||
char *path;
|
||||
} NMKeyfileConnectionPrivate;
|
||||
|
||||
NMKeyfileConnection *
|
||||
nm_keyfile_connection_new (NMConnection *source,
|
||||
const char *full_path,
|
||||
GError **error)
|
||||
{
|
||||
GObject *object;
|
||||
NMKeyfileConnectionPrivate *priv;
|
||||
NMConnection *tmp;
|
||||
const char *uuid;
|
||||
gboolean update_unsaved = TRUE;
|
||||
|
|
@ -75,10 +68,9 @@ nm_keyfile_connection_new (NMConnection *source,
|
|||
update_unsaved = FALSE;
|
||||
}
|
||||
|
||||
object = (GObject *) g_object_new (NM_TYPE_KEYFILE_CONNECTION, NULL);
|
||||
|
||||
priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (object);
|
||||
priv->path = g_strdup (full_path);
|
||||
object = (GObject *) g_object_new (NM_TYPE_KEYFILE_CONNECTION,
|
||||
NM_SETTINGS_CONNECTION_FILENAME, full_path,
|
||||
NULL);
|
||||
|
||||
/* Update our settings with what was read from the file */
|
||||
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (object),
|
||||
|
|
@ -93,38 +85,16 @@ nm_keyfile_connection_new (NMConnection *source,
|
|||
return (NMKeyfileConnection *) object;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_keyfile_connection_get_path (NMKeyfileConnection *self)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_KEYFILE_CONNECTION (self), NULL);
|
||||
|
||||
return NM_KEYFILE_CONNECTION_GET_PRIVATE (self)->path;
|
||||
}
|
||||
|
||||
void
|
||||
nm_keyfile_connection_set_path (NMKeyfileConnection *self, const char *path)
|
||||
{
|
||||
NMKeyfileConnectionPrivate *priv;
|
||||
|
||||
g_return_if_fail (NM_IS_KEYFILE_CONNECTION (self));
|
||||
g_return_if_fail (path != NULL);
|
||||
|
||||
priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (self);
|
||||
g_free (priv->path);
|
||||
priv->path = g_strdup (path);
|
||||
}
|
||||
|
||||
static void
|
||||
commit_changes (NMSettingsConnection *connection,
|
||||
NMSettingsConnectionCommitFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMKeyfileConnectionPrivate *priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (connection);
|
||||
char *path = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
if (!nm_keyfile_plugin_write_connection (NM_CONNECTION (connection),
|
||||
priv->path,
|
||||
nm_settings_connection_get_filename (connection),
|
||||
&path,
|
||||
&error)) {
|
||||
callback (connection, error, user_data);
|
||||
|
|
@ -133,10 +103,8 @@ commit_changes (NMSettingsConnection *connection,
|
|||
}
|
||||
|
||||
/* Update the filename if it changed */
|
||||
if (path) {
|
||||
g_free (priv->path);
|
||||
priv->path = path;
|
||||
}
|
||||
if (path)
|
||||
nm_settings_connection_set_filename (connection, path);
|
||||
|
||||
NM_SETTINGS_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->commit_changes (connection,
|
||||
callback,
|
||||
|
|
@ -148,10 +116,11 @@ do_delete (NMSettingsConnection *connection,
|
|||
NMSettingsConnectionDeleteFunc callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
NMKeyfileConnectionPrivate *priv = NM_KEYFILE_CONNECTION_GET_PRIVATE (connection);
|
||||
const char *path;
|
||||
|
||||
if (priv->path)
|
||||
g_unlink (priv->path);
|
||||
path = nm_settings_connection_get_filename (connection);
|
||||
if (path)
|
||||
g_unlink (path);
|
||||
|
||||
NM_SETTINGS_CONNECTION_CLASS (nm_keyfile_connection_parent_class)->delete (connection,
|
||||
callback,
|
||||
|
|
@ -165,24 +134,12 @@ nm_keyfile_connection_init (NMKeyfileConnection *connection)
|
|||
{
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
g_free (NM_KEYFILE_CONNECTION_GET_PRIVATE (object)->path);
|
||||
|
||||
G_OBJECT_CLASS (nm_keyfile_connection_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_keyfile_connection_class_init (NMKeyfileConnectionClass *keyfile_connection_class)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (keyfile_connection_class);
|
||||
NMSettingsConnectionClass *settings_class = NM_SETTINGS_CONNECTION_CLASS (keyfile_connection_class);
|
||||
|
||||
g_type_class_add_private (keyfile_connection_class, sizeof (NMKeyfileConnectionPrivate));
|
||||
|
||||
/* Virtual methods */
|
||||
object_class->finalize = finalize;
|
||||
settings_class->commit_changes = commit_changes;
|
||||
settings_class->delete = do_delete;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,9 +47,6 @@ NMKeyfileConnection *nm_keyfile_connection_new (NMConnection *source,
|
|||
const char *filename,
|
||||
GError **error);
|
||||
|
||||
const char *nm_keyfile_connection_get_path (NMKeyfileConnection *self);
|
||||
void nm_keyfile_connection_set_path (NMKeyfileConnection *self, const char *path);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __NETWORKMANAGER_KEYFILE_CONNECTION_H__ */
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ remove_connection (SCPluginKeyfile *self, NMKeyfileConnection *connection)
|
|||
|
||||
g_return_if_fail (connection != NULL);
|
||||
|
||||
nm_log_info (LOGD_SETTINGS, "removed %s.", nm_keyfile_connection_get_path (connection));
|
||||
nm_log_info (LOGD_SETTINGS, "removed %s.", nm_settings_connection_get_filename (NM_SETTINGS_CONNECTION (connection)));
|
||||
|
||||
/* Removing from the hash table should drop the last reference */
|
||||
g_object_ref (connection);
|
||||
|
|
@ -139,14 +139,14 @@ find_by_path (SCPluginKeyfile *self, const char *path)
|
|||
{
|
||||
SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (self);
|
||||
GHashTableIter iter;
|
||||
NMKeyfileConnection *candidate = NULL;
|
||||
NMSettingsConnection *candidate = NULL;
|
||||
|
||||
g_return_val_if_fail (path != NULL, NULL);
|
||||
|
||||
g_hash_table_iter_init (&iter, priv->connections);
|
||||
while (g_hash_table_iter_next (&iter, NULL, (gpointer) &candidate)) {
|
||||
if (g_strcmp0 (path, nm_keyfile_connection_get_path (candidate)) == 0)
|
||||
return candidate;
|
||||
if (g_strcmp0 (path, nm_settings_connection_get_filename (candidate)) == 0)
|
||||
return NM_KEYFILE_CONNECTION (candidate);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -157,7 +157,8 @@ new_connection (SCPluginKeyfile *self,
|
|||
char **out_old_path)
|
||||
{
|
||||
SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (self);
|
||||
NMKeyfileConnection *tmp, *connection;
|
||||
NMKeyfileConnection *tmp;
|
||||
NMSettingsConnection *connection;
|
||||
GError *error = NULL;
|
||||
const char *uuid;
|
||||
|
||||
|
|
@ -176,8 +177,8 @@ new_connection (SCPluginKeyfile *self,
|
|||
uuid = nm_connection_get_uuid (NM_CONNECTION (tmp));
|
||||
connection = g_hash_table_lookup (priv->connections, uuid);
|
||||
if (connection) {
|
||||
nm_log_info (LOGD_SETTINGS, "rename %s -> %s", nm_keyfile_connection_get_path (connection), name);
|
||||
if (!nm_settings_connection_replace_settings (NM_SETTINGS_CONNECTION (connection),
|
||||
nm_log_info (LOGD_SETTINGS, "rename %s -> %s", nm_settings_connection_get_filename (connection), name);
|
||||
if (!nm_settings_connection_replace_settings (connection,
|
||||
NM_CONNECTION (tmp),
|
||||
FALSE, /* don't set Unsaved */
|
||||
&error)) {
|
||||
|
|
@ -186,8 +187,8 @@ new_connection (SCPluginKeyfile *self,
|
|||
}
|
||||
g_object_unref (tmp);
|
||||
if (out_old_path)
|
||||
*out_old_path = g_strdup (nm_keyfile_connection_get_path (connection));
|
||||
nm_keyfile_connection_set_path (connection, name);
|
||||
*out_old_path = g_strdup (nm_settings_connection_get_filename (connection));
|
||||
nm_settings_connection_set_filename (connection, name);
|
||||
} else {
|
||||
nm_log_info (LOGD_SETTINGS, "new connection %s", name);
|
||||
g_hash_table_insert (priv->connections, g_strdup (uuid), tmp);
|
||||
|
|
@ -330,7 +331,7 @@ read_connections (NMSystemConfigInterface *config)
|
|||
oldconns = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
g_hash_table_iter_init (&iter, priv->connections);
|
||||
while (g_hash_table_iter_next (&iter, NULL, &data)) {
|
||||
const char *con_path = nm_keyfile_connection_get_path (data);
|
||||
const char *con_path = nm_settings_connection_get_filename (data);
|
||||
if (con_path)
|
||||
g_hash_table_insert (oldconns, g_strdup (con_path), data);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue