diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2011-11-28 14:42:43 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-03-15 14:14:28 +0100 |
commit | 69079ff8914419d08c21720f022ef33da8225959 (patch) | |
tree | 218a1f1427431c63d19cc9fe8dd29217c3f3ca29 | |
parent | bb625b332a4dfd6159455e8a795ffe6a0b81a3ee (diff) |
iface-modem-3gpp: load `IMEI' during init
-rw-r--r-- | src/mm-iface-modem-3gpp.c | 39 | ||||
-rw-r--r-- | src/mm-iface-modem-3gpp.h | 8 |
2 files changed, 47 insertions, 0 deletions
diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c index f6a19b18..6b7cde2a 100644 --- a/src/mm-iface-modem-3gpp.c +++ b/src/mm-iface-modem-3gpp.c @@ -30,6 +30,7 @@ static void interface_initialization_step (InitializationContext *ctx); typedef enum { INITIALIZATION_STEP_FIRST, + INITIALIZATION_STEP_IMEI, INITIALIZATION_STEP_LAST } InitializationStep; @@ -75,6 +76,28 @@ initialization_context_free (InitializationContext *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) { switch (ctx->step) { @@ -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); diff --git a/src/mm-iface-modem-3gpp.h b/src/mm-iface-modem-3gpp.h index 0fcdde01..0dc7389d 100644 --- a/src/mm-iface-modem-3gpp.h +++ b/src/mm-iface-modem-3gpp.h @@ -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); |