diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 10afa18ff..6fe685e25 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -429,7 +429,9 @@ G_DEFINE_TYPE (NMLinuxPlatform, nm_linux_platform, NM_TYPE_PLATFORM) void nm_linux_platform_setup (void) { - nm_platform_setup (g_object_new (NM_TYPE_LINUX_PLATFORM, NULL)); + g_object_new (NM_TYPE_LINUX_PLATFORM, + NM_PLATFORM_REGISTER_SINGLETON, TRUE, + NULL); } /******************************************************************/ diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index caad16e2c..da1cea829 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -58,6 +58,16 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +enum { + PROP_0, + PROP_REGISTER_SINGLETON, + LAST_PROP, +}; + +typedef struct { + gboolean register_singleton; +} NMPlatformPrivate; + /******************************************************************/ /* Singleton NMPlatform subclass instance and cached class object */ @@ -3119,6 +3129,35 @@ const NMPlatformVTableRoute nm_platform_vtable_route_v6 = { /******************************************************************/ +static void +set_property (GObject *object, guint prop_id, + const GValue *value, GParamSpec *pspec) +{ + NMPlatformPrivate *priv = NM_PLATFORM_GET_PRIVATE (object); + + switch (prop_id) { + case PROP_REGISTER_SINGLETON: + /* construct-only */ + priv->register_singleton = g_value_get_boolean (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +constructed (GObject *object) +{ + NMPlatform *self = NM_PLATFORM (object); + NMPlatformPrivate *priv = NM_PLATFORM_GET_PRIVATE (self); + + G_OBJECT_CLASS (nm_platform_parent_class)->constructed (object); + + if (priv->register_singleton) + nm_platform_setup (self); +} + static void nm_platform_init (NMPlatform *object) { @@ -3137,8 +3176,21 @@ nm_platform_class_init (NMPlatformClass *platform_class) { GObjectClass *object_class = G_OBJECT_CLASS (platform_class); + g_type_class_add_private (object_class, sizeof (NMPlatformPrivate)); + + object_class->set_property = set_property; + object_class->constructed = constructed; + platform_class->wifi_set_powersave = wifi_set_powersave; + g_object_class_install_property + (object_class, PROP_REGISTER_SINGLETON, + g_param_spec_boolean (NM_PLATFORM_REGISTER_SINGLETON, "", "", + FALSE, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + /* Signals */ SIGNAL (SIGNAL_LINK_CHANGED, log_link) SIGNAL (SIGNAL_IP4_ADDRESS_CHANGED, log_ip4_address) diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 62247bc31..81771b87f 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -40,6 +40,10 @@ /******************************************************************/ +#define NM_PLATFORM_REGISTER_SINGLETON "register-singleton" + +/******************************************************************/ + typedef struct _NMPlatform NMPlatform; /* workaround for older libnl version, that does not define these flags. */