27#ifndef SDBUS_CXX_STANDARDINTERFACES_H_
28#define SDBUS_CXX_STANDARDINTERFACES_H_
42 static constexpr const char* INTERFACE_NAME =
"org.freedesktop.DBus.Peer";
60 proxy_->
callMethod(
"Ping").onInterface(INTERFACE_NAME);
63 std::string GetMachineId()
65 std::string machineUUID;
66 proxy_->
callMethod(
"GetMachineId").onInterface(INTERFACE_NAME).storeResultsTo(machineUUID);
77 static constexpr const char* INTERFACE_NAME =
"org.freedesktop.DBus.Introspectable";
93 std::string Introspect()
96 proxy_->
callMethod(
"Introspect").onInterface(INTERFACE_NAME).storeResultsTo(xml);
107 static constexpr const char* INTERFACE_NAME =
"org.freedesktop.DBus.Properties";
115 .onInterface(INTERFACE_NAME)
116 .call([
this](
const std::string& interfaceName
117 ,
const std::map<std::string, sdbus::Variant>& changedProperties
118 ,
const std::vector<std::string>& invalidatedProperties )
120 this->onPropertiesChanged(interfaceName, changedProperties, invalidatedProperties);
131 virtual void onPropertiesChanged(
const std::string& interfaceName
132 ,
const std::map<std::string, sdbus::Variant>& changedProperties
133 ,
const std::vector<std::string>& invalidatedProperties ) = 0;
136 sdbus::Variant Get(
const std::string& interfaceName,
const std::string& propertyName)
138 return proxy_->
getProperty(propertyName).onInterface(interfaceName);
141 template <
typename _Function>
142 PendingAsyncCall GetAsync(
const std::string& interfaceName,
const std::string& propertyName, _Function&& callback)
144 return proxy_->
getPropertyAsync(propertyName).onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
147 std::future<sdbus::Variant> GetAsync(
const std::string& interfaceName,
const std::string& propertyName,
with_future_t)
149 return proxy_->
getPropertyAsync(propertyName).onInterface(interfaceName).getResultAsFuture();
152 void Set(
const std::string& interfaceName,
const std::string& propertyName,
const sdbus::Variant& value)
154 proxy_->
setProperty(propertyName).onInterface(interfaceName).toValue(value);
159 proxy_->
setProperty(propertyName).onInterface(interfaceName).toValue(value, dont_expect_reply);
162 template <
typename _Function>
165 return proxy_->
setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).uponReplyInvoke(std::forward<_Function>(callback));
168 std::future<void> SetAsync(
const std::string& interfaceName,
const std::string& propertyName,
const sdbus::Variant& value,
with_future_t)
170 return proxy_->
setPropertyAsync(propertyName).onInterface(interfaceName).toValue(value).getResultAsFuture();
173 std::map<std::string, sdbus::Variant> GetAll(
const std::string& interfaceName)
178 template <
typename _Function>
179 PendingAsyncCall GetAllAsync(
const std::string& interfaceName, _Function&& callback)
181 return proxy_->
getAllPropertiesAsync().onInterface(interfaceName).uponReplyInvoke(std::forward<_Function>(callback));
184 std::future<std::map<std::string, sdbus::Variant>> GetAllAsync(
const std::string& interfaceName,
with_future_t)
196 static constexpr const char* INTERFACE_NAME =
"org.freedesktop.DBus.ObjectManager";
204 .onInterface(INTERFACE_NAME)
206 ,
const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties )
208 this->onInterfacesAdded(objectPath, interfacesAndProperties);
212 .onInterface(INTERFACE_NAME)
214 ,
const std::vector<std::string>& interfaces )
216 this->onInterfacesRemoved(objectPath, interfaces);
228 ,
const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties) = 0;
230 ,
const std::vector<std::string>& interfaces) = 0;
233 std::map<sdbus::ObjectPath, std::map<std::string, std::map<std::string, sdbus::Variant>>> GetManagedObjects()
235 std::map<sdbus::ObjectPath, std::map<std::string, std::map<std::string, sdbus::Variant>>> objectsInterfacesAndProperties;
236 proxy_->
callMethod(
"GetManagedObjects").onInterface(INTERFACE_NAME).storeResultsTo(objectsInterfacesAndProperties);
237 return objectsInterfacesAndProperties;
251 static constexpr const char* INTERFACE_NAME =
"org.freedesktop.DBus.Properties";
267 void emitPropertiesChangedSignal(
const std::string& interfaceName,
const std::vector<std::string>& properties)
272 void emitPropertiesChangedSignal(
const std::string& interfaceName)
293 static constexpr const char* INTERFACE_NAME =
"org.freedesktop.DBus.ObjectManager";
virtual void emitInterfacesRemovedSignal()=0
Emits InterfacesRemoved signal on this object path.
virtual void addObjectManager()=0
Adds an ObjectManager interface at the path of this D-Bus object.
virtual void emitInterfacesAddedSignal()=0
Emits InterfacesAdded signal on this object path.
virtual void emitPropertiesChangedSignal(const std::string &interfaceName, const std::vector< std::string > &propNames)=0
Emits PropertyChanged signal for specified properties under a given interface of this object path.
AsyncAllPropertiesGetter getAllPropertiesAsync()
Gets values of all properties of the D-Bus object asynchronously.
Definition: IProxy.h:546
AsyncPropertyGetter getPropertyAsync(const std::string &propertyName)
Gets value of a property of the D-Bus object asynchronously.
Definition: IProxy.h:526
PropertySetter setProperty(const std::string &propertyName)
Sets value of a property of the D-Bus object.
Definition: IProxy.h:531
virtual MethodReply callMethod(const MethodCall &message, uint64_t timeout=0)=0
Calls method on the D-Bus object.
AsyncPropertySetter setPropertyAsync(const std::string &propertyName)
Sets value of a property of the D-Bus object asynchronously.
Definition: IProxy.h:536
PropertyGetter getProperty(const std::string &propertyName)
Gets value of a property of the D-Bus object.
Definition: IProxy.h:521
AllPropertiesGetter getAllProperties()
Gets values of all properties of the D-Bus object.
Definition: IProxy.h:541
SignalSubscriber uponSignal(const std::string &signalName)
Registers signal handler for a given signal of the D-Bus object.
Definition: IProxy.h:511
Definition: StandardInterfaces.h:76
Managed Object Convenience Adaptor.
Definition: StandardInterfaces.h:325
void emitInterfacesRemovedSignal()
Emits InterfacesRemoved signal for this object path.
Definition: StandardInterfaces.h:365
void emitInterfacesRemovedSignal(const std::vector< std::string > &interfaces)
Emits InterfacesRemoved signal for this object path.
Definition: StandardInterfaces.h:375
void emitInterfacesAddedSignal()
Emits InterfacesAdded signal for this object path.
Definition: StandardInterfaces.h:345
void emitInterfacesAddedSignal(const std::vector< std::string > &interfaces)
Emits InterfacesAdded signal for this object path.
Definition: StandardInterfaces.h:355
Object Manager Convenience Adaptor.
Definition: StandardInterfaces.h:292
Definition: StandardInterfaces.h:195
Definition: StandardInterfaces.h:41
Definition: StandardInterfaces.h:250
Definition: StandardInterfaces.h:106
Definition: TypeTraits.h:97
Definition: TypeTraits.h:94