aboutsummaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal-composer.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-12-18 16:40:50 +0100
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-18 17:40:02 +0100
commit15efef0b066a1416778a304ed41cdf3ecb3209ef (patch)
tree507c2eb9ff510d20e0ea3fa7d6b5b2e176364232 /signal-composer-binding/signal-composer.cpp
parent1b3411359d6a0e53f12811436a5410104816da34 (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.cpp')
-rw-r--r--signal-composer-binding/signal-composer.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp
index 7ba9c27..17ba16f 100644
--- a/signal-composer-binding/signal-composer.cpp
+++ b/signal-composer-binding/signal-composer.cpp
@@ -264,7 +264,6 @@ int Composer::pluginsLoad(AFB_ApiT apiHandle, CtlSectionT *section, json_object
}
else
{
-
completePluginsJ = json_object_new_array();
json_object_array_add(completePluginsJ, pluginsJ);
json_object_array_add(completePluginsJ, builtinJ);
@@ -343,6 +342,7 @@ int Composer::loadSourcesAPI(AFB_ApiT apihandle, CtlSectionT* section, json_obje
if(sourcesJ)
{
+ int count = 1;
json_object *sigCompJ = nullptr;
// add the signal composer itself as source
wrap_json_pack(&sigCompJ, "{ss,ss,ss}",
@@ -355,7 +355,7 @@ int Composer::loadSourcesAPI(AFB_ApiT apihandle, CtlSectionT* section, json_obje
if (json_object_get_type(sourcesJ) == json_type_array)
{
- int count = json_object_array_length(sourcesJ);
+ count = json_object_array_length(sourcesJ);
for (int idx = 0; idx < count; idx++)
{
@@ -369,6 +369,7 @@ int Composer::loadSourcesAPI(AFB_ApiT apihandle, CtlSectionT* section, json_obje
if ((err = composer.loadOneSourceAPI(sourcesJ))) return err;
if (sigCompJ && (err = composer.loadOneSourceAPI(sigCompJ))) return err;
}
+ AFB_NOTICE("%d new sources added to service", count);
}
else
{Composer::instance().initSourcesAPI();}
@@ -480,6 +481,7 @@ int Composer::loadOneSignal(json_object* signalJ)
// Overwrite uid to the signal one instead of the default
if(onReceivedCtl)
{onReceivedCtl->uid = uid;}
+ int count = 1;
}
else {onReceivedCtl = convert2Action(uid, onReceivedJ);}
@@ -498,10 +500,10 @@ int Composer::loadSignals(AFB_ApiT apihandle, CtlSectionT* section, json_object
if(signalsJ)
{
+ int count = 1;
if (json_object_get_type(signalsJ) == json_type_array)
{
- int count = json_object_array_length(signalsJ);
-
+ count = json_object_array_length(signalsJ);
for (int idx = 0; idx < count; idx++)
{
json_object *signalJ = json_object_array_get_idx(signalsJ, idx);
@@ -510,6 +512,7 @@ int Composer::loadSignals(AFB_ApiT apihandle, CtlSectionT* section, json_object
}
else
{err = composer.loadOneSignal(signalsJ);}
+ AFB_NOTICE("%d new signals added to service", count);
}
return err;