diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-12-18 16:40:50 +0100 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-12-18 17:40:02 +0100 |
commit | 15efef0b066a1416778a304ed41cdf3ecb3209ef (patch) | |
tree | 507c2eb9ff510d20e0ea3fa7d6b5b2e176364232 /signal-composer-binding/signal-composer-binding.cpp | |
parent | 1b3411359d6a0e53f12811436a5410104816da34 (diff) |
More security to add new signals/source at runtime
Also renamed loadConf to addObjects to avoid confusion
with loadConf at init time.
Improve file research if fullpath not procided by searching
in the CONTROL_CONFIG_PATH.
Change-Id: I8e541ff7437f0378bcdc7215ff9f391dcce6db9f
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'signal-composer-binding/signal-composer-binding.cpp')
-rw-r--r-- | signal-composer-binding/signal-composer-binding.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/signal-composer-binding/signal-composer-binding.cpp b/signal-composer-binding/signal-composer-binding.cpp index d9f1f01..9afed5a 100644 --- a/signal-composer-binding/signal-composer-binding.cpp +++ b/signal-composer-binding/signal-composer-binding.cpp @@ -168,7 +168,7 @@ void unsubscribe(afb_req request) } /// @brief verb that loads JSON configuration (old SigComp.json file now) -void loadConf(afb_req request) +void addObjects(afb_req request) { Composer& composer = Composer::instance(); json_object *sourcesJ = nullptr, @@ -178,6 +178,13 @@ void loadConf(afb_req request) if(filepath) { json_object *fileJ = json_object_from_file(filepath); + if(!fileJ) + { + json_object* responseJ = ScanForConfig(CONTROL_CONFIG_PATH, CTL_SCAN_RECURSIVE, filepath, ".json"); + filepath = ConfigSearch(nullptr, responseJ); + if(filepath) + {fileJ = json_object_from_file(filepath);} + } json_object_object_get_ex(fileJ, "sources", &sourcesJ); json_object_object_get_ex(fileJ, "signals", &signalsJ); |