Enable compatibility with older versions of libconfig (such as the one shipped with RHEL/CentOS 7)

This commit is contained in:
Kevin Abraham
2020-11-22 12:12:29 -05:00
parent 4c582241d5
commit 28a93b2df4
13 changed files with 44 additions and 44 deletions
+6 -6
View File
@@ -180,7 +180,7 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
Action::Config(device)
{
try {
auto& gestures = root.lookup("gestures");
auto& gestures = root["gestures"];
if(!gestures.isList()) {
logPrintf(WARN, "Line %d: gestures must be a list, ignoring.",
@@ -199,7 +199,7 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
Direction d;
try {
auto& direction = gestures[i].lookup("direction");
auto& direction = gestures[i]["direction"];
if(direction.getType() != libconfig::Setting::TypeString) {
logPrintf(WARN, "Line %d: direction must be a string, "
"skipping.", direction.getSourceLine());
@@ -228,7 +228,7 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
if(d == None) {
try {
auto& mode = gestures[i].lookup("mode");
auto& mode = gestures[i]["mode"];
if(mode.getType() == libconfig::Setting::TypeString) {
std::string mode_str = mode;
std::transform(mode_str.begin(), mode_str.end(),
@@ -251,10 +251,10 @@ GestureAction::Config::Config(Device* device, libconfig::Setting &root) :
try {
_none_action = Action::makeAction(_device,
gestures[i].lookup("action"));
gestures[i]["action"]);
} catch (InvalidAction& e) {
logPrintf(WARN, "Line %d: %s is not a valid action, "
"skipping.", gestures[i].lookup("action")
"skipping.", gestures[i]["action"]
.getSourceLine(), e.what());
} catch (libconfig::SettingNotFoundException& e) {
logPrintf(WARN, "Line %d: action is a required field, "
@@ -288,4 +288,4 @@ std::map<GestureAction::Direction, std::shared_ptr<Gesture>>&
std::shared_ptr<Action> GestureAction::Config::noneAction()
{
return _none_action;
}
}