aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2018-12-17 13:53:55 +0100
committerDan Williams <dcbw@redhat.com>2019-01-03 18:53:52 +0000
commitf69098819b58a6f2f7012376e34035503daa876c (patch)
tree3d0cc8f2b973b4e0afb629bc5b1089487d365cdf
parentfc02b1320c91367be8f1b9d073fc0da473538647 (diff)
iface-modem-firmware: List() and Select() are now optional
Since the Firmware interface now contains more actions and properties apart from List() and Select(), these two actions are now optional. Not all modems implementing the Firmware interface must implement these two methods.
-rw-r--r--src/mm-iface-modem-firmware.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/mm-iface-modem-firmware.c b/src/mm-iface-modem-firmware.c
index 06f07754..571758a7 100644
--- a/src/mm-iface-modem-firmware.c
+++ b/src/mm-iface-modem-firmware.c
@@ -126,6 +126,18 @@ list_auth_ready (MMBaseModem *self,
return;
}
+ if (!MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->load_list ||
+ !MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->load_list_finish ||
+ !MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->load_current ||
+ !MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->load_current_finish) {
+ g_dbus_method_invocation_return_error (ctx->invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_UNSUPPORTED,
+ "Cannot list firmware: operation not supported");
+ handle_list_context_free (ctx);
+ return;
+ }
+
MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->load_list (MM_IFACE_MODEM_FIRMWARE (self),
(GAsyncReadyCallback)load_list_ready,
ctx);
@@ -138,11 +150,6 @@ handle_list (MmGdbusModemFirmware *skeleton,
{
HandleListContext *ctx;
- g_assert (MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->load_list != NULL);
- g_assert (MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->load_list_finish != NULL);
- g_assert (MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->load_current != NULL);
- g_assert (MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->load_current_finish != NULL);
-
ctx = g_slice_new (HandleListContext);
ctx->skeleton = g_object_ref (skeleton);
ctx->invocation = g_object_ref (invocation);
@@ -204,6 +211,17 @@ select_auth_ready (MMBaseModem *self,
return;
}
+
+ if (!MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->change_current ||
+ !MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->change_current_finish) {
+ g_dbus_method_invocation_return_error (ctx->invocation,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_UNSUPPORTED,
+ "Cannot select firmware: operation not supported");
+ handle_select_context_free (ctx);
+ return;
+ }
+
MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->change_current (MM_IFACE_MODEM_FIRMWARE (self),
ctx->name,
(GAsyncReadyCallback)change_current_ready,
@@ -218,9 +236,6 @@ handle_select (MmGdbusModemFirmware *skeleton,
{
HandleSelectContext *ctx;
- g_assert (MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->change_current != NULL);
- g_assert (MM_IFACE_MODEM_FIRMWARE_GET_INTERFACE (self)->change_current_finish != NULL);
-
ctx = g_slice_new (HandleSelectContext);
ctx->skeleton = g_object_ref (skeleton);
ctx->invocation = g_object_ref (invocation);