diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-04-10 17:17:42 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-04-10 17:47:43 +0200 |
commit | b49ddfe9300429cee5f5648582be01c541df2c82 (patch) | |
tree | 604b0ac41c7f04ea326aa482888ba3534aea21d7 /src/mm-iface-modem.c | |
parent | 9812225d93da8a257ae85c9737afdd2b1d9cfda6 (diff) |
iface-modem: skip handling the CURRENT_CAPABILITIES property
It is an unnecessary complication, as long as we can keep the helpers in the interface.
Diffstat (limited to 'src/mm-iface-modem.c')
-rw-r--r-- | src/mm-iface-modem.c | 121 |
1 files changed, 43 insertions, 78 deletions
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index 62eac35f..c094b578 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -3037,7 +3037,7 @@ initialization_context_complete_and_free_if_cancelled (InitializationContext *ct } #undef UINT_REPLY_READY_FN -#define UINT_REPLY_READY_FN(NAME,DISPLAY) \ +#define UINT_REPLY_READY_FN(NAME,DISPLAY,FATAL) \ static void \ load_##NAME##_ready (MMIfaceModem *self, \ GAsyncResult *res, \ @@ -3050,41 +3050,27 @@ initialization_context_complete_and_free_if_cancelled (InitializationContext *ct MM_IFACE_MODEM_GET_INTERFACE (self)->load_##NAME##_finish (self, res, &error)); \ \ if (error) { \ - mm_warn ("couldn't load %s: '%s'", DISPLAY, error->message); \ - g_error_free (error); \ + if (FATAL) { \ + g_propagate_error (&ctx->fatal_error, error); \ + g_prefix_error (&ctx->fatal_error, "couldn't load %s: ", DISPLAY); \ + /* Jump to the last step */ \ + ctx->step = INITIALIZATION_STEP_LAST; \ + } else { \ + mm_warn ("couldn't load %s: '%s'", DISPLAY, error->message); \ + g_error_free (error); \ + /* Go on to next step */ \ + ctx->step++; \ + } \ + } else { \ + /* Go on to next step */ \ + ctx->step++; \ } \ \ - /* Go on to next step */ \ - ctx->step++; \ interface_initialization_step (ctx); \ } -static void -load_current_capabilities_ready (MMIfaceModem *self, - GAsyncResult *res, - InitializationContext *ctx) -{ - /* We have the property in the interface bound to the property in the - * skeleton. */ - g_object_set (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, - MM_IFACE_MODEM_GET_INTERFACE (self)->load_current_capabilities_finish (self, - res, - &ctx->fatal_error), - NULL); - if (ctx->fatal_error) { - g_prefix_error (&ctx->fatal_error, - "couldn't load Current Capabilities: "); - /* Jump to the last step */ - ctx->step = INITIALIZATION_STEP_LAST; - } else - /* Go on to next step */ - ctx->step++; - - interface_initialization_step (ctx); -} - -UINT_REPLY_READY_FN (modem_capabilities, "Modem Capabilities") +UINT_REPLY_READY_FN (current_capabilities, "Current Capabilities", TRUE) +UINT_REPLY_READY_FN (modem_capabilities, "Modem Capabilities", FALSE) STR_REPLY_READY_FN (manufacturer, "Manufacturer") STR_REPLY_READY_FN (model, "Model") STR_REPLY_READY_FN (revision, "Revision") @@ -3643,6 +3629,7 @@ mm_iface_modem_initialize (MMIfaceModem *self, /* Set all initial property defaults */ mm_gdbus_modem_set_sim (skeleton, NULL); + mm_gdbus_modem_set_current_capabilities (skeleton, MM_MODEM_CAPABILITY_NONE); mm_gdbus_modem_set_modem_capabilities (skeleton, MM_MODEM_CAPABILITY_NONE); mm_gdbus_modem_set_max_bearers (skeleton, 0); mm_gdbus_modem_set_max_active_bearers (skeleton, 0); @@ -3669,10 +3656,6 @@ mm_iface_modem_initialize (MMIfaceModem *self, g_object_bind_property (self, MM_IFACE_MODEM_STATE, skeleton, "state", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); - /* Bind our Capabilities property */ - g_object_bind_property (self, MM_IFACE_MODEM_CURRENT_CAPABILITIES, - skeleton, "current-capabilities", - G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); g_object_set (self, MM_IFACE_MODEM_DBUS_SKELETON, skeleton, @@ -3706,75 +3689,66 @@ mm_iface_modem_shutdown (MMIfaceModem *self) /*****************************************************************************/ -gboolean -mm_iface_modem_is_3gpp (MMIfaceModem *self) +MMModemCapability +mm_iface_modem_get_current_capabilities (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; + MMModemCapability current = MM_MODEM_CAPABILITY_NONE; + MmGdbusModem *skeleton; g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, + MM_IFACE_MODEM_DBUS_SKELETON, &skeleton, NULL); - return (capabilities & MM_MODEM_CAPABILITY_3GPP); + if (skeleton) { + current = mm_gdbus_modem_get_current_capabilities (skeleton); + g_object_unref (skeleton); + } + + return current; } gboolean -mm_iface_modem_is_3gpp_lte (MMIfaceModem *self) +mm_iface_modem_is_3gpp (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; - - g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, - NULL); + return (mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_3GPP); +} - return (capabilities & MM_MODEM_CAPABILITY_3GPP_LTE); +gboolean +mm_iface_modem_is_3gpp_lte (MMIfaceModem *self) +{ + return (mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_3GPP_LTE); } gboolean mm_iface_modem_is_cdma (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; - - g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, - NULL); - - return (capabilities & MM_MODEM_CAPABILITY_CDMA_EVDO); + return (mm_iface_modem_get_current_capabilities (self) & MM_MODEM_CAPABILITY_CDMA_EVDO); } gboolean mm_iface_modem_is_3gpp_only (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; - - g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, - NULL); + MMModemCapability capabilities; + capabilities = mm_iface_modem_get_current_capabilities (self); return !((MM_MODEM_CAPABILITY_3GPP ^ capabilities) & capabilities); } gboolean mm_iface_modem_is_3gpp_lte_only (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; - - g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, - NULL); + MMModemCapability capabilities; + capabilities = mm_iface_modem_get_current_capabilities (self); return !((MM_MODEM_CAPABILITY_3GPP_LTE ^ capabilities) & capabilities); } gboolean mm_iface_modem_is_cdma_only (MMIfaceModem *self) { - MMModemCapability capabilities = MM_MODEM_CAPABILITY_NONE; - - g_object_get (self, - MM_IFACE_MODEM_CURRENT_CAPABILITIES, &capabilities, - NULL); + MMModemCapability capabilities; + capabilities = mm_iface_modem_get_current_capabilities (self); return !((MM_MODEM_CAPABILITY_CDMA_EVDO ^ capabilities) & capabilities); } @@ -3816,15 +3790,6 @@ iface_modem_init (gpointer g_iface) g_object_interface_install_property (g_iface, - g_param_spec_flags (MM_IFACE_MODEM_CURRENT_CAPABILITIES, - "Current capabilities", - "Current capabilities of the modem", - MM_TYPE_MODEM_CAPABILITY, - MM_MODEM_CAPABILITY_NONE, - G_PARAM_READWRITE)); - - g_object_interface_install_property - (g_iface, g_param_spec_object (MM_IFACE_MODEM_BEARER_LIST, "Bearer list", "List of bearers handled by the modem", |