mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-10 10:30:19 +01:00
sleep-monitor: make sleep-monitor not a singleton
The only user of the sleep-monitor singleton was NMManager anyway.
Also, even if we ever get more users that are interested in the SLEEPING
signal, we would hook them onto NMManager -- because NMManager should
collect, coordinate and possibly forward the SLEEPING signal. In no case,
another object should react on the SLEEPING signal and thus bypassing the
NMManager.
(cherry picked from commit 1e3b2cbb77)
This commit is contained in:
parent
ee561f8e89
commit
df245d7977
3 changed files with 12 additions and 18 deletions
|
|
@ -5264,7 +5264,7 @@ nm_manager_init (NMManager *self)
|
|||
self);
|
||||
|
||||
/* sleep/wake handling */
|
||||
priv->sleep_monitor = g_object_ref (nm_sleep_monitor_get ());
|
||||
priv->sleep_monitor = nm_sleep_monitor_new ();
|
||||
g_signal_connect (priv->sleep_monitor, NM_SLEEP_MONITOR_SLEEPING,
|
||||
G_CALLBACK (sleeping_cb), self);
|
||||
|
||||
|
|
|
|||
|
|
@ -90,8 +90,6 @@ static guint signals[LAST_SIGNAL] = {0};
|
|||
|
||||
G_DEFINE_TYPE (NMSleepMonitor, nm_sleep_monitor, G_TYPE_OBJECT);
|
||||
|
||||
NM_DEFINE_SINGLETON_GETTER (NMSleepMonitor, nm_sleep_monitor_get, NM_TYPE_SLEEP_MONITOR);
|
||||
|
||||
static void sleep_signal (NMSleepMonitor *self, gboolean is_about_to_suspend);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -99,20 +97,10 @@ static void sleep_signal (NMSleepMonitor *self, gboolean is_about_to_suspend);
|
|||
#define _NMLOG_DOMAIN LOGD_SUSPEND
|
||||
#define _NMLOG(level, ...) \
|
||||
G_STMT_START { \
|
||||
const NMLogLevel __level = (level); \
|
||||
\
|
||||
if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \
|
||||
char __prefix[20]; \
|
||||
const NMSleepMonitor *const __self = (self); \
|
||||
\
|
||||
_nm_log (__level, _NMLOG_DOMAIN, 0, \
|
||||
"%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
_NMLOG_PREFIX_NAME, \
|
||||
(!__self || __self == singleton_instance \
|
||||
? "" \
|
||||
: nm_sprintf_buf (__prefix, "[%p]", __self)) \
|
||||
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
|
||||
} \
|
||||
nm_log ((level), _NMLOG_DOMAIN, \
|
||||
"%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
|
||||
_NMLOG_PREFIX_NAME \
|
||||
_NM_UTILS_MACRO_REST (__VA_ARGS__)); \
|
||||
} G_STMT_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -303,6 +291,12 @@ nm_sleep_monitor_init (NMSleepMonitor *self)
|
|||
(GAsyncReadyCallback) on_proxy_acquired, self);
|
||||
}
|
||||
|
||||
NMSleepMonitor *
|
||||
nm_sleep_monitor_new (void)
|
||||
{
|
||||
return g_object_new (NM_TYPE_SLEEP_MONITOR, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
dispose (GObject *object)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ G_BEGIN_DECLS
|
|||
typedef struct _NMSleepMonitorClass NMSleepMonitorClass;
|
||||
|
||||
GType nm_sleep_monitor_get_type (void) G_GNUC_CONST;
|
||||
NMSleepMonitor *nm_sleep_monitor_get (void);
|
||||
NMSleepMonitor *nm_sleep_monitor_new (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue