iface-modem: refactor user request to list bearers

This commit is contained in:
Aleksander Morgado
2022-09-12 12:04:24 +00:00
parent f1fa2eb81e
commit f98bcd5f58

View File

@@ -1203,12 +1203,12 @@ handle_delete_bearer (MmGdbusModem *skeleton,
/*****************************************************************************/ /*****************************************************************************/
static gboolean static gboolean
handle_list_bearers (MmGdbusModem *skeleton, handle_list_bearers (MmGdbusModem *skeleton,
GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation,
MMIfaceModem *self) MMIfaceModem *self)
{ {
GStrv paths; g_auto(GStrv) paths = NULL;
MMBearerList *list = NULL; g_autoptr(MMBearerList) list = NULL;
if (mm_iface_modem_abort_invocation_if_state_not_reached (self, invocation, MM_MODEM_STATE_LOCKED)) if (mm_iface_modem_abort_invocation_if_state_not_reached (self, invocation, MM_MODEM_STATE_LOCKED))
return TRUE; return TRUE;
@@ -1217,20 +1217,13 @@ handle_list_bearers (MmGdbusModem *skeleton,
MM_IFACE_MODEM_BEARER_LIST, &list, MM_IFACE_MODEM_BEARER_LIST, &list,
NULL); NULL);
if (!list) { if (!list) {
g_dbus_method_invocation_return_error (invocation, g_dbus_method_invocation_return_error (invocation, MM_CORE_ERROR, MM_CORE_ERROR_FAILED,
MM_CORE_ERROR,
MM_CORE_ERROR_FAILED,
"Bearer list not found"); "Bearer list not found");
return TRUE; return TRUE;
} }
paths = mm_bearer_list_get_paths (list); paths = mm_bearer_list_get_paths (list);
mm_gdbus_modem_complete_list_bearers (skeleton, mm_gdbus_modem_complete_list_bearers (skeleton, invocation, (const gchar *const *)paths);
invocation,
(const gchar *const *)paths);
g_strfreev (paths);
g_object_unref (list);
return TRUE; return TRUE;
} }