From 32837eddf0644aef8c71a208d87aaa8140eeafaa Mon Sep 17 00:00:00 2001 From: Li Xiaoming Date: Mon, 18 Nov 2019 13:52:01 +0100 Subject: Migration to binding V3 Bug-AGL: SPEC-2745 Change-Id: Idbaecfaf7d48e35fcb9d9964d682ff99702a05cd Signed-off-by: Li Xiaoming --- src/af-steering-wheel-binding.c | 38 +++++++++++++++++++------------------- src/af-steering-wheel-binding.h | 12 ++++++------ src/bind_event.c | 4 ++-- src/bind_event.h | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/af-steering-wheel-binding.c b/src/af-steering-wheel-binding.c index 908bf71..8b75175 100644 --- a/src/af-steering-wheel-binding.c +++ b/src/af-steering-wheel-binding.c @@ -131,7 +131,7 @@ static int connection(struct wheel_conf *conf) /** * get method. */ -static void get(struct afb_req req) +static void get(afb_req_t req) { } @@ -161,7 +161,7 @@ static void _listup_properties(struct prop_info_t *property_info) } } -static void list(struct afb_req req) +static void list(afb_req_t req) { if (tmplists != NULL) { @@ -171,19 +171,19 @@ static void list(struct afb_req req) if (tmplists == NULL) { ERRMSG("not enough memory"); - afb_req_fail(req,"not enough memory", NULL); + afb_req_reply(req, NULL, "not enough memory", NULL); return; } (void)canid_walker(_listup_properties); - afb_req_success(req, tmplists, NULL); + afb_req_reply(req, tmplists, NULL, NULL); } /** * subscribe method. */ -static int subscribe_all(struct afb_req req, struct json_object *apply); +static int subscribe_all(afb_req_t req, struct json_object *apply); -static int subscribe_signal(struct afb_req req, const char *name, struct json_object *apply) +static int subscribe_signal(afb_req_t req, const char *name, struct json_object *apply) { struct bind_event_t *event; @@ -218,7 +218,7 @@ static int subscribe_signal(struct afb_req req, const char *name, struct json_o return 0; } -static int subscribe_all(struct afb_req req, struct json_object *apply) +static int subscribe_all(afb_req_t req, struct json_object *apply) { int i; int nProp; @@ -230,7 +230,7 @@ static int subscribe_all(struct afb_req req, struct json_object *apply) return err; } -static void subscribe(struct afb_req req) +static void subscribe(afb_req_t req) { struct json_object *apply; int err = 0; @@ -240,7 +240,7 @@ static void subscribe(struct afb_req req) if (event == NULL) { ERRMSG("Unknwon subscrive event args"); - afb_req_fail(req, "error", NULL); + afb_req_reply(req, NULL, "error", NULL); return; } apply = json_object_new_object(); @@ -248,12 +248,12 @@ static void subscribe(struct afb_req req) if (!err) { - afb_req_success(req, apply, NULL); + afb_req_reply(req, apply, NULL, NULL); } else { json_object_put(apply); - afb_req_fail(req, "error", NULL); + afb_req_reply(req, NULL, "error", NULL); } } @@ -261,9 +261,9 @@ static void subscribe(struct afb_req req) * unsubscribe method. */ -static int unsubscribe_all(struct afb_req req); +static int unsubscribe_all(afb_req_t req); -static int unsubscribe_signal(struct afb_req req, const char *name) +static int unsubscribe_signal(afb_req_t req, const char *name) { struct bind_event_t *event; if(strcmp(name, "*") == 0) @@ -286,7 +286,7 @@ static int unsubscribe_signal(struct afb_req req, const char *name) return 0; } -static int unsubscribe_all(struct afb_req req) +static int unsubscribe_all(afb_req_t req) { int i; int nProp; @@ -300,7 +300,7 @@ static int unsubscribe_all(struct afb_req req) return err; } -static void unsubscribe(struct afb_req req) +static void unsubscribe(afb_req_t req) { struct json_object *args, *val; int n,i; @@ -327,9 +327,9 @@ static void unsubscribe(struct afb_req req) } if (!err) - afb_req_success(req, NULL, NULL); + afb_req_reply(req, NULL, NULL, NULL); else - afb_req_fail(req, "error", NULL); + afb_req_reply(req, NULL, "error", NULL); } /* @@ -400,7 +400,7 @@ static int init() /* * array of the verbs exported to afb-daemon */ -static const struct afb_verb_v2 binding_verbs[] = +static const afb_verb_t binding_verbs[] = { /* VERB'S NAME SESSION MANAGEMENT FUNCTION TO CALL Authorization */ { .verb= "get", .session= AFB_SESSION_NONE, .callback= get, .info = "get", .auth = NULL }, @@ -414,7 +414,7 @@ static const struct afb_verb_v2 binding_verbs[] = /* * description of the binding for afb-daemon */ -const struct afb_binding_v2 afbBindingV2 = +const afb_binding_t afbBindingExport = { .api = "steering-wheel", .specification = NULL, diff --git a/src/af-steering-wheel-binding.h b/src/af-steering-wheel-binding.h index 1b7323c..d7130fa 100644 --- a/src/af-steering-wheel-binding.h +++ b/src/af-steering-wheel-binding.h @@ -17,17 +17,17 @@ #ifndef _AF_WHEEL_BINDING_H_ #define _AF_WHEEL_BINDING_H_ -#define AFB_BINDING_VERSION 2 +#define AFB_BINDING_VERSION 3 #include #include "prop_info.h" #if !defined(NO_BINDING_VERBOSE_MACRO) -#define ERRMSG(msg, ...) AFB_ERROR(msg,##__VA_ARGS__) -#define WARNMSG(msg, ...) AFB_WARNING(msg,##__VA_ARGS__) -#define DBGMSG(msg, ...) AFB_DEBUG(msg,##__VA_ARGS__) -#define INFOMSG(msg, ...) AFB_INFO(msg,##__VA_ARGS__) -#define NOTICEMSG(msg, ...) AFB_NOTICE(msg,##__VA_ARGS__) +#define ERRMSG(msg, ...) AFB_API_ERROR(afbBindingV3root, msg, ##__VA_ARGS__) +#define WARNMSG(msg, ...) AFB_API_WARNING(afbBindingV3root, msg, ##__VA_ARGS__) +#define DBGMSG(msg, ...) AFB_API_DEBUG(afbBindingV3root, msg, ##__VA_ARGS__) +#define INFOMSG(msg, ...) AFB_API_INFO(afbBindingV3root, msg, ##__VA_ARGS__) +#define NOTICEMSG(msg, ...) AFB_API_NOTICE(afbBindingV3root, msg, ##__VA_ARGS__) #endif extern int notify_property_changed(struct prop_info_t *property_info); diff --git a/src/bind_event.c b/src/bind_event.c index 01887cd..15e2b5d 100644 --- a/src/bind_event.c +++ b/src/bind_event.c @@ -81,7 +81,7 @@ struct bind_event_t *register_event(const char *name) if (ent == NULL) { ERRMSG("not enough memory"); - afb_event_drop(evt->event); + afb_event_unref(evt->event); free(evt); return NULL; } @@ -106,7 +106,7 @@ int remove_event(const char *name) return 0; } dnode = *(struct bind_event_t **)p; - afb_event_drop(dnode->event); + afb_event_unref(dnode->event); tdelete(&key, &bind_event_root, compare); free(dnode); diff --git a/src/bind_event.h b/src/bind_event.h index 5e44a5b..8c49165 100644 --- a/src/bind_event.h +++ b/src/bind_event.h @@ -21,7 +21,7 @@ struct bind_event_t { const char *name; /* name of the event : IvI Property-Name */ - struct afb_event event; /* the event for the binder */ + afb_event_t event; /* the event for the binder */ struct prop_info_t *raw_info; }; -- cgit 1.2.3-korg