mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-14 09:00:24 +01:00
settings: let NMSettings reference NMManager
NMSettings needs access to the list of all devices, which is tracked
by NMManager. Of course, this ties NMSettings and NMManager closer
together. Note that NMManager already owns a reference to NMSettings,
so they are in fact related.
The alternatives of just letting NMSettings reference NMManager (and
vice versa) would be more complicated, and likely not help to simplify
the code (on the contrary).
(cherry picked from commit d27a6055b9)
This commit is contained in:
parent
61e0b949b3
commit
1745b4e0c0
3 changed files with 45 additions and 4 deletions
|
|
@ -7455,7 +7455,7 @@ constructed (GObject *object)
|
|||
|
||||
G_OBJECT_CLASS (nm_manager_parent_class)->constructed (object);
|
||||
|
||||
priv->settings = nm_settings_new ();
|
||||
priv->settings = nm_settings_new (self);
|
||||
|
||||
nm_dbus_object_export (NM_DBUS_OBJECT (priv->settings));
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@
|
|||
#include "plugins/keyfile/nms-keyfile-storage.h"
|
||||
#include "nm-agent-manager.h"
|
||||
#include "nm-config.h"
|
||||
#include "nm-manager.h"
|
||||
#include "nm-audit-manager.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-dispatcher.h"
|
||||
|
|
@ -324,6 +325,7 @@ _sett_conn_entry_find_shadowed_storage (SettConnEntry *sett_conn_entry,
|
|||
/*****************************************************************************/
|
||||
|
||||
NM_GOBJECT_PROPERTIES_DEFINE (NMSettings,
|
||||
PROP_MANAGER,
|
||||
PROP_UNMANAGED_SPECS,
|
||||
PROP_HOSTNAME,
|
||||
PROP_CAN_MODIFY,
|
||||
|
|
@ -348,6 +350,8 @@ typedef struct {
|
|||
|
||||
NMPlatform *platform;
|
||||
|
||||
NMManager *manager;
|
||||
|
||||
NMHostnameManager *hostname_manager;
|
||||
|
||||
NMSessionMonitor *session_monitor;
|
||||
|
|
@ -3805,6 +3809,26 @@ get_property (GObject *object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettings *self = NM_SETTINGS (object);
|
||||
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MANAGER:
|
||||
/* construct-only */
|
||||
priv->manager = g_value_get_pointer (value);
|
||||
nm_assert (NM_IS_MANAGER (priv->manager));
|
||||
g_object_add_weak_pointer (G_OBJECT (priv->manager), (gpointer *) &priv->manager);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
|
|
@ -3833,9 +3857,13 @@ nm_settings_init (NMSettings *self)
|
|||
}
|
||||
|
||||
NMSettings *
|
||||
nm_settings_new (void)
|
||||
nm_settings_new (NMManager *manager)
|
||||
{
|
||||
return g_object_new (NM_TYPE_SETTINGS, NULL);
|
||||
nm_assert (NM_IS_MANAGER (manager));
|
||||
|
||||
return g_object_new (NM_TYPE_SETTINGS,
|
||||
NM_SETTINGS_MANAGER, manager,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3915,6 +3943,11 @@ finalize (GObject *object)
|
|||
g_clear_object (&priv->config);
|
||||
|
||||
g_clear_object (&priv->platform);
|
||||
|
||||
if (priv->manager) {
|
||||
g_object_remove_weak_pointer (G_OBJECT (priv->manager), (gpointer *) &priv->manager);
|
||||
priv->manager = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static const GDBusSignalInfo signal_info_new_connection = NM_DEFINE_GDBUS_SIGNAL_INFO_INIT (
|
||||
|
|
@ -4051,9 +4084,16 @@ nm_settings_class_init (NMSettingsClass *class)
|
|||
dbus_object_class->interface_infos = NM_DBUS_INTERFACE_INFOS (&interface_info_settings);
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
obj_properties[PROP_MANAGER] =
|
||||
g_param_spec_pointer (NM_SETTINGS_MANAGER, "", "",
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_WRITABLE |
|
||||
G_PARAM_STATIC_STRINGS);
|
||||
|
||||
obj_properties[PROP_UNMANAGED_SPECS] =
|
||||
g_param_spec_boxed (NM_SETTINGS_UNMANAGED_SPECS, "", "",
|
||||
G_TYPE_STRV,
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#define NM_SETTINGS_CAN_MODIFY "can-modify"
|
||||
#define NM_SETTINGS_CONNECTIONS "connections"
|
||||
#define NM_SETTINGS_STARTUP_COMPLETE "startup-complete"
|
||||
#define NM_SETTINGS_MANAGER "manager"
|
||||
|
||||
#define NM_SETTINGS_SIGNAL_CONNECTION_ADDED "connection-added"
|
||||
#define NM_SETTINGS_SIGNAL_CONNECTION_UPDATED "connection-updated"
|
||||
|
|
@ -53,7 +54,7 @@ GType nm_settings_get_type (void);
|
|||
NMSettings *nm_settings_get (void);
|
||||
#define NM_SETTINGS_GET (nm_settings_get ())
|
||||
|
||||
NMSettings *nm_settings_new (void);
|
||||
NMSettings *nm_settings_new (NMManager *manager);
|
||||
|
||||
gboolean nm_settings_start (NMSettings *self, GError **error);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue