aboutsummaryrefslogtreecommitdiff
path: root/libmm-common/mm-common-helpers.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-12-26 21:29:01 +0100
committerAleksander Morgado <aleksander@lanedo.com>2012-03-15 14:14:37 +0100
commit6cfccb14526a6b0fa27f680cb76d7bef165cd169 (patch)
tree609752696602dbf300e137768f5af7ec92279505 /libmm-common/mm-common-helpers.c
parentaa3d98d0ff6ff75cdeb8106b7d9e1108eef4994e (diff)
libmm-common,libmm-glib: new modes string builder
Diffstat (limited to 'libmm-common/mm-common-helpers.c')
-rw-r--r--libmm-common/mm-common-helpers.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/libmm-common/mm-common-helpers.c b/libmm-common/mm-common-helpers.c
index 93509f11..48a535f2 100644
--- a/libmm-common/mm-common-helpers.c
+++ b/libmm-common/mm-common-helpers.c
@@ -97,6 +97,46 @@ mm_common_get_access_technologies_string (MMModemAccessTechnology access_tech)
}
gchar *
+mm_common_get_modes_string (MMModemMode mode)
+{
+ GFlagsClass *flags_class;
+ GString *str;
+
+ str = g_string_new ("");
+ flags_class = G_FLAGS_CLASS (g_type_class_ref (MM_TYPE_MODEM_MODE));
+
+ if (mode == MM_MODEM_MODE_NONE ||
+ mode == MM_MODEM_MODE_ANY) {
+ GFlagsValue *value;
+
+ value = g_flags_get_first_value (flags_class, mode);
+ g_string_append (str, value->value_nick);
+ } else {
+ MMModemMode it;
+ gboolean first = TRUE;
+
+ for (it = MM_MODEM_MODE_1G; /* first */
+ it <= MM_MODEM_MODE_4G; /* last */
+ it = it << 1) {
+ if (mode & it) {
+ GFlagsValue *value;
+
+ value = g_flags_get_first_value (flags_class, it);
+ g_string_append_printf (str, "%s%s",
+ first ? "" : ", ",
+ value->value_nick);
+
+ if (first)
+ first = FALSE;
+ }
+ }
+ }
+ g_type_class_unref (flags_class);
+
+ return g_string_free (str, FALSE);
+}
+
+gchar *
mm_common_get_bands_string (const MMModemBand *bands,
guint n_bands)
{