summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Fernandez Mancera <ffmancera@riseup.net>2024-02-04 21:11:47 +0100
committerFernando Fernandez Mancera <ffmancera@riseup.net>2024-03-04 18:29:07 +0100
commit5ab87886f345967184e477b721e53fe3279bf2cd (patch)
tree9f8cf65c9520bd9a69c1db7bbadd885d06d89107
parent14cad33baabc039ae3b763573135724d10f7d9ae (diff)
power: rename NMSleepMonitor to NMPowerMonitor
In order to provide the NMSleepMonitor a more generic usage, let's rename the whole module to NMPowerMonitor. Nothing is exposed to the API so it is a trivial renaming.
-rw-r--r--Makefile.am4
-rw-r--r--src/core/meson.build2
-rw-r--r--src/core/nm-manager.c32
-rw-r--r--src/core/nm-power-monitor.c (renamed from src/core/nm-sleep-monitor.c)76
-rw-r--r--src/core/nm-power-monitor.h33
-rw-r--r--src/core/nm-sleep-monitor.h33
-rw-r--r--src/core/nm-types.h2
7 files changed, 91 insertions, 91 deletions
diff --git a/Makefile.am b/Makefile.am
index d91e983e9c..2b6eab2f97 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2813,8 +2813,8 @@ src_core_libNetworkManager_la_SOURCES = \
src/core/nm-priv-helper-call.h \
src/core/nm-keep-alive.c \
src/core/nm-keep-alive.h \
- src/core/nm-sleep-monitor.c \
- src/core/nm-sleep-monitor.h \
+ src/core/nm-power-monitor.c \
+ src/core/nm-power-monitor.h \
src/core/nm-types.h \
\
$(NULL)
diff --git a/src/core/meson.build b/src/core/meson.build
index 45b068a675..4419ff6296 100644
--- a/src/core/meson.build
+++ b/src/core/meson.build
@@ -171,7 +171,7 @@ libNetworkManager = static_library(
'nm-policy.c',
'nm-rfkill-manager.c',
'nm-session-monitor.c',
- 'nm-sleep-monitor.c',
+ 'nm-power-monitor.c',
'nm-priv-helper-call.c',
),
dependencies: nm_deps,
diff --git a/src/core/nm-manager.c b/src/core/nm-manager.c
index 730ba4763b..072c4262aa 100644
--- a/src/core/nm-manager.c
+++ b/src/core/nm-manager.c
@@ -46,7 +46,7 @@
#include "nm-priv-helper-call.h"
#include "nm-rfkill-manager.h"
#include "nm-session-monitor.h"
-#include "nm-sleep-monitor.h"
+#include "nm-power-monitor.h"
#include "settings/nm-settings-connection.h"
#include "settings/nm-settings.h"
#include "vpn/nm-vpn-manager.h"
@@ -214,7 +214,7 @@ typedef struct {
NMVpnManager *vpn_manager;
- NMSleepMonitor *sleep_monitor;
+ NMPowerMonitor *power_monitor;
NMAuthManager *auth_mgr;
@@ -7128,7 +7128,7 @@ static gboolean
sleep_devices_add(NMManager *self, NMDevice *device, gboolean suspending)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
- NMSleepMonitorInhibitorHandle *handle = NULL;
+ NMPowerMonitorInhibitorHandle *handle = NULL;
if (g_hash_table_lookup_extended(priv->sleep_devices, device, NULL, (gpointer *) &handle)) {
if (suspending) {
@@ -7136,16 +7136,16 @@ sleep_devices_add(NMManager *self, NMDevice *device, gboolean suspending)
* Even if we had an old handle, it might be stale by now. */
g_hash_table_insert(priv->sleep_devices,
device,
- nm_sleep_monitor_inhibit_take(priv->sleep_monitor));
+ nm_power_monitor_inhibit_take(priv->power_monitor));
if (handle)
- nm_sleep_monitor_inhibit_release(priv->sleep_monitor, handle);
+ nm_power_monitor_inhibit_release(priv->power_monitor, handle);
}
return FALSE;
}
g_hash_table_insert(priv->sleep_devices,
g_object_ref(device),
- suspending ? nm_sleep_monitor_inhibit_take(priv->sleep_monitor) : NULL);
+ suspending ? nm_power_monitor_inhibit_take(priv->power_monitor) : NULL);
g_signal_connect(device, "notify::" NM_DEVICE_STATE, G_CALLBACK(device_sleep_cb), self);
return TRUE;
}
@@ -7154,13 +7154,13 @@ static gboolean
sleep_devices_remove(NMManager *self, NMDevice *device)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
- NMSleepMonitorInhibitorHandle *handle;
+ NMPowerMonitorInhibitorHandle *handle;
if (!g_hash_table_lookup_extended(priv->sleep_devices, device, NULL, (gpointer *) &handle))
return FALSE;
if (handle)
- nm_sleep_monitor_inhibit_release(priv->sleep_monitor, handle);
+ nm_power_monitor_inhibit_release(priv->power_monitor, handle);
/* Remove device from hash */
g_signal_handlers_disconnect_by_func(device, device_sleep_cb, self);
@@ -7177,14 +7177,14 @@ sleep_devices_clear(NMManager *self)
{
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE(self);
NMDevice *device;
- NMSleepMonitorInhibitorHandle *handle;
+ NMPowerMonitorInhibitorHandle *handle;
GHashTableIter iter;
g_hash_table_iter_init(&iter, priv->sleep_devices);
while (g_hash_table_iter_next(&iter, (gpointer *) &device, (gpointer *) &handle)) {
g_signal_handlers_disconnect_by_func(device, device_sleep_cb, self);
if (handle)
- nm_sleep_monitor_inhibit_release(priv->sleep_monitor, handle);
+ nm_power_monitor_inhibit_release(priv->power_monitor, handle);
g_object_unref(device);
g_hash_table_iter_remove(&iter);
}
@@ -7438,7 +7438,7 @@ impl_manager_sleep(NMDBusObject *obj,
}
static void
-sleeping_cb(NMSleepMonitor *monitor, gboolean is_about_to_suspend, gpointer user_data)
+sleeping_cb(NMPowerMonitor *monitor, gboolean is_about_to_suspend, gpointer user_data)
{
NMManager *self = user_data;
@@ -8834,8 +8834,8 @@ nm_manager_init(NMManager *self)
priv->devcon_data_dict = g_hash_table_new(_devcon_data_hash, _devcon_data_equal);
/* sleep/wake handling */
- priv->sleep_monitor = nm_sleep_monitor_new();
- g_signal_connect(priv->sleep_monitor, NM_SLEEP_MONITOR_SLEEPING, G_CALLBACK(sleeping_cb), self);
+ priv->power_monitor = nm_power_monitor_new();
+ g_signal_connect(priv->power_monitor, NM_POWER_MONITOR_SLEEPING, G_CALLBACK(sleeping_cb), self);
/* Listen for authorization changes */
priv->auth_mgr = g_object_ref(nm_auth_manager_get());
@@ -9134,9 +9134,9 @@ dispose(GObject *object)
nm_clear_pointer(&priv->sleep_devices, g_hash_table_unref);
}
- if (priv->sleep_monitor) {
- g_signal_handlers_disconnect_by_func(priv->sleep_monitor, sleeping_cb, self);
- g_clear_object(&priv->sleep_monitor);
+ if (priv->power_monitor) {
+ g_signal_handlers_disconnect_by_func(priv->power_monitor, sleeping_cb, self);
+ g_clear_object(&priv->power_monitor);
}
if (priv->fw_monitor) {
diff --git a/src/core/nm-sleep-monitor.c b/src/core/nm-power-monitor.c
index 66ea2f6c71..1f703a63eb 100644
--- a/src/core/nm-sleep-monitor.c
+++ b/src/core/nm-power-monitor.c
@@ -6,7 +6,7 @@
#include "src/core/nm-default-daemon.h"
-#include "nm-sleep-monitor.h"
+#include "nm-power-monitor.h"
#include <sys/stat.h>
#include <gio/gunixfdlist.h>
@@ -21,7 +21,7 @@
#define SUSPEND_DBUS_PATH "/org/freedesktop/UPower"
#define SUSPEND_DBUS_INTERFACE "org.freedesktop.UPower"
#define USE_UPOWER 1
-#define _NMLOG_PREFIX_NAME "sleep-monitor-up"
+#define _NMLOG_PREFIX_NAME "power-monitor-up"
#elif defined(SUSPEND_RESUME_SYSTEMD) || defined(SUSPEND_RESUME_ELOGIND)
@@ -30,9 +30,9 @@
#define SUSPEND_DBUS_INTERFACE "org.freedesktop.login1.Manager"
#define USE_UPOWER 0
#if defined(SUSPEND_RESUME_SYSTEMD)
-#define _NMLOG_PREFIX_NAME "sleep-monitor-sd"
+#define _NMLOG_PREFIX_NAME "power-monitor-sd"
#else
-#define _NMLOG_PREFIX_NAME "sleep-monitor-el"
+#define _NMLOG_PREFIX_NAME "power-monitor-el"
#endif
#elif defined(SUSPEND_RESUME_CONSOLEKIT)
@@ -45,7 +45,7 @@
#define SUSPEND_DBUS_PATH "/org/freedesktop/ConsoleKit/Manager"
#define SUSPEND_DBUS_INTERFACE "org.freedesktop.ConsoleKit.Manager"
#define USE_UPOWER 0
-#define _NMLOG_PREFIX_NAME "sleep-monitor-ck"
+#define _NMLOG_PREFIX_NAME "power-monitor-ck"
#else
@@ -62,7 +62,7 @@ enum {
static guint signals[LAST_SIGNAL] = {0};
-struct _NMSleepMonitor {
+struct _NMPowerMonitor {
GObject parent;
GDBusProxy *proxy;
@@ -78,11 +78,11 @@ struct _NMSleepMonitor {
gulong sig_id_2;
};
-struct _NMSleepMonitorClass {
+struct _NMPowerMonitorClass {
GObjectClass parent;
};
-G_DEFINE_TYPE(NMSleepMonitor, nm_sleep_monitor, G_TYPE_OBJECT);
+G_DEFINE_TYPE(NMPowerMonitor, nm_power_monitor, G_TYPE_OBJECT);
/*****************************************************************************/
@@ -91,7 +91,7 @@ G_DEFINE_TYPE(NMSleepMonitor, nm_sleep_monitor, G_TYPE_OBJECT);
/*****************************************************************************/
-static void sleep_signal(NMSleepMonitor *self, gboolean is_about_to_suspend);
+static void sleep_signal(NMPowerMonitor *self, gboolean is_about_to_suspend);
/*****************************************************************************/
@@ -112,7 +112,7 @@ upower_resuming_cb(GDBusProxy *proxy, gpointer user_data)
#else /* USE_UPOWER */
static void
-drop_inhibitor(NMSleepMonitor *self, gboolean force)
+drop_inhibitor(NMPowerMonitor *self, gboolean force)
{
if (!force && self->handles_active)
return;
@@ -135,7 +135,7 @@ static void
inhibit_done(GObject *source, GAsyncResult *result, gpointer user_data)
{
GDBusProxy *proxy = G_DBUS_PROXY(source);
- NMSleepMonitor *self = user_data;
+ NMPowerMonitor *self = user_data;
gs_free_error GError *error = NULL;
gs_unref_variant GVariant *res = NULL;
gs_unref_object GUnixFDList *fd_list = NULL;
@@ -161,9 +161,9 @@ inhibit_done(GObject *source, GAsyncResult *result, gpointer user_data)
}
static void
-take_inhibitor(NMSleepMonitor *self)
+take_inhibitor(NMPowerMonitor *self)
{
- g_return_if_fail(NM_IS_SLEEP_MONITOR(self));
+ g_return_if_fail(NM_IS_POWER_MONITOR(self));
g_return_if_fail(G_IS_DBUS_PROXY(self->proxy));
drop_inhibitor(self, TRUE);
@@ -195,7 +195,7 @@ static void
name_owner_cb(GObject *object, GParamSpec *pspec, gpointer user_data)
{
GDBusProxy *proxy = G_DBUS_PROXY(object);
- NMSleepMonitor *self = NM_SLEEP_MONITOR(user_data);
+ NMPowerMonitor *self = NM_POWER_MONITOR(user_data);
char *owner;
g_assert(proxy == self->proxy);
@@ -210,9 +210,9 @@ name_owner_cb(GObject *object, GParamSpec *pspec, gpointer user_data)
#endif /* USE_UPOWER */
static void
-sleep_signal(NMSleepMonitor *self, gboolean is_about_to_suspend)
+sleep_signal(NMPowerMonitor *self, gboolean is_about_to_suspend)
{
- g_return_if_fail(NM_IS_SLEEP_MONITOR(self));
+ g_return_if_fail(NM_IS_POWER_MONITOR(self));
_LOGD("received %s signal", is_about_to_suspend ? "SLEEP" : "RESUME");
@@ -230,36 +230,36 @@ sleep_signal(NMSleepMonitor *self, gboolean is_about_to_suspend)
}
/**
- * nm_sleep_monitor_inhibit_take:
- * @self: the #NMSleepMonitor instance
+ * nm_power_monitor_inhibit_take:
+ * @self: the #NMPowerMonitor instance
*
* Prevent the release of inhibitor lock
*
* Returns: an inhibitor handle that must be returned via
- * nm_sleep_monitor_inhibit_release().
+ * nm_power_monitor_inhibit_release().
**/
-NMSleepMonitorInhibitorHandle *
-nm_sleep_monitor_inhibit_take(NMSleepMonitor *self)
+NMPowerMonitorInhibitorHandle *
+nm_power_monitor_inhibit_take(NMPowerMonitor *self)
{
- g_return_val_if_fail(NM_IS_SLEEP_MONITOR(self), NULL);
+ g_return_val_if_fail(NM_IS_POWER_MONITOR(self), NULL);
self->handles_active = g_slist_prepend(self->handles_active, NULL);
- return (NMSleepMonitorInhibitorHandle *) self->handles_active;
+ return (NMPowerMonitorInhibitorHandle *) self->handles_active;
}
/**
- * nm_sleep_monitor_inhibit_release:
- * @self: the #NMSleepMonitor instance
- * @handle: the #NMSleepMonitorInhibitorHandle inhibitor handle.
+ * nm_power_monitor_inhibit_release:
+ * @self: the #NMPowerMonitor instance
+ * @handle: the #NMPowerMonitorInhibitorHandle inhibitor handle.
*
* Allow again the release of inhibitor lock
**/
void
-nm_sleep_monitor_inhibit_release(NMSleepMonitor *self, NMSleepMonitorInhibitorHandle *handle)
+nm_power_monitor_inhibit_release(NMPowerMonitor *self, NMPowerMonitorInhibitorHandle *handle)
{
GSList *l;
- g_return_if_fail(NM_IS_SLEEP_MONITOR(self));
+ g_return_if_fail(NM_IS_POWER_MONITOR(self));
g_return_if_fail(handle);
l = (GSList *) handle;
@@ -279,7 +279,7 @@ nm_sleep_monitor_inhibit_release(NMSleepMonitor *self, NMSleepMonitorInhibitorHa
}
static void
-on_proxy_acquired(GObject *object, GAsyncResult *res, NMSleepMonitor *self)
+on_proxy_acquired(GObject *object, GAsyncResult *res, NMPowerMonitor *self)
{
GError *error = NULL;
GDBusProxy *proxy;
@@ -326,7 +326,7 @@ on_proxy_acquired(GObject *object, GAsyncResult *res, NMSleepMonitor *self)
/*****************************************************************************/
static void
-nm_sleep_monitor_init(NMSleepMonitor *self)
+nm_power_monitor_init(NMPowerMonitor *self)
{
self->inhibit_fd = -1;
self->cancellable = g_cancellable_new();
@@ -342,16 +342,16 @@ nm_sleep_monitor_init(NMSleepMonitor *self)
self);
}
-NMSleepMonitor *
-nm_sleep_monitor_new(void)
+NMPowerMonitor *
+nm_power_monitor_new(void)
{
- return g_object_new(NM_TYPE_SLEEP_MONITOR, NULL);
+ return g_object_new(NM_TYPE_POWER_MONITOR, NULL);
}
static void
dispose(GObject *object)
{
- NMSleepMonitor *self = NM_SLEEP_MONITOR(object);
+ NMPowerMonitor *self = NM_POWER_MONITOR(object);
#if !USE_UPOWER
drop_inhibitor(self, TRUE);
@@ -365,11 +365,11 @@ dispose(GObject *object)
g_clear_object(&self->proxy);
}
- G_OBJECT_CLASS(nm_sleep_monitor_parent_class)->dispose(object);
+ G_OBJECT_CLASS(nm_power_monitor_parent_class)->dispose(object);
}
static void
-nm_sleep_monitor_class_init(NMSleepMonitorClass *klass)
+nm_power_monitor_class_init(NMPowerMonitorClass *klass)
{
GObjectClass *gobject_class;
@@ -377,8 +377,8 @@ nm_sleep_monitor_class_init(NMSleepMonitorClass *klass)
gobject_class->dispose = dispose;
- signals[SLEEPING] = g_signal_new(NM_SLEEP_MONITOR_SLEEPING,
- NM_TYPE_SLEEP_MONITOR,
+ signals[SLEEPING] = g_signal_new(NM_POWER_MONITOR_SLEEPING,
+ NM_TYPE_POWER_MONITOR,
G_SIGNAL_RUN_LAST,
0,
NULL,
diff --git a/src/core/nm-power-monitor.h b/src/core/nm-power-monitor.h
new file mode 100644
index 0000000000..e4bbe11588
--- /dev/null
+++ b/src/core/nm-power-monitor.h
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2012 - 2016 Red Hat, Inc.
+ * Author: Matthias Clasen <mclasen@redhat.com>
+ */
+
+#ifndef __NETWORKMANAGER_POWER_MONITOR_H__
+#define __NETWORKMANAGER_POWER_MONITOR_H__
+
+#define NM_TYPE_POWER_MONITOR (nm_power_monitor_get_type())
+#define NM_POWER_MONITOR(o) \
+ (_NM_G_TYPE_CHECK_INSTANCE_CAST((o), NM_TYPE_POWER_MONITOR, NMPowerMonitor))
+#define NM_POWER_MONITOR_CLASS(k) \
+ (G_TYPE_CHECK_CLASS_CAST((k), NM_TYPE_POWER_MONITOR, NMPowerMonitorClass))
+#define NM_POWER_MONITOR_GET_CLASS(o) \
+ (G_TYPE_INSTANCE_GET_CLASS((o), NM_TYPE_POWER_MONITOR, NMPowerMonitorClass))
+#define NM_IS_POWER_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), NM_TYPE_POWER_MONITOR))
+#define NM_IS_POWER_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), NM_TYPE_POWER_MONITOR))
+
+#define NM_POWER_MONITOR_SLEEPING "sleeping"
+
+typedef struct _NMPowerMonitorClass NMPowerMonitorClass;
+
+GType nm_power_monitor_get_type(void) G_GNUC_CONST;
+
+NMPowerMonitor *nm_power_monitor_new(void);
+
+typedef struct _NMPowerMonitorInhibitorHandle NMPowerMonitorInhibitorHandle;
+
+NMPowerMonitorInhibitorHandle *nm_power_monitor_inhibit_take(NMPowerMonitor *self);
+void nm_power_monitor_inhibit_release(NMPowerMonitor *self, NMPowerMonitorInhibitorHandle *handle);
+
+#endif /* __NETWORKMANAGER_POWER_MONITOR_H__ */
diff --git a/src/core/nm-sleep-monitor.h b/src/core/nm-sleep-monitor.h
deleted file mode 100644
index 0b7708db27..0000000000
--- a/src/core/nm-sleep-monitor.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
-/*
- * Copyright (C) 2012 - 2016 Red Hat, Inc.
- * Author: Matthias Clasen <mclasen@redhat.com>
- */
-
-#ifndef __NETWORKMANAGER_SLEEP_MONITOR_H__
-#define __NETWORKMANAGER_SLEEP_MONITOR_H__
-
-#define NM_TYPE_SLEEP_MONITOR (nm_sleep_monitor_get_type())
-#define NM_SLEEP_MONITOR(o) \
- (_NM_G_TYPE_CHECK_INSTANCE_CAST((o), NM_TYPE_SLEEP_MONITOR, NMSleepMonitor))
-#define NM_SLEEP_MONITOR_CLASS(k) \
- (G_TYPE_CHECK_CLASS_CAST((k), NM_TYPE_SLEEP_MONITOR, NMSleepMonitorClass))
-#define NM_SLEEP_MONITOR_GET_CLASS(o) \
- (G_TYPE_INSTANCE_GET_CLASS((o), NM_TYPE_SLEEP_MONITOR, NMSleepMonitorClass))
-#define NM_IS_SLEEP_MONITOR(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), NM_TYPE_SLEEP_MONITOR))
-#define NM_IS_SLEEP_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), NM_TYPE_SLEEP_MONITOR))
-
-#define NM_SLEEP_MONITOR_SLEEPING "sleeping"
-
-typedef struct _NMSleepMonitorClass NMSleepMonitorClass;
-
-GType nm_sleep_monitor_get_type(void) G_GNUC_CONST;
-
-NMSleepMonitor *nm_sleep_monitor_new(void);
-
-typedef struct _NMSleepMonitorInhibitorHandle NMSleepMonitorInhibitorHandle;
-
-NMSleepMonitorInhibitorHandle *nm_sleep_monitor_inhibit_take(NMSleepMonitor *self);
-void nm_sleep_monitor_inhibit_release(NMSleepMonitor *self, NMSleepMonitorInhibitorHandle *handle);
-
-#endif /* __NETWORKMANAGER_SLEEP_MONITOR_H__ */
diff --git a/src/core/nm-types.h b/src/core/nm-types.h
index 104a2f4b06..29b391fc88 100644
--- a/src/core/nm-types.h
+++ b/src/core/nm-types.h
@@ -33,7 +33,7 @@ typedef struct _NMRfkillManager NMRfkillManager;
typedef struct _NMPacrunnerManager NMPacrunnerManager;
typedef struct _NMSessionMonitor NMSessionMonitor;
typedef struct _NMKeepAlive NMKeepAlive;
-typedef struct _NMSleepMonitor NMSleepMonitor;
+typedef struct _NMPowerMonitor NMPowerMonitor;
typedef struct _NMLldpListener NMLldpListener;
typedef struct _NMConfigDeviceStateData NMConfigDeviceStateData;