From de81520c4347f5203a179eeedb9f5188d89ab7c6 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 11 Feb 2019 15:04:53 +0100 Subject: [PATCH] cli: report modem removal in --monitor-state If the modem ends up not being managed by ModemManager, detect it during the '--monitor-state' mmcli operation and report it. https://gitlab.freedesktop.org/mobile-broadband/ModemManager/issues/106 --- cli/mmcli-modem.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cli/mmcli-modem.c b/cli/mmcli-modem.c index 2b7e3569..9c964294 100644 --- a/cli/mmcli-modem.c +++ b/cli/mmcli-modem.c @@ -900,6 +900,19 @@ state_changed (MMModem *modem, fflush (stdout); } +static void +device_removed (MMManager *manager, + MMObject *object) +{ + if (object != ctx->object) + return; + + g_print ("\t%s: Removed\n", mm_object_get_path (object)); + fflush (stdout); + + mmcli_async_operation_done (); +} + static void get_modem_ready (GObject *source, GAsyncResult *result, @@ -930,6 +943,11 @@ get_modem_ready (GObject *source, G_CALLBACK (state_changed), NULL); + g_signal_connect (ctx->manager, + "object-removed", + G_CALLBACK (device_removed), + NULL); + current = mm_modem_get_state (ctx->modem); g_print ("\t%s: Initial state, '%s'\n", mm_object_get_path (ctx->object),