Exposed trusted property

This commit is contained in:
Kevin Dewald 2024-12-02 14:38:19 -08:00
parent fd3504f7eb
commit 8eef23d8ff
5 changed files with 30 additions and 1 deletions

View File

@ -34,6 +34,8 @@ class Device : public SimpleDBus::Proxy {
bool paired(bool refresh = true); bool paired(bool refresh = true);
bool bonded(bool refresh = true); bool bonded(bool refresh = true);
bool trusted();
void trusted(bool trusted);
bool connected(bool refresh = true); bool connected(bool refresh = true);
bool services_resolved(bool refresh = true); bool services_resolved(bool refresh = true);

View File

@ -33,6 +33,8 @@ class Device1 : public SimpleDBus::Interface {
std::map<std::string, ByteArray> ServiceData(bool refresh = true); std::map<std::string, ByteArray> ServiceData(bool refresh = true);
bool Paired(bool refresh = true); bool Paired(bool refresh = true);
bool Bonded(bool refresh = true); bool Bonded(bool refresh = true);
bool Trusted();
void Trusted(bool trusted);
bool Connected(bool refresh = true); bool Connected(bool refresh = true);
bool ServicesResolved(bool refresh = true); bool ServicesResolved(bool refresh = true);

View File

@ -92,6 +92,10 @@ bool Device::paired(bool refresh) { return device1()->Paired(refresh); }
bool Device::bonded(bool refresh) { return device1()->Bonded(refresh); } bool Device::bonded(bool refresh) { return device1()->Bonded(refresh); }
bool Device::trusted() { return device1()->Trusted(); }
void Device::trusted(bool trusted) { device1()->Trusted(trusted); }
bool Device::connected(bool refresh) { return device1()->Connected(refresh); } bool Device::connected(bool refresh) { return device1()->Connected(refresh); }
bool Device::services_resolved(bool refresh) { return device1()->ServicesResolved(refresh); } bool Device::services_resolved(bool refresh) { return device1()->ServicesResolved(refresh); }

View File

@ -6,7 +6,6 @@ Agent1::Agent1(std::shared_ptr<SimpleDBus::Connection> conn, SimpleDBus::Proxy*
: SimpleDBus::Interface(conn, proxy, "org.bluez.Agent1") {} : SimpleDBus::Interface(conn, proxy, "org.bluez.Agent1") {}
void Agent1::message_handle(SimpleDBus::Message& msg) { void Agent1::message_handle(SimpleDBus::Message& msg) {
std::cout << "Agent1::message_handle()\n" << msg.to_string() << std::endl;
if (msg.get_type() == SimpleDBus::Message::Type::METHOD_CALL) { if (msg.get_type() == SimpleDBus::Message::Type::METHOD_CALL) {
// To minimize the amount of repeated code, create a method return object that will be // To minimize the amount of repeated code, create a method return object that will be

View File

@ -1,4 +1,6 @@
#include "simplebluez/interfaces/Device1.h" #include "simplebluez/interfaces/Device1.h"
#include "simpledbus/interfaces/Properties.h"
#include "simpledbus/advanced/Proxy.h"
using namespace SimpleBluez; using namespace SimpleBluez;
@ -111,6 +113,26 @@ bool Device1::Bonded(bool refresh) {
return _properties["Bonded"].get_boolean(); return _properties["Bonded"].get_boolean();
} }
bool Device1::Trusted() {
std::scoped_lock lock(_property_update_mutex);
return _properties["Trusted"].get_boolean();
}
void Device1::Trusted(bool trusted) {
SimpleDBus::Holder value_array = SimpleDBus::Holder::create_boolean(trusted);
{
std::scoped_lock lock(_property_update_mutex);
_properties["Trusted"] = value_array;
}
std::map<std::string, SimpleDBus::Holder> changed_properties;
changed_properties["Trusted"] = value_array;
std::shared_ptr<SimpleDBus::Properties> properties = std::dynamic_pointer_cast<SimpleDBus::Properties>(_proxy->interface_get("org.freedesktop.DBus.Properties"));
properties->PropertiesChanged("org.bluez.Device1", changed_properties);
}
bool Device1::Connected(bool refresh) { bool Device1::Connected(bool refresh) {
if (refresh) { if (refresh) {
property_refresh("Connected"); property_refresh("Connected");