From d088bb8d59ef77c100b155ac12a93f55834aa470 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sat, 30 Jun 2018 17:12:50 +0200 Subject: modem-helpers-qmi: new helper to transform QmiLocIndicationStatus into a GError --- src/mm-modem-helpers-qmi.c | 37 ++++++++++++++++++++++++++++++++++++- src/mm-modem-helpers-qmi.h | 6 ++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c index 911b9a6d6..ccc2a9122 100644 --- a/src/mm-modem-helpers-qmi.c +++ b/src/mm-modem-helpers-qmi.c @@ -10,9 +10,13 @@ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details: * - * Copyright (C) 2012 Google, Inc. + * Copyright (C) 2012-2018 Google, Inc. + * Copyright (C) 2018 Aleksander Morgado */ +#include +#include + #include "mm-modem-helpers-qmi.h" #include "mm-enums-types.h" #include "mm-log.h" @@ -1350,3 +1354,34 @@ mm_oma_session_state_failed_reason_from_qmi_oma_session_failed_reason (QmiOmaSes return MM_OMA_SESSION_STATE_FAILED_REASON_UNKNOWN; } } + +gboolean +mm_error_from_qmi_loc_indication_status (QmiLocIndicationStatus status, + GError **error) +{ + switch (status) { + case QMI_LOC_INDICATION_STATUS_SUCCESS: + return TRUE; + case QMI_LOC_INDICATION_STATUS_GENERAL_FAILURE: + g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "LOC service: general failure"); + return FALSE; + case QMI_LOC_INDICATION_STATUS_UNSUPPORTED: + g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED, "LOC service: unsupported"); + return FALSE; + case QMI_LOC_INDICATION_STATUS_INVALID_PARAMETER: + g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_INVALID_ARGS, "LOC service: invalid parameter"); + return FALSE; + case QMI_LOC_INDICATION_STATUS_ENGINE_BUSY: + g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_IN_PROGRESS, "LOC service: engine busy"); + return FALSE; + case QMI_LOC_INDICATION_STATUS_PHONE_OFFLINE: + g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_WRONG_STATE, "LOC service: phone offline"); + return FALSE; + case QMI_LOC_INDICATION_STATUS_TIMEOUT: + g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_ABORTED, "LOC service: timeout"); + return FALSE; + default: + g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "LOC service: unknown failure"); + return FALSE; + } +} diff --git a/src/mm-modem-helpers-qmi.h b/src/mm-modem-helpers-qmi.h index a19851fd9..8f02b95b5 100644 --- a/src/mm-modem-helpers-qmi.h +++ b/src/mm-modem-helpers-qmi.h @@ -105,6 +105,12 @@ MMOmaSessionState mm_oma_session_state_from_qmi_oma_session_state (QmiOmaSession MMOmaSessionStateFailedReason mm_oma_session_state_failed_reason_from_qmi_oma_session_failed_reason (QmiOmaSessionFailedReason qmi_session_failed_reason); +/*****************************************************************************/ +/* QMI/LOC to MM translations */ + +gboolean mm_error_from_qmi_loc_indication_status (QmiLocIndicationStatus status, + GError **error); + /*****************************************************************************/ /* Utility to gather current capabilities from various sources */ -- cgit v1.2.1