libmm-glib,modem: new methods to handle the power state

This commit is contained in:
Aleksander Morgado
2013-01-01 12:09:27 +01:00
parent eec5d00a97
commit 091c47d695
3 changed files with 113 additions and 0 deletions

View File

@@ -77,6 +77,7 @@ MMModem
mm_modem_get_path
mm_modem_dup_path
mm_modem_get_state
mm_modem_get_power_state
mm_modem_get_modem_capabilities
mm_modem_get_current_capabilities
mm_modem_get_manufacturer
@@ -126,6 +127,9 @@ mm_modem_enable_sync
mm_modem_disable
mm_modem_disable_finish
mm_modem_disable_sync
mm_modem_set_power_state
mm_modem_set_power_state_finish
mm_modem_set_power_state_sync
mm_modem_set_allowed_modes
mm_modem_set_allowed_modes_finish
mm_modem_set_allowed_modes_sync

View File

@@ -816,6 +816,24 @@ mm_modem_get_state (MMModem *self)
/*****************************************************************************/
/**
* mm_modem_get_power_state:
* @self: A #MMModem.
*
* Gets the power state of the #MMModem.
*
* Returns: A #MMModemPowerState value.
*/
MMModemPowerState
mm_modem_get_power_state (MMModem *self)
{
g_return_val_if_fail (MM_IS_MODEM (self), MM_MODEM_POWER_STATE_UNKNOWN);
return (MMModemPowerState) mm_gdbus_modem_get_power_state (MM_GDBUS_MODEM (self));
}
/*****************************************************************************/
/**
* mm_modem_get_access_technology:
* @self: A #MMModem.
@@ -2067,6 +2085,82 @@ mm_modem_command_sync (MMModem *self,
/*****************************************************************************/
/**
* mm_modem_set_power_state_finish:
* @self: A #MMModem.
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_set_power_state().
* @error: Return location for error or %NULL.
*
* Finishes an operation started with mm_modem_set_power_state().
*
* Returns: %TRUE if the power state was successfully set, %FALSE if @error is set.
*/
gboolean
mm_modem_set_power_state_finish (MMModem *self,
GAsyncResult *res,
GError **error)
{
g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
return mm_gdbus_modem_call_set_power_state_finish (MM_GDBUS_MODEM (self), res, error);
}
/**
* mm_modem_set_power_state:
* @self: A #MMModem.
* @state: Either %MM_MODEM_POWER_STATE_LOW or %MM_MODEM_POWER_STATE_ON. Every other #MMModemPowerState value is not allowed.
* @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 power state of the device. This method can only be
* used while the modem is in %MM_MODEM_STATE_DISABLED state.
*
* 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_power_state_finish() to get the result of the operation.
*
* See mm_modem_set_power_state_sync() for the synchronous, blocking version of this method.
*/
void
mm_modem_set_power_state (MMModem *self,
MMModemPowerState state,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (MM_IS_MODEM (self));
mm_gdbus_modem_call_set_power_state (MM_GDBUS_MODEM (self), state, cancellable, callback, user_data);
}
/**
* mm_modem_set_power_state_sync:
* @self: A #MMModem.
* @state: Either %MM_MODEM_POWER_STATE_LOW or %MM_MODEM_POWER_STATE_ON. Every other #MMModemPowerState value is not allowed.
* @cancellable: (allow-none): A #GCancellable or %NULL.
* @error: Return location for error or %NULL.
*
* Synchronously sets the power state of the device. This method can only be
* used while the modem is in %MM_MODEM_STATE_DISABLED state.
*
* The calling thread is blocked until a reply is received. See mm_modem_set_power_state()
* for the asynchronous version of this method.
*
* Returns: %TRUE if the power state was successfully set, %FALSE if @error is set.
*/
gboolean
mm_modem_set_power_state_sync (MMModem *self,
MMModemPowerState state,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
return mm_gdbus_modem_call_set_power_state_sync (MM_GDBUS_MODEM (self), state, cancellable, error);
}
/*****************************************************************************/
/**
* mm_modem_set_allowed_modes_finish:
* @self: A #MMModem.

View File

@@ -118,6 +118,8 @@ MMUnlockRetries *mm_modem_peek_unlock_retries (MMModem *self);
MMModemState mm_modem_get_state (MMModem *self);
MMModemPowerState mm_modem_get_power_state (MMModem *self);
MMModemAccessTechnology mm_modem_get_access_technologies (MMModem *self);
guint mm_modem_get_signal_quality (MMModem *self,
@@ -241,6 +243,19 @@ gchar *mm_modem_command_sync (MMModem *self,
GCancellable *cancellable,
GError **error);
void mm_modem_set_power_state (MMModem *self,
MMModemPowerState state,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_modem_set_power_state_finish (MMModem *self,
GAsyncResult *res,
GError **error);
gboolean mm_modem_set_power_state_sync (MMModem *self,
MMModemPowerState state,
GCancellable *cancellable,
GError **error);
void mm_modem_set_allowed_modes (MMModem *self,
MMModemMode modes,
MMModemMode preferred,