MCPcopy Create free account
hub / github.com/Alexays/Waybar / onInterfaceProxyPropertiesChanged

Method onInterfaceProxyPropertiesChanged

src/modules/bluetooth.cpp:346–383  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344}
345
346auto waybar::modules::Bluetooth::onInterfaceProxyPropertiesChanged(
347 GDBusObjectManagerClient* manager, GDBusObjectProxy* object_proxy, GDBusProxy* interface_proxy,
348 GVariant* changed_properties, const gchar* const* invalidated_properties, gpointer user_data)
349 -> void {
350 std::string interface_name = g_dbus_proxy_get_interface_name(interface_proxy);
351 std::string object_path = g_dbus_object_get_object_path(G_DBUS_OBJECT(object_proxy));
352
353 Bluetooth* bt = static_cast<Bluetooth*>(user_data);
354
355 if (!bt->cur_controller_.has_value()) {
356 return;
357 }
358
359 if (interface_name == "org.bluez.Adapter1") {
360 if (object_path == bt->cur_controller_->path) {
361 bt->getControllerProperties(G_DBUS_OBJECT(object_proxy), *bt->cur_controller_);
362 bt->dp.emit();
363 }
364 } else if (interface_name == "org.bluez.Device1" || interface_name == "org.bluez.Battery1") {
365 DeviceInfo device;
366 bt->getDeviceProperties(G_DBUS_OBJECT(object_proxy), device);
367 auto cur_device = std::find_if(bt->connected_devices_.begin(), bt->connected_devices_.end(),
368 [device](auto d) { return d.path == device.path; });
369 if (cur_device == bt->connected_devices_.end()) {
370 if (device.connected) {
371 bt->connected_devices_.push_back(device);
372 bt->dp.emit();
373 }
374 } else {
375 if (!device.connected) {
376 bt->connected_devices_.erase(cur_device);
377 } else {
378 *cur_device = device;
379 }
380 bt->dp.emit();
381 }
382 }
383}
384
385auto waybar::modules::Bluetooth::getDeviceBatteryPercentage(GDBusObject* object)
386 -> std::optional<unsigned char> {

Callers

nothing calls this directly

Calls 5

getDevicePropertiesMethod · 0.80
emitMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected