aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2015-01-16 09:52:05 +0100
committerAleksander Morgado <aleksander@aleksander.es>2015-02-07 12:57:48 +0100
commitb6f8e5f08de8860b4c54609a3648cb86a04244ea (patch)
tree34640c5fc0472d578479aab3f74672e9891db495 /src/main.c
parent132fbb0a7f51d01f11094367ee1f76cdafca350b (diff)
suspend: invalidate and remove modems on suspend, reprobe on resume
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 47fa6135..8a3ebaba 100644
--- a/src/main.c
+++ b/src/main.c
@@ -30,6 +30,10 @@
#include "mm-log.h"
#include "mm-context.h"
+#if WITH_SUSPEND_RESUME
+# include "mm-sleep-monitor.h"
+#endif
+
/* Maximum time to wait for all modems to get disabled and removed */
#define MAX_SHUTDOWN_TIME_SECS 20
@@ -51,6 +55,24 @@ quit_cb (gpointer user_data)
return FALSE;
}
+#if WITH_SUSPEND_RESUME
+
+static void
+sleeping_cb (MMSleepMonitor *sleep_monitor)
+{
+ mm_dbg ("Removing devices... (sleeping)");
+ mm_base_manager_shutdown (manager, FALSE);
+}
+
+static void
+resuming_cb (MMSleepMonitor *sleep_monitor)
+{
+ mm_dbg ("Re-scanning (resuming)");
+ mm_base_manager_start (manager, FALSE);
+}
+
+#endif
+
static void
bus_acquired_cb (GDBusConnection *connection,
const gchar *name,
@@ -144,6 +166,15 @@ main (int argc, char *argv[])
name_lost_cb,
NULL,
NULL);
+#if WITH_SUSPEND_RESUME
+ {
+ MMSleepMonitor *sleep_monitor;
+
+ sleep_monitor = mm_sleep_monitor_get ();
+ g_signal_connect (sleep_monitor, MM_SLEEP_MONITOR_SLEEPING, G_CALLBACK (sleeping_cb), NULL);
+ g_signal_connect (sleep_monitor, MM_SLEEP_MONITOR_RESUMING, G_CALLBACK (resuming_cb), NULL);
+ }
+#endif
/* Go into the main loop */
loop = g_main_loop_new (NULL, FALSE);
@@ -157,7 +188,7 @@ main (int argc, char *argv[])
if (manager) {
GTimer *timer;
- mm_base_manager_shutdown (manager);
+ mm_base_manager_shutdown (manager, TRUE);
/* Wait for all modems to be disabled and removed, but don't wait
* forever: if disabling the modems takes longer than 20s, just