* Add methods to initiate custom session bus connection
The new function helper `createSessionBusConnectionWithAddress` allows to create connection to session bus with custom address.
Signed-off-by: Alexander Livenets <a.livenets@gmail.com>
* feat: add support for session bus connection at custom address
Co-authored-by: Stanislav Angelovic <stanislav.angelovic@siemens.com>
* Since ObjectPath and Signature have a user-declared copy-ctor and copy
assignment operator the implicit declaration of corresponding move
operations is disabled. Explicitly add defaulted versions so that
move operations actually move instead of copy.
* See: https://github.com/Kistler-Group/sdbus-cpp/issues/230
fix timeout handling
* Despite what is documented in sd_bus_get_timeout(3), the timeout
returned is actually an absolute time point of Linux's CLOCK_MONOTONIC
clock. Hence, we first have to subtract the current time from the
timeout in order to get a relative time that can be passed to poll.
* For async call timeouts to reliably work, we need a way to notify the
event loop of a connection that is currently blocked waiting in poll.
I.e. assume the event loop thread entered poll with a timeout set to
T1. Afterwards, the main thread starts an async call C with a timeout
T2 < T1. In order for C to be canceled after its timeout T1 has
elapsed, we have to be able to notify the event loop so that it can
update its poll data.
Co-authored-by: Urs Ritzmann <ursritzmann@protonmail.ch>
Co-authored-by: Lukasz Marcul <lukasz.marcul@onemeter.com>
This change addresses conditions where an exception is thrown by the library upon receipt of a malformed message from an external
source, and propagated up to the event loop with no chance of
interception by the application. This issue is only experienced by
proxy convenience APIs, as low-level APIs allow the application to
unpack the message.
Strategy:
1. For malformed signals received by proxies: ignore the signal.
2. For malformed async method responses, translate the unpack
exception into an sdbus::Error, and pass it to the caller as expected.
This internally calls sd_bus_open(), which automatically selects the
system or session bus connection based on the presence and
content of a DBUS_STARTER_BUS_TYPE environment variable and
whether the calling process has root privileges.
This option is very helpful when creating services and clients that will use the system bus in production, but connect to a session
for testing.
Additional changes:
* Removed assertions null-checking make_unique() return values.
make_unique() calls new, and new is expected to throw or abort
on failure, making the assertions unhelpful.
* Corrected a typo in the ClosesAndUnrefsBusWhenDestructed
unit test for the system bus (tested the wrong function).
* Add API to get message path
* Add API to get message destination
* Handle NULL message fields interface and member
Functions sd_bus_message_get_interface() and sd_bus_message_get_member()
can return null in case the message does not use those fields or does
not have them set.
This provides access to the proxy's bus connection so code using
the proxy does not need to store an external reference to it.
A matching function is already available in IObject.
* sdbus-cpp: Add API to get message credentials
Signed-off-by: Alexander Livenets <a.livenets@gmail.com>
* fix: add <sys/types.h> include for gid_t and other types
Co-authored-by: Stanislav Angelovič <angelovic.s@gmail.com>
sdbus::ObjectPath and sdbus::Signature copy constructors are implicitly
declared as deleted when compiling with Linaro's ARM toolchain [1] gcc8.3.
Explicitly listing the copy constructors for affected classes fixes the problem.
[1] https://www.linaro.org/