pkg_check_modules(gio REQUIRED gio-2.0)
set(dbussinkplugin_headers dbusplugin.h abstractproperty.h abstractdbusinterface.h dbusinterfacemanager.h basicproperty.h runningstatus.h varianttype.h
-custompropertyinterface.h environmentproperties.h vehicleinfo.h maintenance.h parking.h fakeidlheader.h drivingsafety.h)
+custompropertyinterface.h uncategorizedproperty.h environmentproperties.h vehicleinfo.h maintenance.h parking.h fakeidlheader.h drivingsafety.h)
set(dbussinkplugin_sources dbusplugin.cpp abstractproperty.cpp abstractdbusinterface.cpp dbusinterfacemanager.cpp basicproperty.cpp runningstatus.cpp
-varianttype.cpp custompropertyinterface.cpp environmentproperties.cpp vehicleinfo.cpp maintenance.cpp parking.cpp drivingsafety.cpp)
+varianttype.cpp custompropertyinterface.cpp uncategorizedproperty.cpp environmentproperties.cpp vehicleinfo.cpp maintenance.cpp parking.cpp drivingsafety.cpp)
add_library(dbussinkplugin MODULE ${dbussinkplugin_sources})
set_target_properties(dbussinkplugin PROPERTIES PREFIX "")
#include <boost/algorithm/string.hpp>
#include <gio/gio.h>
+#include "listplusplus.h"
#include "abstractproperty.h"
unordered_map<string, AbstractDBusInterface*> AbstractDBusInterface::interfaceMap;
+list<string> AbstractDBusInterface::mimplementedProperties;
AbstractDBusInterface::AbstractDBusInterface(string interfaceName, string objectPath,
GDBusConnection* connection)
"</signal>";
properties[property->name()] = property;
+
+ if(!ListPlusPlus<string>(&mimplementedProperties).contains(property->name()))
+ {
+ mimplementedProperties.push_back(property->name());
+ }
}
void AbstractDBusInterface::registerObject()
#include <string>
#include <functional>
#include <unordered_map>
+#include <list>
#include <gio/gio.h>
#include <boost/any.hpp>
#include <nullptr.h>
void addProperty(AbstractProperty* property);
virtual void updateValue(AbstractProperty* property);
+ static list<string> implementedProperties() { return mimplementedProperties; }
+
protected:
void startRegistration();
string introspectionXml;
GDBusConnection * mConnection;
static unordered_map<string, AbstractDBusInterface*> interfaceMap;
+ static list<string> mimplementedProperties;
guint regId;
};
<busconfig>
<policy context="default">
- <!-- <deny send_destination="org.automotive.message.broker"/> -->
+ <allow own="org.automotive.message.broker"/>
<allow send_destination="org.automotive.message.broker"/>
- <allow own="org.automotive.message.broker"/>
+
+ <!-- Example: in the default context, this interface is denied write control -->
+ <deny send_destination="org.automotive.message.broker" send_interface="org.automotive.MachineGunTurretStatus" />
+
</policy>
+ <!-- Example: the following is an example on how a specific interface can be protected using SMACK
+ <policy smack="allow_write_machinegun" >
+ <allow send_desination="org.automotive.message.broker" send_interface="org.automotive.MachineGunTurret" />
+ </policy> -->
+
</busconfig>
#include <gio/gio.h>
#include <string>
+#include "listplusplus.h"
+
///properties:
#include "accelerationproperty.h"
#include "runningstatus.h"
#include "custompropertyinterface.h"
+#include "uncategorizedproperty.h"
#include "environmentproperties.h"
#include "vehicleinfo.h"
#include "maintenance.h"
}
+ /// Create objects for unimplemented properties:
+
+ PropertyList capabilitiesList = VehicleProperty::capabilities();
+
+ for (auto itr = capabilitiesList.begin(); itr != capabilitiesList.end(); itr++)
+ {
+ VehicleProperty::Property prop = *itr;
+
+ PropertyList implemented = AbstractDBusInterface::implementedProperties();
+
+ if(!ListPlusPlus<VehicleProperty::Property>(&implemented).contains(prop))
+ {
+ new UncategorizedPropertyInterface(prop, iface->re, connection);
+ }
+ }
+
}
static void
on_name_lost (GDBusConnection *connection, const gchar *name, gpointer user_data)
{
+ DebugOut(0)<<"DBus: Lost bus name"<<endl;
+
+ if(!connection){
+ DebugOut(0)<<"DBus: Connection could not be established."<<endl;
+ throw std::runtime_error("Could not establish DBus connection.");
+ }
}
}
PropertyDBusMap propertyDBusMap;
+
private:
bool supported;
--- /dev/null
+#include "uncategorizedproperty.h"
+#include "vehicleproperty.h"
+#include "varianttype.h"
+#include "listplusplus.h"
+
+UncategorizedPropertyInterface::UncategorizedPropertyInterface(VehicleProperty::Property prop, AbstractRoutingEngine *re, GDBusConnection *connection)
+ :DBusSink("org.automotive."+prop,"/org/automotive/uncategorized/"+prop, re, connection, map<string, string>())
+{
+ AbstractPropertyType* temp = VehicleProperty::getPropertyTypeForPropertyNameValue(prop);
+
+ if(!temp)
+ {
+ throw std::runtime_error("Cannot create uncategorized property: " + prop);
+ }
+
+ std::string signature = g_variant_get_type_string(temp->toVariant());
+
+ propertyDBusMap[prop] = new VariantType(re, signature, prop, VariantType::ReadWrite, this);
+
+ delete temp;
+
+ supportedChanged(re->supported());
+}
--- /dev/null
+#ifndef UncategorizedPropertyInterface_H_
+#define UncategorizedPropertyInterface_H_
+
+#include "dbusplugin.h"
+
+class UncategorizedPropertyInterface: DBusSink
+{
+public:
+ UncategorizedPropertyInterface(VehicleProperty::Property, AbstractRoutingEngine* re, GDBusConnection* connection);
+};
+
+
+#endif
reply->success = true;
reply->completed(reply);
}
+ else if(reply->property == VehicleProperty::MachineGunTurretStatus)
+ {
+ VehicleProperty::MachineGunTurretStatusType temp(true);
+ reply->value = &temp;
+ reply->success = true;
+ reply->completed(reply);
+ }
}
void ExampleSourcePlugin::getRangePropertyAsync(AsyncRangePropertyReply *reply)
props.push_back(VehicleProperty::ExteriorBrightness);
props.push_back(VehicleProperty::DoorsPerRow);
props.push_back(VehicleProperty::AirbagStatus);
+ props.push_back(VehicleProperty::MachineGunTurretStatus);
return props;
}