aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-11-22 17:38:42 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:14:22 +0100
commit7a9b0d9faced7c960b7e35d48df9d705feb1932b (patch)
tree1f787be62a45809480e181e4623e53b9c945a5fe /src
parentb35be6141500d69000956210292bb7094315b80f (diff)
iface-modem: load `Manufacturer', `Model' and `Revision' during init
Diffstat (limited to 'src')
-rw-r--r--src/mm-iface-modem.c75
-rw-r--r--src/mm-iface-modem.h24
2 files changed, 99 insertions, 0 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index f7f25785..c8adfcd3 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -111,6 +111,9 @@ typedef enum {
INITIALIZATION_STEP_CURRENT_CAPABILITIES,
INITIALIZATION_STEP_MAX_BEARERS,
INITIALIZATION_STEP_MAX_ACTIVE_BEARERS,
+ INITIALIZATION_STEP_MANUFACTURER,
+ INITIALIZATION_STEP_MODEL,
+ INITIALIZATION_STEP_REVISION,
INITIALIZATION_STEP_LAST
} InitializationStep;
@@ -162,6 +165,30 @@ interface_initialization_finish (MMIfaceModem *self,
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
#define UINT_REPLY_READY_FN(NAME,DISPLAY) \
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 (max_bearers, "Max 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
interface_initialization_step (InitializationContext *ctx)
@@ -298,6 +328,51 @@ interface_initialization_step (InitializationContext *ctx)
mm_gdbus_modem_get_max_bearers (ctx->skeleton));
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:
/* We are done without errors! */
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
diff --git a/src/mm-iface-modem.h b/src/mm-iface-modem.h
index e8cdeb23..1e56415d 100644
--- a/src/mm-iface-modem.h
+++ b/src/mm-iface-modem.h
@@ -62,6 +62,30 @@ struct _MMIfaceModem {
guint (*load_max_active_bearers_finish) (MMIfaceModem *self,
GAsyncResult *res,
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);