From d45c1b84f433da696a1c244fb6d65a26a3e26661 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 6 Jan 2015 11:54:27 +0100 Subject: [PATCH] core: declare nm_supplicant_manager_get() using NM_DEFINE_SINGLETON_GETTER() --- src/devices/nm-device-ethernet.c | 2 +- src/devices/wifi/nm-device-wifi.c | 3 +-- src/main.c | 7 +------ src/supplicant-manager/nm-supplicant-manager.c | 14 +------------- 4 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/devices/nm-device-ethernet.c b/src/devices/nm-device-ethernet.c index ac408d3d9..0027958c3 100644 --- a/src/devices/nm-device-ethernet.c +++ b/src/devices/nm-device-ethernet.c @@ -946,7 +946,7 @@ nm_8021x_stage2_config (NMDeviceEthernet *self, NMDeviceStateReason *reason) } if (!priv->supplicant.mgr) - priv->supplicant.mgr = nm_supplicant_manager_get (); + priv->supplicant.mgr = g_object_ref (nm_supplicant_manager_get ()); /* If we need secrets, get them */ setting_name = nm_connection_need_secrets (connection, NULL); diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c index dd7754b33..7d3dc9a1d 100644 --- a/src/devices/wifi/nm-device-wifi.c +++ b/src/devices/wifi/nm-device-wifi.c @@ -224,8 +224,7 @@ constructor (GType type, _LOGI (LOGD_HW | LOGD_WIFI, "driver supports Access Point (AP) mode"); /* Connect to the supplicant manager */ - priv->sup_mgr = nm_supplicant_manager_get (); - g_assert (priv->sup_mgr); + priv->sup_mgr = g_object_ref (nm_supplicant_manager_get ()); return object; } diff --git a/src/main.c b/src/main.c index 5a2934bd7..88d16144d 100644 --- a/src/main.c +++ b/src/main.c @@ -47,7 +47,7 @@ #include "nm-manager.h" #include "nm-linux-platform.h" #include "nm-dbus-manager.h" -#include "nm-supplicant-manager.h" +#include "nm-device.h" #include "nm-dhcp-manager.h" #include "nm-logging.h" #include "nm-config.h" @@ -201,7 +201,6 @@ main (int argc, char *argv[]) gboolean success, show_version = FALSE; NMManager *manager = NULL; gs_unref_object NMDBusManager *dbus_mgr = NULL; - gs_unref_object NMSupplicantManager *sup_mgr = NULL; gs_unref_object NMSettings *settings = NULL; gs_unref_object NMConfig *config = NULL; GError *error = NULL; @@ -414,10 +413,6 @@ main (int argc, char *argv[]) goto done; } - /* Initialize the supplicant manager */ - sup_mgr = nm_supplicant_manager_get (); - g_assert (sup_mgr != NULL); - if (!nm_dbus_manager_get_connection (dbus_mgr)) { #if HAVE_DBUS_GLIB_100 nm_log_warn (LOGD_CORE, "Failed to connect to D-Bus; only private bus is available"); diff --git a/src/supplicant-manager/nm-supplicant-manager.c b/src/supplicant-manager/nm-supplicant-manager.c index 01e35929d..9a7a69844 100644 --- a/src/supplicant-manager/nm-supplicant-manager.c +++ b/src/supplicant-manager/nm-supplicant-manager.c @@ -301,19 +301,7 @@ name_owner_changed (NMDBusManager *dbus_mgr, /*******************************************************************/ -NMSupplicantManager * -nm_supplicant_manager_get (void) -{ - static NMSupplicantManager *singleton = NULL; - - if (!singleton) - singleton = NM_SUPPLICANT_MANAGER (g_object_new (NM_TYPE_SUPPLICANT_MANAGER, NULL)); - else - g_object_ref (singleton); - - g_assert (singleton); - return singleton; -} +NM_DEFINE_SINGLETON_GETTER (NMSupplicantManager, nm_supplicant_manager_get, NM_TYPE_SUPPLICANT_MANAGER); static void nm_supplicant_manager_init (NMSupplicantManager *self)