aboutsummaryrefslogtreecommitdiffstats
path: root/Controler-afb/ctl-binding.h
diff options
context:
space:
mode:
authorfulup <fulup.arfoll@iot.bzh>2017-08-10 17:37:24 +0200
committerfulup <fulup.arfoll@iot.bzh>2017-08-10 17:37:24 +0200
commiteb6a78be524aaee70fca55b86a7b065763591178 (patch)
tree9db4e1e9f75ef18b90255a468ab5087e65bba5c3 /Controler-afb/ctl-binding.h
parent302d4bfcc49c69ea8251e1755ba3876555f680aa (diff)
Work in Progress
Diffstat (limited to 'Controler-afb/ctl-binding.h')
-rw-r--r--Controler-afb/ctl-binding.h80
1 files changed, 33 insertions, 47 deletions
diff --git a/Controler-afb/ctl-binding.h b/Controler-afb/ctl-binding.h
index e53d2ca..77d1b6e 100644
--- a/Controler-afb/ctl-binding.h
+++ b/Controler-afb/ctl-binding.h
@@ -14,33 +14,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <systemd/sd-event.h>
-#include "audio-common.h"
#ifndef CONTROLER_BINDING_INCLUDE
#define CONTROLER_BINDING_INCLUDE
+#define AFB_BINDING_VERSION 2
+#include <afb/afb-binding.h>
+#include <json-c/json.h>
+
+#ifndef PUBLIC
+ #define PUBLIC
+#endif
+#define STATIC static
+
// polctl-binding.c
PUBLIC int CtlBindingInit ();
// ctl-timerevt.c
// ----------------------
-#define DEFAULT_PAUSE_DELAY 3000
-#define DEFAULT_TEST_COUNT 1
-typedef int (*timerCallbackT)(void *context);
-typedef struct {
- int value;
- const char *label;
-} AutoTestCtxT;
-
-typedef struct TimerHandleS {
- int count;
- int delay;
- AutoTestCtxT *context;
- timerCallbackT callback;
- sd_event_source *evtSource;
-} TimerHandleT;
+
PUBLIC int TimerEvtInit (void);
PUBLIC afb_event TimerEvtGet(void);
@@ -49,46 +42,39 @@ PUBLIC void ctlapi_event_test (afb_req request);
// ctl-policy
// -----------
-typedef struct PolicyActionS{
- const char* label;
- const char* api;
- const char* verb;
- json_object *argsJ;
- const char *info;
- int timeout;
- json_object* (*actionCB)(struct PolicyActionS *action,json_object *response, void *context);
-} PolicyActionT;
-
-typedef struct {
- const char* label;
- const char *info;
- const char *version;
- void *context;
-} PolicyHandleT;
-
-typedef struct {
- char *sharelib;
- void *dlHandle;
- PolicyHandleT **handle;
- PolicyActionT **onload;
- PolicyActionT **events;
- PolicyActionT **controls;
-} PolicyCtlConfigT;
-
typedef enum {
CTLAPI_NAVIGATION,
CTLAPI_MULTIMEDIA,
CTLAPI_EMERGENCY,
CTL_NONE=-1
-} PolicyCtlEnumT;
+} DispatchCtlEnumT;
-PUBLIC int PolicyInit(void);
-PUBLIC json_object* ScanForConfig (char* searchPath, char * pre, char *ext);
-PUBLIC void ctlapi_authorize (PolicyCtlEnumT control, afb_req request);
+
+typedef enum {
+ CTL_MODE_NONE=0,
+ CTL_MODE_API,
+ CTL_MODE_CB,
+ CTL_MODE_LUA,
+} CtlRequestModeT;
+
+typedef struct DispatchActionS{
+ const char *info;
+ const char* label;
+ CtlRequestModeT mode;
+ const char* api;
+ const char* call;
+ json_object *argsJ;
+ int timeout;
+ json_object* (*actionCB)(struct DispatchActionS *action,json_object *response, void *context);
+} DispatchActionT;
+
+PUBLIC int DispatchInit(void);
+PUBLIC void ctlapi_dispatch (DispatchCtlEnumT control, afb_req request);
// ctl-lua.c
PUBLIC int LuaLibInit ();
+PUBLIC json_object* ScanForConfig (char* searchPath, char * pre, char *ext);
PUBLIC void ctlapi_lua_docall (afb_req request);
PUBLIC void ctlapi_lua_dostring (afb_req request);
PUBLIC void ctlapi_lua_doscript (afb_req request);