From 467b8892ae4c5107247fb2dc030bbf2becb07cac Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 26 Mar 2012 12:09:33 +0200 Subject: mmcli: ensure the modem exports the Simple interface before trying to use it --- cli/mmcli-modem-simple.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'cli/mmcli-modem-simple.c') diff --git a/cli/mmcli-modem-simple.c b/cli/mmcli-modem-simple.c index 65f615b5..29df8a34 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 (); -- cgit v1.2.3-70-g09d2