aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libmm-common/Makefile.am4
-rw-r--r--libmm-common/mm-common-helpers.c50
-rw-r--r--libmm-common/mm-common-helpers.h24
-rw-r--r--src/mm-broadband-modem.c34
4 files changed, 79 insertions, 33 deletions
diff --git a/libmm-common/Makefile.am b/libmm-common/Makefile.am
index 9a78853d..56e059a5 100644
--- a/libmm-common/Makefile.am
+++ b/libmm-common/Makefile.am
@@ -143,7 +143,9 @@ $(mm_gdbus_bearer_generated): $(top_srcdir)/new/org.freedesktop.ModemManager1.Be
libmm_common_la_SOURCES = \
$(GENERATED_H) \
$(GENERATED_C) \
- mm-errors-quarks.c
+ mm-errors-quarks.c \
+ mm-common-helpers.h \
+ mm-common-helpers.c
libmm_common_la_CPPFLAGS = \
$(MM_CFLAGS) \
diff --git a/libmm-common/mm-common-helpers.c b/libmm-common/mm-common-helpers.c
new file mode 100644
index 00000000..d99f983c
--- /dev/null
+++ b/libmm-common/mm-common-helpers.c
@@ -0,0 +1,50 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2011 - Google, Inc.
+ */
+
+#include <gio/gio.h>
+
+#include "mm-enums-types.h"
+#include "mm-common-helpers.h"
+
+gchar *
+mm_common_get_capabilities_string (MMModemCapability caps)
+{
+ GFlagsClass *flags_class;
+ GString *str;
+ MMModemCapability it;
+ gboolean first = TRUE;
+
+ str = g_string_new ("");
+ flags_class = G_FLAGS_CLASS (g_type_class_ref (MM_TYPE_MODEM_CAPABILITY));
+
+ for (it = MM_MODEM_CAPABILITY_POTS; /* first */
+ it <= MM_MODEM_CAPABILITY_LTE_ADVANCED; /* last */
+ it = it << 1) {
+ if (caps & 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);
+}
diff --git a/libmm-common/mm-common-helpers.h b/libmm-common/mm-common-helpers.h
new file mode 100644
index 00000000..3f894d87
--- /dev/null
+++ b/libmm-common/mm-common-helpers.h
@@ -0,0 +1,24 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details:
+ *
+ * Copyright (C) 2011 - Google, Inc.
+ */
+
+#include <glib.h>
+#include <ModemManager-enums.h>
+
+#ifndef MM_COMMON_HELPERS_H
+#define MM_COMMON_HELPERS_H
+
+gchar *mm_common_get_capabilities_string (MMModemCapability caps);
+
+#endif /* MM_COMMON_HELPERS_H */
diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c
index 72b085e4..fc006015 100644
--- a/src/mm-broadband-modem.c
+++ b/src/mm-broadband-modem.c
@@ -24,6 +24,7 @@
#include <ModemManager.h>
#include <mm-errors-types.h>
#include <mm-enums-types.h>
+#include <mm-common-helpers.h>
#include "mm-base-modem-at.h"
#include "mm-broadband-modem.h"
@@ -357,37 +358,6 @@ parse_caps_cgmm (MMBaseModem *self,
return FALSE;
}
-static gchar *
-create_capabilities_string (MMModemCapability caps)
-{
- GFlagsClass *flags_class;
- GString *str;
- MMModemCapability it;
- gboolean first = TRUE;
-
- str = g_string_new ("");
- flags_class = G_FLAGS_CLASS (g_type_class_ref (MM_TYPE_MODEM_CAPABILITY));
-
- for (it = MM_MODEM_CAPABILITY_POTS; /* first */
- it <= MM_MODEM_CAPABILITY_LTE_ADVANCED; /* last */
- it = it << 1) {
- if (caps & 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);
-}
-
static MMModemCapability
load_current_capabilities_finish (MMIfaceModem *self,
GAsyncResult *res,
@@ -402,7 +372,7 @@ load_current_capabilities_finish (MMIfaceModem *self,
return MM_MODEM_CAPABILITY_NONE;
caps = (MMModemCapability)g_variant_get_uint32 (result);
- caps_str = create_capabilities_string (caps);
+ caps_str = mm_common_get_capabilities_string (caps);
mm_dbg ("loaded current capabilities: %s", caps_str);
g_free (caps_str);
return caps;