diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-base-modem.c | 47 | ||||
-rw-r--r-- | src/mm-base-modem.h | 6 | ||||
-rw-r--r-- | src/mm-iface-modem.c | 9 |
3 files changed, 62 insertions, 0 deletions
diff --git a/src/mm-base-modem.c b/src/mm-base-modem.c index c4133932..b348abaa 100644 --- a/src/mm-base-modem.c +++ b/src/mm-base-modem.c @@ -968,6 +968,53 @@ mm_base_modem_has_at_port (MMBaseModem *self) return FALSE; } +MMModemPortInfo * +mm_base_modem_get_port_infos (MMBaseModem *self, + guint *n_port_infos) +{ + GHashTableIter iter; + MMModemPortInfo *port_infos; + MMPort *port; + guint i; + + *n_port_infos = g_hash_table_size (self->priv->ports); + port_infos = g_new (MMModemPortInfo, *n_port_infos); + g_hash_table_iter_init (&iter, self->priv->ports); + i = 0; + while (g_hash_table_iter_next (&iter, NULL, (gpointer)&port)) { + port_infos[i].name = g_strdup (mm_port_get_device (port)); + switch (mm_port_get_port_type (port)) { + case MM_PORT_TYPE_NET: + port_infos[i].type = MM_MODEM_PORT_TYPE_NET; + break; + case MM_PORT_TYPE_AT: + port_infos[i].type = MM_MODEM_PORT_TYPE_AT; + break; + case MM_PORT_TYPE_QCDM: + port_infos[i].type = MM_MODEM_PORT_TYPE_QCDM; + break; + case MM_PORT_TYPE_GPS: + port_infos[i].type = MM_MODEM_PORT_TYPE_GPS; + break; + case MM_PORT_TYPE_QMI: + port_infos[i].type = MM_MODEM_PORT_TYPE_QMI; + break; + case MM_PORT_TYPE_MBIM: + port_infos[i].type = MM_MODEM_PORT_TYPE_MBIM; + break; + case MM_PORT_TYPE_UNKNOWN: + case MM_PORT_TYPE_IGNORED: + default: + port_infos[i].type = MM_MODEM_PORT_TYPE_UNKNOWN; + break; + } + + i++; + } + + return port_infos; +} + static void initialize_ready (MMBaseModem *self, GAsyncResult *res) diff --git a/src/mm-base-modem.h b/src/mm-base-modem.h index 6eeed44b..2c3bd96a 100644 --- a/src/mm-base-modem.h +++ b/src/mm-base-modem.h @@ -23,6 +23,9 @@ #include <glib.h> #include <glib-object.h> +#define _LIBMM_INSIDE_MM +#include <libmm-glib.h> + #include <mm-gdbus-modem.h> #include "mm-auth.h" @@ -155,6 +158,9 @@ MMAtSerialPort *mm_base_modem_get_best_at_port (MMBaseModem *self, GError MMPort *mm_base_modem_get_best_data_port (MMBaseModem *self, MMPortType type); GList *mm_base_modem_get_data_ports (MMBaseModem *self); +MMModemPortInfo *mm_base_modem_get_port_infos (MMBaseModem *self, + guint *n_port_infos); + void mm_base_modem_set_hotplugged (MMBaseModem *self, gboolean hotplugged); gboolean mm_base_modem_get_hotplugged (MMBaseModem *self); diff --git a/src/mm-iface-modem.c b/src/mm-iface-modem.c index e4103ffe..cbee740e 100644 --- a/src/mm-iface-modem.c +++ b/src/mm-iface-modem.c @@ -4019,6 +4019,15 @@ interface_initialization_step (InitializationContext *ctx) g_assert (primary != NULL); mm_gdbus_modem_set_primary_port (ctx->skeleton, mm_port_get_device (primary)); } + /* Load ports if not done before */ + if (!mm_gdbus_modem_get_ports (ctx->skeleton)) { + MMModemPortInfo *port_infos; + guint n_port_infos; + + port_infos = mm_base_modem_get_port_infos (MM_BASE_MODEM (ctx->self), &n_port_infos); + mm_gdbus_modem_set_ports (ctx->skeleton, mm_common_ports_array_to_variant (port_infos, n_port_infos)); + mm_modem_port_info_array_free (port_infos, n_port_infos); + } /* Fall down to next step */ ctx->step++; |