mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-03-25 04:50:37 +01:00
core: merge branch 'th/singleton-cleanup-bgo753519'
Some cleanup for singleton instances and fix some leaks during shutdown. https://bugzilla.gnome.org/show_bug.cgi?id=753519
This commit is contained in:
commit
f0bca9ed7b
20 changed files with 215 additions and 168 deletions
|
|
@ -133,7 +133,7 @@ _nm_singleton_instance_destroy (void)
|
|||
g_object_weak_unref (instance, _nm_singleton_instance_weak_cb, NULL);
|
||||
|
||||
if (instance->ref_count > 1)
|
||||
nm_log_dbg (LOGD_CORE, "disown %s singleton (%p). There are more references and the instance might leak", G_OBJECT_TYPE_NAME (instance), instance);
|
||||
nm_log_dbg (LOGD_CORE, "disown %s singleton (%p)", G_OBJECT_TYPE_NAME (instance), instance);
|
||||
|
||||
g_object_unref (instance);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,6 +76,17 @@ GETTER (void) \
|
|||
return singleton_instance; \
|
||||
}
|
||||
|
||||
/* attach @instance to the data or @owner. @owner owns a reference
|
||||
* to @instance thus the lifetime of @instance is at least as long
|
||||
* as that of @owner. Use this when @owner depends on @instance. */
|
||||
#define NM_UTILS_KEEP_ALIVE(owner, instance, unique_token) \
|
||||
G_STMT_START { \
|
||||
g_object_set_data_full (G_OBJECT (owner), \
|
||||
".nm-utils-keep-alive-" unique_token "", \
|
||||
g_object_ref (instance), \
|
||||
g_object_unref); \
|
||||
} G_STMT_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean nm_ethernet_address_is_valid (gconstpointer addr, gssize len);
|
||||
|
|
|
|||
|
|
@ -9103,6 +9103,8 @@ constructed (GObject *object)
|
|||
}
|
||||
|
||||
G_OBJECT_CLASS (nm_device_parent_class)->constructed (object);
|
||||
|
||||
_LOGD (LOGD_DEVICE, "constructed (%s)", G_OBJECT_TYPE_NAME (self));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -9112,7 +9114,7 @@ dispose (GObject *object)
|
|||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
NMPlatform *platform;
|
||||
|
||||
_LOGD (LOGD_DEVICE, "dispose(): %s", G_OBJECT_TYPE_NAME (self));
|
||||
_LOGD (LOGD_DEVICE, "disposing");
|
||||
|
||||
g_signal_handlers_disconnect_by_func (nm_config_get (), config_changed_update_ignore_carrier, self);
|
||||
|
||||
|
|
|
|||
38
src/main.c
38
src/main.c
|
|
@ -79,17 +79,15 @@ parse_state_file (const char *filename,
|
|||
gboolean *net_enabled,
|
||||
gboolean *wifi_enabled,
|
||||
gboolean *wwan_enabled,
|
||||
gboolean *wimax_enabled,
|
||||
GError **error)
|
||||
{
|
||||
GKeyFile *state_file;
|
||||
GError *tmp_error = NULL;
|
||||
gboolean wifi, net, wwan, wimax;
|
||||
gboolean wifi, net, wwan;
|
||||
|
||||
g_return_val_if_fail (net_enabled != NULL, FALSE);
|
||||
g_return_val_if_fail (wifi_enabled != NULL, FALSE);
|
||||
g_return_val_if_fail (wwan_enabled != NULL, FALSE);
|
||||
g_return_val_if_fail (wimax_enabled != NULL, FALSE);
|
||||
|
||||
state_file = g_key_file_new ();
|
||||
g_key_file_set_list_separator (state_file, ',');
|
||||
|
|
@ -111,7 +109,6 @@ parse_state_file (const char *filename,
|
|||
g_key_file_set_boolean (state_file, "main", "NetworkingEnabled", *net_enabled);
|
||||
g_key_file_set_boolean (state_file, "main", "WirelessEnabled", *wifi_enabled);
|
||||
g_key_file_set_boolean (state_file, "main", "WWANEnabled", *wwan_enabled);
|
||||
g_key_file_set_boolean (state_file, "main", "WimaxEnabled", *wimax_enabled);
|
||||
|
||||
data = g_key_file_to_data (state_file, &len, NULL);
|
||||
if (data)
|
||||
|
|
@ -143,11 +140,6 @@ parse_state_file (const char *filename,
|
|||
*wwan_enabled = wwan;
|
||||
g_clear_error (&tmp_error);
|
||||
|
||||
wimax = g_key_file_get_boolean (state_file, "main", "WimaxEnabled", &tmp_error);
|
||||
if (tmp_error == NULL)
|
||||
*wimax_enabled = wimax;
|
||||
g_clear_error (&tmp_error);
|
||||
|
||||
g_key_file_free (state_file);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -255,9 +247,8 @@ do_early_setup (int *argc, char **argv[], NMConfigCmdLineOptions *config_cli)
|
|||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
gboolean wifi_enabled = TRUE, net_enabled = TRUE, wwan_enabled = TRUE, wimax_enabled = TRUE;
|
||||
gboolean wifi_enabled = TRUE, net_enabled = TRUE, wwan_enabled = TRUE;
|
||||
gboolean success = FALSE;
|
||||
NMManager *manager = NULL;
|
||||
NMConfig *config;
|
||||
GError *error = NULL;
|
||||
gboolean wrote_pidfile = FALSE;
|
||||
|
|
@ -389,7 +380,7 @@ main (int argc, char *argv[])
|
|||
nm_log_info (LOGD_CORE, "NetworkManager (version " NM_DIST_VERSION ") is starting...");
|
||||
|
||||
/* Parse the state file */
|
||||
if (!parse_state_file (global_opt.state_file, &net_enabled, &wifi_enabled, &wwan_enabled, &wimax_enabled, &error)) {
|
||||
if (!parse_state_file (global_opt.state_file, &net_enabled, &wifi_enabled, &wwan_enabled, &error)) {
|
||||
nm_log_err (LOGD_CORE, "State file %s parsing failed: (%d) %s",
|
||||
global_opt.state_file,
|
||||
error ? error->code : -1,
|
||||
|
|
@ -410,11 +401,10 @@ main (int argc, char *argv[])
|
|||
|
||||
nm_auth_manager_setup (nm_config_get_auth_polkit (config));
|
||||
|
||||
manager = nm_manager_setup (global_opt.state_file,
|
||||
net_enabled,
|
||||
wifi_enabled,
|
||||
wwan_enabled,
|
||||
wimax_enabled);
|
||||
nm_manager_setup (global_opt.state_file,
|
||||
net_enabled,
|
||||
wifi_enabled,
|
||||
wwan_enabled);
|
||||
|
||||
if (!nm_bus_manager_get_connection (nm_bus_manager_get ())) {
|
||||
nm_log_warn (LOGD_CORE, "Failed to connect to D-Bus; only private bus is available");
|
||||
|
|
@ -429,17 +419,13 @@ main (int argc, char *argv[])
|
|||
/* Set up platform interaction layer */
|
||||
nm_linux_platform_setup ();
|
||||
|
||||
/* FIXME: intentionally leak the singleton instance of NMPlatform.
|
||||
* nm_linux_platform_setup() will register the singleton for destruction,
|
||||
* but we don't yet shut down all singletons properly, so don't destroy
|
||||
* NMPlatform. */
|
||||
g_object_ref (NM_PLATFORM_GET);
|
||||
NM_UTILS_KEEP_ALIVE (config, NM_PLATFORM_GET, "NMConfig-depends-on-NMPlatform");
|
||||
|
||||
nm_dispatcher_init ();
|
||||
|
||||
g_signal_connect (manager, NM_MANAGER_CONFIGURE_QUIT, G_CALLBACK (manager_configure_quit), config);
|
||||
g_signal_connect (nm_manager_get (), NM_MANAGER_CONFIGURE_QUIT, G_CALLBACK (manager_configure_quit), config);
|
||||
|
||||
if (!nm_manager_start (manager, &error)) {
|
||||
if (!nm_manager_start (nm_manager_get (), &error)) {
|
||||
nm_log_err (LOGD_CORE, "failed to initialize: %s", error->message);
|
||||
goto done;
|
||||
}
|
||||
|
|
@ -462,11 +448,9 @@ main (int argc, char *argv[])
|
|||
if (configure_and_quit == FALSE)
|
||||
g_main_loop_run (main_loop);
|
||||
|
||||
nm_manager_stop (manager);
|
||||
nm_manager_stop (nm_manager_get ());
|
||||
|
||||
done:
|
||||
g_clear_object (&manager);
|
||||
|
||||
if (global_opt.pidfile && wrote_pidfile)
|
||||
unlink (global_opt.pidfile);
|
||||
|
||||
|
|
|
|||
|
|
@ -104,6 +104,46 @@ static void _device_cleanup (NMActiveConnection *self);
|
|||
|
||||
/****************************************************************/
|
||||
|
||||
#define _LOG_DOMAIN LOGD_DEVICE
|
||||
#define _LOG_PREFIX_NAME "active-connection"
|
||||
|
||||
#define _LOG(level, domain, self, ...) \
|
||||
G_STMT_START { \
|
||||
const NMLogLevel __level = (level); \
|
||||
const NMLogDomain __domain = (domain); \
|
||||
\
|
||||
if (nm_logging_enabled (__level, __domain)) { \
|
||||
char __prefix[128]; \
|
||||
const char *__p_prefix = _LOG_PREFIX_NAME; \
|
||||
const void *const __self = (self); \
|
||||
\
|
||||
if (__self) { \
|
||||
g_snprintf (__prefix, sizeof (__prefix), "%s[%p]", _LOG_PREFIX_NAME, __self); \
|
||||
__p_prefix = __prefix; \
|
||||
} \
|
||||
_nm_log (__level, __domain, 0, \
|
||||
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
__p_prefix _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
|
||||
} \
|
||||
} G_STMT_END
|
||||
#define _LOG_LEVEL_ENABLED(level, domain) \
|
||||
( nm_logging_enabled ((level), (domain)) )
|
||||
|
||||
#ifdef NM_MORE_LOGGING
|
||||
#define _LOGT_ENABLED() _LOG_LEVEL_ENABLED (LOGL_TRACE, _LOG_DOMAIN)
|
||||
#define _LOGT(...) _LOG (LOGL_TRACE, _LOG_DOMAIN, self, __VA_ARGS__)
|
||||
#else
|
||||
#define _LOGT_ENABLED() FALSE
|
||||
#define _LOGT(...) G_STMT_START { if (FALSE) { _LOG (LOGL_TRACE, _LOG_DOMAIN, self, __VA_ARGS__); } } G_STMT_END
|
||||
#endif
|
||||
|
||||
#define _LOGD(...) _LOG (LOGL_DEBUG, _LOG_DOMAIN, self, __VA_ARGS__)
|
||||
#define _LOGI(...) _LOG (LOGL_INFO , _LOG_DOMAIN, self, __VA_ARGS__)
|
||||
#define _LOGW(...) _LOG (LOGL_WARN , _LOG_DOMAIN, self, __VA_ARGS__)
|
||||
#define _LOGE(...) _LOG (LOGL_ERR , _LOG_DOMAIN, self, __VA_ARGS__)
|
||||
|
||||
/****************************************************************/
|
||||
|
||||
static const char *
|
||||
state_to_string (NMActiveConnectionState state)
|
||||
{
|
||||
|
|
@ -464,15 +504,15 @@ check_master_ready (NMActiveConnection *self)
|
|||
NMActiveConnectionState master_state = NM_ACTIVE_CONNECTION_STATE_UNKNOWN;
|
||||
|
||||
if (priv->state != NM_ACTIVE_CONNECTION_STATE_ACTIVATING) {
|
||||
nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (not activating)", self);
|
||||
_LOGD ("not signalling master-ready (not activating)");
|
||||
return;
|
||||
}
|
||||
if (!priv->master) {
|
||||
nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (no master)", self);
|
||||
_LOGD ("not signalling master-ready (no master)");
|
||||
return;
|
||||
}
|
||||
if (priv->master_ready) {
|
||||
nm_log_dbg (LOGD_DEVICE, "(%p): not signalling master-ready (already signaled)", self);
|
||||
_LOGD ("not signalling master-ready (already signaled)");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -482,12 +522,12 @@ check_master_ready (NMActiveConnection *self)
|
|||
* or higher states.
|
||||
*/
|
||||
master_state = nm_active_connection_get_state (priv->master);
|
||||
nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection [%p] state now '%s' (%d)",
|
||||
self, priv->master, state_to_string (master_state), master_state);
|
||||
_LOGD ("master ActiveConnection [%p] state now '%s' (%d)",
|
||||
priv->master, state_to_string (master_state), master_state);
|
||||
|
||||
if ( master_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATING
|
||||
|| master_state == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
||||
nm_log_dbg (LOGD_DEVICE, "(%p): signalling master-ready", self);
|
||||
_LOGD ("signalling master-ready");
|
||||
|
||||
priv->master_ready = TRUE;
|
||||
g_object_notify (G_OBJECT (self), NM_ACTIVE_CONNECTION_INT_MASTER_READY);
|
||||
|
|
@ -511,8 +551,8 @@ master_state_cb (NMActiveConnection *master,
|
|||
|
||||
check_master_ready (self);
|
||||
|
||||
nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection [%p] state now '%s' (%d)",
|
||||
self, master, state_to_string (master_state), master_state);
|
||||
_LOGD ("master ActiveConnection [%p] state now '%s' (%d)",
|
||||
master, state_to_string (master_state), master_state);
|
||||
|
||||
if ( master_state >= NM_ACTIVE_CONNECTION_STATE_DEACTIVATING
|
||||
&& !priv->master_ready) {
|
||||
|
|
@ -549,8 +589,8 @@ nm_active_connection_set_master (NMActiveConnection *self, NMActiveConnection *m
|
|||
g_return_if_fail (priv->device != nm_active_connection_get_device (master));
|
||||
}
|
||||
|
||||
nm_log_dbg (LOGD_DEVICE, "(%p): master ActiveConnection is [%p] %s",
|
||||
self, master, nm_active_connection_get_id (master));
|
||||
_LOGD ("master ActiveConnection is [%p] %s",
|
||||
master, nm_active_connection_get_id (master));
|
||||
|
||||
priv->master = g_object_ref (master);
|
||||
g_signal_connect (priv->master,
|
||||
|
|
@ -694,8 +734,12 @@ nm_active_connection_init (NMActiveConnection *self)
|
|||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
NMActiveConnection *self = (NMActiveConnection *) object;
|
||||
|
||||
G_OBJECT_CLASS (nm_active_connection_parent_class)->constructed (object);
|
||||
g_assert (NM_ACTIVE_CONNECTION_GET_PRIVATE (object)->subject);
|
||||
|
||||
_LOGD ("constructed (%s)", G_OBJECT_TYPE_NAME (self));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -847,6 +891,8 @@ dispose (GObject *object)
|
|||
NMActiveConnection *self = NM_ACTIVE_CONNECTION (object);
|
||||
NMActiveConnectionPrivate *priv = NM_ACTIVE_CONNECTION_GET_PRIVATE (self);
|
||||
|
||||
_LOGD ("disposing");
|
||||
|
||||
if (priv->chain) {
|
||||
nm_auth_chain_unref (priv->chain);
|
||||
priv->chain = NULL;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@
|
|||
#include "nm-config.h"
|
||||
#include "nm-audit-manager.h"
|
||||
#include "nm-dbus-compat.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
#include "nmdbus-manager.h"
|
||||
|
||||
|
|
@ -4705,7 +4706,7 @@ dbus_connection_changed_cb (NMBusManager *dbus_mgr,
|
|||
|
||||
/**********************************************************************/
|
||||
|
||||
static NMManager *singleton_instance = NULL;
|
||||
NM_DEFINE_SINGLETON_REGISTER (NMManager);
|
||||
|
||||
NMManager *
|
||||
nm_manager_get (void)
|
||||
|
|
@ -4726,8 +4727,7 @@ NMManager *
|
|||
nm_manager_setup (const char *state_file,
|
||||
gboolean initial_net_enabled,
|
||||
gboolean initial_wifi_enabled,
|
||||
gboolean initial_wwan_enabled,
|
||||
gboolean initial_wimax_enabled)
|
||||
gboolean initial_wwan_enabled)
|
||||
{
|
||||
NMManager *self;
|
||||
NMManagerPrivate *priv;
|
||||
|
|
@ -4790,7 +4790,6 @@ nm_manager_setup (const char *state_file,
|
|||
|
||||
priv->radio_states[RFKILL_TYPE_WLAN].user_enabled = initial_wifi_enabled;
|
||||
priv->radio_states[RFKILL_TYPE_WWAN].user_enabled = initial_wwan_enabled;
|
||||
priv->radio_states[RFKILL_TYPE_WIMAX].user_enabled = initial_wimax_enabled;
|
||||
|
||||
nm_exported_object_export (NM_EXPORTED_OBJECT (self));
|
||||
|
||||
|
|
@ -4808,6 +4807,9 @@ nm_manager_setup (const char *state_file,
|
|||
rfkill_change (priv->radio_states[RFKILL_TYPE_WLAN].desc, RFKILL_TYPE_WLAN, initial_wifi_enabled);
|
||||
rfkill_change (priv->radio_states[RFKILL_TYPE_WWAN].desc, RFKILL_TYPE_WWAN, initial_wwan_enabled);
|
||||
|
||||
nm_singleton_instance_register ();
|
||||
nm_log_dbg (LOGD_CORE, "setup %s singleton (%p)", "NMManager", singleton_instance);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
@ -4835,13 +4837,6 @@ nm_manager_init (NMManager *manager)
|
|||
priv->radio_states[RFKILL_TYPE_WWAN].desc = "WWAN";
|
||||
priv->radio_states[RFKILL_TYPE_WWAN].rtype = RFKILL_TYPE_WWAN;
|
||||
|
||||
priv->radio_states[RFKILL_TYPE_WIMAX].user_enabled = TRUE;
|
||||
priv->radio_states[RFKILL_TYPE_WIMAX].key = "WimaxEnabled";
|
||||
priv->radio_states[RFKILL_TYPE_WIMAX].prop = NM_MANAGER_WIMAX_ENABLED;
|
||||
priv->radio_states[RFKILL_TYPE_WIMAX].hw_prop = NM_MANAGER_WIMAX_HARDWARE_ENABLED;
|
||||
priv->radio_states[RFKILL_TYPE_WIMAX].desc = "WiMAX";
|
||||
priv->radio_states[RFKILL_TYPE_WIMAX].rtype = RFKILL_TYPE_WIMAX;
|
||||
|
||||
for (i = 0; i < RFKILL_TYPE_MAX; i++)
|
||||
priv->radio_states[i].hw_enabled = TRUE;
|
||||
|
||||
|
|
@ -4928,10 +4923,10 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_boolean (value, priv->radio_states[RFKILL_TYPE_WWAN].hw_enabled);
|
||||
break;
|
||||
case PROP_WIMAX_ENABLED:
|
||||
g_value_set_boolean (value, radio_enabled_for_type (self, RFKILL_TYPE_WIMAX, TRUE));
|
||||
g_value_set_boolean (value, FALSE);
|
||||
break;
|
||||
case PROP_WIMAX_HARDWARE_ENABLED:
|
||||
g_value_set_boolean (value, priv->radio_states[RFKILL_TYPE_WIMAX].hw_enabled);
|
||||
g_value_set_boolean (value, FALSE);
|
||||
break;
|
||||
case PROP_ACTIVE_CONNECTIONS:
|
||||
nm_utils_g_value_set_object_path_array (value, priv->active_connections);
|
||||
|
|
@ -4990,9 +4985,7 @@ set_property (GObject *object, guint prop_id,
|
|||
g_value_get_boolean (value));
|
||||
break;
|
||||
case PROP_WIMAX_ENABLED:
|
||||
manager_radio_user_toggled (NM_MANAGER (object),
|
||||
&priv->radio_states[RFKILL_TYPE_WIMAX],
|
||||
g_value_get_boolean (value));
|
||||
/* WIMAX is depreacted. This does nothing. */
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
|
|||
|
|
@ -79,8 +79,7 @@ GType nm_manager_get_type (void);
|
|||
NMManager * nm_manager_setup (const char *state_file,
|
||||
gboolean initial_net_enabled,
|
||||
gboolean initial_wifi_enabled,
|
||||
gboolean initial_wwan_enabled,
|
||||
gboolean initial_wimax_enabled);
|
||||
gboolean initial_wwan_enabled);
|
||||
|
||||
NMManager * nm_manager_get (void);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@
|
|||
|
||||
typedef struct {
|
||||
NMManager *manager;
|
||||
NMFirewallManager *firewall_manager;
|
||||
guint update_state_id;
|
||||
GSList *pending_activation_checks;
|
||||
GSList *manager_ids;
|
||||
|
|
@ -1575,7 +1576,7 @@ firewall_update_zone (NMPolicy *policy, NMConnection *connection)
|
|||
if ( (nm_device_get_connection (dev) == connection)
|
||||
&& (nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED)
|
||||
&& !nm_device_uses_assumed_connection (dev)) {
|
||||
nm_firewall_manager_add_or_change_zone (nm_firewall_manager_get (),
|
||||
nm_firewall_manager_add_or_change_zone (priv->firewall_manager,
|
||||
nm_device_get_ip_iface (dev),
|
||||
nm_setting_connection_get_zone (s_con),
|
||||
FALSE, /* change zone */
|
||||
|
|
@ -1606,7 +1607,7 @@ firewall_started (NMFirewallManager *manager,
|
|||
s_con = nm_connection_get_setting_connection (connection);
|
||||
if ( nm_device_get_state (dev) == NM_DEVICE_STATE_ACTIVATED
|
||||
&& !nm_device_uses_assumed_connection (dev)) {
|
||||
nm_firewall_manager_add_or_change_zone (nm_firewall_manager_get (),
|
||||
nm_firewall_manager_add_or_change_zone (priv->firewall_manager,
|
||||
nm_device_get_ip_iface (dev),
|
||||
nm_setting_connection_get_zone (s_con),
|
||||
FALSE, /* still change zone */
|
||||
|
|
@ -1782,7 +1783,9 @@ nm_policy_new (NMManager *manager, NMSettings *settings)
|
|||
priv->orig_hostname = g_strdup (hostname);
|
||||
}
|
||||
|
||||
priv->fw_started_id = g_signal_connect (nm_firewall_manager_get (), "started",
|
||||
priv->firewall_manager = g_object_ref (nm_firewall_manager_get ());
|
||||
|
||||
priv->fw_started_id = g_signal_connect (priv->firewall_manager, "started",
|
||||
G_CALLBACK (firewall_started), policy);
|
||||
|
||||
priv->dns_manager = g_object_ref (nm_dns_manager_get ());
|
||||
|
|
@ -1889,9 +1892,11 @@ dispose (GObject *object)
|
|||
g_slist_free_full (priv->pending_secondaries, (GDestroyNotify) pending_secondary_data_free);
|
||||
priv->pending_secondaries = NULL;
|
||||
|
||||
if (priv->fw_started_id) {
|
||||
g_signal_handler_disconnect (nm_firewall_manager_get (), priv->fw_started_id);
|
||||
if (priv->firewall_manager) {
|
||||
g_assert (priv->fw_started_id);
|
||||
g_signal_handler_disconnect (priv->firewall_manager, priv->fw_started_id);
|
||||
priv->fw_started_id = 0;
|
||||
g_clear_object (&priv->firewall_manager);
|
||||
}
|
||||
|
||||
if (priv->dns_manager) {
|
||||
|
|
|
|||
|
|
@ -268,8 +268,6 @@ rfkill_type_to_enum (const char *str)
|
|||
return RFKILL_TYPE_WLAN;
|
||||
else if (!strcmp (str, "wwan"))
|
||||
return RFKILL_TYPE_WWAN;
|
||||
else if (!strcmp (str, "wimax"))
|
||||
return RFKILL_TYPE_WIMAX;
|
||||
|
||||
return RFKILL_TYPE_UNKNOWN;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ typedef enum {
|
|||
typedef enum {
|
||||
RFKILL_TYPE_WLAN = 0,
|
||||
RFKILL_TYPE_WWAN = 1,
|
||||
RFKILL_TYPE_WIMAX = 2,
|
||||
|
||||
/* UNKNOWN and MAX should always be 1 more than
|
||||
* the last rfkill type since RFKILL_TYPE_MAX is
|
||||
|
|
|
|||
|
|
@ -277,12 +277,11 @@ ck_finalize (NMSessionMonitor *monitor)
|
|||
|
||||
/********************************************************************/
|
||||
|
||||
NMSessionMonitor *nm_session_monitor_get(void);
|
||||
|
||||
NM_DEFINE_SINGLETON_GETTER (NMSessionMonitor, nm_session_monitor_get, NM_TYPE_SESSION_MONITOR);
|
||||
|
||||
/**
|
||||
* nm_session_monitor_connect:
|
||||
* @self: the session monitor
|
||||
* @callback: The callback.
|
||||
* @user_data: User data for the callback.
|
||||
*
|
||||
|
|
@ -291,9 +290,13 @@ NM_DEFINE_SINGLETON_GETTER (NMSessionMonitor, nm_session_monitor_get, NM_TYPE_SE
|
|||
* Returns: Handler ID to be used with nm_session_monitor_disconnect().
|
||||
*/
|
||||
gulong
|
||||
nm_session_monitor_connect (NMSessionCallback callback, gpointer user_data)
|
||||
nm_session_monitor_connect (NMSessionMonitor *self,
|
||||
NMSessionCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
return g_signal_connect (nm_session_monitor_get (),
|
||||
g_return_val_if_fail (NM_IS_SESSION_MONITOR (self), 0);
|
||||
|
||||
return g_signal_connect (self,
|
||||
NM_SESSION_MONITOR_CHANGED,
|
||||
G_CALLBACK (callback),
|
||||
user_data);
|
||||
|
|
@ -301,14 +304,18 @@ nm_session_monitor_connect (NMSessionCallback callback, gpointer user_data)
|
|||
|
||||
/**
|
||||
* nm_session_monitor_disconnect:
|
||||
* @self: the session monitor
|
||||
* @handler_id: Handler ID returned by nm_session_monitor-connect().
|
||||
*
|
||||
* Disconnect callback from the session handler.
|
||||
*/
|
||||
void
|
||||
nm_session_monitor_disconnect (gulong handler_id)
|
||||
nm_session_monitor_disconnect (NMSessionMonitor *self,
|
||||
gulong handler_id)
|
||||
{
|
||||
g_signal_handler_disconnect (nm_session_monitor_get (), handler_id);
|
||||
g_return_if_fail (NM_IS_SESSION_MONITOR (self));
|
||||
|
||||
g_signal_handler_disconnect (self, handler_id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -357,6 +364,7 @@ nm_session_monitor_user_to_uid (const char *user, uid_t *out_uid)
|
|||
|
||||
/**
|
||||
* nm_session_monitor_session_exists:
|
||||
* @self: the session monitor
|
||||
* @uid: A user ID.
|
||||
* @active: Ignore inactive sessions.
|
||||
*
|
||||
|
|
@ -369,19 +377,19 @@ nm_session_monitor_user_to_uid (const char *user, uid_t *out_uid)
|
|||
* logged into an active session.
|
||||
*/
|
||||
gboolean
|
||||
nm_session_monitor_session_exists (uid_t uid, gboolean active)
|
||||
nm_session_monitor_session_exists (NMSessionMonitor *self,
|
||||
uid_t uid,
|
||||
gboolean active)
|
||||
{
|
||||
#if defined(SESSION_TRACKING_SYSTEMD) || defined(SESSION_TRACKING_CONSOLEKIT)
|
||||
NMSessionMonitor *monitor = nm_session_monitor_get ();
|
||||
#endif
|
||||
g_return_val_if_fail (NM_IS_SESSION_MONITOR (self), FALSE);
|
||||
|
||||
#ifdef SESSION_TRACKING_SYSTEMD
|
||||
if (sd_session_exists (monitor, uid, active))
|
||||
if (sd_session_exists (self, uid, active))
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
#ifdef SESSION_TRACKING_CONSOLEKIT
|
||||
if (ck_session_exists (monitor, uid, active))
|
||||
if (ck_session_exists (self, uid, active))
|
||||
return TRUE;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -41,12 +41,19 @@ typedef void (*NMSessionCallback) (NMSessionMonitor *monitor, gpointer user_data
|
|||
|
||||
GType nm_session_monitor_get_type (void) G_GNUC_CONST;
|
||||
|
||||
gulong nm_session_monitor_connect (NMSessionCallback callback, gpointer user_data);
|
||||
void nm_session_monitor_disconnect (gulong handler_id);
|
||||
NMSessionMonitor *nm_session_monitor_get (void);
|
||||
|
||||
gulong nm_session_monitor_connect (NMSessionMonitor *self,
|
||||
NMSessionCallback callback,
|
||||
gpointer user_data);
|
||||
void nm_session_monitor_disconnect (NMSessionMonitor *self,
|
||||
gulong handler_id);
|
||||
|
||||
gboolean nm_session_monitor_uid_to_user (uid_t uid, const char **out_user);
|
||||
gboolean nm_session_monitor_user_to_uid (const char *user, uid_t *out_uid);
|
||||
gboolean nm_session_monitor_session_exists (uid_t uid, gboolean active);
|
||||
gboolean nm_session_monitor_session_exists (NMSessionMonitor *self,
|
||||
uid_t uid,
|
||||
gboolean active);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -517,8 +517,8 @@ agent_compare_func (gconstpointer aa, gconstpointer bb, gpointer user_data)
|
|||
}
|
||||
|
||||
/* Prefer agents in active sessions */
|
||||
a_active = nm_session_monitor_session_exists (nm_secret_agent_get_owner_uid (a), TRUE);
|
||||
b_active = nm_session_monitor_session_exists (nm_secret_agent_get_owner_uid (b), TRUE);
|
||||
a_active = nm_session_monitor_session_exists (nm_session_monitor_get (), nm_secret_agent_get_owner_uid (a), TRUE);
|
||||
b_active = nm_session_monitor_session_exists (nm_session_monitor_get (), nm_secret_agent_get_owner_uid (b), TRUE);
|
||||
if (a_active && !b_active)
|
||||
return -1;
|
||||
else if (a_active == b_active)
|
||||
|
|
@ -1543,6 +1543,8 @@ constructed (GObject *object)
|
|||
NM_AUTH_MANAGER_SIGNAL_CHANGED,
|
||||
G_CALLBACK (authority_changed_cb),
|
||||
object);
|
||||
|
||||
NM_UTILS_KEEP_ALIVE (object, nm_session_monitor_get (), "NMAgentManager-depends-on-NMSessionMonitor");
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ typedef struct {
|
|||
gboolean removed;
|
||||
|
||||
NMAgentManager *agent_mgr;
|
||||
NMSessionMonitor *session_monitor;
|
||||
guint session_changed_id;
|
||||
|
||||
NMSettingsConnectionFlags flags;
|
||||
|
|
@ -333,7 +334,7 @@ nm_settings_connection_recheck_visibility (NMSettingsConnection *self)
|
|||
continue;
|
||||
if (!nm_session_monitor_user_to_uid (user, &uid))
|
||||
continue;
|
||||
if (!nm_session_monitor_session_exists (uid, FALSE))
|
||||
if (!nm_session_monitor_session_exists (priv->session_monitor, uid, FALSE))
|
||||
continue;
|
||||
|
||||
set_visible (self, TRUE);
|
||||
|
|
@ -2325,7 +2326,8 @@ nm_settings_connection_init (NMSettingsConnection *self)
|
|||
priv->visible = FALSE;
|
||||
priv->ready = TRUE;
|
||||
|
||||
priv->session_changed_id = nm_session_monitor_connect (session_changed_cb, self);
|
||||
priv->session_monitor = g_object_ref (nm_session_monitor_get ());
|
||||
priv->session_changed_id = nm_session_monitor_connect (priv->session_monitor, session_changed_cb, self);
|
||||
|
||||
priv->agent_mgr = g_object_ref (nm_agent_manager_get ());
|
||||
|
||||
|
|
@ -2387,9 +2389,10 @@ dispose (GObject *object)
|
|||
|
||||
set_visible (self, FALSE);
|
||||
|
||||
if (priv->session_changed_id) {
|
||||
nm_session_monitor_disconnect (priv->session_changed_id);
|
||||
if (priv->session_monitor) {
|
||||
nm_session_monitor_disconnect (priv->session_monitor, priv->session_changed_id);
|
||||
priv->session_changed_id = 0;
|
||||
g_clear_object (&priv->session_monitor);
|
||||
}
|
||||
g_clear_object (&priv->agent_mgr);
|
||||
|
||||
|
|
|
|||
|
|
@ -625,7 +625,7 @@ unrecognized_specs_changed (NMSystemConfigInterface *config,
|
|||
nm_system_config_interface_get_unrecognized_specs);
|
||||
}
|
||||
|
||||
static void
|
||||
static gboolean
|
||||
add_plugin (NMSettings *self, NMSystemConfigInterface *plugin)
|
||||
{
|
||||
NMSettingsPrivate *priv;
|
||||
|
|
@ -633,11 +633,16 @@ add_plugin (NMSettings *self, NMSystemConfigInterface *plugin)
|
|||
char *pinfo = NULL;
|
||||
const char *path;
|
||||
|
||||
g_return_if_fail (NM_IS_SETTINGS (self));
|
||||
g_return_if_fail (NM_IS_SYSTEM_CONFIG_INTERFACE (plugin));
|
||||
g_return_val_if_fail (NM_IS_SETTINGS (self), FALSE);
|
||||
g_return_val_if_fail (NM_IS_SYSTEM_CONFIG_INTERFACE (plugin), FALSE);
|
||||
|
||||
priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
|
||||
if (g_slist_find (priv->plugins, plugin)) {
|
||||
/* don't add duplicates. */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
priv->plugins = g_slist_append (priv->plugins, g_object_ref (plugin));
|
||||
nm_system_config_interface_init (plugin, NULL);
|
||||
|
||||
|
|
@ -652,6 +657,8 @@ add_plugin (NMSettings *self, NMSystemConfigInterface *plugin)
|
|||
NM_PRINT_FMT_QUOTED (path, " (", path, ")", ""));
|
||||
g_free (pname);
|
||||
g_free (pinfo);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GObject *
|
||||
|
|
@ -682,11 +689,12 @@ find_plugin (GSList *list, const char *pname)
|
|||
static void
|
||||
add_keyfile_plugin (NMSettings *self)
|
||||
{
|
||||
GObject *keyfile_plugin;
|
||||
gs_unref_object GObject *keyfile_plugin = NULL;
|
||||
|
||||
keyfile_plugin = nm_settings_keyfile_plugin_new ();
|
||||
g_assert (keyfile_plugin);
|
||||
add_plugin (self, NM_SYSTEM_CONFIG_INTERFACE (keyfile_plugin));
|
||||
if (!add_plugin (self, NM_SYSTEM_CONFIG_INTERFACE (keyfile_plugin)))
|
||||
g_return_if_reached ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -726,10 +734,6 @@ load_plugins (NMSettings *self, const char **plugins, GError **error)
|
|||
if (has_no_ibft && !strcmp (pname, "ibft"))
|
||||
continue;
|
||||
|
||||
obj = find_plugin (list, pname);
|
||||
if (obj)
|
||||
continue;
|
||||
|
||||
/* keyfile plugin is built-in now */
|
||||
if (strcmp (pname, "keyfile") == 0) {
|
||||
if (!keyfile_added) {
|
||||
|
|
@ -739,6 +743,17 @@ load_plugins (NMSettings *self, const char **plugins, GError **error)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (_nm_utils_strv_find_first ((char **) plugins,
|
||||
iter - plugins,
|
||||
pname) >= 0) {
|
||||
/* the plugin is already mentioned in the list previously.
|
||||
* Don't load a duplicate. */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (find_plugin (list, pname))
|
||||
continue;
|
||||
|
||||
load_plugin:
|
||||
{
|
||||
GModule *plugin;
|
||||
|
|
@ -801,8 +816,10 @@ load_plugin:
|
|||
g_object_weak_ref (obj, (GWeakNotify) g_module_close, plugin);
|
||||
g_object_set_data_full (obj, PLUGIN_MODULE_PATH, path, g_free);
|
||||
path = NULL;
|
||||
add_plugin (self, NM_SYSTEM_CONFIG_INTERFACE (obj));
|
||||
list = g_slist_append (list, obj);
|
||||
if (add_plugin (self, NM_SYSTEM_CONFIG_INTERFACE (obj)))
|
||||
list = g_slist_append (list, obj);
|
||||
else
|
||||
g_object_unref (obj);
|
||||
}
|
||||
next:
|
||||
if (add_ibft && !strcmp (pname, "ifcfg-rh")) {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,9 @@ typedef struct {
|
|||
gboolean initialized;
|
||||
} SCPluginIbftPrivate;
|
||||
|
||||
static SCPluginIbft *sc_plugin_ibft_get (void);
|
||||
NM_DEFINE_SINGLETON_GETTER (SCPluginIbft, sc_plugin_ibft_get, SC_TYPE_PLUGIN_IBFT);
|
||||
|
||||
static void
|
||||
read_connections (SCPluginIbft *self)
|
||||
{
|
||||
|
|
@ -191,12 +194,5 @@ system_config_interface_init (NMSystemConfigInterface *system_config_interface_c
|
|||
G_MODULE_EXPORT GObject *
|
||||
nm_system_config_factory (void)
|
||||
{
|
||||
static SCPluginIbft *singleton = NULL;
|
||||
|
||||
if (!singleton)
|
||||
singleton = SC_PLUGIN_IBFT (g_object_new (SC_TYPE_PLUGIN_IBFT, NULL));
|
||||
else
|
||||
g_object_ref (singleton);
|
||||
|
||||
return G_OBJECT (singleton);
|
||||
return g_object_ref (sc_plugin_ibft_get ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,10 +98,10 @@ typedef struct {
|
|||
|
||||
GFileMonitor *ifcfg_monitor;
|
||||
guint ifcfg_monitor_id;
|
||||
|
||||
gboolean has_dbus_service;
|
||||
} SCPluginIfcfgPrivate;
|
||||
|
||||
static SCPluginIfcfg *sc_plugin_ifcfg_get (void);
|
||||
NM_DEFINE_SINGLETON_GETTER (SCPluginIfcfg, sc_plugin_ifcfg_get, SC_TYPE_PLUGIN_IFCFG);
|
||||
|
||||
static void
|
||||
connection_ifcfg_changed (NMIfcfgConnection *connection, gpointer user_data)
|
||||
|
|
@ -755,13 +755,19 @@ static void
|
|||
sc_plugin_ifcfg_init (SCPluginIfcfg *plugin)
|
||||
{
|
||||
SCPluginIfcfgPrivate *priv = SC_PLUGIN_IFCFG_GET_PRIVATE (plugin);
|
||||
|
||||
priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
SCPluginIfcfg *self = SC_PLUGIN_IFCFG (object);
|
||||
GError *error = NULL;
|
||||
GDBusConnection *bus;
|
||||
GVariant *ret;
|
||||
guint32 result;
|
||||
|
||||
priv->connections = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
|
||||
|
||||
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||
if (!bus) {
|
||||
_LOGW ("Couldn't connect to D-Bus: %s", error->message);
|
||||
|
|
@ -786,9 +792,10 @@ sc_plugin_ifcfg_init (SCPluginIfcfg *plugin)
|
|||
g_variant_get (ret, "(u)", &result);
|
||||
g_variant_unref (ret);
|
||||
|
||||
if (result == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER)
|
||||
priv->has_dbus_service = TRUE;
|
||||
else
|
||||
if (result == DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
|
||||
nm_exported_object_export (NM_EXPORTED_OBJECT (self));
|
||||
_LOGD ("Acquired D-Bus service %s", IFCFGRH1_DBUS_SERVICE_NAME);
|
||||
} else
|
||||
_LOGW ("Couldn't acquire ifcfgrh1 D-Bus service (already taken)");
|
||||
} else {
|
||||
_LOGW ("Couldn't acquire D-Bus service: %s", error->message);
|
||||
|
|
@ -859,6 +866,7 @@ sc_plugin_ifcfg_class_init (SCPluginIfcfgClass *req_class)
|
|||
|
||||
exported_object_class->export_path = IFCFGRH1_DBUS_OBJECT_PATH;
|
||||
|
||||
object_class->constructed = constructed;
|
||||
object_class->dispose = dispose;
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
|
|
@ -897,17 +905,5 @@ system_config_interface_init (NMSystemConfigInterface *system_config_interface_c
|
|||
G_MODULE_EXPORT GObject *
|
||||
nm_system_config_factory (void)
|
||||
{
|
||||
static SCPluginIfcfg *singleton = NULL;
|
||||
SCPluginIfcfgPrivate *priv;
|
||||
|
||||
if (!singleton) {
|
||||
singleton = SC_PLUGIN_IFCFG (g_object_new (SC_TYPE_PLUGIN_IFCFG, NULL));
|
||||
priv = SC_PLUGIN_IFCFG_GET_PRIVATE (singleton);
|
||||
if (priv->has_dbus_service)
|
||||
nm_exported_object_export (NM_EXPORTED_OBJECT (singleton));
|
||||
_LOGD ("Acquired D-Bus service %s", IFCFGRH1_DBUS_SERVICE_NAME);
|
||||
} else
|
||||
g_object_ref (singleton);
|
||||
|
||||
return G_OBJECT (singleton);
|
||||
return g_object_ref (sc_plugin_ifcfg_get ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include "nm-system-config-interface.h"
|
||||
#include "nm-ifnet-connection.h"
|
||||
#include "nm-config.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include "net_utils.h"
|
||||
|
|
@ -68,13 +69,9 @@ static void reload_connections (NMSystemConfigInterface *config);
|
|||
G_DEFINE_TYPE_EXTENDED (SCPluginIfnet, sc_plugin_ifnet, G_TYPE_OBJECT, 0,
|
||||
G_IMPLEMENT_INTERFACE (NM_TYPE_SYSTEM_CONFIG_INTERFACE, system_config_interface_init))
|
||||
#define SC_PLUGIN_IFNET_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFNET, SCPluginIfnetPrivate))
|
||||
/*
|
||||
static void
|
||||
ignore_cb(NMSettingsConnectionInterface * connection,
|
||||
GError * error, gpointer user_data)
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
static SCPluginIfnet *sc_plugin_ifnet_get (void);
|
||||
NM_DEFINE_SINGLETON_GETTER (SCPluginIfnet, sc_plugin_ifnet_get, SC_TYPE_PLUGIN_IFNET);
|
||||
|
||||
static gboolean
|
||||
is_managed_plugin (void)
|
||||
|
|
@ -500,14 +497,5 @@ sc_plugin_ifnet_class_init (SCPluginIfnetClass * req_class)
|
|||
G_MODULE_EXPORT GObject *
|
||||
nm_system_config_factory (void)
|
||||
{
|
||||
static SCPluginIfnet *singleton = NULL;
|
||||
SCPluginIfnetPrivate *priv;
|
||||
|
||||
if (!singleton) {
|
||||
singleton = SC_PLUGIN_IFNET (g_object_new (SC_TYPE_PLUGIN_IFNET, NULL));
|
||||
priv = SC_PLUGIN_IFNET_GET_PRIVATE (singleton);
|
||||
} else
|
||||
g_object_ref (singleton);
|
||||
|
||||
return G_OBJECT (singleton);
|
||||
return g_object_ref (sc_plugin_ifnet_get ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#include "nm-setting-ppp.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-core-internal.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
|
||||
#include "nm-ifupdown-connection.h"
|
||||
#include "plugin.h"
|
||||
|
|
@ -88,6 +89,9 @@ G_DEFINE_TYPE_EXTENDED (SCPluginIfupdown, sc_plugin_ifupdown, G_TYPE_OBJECT, 0,
|
|||
|
||||
#define SC_PLUGIN_IFUPDOWN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SC_TYPE_PLUGIN_IFUPDOWN, SCPluginIfupdownPrivate))
|
||||
|
||||
static SCPluginIfupdown *sc_plugin_ifupdown_get (void);
|
||||
NM_DEFINE_SINGLETON_GETTER (SCPluginIfupdown, sc_plugin_ifupdown_get, SC_TYPE_PLUGIN_IFUPDOWN);
|
||||
|
||||
static void
|
||||
sc_plugin_ifupdown_class_init (SCPluginIfupdownClass *req_class);
|
||||
|
||||
|
|
@ -555,15 +559,6 @@ GObject__dispose (GObject *object)
|
|||
G_MODULE_EXPORT GObject *
|
||||
nm_system_config_factory (void)
|
||||
{
|
||||
static SCPluginIfupdown *singleton = NULL;
|
||||
SCPluginIfupdownPrivate *priv;
|
||||
|
||||
if (!singleton) {
|
||||
singleton = SC_PLUGIN_IFUPDOWN (g_object_new (SC_TYPE_PLUGIN_IFUPDOWN, NULL));
|
||||
priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (singleton);
|
||||
} else
|
||||
g_object_ref (singleton);
|
||||
|
||||
return G_OBJECT (singleton);
|
||||
return g_object_ref (sc_plugin_ifupdown_get ());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -568,6 +568,18 @@ set_property (GObject *object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
constructed (GObject *object)
|
||||
{
|
||||
SCPluginKeyfilePrivate *priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (object);
|
||||
|
||||
priv->config = g_object_ref (nm_config_get ());
|
||||
if (nm_config_data_has_value (nm_config_get_data_orig (priv->config),
|
||||
NM_CONFIG_KEYFILE_GROUP_KEYFILE, "hostname",
|
||||
NM_CONFIG_GET_VALUE_RAW))
|
||||
nm_log_warn (LOGD_SETTINGS, "keyfile: 'hostname' option is deprecated and has no effect");
|
||||
}
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
|
|
@ -603,6 +615,7 @@ sc_plugin_keyfile_class_init (SCPluginKeyfileClass *req_class)
|
|||
|
||||
g_type_class_add_private (req_class, sizeof (SCPluginKeyfilePrivate));
|
||||
|
||||
object_class->constructed = constructed;
|
||||
object_class->dispose = dispose;
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
|
|
@ -634,20 +647,5 @@ system_config_interface_init (NMSystemConfigInterface *system_config_interface_c
|
|||
GObject *
|
||||
nm_settings_keyfile_plugin_new (void)
|
||||
{
|
||||
static SCPluginKeyfile *singleton = NULL;
|
||||
SCPluginKeyfilePrivate *priv;
|
||||
|
||||
if (!singleton) {
|
||||
singleton = SC_PLUGIN_KEYFILE (g_object_new (SC_TYPE_PLUGIN_KEYFILE, NULL));
|
||||
priv = SC_PLUGIN_KEYFILE_GET_PRIVATE (singleton);
|
||||
|
||||
priv->config = g_object_ref (nm_config_get ());
|
||||
if (nm_config_data_has_value (nm_config_get_data_orig (priv->config),
|
||||
NM_CONFIG_KEYFILE_GROUP_KEYFILE, "hostname",
|
||||
NM_CONFIG_GET_VALUE_RAW))
|
||||
nm_log_warn (LOGD_SETTINGS, "keyfile: 'hostname' option is deprecated and has no effect");
|
||||
} else
|
||||
g_object_ref (singleton);
|
||||
|
||||
return G_OBJECT (singleton);
|
||||
return g_object_new (SC_TYPE_PLUGIN_KEYFILE, NULL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue