iface-modem: load Manufacturer', Model' and `Revision' during init

This commit is contained in:
Aleksander Morgado
2011-11-22 17:38:42 +01:00
parent b35be61415
commit 7a9b0d9fac
2 changed files with 99 additions and 0 deletions

View File

@@ -111,6 +111,9 @@ typedef enum {
INITIALIZATION_STEP_CURRENT_CAPABILITIES, INITIALIZATION_STEP_CURRENT_CAPABILITIES,
INITIALIZATION_STEP_MAX_BEARERS, INITIALIZATION_STEP_MAX_BEARERS,
INITIALIZATION_STEP_MAX_ACTIVE_BEARERS, INITIALIZATION_STEP_MAX_ACTIVE_BEARERS,
INITIALIZATION_STEP_MANUFACTURER,
INITIALIZATION_STEP_MODEL,
INITIALIZATION_STEP_REVISION,
INITIALIZATION_STEP_LAST INITIALIZATION_STEP_LAST
} InitializationStep; } InitializationStep;
@@ -162,6 +165,30 @@ interface_initialization_finish (MMIfaceModem *self,
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
} }
#undef STR_REPLY_READY_FN
#define STR_REPLY_READY_FN(NAME,DISPLAY) \
static void \
load_##NAME##_ready (MMIfaceModem *self, \
GAsyncResult *res, \
InitializationContext *ctx) \
{ \
GError *error = NULL; \
gchar *val; \
\
val = MM_IFACE_MODEM_GET_INTERFACE (self)->load_##NAME##_finish (self, res, &error); \
mm_gdbus_modem_set_##NAME (ctx->skeleton, val); \
g_free (val); \
\
if (error) { \
mm_warn ("couldn't load %s: '%s'", DISPLAY, error->message); \
g_error_free (error); \
} \
\
/* Go on to next step */ \
ctx->step++; \
interface_initialization_step (ctx); \
}
#undef UINT_REPLY_READY_FN #undef UINT_REPLY_READY_FN
#define UINT_REPLY_READY_FN(NAME,DISPLAY) \ #define UINT_REPLY_READY_FN(NAME,DISPLAY) \
static void \ static void \
@@ -189,6 +216,9 @@ UINT_REPLY_READY_FN (modem_capabilities, "Modem Capabilities")
UINT_REPLY_READY_FN (current_capabilities, "Current Capabilities") UINT_REPLY_READY_FN (current_capabilities, "Current Capabilities")
UINT_REPLY_READY_FN (max_bearers, "Max Bearers") UINT_REPLY_READY_FN (max_bearers, "Max Bearers")
UINT_REPLY_READY_FN (max_active_bearers, "Max Active Bearers") UINT_REPLY_READY_FN (max_active_bearers, "Max Active Bearers")
STR_REPLY_READY_FN (manufacturer, "Manufacturer")
STR_REPLY_READY_FN (model, "Model")
STR_REPLY_READY_FN (revision, "Revision")
static void static void
interface_initialization_step (InitializationContext *ctx) interface_initialization_step (InitializationContext *ctx)
@@ -298,6 +328,51 @@ interface_initialization_step (InitializationContext *ctx)
mm_gdbus_modem_get_max_bearers (ctx->skeleton)); mm_gdbus_modem_get_max_bearers (ctx->skeleton));
break; break;
case INITIALIZATION_STEP_MANUFACTURER:
/* Manufacturer is meant to be loaded only once during the whole
* lifetime of the modem. Therefore, if we already have them loaded,
* don't try to load them again. */
if (mm_gdbus_modem_get_manufacturer (ctx->skeleton) == NULL &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_manufacturer &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_manufacturer_finish) {
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_manufacturer (
ctx->self,
(GAsyncReadyCallback)load_manufacturer_ready,
ctx);
return;
}
break;
case INITIALIZATION_STEP_MODEL:
/* Model is meant to be loaded only once during the whole
* lifetime of the modem. Therefore, if we already have them loaded,
* don't try to load them again. */
if (mm_gdbus_modem_get_model (ctx->skeleton) == NULL &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_model &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_model_finish) {
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_model (
ctx->self,
(GAsyncReadyCallback)load_model_ready,
ctx);
return;
}
break;
case INITIALIZATION_STEP_REVISION:
/* Revision is meant to be loaded only once during the whole
* lifetime of the modem. Therefore, if we already have them loaded,
* don't try to load them again. */
if (mm_gdbus_modem_get_revision (ctx->skeleton) == NULL &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_revision &&
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_revision_finish) {
MM_IFACE_MODEM_GET_INTERFACE (ctx->self)->load_revision (
ctx->self,
(GAsyncReadyCallback)load_revision_ready,
ctx);
return;
}
break;
case INITIALIZATION_STEP_LAST: case INITIALIZATION_STEP_LAST:
/* We are done without errors! */ /* We are done without errors! */
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);

View File

@@ -62,6 +62,30 @@ struct _MMIfaceModem {
guint (*load_max_active_bearers_finish) (MMIfaceModem *self, guint (*load_max_active_bearers_finish) (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
GError **error); GError **error);
/* Loading of the Manufacturer property */
void (*load_manufacturer) (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data);
gchar * (*load_manufacturer_finish) (MMIfaceModem *self,
GAsyncResult *res,
GError **error);
/* Loading of the Model property */
void (*load_model) (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data);
gchar * (*load_model_finish) (MMIfaceModem *self,
GAsyncResult *res,
GError **error);
/* Loading of the Revision property */
void (*load_revision) (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data);
gchar * (*load_revision_finish) (MMIfaceModem *self,
GAsyncResult *res,
GError **error);
}; };
GType mm_iface_modem_get_type (void); GType mm_iface_modem_get_type (void);