summaryrefslogtreecommitdiff
path: root/plugins/dbus/custompropertyinterface.cpp
blob: b2ef92fb48b16f669afd86ea502cd55a0bc0f5a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "custompropertyinterface.h"
#include "vehicleproperty.h"
#include "varianttype.h"
#include "listplusplus.h"

CustomPropertyInterface::CustomPropertyInterface(VehicleProperty::Property prop, AbstractRoutingEngine *re, GDBusConnection *connection)
	:DBusSink("org.automotive."+prop,"/org/automotive/custom/"+prop, re, connection, map<string, string>())
{
	PropertyList list = VehicleProperty::customProperties();

	if(ListPlusPlus<VehicleProperty::Property>(&list).contains(prop))
	{
		AbstractPropertyType* temp = VehicleProperty::getPropertyTypeForPropertyNameValue(prop);

		if(!temp)
		{
			throw std::runtime_error("Cannot create custom property: " + prop);
		}

		std::string signature = g_variant_get_type_string(temp->toVariant());

		propertyDBusMap[prop] = new VariantType(re, signature, prop, prop, VariantType::ReadWrite, this);

		delete temp;
	}

	supportedChanged(re->supported());
}