diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-26 12:09:33 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-26 12:09:33 +0200 |
commit | 467b8892ae4c5107247fb2dc030bbf2becb07cac (patch) | |
tree | 6248a8b58f12b8b24e46b44dd08fac671ec3fa10 | |
parent | fec294b2265ef897967d3b01685108c79c21f59e (diff) | |
download | ModemManager-467b8892ae4c5107247fb2dc030bbf2becb07cac.tar.gz |
mmcli: ensure the modem exports the Simple interface before trying to use it
-rw-r--r-- | cli/mmcli-modem-simple.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cli/mmcli-modem-simple.c b/cli/mmcli-modem-simple.c index 65f615b52..29df8a340 100644 --- a/cli/mmcli-modem-simple.c +++ b/cli/mmcli-modem-simple.c @@ -122,6 +122,16 @@ context_free (Context *ctx) g_free (ctx); } +static void +ensure_modem_simple (void) +{ + if (ctx->modem_simple) + return; + + g_printerr ("error: modem has no Simple capabilities\n"); + exit (EXIT_FAILURE); +} + void mmcli_modem_simple_shutdown (void) { @@ -312,6 +322,8 @@ get_modem_ready (GObject *source, ctx->object = mmcli_get_modem_finish (result, &ctx->manager); ctx->modem_simple = mm_object_get_modem_simple (ctx->object); + ensure_modem_simple (); + /* Request to connect the modem? */ if (connect_str) { GError *error = NULL; @@ -389,6 +401,8 @@ mmcli_modem_simple_run_synchronous (GDBusConnection *connection) &ctx->manager); ctx->modem_simple = mm_object_get_modem_simple (ctx->object); + ensure_modem_simple (); + if (connect_str) g_assert_not_reached (); |