summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2018-09-07 10:10:38 +0200
committerRomain Forlot <romain.forlot@iot.bzh>2018-09-07 10:10:38 +0200
commitbba4befcc57ff4eb106a01b416119da01accfcd1 (patch)
treea398a743e1542dc34208bf1a38b5fd81b1528e0e
parenta826da17cdfa4586f66b9d3350e10d6799609a88 (diff)
Use controller new behavior that add objectsflounder_5.99.6flounder/5.99.65.99.6
Adding objects to events section using the controller function to create a mock-api. Change-Id: Ic538c02f08b2f4f3376ffa6e9b9ffcbef1592599 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
m---------app-controller-submodule0
-rw-r--r--src/mapis.c37
2 files changed, 5 insertions, 32 deletions
diff --git a/app-controller-submodule b/app-controller-submodule
-Subproject 82820f44b1307ef8c6e12a505f383037fdad9fc
+Subproject d6eb01e14f2340c950ff8476d7b112f91297aae
diff --git a/src/mapis.c b/src/mapis.c
index ba72857..e40f3aa 100644
--- a/src/mapis.c
+++ b/src/mapis.c
@@ -29,8 +29,7 @@ struct mapisHandleT {
};
static int LoadOneMapi(void *data, AFB_ApiT apiHandle) {
- int savedCount = 0, count = 0, idx = 0;
- CtlActionT *savedActions = NULL, *newActions = NULL;
+ int idx = 0;
struct mapisHandleT *mapisHandle = (struct mapisHandleT*)data;
CtlConfigT *ctrlConfig = AFB_ApiGetUserData(mapisHandle->mainApiHandle);
@@ -48,40 +47,14 @@ static int LoadOneMapi(void *data, AFB_ApiT apiHandle) {
if(mapisHandle->eventsJ) {
// Add actions to the section to be able to respond to defined events.
for(idx = 0; ctrlConfig->sections[idx].key != NULL; ++idx) {
- if(! strcasecmp(ctrlConfig->sections[idx].key, "events")) {
- savedActions = ctrlConfig->sections[idx].actions;
+ if(! strcasecmp(ctrlConfig->sections[idx].key, "events"))
break;
- }
}
- newActions = ActionConfig(apiHandle, mapisHandle->eventsJ, 0);
- if(savedActions) {
- while(savedActions[savedCount].uid != NULL)
- savedCount++;
+ if( AddActionsToSection(apiHandle, &ctrlConfig->sections[idx], mapisHandle->eventsJ, 0) ) {
+ AFB_ApiError(apiHandle, "Wasn't able to add new events to %s", ctrlConfig->sections[idx].uid);
+ return -1;
}
-
- while(newActions[count].uid != NULL)
- count++;
-
- int total = savedCount + count;
- count = 0;
- savedCount = 0;
- CtlActionT * mergedActions = calloc(total + 1, sizeof(CtlActionT));
-
- if(savedActions) {
- while(savedActions[count].uid != NULL) {
- mergedActions[count] = savedActions[count];
- count++;
- }
- }
-
- while(newActions[savedCount].uid != NULL && count <= total) {
- mergedActions[count] = newActions[savedCount];
- count++;
- savedCount++;
- }
-
- ctrlConfig->sections[idx].actions = mergedActions;
}
// declare an event event manager for this API;