Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package sdbus-cpp for openSUSE:Factory checked in at 2021-10-29 22:33:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/sdbus-cpp (Old) and /work/SRC/openSUSE:Factory/.sdbus-cpp.new.1890 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "sdbus-cpp" Fri Oct 29 22:33:32 2021 rev:3 rq:927756 version:1.0.0 Changes: -------- --- /work/SRC/openSUSE:Factory/sdbus-cpp/sdbus-cpp.changes 2021-10-23 00:52:24.941159489 +0200 +++ /work/SRC/openSUSE:Factory/.sdbus-cpp.new.1890/sdbus-cpp.changes 2021-10-29 22:34:15.227682586 +0200 @@ -1,0 +2,6 @@ +* Mon Oct 25 14:48:52 UTC 2021 - Luca Boccassi <bl...@debian.org> + +- Update to new version 1.0.0 +- Bump package name for new SOVERSION + +------------------------------------------------------------------- Old: ---- sdbus-cpp-0.9.0.tar.gz New: ---- sdbus-cpp-1.0.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ sdbus-cpp.spec ++++++ --- /var/tmp/diff_new_pack.ry7l0S/_old 2021-10-29 22:34:15.643682743 +0200 +++ /var/tmp/diff_new_pack.ry7l0S/_new 2021-10-29 22:34:15.647682745 +0200 @@ -18,8 +18,8 @@ # -%global version_major 0 -%global version_minor 9 +%global version_major 1 +%global version_minor 0 %global version_micro 0 Name: sdbus-cpp @@ -40,17 +40,17 @@ High-level C++ D-Bus library for Linux designed to provide easy-to-use yet powerful API in modern C++ -%package -n libsdbus-c++0 +%package -n libsdbus-c++1 Summary: Shared library for %{name} Group: Development/Libraries/C and C++ -%description -n libsdbus-c++0 +%description -n libsdbus-c++1 Shared library files for %{name}. %package devel Summary: Development files for %{name} Group: Development/Libraries/C and C++ -Requires: libsdbus-c++0 = %{version} +Requires: libsdbus-c++1 = %{version} %description devel CMake, pkg-config, headers and other development files for %{name}. @@ -67,7 +67,7 @@ %package xml2cpp Summary: Stub code generator for sdbus-c++ Group: Development/Libraries/C and C++ -Requires: libsdbus-c++0 = %{version} +Requires: libsdbus-c++1 = %{version} BuildRequires: pkgconfig(expat) %description xml2cpp @@ -89,12 +89,12 @@ %install %cmake_install -%post -n libsdbus-c++0 -p /sbin/ldconfig +%post -n libsdbus-c++1 -p /sbin/ldconfig -%postun -n libsdbus-c++0 -p /sbin/ldconfig +%postun -n libsdbus-c++1 -p /sbin/ldconfig -%files -n libsdbus-c++0 -%license %{_docdir}/sdbus-c++/COPYING +%files -n libsdbus-c++1 +%license COPYING %{_libdir}/libsdbus-c++.so.* %files devel @@ -105,6 +105,7 @@ %doc %{_docdir}/sdbus-c++/ChangeLog %doc %{_docdir}/sdbus-c++/NEWS %doc %{_docdir}/sdbus-c++/README +%doc %{_docdir}/sdbus-c++/COPYING %{_libdir}/cmake/sdbus-c++* %{_libdir}/pkgconfig/sdbus-c++* %{_libdir}/libsdbus-c++.so @@ -119,8 +120,10 @@ %doc %{_docdir}/sdbus-c++/sdbus-c++-class-diagram.uml %doc %{_docdir}/sdbus-c++/systemd-dbus-config.md %doc %{_docdir}/sdbus-c++/using-sdbus-c++.md +%license COPYING %files xml2cpp %{_bindir}/sdbus-c++-xml2cpp +%license COPYING %changelog ++++++ sdbus-cpp-0.9.0.tar.gz -> sdbus-cpp-1.0.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/.github/workflows/ci.yml new/sdbus-cpp-1.0.0/.github/workflows/ci.yml --- old/sdbus-cpp-0.9.0/.github/workflows/ci.yml 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/.github/workflows/ci.yml 2021-10-25 09:02:37.000000000 +0200 @@ -50,7 +50,7 @@ run: | mkdir build cd build - cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -DNDEBUG -W -Wextra -Wall -Wnon-virtual-dtor -Werror" -DBUILD_TESTS=ON -DENABLE_PERF_TESTS=ON -DENABLE_STRESS_TESTS=ON -DBUILD_CODE_GEN=ON .. + cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_CXX_FLAGS="-O3 -DNDEBUG -W -Wextra -Wall -Wnon-virtual-dtor -Werror" -DBUILD_TESTS=ON -DENABLE_PERF_TESTS=ON -DENABLE_STRESS_TESTS=ON -DBUILD_CODE_GEN=ON .. - name: configure-with-embedded-libsystemd if: matrix.build == 'embedded-static-libsystemd' run: | @@ -60,9 +60,23 @@ - name: make run: | cd build - make -j2 + cmake --build . -j2 - name: verify run: | cd build - sudo make install + sudo cmake --build . --target install ctest + - name: pack + if: matrix.build == 'shared-libsystemd' && matrix.os == 'ubuntu-20.04' + run: | + cd build + cpack -G DEB + - name: 'Upload Artifact' + if: matrix.build == 'shared-libsystemd' && matrix.os == 'ubuntu-20.04' && matrix.compiler == 'g++' + uses: actions/upload-artifact@v2 + with: + name: "debian-packages-${{ matrix.os }}-${{ matrix.compiler }}" + path: | + build/sdbus-c++*.deb + build/sdbus-c++*.ddeb + retention-days: 10 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/CMakeLists.txt new/sdbus-cpp-1.0.0/CMakeLists.txt --- old/sdbus-cpp-0.9.0/CMakeLists.txt 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/CMakeLists.txt 2021-10-25 09:02:37.000000000 +0200 @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.13) -project(sdbus-c++ VERSION 0.8.3 LANGUAGES C CXX) +project(sdbus-c++ VERSION 1.0.0 LANGUAGES C CXX) include(GNUInstallDirs) # Installation directories for `install` command and pkgconfig file @@ -165,6 +165,17 @@ endif() #---------------------------------- +# EXAMPLES +#---------------------------------- + +option(BUILD_EXAMPLES "Build example programs (default OFF)" OFF) + +if(BUILD_EXAMPLES) + message(STATUS "Building with examples") + add_subdirectory(examples) +endif() + +#---------------------------------- # DOCUMENTATION #---------------------------------- @@ -207,6 +218,7 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "high-level C++ D-Bus library") set(CPACK_PACKAGE_CONTACT "i...@kistler.com") set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md") +set(CPACK_COMPONENTS_ALL runtime dev doc) set(CPACK_COMPONENT_DEV_DEPENDS "runtime") # specific for DEB generator diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/ChangeLog new/sdbus-cpp-1.0.0/ChangeLog --- old/sdbus-cpp-0.9.0/ChangeLog 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/ChangeLog 2021-10-25 09:02:37.000000000 +0200 @@ -170,9 +170,6 @@ - Fix unused variable warning for release builds - Introduce CI workflow based on GitHub Actions -v0.8.4 -- fix issue #145: signals are not filtered by sender - v0.9.0 - Provide CMake config and PkgConfig files for tools - Provide access to D-Bus message in high-level API @@ -182,6 +179,7 @@ - Enable default construction of PendingAsyncCall - Add API to get message path and message destination - Avoid propagating msg unpack exceptions to the event loop +- Fix issue #145: signals are not filtered by sender - Fix race condition in Proxy and Object destructor - Fix seg fault in Message::peekType() - Add information to documentation about conan recipe @@ -192,3 +190,8 @@ - Support Error parameter in signal handlers - Add specific sections for tips and notes in the tutorial - A few additional documentation and test updates and improvements + +v1.0.0 +- [[Breaking API change]] Fixed the API to send org.freedesktop.DBus.ObjectManager.InterfacesAdded and org.freedesktop.DBus.ObjectManager.InterfacesRemoved signals via the generated stubs layer. + - StandardInterfaces.h: Split ObjectManager_adaptor and ManagedObject_adaptor. +- New examples directory. First example covers the object manager. Further examples might follow. \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/README.md new/sdbus-cpp-1.0.0/README.md --- old/sdbus-cpp-0.9.0/README.md 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/README.md 2021-10-25 09:02:37.000000000 +0200 @@ -70,6 +70,10 @@ This is a global CMake flag, promoted in sdbus-c++ project to a CMake option. Use this to control whether sdbus-c++ is built as either a shared or static library. Default value: `ON`. +* `BUILD_EXAMPLES` [boolean] + + Build example programs which are located in the _example_ directory. Examples are not installed. Default value: `OFF` + Dependencies ------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/docs/using-sdbus-c++.md new/sdbus-cpp-1.0.0/docs/using-sdbus-c++.md --- old/sdbus-cpp-0.9.0/docs/using-sdbus-c++.md 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/docs/using-sdbus-c++.md 2021-10-25 09:02:37.000000000 +0200 @@ -1252,7 +1252,7 @@ Note that signals of afore-mentioned standard D-Bus interfaces are not emitted by the library automatically. It's clients who are supposed to emit them. -Working examples of using standard D-Bus interfaces can be found in [sdbus-c++ integration tests](/tests/integrationtests/DBusStandardInterfacesTests.cpp). +Working examples of using standard D-Bus interfaces can be found in [sdbus-c++ integration tests](/tests/integrationtests/DBusStandardInterfacesTests.cpp) or the [examples](/examples) directory. Conclusion ---------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/examples/CMakeLists.txt new/sdbus-cpp-1.0.0/examples/CMakeLists.txt --- old/sdbus-cpp-0.9.0/examples/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/sdbus-cpp-1.0.0/examples/CMakeLists.txt 2021-10-25 09:02:37.000000000 +0200 @@ -0,0 +1,6 @@ + +add_executable(obj-manager-server org.freedesktop.DBus.ObjectManager/obj-manager-server.cpp) +target_link_libraries(obj-manager-server sdbus-c++) + +add_executable(obj-manager-client org.freedesktop.DBus.ObjectManager/obj-manager-client.cpp) +target_link_libraries(obj-manager-client sdbus-c++) \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/examples/org.freedesktop.DBus.ObjectManager/examplemanager-planet1-client-glue.h new/sdbus-cpp-1.0.0/examples/org.freedesktop.DBus.ObjectManager/examplemanager-planet1-client-glue.h --- old/sdbus-cpp-0.9.0/examples/org.freedesktop.DBus.ObjectManager/examplemanager-planet1-client-glue.h 1970-01-01 01:00:00.000000000 +0100 +++ new/sdbus-cpp-1.0.0/examples/org.freedesktop.DBus.ObjectManager/examplemanager-planet1-client-glue.h 2021-10-25 09:02:37.000000000 +0200 @@ -0,0 +1,50 @@ + +/* + * This file was automatically generated by sdbus-c++-xml2cpp; DO NOT EDIT! + */ + +#ifndef __sdbuscpp__examplemanager_planet1_client_glue_h__proxy__H__ +#define __sdbuscpp__examplemanager_planet1_client_glue_h__proxy__H__ + +#include <sdbus-c++/sdbus-c++.h> +#include <string> +#include <tuple> + +namespace org { +namespace sdbuscpp { +namespace ExampleManager { + +class Planet1_proxy +{ +public: + static constexpr const char* INTERFACE_NAME = "org.sdbuscpp.ExampleManager.Planet1"; + +protected: + Planet1_proxy(sdbus::IProxy& proxy) + : proxy_(proxy) + { + } + + ~Planet1_proxy() = default; + +public: + uint64_t GetPopulation() + { + uint64_t result; + proxy_.callMethod("GetPopulation").onInterface(INTERFACE_NAME).storeResultsTo(result); + return result; + } + +public: + std::string Name() + { + return proxy_.getProperty("Name").onInterface(INTERFACE_NAME); + } + +private: + sdbus::IProxy& proxy_; +}; + +}}} // namespaces + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/examples/org.freedesktop.DBus.ObjectManager/examplemanager-planet1-server-glue.h new/sdbus-cpp-1.0.0/examples/org.freedesktop.DBus.ObjectManager/examplemanager-planet1-server-glue.h --- old/sdbus-cpp-0.9.0/examples/org.freedesktop.DBus.ObjectManager/examplemanager-planet1-server-glue.h 1970-01-01 01:00:00.000000000 +0100 +++ new/sdbus-cpp-1.0.0/examples/org.freedesktop.DBus.ObjectManager/examplemanager-planet1-server-glue.h 2021-10-25 09:02:37.000000000 +0200 @@ -0,0 +1,44 @@ + +/* + * This file was automatically generated by sdbus-c++-xml2cpp; DO NOT EDIT! + */ + +#ifndef __sdbuscpp__examplemanager_planet1_server_glue_h__adaptor__H__ +#define __sdbuscpp__examplemanager_planet1_server_glue_h__adaptor__H__ + +#include <sdbus-c++/sdbus-c++.h> +#include <string> +#include <tuple> + +namespace org { +namespace sdbuscpp { +namespace ExampleManager { + +class Planet1_adaptor +{ +public: + static constexpr const char* INTERFACE_NAME = "org.sdbuscpp.ExampleManager.Planet1"; + +protected: + Planet1_adaptor(sdbus::IObject& object) + : object_(object) + { + object_.registerMethod("GetPopulation").onInterface(INTERFACE_NAME).withOutputParamNames("population").implementedAs([this](){ return this->GetPopulation(); }); + object_.registerProperty("Name").onInterface(INTERFACE_NAME).withGetter([this](){ return this->Name(); }); + } + + ~Planet1_adaptor() = default; + +private: + virtual uint64_t GetPopulation() = 0; + +private: + virtual std::string Name() = 0; + +private: + sdbus::IObject& object_; +}; + +}}} // namespaces + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/examples/org.freedesktop.DBus.ObjectManager/obj-manager-client.cpp new/sdbus-cpp-1.0.0/examples/org.freedesktop.DBus.ObjectManager/obj-manager-client.cpp --- old/sdbus-cpp-0.9.0/examples/org.freedesktop.DBus.ObjectManager/obj-manager-client.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/sdbus-cpp-1.0.0/examples/org.freedesktop.DBus.ObjectManager/obj-manager-client.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -0,0 +1,110 @@ +/** + * Example of a D-Bus client which implements org.freedesktop.DBus.ObjectManager + * + * The example uses the generated stub API layer to listen to interfaces added to new objects under + * "org.sdbuscpp.examplemanager". If added, we access "org.sdbuscpp.ExampleManager.Planet1" to print + * info like this: + * /org/sdbuscpp/examplemanager/Planet1/Earth added: org.sdbuscpp.ExampleManager.Planet1 + * Earth has a population of 7874965825. + * + */ + +#include "examplemanager-planet1-client-glue.h" +#include <sdbus-c++/sdbus-c++.h> +#include <iostream> +#include <thread> + +class PlanetProxy final : public sdbus::ProxyInterfaces< org::sdbuscpp::ExampleManager::Planet1_proxy > +{ +public: + PlanetProxy(sdbus::IConnection& connection, std::string destination, std::string path) + : ProxyInterfaces(connection, std::move(destination), std::move(path)) + { + registerProxy(); + } + + ~PlanetProxy() + { + unregisterProxy(); + } +}; + +class ManagerProxy final : public sdbus::ProxyInterfaces< sdbus::ObjectManager_proxy > +{ +public: + ManagerProxy(sdbus::IConnection& connection, const std::string& destination, std::string path) + : ProxyInterfaces(connection, destination, std::move(path)) + , m_connection(connection) + , m_destination(destination) + { + registerProxy(); + } + + ~ManagerProxy() + { + unregisterProxy(); + } + + void handleExistingObjects() + { + std::map<sdbus::ObjectPath, std::map<std::string, std::map<std::string, sdbus::Variant>>> objectsInterfacesAndProperties; + objectsInterfacesAndProperties = GetManagedObjects(); + for (const auto& [object, interfacesAndProperties] : objectsInterfacesAndProperties) { + onInterfacesAdded(object, interfacesAndProperties); + } + } + +private: + void onInterfacesAdded( const sdbus::ObjectPath& objectPath + , const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties) override + { + std::cout << objectPath << " added:\t"; + for (const auto& [interface, _] : interfacesAndProperties) { + std::cout << interface << " "; + } + std::cout << std::endl; + + // Parse and print some more info + auto planetInterface = interfacesAndProperties.find(org::sdbuscpp::ExampleManager::Planet1_proxy::INTERFACE_NAME); + if (planetInterface == interfacesAndProperties.end()) { + return; + } + const auto& properties = planetInterface->second; + // get a property which was passed as part of the signal. + const auto& name = properties.at("Name").get<std::string>(); + // or create a proxy instance to the newly added object. + PlanetProxy planet(m_connection, m_destination, objectPath); + std::cout << name << " has a population of " << planet.GetPopulation() << ".\n" << std::endl; + } + + void onInterfacesRemoved( const sdbus::ObjectPath& objectPath + , const std::vector<std::string>& interfaces) override + { + std::cout << objectPath << " removed:\t"; + for (const auto& interface : interfaces) { + std::cout << interface << " "; + } + std::cout << std::endl; + } + + sdbus::IConnection& m_connection; + std::string m_destination; +}; + +int main() +{ + auto connection = sdbus::createSessionBusConnection(); + + auto managerProxy = std::make_unique<ManagerProxy>(*connection, "org.sdbuscpp.examplemanager", "/org/sdbuscpp/examplemanager"); + try { + managerProxy->handleExistingObjects(); + } + catch (const sdbus::Error& e) { + if (e.getName() == "org.freedesktop.DBus.Error.ServiceUnknown") { + std::cout << "Waiting for server to start ..." << std::endl; + } + } + + connection->enterEventLoop(); + return 0; +} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/examples/org.freedesktop.DBus.ObjectManager/obj-manager-server.cpp new/sdbus-cpp-1.0.0/examples/org.freedesktop.DBus.ObjectManager/obj-manager-server.cpp --- old/sdbus-cpp-0.9.0/examples/org.freedesktop.DBus.ObjectManager/obj-manager-server.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/sdbus-cpp-1.0.0/examples/org.freedesktop.DBus.ObjectManager/obj-manager-server.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -0,0 +1,108 @@ +/** + * Example of a D-Bus server which implements org.freedesktop.DBus.ObjectManager + * + * The example uses the generated stub API layer to register an object manager under "org.sdbuscpp.examplemanager" + * and add objects underneath which implement "org.sdbuscpp.ExampleManager.Planet1". + * + * We add and remove objects after a few seconds and print info like this: + * Creating PlanetAdaptor in 5 4 3 2 1 + * Creating PlanetAdaptor in 5 4 3 2 1 + * Creating PlanetAdaptor in 5 4 3 2 1 + * Removing PlanetAdaptor in 5 4 3 2 1 + * Removing PlanetAdaptor in 5 4 3 2 1 + */ + +#include "examplemanager-planet1-server-glue.h" +#include <sdbus-c++/sdbus-c++.h> +#include <iostream> +#include <memory> +#include <thread> +#include <chrono> + +class ManagerAdaptor : public sdbus::AdaptorInterfaces< sdbus::ObjectManager_adaptor > +{ +public: + ManagerAdaptor(sdbus::IConnection& connection, std::string path) + : AdaptorInterfaces(connection, std::move(path)) + { + registerAdaptor(); + } + + ~ManagerAdaptor() + { + unregisterAdaptor(); + } +}; + +class PlanetAdaptor final : public sdbus::AdaptorInterfaces< org::sdbuscpp::ExampleManager::Planet1_adaptor, + sdbus::ManagedObject_adaptor, + sdbus::Properties_adaptor > +{ +public: + PlanetAdaptor(sdbus::IConnection& connection, std::string path, std::string name, uint64_t poulation) + : AdaptorInterfaces(connection, std::move(path)) + , m_name(std::move(name)) + , m_population(poulation) + { + registerAdaptor(); + emitInterfacesAddedSignal({org::sdbuscpp::ExampleManager::Planet1_adaptor::INTERFACE_NAME}); + } + + ~PlanetAdaptor() + { + emitInterfacesRemovedSignal({org::sdbuscpp::ExampleManager::Planet1_adaptor::INTERFACE_NAME}); + unregisterAdaptor(); + } + + uint64_t GetPopulation() override + { + return m_population; + } + + std::string Name() override + { + return m_name; + } + +private: + std::string m_name; + uint64_t m_population; +}; + +void printCountDown(const std::string& message, int seconds) +{ + std::cout << message << std::flush; + for (int i = seconds; i > 0; i--) { + std::this_thread::sleep_for(std::chrono::seconds(1)); + std::cout << i << " " << std::flush; + } + std::cout << std::endl; +} + +int main() +{ + auto connection = sdbus::createSessionBusConnection(); + connection->requestName("org.sdbuscpp.examplemanager"); + connection->enterEventLoopAsync(); + + auto manager = std::make_unique<ManagerAdaptor>(*connection, "/org/sdbuscpp/examplemanager"); + while (true) + { + printCountDown("Creating PlanetAdaptor in ", 5); + auto earth = std::make_unique<PlanetAdaptor>(*connection, "/org/sdbuscpp/examplemanager/Planet1/Earth", "Earth", 7'874'965'825); + printCountDown("Creating PlanetAdaptor in ", 5); + auto trantor = std::make_unique<PlanetAdaptor>(*connection, "/org/sdbuscpp/examplemanager/Planet1/Trantor", "Trantor", 40'000'000'000); + printCountDown("Creating PlanetAdaptor in ", 5); + auto laconia = std::make_unique<PlanetAdaptor>(*connection, "/org/sdbuscpp/examplemanager/Planet1/Laconia", "Laconia", 231'721); + printCountDown("Removing PlanetAdaptor in ", 5); + earth.reset(); + printCountDown("Removing PlanetAdaptor in ", 5); + trantor.reset(); + printCountDown("Removing PlanetAdaptor in ", 5); + laconia.reset(); + } + + connection->releaseName("org.sdbuscpp.examplemanager"); + connection->leaveEventLoop(); + return 0; +} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/examples/org.freedesktop.DBus.ObjectManager/org.sdbuscpp.ExampleManager.Planet1.xml new/sdbus-cpp-1.0.0/examples/org.freedesktop.DBus.ObjectManager/org.sdbuscpp.ExampleManager.Planet1.xml --- old/sdbus-cpp-0.9.0/examples/org.freedesktop.DBus.ObjectManager/org.sdbuscpp.ExampleManager.Planet1.xml 1970-01-01 01:00:00.000000000 +0100 +++ new/sdbus-cpp-1.0.0/examples/org.freedesktop.DBus.ObjectManager/org.sdbuscpp.ExampleManager.Planet1.xml 2021-10-25 09:02:37.000000000 +0200 @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> + <interface name="org.sdbuscpp.ExampleManager.Planet1"> + + <!-- + @brief get the population of this planet + @param [out] population of the planet + --> + <method name="GetPopulation"> + <arg name="population" type="t" direction="out" /> + </method> + + <!-- + @brief This planet's name + --> + <property name="Name" type="s" access="read"/> + + </interface> +</node> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/include/sdbus-c++/StandardInterfaces.h new/sdbus-cpp-1.0.0/include/sdbus-c++/StandardInterfaces.h --- old/sdbus-cpp-0.9.0/include/sdbus-c++/StandardInterfaces.h 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/include/sdbus-c++/StandardInterfaces.h 2021-10-25 09:02:37.000000000 +0200 @@ -187,8 +187,8 @@ }; // Adaptors for the above-listed standard D-Bus interfaces are not necessary because the functionality - // is provided by underlying libsystemd implementation. The exception is Properties_adaptor and - // ObjectManager_adaptor, which provide convenience functionality to emit signals. + // is provided by underlying libsystemd implementation. The exception is Properties_adaptor, + // ObjectManager_adaptor and ManagedObject_adaptor, which provide convenience functionality to emit signals. // Adaptor for properties class Properties_adaptor @@ -218,13 +218,22 @@ sdbus::IObject& object_; }; - // Adaptor for object manager + /*! + * @brief Object Manager Convenience Adaptor + * + * Adding this class as _Interfaces.. template parameter of class AdaptorInterfaces + * implements the *GetManagedObjects()* method of the [org.freedesktop.DBus.ObjectManager.GetManagedObjects](https://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager) + * interface. + * + * Note that there can be multiple object managers in a path hierarchy. InterfacesAdded/InterfacesRemoved + * signals are sent from the closest object manager at either the same path or the closest parent path of an object. + */ class ObjectManager_adaptor { static constexpr const char* INTERFACE_NAME = "org.freedesktop.DBus.ObjectManager"; protected: - ObjectManager_adaptor(sdbus::IObject& object) + explicit ObjectManager_adaptor(sdbus::IObject& object) : object_(object) { object_.addObjectManager(); @@ -232,22 +241,66 @@ ~ObjectManager_adaptor() = default; + private: + sdbus::IObject& object_; + }; + + /*! + * @brief Managed Object Convenience Adaptor + * + * Adding this class as _Interfaces.. template parameter of class AdaptorInterfaces + * will extend the resulting object adaptor with emitInterfacesAddedSignal()/emitInterfacesRemovedSignal() + * according to org.freedesktop.DBus.ObjectManager.InterfacesAdded/.InterfacesRemoved. + * + * Note that objects which implement this adaptor require an object manager (e.g via ObjectManager_adaptor) to be + * instantiated on one of it's parent object paths or the same path. InterfacesAdded/InterfacesRemoved + * signals are sent from the closest object manager at either the same path or the closest parent path of an object. + */ + class ManagedObject_adaptor + { + protected: + explicit ManagedObject_adaptor(sdbus::IObject& object) : object_(object) + { + } + + ~ManagedObject_adaptor() = default; + public: + /*! + * @brief Emits InterfacesAdded signal for this object path + * + * See IObject::emitInterfacesAddedSignal(). + */ void emitInterfacesAddedSignal() { object_.emitInterfacesAddedSignal(); } + /*! + * @brief Emits InterfacesAdded signal for this object path + * + * See IObject::emitInterfacesAddedSignal(). + */ void emitInterfacesAddedSignal(const std::vector<std::string>& interfaces) { object_.emitInterfacesAddedSignal(interfaces); } + /*! + * @brief Emits InterfacesRemoved signal for this object path + * + * See IObject::emitInterfacesRemovedSignal(). + */ void emitInterfacesRemovedSignal() { object_.emitInterfacesRemovedSignal(); } + /*! + * @brief Emits InterfacesRemoved signal for this object path + * + * See IObject::emitInterfacesRemovedSignal(). + */ void emitInterfacesRemovedSignal(const std::vector<std::string>& interfaces) { object_.emitInterfacesRemovedSignal(interfaces); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/AdaptorAndProxy_test.cpp new/sdbus-cpp-1.0.0/tests/integrationtests/AdaptorAndProxy_test.cpp --- old/sdbus-cpp-0.9.0/tests/integrationtests/AdaptorAndProxy_test.cpp 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/AdaptorAndProxy_test.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -57,12 +57,12 @@ TEST(AdaptorAndProxy, CanBeConstructedSuccesfully) { auto connection = sdbus::createConnection(); - connection->requestName(INTERFACE_NAME); + connection->requestName(BUS_NAME); ASSERT_NO_THROW(TestAdaptor adaptor(*connection)); - ASSERT_NO_THROW(TestProxy proxy(INTERFACE_NAME, OBJECT_PATH)); + ASSERT_NO_THROW(TestProxy proxy(BUS_NAME, OBJECT_PATH)); - connection->releaseName(INTERFACE_NAME); + connection->releaseName(BUS_NAME); } // Methods @@ -260,7 +260,7 @@ std::atomic<int> startedCount{}; auto call = [&](uint32_t param) { - TestProxy proxy{INTERFACE_NAME, OBJECT_PATH}; + TestProxy proxy{BUS_NAME, OBJECT_PATH}; ++startedCount; while (!invoke) ; auto result = proxy.doOperationAsync(param); @@ -283,7 +283,7 @@ std::atomic<int> startedCount{}; auto call = [&]() { - TestProxy proxy{INTERFACE_NAME, OBJECT_PATH}; + TestProxy proxy{BUS_NAME, OBJECT_PATH}; ++startedCount; while (!invoke) ; @@ -403,7 +403,7 @@ TEST_F(SdbusTestObject, FailsCallingMethodOnNonexistentObject) { - TestProxy proxy(INTERFACE_NAME, "/sdbuscpp/path/that/does/not/exist"); + TestProxy proxy(BUS_NAME, "/sdbuscpp/path/that/does/not/exist"); ASSERT_THROW(proxy.getInt(), sdbus::Error); } @@ -440,8 +440,8 @@ TEST_F(SdbusTestObject, EmitsSimpleSignalToMultipleProxiesSuccesfully) { - auto proxy1 = std::make_unique<TestProxy>(*s_connection, INTERFACE_NAME, OBJECT_PATH); - auto proxy2 = std::make_unique<TestProxy>(*s_connection, INTERFACE_NAME, OBJECT_PATH); + auto proxy1 = std::make_unique<TestProxy>(*s_connection, BUS_NAME, OBJECT_PATH); + auto proxy2 = std::make_unique<TestProxy>(*s_connection, BUS_NAME, OBJECT_PATH); m_adaptor->emitSimpleSignal(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/DBusAsyncMethodsTests.cpp new/sdbus-cpp-1.0.0/tests/integrationtests/DBusAsyncMethodsTests.cpp --- old/sdbus-cpp-0.9.0/tests/integrationtests/DBusAsyncMethodsTests.cpp 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/DBusAsyncMethodsTests.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -93,7 +93,7 @@ std::atomic<int> startedCount{}; auto call = [&](uint32_t param) { - TestProxy proxy{INTERFACE_NAME, OBJECT_PATH}; + TestProxy proxy{BUS_NAME, OBJECT_PATH}; ++startedCount; while (!invoke) ; auto result = proxy.doOperationAsync(param); @@ -116,7 +116,7 @@ std::atomic<int> startedCount{}; auto call = [&]() { - TestProxy proxy{INTERFACE_NAME, OBJECT_PATH}; + TestProxy proxy{BUS_NAME, OBJECT_PATH}; ++startedCount; while (!invoke) ; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/DBusConnectionTests.cpp new/sdbus-cpp-1.0.0/tests/integrationtests/DBusConnectionTests.cpp --- old/sdbus-cpp-0.9.0/tests/integrationtests/DBusConnectionTests.cpp 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/DBusConnectionTests.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -54,7 +54,7 @@ { auto connection = sdbus::createConnection(); - ASSERT_NO_THROW(connection->requestName(INTERFACE_NAME)) + ASSERT_NO_THROW(connection->requestName(BUS_NAME)) << "Perhaps you've forgotten to copy `org.sdbuscpp.integrationtests.conf` file to `/etc/dbus-1/system.d` directory before running the tests?"; } @@ -68,8 +68,8 @@ { auto connection = sdbus::createConnection(); - connection->requestName(INTERFACE_NAME); - ASSERT_NO_THROW(connection->releaseName(INTERFACE_NAME)); + connection->requestName(BUS_NAME); + ASSERT_NO_THROW(connection->releaseName(BUS_NAME)); } TEST(Connection, CannotReleaseNonrequestedName) @@ -81,7 +81,7 @@ TEST(Connection, CanEnterAndLeaveEventLoop) { auto connection = sdbus::createConnection(); - connection->requestName(INTERFACE_NAME); + connection->requestName(BUS_NAME); std::thread t([&](){ connection->enterEventLoop(); }); connection->leaveEventLoop(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/DBusGeneralTests.cpp new/sdbus-cpp-1.0.0/tests/integrationtests/DBusGeneralTests.cpp --- old/sdbus-cpp-0.9.0/tests/integrationtests/DBusGeneralTests.cpp 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/DBusGeneralTests.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -47,8 +47,8 @@ TEST(AdaptorAndProxy, CanBeConstructedSuccesfully) { auto connection = sdbus::createConnection(); - connection->requestName(INTERFACE_NAME); + connection->requestName(BUS_NAME); - ASSERT_NO_THROW(TestAdaptor adaptor(*connection)); - ASSERT_NO_THROW(TestProxy proxy(INTERFACE_NAME, OBJECT_PATH)); + ASSERT_NO_THROW(TestAdaptor adaptor(*connection, OBJECT_PATH)); + ASSERT_NO_THROW(TestProxy proxy(BUS_NAME, OBJECT_PATH)); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/DBusMethodsTests.cpp new/sdbus-cpp-1.0.0/tests/integrationtests/DBusMethodsTests.cpp --- old/sdbus-cpp-0.9.0/tests/integrationtests/DBusMethodsTests.cpp 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/DBusMethodsTests.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -227,7 +227,7 @@ TEST_F(SdbusTestObject, FailsCallingMethodOnNonexistentObject) { - TestProxy proxy(INTERFACE_NAME, "/sdbuscpp/path/that/does/not/exist"); + TestProxy proxy(BUS_NAME, "/sdbuscpp/path/that/does/not/exist"); ASSERT_THROW(proxy.getInt(), sdbus::Error); } @@ -258,13 +258,13 @@ #if LIBSYSTEMD_VERSION>=240 TEST_F(SdbusTestObject, CanSetGeneralMethodTimeoutWithLibsystemdVersionGreaterThan239) { - s_connection->setMethodCallTimeout(5000000); - ASSERT_THAT(s_connection->getMethodCallTimeout(), Eq(5000000)); + s_adaptorConnection->setMethodCallTimeout(5000000); + ASSERT_THAT(s_adaptorConnection->getMethodCallTimeout(), Eq(5000000)); } #else TEST_F(SdbusTestObject, CannotSetGeneralMethodTimeoutWithLibsystemdVersionLessThan240) { - ASSERT_THROW(s_connection->setMethodCallTimeout(5000000), sdbus::Error); - ASSERT_THROW(s_connection->getMethodCallTimeout(), sdbus::Error); + ASSERT_THROW(s_adaptorConnection->setMethodCallTimeout(5000000), sdbus::Error); + ASSERT_THROW(s_adaptorConnection->getMethodCallTimeout(), sdbus::Error); } #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/DBusSignalsTests.cpp new/sdbus-cpp-1.0.0/tests/integrationtests/DBusSignalsTests.cpp --- old/sdbus-cpp-0.9.0/tests/integrationtests/DBusSignalsTests.cpp 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/DBusSignalsTests.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -58,8 +58,8 @@ TEST_F(SdbusTestObject, EmitsSimpleSignalToMultipleProxiesSuccesfully) { - auto proxy1 = std::make_unique<TestProxy>(*s_connection, INTERFACE_NAME, OBJECT_PATH); - auto proxy2 = std::make_unique<TestProxy>(*s_connection, INTERFACE_NAME, OBJECT_PATH); + auto proxy1 = std::make_unique<TestProxy>(*s_adaptorConnection, BUS_NAME, OBJECT_PATH); + auto proxy2 = std::make_unique<TestProxy>(*s_adaptorConnection, BUS_NAME, OBJECT_PATH); m_adaptor->emitSimpleSignal(); @@ -70,9 +70,9 @@ TEST_F(SdbusTestObject, ProxyDoesNotReceiveSignalFromOtherBusName) { - auto otherBusName = INTERFACE_NAME + "2"; + auto otherBusName = BUS_NAME + "2"; auto connection2 = sdbus::createConnection(otherBusName); - auto adaptor2 = std::make_unique<TestAdaptor>(*connection2); + auto adaptor2 = std::make_unique<TestAdaptor>(*connection2, OBJECT_PATH); adaptor2->emitSimpleSignal(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/DBusStandardInterfacesTests.cpp new/sdbus-cpp-1.0.0/tests/integrationtests/DBusStandardInterfacesTests.cpp --- old/sdbus-cpp-0.9.0/tests/integrationtests/DBusStandardInterfacesTests.cpp 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/DBusStandardInterfacesTests.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -143,32 +143,31 @@ TEST_F(SdbusTestObject, GetsZeroManagedObjectsIfHasNoSubPathObjects) { - const auto objectsInterfacesAndProperties = m_proxy->GetManagedObjects(); + m_adaptor.reset(); + const auto objectsInterfacesAndProperties = m_objectManagerProxy->GetManagedObjects(); ASSERT_THAT(objectsInterfacesAndProperties, SizeIs(0)); } TEST_F(SdbusTestObject, GetsManagedObjectsSuccessfully) { - auto subObject1 = sdbus::createObject(*s_connection, "/sub/path1"); - subObject1->registerProperty("aProperty1").onInterface("org.sdbuscpp.integrationtests.iface1").withGetter([]{return uint8_t{123};}); - subObject1->finishRegistration(); - auto subObject2 = sdbus::createObject(*s_connection, "/sub/path2"); - subObject2->registerProperty("aProperty2").onInterface("org.sdbuscpp.integrationtests.iface2").withGetter([]{return "hi";}); - subObject2->finishRegistration(); - - const auto objectsInterfacesAndProperties = m_proxy->GetManagedObjects(); + auto adaptor2 = std::make_unique<TestAdaptor>(*s_adaptorConnection, OBJECT_PATH_2); + const auto objectsInterfacesAndProperties = m_objectManagerProxy->GetManagedObjects(); ASSERT_THAT(objectsInterfacesAndProperties, SizeIs(2)); - EXPECT_THAT(objectsInterfacesAndProperties.at("/sub/path1").at("org.sdbuscpp.integrationtests.iface1").at("aProperty1").get<uint8_t>(), Eq(123)); - EXPECT_THAT(objectsInterfacesAndProperties.at("/sub/path2").at("org.sdbuscpp.integrationtests.iface2").at("aProperty2").get<std::string>(), Eq("hi")); + EXPECT_THAT(objectsInterfacesAndProperties.at(OBJECT_PATH) + .at(org::sdbuscpp::integrationtests_adaptor::INTERFACE_NAME) + .at("action").get<uint32_t>(), Eq(DEFAULT_ACTION_VALUE)); + EXPECT_THAT(objectsInterfacesAndProperties.at(OBJECT_PATH_2) + .at(org::sdbuscpp::integrationtests_adaptor::INTERFACE_NAME) + .at("action").get<uint32_t>(), Eq(DEFAULT_ACTION_VALUE)); } TEST_F(SdbusTestObject, EmitsInterfacesAddedSignalForSelectedObjectInterfaces) { std::atomic<bool> signalReceived{false}; - m_proxy->m_onInterfacesAddedHandler = [&signalReceived]( const sdbus::ObjectPath& objectPath - , const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties ) + m_objectManagerProxy->m_onInterfacesAddedHandler = [&signalReceived]( const sdbus::ObjectPath& objectPath + , const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties ) { EXPECT_THAT(objectPath, Eq(OBJECT_PATH)); EXPECT_THAT(interfacesAndProperties, SizeIs(1)); @@ -198,8 +197,8 @@ TEST_F(SdbusTestObject, EmitsInterfacesAddedSignalForAllObjectInterfaces) { std::atomic<bool> signalReceived{false}; - m_proxy->m_onInterfacesAddedHandler = [&signalReceived]( const sdbus::ObjectPath& objectPath - , const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties ) + m_objectManagerProxy->m_onInterfacesAddedHandler = [&signalReceived]( const sdbus::ObjectPath& objectPath + , const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties ) { EXPECT_THAT(objectPath, Eq(OBJECT_PATH)); EXPECT_THAT(interfacesAndProperties, SizeIs(5)); // INTERFACE_NAME + 4 standard interfaces @@ -228,8 +227,8 @@ TEST_F(SdbusTestObject, EmitsInterfacesRemovedSignalForSelectedObjectInterfaces) { std::atomic<bool> signalReceived{false}; - m_proxy->m_onInterfacesRemovedHandler = [&signalReceived]( const sdbus::ObjectPath& objectPath - , const std::vector<std::string>& interfaces ) + m_objectManagerProxy->m_onInterfacesRemovedHandler = [&signalReceived]( const sdbus::ObjectPath& objectPath + , const std::vector<std::string>& interfaces ) { EXPECT_THAT(objectPath, Eq(OBJECT_PATH)); ASSERT_THAT(interfaces, SizeIs(1)); @@ -245,8 +244,8 @@ TEST_F(SdbusTestObject, EmitsInterfacesRemovedSignalForAllObjectInterfaces) { std::atomic<bool> signalReceived{false}; - m_proxy->m_onInterfacesRemovedHandler = [&signalReceived]( const sdbus::ObjectPath& objectPath - , const std::vector<std::string>& interfaces ) + m_objectManagerProxy->m_onInterfacesRemovedHandler = [&signalReceived]( const sdbus::ObjectPath& objectPath + , const std::vector<std::string>& interfaces ) { EXPECT_THAT(objectPath, Eq(OBJECT_PATH)); ASSERT_THAT(interfaces, SizeIs(5)); // INTERFACE_NAME + 4 standard interfaces diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/Defs.h new/sdbus-cpp-1.0.0/tests/integrationtests/Defs.h --- old/sdbus-cpp-0.9.0/tests/integrationtests/Defs.h 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/Defs.h 2021-10-25 09:02:37.000000000 +0200 @@ -32,7 +32,10 @@ namespace sdbus { namespace test { const std::string INTERFACE_NAME{"org.sdbuscpp.integrationtests"}; -const std::string OBJECT_PATH{"/"}; +const std::string BUS_NAME = INTERFACE_NAME; +const std::string MANAGER_PATH {"/org/sdbuscpp/integrationtests"}; +const std::string OBJECT_PATH {"/org/sdbuscpp/integrationtests/ObjectA1"}; +const std::string OBJECT_PATH_2{"/org/sdbuscpp/integrationtests/ObjectB1"}; constexpr const uint8_t UINT8_VALUE{1}; constexpr const int16_t INT16_VALUE{21}; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/TestAdaptor.cpp new/sdbus-cpp-1.0.0/tests/integrationtests/TestAdaptor.cpp --- old/sdbus-cpp-0.9.0/tests/integrationtests/TestAdaptor.cpp 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/TestAdaptor.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -31,8 +31,8 @@ namespace sdbus { namespace test { -TestAdaptor::TestAdaptor(sdbus::IConnection& connection) : - AdaptorInterfaces(connection, OBJECT_PATH) +TestAdaptor::TestAdaptor(sdbus::IConnection& connection, const std::string& path) : + AdaptorInterfaces(connection, path) { registerAdaptor(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/TestAdaptor.h new/sdbus-cpp-1.0.0/tests/integrationtests/TestAdaptor.h --- old/sdbus-cpp-0.9.0/tests/integrationtests/TestAdaptor.h 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/TestAdaptor.h 2021-10-25 09:02:37.000000000 +0200 @@ -32,15 +32,31 @@ #include <thread> #include <chrono> #include <atomic> +#include <utility> namespace sdbus { namespace test { +class ObjectManagerTestAdaptor final : public sdbus::AdaptorInterfaces< sdbus::ObjectManager_adaptor > +{ +public: + ObjectManagerTestAdaptor(sdbus::IConnection& connection, std::string path) : + AdaptorInterfaces(connection, std::move(path)) + { + registerAdaptor(); + } + + ~ObjectManagerTestAdaptor() + { + unregisterAdaptor(); + } +}; + class TestAdaptor final : public sdbus::AdaptorInterfaces< org::sdbuscpp::integrationtests_adaptor , sdbus::Properties_adaptor - , sdbus::ObjectManager_adaptor > + , sdbus::ManagedObject_adaptor > { public: - TestAdaptor(sdbus::IConnection& connection); + TestAdaptor(sdbus::IConnection& connection, const std::string& path); ~TestAdaptor(); protected: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/TestFixture.cpp new/sdbus-cpp-1.0.0/tests/integrationtests/TestFixture.cpp --- old/sdbus-cpp-0.9.0/tests/integrationtests/TestFixture.cpp 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/TestFixture.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -28,6 +28,7 @@ namespace sdbus { namespace test { -std::unique_ptr<sdbus::IConnection> TestFixture::s_connection = sdbus::createSystemBusConnection(); +std::unique_ptr<sdbus::IConnection> TestFixture::s_adaptorConnection = sdbus::createSystemBusConnection(); +std::unique_ptr<sdbus::IConnection> TestFixture::s_proxyConnection = sdbus::createSystemBusConnection(); }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/TestFixture.h new/sdbus-cpp-1.0.0/tests/integrationtests/TestFixture.h --- old/sdbus-cpp-0.9.0/tests/integrationtests/TestFixture.h 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/TestFixture.h 2021-10-25 09:02:37.000000000 +0200 @@ -46,14 +46,17 @@ public: static void SetUpTestCase() { - s_connection->requestName(INTERFACE_NAME); - s_connection->enterEventLoopAsync(); + s_proxyConnection->enterEventLoopAsync(); + s_adaptorConnection->requestName(BUS_NAME); + s_adaptorConnection->enterEventLoopAsync(); + std::this_thread::sleep_for(std::chrono::milliseconds(50)); // Give time for the proxy connection to start listening to signals } static void TearDownTestCase() { - s_connection->leaveEventLoop(); - s_connection->releaseName(INTERFACE_NAME); + s_adaptorConnection->releaseName(BUS_NAME); + s_adaptorConnection->leaveEventLoop(); + s_proxyConnection->leaveEventLoop(); } template <typename _Fnc> @@ -81,9 +84,11 @@ private: void SetUp() override { - m_adaptor = std::make_unique<TestAdaptor>(*s_connection); - m_proxy = std::make_unique<TestProxy>(INTERFACE_NAME, OBJECT_PATH); - std::this_thread::sleep_for(std::chrono::milliseconds(50)); // Give time for the proxy to start listening to signals + m_objectManagerProxy = std::make_unique<ObjectManagerTestProxy>(*s_proxyConnection, BUS_NAME, MANAGER_PATH); + m_proxy = std::make_unique<TestProxy>(*s_proxyConnection, BUS_NAME, OBJECT_PATH); + + m_objectManagerAdaptor = std::make_unique<ObjectManagerTestAdaptor>(*s_adaptorConnection, MANAGER_PATH); + m_adaptor = std::make_unique<TestAdaptor>(*s_adaptorConnection, OBJECT_PATH); } void TearDown() override @@ -93,8 +98,10 @@ } public: - static std::unique_ptr<sdbus::IConnection> s_connection; - + static std::unique_ptr<sdbus::IConnection> s_adaptorConnection; + static std::unique_ptr<sdbus::IConnection> s_proxyConnection; + std::unique_ptr<ObjectManagerTestAdaptor> m_objectManagerAdaptor; + std::unique_ptr<ObjectManagerTestProxy> m_objectManagerProxy; std::unique_ptr<TestAdaptor> m_adaptor; std::unique_ptr<TestProxy> m_proxy; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/TestProxy.cpp new/sdbus-cpp-1.0.0/tests/integrationtests/TestProxy.cpp --- old/sdbus-cpp-0.9.0/tests/integrationtests/TestProxy.cpp 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/TestProxy.cpp 2021-10-25 09:02:37.000000000 +0200 @@ -92,18 +92,6 @@ m_onPropertiesChangedHandler(interfaceName, changedProperties, invalidatedProperties); } -void TestProxy::onInterfacesAdded(const sdbus::ObjectPath& objectPath, const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties) -{ - if (m_onInterfacesAddedHandler) - m_onInterfacesAddedHandler(objectPath, interfacesAndProperties); -} - -void TestProxy::onInterfacesRemoved(const sdbus::ObjectPath& objectPath, const std::vector<std::string>& interfaces) -{ - if (m_onInterfacesRemovedHandler) - m_onInterfacesRemovedHandler(objectPath, interfaces); -} - void TestProxy::installDoOperationClientSideAsyncReplyHandler(std::function<void(uint32_t res, const sdbus::Error* err)> handler) { m_DoOperationClientSideAsyncReplyHandler = std::move(handler); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tests/integrationtests/TestProxy.h new/sdbus-cpp-1.0.0/tests/integrationtests/TestProxy.h --- old/sdbus-cpp-0.9.0/tests/integrationtests/TestProxy.h 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tests/integrationtests/TestProxy.h 2021-10-25 09:02:37.000000000 +0200 @@ -35,11 +35,41 @@ namespace sdbus { namespace test { +class ObjectManagerTestProxy final : public sdbus::ProxyInterfaces< sdbus::ObjectManager_proxy > +{ +public: + ObjectManagerTestProxy(sdbus::IConnection& connection, std::string destination, std::string objectPath) + : ProxyInterfaces(connection, std::move(destination), std::move(objectPath)) + { + registerProxy(); + } + + ~ObjectManagerTestProxy() + { + unregisterProxy(); + } +protected: + void onInterfacesAdded(const sdbus::ObjectPath& objectPath, const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties) override + { + if (m_onInterfacesAddedHandler) + m_onInterfacesAddedHandler(objectPath, interfacesAndProperties); + } + + void onInterfacesRemoved(const sdbus::ObjectPath& objectPath, const std::vector<std::string>& interfaces) override + { + if (m_onInterfacesRemovedHandler) + m_onInterfacesRemovedHandler(objectPath, interfaces); + } + +public: // for tests + std::function<void(const sdbus::ObjectPath&, const std::map<std::string, std::map<std::string, sdbus::Variant>>&)> m_onInterfacesAddedHandler; + std::function<void(const sdbus::ObjectPath&, const std::vector<std::string>&)> m_onInterfacesRemovedHandler; +}; + class TestProxy final : public sdbus::ProxyInterfaces< org::sdbuscpp::integrationtests_proxy , sdbus::Peer_proxy , sdbus::Introspectable_proxy - , sdbus::Properties_proxy - , sdbus::ObjectManager_proxy > + , sdbus::Properties_proxy > { public: TestProxy(std::string destination, std::string objectPath); @@ -58,9 +88,6 @@ void onPropertiesChanged( const std::string& interfaceName , const std::map<std::string, sdbus::Variant>& changedProperties , const std::vector<std::string>& invalidatedProperties ) override; - void onInterfacesAdded( const sdbus::ObjectPath& objectPath - , const std::map<std::string, std::map<std::string, sdbus::Variant>>& interfacesAndProperties) override; - void onInterfacesRemoved( const sdbus::ObjectPath& objectPath, const std::vector<std::string>& interfaces) override; public: void installDoOperationClientSideAsyncReplyHandler(std::function<void(uint32_t res, const sdbus::Error* err)> handler); @@ -85,8 +112,6 @@ std::function<void(uint32_t res, const sdbus::Error* err)> m_DoOperationClientSideAsyncReplyHandler; std::function<void(const std::string&, const std::map<std::string, sdbus::Variant>&, const std::vector<std::string>&)> m_onPropertiesChangedHandler; - std::function<void(const sdbus::ObjectPath&, const std::map<std::string, std::map<std::string, sdbus::Variant>>&)> m_onInterfacesAddedHandler; - std::function<void(const sdbus::ObjectPath&, const std::vector<std::string>&)> m_onInterfacesRemovedHandler; const Message* m_signalMsg{}; std::string m_signalMemberName; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/sdbus-cpp-0.9.0/tools/CMakeLists.txt new/sdbus-cpp-1.0.0/tools/CMakeLists.txt --- old/sdbus-cpp-0.9.0/tools/CMakeLists.txt 2021-10-15 15:20:46.000000000 +0200 +++ new/sdbus-cpp-1.0.0/tools/CMakeLists.txt 2021-10-25 09:02:37.000000000 +0200 @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.5) -project(sdbus-c++-tools VERSION 0.8.3) +project(sdbus-c++-tools VERSION 1.0.0) include(GNUInstallDirs)