diff --git a/include/sdbus-c++/IProxy.h b/include/sdbus-c++/IProxy.h index aaff213..0594bf2 100644 --- a/include/sdbus-c++/IProxy.h +++ b/include/sdbus-c++/IProxy.h @@ -267,6 +267,13 @@ namespace sdbus { */ [[nodiscard]] PropertySetter setProperty(const std::string& propertyName); + /*! + * @brief Provides D-Bus connection used by the proxy + * + * @return Reference to the D-Bus connection + */ + virtual sdbus::IConnection& getConnection() const = 0; + /*! * @brief Returns object path of the underlying DBus object */ diff --git a/src/Proxy.cpp b/src/Proxy.cpp index f621781..d7e5225 100644 --- a/src/Proxy.cpp +++ b/src/Proxy.cpp @@ -199,6 +199,11 @@ void Proxy::unregister() interfaces_.clear(); } +sdbus::IConnection& Proxy::getConnection() const +{ + return dynamic_cast(*connection_); +} + const std::string& Proxy::getObjectPath() const { return objectPath_; diff --git a/src/Proxy.h b/src/Proxy.h index b64d8f3..4b74882 100644 --- a/src/Proxy.h +++ b/src/Proxy.h @@ -60,6 +60,7 @@ namespace sdbus::internal { void finishRegistration() override; void unregister() override; + sdbus::IConnection& getConnection() const override; const std::string& getObjectPath() const override; private: