summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-04-27 18:21:28 +0200
committerThomas Haller <thaller@redhat.com>2016-04-28 13:20:09 +0200
commit07db1217a9dad4610b3d556c38947ac66129b537 (patch)
treeb3be79f21c877655bbc474d15568eb845ab67f71
parent2208ca372603dc276eb9128a678fd1f9667d09d0 (diff)
downloadNetworkManager-07db1217a9dad4610b3d556c38947ac66129b537.tar.gz
sleep-monitor: merge RESUMING signal into NMSleepMonitor's SLEEPING signal
Having two signals is more complicated and everybody who cares about one signal also cares about the other.
-rw-r--r--src/nm-manager.c18
-rw-r--r--src/nm-sleep-monitor.c25
-rw-r--r--src/nm-sleep-monitor.h6
3 files changed, 13 insertions, 36 deletions
diff --git a/src/nm-manager.c b/src/nm-manager.c
index 3f6648b912..7f6d044bcc 100644
--- a/src/nm-manager.c
+++ b/src/nm-manager.c
@@ -4017,21 +4017,12 @@ impl_manager_sleep (NMManager *self,
}
static void
-sleeping_cb (NMSleepMonitor *monitor, gpointer user_data)
+sleeping_cb (NMSleepMonitor *monitor, gboolean is_about_to_suspend, gpointer user_data)
{
NMManager *self = user_data;
- _LOGD (LOGD_SUSPEND, "Received sleeping signal");
- _internal_sleep (self, TRUE);
-}
-
-static void
-resuming_cb (NMSleepMonitor *monitor, gpointer user_data)
-{
- NMManager *self = user_data;
-
- _LOGD (LOGD_SUSPEND, "Received resuming signal");
- _internal_sleep (self, FALSE);
+ _LOGD (LOGD_SUSPEND, "Received %s signal", is_about_to_suspend ? "sleeping" : "resuming");
+ _internal_sleep (self, is_about_to_suspend);
}
static void
@@ -5200,8 +5191,6 @@ nm_manager_init (NMManager *self)
priv->sleep_monitor = g_object_ref (nm_sleep_monitor_get ());
g_signal_connect (priv->sleep_monitor, NM_SLEEP_MONITOR_SLEEPING,
G_CALLBACK (sleeping_cb), self);
- g_signal_connect (priv->sleep_monitor, NM_SLEEP_MONITOR_RESUMING,
- G_CALLBACK (resuming_cb), self);
/* Listen for authorization changes */
g_signal_connect (nm_auth_manager_get (),
@@ -5438,7 +5427,6 @@ dispose (GObject *object)
if (priv->sleep_monitor) {
g_signal_handlers_disconnect_by_func (priv->sleep_monitor, sleeping_cb, manager);
- g_signal_handlers_disconnect_by_func (priv->sleep_monitor, resuming_cb, manager);
g_clear_object (&priv->sleep_monitor);
}
diff --git a/src/nm-sleep-monitor.c b/src/nm-sleep-monitor.c
index af9bf6fbfd..bc87743bf7 100644
--- a/src/nm-sleep-monitor.c
+++ b/src/nm-sleep-monitor.c
@@ -84,7 +84,6 @@ struct _NMSleepMonitorClass {
enum {
SLEEPING,
- RESUMING,
LAST_SIGNAL,
};
static guint signals[LAST_SIGNAL] = {0};
@@ -238,17 +237,17 @@ sleep_signal (NMSleepMonitor *self,
_LOGD ("received %s signal", is_about_to_suspend ? "SLEEP" : "RESUME");
- if (is_about_to_suspend) {
- g_signal_emit (self, signals[SLEEPING], 0);
#if !USE_UPOWER
- drop_inhibitor (self);
+ if (!is_about_to_suspend)
+ take_inhibitor (self);
#endif
- } else {
+
+ g_signal_emit (self, signals[SLEEPING], 0, is_about_to_suspend);
+
#if !USE_UPOWER
- take_inhibitor (self);
+ if (is_about_to_suspend)
+ drop_inhibitor (self);
#endif
- g_signal_emit (self, signals[RESUMING], 0);
- }
}
static void
@@ -337,13 +336,7 @@ nm_sleep_monitor_class_init (NMSleepMonitorClass *klass)
NM_TYPE_SLEEP_MONITOR,
G_SIGNAL_RUN_LAST,
0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
- signals[RESUMING] = g_signal_new (NM_SLEEP_MONITOR_RESUMING,
- NM_TYPE_SLEEP_MONITOR,
- G_SIGNAL_RUN_LAST,
- 0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
+ g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}
diff --git a/src/nm-sleep-monitor.h b/src/nm-sleep-monitor.h
index 21e6b844c8..222193ed19 100644
--- a/src/nm-sleep-monitor.h
+++ b/src/nm-sleep-monitor.h
@@ -13,16 +13,13 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * (C) Copyright 2012 Red Hat, Inc.
+ * (C) Copyright 2012-2016 Red Hat, Inc.
* Author: Matthias Clasen <mclasen@redhat.com>
*/
#ifndef __NETWORKMANAGER_SLEEP_MONITOR_H__
#define __NETWORKMANAGER_SLEEP_MONITOR_H__
-
-#include "nm-default.h"
-
G_BEGIN_DECLS
#define NM_TYPE_SLEEP_MONITOR (nm_sleep_monitor_get_type ())
@@ -33,7 +30,6 @@ G_BEGIN_DECLS
#define NM_IS_SLEEP_MONITOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NM_TYPE_SLEEP_MONITOR))
#define NM_SLEEP_MONITOR_SLEEPING "sleeping"
-#define NM_SLEEP_MONITOR_RESUMING "resuming"
typedef struct _NMSleepMonitorClass NMSleepMonitorClass;