libmm-common, libmm-glib: new bands string builder
This commit is contained in:
@@ -88,6 +88,38 @@ mm_common_get_access_technologies_string (MMModemAccessTechnology access_tech)
|
||||
return g_string_free (str, FALSE);
|
||||
}
|
||||
|
||||
gchar *
|
||||
mm_common_get_bands_string (const MMModemBand *bands,
|
||||
guint n_bands)
|
||||
{
|
||||
GEnumClass *enum_class;
|
||||
gboolean first = TRUE;
|
||||
GString *str;
|
||||
guint i;
|
||||
|
||||
str = g_string_new ("");
|
||||
if (n_bands == 0) {
|
||||
g_string_append (str, "none");
|
||||
return g_string_free (str, FALSE);
|
||||
}
|
||||
|
||||
enum_class = G_ENUM_CLASS (g_type_class_ref (MM_TYPE_MODEM_BAND));
|
||||
for (i = 0; i < n_bands; i++) {
|
||||
GEnumValue *value;
|
||||
|
||||
value = g_enum_get_value (enum_class, bands[i]);
|
||||
g_string_append_printf (str, "%s%s",
|
||||
first ? "" : ", ",
|
||||
value->value_nick);
|
||||
|
||||
if (first)
|
||||
first = FALSE;
|
||||
}
|
||||
g_type_class_unref (enum_class);
|
||||
|
||||
return g_string_free (str, FALSE);
|
||||
}
|
||||
|
||||
GArray *
|
||||
mm_common_bands_variant_to_garray (GVariant *variant)
|
||||
{
|
||||
|
@@ -21,6 +21,8 @@
|
||||
|
||||
gchar *mm_common_get_capabilities_string (MMModemCapability caps);
|
||||
gchar *mm_common_get_access_technologies_string (MMModemAccessTechnology access_tech);
|
||||
gchar *mm_common_get_bands_string (const MMModemBand *bands,
|
||||
guint n_bands);
|
||||
|
||||
GArray *mm_common_bands_variant_to_garray (GVariant *variant);
|
||||
GVariant *mm_common_bands_array_to_variant (const MMModemBand *bands,
|
||||
|
@@ -1698,3 +1698,19 @@ mm_modem_get_access_technologies_string (MMModemAccessTechnology access_tech)
|
||||
{
|
||||
return mm_common_get_access_technologies_string (access_tech);
|
||||
}
|
||||
|
||||
/**
|
||||
* mm_modem_get_bands_string:
|
||||
* @bands: List of #MMModemBand values.
|
||||
* @n_bands: Number of values in @bands.
|
||||
*
|
||||
* Build a string with a list of bands.
|
||||
*
|
||||
* Returns: (transfer full): A string specifying the band names given in @bands. The returned value should be freed with g_free().
|
||||
*/
|
||||
gchar *
|
||||
mm_modem_get_bands_string (const MMModemBand *bands,
|
||||
guint n_bands)
|
||||
{
|
||||
return mm_common_get_bands_string (bands, n_bands);
|
||||
}
|
||||
|
@@ -212,6 +212,8 @@ MMSim *mm_modem_get_sim_sync (MMModem *self,
|
||||
|
||||
gchar *mm_modem_get_capabilities_string (MMModemCapability caps);
|
||||
gchar *mm_modem_get_access_technologies_string (MMModemAccessTechnology access_tech);
|
||||
gchar *mm_modem_get_bands_string (const MMModemBand *bands,
|
||||
guint n_bands);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
Reference in New Issue
Block a user