summaryrefslogtreecommitdiff
path: root/src/devices/wwan/nm-wwan-factory.c
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-08-11 10:43:53 +0200
committerThomas Haller <thaller@redhat.com>2019-09-23 12:47:37 +0200
commit4154d9618c904c2286b332b56f3515806cb1bb3b (patch)
tree5fd7a28f36359ad9c659aa04adeac15a86559b5c /src/devices/wwan/nm-wwan-factory.c
parent878d4963ed7e3058c13f03dc1b2978fce1bed9c6 (diff)
downloadNetworkManager-4154d9618c904c2286b332b56f3515806cb1bb3b.tar.gz
bluetooth: refactor BlueZ handling and let NMBluezManager cache ObjectManager data
This is a complete refactoring of the bluetooth code. Now that BlueZ 4 support was dropped, the separation of NMBluezManager and NMBluez5Manager makes no sense. They should be merged. At that point, notice that BlueZ 5's D-Bus API is fully centered around D-Bus's ObjectManager interface. Using that interface, we basically only call GetManagedObjects() once and register to InterfacesAdded, InterfacesRemoved and PropertiesChanged signals. There is no need to fetch individual properties ever. Note how NMBluezDevice used to query the D-Bus properties itself by creating a GDBusProxy. This is redundant, because when using the ObjectManager interfaces, we have all information already. Instead, let NMBluezManager basically become the client-side cache of all of BlueZ's ObjectManager interface. NMBluezDevice was mostly concerned about caching the D-Bus interface's state, tracking suitable profiles (pan_connection), and moderate between bluez and NMDeviceBt. These tasks don't get simpler by moving them to a seprate file. Let them also be handled by NMBluezManager. I mean, just look how it was previously: NMBluez5Manager registers to ObjectManager interface and sees a device appearing. It creates a NMBluezDevice object and registers to its "initialized" and "notify:usable" signal. In the meantime, NMBluezDevice fetches the relevant information from D-Bus (although it was already present in the data provided by the ObjectManager) and eventually emits these usable and initialized signals. Then, NMBlue5Manager emits a "bdaddr-added" signal, for which NMBluezManager creates the NMDeviceBt instance. NMBluezManager, NMBluez5Manager and NMBluezDevice are strongly cooperating to the point that it is simpler to merge them. This is not mere refactoring. This patch aims to make everything asynchronously and always cancellable. Also, it aims to fix races and inconsistencies of the state. - Registering to a NAP server now waits for the response and delays activation of the NMDeviceBridge accordingly. - For NAP connections we now watch the bnep0 interface in platform, and tear down the device when it goes away. Bluez doesn't send us a notification on D-Bus in that case. - Rework establishing a DUN connection. It no longer uses blocking connect() and does not block until rfcomm device appears. It's all async now. It also watches the rfcomm file descriptor for POLLERR/POLLHUP to notice disconnect. - drop nm_device_factory_emit_component_added() and instead let NMDeviceBt directly register to the WWan factory's "added" signal.
Diffstat (limited to 'src/devices/wwan/nm-wwan-factory.c')
-rw-r--r--src/devices/wwan/nm-wwan-factory.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/devices/wwan/nm-wwan-factory.c b/src/devices/wwan/nm-wwan-factory.c
index 7a93b47c7b..c81a8175bd 100644
--- a/src/devices/wwan/nm-wwan-factory.c
+++ b/src/devices/wwan/nm-wwan-factory.c
@@ -67,10 +67,6 @@ modem_added_cb (NMModemManager *manager,
gs_unref_object NMDevice *device = NULL;
const char *driver;
- /* Do nothing if the modem was consumed by some other plugin */
- if (nm_device_factory_emit_component_added (NM_DEVICE_FACTORY (self), G_OBJECT (modem)))
- return;
-
if (nm_modem_is_claimed (modem))
return;
@@ -80,9 +76,10 @@ modem_added_cb (NMModemManager *manager,
* it. The rfcomm port (and thus the modem) gets created automatically
* by the Bluetooth code during the connection process.
*/
- if (driver && strstr (driver, "bluetooth")) {
- nm_log_info (LOGD_MB, "ignoring modem '%s' (no associated Bluetooth device)",
- nm_modem_get_control_port (modem));
+ if ( driver
+ && strstr (driver, "bluetooth")) {
+ nm_log_dbg (LOGD_MB, "WWAN factory ignores bluetooth modem '%s' which should be handled by bluetooth plugin",
+ nm_modem_get_control_port (modem));
return;
}