get signature string directly from the gvariant type itself
authorKevron Rees <tripzero.kev@gmail.com>
Tue, 5 Nov 2013 16:36:57 +0000 (08:36 -0800)
committerKevron Rees <tripzero.kev@gmail.com>
Tue, 5 Nov 2013 16:36:57 +0000 (08:36 -0800)
docs/amb.idl
lib/vehicleproperty.cpp
lib/vehicleproperty.h
plugins/dbus/abstractdbusinterface.cpp
plugins/dbus/abstractproperty.cpp
plugins/dbus/abstractproperty.h
plugins/dbus/varianttype.cpp

index 50c8ffa..a0c45bd 100644 (file)
@@ -447,9 +447,9 @@ interface HVAC : VehiclePropertyType  {
        attribute boolean SteeringWheelHeater;
 
        /**  SeatHeater
-        *   \brief Must return seat heater status: on (true) / off (false).    
+        *   \brief Must return seat heater status: 0-100%.
         **/
-       attribute boolean SeatHeater;
+       attribute unsigned short SeatHeater;
 
        /**  SeatCooler
         *   \brief Must return seat heater status: on (true) / off (false).    
index c45bdd9..29b57ba 100644 (file)
@@ -277,7 +277,7 @@ VehicleProperty::VehicleProperty()
        });
 
        REGISTERPROPERTY(SteeringWheelHeater,false);
-       REGISTERPROPERTY(SeatHeater, false);
+       REGISTERPROPERTY(SeatHeater, 0);
        REGISTERPROPERTY(SeatCooler, false);
        registerPropertyPriv(WindowStatus, []()
        {
index 2db1773..4f61c4f 100644 (file)
@@ -726,7 +726,7 @@ public:
        //typedef BasicPropertyType<bool> SteeringWheelHeaterType;
 
        static const Property SeatHeater;
-       PROPERTYTYPEBASIC(SeatHeater,bool)
+       PROPERTYTYPEBASIC(SeatHeater,int)
        //typedef BasicPropertyType<bool> SeatHeaterType;
 
        static const Property SeatCooler;
index 194244b..13abb4e 100644 (file)
@@ -193,7 +193,7 @@ void AbstractDBusInterface::addProperty(AbstractProperty* property)
 
        ///see which properties are supported:
        introspectionXml +=
-                       "<property type='"+ property->signature() + "' name='"+ pn +"' access='"+access+"' />"
+                       "<property type='"+ string(property->signature()) + "' name='"+ pn +"' access='"+access+"' />"
                        "<method name='Get" + pn + "'>"
                        "       <arg type='v' direction='out' name='value' />"
                        "       <arg type='d' direction='out' name='timestamp' />"
index 7ded707..3a81831 100644 (file)
@@ -20,8 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #include "abstractproperty.h"
 #include "abstractdbusinterface.h"
 
-AbstractProperty::AbstractProperty(string pn, string sig, Access access, AbstractDBusInterface* interface)
-       : mPropertyName(pn), mSignature(sig), mAccess(access), mInterface(interface), mValue(NULL), mZoneFilter(Zone::None), mUpdateFrequency(0)
+AbstractProperty::AbstractProperty(string pn, Access access, AbstractDBusInterface* interface)
+       : mPropertyName(pn), mAccess(access), mInterface(interface), mValue(NULL), mZoneFilter(Zone::None), mUpdateFrequency(0)
 {
 
 }
index e6ac7e7..eb8b5c8 100644 (file)
@@ -46,16 +46,21 @@ public:
                ReadWrite
        };
 
-       AbstractProperty(string propertyName, string signature, Access access, AbstractDBusInterface* interface);
+       AbstractProperty(string propertyName, Access access, AbstractDBusInterface* interface);
        
        virtual void setSetterFunction(SetterFunc setterFunc)
        {
                mSetterFunc = setterFunc;
        }
        
-       virtual string signature()
+       virtual const char* signature()
        {
-               return mSignature;
+               GVariant* var = toGVariant();
+               if(!var) return "";
+
+               const char * s = g_variant_get_type_string(var);
+               g_variant_unref(var);
+               return s;
        }
        
        virtual string name() 
@@ -136,7 +141,6 @@ protected:
        
        string mPropertyName;
        VehicleProperty::Property mAmbPropertyName;
-       string mSignature;
        SetterFunc mSetterFunc;
        Access mAccess;
        AbstractPropertyType* mValue;
index a051833..a43b491 100644 (file)
@@ -4,7 +4,7 @@
 #include "listplusplus.h"
 
 VariantType::VariantType(AbstractRoutingEngine* re, std::string signature, VehicleProperty::Property ambPropertyName, std::string propertyName,  Access access, AbstractDBusInterface *interface)
-       :AbstractProperty(propertyName, signature, access, interface), mInitialized(false)
+       :AbstractProperty(propertyName, access, interface), mInitialized(false)
 {
        mAmbPropertyName = ambPropertyName;
        routingEngine = re;