6 #include <Commons/ThreadPool.h>
8 #include <abstractpropertytype.h>
9 #include <vehicleproperty.h>
17 using namespace WrtDeviceApis::Commons;
19 VehicleMaster::VehicleMaster()
20 :EventRequestReceiver<EventVehiclePropertyChanged>(ThreadEnum::APPLICATION_THREAD)
26 std::list<AbstractPropertyType *> VehicleMaster::get(std::string property)
29 GDBusProxy* managerProxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL,
30 "org.automotive.message.broker",
32 "org.automotive.Manager",
38 throw std::runtime_error("could not get automotive message broker Manager interface");
42 GVariant* objectPath = g_dbus_proxy_call_sync(managerProxy, "findProperty", g_variant_new("(s)", property.c_str()), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
44 const char* objP = g_variant_get_string(objectPath, NULL);
46 if(std::string(objP) == "")
48 throw std::runtime_error("could not find property "+ property);
51 GDBusProxy* propertiesProxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL,
52 "org.automotive.message.broker",
54 "org.freedesktop.DBus.Properties",
57 std::string interfaceName = "org.automotive." + property;
59 GVariant* propertyMap = g_dbus_proxy_call_sync(propertiesProxy, "GetAll", g_variant_new("(s)", interfaceName.c_str()), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
63 throw std::runtime_error("failed to call GetAll on interface " + interfaceName);
70 std::list<AbstractPropertyType*> returnValue;
72 g_variant_get(propertyMap,"(a{sv})",&iter);
74 while(g_variant_iter_next(iter,"{sv}", &key, &value))
76 AbstractPropertyType* val = VehicleProperty::getPropertyTypeForPropertyNameValue(key);
77 val->fromVariant(value);
78 returnValue.push_back(val);
84 void VehicleMaster::addEventListener(std::string property, EventVehiclePropertyChangedPtr& event)