mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-14 14:46:12 -04:00
Add an ObjectManager instance at / for both system and session bus connections.
This commit is contained in:
@@ -13,8 +13,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include <cassert>
|
||||
#include <memory>
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
|
||||
#include <sdbus-c++/IConnection.h>
|
||||
|
||||
@@ -27,9 +27,13 @@ static std::unique_ptr<sdbus::IConnection> global_system_bus_connection =
|
||||
nullptr;
|
||||
static std::unique_ptr<sdbus::IConnection> global_default_bus_connection =
|
||||
nullptr;
|
||||
static std::unique_ptr<RootObjectManager> system_root_object_manager = nullptr;
|
||||
static std::unique_ptr<RootObjectManager> default_root_object_manager = nullptr;
|
||||
static absl::once_flag bus_connection_init_;
|
||||
|
||||
static void disconnectBus() {
|
||||
system_root_object_manager = nullptr;
|
||||
default_root_object_manager = nullptr;
|
||||
global_system_bus_connection = nullptr;
|
||||
global_default_bus_connection = nullptr;
|
||||
}
|
||||
@@ -39,6 +43,11 @@ static void initBusConnections() {
|
||||
global_system_bus_connection->enterEventLoopAsync();
|
||||
global_default_bus_connection = sdbus::createDefaultBusConnection();
|
||||
global_default_bus_connection->enterEventLoopAsync();
|
||||
system_root_object_manager =
|
||||
std::make_unique<RootObjectManager>(*global_system_bus_connection);
|
||||
default_root_object_manager =
|
||||
std::make_unique<RootObjectManager>(*global_default_bus_connection);
|
||||
|
||||
atexit(disconnectBus);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
#ifndef PLATFORM_IMPL_LINUX_DBUS_H_
|
||||
#define PLATFORM_IMPL_LINUX_DBUS_H_
|
||||
|
||||
#include <sdbus-c++/AdaptorInterfaces.h>
|
||||
#include <sdbus-c++/IConnection.h>
|
||||
#include <sdbus-c++/StandardInterfaces.h>
|
||||
#include "internal/platform/logging.h"
|
||||
|
||||
#define DBUS_LOG_METHOD_CALL_ERROR(p, m, e) \
|
||||
@@ -46,6 +48,17 @@ namespace nearby {
|
||||
namespace linux {
|
||||
extern sdbus::IConnection &getSystemBusConnection();
|
||||
extern sdbus::IConnection &getDefaultBusConnection();
|
||||
class RootObjectManager final
|
||||
: public sdbus::AdaptorInterfaces<sdbus::ObjectManager_adaptor,
|
||||
sdbus::Properties_adaptor> {
|
||||
public:
|
||||
explicit RootObjectManager(sdbus::IConnection &system_bus)
|
||||
: AdaptorInterfaces(system_bus, "/") {
|
||||
registerAdaptor();
|
||||
}
|
||||
~RootObjectManager() { unregisterAdaptor(); }
|
||||
};
|
||||
|
||||
} // namespace linux
|
||||
} // namespace nearby
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user