diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2013-11-22 23:40:55 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2014-02-13 13:41:41 +0100 |
commit | 2d9d15f892cd0b2181b6fab73290d81bad63e7e3 (patch) | |
tree | a215b85d8b71666727818970af7f6b9fd18ec7e8 /src/mm-plugin.c | |
parent | c182a04f6438850875319862cf8d22de2250e907 (diff) |
plugin: allow creating 'virtual' modems with 'virtual' ports
Diffstat (limited to 'src/mm-plugin.c')
-rw-r--r-- | src/mm-plugin.c | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/src/mm-plugin.c b/src/mm-plugin.c index a5ddb5db..4a8031ec 100644 --- a/src/mm-plugin.c +++ b/src/mm-plugin.c @@ -836,10 +836,14 @@ mm_plugin_create_modem (MMPlugin *self, MMDevice *device, GError **error) { - MMBaseModem *modem = NULL; - GList *port_probes, *l; + MMBaseModem *modem; + GList *port_probes = NULL; + const gchar **virtual_ports = NULL; - port_probes = mm_device_peek_port_probe_list (device); + if (!mm_device_is_virtual (device)) + port_probes = mm_device_peek_port_probe_list (device); + else + virtual_ports = mm_device_virtual_peek_ports (device); /* Let the plugin create the modem from the port probe results */ modem = MM_PLUGIN_GET_CLASS (self)->create_modem (MM_PLUGIN (self), @@ -849,8 +853,13 @@ mm_plugin_create_modem (MMPlugin *self, mm_device_get_product (device), port_probes, error); - if (modem) { - mm_base_modem_set_hotplugged (modem, mm_device_get_hotplugged (device)); + if (!modem) + return NULL; + + mm_base_modem_set_hotplugged (modem, mm_device_get_hotplugged (device)); + + if (port_probes) { + GList *l; /* Grab each port */ for (l = port_probes; l; l = g_list_next (l)) { @@ -911,12 +920,30 @@ mm_plugin_create_modem (MMPlugin *self, g_clear_error (&inner_error); } } + } else if (virtual_ports) { + guint i; + + for (i = 0; virtual_ports[i]; i++) { + GError *inner_error = NULL; - /* If organizing ports fails, consider the modem invalid */ - if (!mm_base_modem_organize_ports (modem, error)) - g_clear_object (&modem); + if (!mm_base_modem_grab_port (modem, + "virtual", + virtual_ports[i], + MM_PORT_TYPE_AT, + MM_PORT_SERIAL_AT_FLAG_NONE, + &inner_error)) { + mm_warn ("Could not grab port (virtual/%s): '%s'", + virtual_ports[i], + inner_error ? inner_error->message : "unknown error"); + g_clear_error (&inner_error); + } + } } + /* If organizing ports fails, consider the modem invalid */ + if (!mm_base_modem_organize_ports (modem, error)) + g_clear_object (&modem); + return modem; } |