api,dbus: rename AllowedBands' to just Bands'

ModemManager will load:
  1) The list of supported bands. Note that this doesn't mean that any possible
     combination of bands is supported, as modems may support only specific
     combinations, but at least gives a rough idea of what the modem is capable
     of handling.

  2) The list of CURRENT bands. There is no such "Allowed" bands, as we do with
     modes, modems will have a specific set of bands being currently used, which
     will be reported in the `Bands' property.

If the modem allows modifying the list of bands to use, this can be done with
the `SetBands()' method. If the modem doesn't support using a specific
combination of bands, this method will report an error.
This commit is contained in:
Aleksander Morgado
2012-02-17 16:57:12 +01:00
parent 76e52236a4
commit 09d2f062c7
12 changed files with 236 additions and 244 deletions

View File

@@ -58,7 +58,7 @@ static gchar *create_bearer_str;
static gchar *delete_bearer_str; static gchar *delete_bearer_str;
static gchar *set_allowed_modes_str; static gchar *set_allowed_modes_str;
static gchar *set_preferred_mode_str; static gchar *set_preferred_mode_str;
static gchar *set_allowed_bands_str; static gchar *set_bands_str;
static GOptionEntry entries[] = { static GOptionEntry entries[] = {
{ "monitor-state", 'w', 0, G_OPTION_ARG_NONE, &monitor_state_flag, { "monitor-state", 'w', 0, G_OPTION_ARG_NONE, &monitor_state_flag,
@@ -105,8 +105,8 @@ static GOptionEntry entries[] = {
"Set allowed modes in a given modem.", "Set allowed modes in a given modem.",
"[MODE1|MODE2...]" "[MODE1|MODE2...]"
}, },
{ "set-allowed-bands", 0, 0, G_OPTION_ARG_STRING, &set_allowed_bands_str, { "set-bands", 0, 0, G_OPTION_ARG_STRING, &set_bands_str,
"Set allowed bands in a given modem.", "Set bands to be used by a given modem.",
"[BAND1|BAND2...]" "[BAND1|BAND2...]"
}, },
{ "set-preferred-mode", 0, 0, G_OPTION_ARG_STRING, &set_preferred_mode_str, { "set-preferred-mode", 0, 0, G_OPTION_ARG_STRING, &set_preferred_mode_str,
@@ -152,7 +152,7 @@ mmcli_modem_options_enabled (void)
!!command_str + !!command_str +
!!set_allowed_modes_str + !!set_allowed_modes_str +
!!set_preferred_mode_str + !!set_preferred_mode_str +
!!set_allowed_bands_str); !!set_bands_str);
if (n_actions == 0 && mmcli_get_common_modem_string ()) { if (n_actions == 0 && mmcli_get_common_modem_string ()) {
/* default to info */ /* default to info */
@@ -272,7 +272,7 @@ print_modem_info (void)
gchar *allowed_modes_string; gchar *allowed_modes_string;
gchar *preferred_mode_string; gchar *preferred_mode_string;
gchar *supported_bands_string; gchar *supported_bands_string;
gchar *allowed_bands_string; gchar *bands_string;
MMModemBand *bands = NULL; MMModemBand *bands = NULL;
guint n_bands = 0; guint n_bands = 0;
@@ -304,14 +304,10 @@ print_modem_info (void)
mm_modem_get_modem_capabilities (ctx->modem)); mm_modem_get_modem_capabilities (ctx->modem));
access_technologies_string = mm_modem_access_technology_build_string_from_mask ( access_technologies_string = mm_modem_access_technology_build_string_from_mask (
mm_modem_get_access_technologies (ctx->modem)); mm_modem_get_access_technologies (ctx->modem));
mm_modem_get_allowed_bands (ctx->modem, mm_modem_get_bands (ctx->modem, &bands, &n_bands);
&bands, bands_string = mm_common_build_bands_string (bands, n_bands);
&n_bands);
allowed_bands_string = mm_common_build_bands_string (bands, n_bands);
g_free (bands); g_free (bands);
mm_modem_get_supported_bands (ctx->modem, mm_modem_get_supported_bands (ctx->modem, &bands, &n_bands);
&bands,
&n_bands);
supported_bands_string = mm_common_build_bands_string (bands, n_bands); supported_bands_string = mm_common_build_bands_string (bands, n_bands);
g_free (bands); g_free (bands);
allowed_modes_string = mm_modem_mode_build_string_from_mask ( allowed_modes_string = mm_modem_mode_build_string_from_mask (
@@ -374,9 +370,9 @@ print_modem_info (void)
/* Band related stuff */ /* Band related stuff */
g_print (" -------------------------\n" g_print (" -------------------------\n"
" Bands | supported: '%s'\n" " Bands | supported: '%s'\n"
" | allowed: '%s'\n", " | current: '%s'\n",
VALIDATE_UNKNOWN (supported_bands_string), VALIDATE_UNKNOWN (supported_bands_string),
VALIDATE_UNKNOWN (allowed_bands_string)); VALIDATE_UNKNOWN (bands_string));
/* If available, 3GPP related stuff */ /* If available, 3GPP related stuff */
if (ctx->modem_3gpp) { if (ctx->modem_3gpp) {
@@ -434,7 +430,7 @@ print_modem_info (void)
VALIDATE_PATH (mm_modem_get_sim_path (ctx->modem))); VALIDATE_PATH (mm_modem_get_sim_path (ctx->modem)));
g_print ("\n"); g_print ("\n");
g_free (allowed_bands_string); g_free (bands_string);
g_free (supported_bands_string); g_free (supported_bands_string);
g_free (access_technologies_string); g_free (access_technologies_string);
g_free (capabilities_string); g_free (capabilities_string);
@@ -731,44 +727,44 @@ parse_modes (MMModemMode *allowed,
} }
static void static void
set_allowed_bands_process_reply (gboolean result, set_bands_process_reply (gboolean result,
const GError *error) const GError *error)
{ {
if (!result) { if (!result) {
g_printerr ("error: couldn't set allowed bands: '%s'\n", g_printerr ("error: couldn't set bands: '%s'\n",
error ? error->message : "unknown error"); error ? error->message : "unknown error");
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
g_print ("successfully set allowed bands in the modem\n"); g_print ("successfully set bands in the modem\n");
} }
static void static void
set_allowed_bands_ready (MMModem *modem, set_bands_ready (MMModem *modem,
GAsyncResult *result, GAsyncResult *result,
gpointer nothing) gpointer nothing)
{ {
gboolean operation_result; gboolean operation_result;
GError *error = NULL; GError *error = NULL;
operation_result = mm_modem_set_allowed_bands_finish (modem, result, &error); operation_result = mm_modem_set_bands_finish (modem, result, &error);
set_allowed_bands_process_reply (operation_result, error); set_bands_process_reply (operation_result, error);
mmcli_async_operation_done (); mmcli_async_operation_done ();
} }
static void static void
parse_bands (MMModemBand **allowed, parse_bands (MMModemBand **bands,
guint *n_allowed) guint *n_bands)
{ {
GError *error = NULL; GError *error = NULL;
mm_common_get_bands_from_string (set_allowed_bands_str, mm_common_get_bands_from_string (set_bands_str,
allowed, bands,
n_allowed, n_bands,
&error); &error);
if (error) { if (error) {
g_printerr ("error: couldn't parse list of allowed bands: '%s'\n", g_printerr ("error: couldn't parse list of bands: '%s'\n",
error->message); error->message);
exit (EXIT_FAILURE); exit (EXIT_FAILURE);
} }
@@ -934,18 +930,18 @@ get_modem_ready (GObject *source,
} }
/* Request to set allowed bands in a given modem? */ /* Request to set allowed bands in a given modem? */
if (set_allowed_bands_str) { if (set_bands_str) {
MMModemBand *allowed; MMModemBand *bands;
guint n_allowed; guint n_bands;
parse_bands (&allowed, &n_allowed); parse_bands (&bands, &n_bands);
mm_modem_set_allowed_bands (ctx->modem, mm_modem_set_bands (ctx->modem,
allowed, bands,
n_allowed, n_bands,
ctx->cancellable, ctx->cancellable,
(GAsyncReadyCallback)set_allowed_bands_ready, (GAsyncReadyCallback)set_bands_ready,
NULL); NULL);
g_free (allowed); g_free (bands);
return; return;
} }
@@ -1114,19 +1110,19 @@ mmcli_modem_run_synchronous (GDBusConnection *connection)
} }
/* Request to set allowed bands in a given modem? */ /* Request to set allowed bands in a given modem? */
if (set_allowed_bands_str) { if (set_bands_str) {
gboolean result; gboolean result;
MMModemBand *allowed; MMModemBand *bands;
guint n_allowed; guint n_bands;
parse_bands (&allowed, &n_allowed); parse_bands (&bands, &n_bands);
result = mm_modem_set_allowed_bands_sync (ctx->modem, result = mm_modem_set_bands_sync (ctx->modem,
allowed, bands,
n_allowed, n_bands,
NULL, NULL,
&error); &error);
g_free (allowed); g_free (bands);
set_allowed_bands_process_reply (result, error); set_bands_process_reply (result, error);
return; return;
} }

View File

@@ -23,7 +23,7 @@ G_DEFINE_TYPE (MMCommonConnectProperties, mm_common_connect_properties, G_TYPE_O
#define PROPERTY_PIN "pin" #define PROPERTY_PIN "pin"
#define PROPERTY_OPERATOR_ID "operator-id" #define PROPERTY_OPERATOR_ID "operator-id"
#define PROPERTY_ALLOWED_BANDS "allowed-bands" #define PROPERTY_BANDS "bands"
#define PROPERTY_ALLOWED_MODES "allowed-modes" #define PROPERTY_ALLOWED_MODES "allowed-modes"
#define PROPERTY_PREFERRED_MODE "preferred-mode" #define PROPERTY_PREFERRED_MODE "preferred-mode"
@@ -33,8 +33,8 @@ struct _MMCommonConnectPropertiesPrivate {
/* Operator ID */ /* Operator ID */
gchar *operator_id; gchar *operator_id;
/* Bands */ /* Bands */
MMModemBand *allowed_bands; MMModemBand *bands;
guint n_allowed_bands; guint n_bands;
/* Modes */ /* Modes */
gboolean allowed_modes_set; gboolean allowed_modes_set;
MMModemMode allowed_modes; MMModemMode allowed_modes;
@@ -62,16 +62,16 @@ mm_common_connect_properties_set_operator_id (MMCommonConnectProperties *self,
} }
void void
mm_common_connect_properties_set_allowed_bands (MMCommonConnectProperties *self, mm_common_connect_properties_set_bands (MMCommonConnectProperties *self,
const MMModemBand *bands, const MMModemBand *bands,
guint n_bands) guint n_bands)
{ {
g_free (self->priv->allowed_bands); g_free (self->priv->bands);
self->priv->n_allowed_bands = n_bands; self->priv->n_bands = n_bands;
self->priv->allowed_bands = g_new (MMModemBand, self->priv->n_allowed_bands); self->priv->bands = g_new (MMModemBand, self->priv->n_bands);
memcpy (self->priv->allowed_bands, memcpy (self->priv->bands,
bands, bands,
sizeof (MMModemBand) * self->priv->n_allowed_bands); sizeof (MMModemBand) * self->priv->n_bands);
} }
void void
@@ -153,12 +153,12 @@ mm_common_connect_properties_get_operator_id (MMCommonConnectProperties *self)
} }
void void
mm_common_connect_properties_get_allowed_bands (MMCommonConnectProperties *self, mm_common_connect_properties_get_bands (MMCommonConnectProperties *self,
const MMModemBand **bands, const MMModemBand **bands,
guint *n_bands) guint *n_bands)
{ {
*bands = self->priv->allowed_bands; *bands = self->priv->bands;
*n_bands = self->priv->n_allowed_bands; *n_bands = self->priv->n_bands;
} }
void void
@@ -235,12 +235,12 @@ mm_common_connect_properties_get_dictionary (MMCommonConnectProperties *self)
PROPERTY_OPERATOR_ID, PROPERTY_OPERATOR_ID,
g_variant_new_string (self->priv->operator_id)); g_variant_new_string (self->priv->operator_id));
if (self->priv->allowed_bands) if (self->priv->bands)
g_variant_builder_add (&builder, g_variant_builder_add (&builder,
"{sv}", "{sv}",
PROPERTY_ALLOWED_BANDS, PROPERTY_BANDS,
mm_common_bands_array_to_variant (self->priv->allowed_bands, mm_common_bands_array_to_variant (self->priv->bands,
self->priv->n_allowed_bands)); self->priv->n_bands));
if (self->priv->allowed_modes_set) { if (self->priv->allowed_modes_set) {
g_variant_builder_add (&builder, g_variant_builder_add (&builder,
@@ -293,13 +293,13 @@ key_value_foreach (const gchar *key,
mm_common_connect_properties_set_pin (ctx->properties, value); mm_common_connect_properties_set_pin (ctx->properties, value);
else if (g_str_equal (key, PROPERTY_OPERATOR_ID)) else if (g_str_equal (key, PROPERTY_OPERATOR_ID))
mm_common_connect_properties_set_operator_id (ctx->properties, value); mm_common_connect_properties_set_operator_id (ctx->properties, value);
else if (g_str_equal (key, PROPERTY_ALLOWED_BANDS)) { else if (g_str_equal (key, PROPERTY_BANDS)) {
MMModemBand *bands = NULL; MMModemBand *bands = NULL;
guint n_bands = 0; guint n_bands = 0;
mm_common_get_bands_from_string (value, &bands, &n_bands, &ctx->error); mm_common_get_bands_from_string (value, &bands, &n_bands, &ctx->error);
if (!ctx->error) { if (!ctx->error) {
mm_common_connect_properties_set_allowed_bands (ctx->properties, bands, n_bands); mm_common_connect_properties_set_bands (ctx->properties, bands, n_bands);
g_free (bands); g_free (bands);
} }
} else if (g_str_equal (key, PROPERTY_ALLOWED_MODES)) { } else if (g_str_equal (key, PROPERTY_ALLOWED_MODES)) {
@@ -405,11 +405,11 @@ mm_common_connect_properties_new_from_dictionary (GVariant *dictionary,
mm_common_connect_properties_set_operator_id ( mm_common_connect_properties_set_operator_id (
properties, properties,
g_variant_get_string (value, NULL)); g_variant_get_string (value, NULL));
else if (g_str_equal (key, PROPERTY_ALLOWED_BANDS)) { else if (g_str_equal (key, PROPERTY_BANDS)) {
GArray *array; GArray *array;
array = mm_common_bands_variant_to_garray (value); array = mm_common_bands_variant_to_garray (value);
mm_common_connect_properties_set_allowed_bands ( mm_common_connect_properties_set_bands (
properties, properties,
(MMModemBand *)array->data, (MMModemBand *)array->data,
array->len); array->len);
@@ -483,9 +483,9 @@ mm_common_connect_properties_init (MMCommonConnectProperties *self)
self->priv->bearer_properties = mm_common_bearer_properties_new (); self->priv->bearer_properties = mm_common_bearer_properties_new ();
self->priv->allowed_modes = MM_MODEM_MODE_ANY; self->priv->allowed_modes = MM_MODEM_MODE_ANY;
self->priv->preferred_mode = MM_MODEM_MODE_NONE; self->priv->preferred_mode = MM_MODEM_MODE_NONE;
self->priv->allowed_bands = g_new (MMModemBand, 1); self->priv->bands = g_new (MMModemBand, 1);
self->priv->allowed_bands[0] = MM_MODEM_BAND_ANY; self->priv->bands[0] = MM_MODEM_BAND_ANY;
self->priv->n_allowed_bands = 1; self->priv->n_bands = 1;
} }
static void static void
@@ -495,7 +495,7 @@ finalize (GObject *object)
g_free (self->priv->pin); g_free (self->priv->pin);
g_free (self->priv->operator_id); g_free (self->priv->operator_id);
g_free (self->priv->allowed_bands); g_free (self->priv->bands);
g_object_unref (self->priv->bearer_properties); g_object_unref (self->priv->bearer_properties);
G_OBJECT_CLASS (mm_common_connect_properties_parent_class)->finalize (object); G_OBJECT_CLASS (mm_common_connect_properties_parent_class)->finalize (object);

View File

@@ -59,7 +59,7 @@ void mm_common_connect_properties_set_pin (
void mm_common_connect_properties_set_operator_id ( void mm_common_connect_properties_set_operator_id (
MMCommonConnectProperties *properties, MMCommonConnectProperties *properties,
const gchar *operator_id); const gchar *operator_id);
void mm_common_connect_properties_set_allowed_bands ( void mm_common_connect_properties_set_bands (
MMCommonConnectProperties *properties, MMCommonConnectProperties *properties,
const MMModemBand *bands, const MMModemBand *bands,
guint n_bands); guint n_bands);
@@ -90,7 +90,7 @@ const gchar *mm_common_connect_properties_get_pin (
MMCommonConnectProperties *properties); MMCommonConnectProperties *properties);
const gchar *mm_common_connect_properties_get_operator_id ( const gchar *mm_common_connect_properties_get_operator_id (
MMCommonConnectProperties *properties); MMCommonConnectProperties *properties);
void mm_common_connect_properties_get_allowed_bands ( void mm_common_connect_properties_get_bands (
MMCommonConnectProperties *properties, MMCommonConnectProperties *properties,
const MMModemBand **bands, const MMModemBand **bands,
guint *n_bands); guint *n_bands);

View File

@@ -34,13 +34,13 @@ mm_modem_simple_connect_properties_set_operator_id (MMModemSimpleConnectProperti
} }
void void
mm_modem_simple_connect_properties_set_allowed_bands (MMModemSimpleConnectProperties *self, mm_modem_simple_connect_properties_set_bands (MMModemSimpleConnectProperties *self,
const MMModemBand *bands, const MMModemBand *bands,
guint n_bands) guint n_bands)
{ {
g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self)); g_return_if_fail (MM_IS_MODEM_SIMPLE_CONNECT_PROPERTIES (self));
mm_common_connect_properties_set_allowed_bands (self, bands, n_bands); mm_common_connect_properties_set_bands (self, bands, n_bands);
} }
void void

View File

@@ -39,7 +39,7 @@ void mm_modem_simple_connect_properties_set_pin (
void mm_modem_simple_connect_properties_set_operator_id ( void mm_modem_simple_connect_properties_set_operator_id (
MMModemSimpleConnectProperties *properties, MMModemSimpleConnectProperties *properties,
const gchar *operator_id); const gchar *operator_id);
void mm_modem_simple_connect_properties_set_allowed_bands ( void mm_modem_simple_connect_properties_set_bands (
MMModemSimpleConnectProperties *properties, MMModemSimpleConnectProperties *properties,
const MMModemBand *bands, const MMModemBand *bands,
guint n_bands); guint n_bands);

View File

@@ -680,18 +680,18 @@ mm_modem_get_supported_bands (MMModem *self,
} }
/** /**
* mm_modem_get_allowed_bands: * mm_modem_get_bands:
* @self: A #MMModem. * @self: A #MMModem.
* @bands: (out): Return location for the array of #MMModemBand values. * @bands: (out): Return location for the array of #MMModemBand values.
* @n_bands: (out): Return location for the number of values in @bands. * @n_bands: (out): Return location for the number of values in @bands.
* *
* Gets the list of radio frequency and technology bands the #MMModem is currently * Gets the list of radio frequency and technology bands the #MMModem is currently
* allowed to use when connecting to a network. * using when connecting to a network.
* *
* For POTS devices, only the #MM_MODEM_BAND_ANY band is supported. * For POTS devices, only the #MM_MODEM_BAND_ANY band is supported.
*/ */
void void
mm_modem_get_allowed_bands (MMModem *self, mm_modem_get_bands (MMModem *self,
MMModemBand **bands, MMModemBand **bands,
guint *n_bands) guint *n_bands)
{ {
@@ -701,7 +701,7 @@ mm_modem_get_allowed_bands (MMModem *self,
g_return_if_fail (bands != NULL); g_return_if_fail (bands != NULL);
g_return_if_fail (n_bands != NULL); g_return_if_fail (n_bands != NULL);
array = mm_common_bands_variant_to_garray (mm_gdbus_modem_get_allowed_bands (self)); array = mm_common_bands_variant_to_garray (mm_gdbus_modem_get_bands (self));
*n_bands = array->len; *n_bands = array->len;
*bands = (MMModemBand *)g_array_free (array, FALSE); *bands = (MMModemBand *)g_array_free (array, FALSE);
} }
@@ -1555,19 +1555,19 @@ mm_modem_set_allowed_modes_sync (MMModem *self,
} }
gboolean gboolean
mm_modem_set_allowed_bands_finish (MMModem *self, mm_modem_set_bands_finish (MMModem *self,
GAsyncResult *res, GAsyncResult *res,
GError **error) GError **error)
{ {
g_return_val_if_fail (MM_GDBUS_IS_MODEM (self), FALSE); g_return_val_if_fail (MM_GDBUS_IS_MODEM (self), FALSE);
return mm_gdbus_modem_call_set_allowed_bands_finish (self, return mm_gdbus_modem_call_set_bands_finish (self,
res, res,
error); error);
} }
void void
mm_modem_set_allowed_bands (MMModem *self, mm_modem_set_bands (MMModem *self,
const MMModemBand *bands, const MMModemBand *bands,
guint n_bands, guint n_bands,
GCancellable *cancellable, GCancellable *cancellable,
@@ -1576,7 +1576,7 @@ mm_modem_set_allowed_bands (MMModem *self,
{ {
g_return_if_fail (MM_GDBUS_IS_MODEM (self)); g_return_if_fail (MM_GDBUS_IS_MODEM (self));
mm_gdbus_modem_call_set_allowed_bands (self, mm_gdbus_modem_call_set_bands (self,
mm_common_bands_array_to_variant (bands, n_bands), mm_common_bands_array_to_variant (bands, n_bands),
cancellable, cancellable,
callback, callback,
@@ -1584,7 +1584,7 @@ mm_modem_set_allowed_bands (MMModem *self,
} }
gboolean gboolean
mm_modem_set_allowed_bands_sync (MMModem *self, mm_modem_set_bands_sync (MMModem *self,
const MMModemBand *bands, const MMModemBand *bands,
guint n_bands, guint n_bands,
GCancellable *cancellable, GCancellable *cancellable,
@@ -1592,7 +1592,7 @@ mm_modem_set_allowed_bands_sync (MMModem *self,
{ {
g_return_val_if_fail (MM_GDBUS_IS_MODEM (self), FALSE); g_return_val_if_fail (MM_GDBUS_IS_MODEM (self), FALSE);
return (mm_gdbus_modem_call_set_allowed_bands_sync ( return (mm_gdbus_modem_call_set_bands_sync (
self, self,
mm_common_bands_array_to_variant (bands, n_bands), mm_common_bands_array_to_variant (bands, n_bands),
cancellable, cancellable,

View File

@@ -74,7 +74,7 @@ MMModemMode mm_modem_get_preferred_mode (MMModem *self);
void mm_modem_get_supported_bands (MMModem *self, void mm_modem_get_supported_bands (MMModem *self,
MMModemBand **bands, MMModemBand **bands,
guint *n_bands); guint *n_bands);
void mm_modem_get_allowed_bands (MMModem *self, void mm_modem_get_bands (MMModem *self,
MMModemBand **bands, MMModemBand **bands,
guint *n_bands); guint *n_bands);
@@ -191,16 +191,16 @@ gboolean mm_modem_set_allowed_modes_sync (MMModem *self,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);
void mm_modem_set_allowed_bands (MMModem *self, void mm_modem_set_bands (MMModem *self,
const MMModemBand *bands, const MMModemBand *bands,
guint n_bands, guint n_bands,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
gboolean mm_modem_set_allowed_bands_finish (MMModem *self, gboolean mm_modem_set_bands_finish (MMModem *self,
GAsyncResult *res, GAsyncResult *res,
GError **error); GError **error);
gboolean mm_modem_set_allowed_bands_sync (MMModem *self, gboolean mm_modem_set_bands_sync (MMModem *self,
const MMModemBand *bands, const MMModemBand *bands,
guint n_bands, guint n_bands,
GCancellable *cancellable, GCancellable *cancellable,

View File

@@ -52,7 +52,7 @@
given as a string value (signature <literal>"s"</literal>). given as a string value (signature <literal>"s"</literal>).
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry><term><literal>"allowed-bands"</literal></term> <varlistentry><term><literal>"bands"</literal></term>
<listitem> <listitem>
List of <link linkend="MMModemBand">MMModemBand</link> values, List of <link linkend="MMModemBand">MMModemBand</link> values,
to specify all the bands allowed in the modem, given as a list of to specify all the bands allowed in the modem, given as a list of

View File

@@ -136,13 +136,13 @@
</method> </method>
<!-- <!--
SetAllowedBands: SetBands:
@bands: List of <link linkend="MMModemBand">MMModemBand</link> values, to specify all the bands allowed in the modem. @bands: List of <link linkend="MMModemBand">MMModemBand</link> values, to specify the bands to be used.
Set the radio frequency and technology bands the device is currently Set the radio frequency and technology bands the device is currently
allowed to use when connecting to a network. allowed to use when connecting to a network.
--> -->
<method name="SetAllowedBands"> <method name="SetBands">
<arg name="bands" type="au" direction="in" /> <arg name="bands" type="au" direction="in" />
</method> </method>
@@ -419,19 +419,15 @@
<property name="SupportedBands" type="au" access="read" /> <property name="SupportedBands" type="au" access="read" />
<!-- <!--
AllowedBands: Bands:
List of <link linkend="MMModemBand">MMModemBand</link> values, List of <link linkend="MMModemBand">MMModemBand</link> values,
specifying the radio frequency and technology bands the device is specifying the radio frequency and technology bands the device is
currently allowed to use when connecting to a network. currently using when connecting to a network.
It must be a subset of #org.freedesktop.ModemManager1.Modem:SupportedBands. It must be a subset of #org.freedesktop.ModemManager1.Modem:SupportedBands.
For POTS devices, only the
<link linkend="MM-MODEM-BAND-ANY:CAPS"><constant>MM_MODEM_BAND_ANY</constant></link>
mode is supported.
--> -->
<property name="AllowedBands" type="au" access="read" /> <property name="Bands" type="au" access="read" />
</interface> </interface>
</node> </node>

View File

@@ -172,7 +172,7 @@ typedef enum {
CONNECTION_STEP_UNLOCK_CHECK, CONNECTION_STEP_UNLOCK_CHECK,
CONNECTION_STEP_ENABLE, CONNECTION_STEP_ENABLE,
CONNECTION_STEP_ALLOWED_MODES, CONNECTION_STEP_ALLOWED_MODES,
CONNECTION_STEP_ALLOWED_BANDS, CONNECTION_STEP_BANDS,
CONNECTION_STEP_REGISTER, CONNECTION_STEP_REGISTER,
CONNECTION_STEP_BEARER, CONNECTION_STEP_BEARER,
CONNECTION_STEP_CONNECT, CONNECTION_STEP_CONNECT,
@@ -286,14 +286,14 @@ set_allowed_modes_ready (MMBaseModem *self,
} }
static void static void
set_allowed_bands_ready (MMBaseModem *self, set_bands_ready (MMBaseModem *self,
GAsyncResult *res, GAsyncResult *res,
ConnectionContext *ctx) ConnectionContext *ctx)
{ {
GError *error = NULL; GError *error = NULL;
if (!mm_iface_modem_set_allowed_bands_finish (MM_IFACE_MODEM (self), res, &error)) { if (!mm_iface_modem_set_bands_finish (MM_IFACE_MODEM (self), res, &error)) {
/* If setting allowed bands is unsupported, keep on */ /* If setting bands is unsupported, keep on */
if (!g_error_matches (error, if (!g_error_matches (error,
MM_CORE_ERROR, MM_CORE_ERROR,
MM_CORE_ERROR_UNSUPPORTED)) { MM_CORE_ERROR_UNSUPPORTED)) {
@@ -303,7 +303,7 @@ set_allowed_bands_ready (MMBaseModem *self,
} }
} }
/* Allowed bands set... almost there! */ /* Bands set... almost there! */
ctx->step++; ctx->step++;
connection_step (ctx); connection_step (ctx);
} }
@@ -448,26 +448,26 @@ connection_step (ConnectionContext *ctx)
return; return;
} }
case CONNECTION_STEP_ALLOWED_BANDS: { case CONNECTION_STEP_BANDS: {
GArray *array; GArray *array;
const MMModemBand *allowed_bands = NULL; const MMModemBand *bands = NULL;
guint n_allowed_bands = 0; guint n_bands = 0;
guint i; guint i;
mm_info ("Simple connect state (%d/%d): Allowed bands", mm_info ("Simple connect state (%d/%d): Bands",
ctx->step, CONNECTION_STEP_LAST); ctx->step, CONNECTION_STEP_LAST);
mm_common_connect_properties_get_allowed_bands (ctx->properties, mm_common_connect_properties_get_bands (ctx->properties,
&allowed_bands, &bands,
&n_allowed_bands); &n_bands);
array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), n_allowed_bands); array = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), n_bands);
for (i = 0; i < n_allowed_bands; i++) for (i = 0; i < n_bands; i++)
g_array_insert_val (array, i, allowed_bands[i]); g_array_insert_val (array, i, bands[i]);
mm_iface_modem_set_allowed_bands (MM_IFACE_MODEM (ctx->self), mm_iface_modem_set_bands (MM_IFACE_MODEM (ctx->self),
array, array,
(GAsyncReadyCallback)set_allowed_bands_ready, (GAsyncReadyCallback)set_bands_ready,
ctx); ctx);
g_array_unref (array); g_array_unref (array);
return; return;

View File

@@ -59,7 +59,7 @@ mm_iface_modem_bind_simple_status (MMIfaceModem *self,
status, MM_COMMON_SIMPLE_PROPERTY_SIGNAL_QUALITY, status, MM_COMMON_SIMPLE_PROPERTY_SIGNAL_QUALITY,
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
g_object_bind_property (skeleton, "allowed-bands", g_object_bind_property (skeleton, "bands",
status, MM_COMMON_SIMPLE_PROPERTY_BANDS, status, MM_COMMON_SIMPLE_PROPERTY_BANDS,
G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE); G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
@@ -1226,28 +1226,28 @@ handle_factory_reset (MmGdbusModem *skeleton,
} }
/*****************************************************************************/ /*****************************************************************************/
/* ALLOWED BANDS */ /* BANDS */
typedef struct { typedef struct {
MMIfaceModem *self; MMIfaceModem *self;
MmGdbusModem *skeleton; MmGdbusModem *skeleton;
GSimpleAsyncResult *result; GSimpleAsyncResult *result;
GArray *allowed_bands_array; GArray *bands_array;
} SetAllowedBandsContext; } SetBandsContext;
static void static void
set_allowed_bands_context_complete_and_free (SetAllowedBandsContext *ctx) set_bands_context_complete_and_free (SetBandsContext *ctx)
{ {
g_simple_async_result_complete_in_idle (ctx->result); g_simple_async_result_complete_in_idle (ctx->result);
g_object_unref (ctx->result); g_object_unref (ctx->result);
g_object_unref (ctx->self); g_object_unref (ctx->self);
g_object_unref (ctx->skeleton); g_object_unref (ctx->skeleton);
g_array_unref (ctx->allowed_bands_array); g_array_unref (ctx->bands_array);
g_free (ctx); g_free (ctx);
} }
gboolean gboolean
mm_iface_modem_set_allowed_bands_finish (MMIfaceModem *self, mm_iface_modem_set_bands_finish (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
GError **error) GError **error)
{ {
@@ -1255,37 +1255,37 @@ mm_iface_modem_set_allowed_bands_finish (MMIfaceModem *self,
} }
static void static void
set_allowed_bands_ready (MMIfaceModem *self, set_bands_ready (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
SetAllowedBandsContext *ctx) SetBandsContext *ctx)
{ {
GError *error = NULL; GError *error = NULL;
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands_finish (self, res, &error)) if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_bands_finish (self, res, &error))
g_simple_async_result_take_error (ctx->result, error); g_simple_async_result_take_error (ctx->result, error);
else { else {
mm_gdbus_modem_set_allowed_bands (ctx->skeleton, mm_gdbus_modem_set_bands (ctx->skeleton,
mm_common_bands_garray_to_variant (ctx->allowed_bands_array)); mm_common_bands_garray_to_variant (ctx->bands_array));
g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
} }
set_allowed_bands_context_complete_and_free (ctx); set_bands_context_complete_and_free (ctx);
} }
static gboolean static gboolean
validate_allowed_bands (const GArray *supported_bands_array, validate_bands (const GArray *supported_bands_array,
const GArray *allowed_bands_array, const GArray *bands_array,
GError **error) GError **error)
{ {
/* When the array has more than one element, there MUST NOT include ANY or /* When the array has more than one element, there MUST NOT include ANY or
* UNKNOWN */ * UNKNOWN */
if (allowed_bands_array->len > 1) { if (bands_array->len > 1) {
guint i; guint i;
for (i = 0; i < allowed_bands_array->len; i++) { for (i = 0; i < bands_array->len; i++) {
MMModemBand band; MMModemBand band;
band = g_array_index (allowed_bands_array, MMModemBand, i); band = g_array_index (bands_array, MMModemBand, i);
if (band == MM_MODEM_BAND_UNKNOWN || if (band == MM_MODEM_BAND_UNKNOWN ||
band == MM_MODEM_BAND_ANY) { band == MM_MODEM_BAND_ANY) {
g_set_error (error, g_set_error (error,
@@ -1330,18 +1330,18 @@ validate_allowed_bands (const GArray *supported_bands_array,
} }
void void
mm_iface_modem_set_allowed_bands (MMIfaceModem *self, mm_iface_modem_set_bands (MMIfaceModem *self,
GArray *bands_array, GArray *bands_array,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
SetAllowedBandsContext *ctx; SetBandsContext *ctx;
GArray *supported_bands_array; GArray *supported_bands_array;
GError *error = NULL; GError *error = NULL;
/* If setting allowed bands is not implemented, report an error */ /* If setting allowed bands is not implemented, report an error */
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands || if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_bands ||
!MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands_finish) { !MM_IFACE_MODEM_GET_INTERFACE (self)->set_bands_finish) {
g_simple_async_report_error_in_idle (G_OBJECT (self), g_simple_async_report_error_in_idle (G_OBJECT (self),
callback, callback,
user_data, user_data,
@@ -1352,57 +1352,57 @@ mm_iface_modem_set_allowed_bands (MMIfaceModem *self,
} }
/* Setup context */ /* Setup context */
ctx = g_new0 (SetAllowedBandsContext, 1); ctx = g_new0 (SetBandsContext, 1);
ctx->self = g_object_ref (self); ctx->self = g_object_ref (self);
ctx->result = g_simple_async_result_new (G_OBJECT (self), ctx->result = g_simple_async_result_new (G_OBJECT (self),
callback, callback,
user_data, user_data,
mm_iface_modem_set_allowed_bands); mm_iface_modem_set_bands);
g_object_get (self, g_object_get (self,
MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton, MM_IFACE_MODEM_DBUS_SKELETON, &ctx->skeleton,
NULL); NULL);
ctx->allowed_bands_array = g_array_ref (bands_array); ctx->bands_array = g_array_ref (bands_array);
/* Get list of supported bands */ /* Get list of supported bands */
supported_bands_array = (mm_common_bands_variant_to_garray ( supported_bands_array = (mm_common_bands_variant_to_garray (
mm_gdbus_modem_get_supported_bands (ctx->skeleton))); mm_gdbus_modem_get_supported_bands (ctx->skeleton)));
/* Validate input list of bands */ /* Validate input list of bands */
if (!validate_allowed_bands (supported_bands_array, if (!validate_bands (supported_bands_array,
ctx->allowed_bands_array, ctx->bands_array,
&error)) { &error)) {
g_array_unref (supported_bands_array); g_array_unref (supported_bands_array);
g_simple_async_result_take_error (ctx->result, error); g_simple_async_result_take_error (ctx->result, error);
set_allowed_bands_context_complete_and_free (ctx); set_bands_context_complete_and_free (ctx);
return; return;
} }
MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands ( MM_IFACE_MODEM_GET_INTERFACE (self)->set_bands (
self, self,
bands_array, bands_array,
(GAsyncReadyCallback)set_allowed_bands_ready, (GAsyncReadyCallback)set_bands_ready,
ctx); ctx);
g_array_unref (supported_bands_array); g_array_unref (supported_bands_array);
} }
static void static void
handle_set_allowed_bands_ready (MMIfaceModem *self, handle_set_bands_ready (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
DbusCallContext *ctx) DbusCallContext *ctx)
{ {
GError *error = NULL; GError *error = NULL;
if (!mm_iface_modem_set_allowed_bands_finish (self, res, &error)) if (!mm_iface_modem_set_bands_finish (self, res, &error))
g_dbus_method_invocation_take_error (ctx->invocation, error); g_dbus_method_invocation_take_error (ctx->invocation, error);
else else
mm_gdbus_modem_complete_set_allowed_bands (ctx->skeleton, mm_gdbus_modem_complete_set_bands (ctx->skeleton,
ctx->invocation); ctx->invocation);
dbus_call_context_free (ctx); dbus_call_context_free (ctx);
} }
static gboolean static gboolean
handle_set_allowed_bands (MmGdbusModem *skeleton, handle_set_bands (MmGdbusModem *skeleton,
GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation,
GVariant *bands_variant, GVariant *bands_variant,
MMIfaceModem *self) MMIfaceModem *self)
@@ -1435,9 +1435,9 @@ handle_set_allowed_bands (MmGdbusModem *skeleton,
GArray *bands_array; GArray *bands_array;
bands_array = mm_common_bands_variant_to_garray (bands_variant); bands_array = mm_common_bands_variant_to_garray (bands_variant);
mm_iface_modem_set_allowed_bands (self, mm_iface_modem_set_bands (self,
bands_array, bands_array,
(GAsyncReadyCallback)handle_set_allowed_bands_ready, (GAsyncReadyCallback)handle_set_bands_ready,
dbus_call_context_new (skeleton, dbus_call_context_new (skeleton,
invocation, invocation,
self)); self));
@@ -2579,7 +2579,7 @@ load_supported_bands_ready (MMIfaceModem *self,
if (bands_array) { if (bands_array) {
mm_gdbus_modem_set_supported_bands (ctx->skeleton, mm_gdbus_modem_set_supported_bands (ctx->skeleton,
mm_common_bands_garray_to_variant (bands_array)); mm_common_bands_garray_to_variant (bands_array));
mm_gdbus_modem_set_allowed_bands (ctx->skeleton, mm_gdbus_modem_set_bands (ctx->skeleton,
mm_common_bands_garray_to_variant (bands_array)); mm_common_bands_garray_to_variant (bands_array));
g_array_unref (bands_array); g_array_unref (bands_array);
} }
@@ -2958,7 +2958,7 @@ interface_initialization_step (InitializationContext *ctx)
/* Loading supported bands not implemented, default to ANY */ /* Loading supported bands not implemented, default to ANY */
mm_gdbus_modem_set_supported_bands (ctx->skeleton, mm_common_build_bands_any ()); mm_gdbus_modem_set_supported_bands (ctx->skeleton, mm_common_build_bands_any ());
mm_gdbus_modem_set_allowed_bands (ctx->skeleton, mm_common_build_bands_any ()); mm_gdbus_modem_set_bands (ctx->skeleton, mm_common_build_bands_any ());
} }
g_array_unref (supported_bands); g_array_unref (supported_bands);
@@ -3000,7 +3000,7 @@ interface_initialization_step (InitializationContext *ctx)
ctx->self); ctx->self);
g_signal_connect (ctx->skeleton, g_signal_connect (ctx->skeleton,
"handle-set-allowed-bands", "handle-set-allowed-bands",
G_CALLBACK (handle_set_allowed_bands), G_CALLBACK (handle_set_bands),
ctx->self); ctx->self);
g_signal_connect (ctx->skeleton, g_signal_connect (ctx->skeleton,
"handle-set-allowed-modes", "handle-set-allowed-modes",
@@ -3067,7 +3067,7 @@ mm_iface_modem_initialize (MMIfaceModem *self,
mm_gdbus_modem_set_allowed_modes (skeleton, MM_MODEM_MODE_NONE); mm_gdbus_modem_set_allowed_modes (skeleton, MM_MODEM_MODE_NONE);
mm_gdbus_modem_set_preferred_mode (skeleton, MM_MODEM_MODE_NONE); mm_gdbus_modem_set_preferred_mode (skeleton, MM_MODEM_MODE_NONE);
mm_gdbus_modem_set_supported_bands (skeleton, mm_common_build_bands_unknown ()); mm_gdbus_modem_set_supported_bands (skeleton, mm_common_build_bands_unknown ());
mm_gdbus_modem_set_allowed_bands (skeleton, mm_common_build_bands_unknown ()); mm_gdbus_modem_set_bands (skeleton, mm_common_build_bands_unknown ());
/* Bind our State property */ /* Bind our State property */
g_object_bind_property (self, MM_IFACE_MODEM_STATE, g_object_bind_property (self, MM_IFACE_MODEM_STATE,

View File

@@ -174,11 +174,11 @@ struct _MMIfaceModem {
GError **error); GError **error);
/* Asynchronous allowed band setting operation */ /* Asynchronous allowed band setting operation */
void (*set_allowed_bands) (MMIfaceModem *self, void (*set_bands) (MMIfaceModem *self,
GArray *bands_array, GArray *bands_array,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
gboolean (*set_allowed_bands_finish) (MMIfaceModem *self, gboolean (*set_bands_finish) (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
GError **error); GError **error);
@@ -356,12 +356,12 @@ gboolean mm_iface_modem_set_allowed_modes_finish (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
GError **error); GError **error);
/* Allow setting allowed bands */ /* Allow setting bands */
void mm_iface_modem_set_allowed_bands (MMIfaceModem *self, void mm_iface_modem_set_bands (MMIfaceModem *self,
GArray *bands_array, GArray *bands_array,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
gboolean mm_iface_modem_set_allowed_bands_finish (MMIfaceModem *self, gboolean mm_iface_modem_set_bands_finish (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
GError **error); GError **error);