iface-modem: improve logging of user request to set current capabilities
This commit is contained in:
@@ -2530,11 +2530,13 @@ typedef struct {
|
|||||||
GDBusMethodInvocation *invocation;
|
GDBusMethodInvocation *invocation;
|
||||||
MMIfaceModem *self;
|
MMIfaceModem *self;
|
||||||
MMModemCapability capabilities;
|
MMModemCapability capabilities;
|
||||||
|
gchar *capabilities_str;
|
||||||
} HandleSetCurrentCapabilitiesContext;
|
} HandleSetCurrentCapabilitiesContext;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
handle_set_current_capabilities_context_free (HandleSetCurrentCapabilitiesContext *ctx)
|
handle_set_current_capabilities_context_free (HandleSetCurrentCapabilitiesContext *ctx)
|
||||||
{
|
{
|
||||||
|
g_free (ctx->capabilities_str);
|
||||||
g_object_unref (ctx->skeleton);
|
g_object_unref (ctx->skeleton);
|
||||||
g_object_unref (ctx->invocation);
|
g_object_unref (ctx->invocation);
|
||||||
g_object_unref (ctx->self);
|
g_object_unref (ctx->self);
|
||||||
@@ -2548,11 +2550,13 @@ set_current_capabilities_ready (MMIfaceModem *self,
|
|||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_capabilities_finish (self, res, &error))
|
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_capabilities_finish (self, res, &error)) {
|
||||||
|
mm_obj_warn (self, "failed setting current capabilities to '%s': %s", ctx->capabilities_str, error->message);
|
||||||
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
else {
|
} else {
|
||||||
/* Capabilities updated: explicitly refresh signal and access technology */
|
/* Capabilities updated: explicitly refresh signal and access technology */
|
||||||
mm_iface_modem_refresh_signal (self);
|
mm_iface_modem_refresh_signal (self);
|
||||||
|
mm_obj_info (self, "current capabilities set to '%s'", ctx->capabilities_str);
|
||||||
mm_gdbus_modem_complete_set_current_capabilities (ctx->skeleton, ctx->invocation);
|
mm_gdbus_modem_complete_set_current_capabilities (ctx->skeleton, ctx->invocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2565,8 +2569,7 @@ handle_set_current_capabilities_auth_ready (MMBaseModem *self,
|
|||||||
HandleSetCurrentCapabilitiesContext *ctx)
|
HandleSetCurrentCapabilitiesContext *ctx)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gchar *capabilities_string;
|
g_autoptr(GArray) supported = NULL;
|
||||||
GArray *supported;
|
|
||||||
gboolean matched = FALSE;
|
gboolean matched = FALSE;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
@@ -2576,18 +2579,30 @@ handle_set_current_capabilities_auth_ready (MMBaseModem *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Nothing to do if we already are in the requested setup */
|
||||||
|
if (mm_gdbus_modem_get_current_capabilities (ctx->skeleton) == ctx->capabilities) {
|
||||||
|
mm_gdbus_modem_complete_set_current_capabilities (ctx->skeleton, ctx->invocation);
|
||||||
|
handle_set_current_capabilities_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If setting current capabilities is not implemented, report an error */
|
||||||
|
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_capabilities ||
|
||||||
|
!MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_capabilities_finish) {
|
||||||
|
g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
|
||||||
|
"Setting current capabilities not supported");
|
||||||
|
handle_set_current_capabilities_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get list of supported capabilities */
|
/* Get list of supported capabilities */
|
||||||
supported = mm_common_capability_combinations_variant_to_garray (
|
supported = mm_common_capability_combinations_variant_to_garray (mm_gdbus_modem_get_supported_capabilities (ctx->skeleton));
|
||||||
mm_gdbus_modem_get_supported_capabilities (ctx->skeleton));
|
|
||||||
|
|
||||||
/* Don't allow capability switching if only one item given in the supported list */
|
/* Don't allow capability switching if only one item given in the supported list */
|
||||||
if (supported->len == 1) {
|
if (supported->len == 1) {
|
||||||
g_dbus_method_invocation_return_error (ctx->invocation,
|
g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
|
||||||
"Cannot change capabilities: only one combination supported");
|
"Cannot change capabilities: only one combination supported");
|
||||||
handle_set_current_capabilities_context_free (ctx);
|
handle_set_current_capabilities_context_free (ctx);
|
||||||
g_array_unref (supported);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2599,39 +2614,15 @@ handle_set_current_capabilities_auth_ready (MMBaseModem *self,
|
|||||||
if (supported_capability == ctx->capabilities)
|
if (supported_capability == ctx->capabilities)
|
||||||
matched = TRUE;
|
matched = TRUE;
|
||||||
}
|
}
|
||||||
g_array_unref (supported);
|
|
||||||
|
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
g_dbus_method_invocation_return_error (ctx->invocation,
|
g_dbus_method_invocation_return_error (ctx->invocation, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
|
||||||
"The given combination of capabilities is not supported");
|
"The given combination of capabilities is not supported");
|
||||||
handle_set_current_capabilities_context_free (ctx);
|
handle_set_current_capabilities_context_free (ctx);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we already are in the requested setup */
|
ctx->capabilities_str = mm_modem_capability_build_string_from_mask (ctx->capabilities);
|
||||||
if (mm_gdbus_modem_get_current_capabilities (ctx->skeleton) == ctx->capabilities) {
|
mm_obj_info (self, "processing user request to set current capabilities to '%s'...", ctx->capabilities_str);
|
||||||
/* Nothing to do */
|
|
||||||
mm_gdbus_modem_complete_set_current_capabilities (ctx->skeleton, ctx->invocation);
|
|
||||||
handle_set_current_capabilities_context_free (ctx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If setting current capabilities is not implemented, report an error */
|
|
||||||
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_capabilities ||
|
|
||||||
!MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_capabilities_finish) {
|
|
||||||
g_dbus_method_invocation_return_error (ctx->invocation,
|
|
||||||
MM_CORE_ERROR,
|
|
||||||
MM_CORE_ERROR_UNSUPPORTED,
|
|
||||||
"Setting current capabilities not supported");
|
|
||||||
handle_set_current_capabilities_context_free (ctx);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
capabilities_string = mm_modem_capability_build_string_from_mask (ctx->capabilities);
|
|
||||||
mm_obj_dbg (self, "setting new list of capabilities: %s", capabilities_string);
|
|
||||||
g_free (capabilities_string);
|
|
||||||
|
|
||||||
MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_capabilities (
|
MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_capabilities (
|
||||||
MM_IFACE_MODEM (self),
|
MM_IFACE_MODEM (self),
|
||||||
@@ -2648,7 +2639,7 @@ handle_set_current_capabilities (MmGdbusModem *skeleton,
|
|||||||
{
|
{
|
||||||
HandleSetCurrentCapabilitiesContext *ctx;
|
HandleSetCurrentCapabilitiesContext *ctx;
|
||||||
|
|
||||||
ctx = g_slice_new (HandleSetCurrentCapabilitiesContext);
|
ctx = g_slice_new0 (HandleSetCurrentCapabilitiesContext);
|
||||||
ctx->skeleton = g_object_ref (skeleton);
|
ctx->skeleton = g_object_ref (skeleton);
|
||||||
ctx->invocation = g_object_ref (invocation);
|
ctx->invocation = g_object_ref (invocation);
|
||||||
ctx->self = g_object_ref (self);
|
ctx->self = g_object_ref (self);
|
||||||
|
Reference in New Issue
Block a user