diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-10-09 18:21:02 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-03-22 08:12:59 +0100 |
commit | 3e5251cad703dcb7ec679fae215f4cb01503df4e (patch) | |
tree | 1f2263ea5aad926957e89d28aac7cd697f4c4750 | |
parent | 5cc98341ad5fbafd3d8f83c65767f604b0e5a5e4 (diff) |
broadband-modem-qmi: implement initial CDMA activation state loading
-rw-r--r-- | src/mm-broadband-modem-qmi.c | 97 | ||||
-rw-r--r-- | src/mm-modem-helpers-qmi.c | 27 | ||||
-rw-r--r-- | src/mm-modem-helpers-qmi.h | 2 |
3 files changed, 126 insertions, 0 deletions
diff --git a/src/mm-broadband-modem-qmi.c b/src/mm-broadband-modem-qmi.c index 4a316c55..da667fef 100644 --- a/src/mm-broadband-modem-qmi.c +++ b/src/mm-broadband-modem-qmi.c @@ -4493,6 +4493,101 @@ modem_cdma_run_registration_checks (MMIfaceModemCdma *self, } /*****************************************************************************/ +/* Load initial activation state (CDMA interface) */ + +typedef struct { + MMBroadbandModemQmi *self; + QmiClientDms *client; + GSimpleAsyncResult *result; +} LoadActivationStateContext; + +static void +load_activation_state_context_complete_and_free (LoadActivationStateContext *ctx) +{ + g_simple_async_result_complete (ctx->result); + g_object_unref (ctx->result); + g_object_unref (ctx->client); + g_object_unref (ctx->self); + g_slice_free (LoadActivationStateContext, ctx); +} + +static MMModemCdmaActivationState +modem_cdma_load_activation_state_finish (MMIfaceModemCdma *self, + GAsyncResult *res, + GError **error) +{ + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) + return MM_MODEM_CDMA_ACTIVATION_STATE_UNKNOWN; + + return (MMModemCdmaActivationState) GPOINTER_TO_UINT (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res))); +} + +static void +get_activation_state_ready (QmiClientDms *client, + GAsyncResult *res, + LoadActivationStateContext *ctx) +{ + QmiDmsActivationState state = QMI_DMS_ACTIVATION_STATE_NOT_ACTIVATED; + QmiMessageDmsGetActivationStateOutput *output; + GError *error = NULL; + + output = qmi_client_dms_get_activation_state_finish (client, res, &error); + if (!output) { + g_prefix_error (&error, "QMI operation failed: "); + g_simple_async_result_take_error (ctx->result, error); + load_activation_state_context_complete_and_free (ctx); + return; + } + + if (!qmi_message_dms_get_activation_state_output_get_result (output, &error)) { + g_prefix_error (&error, "Couldn't get activation state: "); + g_simple_async_result_take_error (ctx->result, error); + qmi_message_dms_get_activation_state_output_unref (output); + load_activation_state_context_complete_and_free (ctx); + return; + } + + qmi_message_dms_get_activation_state_output_get_info (output, &state, NULL); + qmi_message_dms_get_activation_state_output_unref (output); + + g_simple_async_result_set_op_res_gpointer ( + ctx->result, + GUINT_TO_POINTER (mm_modem_cdma_activation_state_from_qmi_activation_state (state)), + NULL); + load_activation_state_context_complete_and_free (ctx); +} + +static void +modem_cdma_load_activation_state (MMIfaceModemCdma *self, + GAsyncReadyCallback callback, + gpointer user_data) +{ + LoadActivationStateContext *ctx; + QmiClient *client = NULL; + + if (!ensure_qmi_client (MM_BROADBAND_MODEM_QMI (self), + QMI_SERVICE_DMS, &client, + callback, user_data)) + return; + + /* Setup context */ + ctx = g_slice_new0 (LoadActivationStateContext); + ctx->self = g_object_ref (self); + ctx->client = g_object_ref (client); + ctx->result = g_simple_async_result_new (G_OBJECT (self), + callback, + user_data, + modem_cdma_load_activation_state); + + qmi_client_dms_get_activation_state (ctx->client, + NULL, + 10, + NULL, + (GAsyncReadyCallback)get_activation_state_ready, + ctx); +} + +/* /\*****************************************************************************\/ */ /* Setup/Cleanup unsolicited registration event handlers * (3GPP and CDMA interface) */ @@ -7589,6 +7684,8 @@ iface_modem_cdma_init (MMIfaceModemCdma *iface) /* Other actions */ iface->run_registration_checks = modem_cdma_run_registration_checks; iface->run_registration_checks_finish = modem_cdma_run_registration_checks_finish; + iface->load_activation_state = modem_cdma_load_activation_state; + iface->load_activation_state_finish = modem_cdma_load_activation_state_finish; } static void diff --git a/src/mm-modem-helpers-qmi.c b/src/mm-modem-helpers-qmi.c index f4d75992..7de04347 100644 --- a/src/mm-modem-helpers-qmi.c +++ b/src/mm-modem-helpers-qmi.c @@ -1059,6 +1059,33 @@ mm_modem_cdma_registration_state_from_qmi_registration_state (QmiNasRegistration /*****************************************************************************/ +MMModemCdmaActivationState +mm_modem_cdma_activation_state_from_qmi_activation_state (QmiDmsActivationState state) +{ + switch (state) { + case QMI_DMS_ACTIVATION_STATE_NOT_ACTIVATED: + return MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED; + case QMI_DMS_ACTIVATION_STATE_ACTIVATED: + return MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATED; + case QMI_DMS_ACTIVATION_STATE_CONNECTING: + case QMI_DMS_ACTIVATION_STATE_CONNECTED: + case QMI_DMS_ACTIVATION_STATE_OTASP_AUTHENTICATED: + case QMI_DMS_ACTIVATION_STATE_OTASP_NAM: + case QMI_DMS_ACTIVATION_STATE_OTASP_MDN: + case QMI_DMS_ACTIVATION_STATE_OTASP_IMSI: + case QMI_DMS_ACTIVATION_STATE_OTASP_PRL: + case QMI_DMS_ACTIVATION_STATE_OTASP_SPC: + return MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATING; + case QMI_DMS_ACTIVATION_STATE_OTASP_COMMITED: + return MM_MODEM_CDMA_ACTIVATION_STATE_PARTIALLY_ACTIVATED; + + default: + return MM_MODEM_CDMA_ACTIVATION_STATE_UNKNOWN; + } +} + +/*****************************************************************************/ + QmiWmsStorageType mm_sms_storage_to_qmi_storage_type (MMSmsStorage storage) { diff --git a/src/mm-modem-helpers-qmi.h b/src/mm-modem-helpers-qmi.h index 4446341f..711d655b 100644 --- a/src/mm-modem-helpers-qmi.h +++ b/src/mm-modem-helpers-qmi.h @@ -75,6 +75,8 @@ MMModem3gppRegistrationState mm_modem_3gpp_registration_state_from_qmi_registrat MMModemCdmaRegistrationState mm_modem_cdma_registration_state_from_qmi_registration_state (QmiNasRegistrationState registration_state); +MMModemCdmaActivationState mm_modem_cdma_activation_state_from_qmi_activation_state (QmiDmsActivationState state); + /*****************************************************************************/ /* QMI/WMS to MM translations */ |