mmcli: ensure the modem exports the Simple interface before trying to use it

This commit is contained in:
Aleksander Morgado
2012-03-26 12:09:33 +02:00
parent fec294b226
commit 467b8892ae

View File

@@ -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 ();