From f69098819b58a6f2f7012376e34035503daa876c Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 17 Dec 2018 13:53:55 +0100 Subject: 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. --- src/mm-iface-modem-firmware.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'src/mm-iface-modem-firmware.c') 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); -- cgit v1.2.3-70-g09d2