libmm-common: handle exact mask matches when building capabilities string

This commit is contained in:
Aleksander Morgado
2011-12-26 21:26:23 +01:00
parent 9868d757c7
commit d81d1d9d6a

View File

@@ -23,12 +23,19 @@ mm_common_get_capabilities_string (MMModemCapability caps)
{ {
GFlagsClass *flags_class; GFlagsClass *flags_class;
GString *str; GString *str;
MMModemCapability it;
gboolean first = TRUE;
str = g_string_new (""); str = g_string_new ("");
flags_class = G_FLAGS_CLASS (g_type_class_ref (MM_TYPE_MODEM_CAPABILITY)); flags_class = G_FLAGS_CLASS (g_type_class_ref (MM_TYPE_MODEM_CAPABILITY));
if (caps == MM_MODEM_CAPABILITY_NONE) {
GFlagsValue *value;
value = g_flags_get_first_value (flags_class, caps);
g_string_append (str, value->value_nick);
} else {
MMModemCapability it;
gboolean first = TRUE;
for (it = MM_MODEM_CAPABILITY_POTS; /* first */ for (it = MM_MODEM_CAPABILITY_POTS; /* first */
it <= MM_MODEM_CAPABILITY_LTE_ADVANCED; /* last */ it <= MM_MODEM_CAPABILITY_LTE_ADVANCED; /* last */
it = it << 1) { it = it << 1) {
@@ -44,6 +51,7 @@ mm_common_get_capabilities_string (MMModemCapability caps)
first = FALSE; first = FALSE;
} }
} }
}
g_type_class_unref (flags_class); g_type_class_unref (flags_class);
return g_string_free (str, FALSE); return g_string_free (str, FALSE);