iface-modem-3gpp: load `IMEI' during init

This commit is contained in:
Aleksander Morgado
2012-03-15 14:14:28 +01:00
parent bb625b332a
commit 69079ff891
2 changed files with 47 additions and 0 deletions
+39
View File
@@ -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);
+8
View File
@@ -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);