20 #include "gateway/dbus/dbusgateway.h" 21 #include "gateway/gatewayparsererror.h" 25 DBusGateway::DBusGateway(
const std::string &gatewayDir,
26 std::shared_ptr<ContainerAbstractInterface> container) :
27 Gateway(ID, container),
28 sessionBus(DBusGatewayInstance::ProxyType::SessionProxy, gatewayDir, container),
29 systemBus(DBusGatewayInstance::ProxyType::SystemProxy, gatewayDir, container)
33 DBusGateway::~DBusGateway()
40 log_debug() <<
"Setting config for dbus session bus";
41 bool sessionBusParseResult = sessionBus.setConfig(config);
43 log_debug() <<
"Setting config for dbus system bus";
44 bool systemBusParseResult = systemBus.setConfig(config);
46 if (!sessionBusParseResult && !systemBusParseResult) {
47 log_error() <<
"Neither session nor system bus could use the given config";
51 log_error() <<
"Bad config in one of the gateway configurations";
60 bool sessionBusActivationResult =
false;
61 if (sessionBus.isConfigured()) {
62 log_debug() <<
"Activating dbus session bus";
63 sessionBusActivationResult = sessionBus.activate();
66 bool systemBusActivationResult =
false;
67 if (systemBus.isConfigured()) {
68 log_debug() <<
"Activating dbus system bus";
69 sessionBusActivationResult = systemBus.activate();
72 if (!sessionBusActivationResult && !systemBusActivationResult) {
73 log_error() <<
"Neither dbus session bus nor dbus system bus could be activated";
81 bool sessionBusTeardownResult;
82 if (sessionBus.isActivated()) {
83 log_debug() <<
"Tearing down dbus session bus";
84 sessionBusTeardownResult = sessionBus.teardown();
86 sessionBusTeardownResult =
false;
89 bool systemBusTeardownResult;
90 if (systemBus.isActivated()) {
91 log_debug() <<
"Tearing down dbus system bus";
92 systemBusTeardownResult = systemBus.teardown();
94 systemBusTeardownResult =
false;
97 if (!sessionBusTeardownResult && !systemBusTeardownResult) {
98 log_error() <<
"Neither dbus session bus nor dbus system bus could be tore down";
107 return sessionBus.isConfigured() || systemBus.isConfigured();
112 return sessionBus.isActivated() || systemBus.isActivated();
virtual bool isActivated() override
Is the gateway activated or not?
virtual bool isConfigured() override
Is the gateway configured or not?
virtual bool teardown() override
Restore system to the state prior to launching of gateway.
virtual bool setConfig(const json_t *config) override
Sets config for both dbus session instances.
Developers guide to adding a config item:
virtual bool activate() override
Activates both dbus session instances.