diff options
-rw-r--r-- | cli/mmcli-manager.c | 3 | ||||
-rw-r--r-- | cli/mmcli-modem.c | 24 | ||||
-rw-r--r-- | cli/mmcli.c | 35 | ||||
-rw-r--r-- | cli/mmcli.h | 4 |
4 files changed, 40 insertions, 26 deletions
diff --git a/cli/mmcli-manager.c b/cli/mmcli-manager.c index ee0bff8c..de6886fe 100644 --- a/cli/mmcli-manager.c +++ b/cli/mmcli-manager.c @@ -98,6 +98,9 @@ mmcli_manager_options_enabled (void) exit (EXIT_FAILURE); } + if (monitor_modems_flag) + mmcli_force_async_operation (); + return !!n_actions; } diff --git a/cli/mmcli-modem.c b/cli/mmcli-modem.c index 1c7703ac..72e2a34e 100644 --- a/cli/mmcli-modem.c +++ b/cli/mmcli-modem.c @@ -115,6 +115,12 @@ mmcli_modem_options_enabled (void) exit (EXIT_FAILURE); } + if (monitor_state_flag) + mmcli_force_async_operation (); + + if (info_flag) + mmcli_force_sync_operation (); + return !!n_actions; } @@ -436,16 +442,8 @@ get_modem_ready (GObject *source, ctx->object = mmcli_get_modem_finish (result); ctx->modem = mm_object_get_modem (ctx->object); - /* Request to get info from modem? */ - if (info_flag) { - /* TODO */ - - /* mm_modem_get_info_async (ctxt.modem, */ - /* cancellable, */ - /* (GAsyncReadyCallback)get_info_ready, */ - /* NULL); */ - return; - } + if (info_flag) + g_assert_not_reached (); /* Request to monitor modems? */ if (monitor_state_flag) { @@ -530,10 +528,8 @@ mmcli_modem_run_synchronous (GDBusConnection *connection) { GError *error = NULL; - if (monitor_state_flag) { - g_printerr ("error: monitoring state cannot be done synchronously\n"); - exit (EXIT_FAILURE); - } + if (monitor_state_flag) + g_assert_not_reached (); /* Initialize context */ ctx = g_new0 (Context, 1); diff --git a/cli/mmcli.c b/cli/mmcli.c index 7fee76f2..d51af868 100644 --- a/cli/mmcli.c +++ b/cli/mmcli.c @@ -144,6 +144,24 @@ mmcli_async_operation_done (void) g_main_loop_quit (loop); } +void +mmcli_force_async_operation (void) +{ + if (!async_flag) { + g_debug ("Forcing request to be run asynchronously"); + async_flag = TRUE; + } +} + +void +mmcli_force_sync_operation (void) +{ + if (async_flag) { + g_debug ("Ignoring request to run asynchronously"); + async_flag = FALSE; + } +} + gint main (gint argc, gchar **argv) { @@ -184,12 +202,9 @@ main (gint argc, gchar **argv) exit (EXIT_FAILURE); } - /* Setup context for asynchronous operations */ - if (async_flag) { - g_debug ("Running asynchronous operations..."); - loop = g_main_loop_new (NULL, FALSE); - cancellable = g_cancellable_new (); - } + /* Create requirements for async options */ + cancellable = g_cancellable_new (); + loop = g_main_loop_new (NULL, FALSE); /* Manager options? */ if (mmcli_manager_options_enabled ()) { @@ -219,12 +234,8 @@ main (gint argc, gchar **argv) } /* Run loop only in async operations */ - if (async_flag) { + if (async_flag) g_main_loop_run (loop); - if (cancellable) - g_object_unref (cancellable); - g_main_loop_unref (loop); - } if (mmcli_manager_options_enabled ()) { mmcli_manager_shutdown (); @@ -232,6 +243,8 @@ main (gint argc, gchar **argv) mmcli_modem_shutdown (); } + g_object_unref (cancellable); + g_main_loop_unref (loop); g_object_unref (connection); return EXIT_SUCCESS; diff --git a/cli/mmcli.h b/cli/mmcli.h index 37647141..04f45813 100644 --- a/cli/mmcli.h +++ b/cli/mmcli.h @@ -24,7 +24,9 @@ #define __MMCLI_H__ /* Common */ -void mmcli_async_operation_done (void); +void mmcli_async_operation_done (void); +void mmcli_force_async_operation (void); +void mmcli_force_sync_operation (void); /* Manager group */ GOptionGroup *mmcli_manager_get_option_group (void); |