aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmi-firmware-update/qfu-utils.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-02-15 15:17:00 +0100
committerAleksander Morgado <aleksander@aleksander.es>2017-02-23 09:53:56 +0100
commitf4cc493426df00f2ec6a768f6719826424dd5e73 (patch)
tree7a7ff58dacd711661d6a22d1560dec095a0f102f /src/qmi-firmware-update/qfu-utils.c
parent5a7d20a6a23961f316e1195050fa09bab97a52d3 (diff)
downloadexternal_libqmi-f4cc493426df00f2ec6a768f6719826424dd5e73.zip
external_libqmi-f4cc493426df00f2ec6a768f6719826424dd5e73.tar.gz
external_libqmi-f4cc493426df00f2ec6a768f6719826424dd5e73.tar.bz2
qmi-firmware-update: new optional runtime check to see if MM running
Enabled by default, may be disabled using --without-mm-runtime-check during configure.
Diffstat (limited to 'src/qmi-firmware-update/qfu-utils.c')
-rw-r--r--src/qmi-firmware-update/qfu-utils.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/qmi-firmware-update/qfu-utils.c b/src/qmi-firmware-update/qfu-utils.c
index 2667fbf..9109987 100644
--- a/src/qmi-firmware-update/qfu-utils.c
+++ b/src/qmi-firmware-update/qfu-utils.c
@@ -714,3 +714,49 @@ qfu_utils_power_cycle (QmiClientDms *qmi_client,
power_cycle_step (task);
}
+
+/******************************************************************************/
+
+#if defined WITH_MM_RUNTIME_CHECK
+
+gboolean
+qfu_utils_modemmanager_running (gboolean *mm_running,
+ GError **error)
+{
+ GDBusConnection *connection;
+ GVariant *response;
+ GError *inner_error = NULL;
+
+ g_assert (mm_running);
+
+ connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error);
+ if (!connection) {
+ g_prefix_error (error, "Couldn't get system bus: ");
+ return FALSE;
+ }
+
+ response = g_dbus_connection_call_sync (connection,
+ "org.freedesktop.ModemManager1",
+ "/org/freedesktop/ModemManager1",
+ "org.freedesktop.DBus.Peer",
+ "Ping",
+ NULL,
+ NULL,
+ G_DBUS_CALL_FLAGS_NO_AUTO_START,
+ -1,
+ NULL,
+ &inner_error);
+ if (!response) {
+ g_debug ("[qfu-utils] couldn't ping ModemManager: %s", inner_error->message);
+ g_error_free (inner_error);
+ *mm_running = FALSE;
+ } else {
+ *mm_running = TRUE;
+ g_variant_unref (response);
+ }
+
+ g_object_unref (connection);
+ return TRUE;
+}
+
+#endif