|
virtual void | requestName (const std::string &name)=0 |
| Requests D-Bus name on the connection.
|
|
virtual void | releaseName (const std::string &name)=0 |
| Releases D-Bus name on the connection.
|
|
virtual std::string | getUniqueName () const =0 |
| Retrieve the unique name of a connection. E.g. ":1.xx".
|
|
virtual void | enterEventLoop ()=0 |
| Enters I/O event loop on this bus connection.
|
|
virtual void | enterEventLoopAsync ()=0 |
| Enters I/O event loop on this bus connection in a separate thread.
|
|
virtual void | leaveEventLoop ()=0 |
| Leaves the I/O event loop running on this bus connection.
|
|
virtual void | addObjectManager (const std::string &objectPath)=0 |
| Adds an ObjectManager at the specified D-Bus object path.
|
|
virtual PollData | getEventLoopPollData () const =0 |
| Returns fd, I/O events and timeout data you can pass to poll.
|
|
virtual bool | processPendingRequest ()=0 |
| Process a pending request.
|
|
virtual void | setMethodCallTimeout (uint64_t timeout)=0 |
| Sets general method call timeout.
|
|
template<typename _Rep , typename _Period > |
void | setMethodCallTimeout (const std::chrono::duration< _Rep, _Period > &timeout) |
| Sets general method call timeout.
|
|
virtual uint64_t | getMethodCallTimeout () const =0 |
| Gets general method call timeout.
|
|
virtual void | addObjectManager (const std::string &objectPath, floating_slot_t)=0 |
| Adds an ObjectManager at the specified D-Bus object path.
|
|
virtual Slot | addMatch (const std::string &match, message_handler callback)=0 |
| Installs a match rule for messages received on this bus connection.
|
|
virtual void | addMatch (const std::string &match, message_handler callback, floating_slot_t)=0 |
| Installs a floating match rule for messages received on this bus connection.
|
|
virtual Slot | addMatchAsync (const std::string &match, message_handler callback, message_handler installCallback)=0 |
| Asynchronously installs a match rule for messages received on this bus connection.
|
|
virtual void | addMatchAsync (const std::string &match, message_handler callback, message_handler installCallback, floating_slot_t)=0 |
| Asynchronously installs a floating match rule for messages received on this bus connection.
|
|
void | enterProcessingLoop () |
| Enters I/O event loop on this bus connection.
|
|
void | enterProcessingLoopAsync () |
| Enters I/O event loop on this bus connection in a separate thread.
|
|
void | leaveProcessingLoop () |
| Leaves the I/O event loop running on this bus connection.
|
|
PollData | getProcessLoopPollData () const |
| Returns fd, I/O events and timeout data you can pass to poll.
|
|
An interface to D-Bus bus connection. Incorporates implementation of both synchronous and asynchronous D-Bus I/O event loop.
All methods throw sdbus::Error in case of failure. All methods in this class are thread-aware, but not thread-safe.
virtual Slot sdbus::IConnection::addMatch |
( |
const std::string & | match, |
|
|
message_handler | callback ) |
|
pure virtual |
Installs a match rule for messages received on this bus connection.
- Parameters
-
[in] | match | Match expression to filter incoming D-Bus message |
[in] | callback | Callback handler to be called upon processing an inbound D-Bus message matching the rule |
- Returns
- RAII-style slot handle representing the ownership of the subscription
The method installs a match rule for messages received on the specified bus connection. The syntax of the match rule expression passed in match is described in the D-Bus specification. The specified handler function callback is called for each incoming message matching the specified expression. The match is installed synchronously when connected to a bus broker, i.e. the call sends a control message requested the match to be added to the broker and waits until the broker confirms the match has been installed successfully.
Simply let go of the slot instance to uninstall the match rule from the bus connection. The slot must not outlive the connection for the slot is associated with it.
For more information, consult man sd_bus_add_match
.
- Exceptions
-
virtual Slot sdbus::IConnection::addMatchAsync |
( |
const std::string & | match, |
|
|
message_handler | callback, |
|
|
message_handler | installCallback ) |
|
pure virtual |
Asynchronously installs a match rule for messages received on this bus connection.
- Parameters
-
[in] | match | Match expression to filter incoming D-Bus message |
[in] | callback | Callback handler to be called upon processing an inbound D-Bus message matching the rule |
[in] | installCallback | Callback handler to be called upon processing an inbound D-Bus message matching the rule |
- Returns
- RAII-style slot handle representing the ownership of the subscription
This method operates the same as addMatch()
above, just that it installs the match rule asynchronously, in a non-blocking fashion. A request is sent to the broker, but the call does not wait for a response. The ‘installCallback’ callable is called when the response is later received, with the response message from the broker as parameter. If it's an empty function object, a default implementation is used that terminates the bus connection should installing the match fail.
Refer to the addMatch(const std::string& match, message_handler callback)
documentation, and consult man sd_bus_add_match
, for more information.
- Exceptions
-
virtual void sdbus::IConnection::addMatchAsync |
( |
const std::string & | match, |
|
|
message_handler | callback, |
|
|
message_handler | installCallback, |
|
|
floating_slot_t | ) |
|
pure virtual |
Asynchronously installs a floating match rule for messages received on this bus connection.
- Parameters
-
[in] | match | Match expression to filter incoming D-Bus message |
[in] | callback | Callback handler to be called upon processing an inbound D-Bus message matching the rule |
[in] | installCallback | Callback handler to be called upon processing an inbound D-Bus message matching the rule |
The method installs a floating match rule for messages received on the specified bus connection. Floating means that the bus connection object owns the match rule, i.e. lifetime of the match rule is bound to the lifetime of the bus connection.
Refer to the addMatch(const std::string& match, message_handler callback, message_handler installCallback)
documentation for more information.
- Exceptions
-
virtual void sdbus::IConnection::addObjectManager |
( |
const std::string & | objectPath | ) |
|
|
pure virtual |
Adds an ObjectManager at the specified D-Bus object path.
Creates an ObjectManager interface at the specified object path on the connection. This is a convenient way to interrogate a connection to see what objects it has.
This call creates a floating registration. The ObjectManager will be there for the object path until the connection is destroyed.
Another, recommended way to add object managers is directly through IObject API.
- Exceptions
-
virtual void sdbus::IConnection::addObjectManager |
( |
const std::string & | objectPath, |
|
|
floating_slot_t | ) |
|
pure virtual |
Adds an ObjectManager at the specified D-Bus object path.
Creates an ObjectManager interface at the specified object path on the connection. This is a convenient way to interrogate a connection to see what objects it has.
This call creates a floating registration. The ObjectManager will be there for the object path until the connection is destroyed.
Another, recommended way to add object managers is directly through IObject API.
- Exceptions
-
virtual PollData sdbus::IConnection::getEventLoopPollData |
( |
| ) |
const |
|
pure virtual |
Returns fd, I/O events and timeout data you can pass to poll.
To integrate sdbus with your app's own custom event handling system (without the requirement of an extra thread), you can use this method to query which file descriptors, poll events and timeouts you should add to your app's poll call in your main event loop. If these file descriptors signal, then you should call processPendingRequest to process the event. This means that all of sdbus's callbacks will arrive on your app's main event thread (opposed to on a thread created by sdbus-c++). If you are unsure what this all means then use enterEventLoop() or enterEventLoopAsync() instead.
To integrate sdbus-c++ into a gtk app, pass the file descriptor returned by this method to g_main_context_add_poll.
- Exceptions
-
Returns fd, I/O events and timeout data you can pass to poll.
To integrate sdbus with your app's own custom event handling system (without the requirement of an extra thread), you can use this method to query which file descriptors, poll events and timeouts you should add to your app's poll call in your main event loop. If these file descriptors signal, then you should call processPendingRequest to process the event. This means that all of sdbus's callbacks will arrive on your app's main event thread (opposed to on a thread created by sdbus-c++). If you are unsure what this all means then use enterEventLoop() or enterEventLoopAsync() instead.
To integrate sdbus-c++ into a gtk app, pass the file descriptor returned by this method to g_main_context_add_poll.
- Exceptions
-
- Deprecated
- This function has been replaced by getEventLoopPollData()
template<typename _Rep , typename _Period >
void sdbus::IConnection::setMethodCallTimeout |
( |
const std::chrono::duration< _Rep, _Period > & | timeout | ) |
|
|
inline |
Sets general method call timeout.
- Parameters
-
[in] | timeout | Timeout value in microseconds |
General method call timeout is used for all method calls upon this connection. Method call-specific timeout overrides this general setting.
Supported by libsystemd>=v240.
- Exceptions
-