request initial value for dbus properties
authorKevron Rees <kevron_m_rees@linux.intel.com>
Wed, 16 Jan 2013 00:22:16 +0000 (16:22 -0800)
committerKevron Rees <kevron_m_rees@linux.intel.com>
Wed, 16 Jan 2013 00:22:16 +0000 (16:22 -0800)
plugins/dbus/environmentproperties.h
plugins/dbus/varianttype.cpp
plugins/exampleplugin.cpp

index 590d4bb..bd86309 100644 (file)
@@ -15,8 +15,6 @@ public:
                wantProperty<uint16_t>(VehicleProperty::ExteriorBrightness,"ExteriorBrightness", "y", AbstractProperty::Read);
                supportedChanged(re->supported());
        }
-
-
 };
 
 #endif
index bca854f..7f8c1ec 100644 (file)
@@ -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();
index e73a05e..7c24b7d 100644 (file)
@@ -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;
 }