api,introspection: new 'SetCurrentCapabilities' method
For those modems which expose a valid 'SupportedCapabilities' property with more than one item in the list, we'll allow switching between them.
This commit is contained in:
@@ -140,6 +140,9 @@ mm_modem_set_current_modes_sync
|
|||||||
mm_modem_set_current_bands
|
mm_modem_set_current_bands
|
||||||
mm_modem_set_current_bands_finish
|
mm_modem_set_current_bands_finish
|
||||||
mm_modem_set_current_bands_sync
|
mm_modem_set_current_bands_sync
|
||||||
|
mm_modem_set_current_capabilities
|
||||||
|
mm_modem_set_current_capabilities_finish
|
||||||
|
mm_modem_set_current_capabilities_sync
|
||||||
mm_modem_reset
|
mm_modem_reset
|
||||||
mm_modem_reset_finish
|
mm_modem_reset_finish
|
||||||
mm_modem_reset_sync
|
mm_modem_reset_sync
|
||||||
@@ -1490,6 +1493,9 @@ mm_gdbus_modem_call_set_current_modes_sync
|
|||||||
mm_gdbus_modem_call_set_current_bands
|
mm_gdbus_modem_call_set_current_bands
|
||||||
mm_gdbus_modem_call_set_current_bands_finish
|
mm_gdbus_modem_call_set_current_bands_finish
|
||||||
mm_gdbus_modem_call_set_current_bands_sync
|
mm_gdbus_modem_call_set_current_bands_sync
|
||||||
|
mm_gdbus_modem_call_set_current_capabilities
|
||||||
|
mm_gdbus_modem_call_set_current_capabilities_finish
|
||||||
|
mm_gdbus_modem_call_set_current_capabilities_sync
|
||||||
mm_gdbus_modem_call_command
|
mm_gdbus_modem_call_command
|
||||||
mm_gdbus_modem_call_command_finish
|
mm_gdbus_modem_call_command_finish
|
||||||
mm_gdbus_modem_call_command_sync
|
mm_gdbus_modem_call_command_sync
|
||||||
@@ -1532,6 +1538,7 @@ mm_gdbus_modem_complete_list_bearers
|
|||||||
mm_gdbus_modem_complete_reset
|
mm_gdbus_modem_complete_reset
|
||||||
mm_gdbus_modem_complete_set_current_modes
|
mm_gdbus_modem_complete_set_current_modes
|
||||||
mm_gdbus_modem_complete_set_current_bands
|
mm_gdbus_modem_complete_set_current_bands
|
||||||
|
mm_gdbus_modem_complete_set_current_capabilities
|
||||||
mm_gdbus_modem_interface_info
|
mm_gdbus_modem_interface_info
|
||||||
mm_gdbus_modem_override_properties
|
mm_gdbus_modem_override_properties
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
|
@@ -136,6 +136,16 @@
|
|||||||
<arg name="state" type="u" direction="in" />
|
<arg name="state" type="u" direction="in" />
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
SetCurrentCapabilities:
|
||||||
|
@capabilities: Bitmask of <link linkend="MMModemCapability">MMModemCapability</link> values, to specify the capabilities to use.
|
||||||
|
|
||||||
|
Set the capabilities of the device. A restart of the modem may be required.
|
||||||
|
-->
|
||||||
|
<method name="SetCurrentCapabilities">
|
||||||
|
<arg name="capabilities" type="u" direction="in" />
|
||||||
|
</method>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
SetCurrentModes:
|
SetCurrentModes:
|
||||||
@modes: A pair of <link linkend="MMModemMode">MMModemMode</link> values, where the first one is a bitmask of allowed modes, and the second one the preferred mode, if any.
|
@modes: A pair of <link linkend="MMModemMode">MMModemMode</link> values, where the first one is a bitmask of allowed modes, and the second one the preferred mode, if any.
|
||||||
|
@@ -2414,6 +2414,88 @@ mm_modem_set_power_state_sync (MMModem *self,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_modem_set_current_capabilities_finish:
|
||||||
|
* @self: A #MMModem.
|
||||||
|
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_set_current_capabilities().
|
||||||
|
* @error: Return location for error or %NULL.
|
||||||
|
*
|
||||||
|
* Finishes an operation started with mm_modem_set_current_capabilities().
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the capabilities were successfully set, %FALSE if @error is set.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
mm_modem_set_current_capabilities_finish (MMModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
|
||||||
|
|
||||||
|
return mm_gdbus_modem_call_set_current_capabilities_finish (MM_GDBUS_MODEM (self), res, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_modem_set_current_capabilities:
|
||||||
|
* @self: A #MMModem.
|
||||||
|
* @capabilities: A #MMModemCapability mask.
|
||||||
|
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||||
|
* @callback: A #GAsyncReadyCallback to call when the request is satisfied or %NULL.
|
||||||
|
* @user_data: User data to pass to @callback.
|
||||||
|
*
|
||||||
|
* Asynchronously sets the capabilities of the device. A restart of the modem may be required.
|
||||||
|
*
|
||||||
|
* When the operation is finished, @callback will be invoked in the <link linkend="g-main-context-push-thread-default">thread-default main loop</link> of the thread you are calling this method from.
|
||||||
|
* You can then call mm_modem_set_current_capabilities_finish() to get the result of the operation.
|
||||||
|
*
|
||||||
|
* See mm_modem_set_current_capabilities_sync() for the synchronous, blocking version of this method.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
mm_modem_set_current_capabilities (MMModem *self,
|
||||||
|
MMModemCapability capabilities,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
g_return_if_fail (MM_IS_MODEM (self));
|
||||||
|
|
||||||
|
mm_gdbus_modem_call_set_current_capabilities (MM_GDBUS_MODEM (self),
|
||||||
|
capabilities,
|
||||||
|
cancellable,
|
||||||
|
callback,
|
||||||
|
user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mm_modem_set_current_capabilities_sync:
|
||||||
|
* @self: A #MMModem.
|
||||||
|
* @capabilities: A #MMModemCapability mask.
|
||||||
|
* @cancellable: (allow-none): A #GCancellable or %NULL.
|
||||||
|
* @error: Return location for error or %NULL.
|
||||||
|
*
|
||||||
|
* Synchronously sets the capabilities of the device. A restart of the modem may be required.
|
||||||
|
*
|
||||||
|
* The calling thread is blocked until a reply is received. See mm_modem_set_current_capabilities()
|
||||||
|
* for the asynchronous version of this method.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the capabilities were successfully set, %FALSE if @error is set.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
mm_modem_set_current_capabilities_sync (MMModem *self,
|
||||||
|
MMModemCapability capabilities,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
|
||||||
|
|
||||||
|
return (mm_gdbus_modem_call_set_current_capabilities_sync (
|
||||||
|
MM_GDBUS_MODEM (self),
|
||||||
|
capabilities,
|
||||||
|
cancellable,
|
||||||
|
error));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* mm_modem_set_current_modes_finish:
|
* mm_modem_set_current_modes_finish:
|
||||||
* @self: A #MMModem.
|
* @self: A #MMModem.
|
||||||
|
@@ -271,6 +271,19 @@ gboolean mm_modem_set_power_state_sync (MMModem *self,
|
|||||||
GCancellable *cancellable,
|
GCancellable *cancellable,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
void mm_modem_set_current_capabilities (MMModem *self,
|
||||||
|
MMModemCapability capabilities,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
gboolean mm_modem_set_current_capabilities_finish (MMModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
gboolean mm_modem_set_current_capabilities_sync (MMModem *self,
|
||||||
|
MMModemCapability capabilities,
|
||||||
|
GCancellable *cancellable,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
void mm_modem_set_current_modes (MMModem *self,
|
void mm_modem_set_current_modes (MMModem *self,
|
||||||
MMModemMode modes,
|
MMModemMode modes,
|
||||||
MMModemMode preferred,
|
MMModemMode preferred,
|
||||||
|
@@ -1790,6 +1790,142 @@ handle_factory_reset (MmGdbusModem *skeleton,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Current capabilities setting */
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
MmGdbusModem *skeleton;
|
||||||
|
GDBusMethodInvocation *invocation;
|
||||||
|
MMIfaceModem *self;
|
||||||
|
MMModemCapability capabilities;
|
||||||
|
} HandleSetCurrentCapabilitiesContext;
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_set_current_capabilities_context_free (HandleSetCurrentCapabilitiesContext *ctx)
|
||||||
|
{
|
||||||
|
g_object_unref (ctx->skeleton);
|
||||||
|
g_object_unref (ctx->invocation);
|
||||||
|
g_object_unref (ctx->self);
|
||||||
|
g_slice_free (HandleSetCurrentCapabilitiesContext, ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_current_capabilities_ready (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
HandleSetCurrentCapabilitiesContext *ctx)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_capabilities_finish (self, res, &error))
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
else
|
||||||
|
mm_gdbus_modem_complete_set_current_capabilities (ctx->skeleton, ctx->invocation);
|
||||||
|
handle_set_current_capabilities_context_free (ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_set_current_capabilities_auth_ready (MMBaseModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
HandleSetCurrentCapabilitiesContext *ctx)
|
||||||
|
{
|
||||||
|
GError *error = NULL;
|
||||||
|
gchar *capabilities_string;
|
||||||
|
GArray *supported;
|
||||||
|
gboolean matched = FALSE;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
if (!mm_base_modem_authorize_finish (self, res, &error)) {
|
||||||
|
g_dbus_method_invocation_take_error (ctx->invocation, error);
|
||||||
|
handle_set_current_capabilities_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get list of supported capabilities */
|
||||||
|
supported = mm_common_capability_combinations_variant_to_garray (
|
||||||
|
mm_gdbus_modem_get_supported_capabilities (ctx->skeleton));
|
||||||
|
|
||||||
|
/* Don't allow capability switching if only one item given in the supported list */
|
||||||
|
if (supported->len == 1) {
|
||||||
|
g_dbus_method_invocation_return_error (ctx->invocation,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_UNSUPPORTED,
|
||||||
|
"Cannot change capabilities: only one combination supported");
|
||||||
|
handle_set_current_capabilities_context_free (ctx);
|
||||||
|
g_array_unref (supported);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if the given combination is supported */
|
||||||
|
for (i = 0; !matched && i < supported->len; i++) {
|
||||||
|
MMModemCapability supported_capability;
|
||||||
|
|
||||||
|
supported_capability = g_array_index (supported, MMModemCapability, i);
|
||||||
|
if (supported_capability == ctx->capabilities)
|
||||||
|
matched = TRUE;
|
||||||
|
}
|
||||||
|
g_array_unref (supported);
|
||||||
|
|
||||||
|
if (!matched) {
|
||||||
|
g_dbus_method_invocation_return_error (ctx->invocation,
|
||||||
|
MM_CORE_ERROR,
|
||||||
|
MM_CORE_ERROR_UNSUPPORTED,
|
||||||
|
"The given combination of capabilities is not supported");
|
||||||
|
handle_set_current_capabilities_context_free (ctx);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if we already are in the requested setup */
|
||||||
|
if (mm_gdbus_modem_get_current_capabilities (ctx->skeleton) == ctx->capabilities) {
|
||||||
|
/* 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_dbg ("Setting new list of capabilities: '%s'", capabilities_string);
|
||||||
|
g_free (capabilities_string);
|
||||||
|
|
||||||
|
MM_IFACE_MODEM_GET_INTERFACE (self)->set_current_capabilities (
|
||||||
|
MM_IFACE_MODEM (self),
|
||||||
|
ctx->capabilities,
|
||||||
|
(GAsyncReadyCallback)set_current_capabilities_ready,
|
||||||
|
ctx);
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
handle_set_current_capabilities (MmGdbusModem *skeleton,
|
||||||
|
GDBusMethodInvocation *invocation,
|
||||||
|
guint capabilities,
|
||||||
|
MMIfaceModem *self)
|
||||||
|
{
|
||||||
|
HandleSetCurrentCapabilitiesContext *ctx;
|
||||||
|
|
||||||
|
ctx = g_slice_new (HandleSetCurrentCapabilitiesContext);
|
||||||
|
ctx->skeleton = g_object_ref (skeleton);
|
||||||
|
ctx->invocation = g_object_ref (invocation);
|
||||||
|
ctx->self = g_object_ref (self);
|
||||||
|
ctx->capabilities = capabilities;
|
||||||
|
|
||||||
|
mm_base_modem_authorize (MM_BASE_MODEM (self),
|
||||||
|
invocation,
|
||||||
|
MM_AUTHORIZATION_DEVICE_CONTROL,
|
||||||
|
(GAsyncReadyCallback)handle_set_current_capabilities_auth_ready,
|
||||||
|
ctx);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Current bands setting */
|
/* Current bands setting */
|
||||||
|
|
||||||
@@ -4311,6 +4447,10 @@ interface_initialization_step (InitializationContext *ctx)
|
|||||||
"handle-factory-reset",
|
"handle-factory-reset",
|
||||||
G_CALLBACK (handle_factory_reset),
|
G_CALLBACK (handle_factory_reset),
|
||||||
ctx->self);
|
ctx->self);
|
||||||
|
g_signal_connect (ctx->skeleton,
|
||||||
|
"handle-set-current-capabilities",
|
||||||
|
G_CALLBACK (handle_set_current_capabilities),
|
||||||
|
ctx->self);
|
||||||
g_signal_connect (ctx->skeleton,
|
g_signal_connect (ctx->skeleton,
|
||||||
"handle-set-current-bands",
|
"handle-set-current-bands",
|
||||||
G_CALLBACK (handle_set_current_bands),
|
G_CALLBACK (handle_set_current_bands),
|
||||||
|
@@ -217,6 +217,15 @@ struct _MMIfaceModem {
|
|||||||
GAsyncResult *res,
|
GAsyncResult *res,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
|
/* Asynchronous capabilities setting operation */
|
||||||
|
void (*set_current_capabilities) (MMIfaceModem *self,
|
||||||
|
MMModemCapability,
|
||||||
|
GAsyncReadyCallback callback,
|
||||||
|
gpointer user_data);
|
||||||
|
gboolean (*set_current_capabilities_finish) (MMIfaceModem *self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
/* Asynchronous current band setting operation */
|
/* Asynchronous current band setting operation */
|
||||||
void (*set_current_bands) (MMIfaceModem *self,
|
void (*set_current_bands) (MMIfaceModem *self,
|
||||||
GArray *bands_array,
|
GArray *bands_array,
|
||||||
|
Reference in New Issue
Block a user