base-sim: wrap in its own GTask the SIM id loading from the subclass
Instead of reusing the caller GTask, use a new GTask to wrap the execution of the subclass' async method implementation. Also, rename the _ready() methods implemented in the GObject initialization flow so that we can use the load_sim_identifier_ready() function name.
This commit is contained in:
@@ -708,24 +708,23 @@ mm_base_sim_load_sim_identifier_finish (MMBaseSim *self,
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
GError *inner_error = NULL;
|
return g_task_propagate_pointer (G_TASK (res), error);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
load_sim_identifier_ready (MMBaseSim *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GTask *task)
|
||||||
|
{
|
||||||
gchar *simid;
|
gchar *simid;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
if (g_async_result_is_tagged (res, mm_base_sim_load_sim_identifier) ||
|
simid = MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier_finish (self, res, &error);
|
||||||
!MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier_finish) {
|
if (!simid)
|
||||||
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
|
g_task_return_error (task, error);
|
||||||
"not implemented");
|
else
|
||||||
g_propagate_error (error, inner_error);
|
g_task_return_pointer (task, simid, g_free);
|
||||||
return NULL;
|
g_object_unref (task);
|
||||||
}
|
|
||||||
|
|
||||||
simid = MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier_finish (self, res, &inner_error);
|
|
||||||
if (inner_error) {
|
|
||||||
g_propagate_error (error, inner_error);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return simid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -733,24 +732,22 @@ mm_base_sim_load_sim_identifier (MMBaseSim *self,
|
|||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
if (!MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier &&
|
GTask *task;
|
||||||
|
|
||||||
|
task = g_task_new (self, NULL, callback, user_data);
|
||||||
|
|
||||||
|
if (!MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier ||
|
||||||
!MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier_finish) {
|
!MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier_finish) {
|
||||||
g_task_report_new_error (self,
|
g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
|
||||||
callback,
|
|
||||||
user_data,
|
|
||||||
mm_base_sim_load_sim_identifier,
|
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
|
||||||
"not implemented");
|
"not implemented");
|
||||||
|
g_object_unref (task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier (
|
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier (
|
||||||
self,
|
self,
|
||||||
(GAsyncReadyCallback)callback,
|
(GAsyncReadyCallback)load_sim_identifier_ready,
|
||||||
user_data);
|
task);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -1381,7 +1378,7 @@ initable_init_finish (GAsyncInitable *initable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
load_sim_identifier_ready (MMBaseSim *self,
|
init_load_sim_identifier_ready (MMBaseSim *self,
|
||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GTask *task)
|
GTask *task)
|
||||||
{
|
{
|
||||||
@@ -1420,7 +1417,7 @@ load_sim_identifier_ready (MMBaseSim *self,
|
|||||||
#undef STR_REPLY_READY_FN
|
#undef STR_REPLY_READY_FN
|
||||||
#define STR_REPLY_READY_FN(NAME,DISPLAY) \
|
#define STR_REPLY_READY_FN(NAME,DISPLAY) \
|
||||||
static void \
|
static void \
|
||||||
load_##NAME##_ready (MMBaseSim *self, \
|
init_load_##NAME##_ready (MMBaseSim *self, \
|
||||||
GAsyncResult *res, \
|
GAsyncResult *res, \
|
||||||
GTask *task) \
|
GTask *task) \
|
||||||
{ \
|
{ \
|
||||||
@@ -1475,7 +1472,7 @@ interface_initialization_step (GTask *task)
|
|||||||
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier_finish) {
|
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier_finish) {
|
||||||
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier (
|
MM_BASE_SIM_GET_CLASS (self)->load_sim_identifier (
|
||||||
self,
|
self,
|
||||||
(GAsyncReadyCallback)load_sim_identifier_ready,
|
(GAsyncReadyCallback)init_load_sim_identifier_ready,
|
||||||
task);
|
task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1491,7 +1488,7 @@ interface_initialization_step (GTask *task)
|
|||||||
MM_BASE_SIM_GET_CLASS (self)->load_imsi_finish) {
|
MM_BASE_SIM_GET_CLASS (self)->load_imsi_finish) {
|
||||||
MM_BASE_SIM_GET_CLASS (self)->load_imsi (
|
MM_BASE_SIM_GET_CLASS (self)->load_imsi (
|
||||||
self,
|
self,
|
||||||
(GAsyncReadyCallback)load_imsi_ready,
|
(GAsyncReadyCallback)init_load_imsi_ready,
|
||||||
task);
|
task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1507,7 +1504,7 @@ interface_initialization_step (GTask *task)
|
|||||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_identifier_finish) {
|
MM_BASE_SIM_GET_CLASS (self)->load_operator_identifier_finish) {
|
||||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_identifier (
|
MM_BASE_SIM_GET_CLASS (self)->load_operator_identifier (
|
||||||
self,
|
self,
|
||||||
(GAsyncReadyCallback)load_operator_identifier_ready,
|
(GAsyncReadyCallback)init_load_operator_identifier_ready,
|
||||||
task);
|
task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1523,7 +1520,7 @@ interface_initialization_step (GTask *task)
|
|||||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_name_finish) {
|
MM_BASE_SIM_GET_CLASS (self)->load_operator_name_finish) {
|
||||||
MM_BASE_SIM_GET_CLASS (self)->load_operator_name (
|
MM_BASE_SIM_GET_CLASS (self)->load_operator_name (
|
||||||
self,
|
self,
|
||||||
(GAsyncReadyCallback)load_operator_name_ready,
|
(GAsyncReadyCallback)init_load_operator_name_ready,
|
||||||
task);
|
task);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user