aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorScott Murray <scott.murray@konsulko.com>2019-10-07 17:36:39 -0400
committerScott Murray <scott.murray@konsulko.com>2019-10-08 18:18:43 -0400
commit218cc70720fce6235d74fd4d851629dfda34a00e (patch)
treeec433213f54c97855816a29991c0b7eb299f4fc9 /src
parentd8ddb879b61b956d0a7ebd6a181595c9a41a9562 (diff)
Switch to appcontroller library
Remove old app-controller submodule usage in favor of library from the toolchain. Also update dynamic API calls for V3. Bug-AGL: SPEC-2857 Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: Ib52d00939e0c5998004c96b9ec1a41905f8d71fb
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/plugins/CMakeLists.txt2
-rw-r--r--src/plugins/VshlCapabilitiesApi.cpp16
-rw-r--r--src/plugins/afb/AFBApiImpl.cpp8
-rw-r--r--src/plugins/afb/AFBApiImpl.h6
-rw-r--r--src/plugins/afb/AFBRequestImpl.cpp6
-rw-r--r--src/plugins/afb/AFBRequestImpl.h6
-rw-r--r--src/plugins/afb/include/AFBEventImpl.h6
-rw-r--r--src/plugins/afb/src/AFBEventImpl.cpp8
-rw-r--r--src/plugins/utilities/logging/Logger.cpp14
-rw-r--r--src/plugins/utilities/logging/Logger.h8
-rw-r--r--src/vshl-capabilities-binding.c48
12 files changed, 62 insertions, 67 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 6ca565d..9e527e6 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -37,7 +37,6 @@ PROJECT_TARGET_ADD(vshl-capabilities)
# Library dependencies (include updates automatically)
TARGET_LINK_LIBRARIES(${TARGET_NAME}
- ctl-utilities
${link_libraries})
add_subdirectory("plugins")
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 20c13e9..dd1cd8e 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -86,7 +86,6 @@ PROJECT_TARGET_ADD(vshl-capabilities-api)
TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}
PUBLIC ${GLIB_PKG_INCLUDE_DIRS}
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}"
- PRIVATE "${CMAKE_SOURCE_DIR}/app-controller/ctl-lib"
)
# Library dependencies (include updates automatically)
@@ -136,7 +135,6 @@ PROJECT_TARGET_ADD(vshl-capabilities-api)
TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}_Test
PUBLIC ${GLIB_PKG_INCLUDE_DIRS}
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}"
- PRIVATE "${CMAKE_SOURCE_DIR}/app-controller/ctl-lib"
)
TARGET_LINK_LIBRARIES(${TARGET_NAME}_Test
diff --git a/src/plugins/VshlCapabilitiesApi.cpp b/src/plugins/VshlCapabilitiesApi.cpp
index 066edd5..78c686f 100644
--- a/src/plugins/VshlCapabilitiesApi.cpp
+++ b/src/plugins/VshlCapabilitiesApi.cpp
@@ -117,7 +117,7 @@ CTLP_CAPI(guiMetadataSubscribe, source, argsJ, eventJ) {
}
}
- AFB_ReqSuccess(
+ afb_req_success(
source->request, json_object_new_string("Subscription to guimetadata events successfully completed."), NULL);
return 0;
}
@@ -165,7 +165,7 @@ CTLP_CAPI(guiMetadataPublish, source, argsJ, eventJ) {
return -1;
}
- AFB_ReqSuccess(source->request, json_object_new_string("Successfully published guimetadata messages."), NULL);
+ afb_req_success(source->request, json_object_new_string("Successfully published guimetadata messages."), NULL);
return 0;
}
@@ -201,7 +201,7 @@ CTLP_CAPI(phonecontrolSubscribe, source, argsJ, eventJ) {
}
}
- AFB_ReqSuccess(
+ afb_req_success(
source->request, json_object_new_string("Subscription to phone control events successfully completed."), NULL);
return 0;
}
@@ -245,7 +245,7 @@ CTLP_CAPI(phonecontrolPublish, source, argsJ, eventJ) {
return -1;
}
- AFB_ReqSuccess(source->request, json_object_new_string("Successfully published phone control messages."), NULL);
+ afb_req_success(source->request, json_object_new_string("Successfully published phone control messages."), NULL);
return 0;
}
@@ -281,7 +281,7 @@ CTLP_CAPI(navigationSubscribe, source, argsJ, eventJ) {
}
}
- AFB_ReqSuccess(
+ afb_req_success(
source->request, json_object_new_string("Subscription to navigation events successfully completed."), NULL);
return 0;
}
@@ -325,7 +325,7 @@ CTLP_CAPI(navigationPublish, source, argsJ, eventJ) {
return -1;
}
- AFB_ReqSuccess(source->request, json_object_new_string("Successfully published navigation messages."), NULL);
+ afb_req_success(source->request, json_object_new_string("Successfully published navigation messages."), NULL);
return 0;
}
@@ -361,7 +361,7 @@ CTLP_CAPI(playbackControllerSubscribe, source, argsJ, eventJ) {
}
}
- AFB_ReqSuccess(
+ afb_req_success(
source->request, json_object_new_string("Subscription to playbackcontroller events successfully completed."), NULL);
return 0;
}
@@ -405,6 +405,6 @@ CTLP_CAPI(playbackControllerPublish, source, argsJ, eventJ) {
return -1;
}
- AFB_ReqSuccess(source->request, json_object_new_string("Successfully published playbackcontroller messages."), NULL);
+ afb_req_success(source->request, json_object_new_string("Successfully published playbackcontroller messages."), NULL);
return 0;
}
diff --git a/src/plugins/afb/AFBApiImpl.cpp b/src/plugins/afb/AFBApiImpl.cpp
index 443a412..aab2ce6 100644
--- a/src/plugins/afb/AFBApiImpl.cpp
+++ b/src/plugins/afb/AFBApiImpl.cpp
@@ -21,7 +21,7 @@
extern "C" {
#define AFB_BINDING_VERSION 3
-#include "afb-definitions.h"
+#include <afb/afb-binding.h>
}
static std::string TAG = "vshlcapabilities::afb::AFBApiImpl";
@@ -36,11 +36,11 @@ using namespace vshlcapabilities::utilities::logging;
namespace vshlcapabilities {
namespace afb {
-std::unique_ptr<AFBApiImpl> AFBApiImpl::create(AFB_ApiT api) {
+std::unique_ptr<AFBApiImpl> AFBApiImpl::create(afb_api_t api) {
return std::unique_ptr<AFBApiImpl>(new AFBApiImpl(api));
}
-AFBApiImpl::AFBApiImpl(AFB_ApiT api) : mApi(api), mLogger(Logger::create(api)) {
+AFBApiImpl::AFBApiImpl(afb_api_t api) : mApi(api), mLogger(Logger::create(api)) {
}
AFBApiImpl::~AFBApiImpl() {
@@ -59,7 +59,7 @@ int AFBApiImpl::callSync(
std::string& info) {
char* errorStr = NULL;
char* infoStr = NULL;
- int rc = AFB_ApiSync(mApi, api.c_str(), verb.c_str(), request, result, &errorStr, &infoStr);
+ int rc = afb_api_call_sync(mApi, api.c_str(), verb.c_str(), request, result, &errorStr, &infoStr);
if (errorStr) {
error = errorStr;
diff --git a/src/plugins/afb/AFBApiImpl.h b/src/plugins/afb/AFBApiImpl.h
index a8d8e08..70da627 100644
--- a/src/plugins/afb/AFBApiImpl.h
+++ b/src/plugins/afb/AFBApiImpl.h
@@ -31,7 +31,7 @@ namespace afb {
class AFBApiImpl : public vshlcapabilities::common::interfaces::IAFBApi {
public:
- static std::unique_ptr<AFBApiImpl> create(AFB_ApiT api);
+ static std::unique_ptr<AFBApiImpl> create(afb_api_t api);
~AFBApiImpl();
@@ -46,10 +46,10 @@ public:
std::string& info) override;
private:
- AFBApiImpl(AFB_ApiT api);
+ AFBApiImpl(afb_api_t api);
// AFB API Binding
- AFB_ApiT mApi;
+ afb_api_t mApi;
// Logger
std::shared_ptr<vshlcapabilities::common::interfaces::ILogger> mLogger;
diff --git a/src/plugins/afb/AFBRequestImpl.cpp b/src/plugins/afb/AFBRequestImpl.cpp
index 3e20172..db897d3 100644
--- a/src/plugins/afb/AFBRequestImpl.cpp
+++ b/src/plugins/afb/AFBRequestImpl.cpp
@@ -16,17 +16,17 @@
#include "afb/AFBRequestImpl.h"
extern "C" {
-#include "afb-definitions.h"
+#include <afb/afb-binding.h>
}
namespace vshlcapabilities {
namespace afb {
-std::unique_ptr<AFBRequestImpl> AFBRequestImpl::create(AFB_ReqT afbRequest) {
+std::unique_ptr<AFBRequestImpl> AFBRequestImpl::create(afb_req_t afbRequest) {
return std::unique_ptr<AFBRequestImpl>(new AFBRequestImpl(afbRequest));
}
-AFBRequestImpl::AFBRequestImpl(AFB_ReqT afbRequest) : mAfbRequest(afbRequest) {
+AFBRequestImpl::AFBRequestImpl(afb_req_t afbRequest) : mAfbRequest(afbRequest) {
}
void* AFBRequestImpl::getNativeRequest() {
diff --git a/src/plugins/afb/AFBRequestImpl.h b/src/plugins/afb/AFBRequestImpl.h
index c155f31..ac8f31f 100644
--- a/src/plugins/afb/AFBRequestImpl.h
+++ b/src/plugins/afb/AFBRequestImpl.h
@@ -31,16 +31,16 @@ namespace afb {
*/
class AFBRequestImpl : public vshlcapabilities::common::interfaces::IAFBRequest {
public:
- static std::unique_ptr<AFBRequestImpl> create(AFB_ReqT afbRequest);
+ static std::unique_ptr<AFBRequestImpl> create(afb_req_t afbRequest);
// {@c IAFBRequest Implementation
void *getNativeRequest() override;
// @c IAFBRequest Implementation }
private:
- AFBRequestImpl(AFB_ReqT afbRequest);
+ AFBRequestImpl(afb_req_t afbRequest);
- AFB_ReqT mAfbRequest;
+ afb_req_t mAfbRequest;
};
} // namespace afb
diff --git a/src/plugins/afb/include/AFBEventImpl.h b/src/plugins/afb/include/AFBEventImpl.h
index 2dda513..2d06dc9 100644
--- a/src/plugins/afb/include/AFBEventImpl.h
+++ b/src/plugins/afb/include/AFBEventImpl.h
@@ -36,7 +36,7 @@ namespace afb {
class AFBEventImpl : public vshlcapabilities::common::interfaces::IAFBApi::IAFBEvent {
public:
static unique_ptr<AFBEventImpl>
- create(shared_ptr<vshlcapabilities::common::interfaces::ILogger> logger, AFB_ApiT api,
+ create(shared_ptr<vshlcapabilities::common::interfaces::ILogger> logger, afb_api_t api,
const string &eventName);
// Destructor
@@ -52,14 +52,14 @@ public:
private:
AFBEventImpl(shared_ptr<vshlcapabilities::common::interfaces::ILogger> logger,
- AFB_ApiT api, const string &eventName);
+ afb_api_t api, const string &eventName);
// Make the event. This is a lazy make that happens
// usually during the subscribe stage.
void makeEventIfNeccessary();
// Binding API reference
- AFB_ApiT mAfbApi;
+ afb_api_t mAfbApi;
// AFB Event
afb_event_t mAfbEvent;
diff --git a/src/plugins/afb/src/AFBEventImpl.cpp b/src/plugins/afb/src/AFBEventImpl.cpp
index 7ddac36..86cbd4c 100644
--- a/src/plugins/afb/src/AFBEventImpl.cpp
+++ b/src/plugins/afb/src/AFBEventImpl.cpp
@@ -24,14 +24,14 @@ namespace afb {
unique_ptr<AFBEventImpl> AFBEventImpl::create(
shared_ptr<vshlcapabilities::common::interfaces::ILogger> logger,
- AFB_ApiT api,
+ afb_api_t api,
const string& eventName) {
return unique_ptr<AFBEventImpl>(new AFBEventImpl(logger, api, eventName));
}
AFBEventImpl::AFBEventImpl(
shared_ptr<vshlcapabilities::common::interfaces::ILogger> logger,
- AFB_ApiT api,
+ afb_api_t api,
const string& eventName) :
mLogger(logger),
mAfbApi(api),
@@ -53,7 +53,7 @@ bool AFBEventImpl::isValid() {
bool AFBEventImpl::subscribe(IAFBRequest& requestInterface) {
makeEventIfNeccessary();
- auto request = static_cast<AFB_ReqT>(requestInterface.getNativeRequest());
+ auto request = static_cast<afb_req_t>(requestInterface.getNativeRequest());
if (isValid() && afb_req_subscribe(request, mAfbEvent) == 0) {
return true;
}
@@ -63,7 +63,7 @@ bool AFBEventImpl::subscribe(IAFBRequest& requestInterface) {
bool AFBEventImpl::unsubscribe(IAFBRequest& requestInterface) {
makeEventIfNeccessary();
- auto request = static_cast<AFB_ReqT>(requestInterface.getNativeRequest());
+ auto request = static_cast<afb_req_t>(requestInterface.getNativeRequest());
if (isValid() && afb_req_unsubscribe(request, mAfbEvent) == 0) {
return true;
}
diff --git a/src/plugins/utilities/logging/Logger.cpp b/src/plugins/utilities/logging/Logger.cpp
index c121556..71c83b6 100644
--- a/src/plugins/utilities/logging/Logger.cpp
+++ b/src/plugins/utilities/logging/Logger.cpp
@@ -19,11 +19,11 @@ namespace utilities {
namespace logging {
// Constructor
-Logger::Logger(AFB_ApiT api) {
+Logger::Logger(afb_api_t api) {
mApi = api;
}
-unique_ptr<Logger> Logger::create(AFB_ApiT api) {
+unique_ptr<Logger> Logger::create(afb_api_t api) {
auto logger = std::unique_ptr<Logger>(new Logger(api));
return logger;
}
@@ -32,19 +32,19 @@ void Logger::log(Level level, const std::string& tag, const std::string& message
string format_msg = "Tag: " + tag + ", message: " + message;
switch (level) {
case Level::NOTICE:
- AFB_ApiNotice(mApi, format_msg.c_str());
+ AFB_API_NOTICE(mApi, format_msg.c_str());
break;
case Level::WARNING:
- AFB_ApiWarning(mApi, format_msg.c_str());
+ AFB_API_WARNING(mApi, format_msg.c_str());
break;
case Level::DEBUG:
- AFB_ApiDebug(mApi, format_msg.c_str());
+ AFB_API_DEBUG(mApi, format_msg.c_str());
break;
case Level::ERROR:
- AFB_ApiError(mApi, format_msg.c_str());
+ AFB_API_ERROR(mApi, format_msg.c_str());
break;
case Level::INFO:
- AFB_ApiInfo(mApi, format_msg.c_str());
+ AFB_API_INFO(mApi, format_msg.c_str());
break;
default:
break;
diff --git a/src/plugins/utilities/logging/Logger.h b/src/plugins/utilities/logging/Logger.h
index 56f810d..02acc3e 100644
--- a/src/plugins/utilities/logging/Logger.h
+++ b/src/plugins/utilities/logging/Logger.h
@@ -19,7 +19,7 @@
extern "C" {
#define AFB_BINDING_VERSION 3
-#include "afb-definitions.h"
+#include <afb/afb-binding.h>
#include "ctl-plugin.h"
};
@@ -33,17 +33,17 @@ namespace logging {
class Logger : public vshlcapabilities::common::interfaces::ILogger {
public:
- static std::unique_ptr<Logger> create(AFB_ApiT api);
+ static std::unique_ptr<Logger> create(afb_api_t api);
// ILogger interface
void log(Level level, const std::string &tag,
const std::string &message) override;
private:
- Logger(AFB_ApiT api);
+ Logger(afb_api_t api);
// Binding API reference
- AFB_ApiT mApi;
+ afb_api_t mApi;
};
} // namespace logging
diff --git a/src/vshl-capabilities-binding.c b/src/vshl-capabilities-binding.c
index b38210a..d7b970c 100644
--- a/src/vshl-capabilities-binding.c
+++ b/src/vshl-capabilities-binding.c
@@ -15,30 +15,29 @@
#define _GNU_SOURCE
#include "vshl-capabilities-binding.h"
-afb_dynapi* AFB_default;
-
// Config Section definition (note: controls section index should match handle
// retrieval in HalConfigExec)
static CtlSectionT ctrlSections[] = {{.key = "plugins", .loadCB = PluginConfig},
{.key = "controls", .loadCB = ControlConfig},
{.key = NULL}};
-static AFB_ApiVerbs ctrlApiVerbs[] = {
+static afb_verb_t ctrlApiVerbs[] = {
{.verb = NULL} /* marker for end of the array */
};
-static int ctrlLoadStaticVerbs(afb_dynapi* apiHandle, AFB_ApiVerbs* verbs) {
+static int ctrlLoadStaticVerbs(afb_api_t apiHandle, afb_verb_t* verbs) {
int errcount = 0;
for (int idx = 0; verbs[idx].verb; idx++) {
- errcount += afb_dynapi_add_verb(
+ errcount += afb_api_add_verb(
apiHandle,
ctrlApiVerbs[idx].verb,
NULL,
ctrlApiVerbs[idx].callback,
(void*)&ctrlApiVerbs[idx],
ctrlApiVerbs[idx].auth,
- 0);
+ 0,
+ !!strchr(ctrlApiVerbs[idx].verb, '*'));
}
return errcount;
@@ -47,7 +46,7 @@ static int ctrlLoadStaticVerbs(afb_dynapi* apiHandle, AFB_ApiVerbs* verbs) {
// next generation dynamic API-V3 mode
#include <signal.h>
-static int CtrlInitOneApi(AFB_ApiT apiHandle)
+static int CtrlInitOneApi(afb_api_t apiHandle)
{
CtlConfigT *ctrlConfig;
@@ -55,72 +54,71 @@ static int CtrlInitOneApi(AFB_ApiT apiHandle)
return -1;
// Retrieve section config from api handle
- ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle);
+ ctrlConfig = (CtlConfigT *) afb_api_get_userdata(apiHandle);
if(!ctrlConfig)
return -2;
return CtlConfigExec(apiHandle, ctrlConfig);
}
-static int ctrlLoadOneApi(void* cbdata, AFB_ApiT apiHandle) {
+static int ctrlLoadOneApi(void* cbdata, afb_api_t apiHandle) {
CtlConfigT* ctrlConfig = (CtlConfigT*)cbdata;
// save closure as api's data context
- afb_dynapi_set_userdata(apiHandle, ctrlConfig);
+ afb_api_set_userdata(apiHandle, ctrlConfig);
// add static controls verbs
int err = ctrlLoadStaticVerbs(apiHandle, ctrlApiVerbs);
if (err) {
- AFB_ApiError(apiHandle, "ctrlLoadStaticVerbs fail to register static V2 verbs");
+ AFB_API_ERROR(apiHandle, "ctrlLoadStaticVerbs fail to register static V2 verbs");
return ERROR;
}
// load section for corresponding API
err = CtlLoadSections(apiHandle, ctrlConfig, ctrlSections);
if (err) {
- AFB_ApiError(apiHandle, "CtlLoadSections fail to load the sections");
+ AFB_API_ERROR(apiHandle, "CtlLoadSections fail to load the sections");
return ERROR;
}
// declare an event event manager for this API;
- afb_dynapi_on_event(apiHandle, CtrlDispatchApiEvent);
+ afb_api_on_event(apiHandle, CtrlDispatchApiEvent);
// init API function (does not receive user closure ???
- afb_dynapi_on_init(apiHandle, CtrlInitOneApi);
+ afb_api_on_init(apiHandle, CtrlInitOneApi);
- afb_dynapi_seal(apiHandle);
+ afb_api_seal(apiHandle);
return err;
}
-int afbBindingEntry(afb_dynapi* apiHandle) {
- AFB_default = apiHandle;
- AFB_ApiNotice(apiHandle, "Controller in afbBindingEntry");
+int afbBindingEntry(afb_api_t apiHandle) {
+ AFB_API_NOTICE(apiHandle, "Controller in afbBindingEntry");
const char* dirList = getenv("CONTROL_CONFIG_PATH");
if (!dirList) dirList = CONTROL_CONFIG_PATH;
const char* configPath = CtlConfigSearch(apiHandle, dirList, "");
if (!configPath) {
- AFB_ApiError(apiHandle, "CtlPreInit: No %s* config found in %s ", GetBinderName(), dirList);
+ AFB_API_ERROR(apiHandle, "CtlPreInit: No %s* config found in %s ", GetBinderName(), dirList);
return ERROR;
}
// load config file and create API
CtlConfigT* ctrlConfig = CtlLoadMetaData(apiHandle, configPath);
if (!ctrlConfig) {
- AFB_ApiError(apiHandle, "CtrlBindingDyn No valid control config file in:\n-- %s", configPath);
+ AFB_API_ERROR(apiHandle, "CtrlBindingDyn No valid control config file in:\n-- %s", configPath);
return ERROR;
}
if (!ctrlConfig->api) {
- AFB_ApiError(apiHandle, "CtrlBindingDyn API Missing from metadata in:\n-- %s", configPath);
+ AFB_API_ERROR(apiHandle, "CtrlBindingDyn API Missing from metadata in:\n-- %s", configPath);
return ERROR;
}
- AFB_ApiNotice(apiHandle, "Controller API='%s' info='%s'", ctrlConfig->api, ctrlConfig->info);
+ AFB_API_NOTICE(apiHandle, "Controller API='%s' info='%s'", ctrlConfig->api, ctrlConfig->info);
- // create one API per config file (Pre-V3 return code ToBeChanged)
- int status = afb_dynapi_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, ctrlLoadOneApi, ctrlConfig);
+ // create one API per config file
+ afb_api_t newApi = afb_api_new_api(apiHandle, ctrlConfig->api, ctrlConfig->info, 1, ctrlLoadOneApi, ctrlConfig);
- return status;
+ return newApi != NULL ? 0 : -1;
}