forked from Kistler-Group/sdbus-cpp
connection: add createDefaultBusConnection()
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).
This commit is contained in:
committed by
Stanislav Angelovič
parent
d74365c535
commit
75ea127374
@ -265,6 +265,27 @@ namespace sdbus {
|
||||
*/
|
||||
[[nodiscard]] std::unique_ptr<sdbus::IConnection> createConnection(const std::string& name);
|
||||
|
||||
/*!
|
||||
* @brief Creates/opens D-Bus user connection when in a user context,
|
||||
* and a system connection, otherwise.
|
||||
*
|
||||
* @return Connection instance
|
||||
*
|
||||
* @throws sdbus::Error in case of failure
|
||||
*/
|
||||
[[nodiscard]] std::unique_ptr<sdbus::IConnection> createDefaultBusConnection();
|
||||
|
||||
/*!
|
||||
* @brief Creates/opens D-Bus user connection with a name when in a user
|
||||
* context, and a system connection with a name, otherwise.
|
||||
*
|
||||
* @param[in] name Name to request on the connection after its opening
|
||||
* @return Connection instance
|
||||
*
|
||||
* @throws sdbus::Error in case of failure
|
||||
*/
|
||||
[[nodiscard]] std::unique_ptr<sdbus::IConnection> createDefaultBusConnection(const std::string& name);
|
||||
|
||||
/*!
|
||||
* @brief Creates/opens D-Bus system connection
|
||||
*
|
||||
|
Reference in New Issue
Block a user