mConnection.call(vasum::api::host::METHOD_REVOKE_DEVICE, argIn);
}
-void HostDbusConnection::callGetZoneDbuses(vasum::api::Dbuses& argOut)
+void HostDbusConnection::callGetZoneConnections(vasum::api::Connections& argOut)
{
- mConnection.call(vasum::api::host::METHOD_GET_ZONE_DBUSES, argOut);
+ mConnection.call(vasum::api::host::METHOD_GET_ZONE_CONNECTIONS, argOut);
}
HostDbusConnection::SubscriptionId
-HostDbusConnection::subscribeZoneDbusState(const ZoneDbusStateCallback& callback)
+HostDbusConnection::subscribeZoneConnectionState(const ZoneConnectionStateCallback& callback)
{
- return mConnection.signalSubscribe<vasum::api::DbusState>(
- vasum::api::host::SIGNAL_ZONE_DBUS_STATE, callback);
+ return mConnection.signalSubscribe<vasum::api::ConnectionState>(
+ vasum::api::host::SIGNAL_ZONE_CONNECTION_STATE, callback);
}
void HostDbusConnection::unsubscribe(const SubscriptionId& id)
class HostDbusConnection {
public:
typedef unsigned int SubscriptionId;
- typedef std::function<void(const vasum::api::DbusState&)> ZoneDbusStateCallback;
+ typedef std::function<void(const vasum::api::ConnectionState&)> ZoneConnectionStateCallback;
HostDbusConnection();
void callUnlockZone(const vasum::api::ZoneId& argIn);
void callGrantDevice(const vasum::api::GrantDeviceIn& argIn);
void callRevokeDevice(const vasum::api::RevokeDeviceIn& argIn);
- void callGetZoneDbuses(vasum::api::Dbuses& argOut);
- SubscriptionId subscribeZoneDbusState(const ZoneDbusStateCallback& callback);
+ void callGetZoneConnections(vasum::api::Connections& argOut);
+ SubscriptionId subscribeZoneConnectionState(const ZoneConnectionStateCallback& callback);
void unsubscribe(const SubscriptionId& id);
private:
DbusConnection mConnection;
mConnection.call(vasum::api::host::METHOD_REVOKE_DEVICE, argIn);
}
-void HostIPCConnection::callGetZoneDbuses(vasum::api::Dbuses& argOut)
+void HostIPCConnection::callGetZoneConnections(vasum::api::Connections& argOut)
{
- mConnection.call(vasum::api::host::METHOD_GET_ZONE_DBUSES, argOut);
+ mConnection.call(vasum::api::host::METHOD_GET_ZONE_CONNECTIONS, argOut);
}
HostIPCConnection::SubscriptionId
-HostIPCConnection::subscribeZoneDbusState(const ZoneDbusStateCallback& callback)
+HostIPCConnection::subscribeZoneConnectionState(const ZoneConnectionStateCallback& callback)
{
- mConnection.subscribe<ZoneDbusStateCallback, vasum::api::DbusState>(
- vasum::api::host::SIGNAL_ZONE_DBUS_STATE, callback);
- return vasum::api::host::SIGNAL_ZONE_DBUS_STATE;
+ mConnection.subscribe<ZoneConnectionStateCallback, vasum::api::ConnectionState>(
+ vasum::api::host::SIGNAL_ZONE_CONNECTION_STATE, callback);
+ return vasum::api::host::SIGNAL_ZONE_CONNECTION_STATE;
}
void HostIPCConnection::unsubscribe(const SubscriptionId& id)
class HostIPCConnection {
public:
typedef unsigned int SubscriptionId;
- typedef std::function<void(const vasum::api::DbusState&)> ZoneDbusStateCallback;
+ typedef std::function<void(const vasum::api::ConnectionState&)> ZoneConnectionStateCallback;
void createSystem();
void callGetZoneIds(vasum::api::ZoneIds& argOut);
void callUnlockZone(const vasum::api::ZoneId& argIn);
void callGrantDevice(const vasum::api::GrantDeviceIn& argIn);
void callRevokeDevice(const vasum::api::RevokeDeviceIn& argIn);
- void callGetZoneDbuses(vasum::api::Dbuses& argOut);
- SubscriptionId subscribeZoneDbusState(const ZoneDbusStateCallback& callback);
+ void callGetZoneConnections(vasum::api::Connections& argOut);
+ SubscriptionId subscribeZoneConnectionState(const ZoneConnectionStateCallback& callback);
void unsubscribe(const SubscriptionId& id);
private:
assert(values);
return coverException([&] {
- api::Dbuses dbuses;
- mHostClient.callGetZoneDbuses(dbuses);
+ api::Connections dbuses;
+ mHostClient.callGetZoneConnections(dbuses);
convert(dbuses, *keys, *values);
});
}
assert(zoneDbusStateCallback);
return coverException([&] {
- auto onSigal = [=](const api::DbusState& dbus)
+ auto onSigal = [=](const api::ConnectionState& dbus)
{
zoneDbusStateCallback(dbus.first.c_str(),
dbus.second.c_str(),
};
VsmSubscriptionId id;
- id = mHostClient.subscribeZoneDbusState(onSigal);
+ id = mHostClient.subscribeZoneConnectionState(onSigal);
if (subscriptionId) {
*subscriptionId = id;
}
* Zone's D-Bus state change callback function signature.
*
* @param[in] zoneId affected zone id
- * @param[in] dbusAddress new D-Bus address
+ * @param[in] address new D-Bus address
* @param data custom user's data pointer passed to vsm_add_state_callback() function
*/
typedef void (*VsmZoneDbusStateCallback)(const char* zoneId,
- const char* dbusAddress,
+ const char* address,
void* data);
/**
typedef api::StringPair CreateZoneIn;
typedef api::StringPair RevokeDeviceIn;
typedef api::StringPair DestroyNetDevIn;
-typedef api::StringPair DbusState;
+typedef api::StringPair ConnectionState;
typedef api::StringPair NotifActiveZoneIn;
typedef api::StringPair FileMoveRequestIn;
typedef api::VectorOfStrings ZoneIds;
typedef api::VectorOfStrings Declarations;
typedef api::VectorOfStrings NetDevList;
-typedef api::VectorOfStringPairs Dbuses;
+typedef api::VectorOfStringPairs Connections;
typedef api::VectorOfStringPairs GetNetDevAttrs;
struct ZoneInfoOut {
"vt" : 0,
"shutdownTimeout" : 10,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : false,
+ "enableZoneConnection" : false,
"runMountPoint" : "~NAME~/run",
"provisions" : [],
"permittedToSend" : [ "/tmp/.*" ],
mProxyCallCallback = callback;
}
-void HostDbusConnection::setGetZoneDbusesCallback(const GetZoneDbusesCallback& callback)
+void HostDbusConnection::setGetZoneConnectionsCallback(const GetZoneConnectionsCallback& callback)
{
- mGetZoneDbusesCallback = callback;
+ mGetZoneConnectionsCallback = callback;
}
void HostDbusConnection::setGetZoneIdsCallback(const GetZoneIdsCallback& callback)
return;
}
- if (methodName == api::host::METHOD_GET_ZONE_DBUSES) {
- if (mGetZoneDbusesCallback) {
- auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Dbuses>>(result);
- mGetZoneDbusesCallback(rb);
+ if (methodName == api::host::METHOD_GET_ZONE_CONNECTIONS) {
+ if (mGetZoneConnectionsCallback) {
+ auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Connections>>(result);
+ mGetZoneConnectionsCallback(rb);
}
return;
}
callback);
}
-void HostDbusConnection::signalZoneDbusState(const api::DbusState& state)
+void HostDbusConnection::signalZoneConnectionState(const api::ConnectionState& state)
{
GVariant* parameters = g_variant_new("(ss)", state.first.c_str(), state.second.c_str());
mDbusConnection->emitSignal(api::host::OBJECT_PATH,
api::host::INTERFACE,
- api::host::SIGNAL_ZONE_DBUS_STATE,
+ api::host::SIGNAL_ZONE_CONNECTION_STATE,
parameters);
}
dbus::MethodResultBuilder::Pointer result
)> ProxyCallCallback;
typedef std::function<void(api::MethodResultBuilder::Pointer result
- )> GetZoneDbusesCallback;
+ )> GetZoneConnectionsCallback;
typedef std::function<void(api::MethodResultBuilder::Pointer result
)> GetZoneIdsCallback;
typedef std::function<void(api::MethodResultBuilder::Pointer result
void setProxyCallCallback(const ProxyCallCallback& callback);
/**
- * Register get zone dbuses callback
+ * Register get zone connections callback
*/
- void setGetZoneDbusesCallback(const GetZoneDbusesCallback& callback);
+ void setGetZoneConnectionsCallback(const GetZoneConnectionsCallback& callback);
/**
* Send signal describing dbus address state change
*/
- void signalZoneDbusState(const api::DbusState& state);
+ void signalZoneConnectionState(const api::ConnectionState& state);
/**
* Register a callback called to get a list of zone ids
bool mNameAcquired;
bool mNameLost;
ProxyCallCallback mProxyCallCallback;
- GetZoneDbusesCallback mGetZoneDbusesCallback;
+ GetZoneConnectionsCallback mGetZoneConnectionsCallback;
GetZoneIdsCallback mGetZoneIdsCallback;
GetActiveZoneIdCallback mGetActiveZoneIdCallback;
GetZoneInfoCallback mGetZoneInfoCallback;
const std::string ERROR_ZONE_NOT_RUNNING = "org.tizen.vasum.host.Error.ZonesNotRunning";
-const std::string METHOD_GET_ZONE_DBUSES = "GetZoneDbuses";
+const std::string METHOD_GET_ZONE_CONNECTIONS = "GetZoneConnections";
const std::string METHOD_GET_ZONE_ID_LIST = "GetZoneIds";
const std::string METHOD_GET_ACTIVE_ZONE_ID = "GetActiveZoneId";
const std::string METHOD_GET_ZONE_INFO = "GetZoneInfo";
const std::string METHOD_GRANT_DEVICE = "GrantDevice";
const std::string METHOD_REVOKE_DEVICE = "RevokeDevice";
-const std::string SIGNAL_ZONE_DBUS_STATE = "ZoneDbusState";
+const std::string SIGNAL_ZONE_CONNECTION_STATE = "ZoneConnectionState";
const std::string DEFINITION =
" <arg type='v' name='parameters' direction='in'/>"
" <arg type='v' name='result' direction='out'/>"
" </method>"
- " <method name='" + METHOD_GET_ZONE_DBUSES + "'>"
- " <arg type='a(ss)' name='dbuses' direction='out'/>"
+ " <method name='" + METHOD_GET_ZONE_CONNECTIONS + "'>"
+ " <arg type='a(ss)' name='connections' direction='out'/>"
" </method>"
" <method name='" + METHOD_GET_ZONE_ID_LIST + "'>"
" <arg type='as' name='result' direction='out'/>"
" <arg type='s' name='id' direction='in'/>"
" <arg type='s' name='device' direction='in'/>"
" </method>"
- " <signal name='" + SIGNAL_ZONE_DBUS_STATE + "'>"
+ " <signal name='" + SIGNAL_ZONE_CONNECTION_STATE + "'>"
" <arg type='s' name='zone'/>"
- " <arg type='s' name='dbusAddress'/>"
+ " <arg type='s' name='address'/>"
" </signal>"
" </interface>"
"</node>";
{
}
-void HostIPCConnection::setGetZoneDbusesCallback(const Callback<api::Dbuses>::type& callback)
+void HostIPCConnection::setGetZoneConnectionsCallback(const Callback<api::Connections>::type& callback)
{
- typedef Callback<api::Dbuses> Callback;
+ typedef Callback<api::Connections> Callback;
mService->setMethodHandler<Callback::out, Callback::in>(
- api::host::METHOD_GET_ZONE_DBUSES,
+ api::host::METHOD_GET_ZONE_CONNECTIONS,
Callback::getCallbackWrapper(callback));
}
Callback::getCallbackWrapper(callback));
}
-void HostIPCConnection::signalZoneDbusState(const api::DbusState& dbusState)
+void HostIPCConnection::signalZoneConnectionState(const api::ConnectionState& connectionState)
{
- mService->signal(api::host::SIGNAL_ZONE_DBUS_STATE,
- std::make_shared<api::DbusState>(dbusState));
+ mService->signal(api::host::SIGNAL_ZONE_CONNECTION_STATE,
+ std::make_shared<api::ConnectionState>(connectionState));
}
} // namespace vasum
HostIPCConnection();
~HostIPCConnection();
- void setGetZoneDbusesCallback(const Callback<api::Dbuses>::type& callback);
+ void setGetZoneConnectionsCallback(const Callback<api::Connections>::type& callback);
void setGetZoneIdsCallback(const Callback<api::ZoneIds>::type& callback);
void setGetActiveZoneIdCallback(const Callback<api::ZoneId>::type& callback);
void setGetZoneInfoCallback(const Callback<const api::ZoneId, api::ZoneInfoOut>::type& callback);
void setUnlockZoneCallback(const Callback<const api::ZoneId>::type& callback);
void setGrantDeviceCallback(const Callback<const api::GrantDeviceIn>::type& callback);
void setRevokeDeviceCallback(const Callback<const api::RevokeDeviceIn>::type& callback);
- void signalZoneDbusState(const api::DbusState& dbusState);
+ void signalZoneConnectionState(const api::ConnectionState& connectionState);
private:
epoll::ThreadDispatcher mDispatcher;
namespace api {
namespace host {
-const vasum::ipc::MethodID METHOD_GET_ZONE_DBUSES = 1;
+const vasum::ipc::MethodID METHOD_GET_ZONE_CONNECTIONS = 1;
const vasum::ipc::MethodID METHOD_GET_ZONE_ID_LIST = 2;
const vasum::ipc::MethodID METHOD_GET_ACTIVE_ZONE_ID = 3;
const vasum::ipc::MethodID METHOD_GET_ZONE_INFO = 4;
const vasum::ipc::MethodID METHOD_GRANT_DEVICE = 25;
const vasum::ipc::MethodID METHOD_REVOKE_DEVICE = 26;
-const vasum::ipc::MethodID SIGNAL_ZONE_DBUS_STATE = 27;
+const vasum::ipc::MethodID SIGNAL_ZONE_CONNECTION_STATE = 27;
} // namespace host
} // namespace api
* Specify, if D-Bus communication with the zone will be enabled.
* Setting this value to "false" will make the zone API not work inside the zone.
*/
- bool enableDbusIntegration;
+ bool enableZoneConnection;
/**
* Zone's CFS quota in us when it's in the foreground
initWithArgs,
privilege, // TODO not needed?
switchToDefaultAfterTimeout, // TODO move to dynamic and add an API to change
- enableDbusIntegration,
+ enableZoneConnection,
cpuQuotaForeground,
cpuQuotaBackground,
permittedToSend, // TODO move to dynamic and add an API to change
mNotifyActiveZoneCallback = callback;
}
-void ZoneConnection::setDisplayOffCallback(const DisplayOffCallback& callback)
+void ZoneConnection::setSwitchToDefaultCallback(const SwitchToDefaultCallback& callback)
{
- mDisplayOffCallback = callback;
+ mSwitchToDefaultCallback = callback;
}
void ZoneConnection::setFileMoveCallback(
if (objectPath == fake_power_manager_api::OBJECT_PATH &&
interface == fake_power_manager_api::INTERFACE) {
//power-manager sent us a signal, check it
- if (signalName == fake_power_manager_api::SIGNAL_DISPLAY_OFF && mDisplayOffCallback) {
- mDisplayOffCallback();
+ if (signalName == fake_power_manager_api::SIGNAL_DISPLAY_OFF && mSwitchToDefaultCallback) {
+ mSwitchToDefaultCallback();
}
}
}
public:
typedef std::function<void()> OnNameLostCallback;
- typedef std::function<void()> DisplayOffCallback;
+ typedef std::function<void()> SwitchToDefaultCallback;
ZoneConnection(const std::string& address, const OnNameLostCallback& callback);
~ZoneConnection();
void setNotifyActiveZoneCallback(const NotifyActiveZoneCallback& callback);
/**
- * Register callback to handle turning off the display
+ * Register switch to default request callback
*/
- void setDisplayOffCallback(const DisplayOffCallback& callback);
+ void setSwitchToDefaultCallback(const SwitchToDefaultCallback& callback);
/*
* Register file move request callback
bool mNameLost;
OnNameLostCallback mOnNameLostCallback;
NotifyActiveZoneCallback mNotifyActiveZoneCallback;
- DisplayOffCallback mDisplayOffCallback;
+ SwitchToDefaultCallback mSwitchToDefaultCallback;
FileMoveCallback mFileMoveCallback;
ProxyCallCallback mProxyCallCallback;
Lock lock(mReconnectMutex);
updateRequestedState(STATE_RUNNING);
mProvision->start();
- if (mConfig.enableDbusIntegration) {
+ if (mConfig.enableZoneConnection) {
mConnectionTransport.reset(new ZoneConnectionTransport(mRunMountPoint));
}
mAdmin->start();
- if (mConfig.enableDbusIntegration) {
+ if (mConfig.enableZoneConnection) {
// Increase cpu quota before connect, otherwise it'd take ages.
goForeground();
connect();
void Zone::connect()
{
// assume called under reconnect lock
- mDbusAddress = mConnectionTransport->acquireAddress();
- mConnection.reset(new ZoneConnection(mDbusAddress,
- std::bind(&Zone::onNameLostCallback, this)));
+ mConnectionAddress = mConnectionTransport->acquireAddress();
+ mConnection.reset(new ZoneConnection(mConnectionAddress,
+ std::bind(&Zone::onNameLostCallback, this)));
if (mNotifyCallback) {
mConnection->setNotifyActiveZoneCallback(mNotifyCallback);
}
- if (mDisplayOffCallback) {
- mConnection->setDisplayOffCallback(mDisplayOffCallback);
+ if (mSwitchToDefaultCallback) {
+ mConnection->setSwitchToDefaultCallback(mSwitchToDefaultCallback);
}
if (mFileMoveCallback) {
mConnection->setFileMoveCallback(mFileMoveCallback);
if (mProxyCallCallback) {
mConnection->setProxyCallCallback(mProxyCallCallback);
}
- if (mDbusStateChangedCallback) {
- mDbusStateChangedCallback(mDbusAddress);
+ if (mConnectionStateChangedCallback) {
+ mConnectionStateChangedCallback(mConnectionAddress);
}
}
// assume called under reconnect lock
if (mConnection) {
mConnection.reset();
- mDbusAddress.clear();
- if (mDbusStateChangedCallback) {
- // notify about invalid dbusAddress for this zone
- mDbusStateChangedCallback(std::string());
+ mConnectionAddress.clear();
+ if (mConnectionStateChangedCallback) {
+ // notify about invalid address for this zone
+ mConnectionStateChangedCallback(std::string());
}
}
}
-std::string Zone::getDbusAddress() const
+std::string Zone::getConnectionAddress() const
{
Lock lock(mReconnectMutex);
- return mDbusAddress;
+ return mConnectionAddress;
}
int Zone::getVT() const
}
}
-void Zone::setDisplayOffCallback(const DisplayOffCallback& callback)
+void Zone::setSwitchToDefaultCallback(const SwitchToDefaultCallback& callback)
{
Lock lock(mReconnectMutex);
- mDisplayOffCallback = callback;
+ mSwitchToDefaultCallback = callback;
if (mConnection) {
- mConnection->setDisplayOffCallback(callback);
+ mConnection->setSwitchToDefaultCallback(callback);
}
}
}
}
-void Zone::setDbusStateChangedCallback(const DbusStateChangedCallback& callback)
+void Zone::setConnectionStateChangedCallback(const ConnectionStateChangedCallback& callback)
{
- mDbusStateChangedCallback = callback;
+ mConnectionStateChangedCallback = callback;
}
void Zone::proxyCallAsync(const std::string& busName,
~Zone();
typedef ZoneConnection::NotifyActiveZoneCallback NotifyActiveZoneCallback;
- typedef ZoneConnection::DisplayOffCallback DisplayOffCallback;
+ typedef ZoneConnection::SwitchToDefaultCallback SwitchToDefaultCallback;
typedef ZoneConnection::FileMoveCallback FileMoveCallback;
typedef ZoneConnection::ProxyCallCallback ProxyCallCallback;
- typedef std::function<void(const std::string& address)> DbusStateChangedCallback;
+ typedef std::function<void(const std::string& address)> ConnectionStateChangedCallback;
typedef std::function<void(bool succeeded)> StartAsyncResultCallback;
/**
/**
* Register callback used when switching to default zone.
*/
- void setDisplayOffCallback(const DisplayOffCallback& callback);
+ void setSwitchToDefaultCallback(const SwitchToDefaultCallback& callback);
/**
* Register proxy call callback
/**
* Register dbus state changed callback
*/
- void setDbusStateChangedCallback(const DbusStateChangedCallback& callback);
+ void setConnectionStateChangedCallback(const ConnectionStateChangedCallback& callback);
/**
* Make a proxy call
/**
* Get a dbus address
*/
- std::string getDbusAddress() const;
+ std::string getConnectionAddress() const;
/**
* Get id of VT
std::unique_ptr<ZoneProvision> mProvision;
mutable std::recursive_mutex mReconnectMutex;
NotifyActiveZoneCallback mNotifyCallback;
- DisplayOffCallback mDisplayOffCallback;
+ SwitchToDefaultCallback mSwitchToDefaultCallback;
FileMoveCallback mFileMoveCallback;
ProxyCallCallback mProxyCallCallback;
- DbusStateChangedCallback mDbusStateChangedCallback;
- std::string mDbusAddress;
+ ConnectionStateChangedCallback mConnectionStateChangedCallback;
+ std::string mConnectionAddress;
std::string mRunMountPoint;
std::string mRootPath;
std::string mDbPath;
this, HOST_ID, _1, _2, _3, _4, _5, _6, _7));
#endif
- mHostConnection.setGetZoneDbusesCallback(bind(&ZonesManager::handleGetZoneDbusesCall,
- this, _1));
+ mHostConnection.setGetZoneConnectionsCallback(bind(&ZonesManager::handleGetZoneConnectionsCall,
+ this, _1));
mHostConnection.setGetZoneIdsCallback(bind(&ZonesManager::handleGetZoneIdsCall,
this, _1));
zone->setNotifyActiveZoneCallback(bind(&ZonesManager::handleNotifyActiveZoneCall,
this, zoneId, _1, _2, _3));
- zone->setDisplayOffCallback(bind(&ZonesManager::handleDisplayOffCall,
+ zone->setSwitchToDefaultCallback(bind(&ZonesManager::handleSwitchToDefaultCall,
this, zoneId));
zone->setFileMoveCallback(bind(&ZonesManager::handleFileMoveCall,
zone->setProxyCallCallback(bind(&ZonesManager::handleProxyCall,
this, zoneId, _1, _2, _3, _4, _5, _6, _7));
- zone->setDbusStateChangedCallback(bind(&ZonesManager::handleDbusStateChanged,
- this, zoneId, _1));
+ zone->setConnectionStateChangedCallback(bind(&ZonesManager::handleConnectionStateChanged,
+ this, zoneId, _1));
mZones.push_back(std::move(zone));
}
}
-void ZonesManager::handleDisplayOffCall(const std::string& /*caller*/)
+void ZonesManager::handleSwitchToDefaultCall(const std::string& /*caller*/)
{
// get config of currently set zone and switch if switchToDefaultAfterTimeout is true
Lock lock(mMutex);
asyncResultCallback);
}
-void ZonesManager::handleGetZoneDbusesCall(api::MethodResultBuilder::Pointer result)
+void ZonesManager::handleGetZoneConnectionsCall(api::MethodResultBuilder::Pointer result)
{
Lock lock(mMutex);
- auto dbuses = std::make_shared<api::Dbuses>();
+ auto connections = std::make_shared<api::Connections>();
for (auto& zone : mZones) {
- dbuses->values.push_back({zone->getId(), zone->getDbusAddress()});
+ connections->values.push_back({zone->getId(), zone->getConnectionAddress()});
}
- result->set(dbuses);
+ result->set(connections);
}
-void ZonesManager::handleDbusStateChanged(const std::string& zoneId ,
- const std::string& dbusAddress)
+void ZonesManager::handleConnectionStateChanged(const std::string& zoneId ,
+ const std::string& address)
{
- mHostConnection.signalZoneDbusState({zoneId, dbusAddress});
+ mHostConnection.signalZoneConnectionState({zoneId, address});
}
void ZonesManager::handleGetZoneIdsCall(api::MethodResultBuilder::Pointer result)
const std::string& appliaction,
const std::string& message,
api::MethodResultBuilder::Pointer result);
- void handleDisplayOffCall(const std::string& caller);
+ void handleSwitchToDefaultCall(const std::string& caller);
void handleFileMoveCall(const std::string& srcZoneId,
const std::string& dstZoneId,
const std::string& path,
const std::string& targetMethod,
GVariant* parameters,
dbus::MethodResultBuilder::Pointer result);
- void handleGetZoneDbusesCall(api::MethodResultBuilder::Pointer result);
-
- void handleDbusStateChanged(const std::string& zoneId,
- const std::string& dbusAddress);
+ void handleGetZoneConnectionsCall(api::MethodResultBuilder::Pointer result);
+ void handleConnectionStateChanged(const std::string& zoneId,
+ const std::string& address);
// Host's handlers --------------------------------------------------------
void handleGetZoneIdsCall(api::MethodResultBuilder::Pointer result);
void handleGetActiveZoneIdCall(api::MethodResultBuilder::Pointer result);
"privilege" : 20,
"vt" : -1,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : true,
+ "enableZoneConnection" : true,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"shutdownTimeout" : 10,
};
const int EVENT_TIMEOUT = 5000; ///< ms
-const std::map<std::string, std::string> EXPECTED_DBUSES_STARTED = {
+const std::map<std::string, std::string> EXPECTED_CONNECTIONS = {
{
"zone1",
"unix:path=/tmp/ut-run/zone1/dbus/system_bus_socket"
VsmClient client = vsm_client_create();
VsmStatus status = vsm_connect_custom(client,
- EXPECTED_DBUSES_STARTED.begin()->second.c_str());
+ EXPECTED_CONNECTIONS.begin()->second.c_str());
BOOST_CHECK_EQUAL(VSMCLIENT_IO_ERROR, status);
vsm_client_free(client);
}
-BOOST_AUTO_TEST_CASE(GetZoneDbuses)
+BOOST_AUTO_TEST_CASE(GetZoneConnections)
{
VsmClient client = vsm_client_create();
VsmStatus status = vsm_connect(client);
//TODO: Clean up if BOOST_REQUIRE_EQUAL fail (remove client). Same in other client tests.
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
- BOOST_CHECK_EQUAL(getArrayStringLength(keys, EXPECTED_DBUSES_STARTED.size() + 1u),
- EXPECTED_DBUSES_STARTED.size());
- BOOST_CHECK_EQUAL(getArrayStringLength(values, EXPECTED_DBUSES_STARTED.size() + 1u),
- EXPECTED_DBUSES_STARTED.size());
+ BOOST_CHECK_EQUAL(getArrayStringLength(keys, EXPECTED_CONNECTIONS.size() + 1u),
+ EXPECTED_CONNECTIONS.size());
+ BOOST_CHECK_EQUAL(getArrayStringLength(values, EXPECTED_CONNECTIONS.size() + 1u),
+ EXPECTED_CONNECTIONS.size());
std::map<std::string, std::string> zones;
convertDictToMap(keys, values, zones);
- BOOST_CHECK(zones == EXPECTED_DBUSES_STARTED);
+ BOOST_CHECK(zones == EXPECTED_CONNECTIONS);
vsm_array_string_free(keys);
vsm_array_string_free(values);
vsm_client_free(client);
VsmArrayString values;
status = vsm_get_zone_ids(client, &values);
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
- BOOST_CHECK_EQUAL(getArrayStringLength(values, EXPECTED_DBUSES_STARTED.size() + 1u),
- EXPECTED_DBUSES_STARTED.size());
+ BOOST_CHECK_EQUAL(getArrayStringLength(values, EXPECTED_CONNECTIONS.size() + 1u),
+ EXPECTED_CONNECTIONS.size());
std::set<std::string> zones;
convertArrayToSet(values, zones);
for (const auto& zone : zones) {
- BOOST_CHECK(EXPECTED_DBUSES_STARTED.find(zone) != EXPECTED_DBUSES_STARTED.cend());
+ BOOST_CHECK(EXPECTED_CONNECTIONS.find(zone) != EXPECTED_CONNECTIONS.cend());
}
vsm_array_string_free(values);
vsm_client_free(client);
const std::string secondZone = "fake_zone";
VsmClient client = vsm_client_create();
- VsmStatus status = vsm_connect_custom(client, EXPECTED_DBUSES_STARTED.begin()->second.c_str());
+ VsmStatus status = vsm_connect_custom(client, EXPECTED_CONNECTIONS.begin()->second.c_str());
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
status = vsm_file_move_request(client, secondZone.c_str(), path.c_str());
BOOST_REQUIRE_EQUAL(VSMCLIENT_CUSTOM_ERROR, status);
CallbackData callbackData;
std::map<std::string, VsmClient> clients;
- for (const auto& it : EXPECTED_DBUSES_STARTED) {
+ for (const auto& it : EXPECTED_CONNECTIONS) {
VsmClient client = vsm_client_create();
VsmStatus status = vsm_connect_custom(client, it.second.c_str());
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
BOOST_CHECK(ids.count("host") == 1);
- for (const auto& dbus : EXPECTED_DBUSES_STARTED) {
+ for (const auto& dbus : EXPECTED_CONNECTIONS) {
BOOST_CHECK(ids.count(dbus.first) == 1);
}
}
"privilege" : 20,
"vt" : -1,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : false,
+ "enableZoneConnection" : false,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"shutdownTimeout" : 10,
"privilege" : 10,
"vt" : -1,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : false,
+ "enableZoneConnection" : false,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"shutdownTimeout" : 10,
"privilege" : 10,
"vt" : -1,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : false,
+ "enableZoneConnection" : false,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"shutdownTimeout" : 10,
"privilege" : 10,
"vt" : -1,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : false,
+ "enableZoneConnection" : false,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"shutdownTimeout" : 10,
"privilege" : 10,
"vt" : -1,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : false,
+ "enableZoneConnection" : false,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"shutdownTimeout" : 10,
"privilege" : 10,
"vt" : -1,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : false,
+ "enableZoneConnection" : false,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"shutdownTimeout" : 10,
"privilege" : 10,
"vt" : -1,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : true,
+ "enableZoneConnection" : true,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"shutdownTimeout" : 10,
"privilege" : 10,
"vt" : -1,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : false,
+ "enableZoneConnection" : false,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"shutdownTimeout" : 10,
"privilege" : 20,
"vt" : -1,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : true,
+ "enableZoneConnection" : true,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"shutdownTimeout" : 10,
"privilege" : 20,
"vt" : -1,
"switchToDefaultAfterTimeout" : true,
- "enableDbusIntegration" : false,
+ "enableZoneConnection" : false,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
"shutdownTimeout" : 10,
BOOST_CHECK(signalEmitted.wait(EVENT_TIMEOUT));
}
-BOOST_AUTO_TEST_CASE(SignalDisplayOffApi)
+BOOST_AUTO_TEST_CASE(SignalSwitchToDefaultApi)
{
- Latch displayOffCalled;
+ Latch switchToDefaultCalled;
ZoneConnection connection(acquireAddress(), nullptr);
DbusConnection::Pointer client = DbusConnection::create(acquireAddress());
auto callback = [&]() {
- displayOffCalled.set();
+ switchToDefaultCalled.set();
};
- connection.setDisplayOffCallback(callback);
+ connection.setSwitchToDefaultCallback(callback);
client->emitSignal(fake_power_manager_api::OBJECT_PATH,
fake_power_manager_api::INTERFACE,
nullptr);
// timeout should occur, since no name is set to client
- BOOST_CHECK(!displayOffCalled.wait(EVENT_TIMEOUT));
+ BOOST_CHECK(!switchToDefaultCalled.wait(EVENT_TIMEOUT));
DbusNameSetter setter;
nullptr);
// now signal should be delivered correctly
- BOOST_CHECK(displayOffCalled.wait(EVENT_TIMEOUT));
+ BOOST_CHECK(switchToDefaultCalled.wait(EVENT_TIMEOUT));
}
const std::string NON_EXISTANT_ZONE_ID = "NON_EXISTANT_ZONE_ID";
const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf
const std::string SIMPLE_TEMPLATE = "console";
-const std::string DBUS_TEMPLATE = "console-dbus";
+const std::string ZONE_ACCESS_TEMPLATE = "console-dbus";
#ifdef DBUS_CONNECTION
/**
)> TestApiMethodCallback;
typedef std::function<void()> VoidResultCallback;
typedef std::function<void(const std::string& zoneId,
- const std::string& dbusAddress)> SignalCallback;
+ const std::string& address)> SignalCallback;
- typedef std::map<std::string, std::string> Dbuses;
+ typedef std::map<std::string, std::string> Connections;
DbusAccessory()
: mId(0),
mClient->signalSubscribe(callback, isHost() ? api::host::BUS_NAME : api::zone::BUS_NAME);
}
- void subscribeZoneDbusState(const SignalCallback& callback) {
+ void subscribeZoneConnectionState(const SignalCallback& callback) {
assert(isHost());
auto onSignal = [callback] (const std::string& /*senderBusName*/,
const std::string& objectPath,
GVariant* parameters) {
if (objectPath == api::host::OBJECT_PATH &&
interface == api::host::INTERFACE &&
- signalName == api::host::SIGNAL_ZONE_DBUS_STATE) {
+ signalName == api::host::SIGNAL_ZONE_CONNECTION_STATE) {
const gchar* zoneId = NULL;
- const gchar* dbusAddress = NULL;
- g_variant_get(parameters, "(&s&s)", &zoneId, &dbusAddress);
- callback(zoneId, dbusAddress);
+ const gchar* address = NULL;
+ g_variant_get(parameters, "(&s&s)", &zoneId, &address);
+ callback(zoneId, address);
}
};
mClient->signalSubscribe(onSignal, api::host::BUS_NAME);
return GVariantPtr(unpackedResult, g_variant_unref);
}
- Dbuses callMethodGetZoneDbuses()
+ Connections callMethodGetZoneConnections()
{
assert(isHost());
- Dbuses dbuses;
+ Connections connections;
GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
api::host::OBJECT_PATH,
api::host::INTERFACE,
- api::host::METHOD_GET_ZONE_DBUSES,
+ api::host::METHOD_GET_ZONE_CONNECTIONS,
NULL,
"(a(ss))");
GVariant* array = NULL;
size_t count = g_variant_n_children(array);
for (size_t n = 0; n < count; ++n) {
const char* zoneId = NULL;
- const char* dbusAddress = NULL;
- g_variant_get_child(array, n, "(&s&s)", &zoneId, &dbusAddress);
- dbuses.insert(Dbuses::value_type(zoneId, dbusAddress));
+ const char* address = NULL;
+ g_variant_get_child(array, n, "(&s&s)", &zoneId, &address);
+ connections.insert(Connections::value_type(zoneId, address));
}
- return dbuses;
+ return connections;
}
std::vector<std::string> callMethodGetZoneIds()
)> TestApiMethodCallback;
typedef std::function<void()> VoidResultCallback;
typedef std::function<void(const std::string& zoneId,
- const std::string& dbusAddress)> SignalCallback;
+ const std::string& address)> SignalCallback;
- typedef std::map<std::string, std::string> Dbuses;
+ typedef std::map<std::string, std::string> Connections;
HostIPCAccessory()
: mClient(mDispatcher.getPoll(), HOST_IPC_SOCKET)
mClient.start();
}
- void subscribeZoneDbusState(const SignalCallback& callback)
+ void subscribeZoneConnectionState(const SignalCallback& callback)
{
- auto callbackWrapper = [callback] (const ipc::PeerID, std::shared_ptr<api::DbusState>& data) {
+ auto callbackWrapper = [callback] (const ipc::PeerID, std::shared_ptr<api::ConnectionState>& data) {
callback(data->first, data->second);
};
- mClient.setSignalHandler<api::DbusState>(api::host::SIGNAL_ZONE_DBUS_STATE, callbackWrapper);
+ mClient.setSignalHandler<api::ConnectionState>(api::host::SIGNAL_ZONE_CONNECTION_STATE,
+ callbackWrapper);
}
- Dbuses callMethodGetZoneDbuses()
+ Connections callMethodGetZoneConnections()
{
- const auto out = mClient.callSync<api::Void, api::Dbuses>(api::host::METHOD_GET_ZONE_DBUSES,
- std::make_shared<api::Void>());
- Dbuses dbuses;
+ const auto out = mClient.callSync<api::Void, api::Connections>(api::host::METHOD_GET_ZONE_CONNECTIONS,
+ std::make_shared<api::Void>());
+ Connections connections;
for (const auto& dbus : out->values) {
- dbuses.insert(Dbuses::value_type(dbus.first, dbus.second));
+ connections.insert(Connections::value_type(dbus.first, dbus.second));
}
- return dbuses;
+ return connections;
}
std::vector<std::string> callMethodGetZoneIds()
MethodResultBuilder::Pointer result
)> TestApiMethodCallback;
- typedef std::map<std::string, std::string> Dbuses;
+ typedef std::map<std::string, std::string> Connections;
ZoneDbusAccessory(int id)
: mId(id),
BOOST_AUTO_TEST_CASE(NotifyActiveZone)
{
ZonesManager cm(TEST_CONFIG_PATH);
- cm.createZone("zone1", DBUS_TEMPLATE);
- cm.createZone("zone2", DBUS_TEMPLATE);
- cm.createZone("zone3", DBUS_TEMPLATE);
+ cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
cm.restoreAll();
Latch signalReceivedLatch;
std::map<int, std::vector<std::string>> signalReceivedSourcesMap;
- std::map<int, std::unique_ptr<ZoneAccessory>> dbuses;
+ std::map<int, std::unique_ptr<ZoneAccessory>> connections;
for (int i = 1; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
- dbuses[i] = std::unique_ptr<ZoneAccessory>(new ZoneAccessory(i));
+ connections[i] = std::unique_ptr<ZoneAccessory>(new ZoneAccessory(i));
}
auto handler = [](Latch& latch,
using namespace std::placeholders;
for (int i = 1; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
- dbuses[i]->signalSubscribe(std::bind(handler,
+ connections[i]->signalSubscribe(std::bind(handler,
std::ref(signalReceivedLatch),
std::ref(signalReceivedSourcesMap[i]),
_1, _2, _3, _4, _5));
}
- for (auto& dbus : dbuses) {
+ for (auto& dbus : connections) {
dbus.second->callMethodNotify();
}
- BOOST_REQUIRE(signalReceivedLatch.waitForN(dbuses.size() - 1u, EVENT_TIMEOUT));
+ BOOST_REQUIRE(signalReceivedLatch.waitForN(connections.size() - 1u, EVENT_TIMEOUT));
BOOST_REQUIRE(signalReceivedLatch.empty());
//check if there are no signals that was received more than once
source), 1);
}
//check if all signals was received by active zone
- BOOST_CHECK_EQUAL(signalReceivedSourcesMap[1].size(), dbuses.size() - 1);
+ BOOST_CHECK_EQUAL(signalReceivedSourcesMap[1].size(), connections.size() - 1);
//check if no signals was received by inactive zone
- for (size_t i = 2; i <= dbuses.size(); ++i) {
+ for (size_t i = 2; i <= connections.size(); ++i) {
BOOST_CHECK(signalReceivedSourcesMap[i].empty());
}
- dbuses.clear();
+ connections.clear();
}
-BOOST_AUTO_TEST_CASE(DisplayOff)
+BOOST_AUTO_TEST_CASE(SwitchToDefault)
{
ZonesManager cm(TEST_CONFIG_PATH);
- cm.createZone("zone1", DBUS_TEMPLATE);
- cm.createZone("zone2", DBUS_TEMPLATE);
- cm.createZone("zone3", DBUS_TEMPLATE);
+ cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
cm.restoreAll();
std::vector<std::unique_ptr<ZoneAccessory>> clients;
BOOST_AUTO_TEST_CASE(MoveFile)
{
ZonesManager cm(TEST_CONFIG_PATH);
- cm.createZone("zone1", DBUS_TEMPLATE);
- cm.createZone("zone2", DBUS_TEMPLATE);
- cm.createZone("zone3", DBUS_TEMPLATE);
+ cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
cm.restoreAll();
Latch notificationLatch;
std::string notificationPath;
std::string notificationRetcode;
- std::map<int, std::unique_ptr<ZoneAccessory>> dbuses;
+ std::map<int, std::unique_ptr<ZoneAccessory>> connections;
for (int i = 1; i <= 2; ++i) {
- dbuses[i] = std::unique_ptr<ZoneAccessory>(new ZoneAccessory(i));
+ connections[i] = std::unique_ptr<ZoneAccessory>(new ZoneAccessory(i));
}
auto handler = [&](const std::string& /*senderBusName*/,
};
// subscribe the second (destination) zone for notifications
- dbuses.at(2)->signalSubscribe(handler);
+ connections.at(2)->signalSubscribe(handler);
const std::string TMP = "/tmp/ut-zones";
const std::string NO_PATH = "path_doesnt_matter_here";
const std::string ZONE2PATH = TMP + "/" + ZONE2 + TMP;
// sending to a non existing zone
- BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(BUGGY_ZONE, NO_PATH),
+ BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(BUGGY_ZONE, NO_PATH),
api::zone::FILE_MOVE_DESTINATION_NOT_FOUND);
BOOST_CHECK(notificationLatch.empty());
// sending to self
- BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE1, NO_PATH),
+ BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(ZONE1, NO_PATH),
api::zone::FILE_MOVE_WRONG_DESTINATION);
BOOST_CHECK(notificationLatch.empty());
// no permission to send
- BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE2, "/etc/secret1"),
+ BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(ZONE2, "/etc/secret1"),
api::zone::FILE_MOVE_NO_PERMISSIONS_SEND);
BOOST_CHECK(notificationLatch.empty());
// no permission to receive
// TODO uncomment this after adding an api to change 'permittedTo*' config
- //BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE2, "/etc/secret2"),
+ //BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(ZONE2, "/etc/secret2"),
// api::zone::FILE_MOVE_NO_PERMISSIONS_RECEIVE);
//BOOST_CHECK(notificationLatch.empty());
// non existing file
- BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE2, BUGGY_PATH),
+ BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(ZONE2, BUGGY_PATH),
api::zone::FILE_MOVE_FAILED);
BOOST_CHECK(notificationLatch.empty());
BOOST_REQUIRE(fs::create_directories(ZONE2PATH, ec));
BOOST_REQUIRE(utils::saveFileContent(ZONE1PATH + "/file", FILE_CONTENT));
- BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE2, TMP + "/file"),
+ BOOST_CHECK_EQUAL(connections.at(1)->callMethodMove(ZONE2, TMP + "/file"),
api::zone::FILE_MOVE_SUCCEEDED);
BOOST_REQUIRE(notificationLatch.wait(EVENT_TIMEOUT));
BOOST_REQUIRE(notificationLatch.empty());
BOOST_AUTO_TEST_CASE(AllowSwitchToDefault)
{
ZonesManager cm(TEST_CONFIG_PATH);
- cm.createZone("zone1", DBUS_TEMPLATE);
- cm.createZone("zone2", DBUS_TEMPLATE);
- cm.createZone("zone3", DBUS_TEMPLATE);
+ cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
cm.restoreAll();
std::vector<std::unique_ptr<ZoneAccessory>> clients;
BOOST_AUTO_TEST_CASE(ProxyCall)
{
ZonesManager cm(TEST_CONFIG_PATH);
- cm.createZone("zone1", DBUS_TEMPLATE);
- cm.createZone("zone2", DBUS_TEMPLATE);
- cm.createZone("zone3", DBUS_TEMPLATE);
+ cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
cm.restoreAll();
- std::map<int, std::unique_ptr<DbusAccessory>> dbuses;
- dbuses[0] = std::unique_ptr<DbusAccessory>(new HostAccessory());
+ std::map<int, std::unique_ptr<DbusAccessory>> connections;
+ connections[0] = std::unique_ptr<DbusAccessory>(new HostAccessory());
for (int i = 1; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
- dbuses[i] = std::unique_ptr<DbusAccessory>(new ZoneAccessory(i));
+ connections[i] = std::unique_ptr<DbusAccessory>(new ZoneAccessory(i));
}
- for (auto& dbus : dbuses) {
+ for (auto& dbus : connections) {
dbus.second->setName(testapi::BUS_NAME);
const int id = dbus.first;
// host -> zone2
BOOST_CHECK_EQUAL("reply from 2: param1",
- dbuses.at(0)->testApiProxyCall("zone2",
+ connections.at(0)->testApiProxyCall("zone2",
"param1"));
// host -> host
BOOST_CHECK_EQUAL("reply from 0: param2",
- dbuses.at(0)->testApiProxyCall("host",
+ connections.at(0)->testApiProxyCall("host",
"param2"));
// zone1 -> host
BOOST_CHECK_EQUAL("reply from 0: param3",
- dbuses.at(1)->testApiProxyCall("host",
+ connections.at(1)->testApiProxyCall("host",
"param3"));
// zone1 -> zone2
BOOST_CHECK_EQUAL("reply from 2: param4",
- dbuses.at(1)->testApiProxyCall("zone2",
+ connections.at(1)->testApiProxyCall("zone2",
"param4"));
// zone2 -> zone2
BOOST_CHECK_EQUAL("reply from 2: param5",
- dbuses.at(2)->testApiProxyCall("zone2",
+ connections.at(2)->testApiProxyCall("zone2",
"param5"));
// host -> unknown
- BOOST_CHECK_EXCEPTION(dbuses.at(0)->testApiProxyCall("unknown", "param"),
+ BOOST_CHECK_EXCEPTION(connections.at(0)->testApiProxyCall("unknown", "param"),
DbusCustomException,
WhatEquals("Unknown proxy call target"));
// forwarding error
- BOOST_CHECK_EXCEPTION(dbuses.at(0)->testApiProxyCall("host", ""),
+ BOOST_CHECK_EXCEPTION(connections.at(0)->testApiProxyCall("host", ""),
DbusCustomException,
WhatEquals("Test error"));
// forbidden call
- BOOST_CHECK_EXCEPTION(dbuses.at(0)->proxyCall("host",
- "org.fake",
- "/a/b",
- "c.d",
- "foo",
- g_variant_new("(s)", "arg")),
+ BOOST_CHECK_EXCEPTION(connections.at(0)->proxyCall("host",
+ "org.fake",
+ "/a/b",
+ "c.d",
+ "foo",
+ g_variant_new("(s)", "arg")),
DbusCustomException,
WhatEquals("Proxy call forbidden"));
}
#endif // DBUS_CONNECTION
namespace {
- const HostAccessory::Dbuses EXPECTED_DBUSES_NONE = {
+ const HostAccessory::Connections EXPECTED_CONNECTIONS_NONE = {
{"zone1", ""},
{"zone2", ""},
{"zone3", ""}};
- const HostAccessory::Dbuses EXPECTED_DBUSES_ALL = {
+ const HostAccessory::Connections EXPECTED_CONNECTIONS_ALL = {
{"zone1",
"unix:path=/tmp/ut-run/zone1/dbus/system_bus_socket"},
{"zone2",
"unix:path=/tmp/ut-run/zone3/dbus/system_bus_socket"}};
} // namespace
-BOOST_AUTO_TEST_CASE(GetZoneDbuses)
+BOOST_AUTO_TEST_CASE(GetZoneConnections)
{
ZonesManager cm(TEST_CONFIG_PATH);
HostAccessory host;
- cm.createZone("zone1", DBUS_TEMPLATE);
- cm.createZone("zone2", DBUS_TEMPLATE);
- cm.createZone("zone3", DBUS_TEMPLATE);
+ cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
- BOOST_CHECK(EXPECTED_DBUSES_NONE == host.callMethodGetZoneDbuses());
+ BOOST_CHECK(EXPECTED_CONNECTIONS_NONE == host.callMethodGetZoneConnections());
cm.restoreAll();
- BOOST_CHECK(EXPECTED_DBUSES_ALL == host.callMethodGetZoneDbuses());
+ BOOST_CHECK(EXPECTED_CONNECTIONS_ALL == host.callMethodGetZoneConnections());
cm.shutdownAll();
- BOOST_CHECK(EXPECTED_DBUSES_NONE == host.callMethodGetZoneDbuses());
+ BOOST_CHECK(EXPECTED_CONNECTIONS_NONE == host.callMethodGetZoneConnections());
}
-BOOST_AUTO_TEST_CASE(GetZoneDbusesNoDbus)
+BOOST_AUTO_TEST_CASE(GetZoneConnectionsNoDbus)
{
ZonesManager cm(TEST_CONFIG_PATH);
HostAccessory host;
cm.createZone("zone2", SIMPLE_TEMPLATE);
cm.createZone("zone3", SIMPLE_TEMPLATE);
- BOOST_CHECK(EXPECTED_DBUSES_NONE == host.callMethodGetZoneDbuses());
+ BOOST_CHECK(EXPECTED_CONNECTIONS_NONE == host.callMethodGetZoneConnections());
cm.restoreAll();
- BOOST_CHECK(EXPECTED_DBUSES_NONE == host.callMethodGetZoneDbuses());
+ BOOST_CHECK(EXPECTED_CONNECTIONS_NONE == host.callMethodGetZoneConnections());
cm.shutdownAll();
- BOOST_CHECK(EXPECTED_DBUSES_NONE == host.callMethodGetZoneDbuses());
+ BOOST_CHECK(EXPECTED_CONNECTIONS_NONE == host.callMethodGetZoneConnections());
}
-BOOST_AUTO_TEST_CASE(ZoneDbusesSignals)
+BOOST_AUTO_TEST_CASE(ZoneConnectionsSignals)
{
Latch signalLatch;
- HostAccessory::Dbuses collectedDbuses;
- std::mutex collectedDbusesMutex;
+ HostAccessory::Connections collectedConnections;
+ std::mutex collectedConnectionsMutex;
- auto onSignal = [&] (const std::string& zoneId, const std::string& dbusAddress) {
- std::unique_lock<std::mutex> lock(collectedDbusesMutex);
- collectedDbuses.insert(HostAccessory::Dbuses::value_type(zoneId, dbusAddress));
+ auto onSignal = [&] (const std::string& zoneId, const std::string& address) {
+ std::unique_lock<std::mutex> lock(collectedConnectionsMutex);
+ collectedConnections.insert(HostAccessory::Connections::value_type(zoneId, address));
signalLatch.set();
};
{
ZonesManager cm(TEST_CONFIG_PATH);
HostAccessory host;
- host.subscribeZoneDbusState(onSignal);
- cm.createZone("zone1", DBUS_TEMPLATE);
- cm.createZone("zone2", DBUS_TEMPLATE);
- cm.createZone("zone3", DBUS_TEMPLATE);
+ host.subscribeZoneConnectionState(onSignal);
+ cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
BOOST_CHECK(signalLatch.empty());
- BOOST_CHECK(collectedDbuses.empty());
+ BOOST_CHECK(collectedConnections.empty());
cm.restoreAll();
BOOST_REQUIRE(signalLatch.waitForN(TEST_DBUS_CONNECTION_ZONES_COUNT, EVENT_TIMEOUT));
BOOST_CHECK(signalLatch.empty());
- std::unique_lock<std::mutex> lock(collectedDbusesMutex);
- BOOST_CHECK(EXPECTED_DBUSES_ALL == collectedDbuses);
- collectedDbuses.clear();
+ std::unique_lock<std::mutex> lock(collectedConnectionsMutex);
+ BOOST_CHECK(EXPECTED_CONNECTIONS_ALL == collectedConnections);
+ collectedConnections.clear();
}
}
const std::string zone2 = "zone2";
ZonesManager cm(TEST_CONFIG_PATH);
- cm.createZone(zone1, DBUS_TEMPLATE);
- cm.createZone(zone2, DBUS_TEMPLATE);
+ cm.createZone(zone1, ZONE_ACCESS_TEMPLATE);
+ cm.createZone(zone2, ZONE_ACCESS_TEMPLATE);
Latch callDone;
auto resultCallback = [&]() {
BOOST_AUTO_TEST_CASE(LockUnlockZone)
{
ZonesManager cm(TEST_CONFIG_PATH);
- cm.createZone("zone1", DBUS_TEMPLATE);
- cm.createZone("zone2", DBUS_TEMPLATE);
- cm.createZone("zone3", DBUS_TEMPLATE);
+ cm.createZone("zone1", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone2", ZONE_ACCESS_TEMPLATE);
+ cm.createZone("zone3", ZONE_ACCESS_TEMPLATE);
cm.restoreAll();
HostAccessory host;