aboutsummaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/mmcli-manager.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/cli/mmcli-manager.c b/cli/mmcli-manager.c
index 810b0aa3..dac107c9 100644
--- a/cli/mmcli-manager.c
+++ b/cli/mmcli-manager.c
@@ -56,6 +56,7 @@ static gboolean list_modems_flag;
static gboolean monitor_modems_flag;
static gboolean scan_modems_flag;
static gchar *set_logging_str;
+static gchar *inhibit_device_str;
static gchar *report_kernel_event_str;
#if defined WITH_UDEV
@@ -83,6 +84,10 @@ static GOptionEntry entries[] = {
"Request to re-scan looking for modems",
NULL
},
+ { "inhibit-device", 'I', 0, G_OPTION_ARG_STRING, &inhibit_device_str,
+ "Inhibit device given a unique device identifier",
+ "[UID]"
+ },
{ "report-kernel-event", 'K', 0, G_OPTION_ARG_STRING, &report_kernel_event_str,
"Report kernel event",
"[\"key=value,...\"]"
@@ -126,6 +131,7 @@ mmcli_manager_options_enabled (void)
monitor_modems_flag +
scan_modems_flag +
!!set_logging_str +
+ !!inhibit_device_str +
!!report_kernel_event_str);
#if defined WITH_UDEV
@@ -145,7 +151,8 @@ mmcli_manager_options_enabled (void)
exit (EXIT_FAILURE);
}
mmcli_force_async_operation ();
- }
+ } else if (inhibit_device_str)
+ mmcli_force_async_operation ();
#if defined WITH_UDEV
if (report_kernel_event_auto_scan)
@@ -181,6 +188,41 @@ mmcli_manager_shutdown (void)
}
static void
+inhibition_cancelled (GCancellable *cancellable)
+{
+ GError *error = NULL;
+
+ if (!mm_manager_uninhibit_device_sync (ctx->manager, inhibit_device_str, NULL, &error)) {
+ g_printerr ("error: couldn't uninhibit device: '%s'\n",
+ error ? error->message : "unknown error");
+ } else
+ g_print ("successfully uninhibited device with uid '%s'\n", inhibit_device_str);
+
+ mmcli_async_operation_done ();
+}
+
+static void
+inhibit_device_ready (MMManager *manager,
+ GAsyncResult *result)
+{
+ GError *error = NULL;
+
+ if (!mm_manager_inhibit_device_finish (manager, result, &error)) {
+ g_printerr ("error: couldn't inhibit device: '%s'\n",
+ error ? error->message : "unknown error");
+ exit (EXIT_FAILURE);
+ }
+
+ g_print ("successfully inhibited device with uid '%s'\n", inhibit_device_str);
+ g_print ("type Ctrl+C to abort this program and remove the inhibition\n");
+
+ g_cancellable_connect (ctx->cancellable,
+ G_CALLBACK (inhibition_cancelled),
+ NULL,
+ NULL);
+}
+
+static void
report_kernel_event_process_reply (gboolean result,
const GError *error)
{
@@ -463,6 +505,16 @@ get_manager_ready (GObject *source,
return;
}
+ /* Request to inhibit device? */
+ if (inhibit_device_str) {
+ mm_manager_inhibit_device (ctx->manager,
+ inhibit_device_str,
+ ctx->cancellable,
+ (GAsyncReadyCallback)inhibit_device_ready,
+ NULL);
+ return;
+ }
+
g_warn_if_reached ();
}