mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-24 21:39:02 -05:00
Read DefaultAccess parameter from the configuration file correctly
This commit is contained in:
@@ -72,37 +72,30 @@ ServerInterface* ServerModule::serverInterfaceByIdentifier(const std::string& id
|
||||
}
|
||||
|
||||
void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) {
|
||||
using namespace ghoul::io;
|
||||
global::callback::preSync.emplace_back([this]() { preSync(); });
|
||||
|
||||
if (configuration.hasValue<ghoul::Dictionary>(KeyInterfaces)) {
|
||||
ghoul::Dictionary interfaces =
|
||||
configuration.value<ghoul::Dictionary>(KeyInterfaces);
|
||||
if (!configuration.hasValue<ghoul::Dictionary>(KeyInterfaces)) {
|
||||
return;
|
||||
}
|
||||
ghoul::Dictionary interfaces = configuration.value<ghoul::Dictionary>(KeyInterfaces);
|
||||
|
||||
for (std::string& key : interfaces.keys()) {
|
||||
if (!interfaces.hasValue<ghoul::Dictionary>(key)) {
|
||||
continue;
|
||||
}
|
||||
ghoul::Dictionary interfaceDictionary =
|
||||
interfaces.value<ghoul::Dictionary>(key);
|
||||
for (const std::string& key : interfaces.keys()) {
|
||||
ghoul::Dictionary interfaceDictionary = interfaces.value<ghoul::Dictionary>(key);
|
||||
|
||||
std::unique_ptr<ServerInterface> serverInterface =
|
||||
ServerInterface::createFromDictionary(interfaceDictionary);
|
||||
std::unique_ptr<ServerInterface> serverInterface =
|
||||
ServerInterface::createFromDictionary(interfaceDictionary);
|
||||
|
||||
|
||||
if (global::windowDelegate.isMaster()) {
|
||||
serverInterface->initialize();
|
||||
}
|
||||
|
||||
_interfaceOwner.addPropertySubOwner(serverInterface.get());
|
||||
|
||||
if (serverInterface) {
|
||||
_interfaces.push_back(std::move(serverInterface));
|
||||
}
|
||||
if (global::windowDelegate.isMaster()) {
|
||||
serverInterface->initialize();
|
||||
}
|
||||
|
||||
}
|
||||
_interfaceOwner.addPropertySubOwner(serverInterface.get());
|
||||
|
||||
global::callback::preSync.emplace_back([this]() { preSync(); });
|
||||
if (serverInterface) {
|
||||
_interfaces.push_back(std::move(serverInterface));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ServerModule::preSync() {
|
||||
|
||||
@@ -117,6 +117,19 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& config)
|
||||
_defaultAccess.addOption(static_cast<int>(Access::RequirePassword), RequirePassword);
|
||||
_defaultAccess.addOption(static_cast<int>(Access::Allow), AllowAccess);
|
||||
|
||||
if (config.hasKey(DefaultAccessInfo.identifier)) {
|
||||
std::string access = config.value<std::string>(DefaultAccessInfo.identifier);
|
||||
if (access == DenyAccess) {
|
||||
_defaultAccess.setValue(static_cast<int>(Access::Deny));
|
||||
}
|
||||
else if (access == RequirePassword) {
|
||||
_defaultAccess.setValue(static_cast<int>(Access::RequirePassword));
|
||||
}
|
||||
else if (access == AllowAccess) {
|
||||
_defaultAccess.setValue(static_cast<int>(Access::Allow));
|
||||
}
|
||||
}
|
||||
|
||||
const std::string identifier = config.value<std::string>(KeyIdentifier);
|
||||
|
||||
auto readList =
|
||||
@@ -153,7 +166,7 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& config)
|
||||
_port = static_cast<int>(config.value<double>(PortInfo.identifier));
|
||||
_enabled = config.value<bool>(EnabledInfo.identifier);
|
||||
|
||||
std::function<void()> reinitialize = [this]() {
|
||||
auto reinitialize = [this]() {
|
||||
deinitialize();
|
||||
initialize();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user