aboutsummaryrefslogtreecommitdiffstats
path: root/signal-composer-binding/signal-composer.cpp
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-09-15 16:29:17 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2017-12-14 11:00:25 +0100
commit677cde6288a4574b8251a4a532b1d9e1594b09b2 (patch)
treec510a0cdd76e2b8de1cdaf254fd270c8bfebae42 /signal-composer-binding/signal-composer.cpp
parenteabae24ea592420de46e36f0b1af5d39eee5b8a4 (diff)
Subscription by plugin to signals
Change-Id: Icb923f87df2be8eb664106bc9077b3a8221dd3ce 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.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/signal-composer-binding/signal-composer.cpp b/signal-composer-binding/signal-composer.cpp
index a1300e3..3158797 100644
--- a/signal-composer-binding/signal-composer.cpp
+++ b/signal-composer-binding/signal-composer.cpp
@@ -114,7 +114,7 @@ CtlActionT* bindingApp::convert2Action(const std::string& name, json_object* act
int bindingApp::loadOneSourceAPI(json_object* sourceJ)
{
json_object *initJ = nullptr, *getSignalJ = nullptr;
- CtlActionT *initCtl, *getSignalCtl;
+ CtlActionT *initCtl = nullptr, *getSignalCtl = nullptr;
const char *api, *info;
int err = wrap_json_unpack(sourceJ, "{ss,s?s,s?o,s?o !}",
@@ -205,7 +205,6 @@ int bindingApp::loadOneSignal(json_object* signalJ)
}
// Process sources JSON object
- // TODO: claneys, really needs to factorize JSON array processing
if (json_object_get_type(sourcesJ) == json_type_array)
{
int count = json_object_array_length(sourcesJ);
@@ -251,19 +250,22 @@ int bindingApp::loadSignals(CtlSectionT* section, json_object *signalsJ)
int err = 0;
bindingApp& bApp = instance();
- if (json_object_get_type(signalsJ) == json_type_array)
+ if(signalsJ)
{
- int count = json_object_array_length(signalsJ);
-
- for (int idx = 0; idx < count; idx++)
+ if (json_object_get_type(signalsJ) == json_type_array)
{
- json_object *signalJ = json_object_array_get_idx(signalsJ, idx);
- err = bApp.loadOneSignal(signalJ);
- if (err) return err;
+ int count = json_object_array_length(signalsJ);
+
+ for (int idx = 0; idx < count; idx++)
+ {
+ json_object *signalJ = json_object_array_get_idx(signalsJ, idx);
+ err = bApp.loadOneSignal(signalJ);
+ if (err) return err;
+ }
}
+ else
+ {err = bApp.loadOneSignal(signalsJ);}
}
- else
- {err = bApp.loadOneSignal(signalsJ);}
return err;
}
@@ -306,3 +308,16 @@ CtlConfigT* bindingApp::ctlConfig()
{
return ctlConfig_;
}
+
+int bindingApp::execSubscription() const
+{
+ int err = 0;
+ for(const SourceAPI& srcAPI: sourcesList_)
+ {
+ if (srcAPI.api() != std::string(ctlConfig_->api))
+ {
+ err += srcAPI.makeSubscription();
+ }
+ }
+ return err;
+}