softwarecontainer
0.18.0-739e8d7 2017-05-04
|
DBus Gateway takes care of spawning and killing the DBus proxies. More...
#include <dbusgatewayinstance.h>
Public Types | |
enum | ProxyType { SessionProxy, SystemProxy } |
enum | GatewayState : unsigned int { CREATED, CONFIGURED, ACTIVATED } |
Public Member Functions | |
DBusGatewayInstance (ProxyType type, const std::string &gatewayDir, std::shared_ptr< ContainerAbstractInterface > container) | |
Spawn the proxy and use the supplied path for the socket. More... | |
virtual bool | readConfigElement (const json_t *element) override |
Gateway specific parsing of config elements. More... | |
virtual bool | activateGateway () |
Implements Gateway::activateGateway. More... | |
virtual bool | teardownGateway () override |
Implements Gateway::teardownGateway. More... | |
virtual std::string | id () const |
Returns the ID of the gateway. More... | |
virtual bool | setConfig (const json_t *config) |
Configure this gateway according to the supplied JSON configuration string. More... | |
virtual bool | activate () |
Applies any configuration set by setConfig() More... | |
virtual bool | teardown () |
Restore system to the state prior to launching of gateway. More... | |
virtual bool | isConfigured () |
Is the gateway configured or not? More... | |
virtual bool | isActivated () |
Is the gateway activated or not? More... | |
Static Public Attributes | |
static constexpr const char * | ID |
static constexpr const char * | SESSION_CONFIG |
static constexpr const char * | SYSTEM_CONFIG |
Protected Member Functions | |
std::shared_ptr< ContainerAbstractInterface > | getContainer () |
Get a handle to the associated container. More... | |
bool | setEnvironmentVariable (const std::string &variable, const std::string &value) |
Set an environment variable in the associated container. More... | |
Protected Attributes | |
bool | m_activatedOnce |
DBus Gateway takes care of spawning and killing the DBus proxies.
This module requires the 'dbus-proxy' binary to be available in the $PATH of the user executing softwarecontainer.
Definition at line 32 of file dbusgatewayinstance.h.
softwarecontainer::DBusGatewayInstance::DBusGatewayInstance | ( | ProxyType | type, |
const std::string & | gatewayDir, | ||
std::shared_ptr< ContainerAbstractInterface > | container | ||
) |
Spawn the proxy and use the supplied path for the socket.
type | SessionProxy or SystemProxy |
Definition at line 36 of file dbusgatewayinstance.cpp.
References softwarecontainer::Gateway::id(), softwarecontainer::Gateway::isActivated(), and softwarecontainer::Gateway::teardown().
|
overridevirtual |
Gateway specific parsing of config elements.
All gateways implement this method in order to provide gateway specific parsing of the configuration content.
element | A JSON configuration item. |
Implements softwarecontainer::Gateway.
Definition at line 81 of file dbusgatewayinstance.cpp.
|
virtual |
Implements Gateway::activateGateway.
Starts the dbus-proxy binary and feeds it the configuration set in setConfig(). This function will also set up the correct environment variables (DBUS_SESSION_BUS_ADDRESS when proxying the session bus, or DBUS_SYSTEM_BUS_ADDRESS when proxying the system bus).
This function requires a config to have been set using setConfig().
This function requires the 'dbus-proxy' binary to be available in $PATH
Implements softwarecontainer::Gateway.
Definition at line 96 of file dbusgatewayinstance.cpp.
References softwarecontainer::Gateway::getContainer().
|
overridevirtual |
Implements Gateway::teardownGateway.
This function will clean up processes launched and file descriptors opened during the lifetime of the gatway. Specifically it will close the connection to the dbus-proxy, and close the stdin and stdout pipes opened to dbus-proxy.
Implements softwarecontainer::Gateway.
Definition at line 221 of file dbusgatewayinstance.cpp.
|
virtualinherited |
Returns the ID of the gateway.
Definition at line 36 of file gateway.cpp.
Referenced by softwarecontainer::Gateway::activate(), DBusGatewayInstance(), softwarecontainer::Gateway::setConfig(), and softwarecontainer::Gateway::teardown().
|
virtualinherited |
Configure this gateway according to the supplied JSON configuration string.
config | JSON string containing gateway-specific JSON configuration |
config
was successfully parsed, false otherwiseGatewayError | If called on an already activated gateway. |
Reimplemented in softwarecontainer::DBusGateway.
Definition at line 41 of file gateway.cpp.
References softwarecontainer::Gateway::id(), and softwarecontainer::Gateway::readConfigElement().
|
virtualinherited |
Applies any configuration set by setConfig()
GatewayError | If called on an already activated gateway, or if the gateway has not been previously configured, or if there is not container instance set. |
Reimplemented in softwarecontainer::DBusGateway.
Definition at line 78 of file gateway.cpp.
References softwarecontainer::Gateway::id().
|
virtualinherited |
Restore system to the state prior to launching of gateway.
Any cleanup code (removal of files, virtual interfaces, etc) should be placed here.
GatewayError | If called on a non activated gateway. |
Reimplemented in softwarecontainer::DBusGateway.
Definition at line 103 of file gateway.cpp.
References softwarecontainer::Gateway::id().
Referenced by DBusGatewayInstance().
|
virtualinherited |
Is the gateway configured or not?
Reimplemented in softwarecontainer::DBusGateway.
Definition at line 134 of file gateway.cpp.
|
virtualinherited |
Is the gateway activated or not?
Dynamic gateways will return true if they have been activated at least once. Non-dynamic gateways will return true if they are in state ACTIVATED
Reimplemented in softwarecontainer::DBusGateway.
Definition at line 139 of file gateway.cpp.
Referenced by DBusGatewayInstance().
|
protectedinherited |
Get a handle to the associated container.
GatewayError | If called before setContainer() has been called. |
Definition at line 128 of file gateway.cpp.
Referenced by softwarecontainer::NetworkGateway::activateGateway(), activateGateway(), softwarecontainer::WaylandGateway::readConfigElement(), and softwarecontainer::NetworkGateway::teardownGateway().
|
protectedinherited |
Set an environment variable in the associated container.