mmcli: ensure the modem exports the Simple interface before trying to use it
This commit is contained in:
@@ -122,6 +122,16 @@ context_free (Context *ctx)
|
|||||||
g_free (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
|
void
|
||||||
mmcli_modem_simple_shutdown (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->object = mmcli_get_modem_finish (result, &ctx->manager);
|
||||||
ctx->modem_simple = mm_object_get_modem_simple (ctx->object);
|
ctx->modem_simple = mm_object_get_modem_simple (ctx->object);
|
||||||
|
|
||||||
|
ensure_modem_simple ();
|
||||||
|
|
||||||
/* Request to connect the modem? */
|
/* Request to connect the modem? */
|
||||||
if (connect_str) {
|
if (connect_str) {
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
@@ -389,6 +401,8 @@ mmcli_modem_simple_run_synchronous (GDBusConnection *connection)
|
|||||||
&ctx->manager);
|
&ctx->manager);
|
||||||
ctx->modem_simple = mm_object_get_modem_simple (ctx->object);
|
ctx->modem_simple = mm_object_get_modem_simple (ctx->object);
|
||||||
|
|
||||||
|
ensure_modem_simple ();
|
||||||
|
|
||||||
if (connect_str)
|
if (connect_str)
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user