summaryrefslogtreecommitdiffstats
path: root/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
diff options
context:
space:
mode:
Diffstat (limited to '4a-hal/4a-hal-manager/4a-hal-manager-cb.c')
-rw-r--r--4a-hal/4a-hal-manager/4a-hal-manager-cb.c106
1 files changed, 49 insertions, 57 deletions
diff --git a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
index ba01394..81f2c10 100644
--- a/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
+++ b/4a-hal/4a-hal-manager/4a-hal-manager-cb.c
@@ -22,6 +22,8 @@
#include <wrap-json.h>
+#include <afb/afb-binding.h>
+
#include "4a-hal-utilities-data.h"
#include "4a-hal-manager-cb.h"
@@ -32,9 +34,9 @@
******************************************************************************/
// TBD JAI : to implement
-void HalMgrDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_object *eventJ)
+void HalMgrDispatchApiEvent(afb_api_t apiHandle, const char *evtLabel, json_object *eventJ)
{
- AFB_ApiWarning(apiHandle, "Not implemented yet");
+ AFB_API_WARNING(apiHandle, "Not implemented yet");
// Use "4a-hal-manager-events.h" to handle events
}
@@ -42,58 +44,55 @@ void HalMgrDispatchApiEvent(AFB_ApiT apiHandle, const char *evtLabel, json_objec
* HAL Manager verbs functions *
******************************************************************************/
-void HalMgrPing(AFB_ReqT request)
+void HalMgrPing(afb_req_t request)
{
static int count = 0;
count++;
- AFB_ReqNotice(request, "ping count = %d", count);
- AFB_ReqSuccess(request, json_object_new_int(count), NULL);
+ AFB_REQ_NOTICE(request, "ping count = %d", count);
+ afb_req_success(request, json_object_new_int(count), NULL);
return;
}
-void HalMgrLoaded(AFB_ReqT request)
+void HalMgrLoaded(afb_req_t request)
{
int requestJsonErr = 0, allHal = 0, verbose = 0;
char cardIdString[32];
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
struct HalMgrData *HalMgrGlobalData;
struct SpecificHalData *currentHalData;
json_object *requestJson, *requestAnswer, *apiObject;
- apiHandle = (AFB_ApiT ) AFB_ReqGetApi(request);
- if(! apiHandle) {
- AFB_ReqFail(request, "api_handle", "Can't get hal manager api handle");
+ if(! (apiHandle = afb_req_get_api(request))) {
+ afb_req_fail(request, "api_handle", "Can't get hal manager api handle");
return;
}
- HalMgrGlobalData = (struct HalMgrData *) AFB_ApiGetUserData(apiHandle);
- if(! HalMgrGlobalData) {
- AFB_ReqFail(request, "hal_manager_data", "Can't get hal manager data");
+ if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) {
+ afb_req_fail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
currentHalData = HalMgrGlobalData->first;
if(! currentHalData) {
- AFB_ReqSuccess(request, NULL, "No Hal Api loaded");
+ afb_req_success(request, NULL, "No Hal Api loaded");
return;
}
requestAnswer = json_object_new_array();
if(! requestAnswer) {
- AFB_ReqFail(request, "json_answer", "Can't generate json answer");
+ afb_req_fail(request, "json_answer", "Can't generate json answer");
return;
}
- requestJson = AFB_ReqJson(request);
- if(! requestJson)
- AFB_ReqNotice(request, "Can't get request json");
+ if(! (requestJson = afb_req_json(request)))
+ AFB_REQ_NOTICE(request, "Can't get request json");
else
requestJsonErr = wrap_json_unpack(requestJson, "{s?:b s?:b}", "all", &allHal, "verbose", &verbose);
@@ -128,41 +127,38 @@ void HalMgrLoaded(AFB_ReqT request)
currentHalData = currentHalData->next;
}
- AFB_ReqSuccess(request, requestAnswer, "Requested data");
+ afb_req_success(request, requestAnswer, "Requested data");
}
-void HalMgrLoad(AFB_ReqT request)
+void HalMgrLoad(afb_req_t request)
{
int cardId = -1;
char *apiName, *sndCardPath, *info = NULL, *author = NULL, *version = NULL, *date = NULL;
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
struct HalMgrData *HalMgrGlobalData;
struct SpecificHalData *addedHal;
json_object *requestJson, *apiReceviedMetadata;
- apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
- if(! apiHandle) {
- AFB_ReqFail(request, "api_handle", "Can't get hal manager api handle");
+ if(! (apiHandle = afb_req_get_api(request))) {
+ afb_req_fail(request, "api_handle", "Can't get hal manager api handle");
return;
}
- HalMgrGlobalData = (struct HalMgrData *) AFB_ApiGetUserData(apiHandle);
- if(! HalMgrGlobalData) {
- AFB_ReqFail(request, "hal_manager_data", "Can't get hal manager data");
+ if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) {
+ afb_req_fail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
- requestJson = AFB_ReqJson(request);
- if(! requestJson) {
- AFB_ReqFail(request, "request_json", "Can't get request json");
+ if(! (requestJson = afb_req_json(request))) {
+ afb_req_fail(request, "request_json", "Can't get request json");
return;
}
if(! json_object_object_get_ex(requestJson, "metadata", &apiReceviedMetadata)) {
- AFB_ReqFail(request, "api_metadata", "Can't get json metadata section to register external hal");
+ afb_req_fail(request, "api_metadata", "Can't get json metadata section to register external hal");
return;
}
@@ -175,7 +171,7 @@ void HalMgrLoad(AFB_ReqT request)
"version", &version,
"date", &date,
"snd-dev-id", &cardId)) {
- AFB_ReqFail(request, "api_metadata", "Can't metadata of api to register");
+ afb_req_fail(request, "api_metadata", "Can't metadata of api to register");
return;
}
@@ -204,75 +200,71 @@ void HalMgrLoad(AFB_ReqT request)
// TBD JAI: add subscription to this api status events, if subscription fails, remove hal from list
- AFB_ReqSuccess(request, NULL, "Api successfully registered");
+ afb_req_success(request, NULL, "Api successfully registered");
}
-void HalMgrUnload(AFB_ReqT request)
+void HalMgrUnload(afb_req_t request)
{
char *apiName;
- AFB_ApiT apiHandle;
+ afb_api_t apiHandle;
struct HalMgrData *HalMgrGlobalData;
struct SpecificHalData *HalToRemove;
json_object *requestJson;
- apiHandle = (AFB_ApiT) AFB_ReqGetApi(request);
- if(! apiHandle) {
- AFB_ReqFail(request, "api_handle", "Can't get hal manager api handle");
+ if(! (apiHandle = afb_req_get_api(request))) {
+ afb_req_fail(request, "api_handle", "Can't get hal manager api handle");
return;
}
- HalMgrGlobalData = (struct HalMgrData *) AFB_ApiGetUserData(apiHandle);
- if(! HalMgrGlobalData) {
- AFB_ReqFail(request, "hal_manager_data", "Can't get hal manager data");
+ if(! (HalMgrGlobalData = (struct HalMgrData *) afb_api_get_userdata(apiHandle))) {
+ afb_req_fail(request, "hal_manager_data", "Can't get hal manager data");
return;
}
- requestJson = AFB_ReqJson(request);
- if(! requestJson) {
- AFB_ReqFail(request, "request_json", "Can't get request json");
+ if(! (requestJson = afb_req_json(request))) {
+ afb_req_fail(request, "request_json", "Can't get request json");
return;
}
if(wrap_json_unpack(requestJson, "{s:s}", "api", &apiName)) {
- AFB_ReqFail(request, "requested_api", "Can't get api to remove");
+ afb_req_fail(request, "requested_api", "Can't get api to remove");
return;
}
- HalToRemove = HalUtlSearchHalDataByApiName(&HalMgrGlobalData->first, apiName);
- if(! HalToRemove) {
- AFB_ReqFail(request, "requested_api", "Can't find api to remove");
+ if(! (HalToRemove = HalUtlSearchHalDataByApiName(&HalMgrGlobalData->first, apiName))) {
+ afb_req_fail(request, "requested_api", "Can't find api to remove");
return;
}
if(HalToRemove->internal) {
- AFB_ReqFail(request, "requested_api", "Can't remove an internal controller api");
+ afb_req_fail(request, "requested_api", "Can't remove an internal controller api");
return;
}
if(HalUtlRemoveSelectedHalFromList(&HalMgrGlobalData->first, HalToRemove)) {
- AFB_ReqFail(request, "unregister_error", "Didn't succeed to remove specified api");
+ afb_req_fail(request, "unregister_error", "Didn't succeed to remove specified api");
return;
}
// TBD JAI: remove subscription to this api status events
- AFB_ReqSuccess(request, NULL, "Api successfully unregistered");
+ afb_req_success(request, NULL, "Api successfully unregistered");
}
// TBD JAI : to implement
-void HalMgrSubscribeEvent(AFB_ReqT request)
+void HalMgrSubscribeEvent(afb_req_t request)
{
- AFB_ReqWarning(request, "Not implemented yet");
+ AFB_REQ_WARNING(request, "Not implemented yet");
- AFB_ReqSuccess(request, json_object_new_boolean(0), NULL);
+ afb_req_success(request, json_object_new_boolean(0), NULL);
}
// TBD JAI : to implement
-void HalMgrUnsubscribeEvent(AFB_ReqT request)
+void HalMgrUnsubscribeEvent(afb_req_t request)
{
- AFB_ReqWarning(request, "Not implemented yet");
+ AFB_REQ_WARNING(request, "Not implemented yet");
- AFB_ReqSuccess(request, json_object_new_boolean(0), NULL);
+ afb_req_success(request, json_object_new_boolean(0), NULL);
}