iface-modem-3gpp: load `IMEI' during init
This commit is contained in:
@@ -30,6 +30,7 @@ static void interface_initialization_step (InitializationContext *ctx);
|
||||
|
||||
typedef enum {
|
||||
INITIALIZATION_STEP_FIRST,
|
||||
INITIALIZATION_STEP_IMEI,
|
||||
INITIALIZATION_STEP_LAST
|
||||
} InitializationStep;
|
||||
|
||||
@@ -74,6 +75,28 @@ initialization_context_free (InitializationContext *ctx)
|
||||
g_free (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
load_imei_ready (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
InitializationContext *ctx)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gchar *imei;
|
||||
|
||||
imei = MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_imei_finish (self, res, &error);
|
||||
mm_gdbus_modem3gpp_set_imei (ctx->skeleton, imei);
|
||||
g_free (imei);
|
||||
|
||||
if (error) {
|
||||
mm_warn ("couldn't load IMEI: '%s'", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
/* Go on to next step */
|
||||
ctx->step++;
|
||||
interface_initialization_step (ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
interface_initialization_step (InitializationContext *ctx)
|
||||
{
|
||||
@@ -82,6 +105,22 @@ interface_initialization_step (InitializationContext *ctx)
|
||||
/* Fall down to next step */
|
||||
ctx->step++;
|
||||
|
||||
case INITIALIZATION_STEP_IMEI:
|
||||
/* IMEI value is meant to be loaded only once during the whole
|
||||
* lifetime of the modem. Therefore, if we already have it loaded,
|
||||
* don't try to load it again. */
|
||||
if (!mm_gdbus_modem3gpp_get_imei (ctx->skeleton) &&
|
||||
MM_IFACE_MODEM_3GPP_GET_INTERFACE (ctx->self)->load_imei &&
|
||||
MM_IFACE_MODEM_3GPP_GET_INTERFACE (ctx->self)->load_imei_finish) {
|
||||
MM_IFACE_MODEM_3GPP_GET_INTERFACE (ctx->self)->load_imei (
|
||||
ctx->self,
|
||||
(GAsyncReadyCallback)load_imei_ready,
|
||||
ctx);
|
||||
return;
|
||||
}
|
||||
/* Fall down to next step */
|
||||
ctx->step++;
|
||||
|
||||
case INITIALIZATION_STEP_LAST:
|
||||
/* We are done without errors! */
|
||||
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
|
||||
|
||||
@@ -32,6 +32,14 @@ typedef struct _MMIfaceModem3gpp MMIfaceModem3gpp;
|
||||
|
||||
struct _MMIfaceModem3gpp {
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Loading of the IMEI property */
|
||||
void (*load_imei) (MMIfaceModem3gpp *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gchar * (*load_imei_finish) (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
};
|
||||
|
||||
GType mm_iface_modem_3gpp_get_type (void);
|
||||
|
||||
Reference in New Issue
Block a user