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".
This commit is contained in:
Aleksander Morgado
2011-12-26 18:50:16 +01:00
parent a142a209ec
commit 9d7e3de4cd
11 changed files with 258 additions and 87 deletions

View File

@@ -147,7 +147,7 @@ connect_ready (MMModemSimple *modem_simple,
typedef struct { typedef struct {
gchar *pin; gchar *pin;
gchar *operator_id; gchar *operator_id;
MMModemBand allowed_bands; GArray *allowed_bands;
MMModemMode allowed_modes; MMModemMode allowed_modes;
MMModemMode preferred_mode; MMModemMode preferred_mode;
gchar *apn; gchar *apn;
@@ -171,6 +171,7 @@ string_get_boolean (const gchar *value)
static void static void
simple_connect_properties_shutdown (SimpleConnectProperties *properties) simple_connect_properties_shutdown (SimpleConnectProperties *properties)
{ {
g_array_unref (properties->allowed_bands);
g_free (properties->pin); g_free (properties->pin);
g_free (properties->operator_id); g_free (properties->operator_id);
g_free (properties->apn); g_free (properties->apn);
@@ -190,9 +191,10 @@ simple_connect_properties_init (const gchar *input,
/* Some defaults... */ /* Some defaults... */
memset (properties, 0, sizeof (*properties)); memset (properties, 0, sizeof (*properties));
properties->allow_roaming = TRUE; properties->allow_roaming = TRUE;
properties->allowed_bands = MM_MODEM_BAND_ANY;
properties->allowed_modes = MM_MODEM_MODE_ANY; properties->allowed_modes = MM_MODEM_MODE_ANY;
properties->preferred_mode = MM_MODEM_MODE_NONE; 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: /* Expecting input as:
* key1=string,key2=true,key3=false... * key1=string,key2=true,key3=false...

View File

@@ -236,45 +236,45 @@ typedef enum { /*< underscore_name=mm_modem_mode >*/
* the device and the radio bands the device is allowed to use when * the device and the radio bands the device is allowed to use when
* connecting to a mobile network. * connecting to a mobile network.
*/ */
typedef enum { /*< skip >*/ typedef enum { /*< underscore_name=mm_modem_band >*/
MM_MODEM_BAND_UNKNOWN = 0, MM_MODEM_BAND_UNKNOWN = 0,
/* GSM/UMTS/3GPP bands */ /* GSM/UMTS/3GPP bands */
MM_MODEM_BAND_EGSM = 1 << 0, MM_MODEM_BAND_EGSM = 1,
MM_MODEM_BAND_DCS = 1 << 1, MM_MODEM_BAND_DCS = 2,
MM_MODEM_BAND_PCS = 1 << 2, MM_MODEM_BAND_PCS = 3,
MM_MODEM_BAND_G850 = 1 << 3, MM_MODEM_BAND_G850 = 4,
MM_MODEM_BAND_U2100 = 1 << 4, MM_MODEM_BAND_U2100 = 5,
MM_MODEM_BAND_U1800 = 1 << 5, MM_MODEM_BAND_U1800 = 6,
MM_MODEM_BAND_U17IV = 1 << 6, MM_MODEM_BAND_U17IV = 7,
MM_MODEM_BAND_U800 = 1 << 7, MM_MODEM_BAND_U800 = 8,
MM_MODEM_BAND_U850 = 1 << 8, MM_MODEM_BAND_U850 = 9,
MM_MODEM_BAND_U900 = 1 << 9, MM_MODEM_BAND_U900 = 10,
MM_MODEM_BAND_U17IX = 1 << 10, MM_MODEM_BAND_U17IX = 11,
MM_MODEM_BAND_U1900 = 1 << 11, MM_MODEM_BAND_U1900 = 12,
MM_MODEM_BAND_U2600 = 1 << 12, MM_MODEM_BAND_U2600 = 13,
/* CDMA Band Classes (see 3GPP2 C.S0057-C) */ /* CDMA Band Classes (see 3GPP2 C.S0057-C) */
MM_MODEM_BAND_CDMA_BC0_CELLULAR_800 = 1ULL << 32, MM_MODEM_BAND_CDMA_BC0_CELLULAR_800 = 128,
MM_MODEM_BAND_CDMA_BC1_PCS_1900 = 1ULL << 33, MM_MODEM_BAND_CDMA_BC1_PCS_1900 = 129,
MM_MODEM_BAND_CDMA_BC2_TACS = 1ULL << 34, MM_MODEM_BAND_CDMA_BC2_TACS = 130,
MM_MODEM_BAND_CDMA_BC3_JTACS = 1ULL << 35, MM_MODEM_BAND_CDMA_BC3_JTACS = 131,
MM_MODEM_BAND_CDMA_BC4_KOREAN_PCS = 1ULL << 36, MM_MODEM_BAND_CDMA_BC4_KOREAN_PCS = 132,
MM_MODEM_BAND_CDMA_BC5_NMT450 = 1ULL << 37, MM_MODEM_BAND_CDMA_BC5_NMT450 = 134,
MM_MODEM_BAND_CDMA_BC6_IMT2000 = 1ULL << 38, MM_MODEM_BAND_CDMA_BC6_IMT2000 = 135,
MM_MODEM_BAND_CDMA_BC7_CELLULAR_700 = 1ULL << 49, MM_MODEM_BAND_CDMA_BC7_CELLULAR_700 = 136,
MM_MODEM_BAND_CDMA_BC8_1800 = 1ULL << 40, MM_MODEM_BAND_CDMA_BC8_1800 = 137,
MM_MODEM_BAND_CDMA_BC9_900 = 1ULL << 41, MM_MODEM_BAND_CDMA_BC9_900 = 138,
MM_MODEM_BAND_CDMA_BC10_SECONDARY_800 = 1ULL << 42, MM_MODEM_BAND_CDMA_BC10_SECONDARY_800 = 139,
MM_MODEM_BAND_CDMA_BC11_PAMR_400 = 1ULL << 43, MM_MODEM_BAND_CDMA_BC11_PAMR_400 = 140,
MM_MODEM_BAND_CDMA_BC12_PAMR_800 = 1ULL << 44, MM_MODEM_BAND_CDMA_BC12_PAMR_800 = 141,
MM_MODEM_BAND_CDMA_BC13_IMT2000_2500 = 1ULL << 45, MM_MODEM_BAND_CDMA_BC13_IMT2000_2500 = 142,
MM_MODEM_BAND_CDMA_BC14_PCS2_1900 = 1ULL << 46, MM_MODEM_BAND_CDMA_BC14_PCS2_1900 = 143,
MM_MODEM_BAND_CDMA_BC15_AWS = 1ULL << 47, MM_MODEM_BAND_CDMA_BC15_AWS = 144,
MM_MODEM_BAND_CDMA_BC16_US_2500 = 1ULL << 48, MM_MODEM_BAND_CDMA_BC16_US_2500 = 145,
MM_MODEM_BAND_CDMA_BC17_US_FLO_2500 = 1ULL << 49, MM_MODEM_BAND_CDMA_BC17_US_FLO_2500 = 146,
MM_MODEM_BAND_CDMA_BC18_US_PS_700 = 1ULL << 50, MM_MODEM_BAND_CDMA_BC18_US_PS_700 = 147,
MM_MODEM_BAND_CDMA_BC19_US_LOWER_700 = 1ULL << 51, MM_MODEM_BAND_CDMA_BC19_US_LOWER_700 = 148,
/* All/Any */ /* All/Any */
MM_MODEM_BAND_ANY = 0xFFFFFFFFFFFFFFFF MM_MODEM_BAND_ANY = 256
} MMModemBand; } MMModemBand;
/** /**

View File

@@ -87,3 +87,44 @@ mm_common_get_access_technologies_string (MMModemAccessTechnology access_tech)
return g_string_free (str, FALSE); 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);
}

View File

@@ -22,4 +22,9 @@
gchar *mm_common_get_capabilities_string (MMModemCapability caps); gchar *mm_common_get_capabilities_string (MMModemCapability caps);
gchar *mm_common_get_access_technologies_string (MMModemAccessTechnology access_tech); 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 */ #endif /* MM_COMMON_HELPERS_H */

View File

@@ -40,7 +40,7 @@ gchar *mm_modem_simple_dup_path (MMModemSimple *self);
#define MM_SIMPLE_PROPERTY_PIN "pin" /* string */ #define MM_SIMPLE_PROPERTY_PIN "pin" /* string */
#define MM_SIMPLE_PROPERTY_OPERATOR_ID "operator-id" /* 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_ALLOWED_MODES "allowed-modes" /* MMModemMode */
#define MM_SIMPLE_PROPERTY_PREFERRED_MODE "preferred-mode" /* MMModemMode */ #define MM_SIMPLE_PROPERTY_PREFERRED_MODE "preferred-mode" /* MMModemMode */
#define MM_SIMPLE_PROPERTY_APN "apn" /* string */ #define MM_SIMPLE_PROPERTY_APN "apn" /* string */

View File

@@ -656,38 +656,54 @@ mm_modem_get_preferred_mode (MMModem *self)
/** /**
* mm_modem_get_supported_bands: * mm_modem_get_supported_bands:
* @self: A #MMModem. * @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. * Gets the list of radio frequency and technology bands supported by the #MMModem.
* *
* For POTS devices, only #MM_MODEM_BAND_ANY will be returned. * For POTS devices, only #MM_MODEM_BAND_ANY will be returned in @bands.
*
* Returns: A bitmask of #MMModemBand values.
*/ */
MMModemBand void
mm_modem_get_supported_bands (MMModem *self) 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: * mm_modem_get_allowed_bands:
* @self: A #MMModem. * @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 * Gets the list of radio frequency and technology bands the #MMModem is currently
* allowed to use when connecting to a network. * allowed to use 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.
*
* Returns: A bitmask of #MMModemBand values.
*/ */
MMModemBand void
mm_modem_get_allowed_bands (MMModem *self) 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;
return (MMModemBand) mm_gdbus_modem_get_allowed_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_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 void
mm_modem_set_allowed_bands (MMModem *self, mm_modem_set_allowed_bands (MMModem *self,
MMModemBand bands, const MMModemBand *bands,
guint n_bands,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
@@ -1541,7 +1558,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_allowed_bands (self,
bands, mm_common_bands_array_to_variant (bands, n_bands),
cancellable, cancellable,
callback, callback,
user_data); user_data);
@@ -1549,16 +1566,18 @@ mm_modem_set_allowed_bands (MMModem *self,
gboolean gboolean
mm_modem_set_allowed_bands_sync (MMModem *self, mm_modem_set_allowed_bands_sync (MMModem *self,
MMModemBand bands, const MMModemBand *bands,
guint n_bands,
GCancellable *cancellable, GCancellable *cancellable,
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_sync (self, return (mm_gdbus_modem_call_set_allowed_bands_sync (
bands, self,
cancellable, mm_common_bands_array_to_variant (bands, n_bands),
error); cancellable,
error));
} }
static void static void

View File

@@ -70,8 +70,12 @@ guint mm_modem_get_signal_quality (MMModem *self,
MMModemMode mm_modem_get_supported_modes (MMModem *self); MMModemMode mm_modem_get_supported_modes (MMModem *self);
MMModemMode mm_modem_get_allowed_modes (MMModem *self); MMModemMode mm_modem_get_allowed_modes (MMModem *self);
MMModemMode mm_modem_get_preferred_mode (MMModem *self); MMModemMode mm_modem_get_preferred_mode (MMModem *self);
MMModemBand mm_modem_get_supported_bands (MMModem *self); void mm_modem_get_supported_bands (MMModem *self,
MMModemBand mm_modem_get_allowed_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, void mm_modem_enable (MMModem *self,
GCancellable *cancellable, GCancellable *cancellable,
@@ -181,7 +185,8 @@ gboolean mm_modem_set_allowed_modes_sync (MMModem *self,
GError **error); GError **error);
void mm_modem_set_allowed_bands (MMModem *self, void mm_modem_set_allowed_bands (MMModem *self,
MMModemBand bands, const MMModemBand *bands,
guint n_bands,
GCancellable *cancellable, GCancellable *cancellable,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
@@ -189,7 +194,8 @@ gboolean mm_modem_set_allowed_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_allowed_bands_sync (MMModem *self,
MMModemBand bands, const MMModemBand *bands,
guint n_bands,
GCancellable *cancellable, GCancellable *cancellable,
GError **error); GError **error);

View File

@@ -54,9 +54,9 @@
</varlistentry> </varlistentry>
<varlistentry><term><literal>"allowed-bands"</literal></term> <varlistentry><term><literal>"allowed-bands"</literal></term>
<listitem> <listitem>
Bitmask 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 64bit to specify all the bands allowed in the modem, given as a list of
unsigned integer value (signature <literal>"t"</literal>). unsigned integer values (signature <literal>"au"</literal>).
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry><term><literal>"allowed-modes"</literal></term> <varlistentry><term><literal>"allowed-modes"</literal></term>
@@ -153,9 +153,9 @@
</varlistentry> </varlistentry>
<varlistentry><term><literal>"bands"</literal></term> <varlistentry><term><literal>"bands"</literal></term>
<listitem> <listitem>
Bitmask of <link linkend="MMModemBand">MMModemBand</link> values, List of <link linkend="MMModemBand">MMModemBand</link> values,
given only when registerd, as a 64bit given only when registered, as a list of
unsigned integer value (signature <literal>"t"</literal>). unsigned integer value (signature <literal>"au"</literal>).
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry><term><literal>"access-technology"</literal></term> <varlistentry><term><literal>"access-technology"</literal></term>

View File

@@ -135,13 +135,13 @@
<!-- <!--
SetAllowedBands: 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 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="SetAllowedBands">
<arg name="bands" type="t" direction="in" /> <arg name="bands" type="au" direction="in" />
</method> </method>
<!-- <!--
@@ -392,7 +392,7 @@
<!-- <!--
SupportedBands: 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 specifying the radio frequency and technology bands supported by the
device. device.
@@ -400,12 +400,12 @@
<link linkend="MM-MODEM-BAND-ANY:CAPS"><constant>MM_MODEM_BAND_ANY</constant></link> <link linkend="MM-MODEM-BAND-ANY:CAPS"><constant>MM_MODEM_BAND_ANY</constant></link>
mode will be returned. mode will be returned.
--> -->
<property name="SupportedBands" type="t" access="read" /> <property name="SupportedBands" type="au" access="read" />
<!-- <!--
AllowedBands: 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 specifying the radio frequency and technology bands the device is
currently allowed to use when connecting to a network. 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> <link linkend="MM-MODEM-BAND-ANY:CAPS"><constant>MM_MODEM_BAND_ANY</constant></link>
mode is supported. mode is supported.
--> -->
<property name="AllowedBands" type="t" access="read" /> <property name="AllowedBands" type="au" access="read" />
</interface> </interface>
</node> </node>

View File

@@ -594,13 +594,48 @@ set_allowed_bands_ready (MMIfaceModem *self,
g_object_unref (simple); 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 void
mm_iface_modem_set_allowed_bands (MMIfaceModem *self, mm_iface_modem_set_allowed_bands (MMIfaceModem *self,
MMModemBand bands, GArray *bands_array,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data) gpointer user_data)
{ {
GSimpleAsyncResult *result; GSimpleAsyncResult *result;
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_allowed_bands ||
@@ -614,12 +649,21 @@ mm_iface_modem_set_allowed_bands (MMIfaceModem *self,
return; 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), 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_allowed_bands);
MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands (self, MM_IFACE_MODEM_GET_INTERFACE (self)->set_allowed_bands (self,
bands, bands_array,
(GAsyncReadyCallback)set_allowed_bands_ready, (GAsyncReadyCallback)set_allowed_bands_ready,
result); result);
} }
@@ -644,7 +688,7 @@ handle_set_allowed_bands_ready (MMIfaceModem *self,
static gboolean static gboolean
handle_set_allowed_bands (MmGdbusModem *skeleton, handle_set_allowed_bands (MmGdbusModem *skeleton,
GDBusMethodInvocation *invocation, GDBusMethodInvocation *invocation,
guint64 bands, GVariant *bands_variant,
MMIfaceModem *self) MMIfaceModem *self)
{ {
MMModemState modem_state = MM_MODEM_STATE_UNKNOWN; 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_REGISTERED:
case MM_MODEM_STATE_DISCONNECTING: case MM_MODEM_STATE_DISCONNECTING:
case MM_MODEM_STATE_CONNECTING: 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, mm_iface_modem_set_allowed_bands (self,
bands, bands_array,
(GAsyncReadyCallback)handle_set_allowed_bands_ready, (GAsyncReadyCallback)handle_set_allowed_bands_ready,
dbus_call_context_new (skeleton, dbus_call_context_new (skeleton,
invocation, invocation,
self)); self));
g_array_unref (bands_array);
break; break;
}
} }
return TRUE; return TRUE;
@@ -1789,7 +1838,34 @@ STR_REPLY_READY_FN (revision, "Revision")
STR_REPLY_READY_FN (equipment_identifier, "Equipment Identifier") STR_REPLY_READY_FN (equipment_identifier, "Equipment Identifier")
STR_REPLY_READY_FN (device_identifier, "Device Identifier") STR_REPLY_READY_FN (device_identifier, "Device Identifier")
UINT_REPLY_READY_FN (supported_modes, "Supported Modes") 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 static void
load_unlock_required_ready (MMIfaceModem *self, 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); 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 void
mm_iface_modem_initialize (MMIfaceModem *self, mm_iface_modem_initialize (MMIfaceModem *self,
MMAtSerialPort *port, 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_supported_modes (skeleton, MM_MODEM_MODE_NONE);
mm_gdbus_modem_set_allowed_modes (skeleton, MM_MODEM_MODE_ANY); 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_preferred_mode (skeleton, MM_MODEM_MODE_NONE);
mm_gdbus_modem_set_supported_bands (skeleton, MM_MODEM_BAND_UNKNOWN); mm_gdbus_modem_set_supported_bands (skeleton, build_bands_unknown ());
mm_gdbus_modem_set_allowed_bands (skeleton, MM_MODEM_BAND_ANY); mm_gdbus_modem_set_allowed_bands (skeleton, build_bands_any ());
/* 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

@@ -123,9 +123,9 @@ struct _MMIfaceModem {
void (*load_supported_bands) (MMIfaceModem *self, void (*load_supported_bands) (MMIfaceModem *self,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
MMModemBand (*load_supported_bands_finish) (MMIfaceModem *self, GArray * (*load_supported_bands_finish) (MMIfaceModem *self,
GAsyncResult *res, GAsyncResult *res,
GError **error); GError **error);
/* Loading of the SignalQuality property */ /* Loading of the SignalQuality property */
void (*load_signal_quality) (MMIfaceModem *self, void (*load_signal_quality) (MMIfaceModem *self,
@@ -155,7 +155,7 @@ struct _MMIfaceModem {
/* Asynchronous allowed band setting operation */ /* Asynchronous allowed band setting operation */
void (*set_allowed_bands) (MMIfaceModem *self, void (*set_allowed_bands) (MMIfaceModem *self,
MMModemBand bands, GArray *bands_array,
GAsyncReadyCallback callback, GAsyncReadyCallback callback,
gpointer user_data); gpointer user_data);
gboolean (*set_allowed_bands_finish) (MMIfaceModem *self, 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 */ /* Allow setting allowed bands */
void mm_iface_modem_set_allowed_bands (MMIfaceModem *self, void mm_iface_modem_set_allowed_bands (MMIfaceModem *self,
MMModemBand bands, 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_allowed_bands_finish (MMIfaceModem *self,