broadband-modem-qmi: port modem_3gpp_load_enabled_facility_locks to use GTask
This commit is contained in:

committed by
Aleksander Morgado

parent
8ad01d31ac
commit
f3b2deadda
@@ -3844,23 +3844,18 @@ modem_3gpp_load_imei (MMIfaceModem3gpp *_self,
|
|||||||
/* Facility locks status loading (3GPP interface) */
|
/* Facility locks status loading (3GPP interface) */
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
MMBroadbandModem *self;
|
|
||||||
GSimpleAsyncResult *result;
|
|
||||||
QmiClient *client;
|
QmiClient *client;
|
||||||
guint current;
|
guint current;
|
||||||
MMModem3gppFacility facilities;
|
MMModem3gppFacility facilities;
|
||||||
MMModem3gppFacility locks;
|
MMModem3gppFacility locks;
|
||||||
} LoadEnabledFacilityLocksContext;
|
} LoadEnabledFacilityLocksContext;
|
||||||
|
|
||||||
static void get_next_facility_lock_status (LoadEnabledFacilityLocksContext *ctx);
|
static void get_next_facility_lock_status (GTask *task);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_enabled_facility_locks_context_complete_and_free (LoadEnabledFacilityLocksContext *ctx)
|
load_enabled_facility_locks_context_free (LoadEnabledFacilityLocksContext *ctx)
|
||||||
{
|
{
|
||||||
g_simple_async_result_complete (ctx->result);
|
|
||||||
g_object_unref (ctx->result);
|
|
||||||
g_object_unref (ctx->client);
|
g_object_unref (ctx->client);
|
||||||
g_object_unref (ctx->self);
|
|
||||||
g_free (ctx);
|
g_free (ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3869,21 +3864,28 @@ modem_3gpp_load_enabled_facility_locks_finish (MMIfaceModem3gpp *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
|
GError *inner_error = NULL;
|
||||||
return MM_MODEM_3GPP_FACILITY_NONE;
|
gssize value;
|
||||||
|
|
||||||
return ((MMModem3gppFacility) GPOINTER_TO_UINT (
|
value = g_task_propagate_int (G_TASK (res), &inner_error);
|
||||||
g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res))));
|
if (inner_error) {
|
||||||
|
g_propagate_error (error, inner_error);
|
||||||
|
return MM_MODEM_3GPP_FACILITY_NONE;
|
||||||
|
}
|
||||||
|
return (MMModem3gppFacility)value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_sim_lock_status_via_pin_status_ready (QmiClientDms *client,
|
get_sim_lock_status_via_pin_status_ready (QmiClientDms *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
LoadEnabledFacilityLocksContext *ctx)
|
GTask *task)
|
||||||
{
|
{
|
||||||
|
LoadEnabledFacilityLocksContext *ctx;
|
||||||
QmiMessageDmsUimGetPinStatusOutput *output;
|
QmiMessageDmsUimGetPinStatusOutput *output;
|
||||||
gboolean enabled;
|
gboolean enabled;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
|
|
||||||
output = qmi_client_dms_uim_get_pin_status_finish (client, res, NULL);
|
output = qmi_client_dms_uim_get_pin_status_finish (client, res, NULL);
|
||||||
if (!output ||
|
if (!output ||
|
||||||
!qmi_message_dms_uim_get_pin_status_output_get_result (output, NULL)) {
|
!qmi_message_dms_uim_get_pin_status_output_get_result (output, NULL)) {
|
||||||
@@ -3916,17 +3918,19 @@ get_sim_lock_status_via_pin_status_ready (QmiClientDms *client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* No more facilities to query, all done */
|
/* No more facilities to query, all done */
|
||||||
g_simple_async_result_set_op_res_gpointer (ctx->result,
|
g_task_return_int (task, ctx->locks);
|
||||||
GUINT_TO_POINTER (ctx->locks),
|
g_object_unref (task);
|
||||||
NULL);
|
|
||||||
load_enabled_facility_locks_context_complete_and_free (ctx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the SIM lock cannot be queried with the qmi_get_ck_status function,
|
/* the SIM lock cannot be queried with the qmi_get_ck_status function,
|
||||||
* therefore using the PIN status */
|
* therefore using the PIN status */
|
||||||
static void
|
static void
|
||||||
get_sim_lock_status_via_pin_status (LoadEnabledFacilityLocksContext *ctx)
|
get_sim_lock_status_via_pin_status (GTask *task)
|
||||||
{
|
{
|
||||||
|
LoadEnabledFacilityLocksContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
|
|
||||||
mm_dbg ("Retrieving PIN status to check for enabled PIN");
|
mm_dbg ("Retrieving PIN status to check for enabled PIN");
|
||||||
/* if the SIM is locked or not can only be queried by locking at
|
/* if the SIM is locked or not can only be queried by locking at
|
||||||
* the PIN status */
|
* the PIN status */
|
||||||
@@ -3935,17 +3939,19 @@ get_sim_lock_status_via_pin_status (LoadEnabledFacilityLocksContext *ctx)
|
|||||||
5,
|
5,
|
||||||
NULL,
|
NULL,
|
||||||
(GAsyncReadyCallback)get_sim_lock_status_via_pin_status_ready,
|
(GAsyncReadyCallback)get_sim_lock_status_via_pin_status_ready,
|
||||||
ctx);
|
task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dms_uim_get_ck_status_ready (QmiClientDms *client,
|
dms_uim_get_ck_status_ready (QmiClientDms *client,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
LoadEnabledFacilityLocksContext *ctx)
|
GTask *task)
|
||||||
{
|
{
|
||||||
|
LoadEnabledFacilityLocksContext *ctx;
|
||||||
gchar *facility_str;
|
gchar *facility_str;
|
||||||
QmiMessageDmsUimGetCkStatusOutput *output;
|
QmiMessageDmsUimGetCkStatusOutput *output;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
facility_str = mm_modem_3gpp_facility_build_string_from_mask (1 << ctx->current);
|
facility_str = mm_modem_3gpp_facility_build_string_from_mask (1 << ctx->current);
|
||||||
output = qmi_client_dms_uim_get_ck_status_finish (client, res, NULL);
|
output = qmi_client_dms_uim_get_ck_status_finish (client, res, NULL);
|
||||||
if (!output ||
|
if (!output ||
|
||||||
@@ -3981,14 +3987,17 @@ dms_uim_get_ck_status_ready (QmiClientDms *client,
|
|||||||
|
|
||||||
/* And go on with the next one */
|
/* And go on with the next one */
|
||||||
ctx->current++;
|
ctx->current++;
|
||||||
get_next_facility_lock_status (ctx);
|
get_next_facility_lock_status (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_next_facility_lock_status (LoadEnabledFacilityLocksContext *ctx)
|
get_next_facility_lock_status (GTask *task)
|
||||||
{
|
{
|
||||||
|
LoadEnabledFacilityLocksContext *ctx;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
ctx = g_task_get_task_data (task);
|
||||||
|
|
||||||
for (i = ctx->current; i < sizeof (MMModem3gppFacility) * 8; i++) {
|
for (i = ctx->current; i < sizeof (MMModem3gppFacility) * 8; i++) {
|
||||||
guint32 facility = 1 << i;
|
guint32 facility = 1 << i;
|
||||||
|
|
||||||
@@ -4010,13 +4019,13 @@ get_next_facility_lock_status (LoadEnabledFacilityLocksContext *ctx)
|
|||||||
5,
|
5,
|
||||||
NULL,
|
NULL,
|
||||||
(GAsyncReadyCallback)dms_uim_get_ck_status_ready,
|
(GAsyncReadyCallback)dms_uim_get_ck_status_ready,
|
||||||
ctx);
|
task);
|
||||||
qmi_message_dms_uim_get_ck_status_input_unref (input);
|
qmi_message_dms_uim_get_ck_status_input_unref (input);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get_sim_lock_status_via_pin_status (ctx);
|
get_sim_lock_status_via_pin_status (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -4025,20 +4034,17 @@ modem_3gpp_load_enabled_facility_locks (MMIfaceModem3gpp *self,
|
|||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
LoadEnabledFacilityLocksContext *ctx;
|
LoadEnabledFacilityLocksContext *ctx;
|
||||||
|
GTask *task;
|
||||||
QmiClient *client = NULL;
|
QmiClient *client = NULL;
|
||||||
|
|
||||||
if (!ensure_qmi_client (MM_BROADBAND_MODEM_QMI (self),
|
if (!assure_qmi_client (MM_BROADBAND_MODEM_QMI (self),
|
||||||
QMI_SERVICE_DMS, &client,
|
QMI_SERVICE_DMS, &client,
|
||||||
callback, user_data))
|
callback, user_data))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ctx = g_new (LoadEnabledFacilityLocksContext, 1);
|
ctx = g_new (LoadEnabledFacilityLocksContext, 1);
|
||||||
ctx->self = g_object_ref (self);
|
|
||||||
ctx->client = g_object_ref (client);
|
ctx->client = g_object_ref (client);
|
||||||
ctx->result = g_simple_async_result_new (G_OBJECT (self),
|
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
modem_3gpp_load_enabled_facility_locks);
|
|
||||||
/* Set initial list of facilities to query */
|
/* Set initial list of facilities to query */
|
||||||
ctx->facilities = (MM_MODEM_3GPP_FACILITY_PH_SIM |
|
ctx->facilities = (MM_MODEM_3GPP_FACILITY_PH_SIM |
|
||||||
MM_MODEM_3GPP_FACILITY_NET_PERS |
|
MM_MODEM_3GPP_FACILITY_NET_PERS |
|
||||||
@@ -4048,7 +4054,10 @@ modem_3gpp_load_enabled_facility_locks (MMIfaceModem3gpp *self,
|
|||||||
ctx->locks = MM_MODEM_3GPP_FACILITY_NONE;
|
ctx->locks = MM_MODEM_3GPP_FACILITY_NONE;
|
||||||
ctx->current = 0;
|
ctx->current = 0;
|
||||||
|
|
||||||
get_next_facility_lock_status (ctx);
|
task = g_task_new (self, NULL, callback, user_data);
|
||||||
|
g_task_set_task_data (task, ctx, (GDestroyNotify)load_enabled_facility_locks_context_free);
|
||||||
|
|
||||||
|
get_next_facility_lock_status (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Reference in New Issue
Block a user