aboutsummaryrefslogtreecommitdiff
path: root/libmm-glib/mm-common-helpers.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-07-01 21:50:11 +0200
committerAleksander Morgado <aleksander@aleksander.es>2021-07-01 23:38:04 +0200
commitd7acc276e520add0c1a4751824b86f904a8a46ad (patch)
tree26138785e1713080096551e60aebfeecaa5350ad /libmm-glib/mm-common-helpers.c
parent22396a7d1d7e845771cd1063c66dd0a7127d4eb1 (diff)
libmm-glib,modem: use helper macros to manage the monitored properties
Diffstat (limited to 'libmm-glib/mm-common-helpers.c')
-rw-r--r--libmm-glib/mm-common-helpers.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libmm-glib/mm-common-helpers.c b/libmm-glib/mm-common-helpers.c
index 11d0640c..8c3415ff 100644
--- a/libmm-glib/mm-common-helpers.c
+++ b/libmm-glib/mm-common-helpers.c
@@ -728,6 +728,33 @@ mm_common_ports_garray_to_variant (GArray *array)
return mm_common_ports_array_to_variant (NULL, 0);
}
+gboolean
+mm_common_ports_garray_to_array (GArray *array,
+ MMModemPortInfo **ports,
+ guint *n_ports)
+{
+ if (!array)
+ return FALSE;
+
+ *ports = NULL;
+ *n_ports = array->len;
+ if (array->len > 0) {
+ guint i;
+
+ *ports = g_malloc (sizeof (MMModemPortInfo) * array->len);
+
+ /* Deep-copy the array */
+ for (i = 0; i < array->len; i++) {
+ MMModemPortInfo *src;
+
+ src = &g_array_index (array, MMModemPortInfo, i);
+ (*ports)[i].name = g_strdup (src->name);
+ (*ports)[i].type = src->type;
+ }
+ }
+ return TRUE;
+}
+
/******************************************************************************/
/* MMSmsStorage array management */