Commit f796be3d authored by Thomas Haller's avatar Thomas Haller

wwan: add nm_modem_manager_get_modems() to iterate over modems

Currently, we cannot ask which modems exist. NMDeviceBt may claim it
via nm_device_factory_emit_component_added(), and NMWWanFactory may
take it by listening to NM_MODEM_MANAGER_MODEM_ADDED. But that's it.

We will drop nm_device_factory_emit_component_added() because it's only
used for passing modems to NMDeviceBt. Instead, NMDeviceBt can directly
subscribe to NM_MODEM_MANAGER_MODEM_ADDED. It already has a reference
to NMModemManager.

Anyway, the NM_MODEM_MANAGER_MODEM_ADDED signal is no enough, because
sometimes when the mode appears, NMDeviceBt might not yet know whether
it should take it (because the DUN connect call is not yet complete).
Currently that never happens because dun_connect() blocks waiting for
the device. That must be fixed, by not waiting. But this opens up a
race, and NMDeviceBt might after NM_MODEM_MANAGER_MODEM_ADDED need to
search for the suitable modem: by iterating the list of all modems.
parent 6d644c66
......@@ -25,6 +25,7 @@ global:
nm_modem_ip4_pre_commit;
nm_modem_is_claimed;
nm_modem_manager_get;
nm_modem_manager_get_modems;
nm_modem_manager_get_type;
nm_modem_manager_name_owner_get;
nm_modem_manager_name_owner_ref;
......
......@@ -136,6 +136,20 @@ remove_one_modem (gpointer key, gpointer value, gpointer user_data)
/*****************************************************************************/
NMModem **
nm_modem_manager_get_modems (NMModemManager *self,
guint *out_len)
{
g_return_val_if_fail (NM_IS_MODEM_MANAGER (self), NULL);
return (NMModem **) nm_utils_hash_values_to_array (NM_MODEM_MANAGER_GET_PRIVATE (self)->modems,
NULL,
NULL,
out_len);
}
/*****************************************************************************/
static void
modm_clear_manager (NMModemManager *self)
{
......
......@@ -38,4 +38,7 @@ void nm_modem_manager_name_owner_unref (NMModemManager *self);
const char *nm_modem_manager_name_owner_get (NMModemManager *self);
NMModem **nm_modem_manager_get_modems (NMModemManager *self,
guint *out_len);
#endif /* __NETWORKMANAGER_MODEM_MANAGER_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment