From 6abcfd54a6c3b45b38c0bc4a999b39f0c683de35 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 3 Jan 2012 13:23:36 +0100 Subject: iface-modem-cdma: load MEID during initialization --- src/mm-iface-modem-cdma.c | 39 +++++++++++++++++++++++++++++++++++++++ src/mm-iface-modem-cdma.h | 8 ++++++++ 2 files changed, 47 insertions(+) (limited to 'src') diff --git a/src/mm-iface-modem-cdma.c b/src/mm-iface-modem-cdma.c index ad749909..3d689e5e 100644 --- a/src/mm-iface-modem-cdma.c +++ b/src/mm-iface-modem-cdma.c @@ -541,6 +541,7 @@ static void interface_initialization_step (InitializationContext *ctx); typedef enum { INITIALIZATION_STEP_FIRST, + INITIALIZATION_STEP_MEID, INITIALIZATION_STEP_LAST } InitializationStep; @@ -586,6 +587,28 @@ initialization_context_complete_and_free (InitializationContext *ctx) g_free (ctx); } +static void +load_meid_ready (MMIfaceModemCdma *self, + GAsyncResult *res, + InitializationContext *ctx) +{ + GError *error = NULL; + gchar *meid; + + meid = MM_IFACE_MODEM_CDMA_GET_INTERFACE (self)->load_meid_finish (self, res, &error); + mm_gdbus_modem_cdma_set_meid (ctx->skeleton, meid); + g_free (meid); + + if (error) { + mm_warn ("couldn't load MEID: '%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) { @@ -594,6 +617,22 @@ interface_initialization_step (InitializationContext *ctx) /* Fall down to next step */ ctx->step++; + case INITIALIZATION_STEP_MEID: + /* MEID 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_modem_cdma_get_meid (ctx->skeleton) && + MM_IFACE_MODEM_CDMA_GET_INTERFACE (ctx->self)->load_meid && + MM_IFACE_MODEM_CDMA_GET_INTERFACE (ctx->self)->load_meid_finish) { + MM_IFACE_MODEM_CDMA_GET_INTERFACE (ctx->self)->load_meid ( + ctx->self, + (GAsyncReadyCallback)load_meid_ready, + ctx); + return; + } + /* Fall down to next step */ + ctx->step++; + case INITIALIZATION_STEP_LAST: /* We are done without errors! */ diff --git a/src/mm-iface-modem-cdma.h b/src/mm-iface-modem-cdma.h index 29b770d3..1ed1c7e7 100644 --- a/src/mm-iface-modem-cdma.h +++ b/src/mm-iface-modem-cdma.h @@ -35,6 +35,14 @@ typedef struct _MMIfaceModemCdma MMIfaceModemCdma; struct _MMIfaceModemCdma { GTypeInterface g_iface; + /* Loading of the MEID property */ + void (*load_meid) (MMIfaceModemCdma *self, + GAsyncReadyCallback callback, + gpointer user_data); + gchar * (*load_meid_finish) (MMIfaceModemCdma *self, + GAsyncResult *res, + GError **error); + /* OTA activation */ void (* activate) (MMIfaceModemCdma *self, const gchar *carrier, -- cgit v1.2.3-70-g09d2