api,introspection: merge 'AllowedModes' and 'SupportedMode' into 'CurrentModes'

We now have a single 'CurrentModes' property which contains both values in a
tuple with signature "(uu)".

Also, rename 'SetAllowedModes()' to 'SetCurrentModes()', and update the list of
arguments expected to have a single "(uu)" tuple.
This commit is contained in:
Aleksander Morgado
2013-06-05 19:15:14 +02:00
parent 45ceba7692
commit 1c67d050cb
24 changed files with 482 additions and 447 deletions
+46 -41
View File
@@ -1034,41 +1034,39 @@ mm_modem_peek_supported_modes (MMModem *self,
/*****************************************************************************/
/**
* mm_modem_get_allowed_modes:
* mm_modem_get_current_modes:
* @self: A #MMModem.
* @allowed: (out): Return location for a bitmask of #MMModemMode values.
* @preferred: (out): Return location for a #MMModemMode value.
*
* Gets the list of modes specifying the access technologies (eg 2G/3G/4G preference)
* the #MMModem is currently allowed to use when connecting to a network.
* Gets the list of modes specifying the access technologies (eg 2G/3G/4G)
* the #MMModem is currently allowed to use when connecting to a network, as
* well as the preferred one, if any.
*
* For POTS devices, only the #MM_MODEM_MODE_ANY is supported.
*
* Returns: A bitmask of #MMModemMode values.
* Returns: %TRUE if @allowed and @preferred are set, %FALSE otherwise.
*/
MMModemMode
mm_modem_get_allowed_modes (MMModem *self)
gboolean
mm_modem_get_current_modes (MMModem *self,
MMModemMode *allowed,
MMModemMode *preferred)
{
g_return_val_if_fail (MM_IS_MODEM (self), MM_MODEM_MODE_NONE);
GVariant *variant;
return (MMModemMode) mm_gdbus_modem_get_allowed_modes (MM_GDBUS_MODEM (self));
}
g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
g_return_val_if_fail (allowed != NULL, FALSE);
g_return_val_if_fail (preferred != NULL, FALSE);
/*****************************************************************************/
variant = mm_gdbus_modem_dup_current_modes (MM_GDBUS_MODEM (self));
if (variant) {
g_variant_get (variant,
"(uu)",
allowed,
preferred);
g_variant_unref (variant);
return TRUE;
}
/**
* mm_modem_get_preferred_mode:
* @self: A #MMModem.
*
* Get the preferred access technology (eg 2G/3G/4G preference), among
* the ones defined in the allowed modes.
*
* Returns: A single #MMModemMode value.
*/
MMModemMode
mm_modem_get_preferred_mode (MMModem *self)
{
g_return_val_if_fail (MM_IS_MODEM (self), MM_MODEM_MODE_NONE);
return (MMModemMode) mm_gdbus_modem_get_preferred_mode (MM_GDBUS_MODEM (self));
return FALSE;
}
/*****************************************************************************/
@@ -2318,27 +2316,27 @@ mm_modem_set_power_state_sync (MMModem *self,
/*****************************************************************************/
/**
* mm_modem_set_allowed_modes_finish:
* mm_modem_set_current_modes_finish:
* @self: A #MMModem.
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_set_allowed_modes().
* @res: The #GAsyncResult obtained from the #GAsyncReadyCallback passed to mm_modem_set_current_modes().
* @error: Return location for error or %NULL.
*
* Finishes an operation started with mm_modem_set_allowed_modes().
* Finishes an operation started with mm_modem_set_current_modes().
*
* Returns: %TRUE if the allowed modes were successfully set, %FALSE if @error is set.
*/
gboolean
mm_modem_set_allowed_modes_finish (MMModem *self,
mm_modem_set_current_modes_finish (MMModem *self,
GAsyncResult *res,
GError **error)
{
g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
return mm_gdbus_modem_call_set_allowed_modes_finish (MM_GDBUS_MODEM (self), res, error);
return mm_gdbus_modem_call_set_current_modes_finish (MM_GDBUS_MODEM (self), res, error);
}
/**
* mm_modem_set_allowed_modes:
* mm_modem_set_current_modes:
* @self: A #MMModem.
* @modes: Mask of #MMModemMode values specifying which modes are allowed.
* @preferred: A #MMModemMode value specifying which of the modes given in @modes is the preferred one, or #MM_MODEM_MODE_NONE if none.
@@ -2350,12 +2348,12 @@ mm_modem_set_allowed_modes_finish (MMModem *self,
* currently allowed to use when connecting to a network.
*
* 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_allowed_modes_finish() to get the result of the operation.
* You can then call mm_modem_set_current_modes_finish() to get the result of the operation.
*
* See mm_modem_set_allowed_modes_sync() for the synchronous, blocking version of this method.
* See mm_modem_set_current_modes_sync() for the synchronous, blocking version of this method.
*/
void
mm_modem_set_allowed_modes (MMModem *self,
mm_modem_set_current_modes (MMModem *self,
MMModemMode modes,
MMModemMode preferred,
GCancellable *cancellable,
@@ -2364,11 +2362,15 @@ mm_modem_set_allowed_modes (MMModem *self,
{
g_return_if_fail (MM_IS_MODEM (self));
mm_gdbus_modem_call_set_allowed_modes (MM_GDBUS_MODEM (self), modes, preferred, cancellable, callback, user_data);
mm_gdbus_modem_call_set_current_modes (MM_GDBUS_MODEM (self),
g_variant_new ("(uu)", modes, preferred),
cancellable,
callback,
user_data);
}
/**
* mm_modem_set_allowed_modes_sync:
* mm_modem_set_current_modes_sync:
* @self: A #MMModem.
* @modes: Mask of #MMModemMode values specifying which modes are allowed.
* @preferred: A #MMModemMode value specifying which of the modes given in @modes is the preferred one, or #MM_MODEM_MODE_NONE if none.
@@ -2378,13 +2380,13 @@ mm_modem_set_allowed_modes (MMModem *self,
* Synchronously sets the access technologies (e.g. 2G/3G/4G preference) the device is
* currently allowed to use when connecting to a network.
*
* The calling thread is blocked until a reply is received. See mm_modem_set_allowed_modes()
* The calling thread is blocked until a reply is received. See mm_modem_set_current_modes()
* for the asynchronous version of this method.
*
* Returns: %TRUE if the allowed modes were successfully set, %FALSE if @error is set.
*/
gboolean
mm_modem_set_allowed_modes_sync (MMModem *self,
mm_modem_set_current_modes_sync (MMModem *self,
MMModemMode modes,
MMModemMode preferred,
GCancellable *cancellable,
@@ -2392,7 +2394,10 @@ mm_modem_set_allowed_modes_sync (MMModem *self,
{
g_return_val_if_fail (MM_IS_MODEM (self), FALSE);
return mm_gdbus_modem_call_set_allowed_modes_sync (MM_GDBUS_MODEM (self), modes, preferred, cancellable, error);
return mm_gdbus_modem_call_set_current_modes_sync (MM_GDBUS_MODEM (self),
g_variant_new ("(uu)", modes, preferred),
cancellable,
error);
}
/*****************************************************************************/
+6 -6
View File
@@ -135,9 +135,9 @@ gboolean mm_modem_get_supported_modes (MMModem *self,
MMModemModeCombination **modes,
guint *n_modes);
MMModemMode mm_modem_get_allowed_modes (MMModem *self);
MMModemMode mm_modem_get_preferred_mode (MMModem *self);
gboolean mm_modem_get_current_modes (MMModem *self,
MMModemMode *allowed,
MMModemMode *preferred);
gboolean mm_modem_peek_supported_bands (MMModem *self,
const MMModemBand **bands,
@@ -266,16 +266,16 @@ gboolean mm_modem_set_power_state_sync (MMModem *self,
GCancellable *cancellable,
GError **error);
void mm_modem_set_allowed_modes (MMModem *self,
void mm_modem_set_current_modes (MMModem *self,
MMModemMode modes,
MMModemMode preferred,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_modem_set_allowed_modes_finish (MMModem *self,
gboolean mm_modem_set_current_modes_finish (MMModem *self,
GAsyncResult *res,
GError **error);
gboolean mm_modem_set_allowed_modes_sync (MMModem *self,
gboolean mm_modem_set_current_modes_sync (MMModem *self,
MMModemMode modes,
MMModemMode preferred,
GCancellable *cancellable,
+11 -11
View File
@@ -49,7 +49,7 @@ struct _MMSimpleConnectPropertiesPrivate {
MMModemBand *current_bands;
guint n_current_bands;
/* Modes */
gboolean allowed_modes_set;
gboolean current_modes_set;
MMModemMode allowed_modes;
MMModemMode preferred_mode;
/* Bearer properties */
@@ -183,7 +183,7 @@ mm_simple_connect_properties_get_current_bands (MMSimpleConnectProperties *self,
/*****************************************************************************/
/**
* mm_simple_connect_properties_set_allowed_modes:
* mm_simple_connect_properties_set_current_modes:
* @self: a #MMSimpleConnectProperties.
* @allowed: bitmask of #MMModemMode values specifying which are allowed.
* @preferred: a #MMModemMode value, specifying which of the ones in @allowed is preferred, if any.
@@ -191,7 +191,7 @@ mm_simple_connect_properties_get_current_bands (MMSimpleConnectProperties *self,
* Sets the modes allowed to use, and which of them is preferred.
*/
void
mm_simple_connect_properties_set_allowed_modes (MMSimpleConnectProperties *self,
mm_simple_connect_properties_set_current_modes (MMSimpleConnectProperties *self,
MMModemMode allowed,
MMModemMode preferred)
{
@@ -199,11 +199,11 @@ mm_simple_connect_properties_set_allowed_modes (MMSimpleConnectProperties *self,
self->priv->allowed_modes = allowed;
self->priv->preferred_mode = preferred;
self->priv->allowed_modes_set = TRUE;
self->priv->current_modes_set = TRUE;
}
/**
* mm_simple_connect_properties_get_allowed_modes:
* mm_simple_connect_properties_get_current_modes:
* @self: a #MMSimpleConnectProperties.
* @allowed: (out): location for the bitmask of #MMModemMode values specifying which are allowed.
* @preferred: (out): loction for a #MMModemMode value, specifying which of the ones in @allowed is preferred, if any.
@@ -213,7 +213,7 @@ mm_simple_connect_properties_set_allowed_modes (MMSimpleConnectProperties *self,
* Returns: %TRUE if @allowed and @preferred are set, %FALSE otherwise.
*/
gboolean
mm_simple_connect_properties_get_allowed_modes (MMSimpleConnectProperties *self,
mm_simple_connect_properties_get_current_modes (MMSimpleConnectProperties *self,
MMModemMode *allowed,
MMModemMode *preferred)
{
@@ -221,7 +221,7 @@ mm_simple_connect_properties_get_allowed_modes (MMSimpleConnectProperties *self,
g_return_val_if_fail (allowed != NULL, FALSE);
g_return_val_if_fail (preferred != NULL, FALSE);
if (self->priv->allowed_modes_set) {
if (self->priv->current_modes_set) {
*allowed = self->priv->allowed_modes;
*preferred = self->priv->preferred_mode;
return TRUE;
@@ -524,7 +524,7 @@ mm_simple_connect_properties_get_dictionary (MMSimpleConnectProperties *self)
mm_common_bands_array_to_variant (self->priv->current_bands,
self->priv->n_current_bands));
if (self->priv->allowed_modes_set) {
if (self->priv->current_modes_set) {
g_variant_builder_add (&builder,
"{sv}",
PROPERTY_ALLOWED_MODES,
@@ -639,7 +639,7 @@ mm_simple_connect_properties_new_from_string (const gchar *str,
g_object_unref (ctx.self);
ctx.self = NULL;
} else {
mm_simple_connect_properties_set_allowed_modes (
mm_simple_connect_properties_set_current_modes (
ctx.self,
allowed_modes,
preferred_mode);
@@ -730,7 +730,7 @@ mm_simple_connect_properties_new_from_dictionary (GVariant *dictionary,
}
/* If we got allowed modes variant, check if we got preferred mode */
else if (allowed_modes_variant) {
mm_simple_connect_properties_set_allowed_modes (
mm_simple_connect_properties_set_current_modes (
self,
g_variant_get_uint32 (allowed_modes_variant),
(preferred_mode_variant ?
@@ -739,7 +739,7 @@ mm_simple_connect_properties_new_from_dictionary (GVariant *dictionary,
}
/* If we only got preferred mode, assume allowed is ANY */
else if (preferred_mode_variant) {
mm_simple_connect_properties_set_allowed_modes (
mm_simple_connect_properties_set_current_modes (
self,
MM_MODEM_MODE_ANY,
g_variant_get_uint32 (preferred_mode_variant));
+2 -2
View File
@@ -66,7 +66,7 @@ void mm_simple_connect_properties_set_operator_id (MMSimpleConnectProperties *
void mm_simple_connect_properties_set_current_bands (MMSimpleConnectProperties *self,
const MMModemBand *bands,
guint n_bands);
void mm_simple_connect_properties_set_allowed_modes (MMSimpleConnectProperties *self,
void mm_simple_connect_properties_set_current_modes (MMSimpleConnectProperties *self,
MMModemMode allowed,
MMModemMode preferred);
void mm_simple_connect_properties_set_apn (MMSimpleConnectProperties *self,
@@ -89,7 +89,7 @@ const gchar *mm_simple_connect_properties_get_operator_id (MMSimpleCon
gboolean mm_simple_connect_properties_get_current_bands (MMSimpleConnectProperties *self,
const MMModemBand **bands,
guint *n_bands);
gboolean mm_simple_connect_properties_get_allowed_modes (MMSimpleConnectProperties *self,
gboolean mm_simple_connect_properties_get_current_modes (MMSimpleConnectProperties *self,
MMModemMode *allowed,
MMModemMode *preferred);
const gchar *mm_simple_connect_properties_get_apn (MMSimpleConnectProperties *self);