diff options
author | Thomas Haller <thaller@redhat.com> | 2015-01-06 11:54:27 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-01-12 12:10:03 +0100 |
commit | d45c1b84f433da696a1c244fb6d65a26a3e26661 (patch) | |
tree | 61a8eb85a9fd2e5bcdcdbc162e7971b08dc5c66c | |
parent | d8887019ce43e29c050f51ae9656b37bd3b262ad (diff) | |
download | NetworkManager-d45c1b84f433da696a1c244fb6d65a26a3e26661.tar.gz |
core: declare nm_supplicant_manager_get() using NM_DEFINE_SINGLETON_GETTER()
-rw-r--r-- | src/devices/nm-device-ethernet.c | 2 | ||||
-rw-r--r-- | src/devices/wifi/nm-device-wifi.c | 3 | ||||
-rw-r--r-- | src/main.c | 7 | ||||
-rw-r--r-- | 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 ac408d3d9f..0027958c38 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 dd7754b33e..7d3dc9a1d7 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 5a2934bd7b..88d16144d9 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 01e35929d4..9a7a69844b 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) |