aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-12-26 18:50:16 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:14:37 +0100
commit9d7e3de4cd7d607dc797b8b6adf93eb75a018b6e (patch)
tree762a58bcb685515756c1787fd72593eca83c9bad
parenta142a209eca617cd3cf4edc6436408e1e9c9f878 (diff)
api: MMModemBand is now an enum, not flags
We don't want to handle bands as flags, in order to avoid the need of 64-bits for the enum. This change implies that setting allowed bands will be done by giving an array of uint32 values, signature "au".
-rw-r--r--cli/mmcli-modem-simple.c6
-rw-r--r--include/ModemManager-enums.h70
-rw-r--r--libmm-common/mm-common-helpers.c41
-rw-r--r--libmm-common/mm-common-helpers.h5
-rw-r--r--libmm-glib/mm-modem-simple.h2
-rw-r--r--libmm-glib/mm-modem.c59
-rw-r--r--libmm-glib/mm-modem.h14
-rw-r--r--new/org.freedesktop.ModemManager1.Modem.Simple.xml12
-rw-r--r--new/org.freedesktop.ModemManager1.Modem.xml12
-rw-r--r--src/mm-iface-modem.c114
-rw-r--r--src/mm-iface-modem.h10
11 files changed, 258 insertions, 87 deletions
diff --git a/cli/mmcli-modem-simple.c b/cli/mmcli-modem-simple.c
index fcae2b14..4ebf4abe 100644
--- a/cli/mmcli-modem-simple.c
+++ b/cli/mmcli-modem-simple.c
@@ -147,7 +147,7 @@ connect_ready (MMModemSimple *modem_simple,
typedef struct {
gchar *pin;
gchar *operator_id;
- MMModemBand allowed_bands;
+ GArray *allowed_bands;
MMModemMode allowed_modes;
MMModemMode preferred_mode;
gchar *apn;
@@ -171,6 +171,7 @@ string_get_boolean (const gchar *value)
static void
simple_connect_properties_shutdown (SimpleConnectProperties *properties)
{
+ g_array_unref (properties->allowed_bands);
g_free (properties->pin);
g_free (properties->operator_id);
g_free (properties->apn);
@@ -190,9 +191,10 @@ simple_connect_properties_init (const gchar *input,
/* Some defaults... */
memset (properties, 0, sizeof (*properties));
properties->allow_roaming = TRUE;
- properties->allowed_bands = MM_MODEM_BAND_ANY;
properties->allowed_modes = MM_MODEM_MODE_ANY;
properties->preferred_mode = MM_MODEM_MODE_NONE;
+ properties->allowed_bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 1);
+ ((MMModemBand *)properties->allowed_bands)[0] = MM_MODEM_BAND_ANY;
/* Expecting input as:
* key1=string,key2=true,key3=false...
diff --git a/include/ModemManager-enums.h b/include/ModemManager-enums.h
index 6a8ff69d..404a4347 100644
--- a/include/ModemManager-enums.h
+++ b/include/ModemManager-enums.h
@@ -236,45 +236,45 @@ typedef enum { /*< underscore_name=mm_modem_mode >*/
* the device and the radio bands the device is allowed to use when
* connecting to a mobile network.
*/
-typedef enum { /*< skip >*/
+typedef enum { /*< underscore_name=mm_modem_band >*/
MM_MODEM_BAND_UNKNOWN = 0,
/* GSM/UMTS/3GPP bands */
- MM_MODEM_BAND_EGSM = 1 << 0,
- MM_MODEM_BAND_DCS = 1 << 1,
- MM_MODEM_BAND_PCS = 1 << 2,
- MM_MODEM_BAND_G850 = 1 << 3,
- MM_MODEM_BAND_U2100 = 1 << 4,
- MM_MODEM_BAND_U1800 = 1 << 5,
- MM_MODEM_BAND_U17IV = 1 << 6,
- MM_MODEM_BAND_U800 = 1 << 7,
- MM_MODEM_BAND_U850 = 1 << 8,
- MM_MODEM_BAND_U900 = 1 << 9,
- MM_MODEM_BAND_U17IX = 1 << 10,
- MM_MODEM_BAND_U1900 = 1 << 11,
- MM_MODEM_BAND_U2600 = 1 << 12,
+ MM_MODEM_BAND_EGSM = 1,
+ MM_MODEM_BAND_DCS = 2,
+ MM_MODEM_BAND_PCS = 3,
+ MM_MODEM_BAND_G850 = 4,
+ MM_MODEM_BAND_U2100 = 5,
+ MM_MODEM_BAND_U1800 = 6,
+ MM_MODEM_BAND_U17IV = 7,
+ MM_MODEM_BAND_U800 = 8,
+ MM_MODEM_BAND_U850 = 9,
+ MM_MODEM_BAND_U900 = 10,
+ MM_MODEM_BAND_U17IX = 11,
+ MM_MODEM_BAND_U1900 = 12,
+ MM_MODEM_BAND_U2600 = 13,
/* CDMA Band Classes (see 3GPP2 C.S0057-C) */
- MM_MODEM_BAND_CDMA_BC0_CELLULAR_800 = 1ULL << 32,
- MM_MODEM_BAND_CDMA_BC1_PCS_1900 = 1ULL << 33,
- MM_MODEM_BAND_CDMA_BC2_TACS = 1ULL << 34,
- MM_MODEM_BAND_CDMA_BC3_JTACS = 1ULL << 35,
- MM_MODEM_BAND_CDMA_BC4_KOREAN_PCS = 1ULL << 36,
- MM_MODEM_BAND_CDMA_BC5_NMT450 = 1ULL << 37,
- MM_MODEM_BAND_CDMA_BC6_IMT2000 = 1ULL << 38,
- MM_MODEM_BAND_CDMA_BC7_CELLULAR_700 = 1ULL << 49,
- MM_MODEM_BAND_CDMA_BC8_1800 = 1ULL << 40,
- MM_MODEM_BAND_CDMA_BC9_900 = 1ULL << 41,
- MM_MODEM_BAND_CDMA_BC10_SECONDARY_800 = 1ULL << 42,
- MM_MODEM_BAND_CDMA_BC11_PAMR_400 = 1ULL << 43,
- MM_MODEM_BAND_CDMA_BC12_PAMR_800 = 1ULL << 44,
- MM_MODEM_BAND_CDMA_BC13_IMT2000_2500 = 1ULL << 45,
- MM_MODEM_BAND_CDMA_BC14_PCS2_1900 = 1ULL << 46,
- MM_MODEM_BAND_CDMA_BC15_AWS = 1ULL << 47,
- MM_MODEM_BAND_CDMA_BC16_US_2500 = 1ULL << 48,
- MM_MODEM_BAND_CDMA_BC17_US_FLO_2500 = 1ULL << 49,
- MM_MODEM_BAND_CDMA_BC18_US_PS_700 = 1ULL << 50,
- MM_MODEM_BAND_CDMA_BC19_US_LOWER_700 = 1ULL << 51,
+ MM_MODEM_BAND_CDMA_BC0_CELLULAR_800 = 128,
+ MM_MODEM_BAND_CDMA_BC1_PCS_1900 = 129,
+ MM_MODEM_BAND_CDMA_BC2_TACS = 130,
+ MM_MODEM_BAND_CDMA_BC3_JTACS = 131,
+ MM_MODEM_BAND_CDMA_BC4_KOREAN_PCS = 132,
+ MM_MODEM_BAND_CDMA_BC5_NMT450 = 134,
+ MM_MODEM_BAND_CDMA_BC6_IMT2000 = 135,
+ MM_MODEM_BAND_CDMA_BC7_CELLULAR_700 = 136,
+ MM_MODEM_BAND_CDMA_BC8_1800 = 137,
+ MM_MODEM_BAND_CDMA_BC9_900 = 138,
+ MM_MODEM_BAND_CDMA_BC10_SECONDARY_800 = 139,
+ MM_MODEM_BAND_CDMA_BC11_PAMR_400 = 140,
+ MM_MODEM_BAND_CDMA_BC12_PAMR_800 = 141,
+ MM_MODEM_BAND_CDMA_BC13_IMT2000_2500 = 142,
+ MM_MODEM_BAND_CDMA_BC14_PCS2_1900 = 143,
+ MM_MODEM_BAND_CDMA_BC15_AWS = 144,
+ MM_MODEM_BAND_CDMA_BC16_US_2500 = 145,
+ MM_MODEM_BAND_CDMA_BC17_US_FLO_2500 = 146,
+ MM_MODEM_BAND_CDMA_BC18_US_PS_700 = 147,
+ MM_MODEM_BAND_CDMA_BC19_US_LOWER_700 = 148,
/* All/Any */
- MM_MODEM_BAND_ANY = 0xFFFFFFFFFFFFFFFF
+ MM_MODEM_BAND_ANY = 256
} MMModemBand;
/**
diff --git a/libmm-common/mm-common-helpers.c b/libmm-common/mm-common-helpers.c
index 04f86f7a..937b8483 100644
--- a/libmm-common/mm-common-helpers.c
+++ b/libmm-common/mm-common-helpers.c
@@ -87,3 +87,44 @@ mm_common_get_access_technologies_string (MMModemAccessTechnology access_tech)
return g_string_free (str, FALSE);
}
+
+GArray *
+mm_common_bands_variant_to_garray (GVariant *variant)
+{
+ GArray *array;
+ GVariantIter iter;
+ guint32 band = MM_MODEM_BAND_UNKNOWN;
+
+ g_variant_iter_init (&iter, variant);
+ array = g_array_sized_new (FALSE,
+ FALSE,
+ sizeof (MMModemBand),
+ g_variant_iter_n_children (&iter));
+ while (g_variant_iter_loop (&iter, "u", &band))
+ g_array_append_val (array, band);
+
+ return array;
+}
+
+GVariant *
+mm_common_bands_array_to_variant (const MMModemBand *bands,
+ guint n_bands)
+{
+ GVariantBuilder builder;
+ guint i;
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("au"));
+ for (i = 0; i < n_bands; i++) {
+ g_variant_builder_add_value (&builder,
+ g_variant_new_uint32 ((guint32)bands[i]));
+ }
+
+ return g_variant_builder_end (&builder);
+}
+
+GVariant *
+mm_common_bands_garray_to_variant (GArray *array)
+{
+ return mm_common_bands_array_to_variant ((const MMModemBand *)array->data,
+ array->len);
+}
diff --git a/libmm-common/mm-common-helpers.h b/libmm-common/mm-common-helpers.h
index 199c2609..c1a4c6a7 100644
--- a/libmm-common/mm-common-helpers.h
+++ b/libmm-common/mm-common-helpers.h
@@ -22,4 +22,9 @@
gchar *mm_common_get_capabilities_string (MMModemCapability caps);
gchar *mm_common_get_access_technologies_string (MMModemAccessTechnology access_tech);
+GArray *mm_common_bands_variant_to_garray (GVariant *variant);
+GVariant *mm_common_bands_array_to_variant (const MMModemBand *bands,
+ guint n_bands);
+GVariant *mm_common_bands_garray_to_variant (GArray *array);
+
#endif /* MM_COMMON_HELPERS_H */
diff --git a/libmm-glib/mm-modem-simple.h b/libmm-glib/mm-modem-simple.h
index 451afdc7..95306ab7 100644
--- a/libmm-glib/mm-modem-simple.h
+++ b/libmm-glib/mm-modem-simple.h
@@ -40,7 +40,7 @@ gchar *mm_modem_simple_dup_path (MMModemSimple *self);
#define MM_SIMPLE_PROPERTY_PIN "pin" /* string */
#define MM_SIMPLE_PROPERTY_OPERATOR_ID "operator-id" /* string */
-#define MM_SIMPLE_PROPERTY_ALLOWED_BANDS "allowed-bands" /* MMModemBand */
+#define MM_SIMPLE_PROPERTY_ALLOWED_BANDS "allowed-bands" /* GArray of MMModemBand */
#define MM_SIMPLE_PROPERTY_ALLOWED_MODES "allowed-modes" /* MMModemMode */
#define MM_SIMPLE_PROPERTY_PREFERRED_MODE "preferred-mode" /* MMModemMode */
#define MM_SIMPLE_PROPERTY_APN "apn" /* string */
diff --git a/libmm-glib/mm-modem.c b/libmm-glib/mm-modem.c
index cdba3929..e89173e7 100644
--- a/libmm-glib/mm-modem.c
+++ b/libmm-glib/mm-modem.c
@@ -656,38 +656,54 @@ mm_modem_get_preferred_mode (MMModem *self)
/**
* mm_modem_get_supported_bands:
* @self: A #MMModem.
+ * @bands: (out): Return location for the array of #MMModemBand values.
+ * @n_bands: (out): Return location for the number of values in @bands.
*
* Gets the list of radio frequency and technology bands supported by the #MMModem.
*
- * For POTS devices, only #MM_MODEM_BAND_ANY will be returned.
- *
- * Returns: A bitmask of #MMModemBand values.
+ * For POTS devices, only #MM_MODEM_BAND_ANY will be returned in @bands.
*/
-MMModemBand
-mm_modem_get_supported_bands (MMModem *self)
+void
+mm_modem_get_supported_bands (MMModem *self,
+ MMModemBand **bands,
+ guint *n_bands)
{
- g_return_val_if_fail (MM_GDBUS_IS_MODEM (self), MM_MODEM_MODE_NONE);
+ GArray *array;
- return (MMModemBand) mm_gdbus_modem_get_supported_bands (self);
+ g_return_if_fail (MM_GDBUS_IS_MODEM (self));
+ g_return_if_fail (bands != NULL);
+ g_return_if_fail (n_bands != NULL);
+
+ array = mm_common_bands_variant_to_garray (mm_gdbus_modem_get_supported_bands (self));
+ *n_bands = array->len;
+ *bands = (MMModemBand *)g_array_free (array, FALSE);
}
/**
* mm_modem_get_allowed_bands:
* @self: A #MMModem.
+ * @bands: (out): Return location for the array of #MMModemBand values.
+ * @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
* allowed to use when connecting to a network.
*
* For POTS devices, only the #MM_MODEM_BAND_ANY band is supported.
- *
- * Returns: A bitmask of #MMModemBand values.
*/
-MMModemBand
-mm_modem_get_allowed_bands (MMModem *self)
+void
+mm_modem_get_allowed_bands (MMModem *self,
+ MMModemBand **bands,
+ guint *n_bands)
{
- g_return_val_if_fail (MM_GDBUS_IS_MODEM (self), MM_MODEM_MODE_NONE);
+ GArray *array;
+
+ g_return_if_fail (MM_GDBUS_IS_MODEM (self));
+ g_return_if_fail (bands != NULL);
+ g_return_if_fail (n_bands != NULL);
- return (MMModemBand) mm_gdbus_modem_get_allowed_bands (self);
+ array = mm_common_bands_variant_to_garray (mm_gdbus_modem_get_allowed_bands (self));
+ *n_bands = array->len;
+ *bands = (MMModemBand *)g_array_free (array, FALSE);
}
/**
@@ -1533,7 +1549,8 @@ mm_modem_set_allowed_bands_finish (MMModem *self,
void
mm_modem_set_allowed_bands (MMModem *self,
- MMModemBand bands,
+ const MMModemBand *bands,
+ guint n_bands,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -1541,7 +1558,7 @@ mm_modem_set_allowed_bands (MMModem *self,
g_return_if_fail (MM_GDBUS_IS_MODEM (self));
mm_gdbus_modem_call_set_allowed_bands (self,
- bands,
+ mm_common_bands_array_to_variant (bands, n_bands),
cancellable,
callback,
user_data);
@@ -1549,16 +1566,18 @@ mm_modem_set_allowed_bands (MMModem *self,
gboolean
mm_modem_set_allowed_bands_sync (MMModem *self,
- MMModemBand bands,
+ const MMModemBand *bands,
+ guint n_bands,
GCancellable *cancellable,
GError **error)
{
g_return_val_if_fail (MM_GDBUS_IS_MODEM (self), FALSE);
- return mm_gdbus_modem_call_set_allowed_bands_sync (self,
- bands,
- cancellable,
- error);
+ return (mm_gdbus_modem_call_set_allowed_bands_sync (
+ self,
+ mm_common_bands_array_to_variant (bands, n_bands),
+ cancellable,
+ error));
}
static void
diff --git a/libmm-glib/mm-modem.h b/libmm-glib/mm-modem.h
index da0c2199..f8dced67 100644
--- a/libmm-glib/mm-modem.h
+++ b/libmm-glib/mm-modem.h
@@ -70,8 +70,12 @@ guint mm_modem_get_signal_quality (MMModem *self,
MMModemMode mm_modem_get_supported_modes (MMModem *self);
MMModemMode mm_modem_get_allowed_modes (MMModem *self);
MMModemMode mm_modem_get_preferred_mode (MMModem *self);
-MMModemBand mm_modem_get_supported_bands (MMModem *self);
-MMModemBand mm_modem_get_allowed_bands (MMModem *self);
+void mm_modem_get_supported_bands (MMModem *self,
+ MMModemBand **bands,
+ guint *n_bands);
+void mm_modem_get_allowed_bands (MMModem *self,
+ MMModemBand **bands,
+ guint *n_bands);
void mm_modem_enable (MMModem *self,
GCancellable *cancellable,
@@ -181,7 +185,8 @@ gboolean mm_modem_set_allowed_modes_sync (MMModem *self,
GError **error);
void mm_modem_set_allowed_bands (MMModem *self,
- MMModemBand bands,
+ const MMModemBand *bands,
+ guint n_bands,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
@@ -189,7 +194,8 @@ gboolean mm_modem_set_allowed_bands_finish (MMModem *self,
GAsyncResult *res,
GError **error);
gboolean mm_modem_set_allowed_bands_sync (MMModem *self,
- MMModemBand bands,
+ const MMModemBand *bands,
+ guint n_bands,
GCancellable *cancellable,
GError **error);
diff --git a/new/org.freedesktop.ModemManager1.Modem.Simple.xml b/new/org.freedesktop.ModemManager1.Modem.Simple.xml
index b44f2504..33c1cb77 100644
--- a/new/org.freedesktop.ModemManager1.Modem.Simple.xml
+++ b/new/org.freedesktop.ModemManager1.Modem.Simple.xml
@@ -54,9 +54,9 @@
</varlistentry>
<varlistentry><term><literal>"allowed-bands"</literal></term>
<listitem>
- Bitmask of <link linkend="MMModemBand">MMModemBand</link> values,
- to specify all the bands allowed in the modem, given as a 64bit
- unsigned integer value (signature <literal>"t"</literal>).
+ List of <link linkend="MMModemBand">MMModemBand</link> values,
+ to specify all the bands allowed in the modem, given as a list of
+ unsigned integer values (signature <literal>"au"</literal>).
</listitem>
</varlistentry>
<varlistentry><term><literal>"allowed-modes"</literal></term>
@@ -153,9 +153,9 @@
</varlistentry>
<varlistentry><term><literal>"bands"</literal></term>
<listitem>
- Bitmask of <link linkend="MMModemBand">MMModemBand</link> values,
- given only when registerd, as a 64bit
- unsigned integer value (signature <literal>"t"</literal>).
+ List of <link linkend="MMModemBand">MMModemBand</link> values,
+ given only when registered, as a list of
+ unsigned integer value (signature <literal>"au"</literal>).
</listitem>
</varlistentry>
<varlistentry><term><literal>"access-technology"</literal></term>
diff --git a/new/org.freedesktop.ModemManager1.Modem.xml b/new/org.freedesktop.ModemManager1.Modem.xml
index 93e02928..9335fe63 100644
--- a/new/org.freedesktop.ModemManager1.Modem.xml
+++ b/new/org.freedesktop.ModemManager1.Modem.xml
@@ -135,13 +135,13 @@
<!--
SetAllowedBands:
- @bands: Bitmask 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 all the bands allowed in the modem.
Set the radio frequency and technology bands the device is currently
allowed to use when connecting to a network.
-->
<method name="SetAllowedBands">
- <arg name="bands" type="t" direction="in" />
+ <arg name="bands" type="au" direction="in" />
</method>
<!--
@@ -392,7 +392,7 @@
<!--
SupportedBands:
- Bitmask of <link linkend="MMModemBand">MMModemBand</link> values,
+ List of <link linkend="MMModemBand">MMModemBand</link> values,
specifying the radio frequency and technology bands supported by the
device.
@@ -400,12 +400,12 @@
<link linkend="MM-MODEM-BAND-ANY:CAPS"><constant>MM_MODEM_BAND_ANY</constant></link>
mode will be returned.
-->
- <property name="SupportedBands" type="t" access="read" />
+ <property name="SupportedBands" type="au" access="read" />
<!--
AllowedBands:
- Bitmask 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
currently allowed to use when connecting to a network.
@@ -415,7 +415,7 @@
<link linkend="MM-MODEM-BAND-ANY:CAPS"><constant>MM_MODEM_BAND_ANY</constant></link>
mode is supported.
-->
- <property name="AllowedBands" type="t" access="read" />
+ <property name="AllowedBands" type="au" access="read" />
</interface>
</node>
diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c
index 3a3762bf..bb43c174 100644
--- a/src/mm-iface-modem.c
+++ b/src/mm-iface-modem.c
@@ -594,13 +594,48 @@ set_allowed_bands_ready (MMIfaceModem *self,
g_object_unref (simple);
}
+static gboolean
+validate_allowed_bands (GArray *bands_array,
+ GError **error)
+{
+ /* When the array has more than one element, there MUST NOT include ANY or
+ * UNKNOWN */
+ if (bands_array->len > 1) {
+ guint i;
+
+ for (i = 0; i < bands_array->len; i++) {
+ MMModemBand band;
+
+ band = g_array_index (bands_array, MMModemBand, i);
+ if (band == MM_MODEM_BAND_UNKNOWN ||
+ band == MM_MODEM_BAND_ANY) {
+ GEnumClass *enum_class;
+ GEnumValue *value;
+
+ enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_BAND));
+ value = g_enum_get_value (enum_class, band);
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_INVALID_ARGS,
+ "Wrong list of bands: "
+ "'%s' should have been the only element in the list",
+ value->value_nick);
+ g_type_class_unref (enum_class);
+ return FALSE;
+ }
+ }
+ }
+ return TRUE;
+}
+
void
mm_iface_modem_set_allowed_bands (MMIfaceModem *self,
- MMModemBand bands,
+ GArray *bands_array,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
+ GError *error = NULL;
/* If setting allowed bands is not implemented, report an error */
if (!MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands ||
@@ -614,12 +649,21 @@ mm_iface_modem_set_allowed_bands (MMIfaceModem *self,
return;
}
+ /* Validate input list of bands */
+ if (!validate_allowed_bands (bands_array, &error)) {
+ g_simple_async_report_take_gerror_in_idle (G_OBJECT (self),
+ callback,
+ user_data,
+ error);
+ return;
+ }
+
result = g_simple_async_result_new (G_OBJECT (self),
callback,
user_data,
mm_iface_modem_set_allowed_bands);
MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands (self,
- bands,
+ bands_array,
(GAsyncReadyCallback)set_allowed_bands_ready,
result);
}
@@ -644,7 +688,7 @@ handle_set_allowed_bands_ready (MMIfaceModem *self,
static gboolean
handle_set_allowed_bands (MmGdbusModem *skeleton,
GDBusMethodInvocation *invocation,
- guint64 bands,
+ GVariant *bands_variant,
MMIfaceModem *self)
{
MMModemState modem_state = MM_MODEM_STATE_UNKNOWN;
@@ -671,14 +715,19 @@ handle_set_allowed_bands (MmGdbusModem *skeleton,
case MM_MODEM_STATE_REGISTERED:
case MM_MODEM_STATE_DISCONNECTING:
case MM_MODEM_STATE_CONNECTING:
- case MM_MODEM_STATE_CONNECTED:
+ case MM_MODEM_STATE_CONNECTED: {
+ GArray *bands_array;
+
+ bands_array = mm_common_bands_variant_to_garray (bands_variant);
mm_iface_modem_set_allowed_bands (self,
- bands,
+ bands_array,
(GAsyncReadyCallback)handle_set_allowed_bands_ready,
dbus_call_context_new (skeleton,
invocation,
self));
+ g_array_unref (bands_array);
break;
+ }
}
return TRUE;
@@ -1789,7 +1838,34 @@ STR_REPLY_READY_FN (revision, "Revision")
STR_REPLY_READY_FN (equipment_identifier, "Equipment Identifier")
STR_REPLY_READY_FN (device_identifier, "Device Identifier")
UINT_REPLY_READY_FN (supported_modes, "Supported Modes")
-UINT_REPLY_READY_FN (supported_bands, "Supported Bands")
+
+static void
+load_supported_bands_ready (MMIfaceModem *self,
+ GAsyncResult *res,
+ InitializationContext *ctx)
+{
+ GError *error = NULL;
+ GArray *bands_array;
+
+ bands_array = MM_IFACE_MODEM_GET_INTERFACE (self)->load_supported_bands_finish (self, res, &error);
+
+ /* We have the property in the interface bound to the property in the
+ * skeleton. */
+ g_object_set (self,
+ MM_IFACE_MODEM_CURRENT_CAPABILITIES,
+ mm_common_bands_garray_to_variant (bands_array),
+ NULL);
+ g_array_unref (bands_array);
+
+ if (error) {
+ mm_warn ("couldn't load Supported Bands: '%s'", error->message);
+ g_error_free (error);
+ }
+
+ /* Go on to next step */
+ ctx->step++;
+ interface_initialization_step (ctx);
+}
static void
load_unlock_required_ready (MMIfaceModem *self,
@@ -2198,6 +2274,28 @@ mm_iface_modem_initialize_finish (MMIfaceModem *self,
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error);
}
+static GVariant *
+build_bands_unknown (void)
+{
+ GVariantBuilder builder;
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("au"));
+ g_variant_builder_add_value (&builder,
+ g_variant_new_uint32 (MM_MODEM_BAND_UNKNOWN));
+ return g_variant_builder_end (&builder);
+}
+
+static GVariant *
+build_bands_any (void)
+{
+ GVariantBuilder builder;
+
+ g_variant_builder_init (&builder, G_VARIANT_TYPE ("au"));
+ g_variant_builder_add_value (&builder,
+ g_variant_new_uint32 (MM_MODEM_BAND_ANY));
+ return g_variant_builder_end (&builder);
+}
+
void
mm_iface_modem_initialize (MMIfaceModem *self,
MMAtSerialPort *port,
@@ -2235,8 +2333,8 @@ mm_iface_modem_initialize (MMIfaceModem *self,
mm_gdbus_modem_set_supported_modes (skeleton, MM_MODEM_MODE_NONE);
mm_gdbus_modem_set_allowed_modes (skeleton, MM_MODEM_MODE_ANY);
mm_gdbus_modem_set_preferred_mode (skeleton, MM_MODEM_MODE_NONE);
- mm_gdbus_modem_set_supported_bands (skeleton, MM_MODEM_BAND_UNKNOWN);
- mm_gdbus_modem_set_allowed_bands (skeleton, MM_MODEM_BAND_ANY);
+ mm_gdbus_modem_set_supported_bands (skeleton, build_bands_unknown ());
+ mm_gdbus_modem_set_allowed_bands (skeleton, build_bands_any ());
/* Bind our State property */
g_object_bind_property (self, MM_IFACE_MODEM_STATE,
diff --git a/src/mm-iface-modem.h b/src/mm-iface-modem.h
index 5195497e..1afd166c 100644
--- a/src/mm-iface-modem.h
+++ b/src/mm-iface-modem.h
@@ -123,9 +123,9 @@ struct _MMIfaceModem {
void (*load_supported_bands) (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data);
- MMModemBand (*load_supported_bands_finish) (MMIfaceModem *self,
- GAsyncResult *res,
- GError **error);
+ GArray * (*load_supported_bands_finish) (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error);
/* Loading of the SignalQuality property */
void (*load_signal_quality) (MMIfaceModem *self,
@@ -155,7 +155,7 @@ struct _MMIfaceModem {
/* Asynchronous allowed band setting operation */
void (*set_allowed_bands) (MMIfaceModem *self,
- MMModemBand bands,
+ GArray *bands_array,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean (*set_allowed_bands_finish) (MMIfaceModem *self,
@@ -316,7 +316,7 @@ gboolean mm_iface_modem_set_allowed_modes_finish (MMIfaceModem *self,
/* Allow setting allowed bands */
void mm_iface_modem_set_allowed_bands (MMIfaceModem *self,
- MMModemBand bands,
+ GArray *bands_array,
GAsyncReadyCallback callback,
gpointer user_data);
gboolean mm_iface_modem_set_allowed_bands_finish (MMIfaceModem *self,