sim-qmi: update IMSI using QMI

This commit is contained in:
Aleksander Morgado
2012-07-02 13:19:01 +02:00
parent 742527aa60
commit 6dc6f7bf0d

View File

@@ -137,6 +137,82 @@ load_sim_identifier (MMSim *self,
result);
}
/*****************************************************************************/
/* Load IMSI */
static gchar *
load_imsi_finish (MMSim *self,
GAsyncResult *res,
GError **error)
{
gchar *imsi;
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return NULL;
imsi = g_strdup (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
mm_dbg ("loaded IMSI: %s", imsi);
return imsi;
}
static void
dms_uim_get_imsi_ready (QmiClientDms *client,
GAsyncResult *res,
GSimpleAsyncResult *simple)
{
QmiMessageDmsUimGetImsiOutput *output = NULL;
GError *error = NULL;
output = qmi_client_dms_uim_get_imsi_finish (client, res, &error);
if (!output) {
g_prefix_error (&error, "QMI operation failed: ");
g_simple_async_result_take_error (simple, error);
} else if (!qmi_message_dms_uim_get_imsi_output_get_result (output, &error)) {
g_prefix_error (&error, "Couldn't get UIM IMSI: ");
g_simple_async_result_take_error (simple, error);
} else {
const gchar *str = NULL;
qmi_message_dms_uim_get_imsi_output_get_imsi (output, &str, NULL);
g_simple_async_result_set_op_res_gpointer (simple,
g_strdup (str),
(GDestroyNotify)g_free);
}
if (output)
qmi_message_dms_uim_get_imsi_output_unref (output);
g_simple_async_result_complete (simple);
g_object_unref (simple);
}
static void
load_imsi (MMSim *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
QmiClient *client = NULL;
if (!ensure_qmi_client (MM_SIM_QMI (self),
QMI_SERVICE_DMS, &client,
callback, user_data))
return;
result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
load_imsi);
mm_dbg ("loading IMSI...");
qmi_client_dms_uim_get_imsi (QMI_CLIENT_DMS (client),
NULL,
5,
NULL,
(GAsyncReadyCallback)dms_uim_get_imsi_ready,
result);
}
/*****************************************************************************/
MMSim *
@@ -186,4 +262,6 @@ mm_sim_qmi_class_init (MMSimQmiClass *klass)
sim_class->load_sim_identifier = load_sim_identifier;
sim_class->load_sim_identifier_finish = load_sim_identifier_finish;
sim_class->load_imsi = load_imsi;
sim_class->load_imsi_finish = load_imsi_finish;
}