mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-10 03:10:39 +01:00
nm-sysconfig-settings: remove "bus" property
NMSysconfigSettings inherited the "bus" property from NMSettingsService. The property was originally created to allow us to specify what DBus connection to use, which was important in the days of user settings services. Now, however, the daemon is the only thing that has a settings service, and so we can trim a bit of clutter by removing this property and using NMDBusManager directly.
This commit is contained in:
parent
7f8dc06dff
commit
f8a92d44cb
3 changed files with 10 additions and 60 deletions
|
|
@ -2983,7 +2983,6 @@ nm_manager_get (const char *config_file,
|
|||
{
|
||||
static NMManager *singleton = NULL;
|
||||
NMManagerPrivate *priv;
|
||||
DBusGConnection *bus;
|
||||
|
||||
if (singleton)
|
||||
return g_object_ref (singleton);
|
||||
|
|
@ -2993,10 +2992,7 @@ nm_manager_get (const char *config_file,
|
|||
|
||||
priv = NM_MANAGER_GET_PRIVATE (singleton);
|
||||
|
||||
bus = nm_dbus_manager_get_connection (priv->dbus_mgr);
|
||||
g_assert (bus);
|
||||
|
||||
priv->sys_settings = nm_sysconfig_settings_new (config_file, plugins, bus, error);
|
||||
priv->sys_settings = nm_sysconfig_settings_new (config_file, plugins, error);
|
||||
if (!priv->sys_settings) {
|
||||
g_object_unref (singleton);
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@
|
|||
#include "nm-system-config-error.h"
|
||||
#include "nm-default-wired-connection.h"
|
||||
#include "nm-logging.h"
|
||||
#include "nm-dbus-manager.h"
|
||||
|
||||
#define CONFIG_KEY_NO_AUTO_DEFAULT "no-auto-default"
|
||||
|
||||
|
|
@ -131,7 +132,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
|||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_BUS,
|
||||
PROP_UNMANAGED_SPECS,
|
||||
PROP_HOSTNAME,
|
||||
PROP_CAN_MODIFY,
|
||||
|
|
@ -540,16 +540,14 @@ connection_removed (NMSysconfigConnection *connection,
|
|||
}
|
||||
|
||||
static void
|
||||
export_connection (NMSysconfigSettings *self,
|
||||
NMSysconfigConnection *connection)
|
||||
export_connection (NMSysconfigConnection *connection)
|
||||
{
|
||||
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
|
||||
DBusGConnection *bus;
|
||||
static guint32 ec_counter = 0;
|
||||
char *path;
|
||||
|
||||
g_return_if_fail (connection != NULL);
|
||||
g_return_if_fail (NM_IS_SYSCONFIG_CONNECTION (connection));
|
||||
g_return_if_fail (priv->bus != NULL);
|
||||
|
||||
/* Don't allow exporting twice */
|
||||
g_return_if_fail (nm_connection_get_path (NM_CONNECTION (connection)) == NULL);
|
||||
|
|
@ -557,7 +555,8 @@ export_connection (NMSysconfigSettings *self,
|
|||
path = g_strdup_printf ("%s/%u", NM_DBUS_PATH_SETTINGS, ec_counter++);
|
||||
nm_connection_set_path (NM_CONNECTION (connection), path);
|
||||
|
||||
dbus_g_connection_register_g_object (priv->bus, path, G_OBJECT (connection));
|
||||
bus = nm_dbus_manager_get_connection (nm_dbus_manager_get ());
|
||||
dbus_g_connection_register_g_object (bus, path, G_OBJECT (connection));
|
||||
g_free (path);
|
||||
}
|
||||
|
||||
|
|
@ -582,7 +581,7 @@ claim_connection (NMSysconfigSettings *self,
|
|||
self);
|
||||
|
||||
if (do_export) {
|
||||
export_connection (self, connection);
|
||||
export_connection (connection);
|
||||
g_signal_emit (self, signals[NEW_CONNECTION], 0, connection);
|
||||
}
|
||||
}
|
||||
|
|
@ -1352,18 +1351,18 @@ static void
|
|||
export_sysconfig (NMSysconfigSettings *self)
|
||||
{
|
||||
NMSysconfigSettingsPrivate *priv;
|
||||
DBusGConnection *bus;
|
||||
|
||||
g_return_if_fail (self != NULL);
|
||||
g_return_if_fail (NM_IS_SYSCONFIG_SETTINGS (self));
|
||||
|
||||
priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
|
||||
|
||||
g_return_if_fail (priv->bus != NULL);
|
||||
|
||||
/* Don't allow exporting twice */
|
||||
g_return_if_fail (priv->exported == FALSE);
|
||||
|
||||
dbus_g_connection_register_g_object (priv->bus,
|
||||
bus = nm_dbus_manager_get_connection (nm_dbus_manager_get ());
|
||||
dbus_g_connection_register_g_object (bus,
|
||||
NM_DBUS_PATH_SETTINGS,
|
||||
G_OBJECT (self));
|
||||
priv->exported = TRUE;
|
||||
|
|
@ -1372,14 +1371,12 @@ export_sysconfig (NMSysconfigSettings *self)
|
|||
NMSysconfigSettings *
|
||||
nm_sysconfig_settings_new (const char *config_file,
|
||||
const char *plugins,
|
||||
DBusGConnection *bus,
|
||||
GError **error)
|
||||
{
|
||||
NMSysconfigSettings *self;
|
||||
NMSysconfigSettingsPrivate *priv;
|
||||
|
||||
self = g_object_new (NM_TYPE_SYSCONFIG_SETTINGS,
|
||||
NM_SYSCONFIG_SETTINGS_BUS, bus,
|
||||
NULL);
|
||||
if (!self)
|
||||
return NULL;
|
||||
|
|
@ -1436,9 +1433,6 @@ dispose (GObject *object)
|
|||
g_slist_free (priv->permissions_calls);
|
||||
priv->permissions_calls = NULL;
|
||||
|
||||
if (priv->bus)
|
||||
dbus_g_connection_unref (priv->bus);
|
||||
|
||||
G_OBJECT_CLASS (nm_sysconfig_settings_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
|
|
@ -1460,39 +1454,15 @@ finalize (GObject *object)
|
|||
G_OBJECT_CLASS (nm_sysconfig_settings_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (object);
|
||||
DBusGConnection *bus;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_BUS:
|
||||
/* Construct only */
|
||||
bus = g_value_get_boxed (value);
|
||||
if (bus)
|
||||
priv->bus = dbus_g_connection_ref (bus);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSysconfigSettings *self = NM_SYSCONFIG_SETTINGS (object);
|
||||
NMSysconfigSettingsPrivate *priv = NM_SYSCONFIG_SETTINGS_GET_PRIVATE (self);
|
||||
const GSList *specs, *iter;
|
||||
GSList *copy = NULL;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_BUS:
|
||||
g_value_set_boxed (value, priv->bus);
|
||||
break;
|
||||
case PROP_UNMANAGED_SPECS:
|
||||
specs = nm_sysconfig_settings_get_unmanaged_specs (self);
|
||||
for (iter = specs; iter; iter = g_slist_next (iter))
|
||||
|
|
@ -1524,26 +1494,12 @@ nm_sysconfig_settings_class_init (NMSysconfigSettingsClass *class)
|
|||
|
||||
/* virtual methods */
|
||||
object_class->notify = notify;
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
/* properties */
|
||||
|
||||
/**
|
||||
* NMSysconfigSettings:bus:
|
||||
*
|
||||
* The %DBusGConnection which this object is exported on
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BUS,
|
||||
g_param_spec_boxed (NM_SYSCONFIG_SETTINGS_BUS,
|
||||
"Bus",
|
||||
"Bus",
|
||||
DBUS_TYPE_G_CONNECTION,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_UNMANAGED_SPECS,
|
||||
g_param_spec_boxed (NM_SYSCONFIG_SETTINGS_UNMANAGED_SPECS,
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ typedef enum {
|
|||
#define NM_IS_SYSCONFIG_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SYSCONFIG_SETTINGS))
|
||||
#define NM_SYSCONFIG_SETTINGS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SYSCONFIG_SETTINGS, NMSysconfigSettingsClass))
|
||||
|
||||
#define NM_SYSCONFIG_SETTINGS_BUS "bus"
|
||||
#define NM_SYSCONFIG_SETTINGS_UNMANAGED_SPECS "unmanaged-specs"
|
||||
#define NM_SYSCONFIG_SETTINGS_HOSTNAME "hostname"
|
||||
#define NM_SYSCONFIG_SETTINGS_CAN_MODIFY "can-modify"
|
||||
|
|
@ -71,7 +70,6 @@ GType nm_sysconfig_settings_get_type (void);
|
|||
|
||||
NMSysconfigSettings *nm_sysconfig_settings_new (const char *config_file,
|
||||
const char *plugins,
|
||||
DBusGConnection *bus,
|
||||
GError **error);
|
||||
|
||||
/* Returns a list of NMSysconfigConnections */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue