summaryrefslogtreecommitdiffstats
path: root/ctl-lib/ctl-action.c
AgeCommit message (Collapse)AuthorFilesLines
2018-12-17Shared library: update to a v3 shared libraryRomain Forlot1-48/+40
- AFB_BINDING_VERSION = 3 - remove preprocessor variables - mandatory lua - name of library is ctl-utilities - does not work with v2 versions - remove afb-definitions.h - use of the GNUinstalldirs module to set the destination directories. Change-Id: Ifdf12885ffad5003ecbbcf3639af63060f0ebc7e Signed-off-by: Clément Bénier <clement.benier@iot.bzh> Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Retrieve plugin list from api rather than a globalRomain Forlot1-5/+0
Change-Id: Iba7c564eea48495c76de8ca919725a2e4b332fd6 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Pass the plugin to action.Romain Forlot1-0/+1
Pass the plugin to action using source structure. Plugin pointer is now accessible from anywhere in the plugin callbacks. Clean deprecated function. Change-Id: Idf50728af0b3573a45c4731d4343cf67741b662c Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Add ctlPlugins array to the ctlConfig structureRomain Forlot1-0/+5
This lets you add new actions to a section from a plugin, typically at its init step. Change-Id: I33a61c6162d25332d680d8a0e2d1841a457e0e80 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Change loading configuration object behaviorRomain Forlot1-0/+44
This changes the default behavior when loading actions. Now, it appends the new actions to the old ones instead of replacing them when called several times. If there were no actions previously loaded then it just loads normally the actions. Change-Id: Ica58a3edf4a9bf18ae31c6b6a5fa329e7ec5478b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix: Wrong variable definitionRomain Forlot1-1/+1
Variable is already defined earlier with all function scope. Redefining here make the variable value wrong at the ending return statement. Change-Id: I85269d1f60a7e1b844d19dd902149fa25da50844 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Migration to v3Romain Forlot1-5/+5
This makes controller fully compatible with binding v3 and also keeps the compatibility with the Pre-V3 + DYNAPI bindings. Change-Id: Iaa47e51b9cb964bbe2f050784fca355c780673f8 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Keep json unmodified during action executionJonathan Aillet1-7/+12
Keep passed json object unmodified during action execution. Before, the action arguments were added in the json passed (so, the json was modified, even for its provider). Now, if action arguments need to be added to the json to execute an action, 'ActionExecOne' function clone the passed json object, add action arguments into it, and use it to call the action. Change-Id: If102cc943326c17aad52cfde735362a72ad35a9a Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-12-13Fixed spelling of AFB_ReqSuccessSebastien Douheret1-1/+1
Also change event message from notice to debug level. Change-Id: I8dc891343ee7f744ea0e3c07455806eaf34c1d7e Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2018-12-13Remove an unnecessary variableJonathan Aillet1-3/+1
This variable was meant to save the result of a function call, and be used into an 'if' statment. So, the function call was put directly into the 'if' statment. Bug-AGL: SPEC-1405 Change-Id: Ia352f5bbf310eadd91a19d80b813dc9f6d054028 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-12-13Make parsing of action loading non blockingJonathan Aillet1-1/+1
When an action is loaded in controller, parsing the json passed to describe the action was sending back an error if an unknown field was present. Now, the parsing just ignore unknown fields. Bug-AGL: SPEC-1405 Change-Id: If95144ad6190d5d2a45d731e82b28ab4caae7c32 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-12-13Use macro to test request validityJonathan Aillet1-3/+3
Use macro to test request validity before reponding to an api call. This macro handles if request is a pointer or a structure (depending if dynamic api are used). Change-Id: I2cd6539e0fe0b6e0324e82fbeef62731d0323be9 Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-12-13Fixed build warnings with gcc >= 7.3Sebastien Douheret1-1/+1
Reduced the number of warnings in native host configuration (here Tumbleweed) in order to not hide true/real warnings that may appear in the future. Signed-off-by: Sebastien Douheret <sebastien.douheret@iot.bzh>
2018-12-13Correct way that api actions are handled in controllerJonathan Aillet1-23/+25
Don't create a new object each time a action is executed. Correction in the way that args are added in the api query. Correction to return the response of the api call if received. Optimization of how get/put are done in 'ActionExecOne' function. Change-Id: I30d0d6450599b7da7bfa9ad29b21d1be8ea6243e Signed-off-by: Jonathan Aillet <jonathan.aillet@iot.bzh>
2018-12-13Fixed compilation warnings with gcc-7.2.0Thierry Bultel1-1/+1
Replaced some 'size_t' by 'int' Change-Id: Iaf58b4b65f9aa2e82c0a87af45f21ca62fa4d84e Signed-off-by: Thierry Bultel <thierry.bultel@iot.bzh>
2018-12-13Good usage of strncat and strncpyRomain Forlot1-14/+13
This change ensure that there are no write over the destination buffer size Change-Id: Ic213e70fab83dfae39a8ff030c823a6ce68aab64 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Detect failure at OnLoad action callsRomain Forlot1-1/+2
Be able to detect that an action has failed on an Onload section processing to avoid retrieving a wrong context after that. Change-Id: If694b11eb0a37154b539c421e43bebdb15d498c0 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Correctly release request JSON objectRomain Forlot1-1/+1
A JSON object coming from an AFB request is handled by the appfw. So, it release it once request has been executed. ActionExecOne also decrement the reference count of the json_object, so to make the count right it is needed to call a json_object_get here. Change-Id: I4c74a767e8e51e8b975ebe66c97f5b1f5b3aba05 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Don't use assert in controller.Romain Forlot1-3/+2
Rather use tests with a test framework. Change-Id: I1c626c7cc96403587a57ae23af67c95f6ed2f862 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix: arguments pointer NULL checkRomain Forlot1-2/+5
Change-Id: I666136b1f1fb21d223fa16f299de2ce5430a0c7e Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Simplify action definitionRomain Forlot1-19/+67
Because before uri could be a path it wasn't suits for parsing as we can't have any character chosen as separator. As now, first part isn't a path but rather a plugin/resource uid then it fine since the separator isn't allowed in the uid So # is forbidden for uid by the schema. Change-Id: Ida3d7acb46687188c44a472c057c58301cb1d9c6 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix: Dyn API Action loading procedureRomain Forlot1-70/+58
Change-Id: Ibb7dbc32580100c588d06e283abb57cc37875312 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13FormatRomain Forlot1-12/+11
Change-Id: Ied901f39cd6814e5afd9811248b0a1fb401f3e76 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Improve json object releaseRomain Forlot1-3/+2
For convenience queryJ will always be released. Users has to call json_object_get to be able to use it after that. API subcall use an intermediate variable to avoid modifying this parameter in case of user wanna use it after that. Change-Id: I98f478d3fc0c4ef28234811333b9effd8289e74d Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Improve way to loading an actionRomain Forlot1-66/+135
Split and cleaner function that load from JSON object an object CtlActionT that could be used by the controller. Also use a new syntax that reduce the number of JSON fields to parse based on a URI syntax. Change-Id: Iabc447368ca56e3a4279fb728ba2f546e11c961b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Upgrade config schemaRomain Forlot1-6/+0
Change the way to load LUA scripts. They are now considerate as Plugin and loads with them. This imply rework of how to search and find plugins as well as the way to load LUA. Also load an harcoded LUA scripts providing LUA helpers and managing global variables lock unlock mechanism Change-Id: I64e38aa27278d0cfdca787155db2d0c89953f905 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Release json_objects used to launched the actionRomain Forlot1-0/+4
Instead of only have API subcall releasing the json_object now release in all cases to be coherent. This should be argument to be passed to an action, treated in that action then after that has been done, this object has no more meanings and should be released. Change-Id: I371f0c3db34f4126a812d70b7e3ccb9f8bb5f776 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Format, get rid of conversion type warning.Romain Forlot1-1/+1
Change-Id: I8cde66dc613fd36e7061f45918520ecd1cdf2825 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Use an intermadiary variable avoiding side effets.Romain Forlot1-10/+13
Previously using parameter and modifying it which could involves side effects. Better to use an intermediary json_object to be fills with action->argsJ and queryJ object meld together. Also fix segfault after json_object_put called inside AFB_ServiceSync doing a json_object_get() on object to be conserved Change-Id: I4618a7bc87e111afa1fe047168ba7232241ac4c8 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix segfault when no l2c functions definedRomain Forlot1-1/+1
Mark "ldpath" parameter as optional like it is. Change-Id: If32e078f5a4349ab895b1fd4b8f0a8c542d247a1 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Get back on track l2c functions.Romain Forlot1-0/+6
Change-Id: I8425f0de60a35b4e287c8829fe72cbca80bc55df Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Avoid compile warning, memory leaks, lintingRomain Forlot1-1/+1
Change-Id: Ida18aeab20d5b894609c1a9c2f6fc2a71a0b4a23 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Fix wrong json object pointed.Romain Forlot1-3/+2
Change-Id: Id485aa5ddf8d78a1fc48922cb3c3161fb65dea1b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Wrong increment always fails load an actionRomain Forlot1-1/+0
Change-Id: I7a8a3ac4846f1190caf1a4dde066e50dc592d58b Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Get back lua2c functions parsed at plugin loadRomain Forlot1-2/+8
Format JSON unpack operations Change-Id: Iaed0988d8536ad1df60a32a610e69e35485fc9f8 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13FormatingRomain Forlot1-18/+18
Change-Id: I2b805a60b67db1a72b429093256999673e2c3964 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13Add action method to execute an action from its uidRomain Forlot1-2/+22
Change-Id: Ic8f1d418db228ca8c646263b32a2431931a6a4be Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
2018-12-13First working version as submoduleFulup Ar Foll1-17/+28
2018-12-131st V2/pre-V3 versionfulup1-40/+79
2018-12-13Remove NetbeansFulup Ar Foll1-0/+174