From 91f20028a939e49285c8540a8056517bfdd6e245 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Tue, 15 Jan 2013 16:22:16 -0800 Subject: [PATCH] request initial value for dbus properties --- plugins/dbus/environmentproperties.h | 2 -- plugins/dbus/varianttype.cpp | 15 ++++++++++++++- plugins/exampleplugin.cpp | 7 +++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/plugins/dbus/environmentproperties.h b/plugins/dbus/environmentproperties.h index 590d4bb..bd86309 100644 --- a/plugins/dbus/environmentproperties.h +++ b/plugins/dbus/environmentproperties.h @@ -15,8 +15,6 @@ public: wantProperty(VehicleProperty::ExteriorBrightness,"ExteriorBrightness", "y", AbstractProperty::Read); supportedChanged(re->supported()); } - - }; #endif diff --git a/plugins/dbus/varianttype.cpp b/plugins/dbus/varianttype.cpp index bca854f..7f8c1ec 100644 --- a/plugins/dbus/varianttype.cpp +++ b/plugins/dbus/varianttype.cpp @@ -1,15 +1,28 @@ #include "varianttype.h" +#include "abstractroutingengine.h" VariantType::VariantType(AbstractRoutingEngine* re, std::string signature, std::string propertyName, Access access, AbstractDBusInterface *interface) :AbstractProperty(propertyName, signature, access, interface),routingEngine(re) { -//VehicleProperty::getPropertyTypeForPropertyNameValue(propertyName,"")->toVariant()->get_type_string() + AsyncPropertyRequest request; + request.property = mPropertyName; + + VariantType* foo = this; + + request.completed = [foo](AsyncPropertyReply* reply) + { + foo->setValue(reply->value); + }; + + re->getPropertyAsync(request); + } GVariant *VariantType::toGVariant() { if(!value()) { + AbstractPropertyType* v = VehicleProperty::getPropertyTypeForPropertyNameValue(mPropertyName); return v->toVariant()->gobj(); diff --git a/plugins/exampleplugin.cpp b/plugins/exampleplugin.cpp index e73a05e..7c24b7d 100644 --- a/plugins/exampleplugin.cpp +++ b/plugins/exampleplugin.cpp @@ -120,6 +120,12 @@ void ExampleSourcePlugin::getPropertyAsync(AsyncPropertyReply *reply) reply->value = &temp; reply->completed(reply); } + else if(reply->property == VehicleProperty::ExteriorBrightness) + { + VehicleProperty::ExteriorBrightnessType temp(1000); + reply->value = &temp; + reply->completed(reply); + } } void ExampleSourcePlugin::getRangePropertyAsync(AsyncRangePropertyReply *reply) @@ -151,6 +157,7 @@ PropertyList ExampleSourcePlugin::supported() props.push_back(VehicleProperty::WMI); props.push_back(VehicleProperty::BatteryVoltage); props.push_back(VehicleProperty::MachineGunTurretStatus); + props.push_back(VehicleProperty::ExteriorBrightness); return props; } -- 2.7.4