19 #ifndef ABSTRACTDBUSINTERFACE_H
20 #define ABSTRACTDBUSINTERFACE_H
24 #include <unordered_map>
27 #include <boost/any.hpp>
29 #include "abstractpropertytype.h"
30 #include <abstractroutingengine.h>
31 #include "varianttype.h"
33 const uint getPid(
const char *owner);
35 typedef std::vector<VariantType*> PropertyDBusMap;
41 AbstractDBusInterface(std::string interfaceName, std::string objectName, GDBusConnection* connection);
45 void setDBusConnection(GDBusConnection* connection)
47 mConnection = connection;
50 void registerObject();
51 void unregisterObject();
56 static PropertyList implementedProperties() {
return mimplementedProperties; }
58 static std::list<AbstractDBusInterface *> getObjectsForProperty(std::string property);
60 static list<AbstractDBusInterface*> interfaces();
62 static std::vector<string> supportedInterfaces();
64 std::string interfaceName() {
return mInterfaceName; }
65 void setInterfaceName(
const std::string & ifaceName)
67 mInterfaceName = ifaceName;
70 bool implementsProperty(std::string property);
80 for(
auto i : propertyDBusMap)
82 if(i->name() == attributeName)
91 std::string objectPath() {
return mObjectPath; }
93 bool isSupported() {
return supported; }
95 double time() {
return mTime; }
99 if(properties.find(propertyName) != properties.end())
100 return properties[propertyName];
106 void setObjectPath(std::string op)
108 if(objectMap.find(op) != objectMap.end())
112 objectMap[mObjectPath] =
this;
115 std::string objectName() {
return mPropertyName; }
117 Zone::Type zone() {
return zoneFilter; }
119 std::string source() {
return mSourceFilter; }
121 std::unordered_map<std::string, VariantType*> getProperties() {
return properties; }
123 bool isRegistered() {
return regId > 0; }
127 void startRegistration();
129 static GVariant *getProperty(GDBusConnection * connection,
const gchar * sender,
const gchar *objectPath,
130 const gchar *interfaceName,
const gchar * propertyName, GError**
error,
132 static gboolean setProperty(GDBusConnection * connection,
const gchar * sender,
const gchar *objectPath,
133 const gchar *interfaceName,
const gchar * propertyName, GVariant *
value,
136 static void handleMyMethodCall(GDBusConnection *connection,
const gchar *sender,
const gchar *object_path,
137 const gchar *interface_name,
const gchar *method_name, GVariant *parameters,
138 GDBusMethodInvocation *invocation, gpointer user_data);
140 virtual void setProperty(std::string propertyName, GVariant * value, std::function<
void (
bool,
AsyncPropertyReply::Error)> callback);
141 virtual GVariant * getProperty(std::string propertyName);
143 void setTimeout(
int timeout);
145 std::unordered_map<std::string, VariantType*> properties;
147 Zone::Type zoneFilter;
149 PropertyDBusMap propertyDBusMap;
153 std::string mSourceFilter;
156 std::string mInterfaceName;
157 std::string mObjectPath;
158 std::string mPropertyName;
159 std::string introspectionXml;
160 GDBusConnection * mConnection;
161 static std::unordered_map<std::string, AbstractDBusInterface*> objectMap;
162 static PropertyList mimplementedProperties;
168 #endif // ABSTRACTDBUSINTERFACE_H