summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2015-05-12 07:34:56 +0200
committerThomas Haller <thaller@redhat.com>2015-06-17 11:41:43 +0200
commit56b07b1a3f26da472ae93ffb94a5928390057ef8 (patch)
treee0096533655fb536fe9890a68d58284f850e0f71 /src
parentf1f1c3cb732fdff37670b83de356a5dc8fba69fb (diff)
downloadNetworkManager-56b07b1a3f26da472ae93ffb94a5928390057ef8.tar.gz
platform: register singleton instance early with NM_PLATFORM_REGISTER_SINGLETON
Add a construct-only property NM_PLATFORM_REGISTER_SINGLETON to NMPlatform. When set to TRUE, the constructor will self-register to nm_platform_setup(). The reason for this is that the _LOG() macro in NMLinuxPlatform logs the self pointer if the instance is not the singleton instance. During construction, we already have many log lines due to initialization of the instance. These lines all end up qualified with the self pointer. By earlier self-registering, printing the pointer value is omitted. Yes, this patch is really just to prettify logging.
Diffstat (limited to 'src')
-rw-r--r--src/platform/nm-linux-platform.c4
-rw-r--r--src/platform/nm-platform.c52
-rw-r--r--src/platform/nm-platform.h4
3 files changed, 59 insertions, 1 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
index 10afa18ffc..6fe685e25b 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 caad16e2c8..da1cea829c 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 */
@@ -3120,6 +3130,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 62247bc31c..81771b87f2 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. */