aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md36
-rwxr-xr-xautobuild/agl/autobuild (renamed from conf.d/autobuild/agl/autobuild)34
-rwxr-xr-xautobuild/linux/autobuild (renamed from conf.d/autobuild/linux/autobuild)34
-rw-r--r--conf.d/cmake/config.cmake8
-rw-r--r--conf.d/project/etc/CMakeLists.txt2
-rw-r--r--conf.d/project/etc/vshl-api.json96
-rw-r--r--conf.d/project/etc/vshl-core-api.json72
-rw-r--r--conf.d/wgt/config.xml.in21
-rw-r--r--htdocs/AFB.js3
-rw-r--r--htdocs/CMakeLists.txt33
-rw-r--r--htdocs/amazon.js323
-rw-r--r--htdocs/binding.js88
-rw-r--r--htdocs/index.html61
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/plugins/CMakeLists.txt46
-rw-r--r--src/plugins/VshlApi.cpp607
-rw-r--r--src/plugins/VshlCoreApi.cpp348
-rw-r--r--src/plugins/VshlCoreApi.h (renamed from src/plugins/VshlApi.h)12
-rw-r--r--src/plugins/afb/AFBApiImpl.cpp20
-rw-r--r--src/plugins/afb/AFBApiImpl.h7
-rw-r--r--src/plugins/afb/AFBRequestImpl.cpp3
-rw-r--r--src/plugins/afb/AFBRequestImpl.h5
-rw-r--r--src/plugins/afb/include/AFBEventImpl.h16
-rw-r--r--src/plugins/afb/src/AFBEventImpl.cpp13
-rw-r--r--src/plugins/capabilities/CapabilitiesFactory.cpp57
-rw-r--r--src/plugins/capabilities/CapabilitiesFactory.h63
-rw-r--r--src/plugins/capabilities/CapabilityMessagingService.cpp117
-rw-r--r--src/plugins/capabilities/CapabilityMessagingService.h82
-rw-r--r--src/plugins/capabilities/communication/include/PhoneControlCapability.h52
-rw-r--r--src/plugins/capabilities/communication/include/PhoneControlMessages.h128
-rw-r--r--src/plugins/capabilities/communication/src/PhoneControlCapability.cpp42
-rw-r--r--src/plugins/capabilities/core/include/MessageChannel.h68
-rw-r--r--src/plugins/capabilities/core/include/PublisherForwarder.h73
-rw-r--r--src/plugins/capabilities/core/include/SubscriberForwarder.h84
-rw-r--r--src/plugins/capabilities/core/src/MessageChannel.cpp51
-rw-r--r--src/plugins/capabilities/core/src/PublisherForwarder.cpp69
-rw-r--r--src/plugins/capabilities/core/src/SubscriberForwarder.cpp139
-rw-r--r--src/plugins/capabilities/guimetadata/include/GuiMetadataCapability.h52
-rw-r--r--src/plugins/capabilities/guimetadata/include/GuiMetadataMessages.h50
-rw-r--r--src/plugins/capabilities/guimetadata/src/GuiMetadataCapability.cpp42
-rw-r--r--src/plugins/capabilities/navigation/include/NavigationCapability.h52
-rw-r--r--src/plugins/capabilities/navigation/include/NavigationMessages.h48
-rw-r--r--src/plugins/capabilities/navigation/src/NavigationCapability.cpp42
-rw-r--r--src/plugins/capabilities/test/CapabilityMessagingServiceTest.cpp96
-rw-r--r--src/plugins/capabilities/test/PublisherForwarderTest.cpp116
-rw-r--r--src/plugins/capabilities/test/SubscriberForwarderTest.cpp262
-rw-r--r--src/plugins/core/VRRequestProcessor.h19
-rw-r--r--src/plugins/core/VRRequestProcessorImpl.cpp19
-rw-r--r--src/plugins/core/include/VRAgentsObserver.h17
-rw-r--r--src/plugins/core/include/VRRequest.h21
-rw-r--r--src/plugins/core/include/VRRequestProcessorDelegate.h23
-rw-r--r--src/plugins/core/src/VRAgentsObserverImpl.cpp15
-rw-r--r--src/plugins/core/src/VRRequestImpl.cpp19
-rw-r--r--src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp23
-rw-r--r--src/plugins/core/test/VRRequestProcessorTest.cpp9
-rw-r--r--src/plugins/core/test/VRRequestTest.cpp9
-rw-r--r--src/plugins/interfaces/afb/IAFBApi.h2
-rw-r--r--src/plugins/interfaces/capabilities/ICapability.h58
-rw-r--r--src/plugins/interfaces/utilities/events/IEventFilter.h3
-rw-r--r--src/plugins/interfaces/utilities/logging/ILogger.h3
-rw-r--r--src/plugins/interfaces/voiceagents/IVoiceAgent.h3
-rw-r--r--src/plugins/interfaces/voiceagents/IVoiceAgentsChangeObserver.h3
-rw-r--r--src/plugins/test/common/ConsoleLogger.cpp3
-rw-r--r--src/plugins/test/common/ConsoleLogger.h5
-rw-r--r--src/plugins/test/mocks/AFBApiMock.h5
-rw-r--r--src/plugins/test/mocks/AFBEventMock.h9
-rw-r--r--src/plugins/test/mocks/AFBRequestMock.h5
-rw-r--r--src/plugins/test/mocks/CapabilityMock.h35
-rw-r--r--src/plugins/test/mocks/VoiceAgentsChangeObserverMock.h17
-rw-r--r--src/plugins/utilities/events/EventRouter.cpp15
-rw-r--r--src/plugins/utilities/events/EventRouter.h15
-rw-r--r--src/plugins/utilities/logging/Logger.cpp3
-rw-r--r--src/plugins/utilities/logging/Logger.h5
-rw-r--r--src/plugins/utilities/uuid/UUIDGeneration.cpp3
-rw-r--r--src/plugins/utilities/uuid/UUIDGeneration.h3
-rw-r--r--src/plugins/voiceagents/VoiceAgentEventNames.h3
-rw-r--r--src/plugins/voiceagents/VoiceAgentsDataManager.h32
-rw-r--r--src/plugins/voiceagents/VoiceAgentsDataManagerImpl.cpp54
-rw-r--r--src/plugins/voiceagents/include/VoiceAgent.h11
-rw-r--r--src/plugins/voiceagents/include/VoiceAgentEventsHandler.h19
-rw-r--r--src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp19
-rw-r--r--src/plugins/voiceagents/src/VoiceAgentImpl.cpp11
-rw-r--r--src/plugins/voiceagents/test/VoiceAgentTest.cpp7
-rw-r--r--src/plugins/voiceagents/test/VoiceAgentsDataManagerTest.cpp9
-rw-r--r--src/plugins/voiceagents/test/VoiceAgentsTestData.h3
-rw-r--r--src/vshl-apidef.h43
-rw-r--r--src/vshl-core-apidef.h52
-rw-r--r--src/vshl-core-apidef.json (renamed from src/vshl-apidef.json)4
-rw-r--r--src/vshl-core-binding.c (renamed from src/vshl-binding.c)24
-rw-r--r--src/vshl-core-binding.h (renamed from src/vshl-binding.h)0
90 files changed, 856 insertions, 3479 deletions
diff --git a/README.md b/README.md
index 8d814c9..c2ad2c9 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
-# 1. High Level Voice Service (VSHL)
-This repository hosts the code for the AGL's high level voice service binding also known as VSHL.
+# 1. High Level Voice Service Core (VSHL-CORE)
+This repository hosts the code for the AGL's high level voice service's core request arbitration binding also known as VSHL-CORE.
Please refer to the [architecture](https://confluence.automotivelinux.org/display/SPE/Speech+EG+Architecture) for more information.
# 2. Build Dependencies and License Information
@@ -11,14 +11,14 @@ During the build time, the following dependencies are fetched and run by the bui
```
export MY_PROJECTS_DIR = <Your Project Directory>
pushd $MY_PROJECTS_DIR
-git clone --recursive https://gerrit.automotivelinux.org/gerrit/apps/agl-service-voice-high
+git clone --recursive https://gerrit.automotivelinux.org/gerrit/apps/agl-service-voice-high-core
```
# 4. Renesas R-Car M3 board
-## 4.1 Building VSHL
+## 4.1 Building VSHL Core
```
-pushd agl-voiceservice-highlevel
+pushd agl-service-voice-high-core
mkdir build
pushd build
source /opt/agl-sdk/6.0.1-aarch64/environment-setup-aarch64-agl-linux
@@ -27,43 +27,43 @@ make autobuild
popd
./conf.d/autobuild/agl/autobuild package
```
-* The build output will be located at $MY_PROJECTS_DIR/agl-voiceservice-highlevel/build/vshl.wgt
+* The build output will be located at $MY_PROJECTS_DIR/agl-service-voice-high-core/build/vshl-core.wgt
-## 4.2 Running VSHL
+## 4.2 Running VSHL Core
```
-# afm-util install vshl.wgt
-# afm-util start vshl@1.0
+# afm-util install vshl-core.wgt
+# afm-util start vshl-core@1.0
```
# 5. Ubuntu 16.04
-## 5.1 Building VSHL
+## 5.1 Building VSHL Core
```
-pushd agl-voiceservice-highlevel/
+pushd agl-service-voice-high-core
mkdir build
pushd build
cmake ..
make autobuild
popd
./conf.d/autobuild/linux/autobuild package
-````
+```
To build the included unit tests modify the cmake step as following:
cmake .. -DENABLE_UNIT_TESTS=ON
-## 5.2 Running VSHL
+## 5.2 Running VSHL Core
```
-afb-daemon --port=1111 --name=afb-vshl --workdir=$MY_PROJECTS_DIR/agl-voice-service/build/package --ldpaths=lib --roothttp=htdocs --token= -vvv
+afb-daemon --port=1111 --name=afb-vshl-core --workdir=$MY_PROJECTS_DIR/agl-voice-service-high-core/build/package --ldpaths=lib --roothttp=htdocs --token= -vvv
```
# 6. Running the Unit Tests
## 6.1 Ubuntu 16.04
```
-pushd agl-voiceservice-highlevel/
-./build/src/plugins/vshl-api_Test
+pushd agl-service-voice-high-core/
+./build/src/plugins/vshl-core-api_Test
popd
```
-# 7. Testing VSHL
+# 7. Testing VSHL Core
* The binding can be tested by launching the HTML5 sample application that is bundled with the package in a browser.
```
@@ -82,7 +82,7 @@ clang-format -i <path to source file>
* Setup clang-format as pre-commit git hook. This is one time step after you clone the repo
```
-cd ${VSHL_ROOT}
+cd ${VSHL_CORE_ROOT}
cp tools/pre-commit .git/hooks/pre-commit
```
diff --git a/conf.d/autobuild/agl/autobuild b/autobuild/agl/autobuild
index 83097ab..a832db4 100755
--- a/conf.d/autobuild/agl/autobuild
+++ b/autobuild/agl/autobuild
@@ -1,5 +1,5 @@
#!/usr/bin/make -f
-# Copyright (C) 2015, 2016 "IoT.bzh"
+# Copyright (C) 2015 - 2018 "IoT.bzh"
# Author "Romain Forlot" <romain.forlot@iot.bzh>
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,8 +15,8 @@
# limitations under the License.
THISFILE := $(lastword $(MAKEFILE_LIST))
-BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build)
-DEST := ${BUILD_DIR}/target
+BUILD_DIR := $(abspath $(dir $(THISFILE))/../../build)
+DEST := ${BUILD_DIR}
.PHONY: all clean distclean configure build package help update
@@ -33,19 +33,21 @@ help:
@echo "- package: output a widget file '*.wgt'"
@echo "- install: install in your ${CMAKE_INSTALL_DIR} directory"
@echo ""
- @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt"
+ @echo "Usage: ./autobuild/agl/autobuild package DEST=${HOME}/opt"
@echo "Don't use your build dir as DEST as wgt file is generated at this location"
update: configure
@cmake --build ${BUILD_DIR} --target autobuild
clean:
- @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean
+ @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} ${CLEAN_ARGS} clean) || echo Nothing to clean
distclean:
@rm -rf ${BUILD_DIR}
-configure: ${BUILD_DIR}/Makefile
+configure:
+ @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
+ @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..)
build: configure
@cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all
@@ -56,12 +58,18 @@ package: build
@mkdir -p ${BUILD_DIR}/$@/lib
@mkdir -p ${BUILD_DIR}/$@/htdocs
@mkdir -p ${BUILD_DIR}/$@/var
- @cmake --build ${BUILD_DIR} --target widget
- @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST}
+ @cmake --build ${BUILD_DIR} ${PACKAGE_ARGS} --target widget
+ @mkdir -p ${DEST} && cp ${BUILD_DIR}/*.wgt ${DEST}
-install: build
- @cmake --build ${BUILD_DIR} --target install
+package-test: build
+ @mkdir -p ${BUILD_DIR}/$@/bin
+ @mkdir -p ${BUILD_DIR}/$@/etc
+ @mkdir -p ${BUILD_DIR}/$@/lib
+ @mkdir -p ${BUILD_DIR}/$@/htdocs
+ @mkdir -p ${BUILD_DIR}/$@/var
+ @cmake --build ${BUILD_DIR} ${PACKAGE_ARGS} --target widget
+ @cmake --build ${BUILD_DIR} ${PACKAGE_ARGS} --target test_widget
+ @mkdir -p ${DEST} && cp ${BUILD_DIR}/*.wgt ${DEST}
-${BUILD_DIR}/Makefile:
- @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
- @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..)
+install: build
+ @cmake --build ${BUILD_DIR} ${INSTALL_ARGS} --target install
diff --git a/conf.d/autobuild/linux/autobuild b/autobuild/linux/autobuild
index 83097ab..a832db4 100755
--- a/conf.d/autobuild/linux/autobuild
+++ b/autobuild/linux/autobuild
@@ -1,5 +1,5 @@
#!/usr/bin/make -f
-# Copyright (C) 2015, 2016 "IoT.bzh"
+# Copyright (C) 2015 - 2018 "IoT.bzh"
# Author "Romain Forlot" <romain.forlot@iot.bzh>
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,8 +15,8 @@
# limitations under the License.
THISFILE := $(lastword $(MAKEFILE_LIST))
-BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build)
-DEST := ${BUILD_DIR}/target
+BUILD_DIR := $(abspath $(dir $(THISFILE))/../../build)
+DEST := ${BUILD_DIR}
.PHONY: all clean distclean configure build package help update
@@ -33,19 +33,21 @@ help:
@echo "- package: output a widget file '*.wgt'"
@echo "- install: install in your ${CMAKE_INSTALL_DIR} directory"
@echo ""
- @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt"
+ @echo "Usage: ./autobuild/agl/autobuild package DEST=${HOME}/opt"
@echo "Don't use your build dir as DEST as wgt file is generated at this location"
update: configure
@cmake --build ${BUILD_DIR} --target autobuild
clean:
- @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean
+ @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} ${CLEAN_ARGS} clean) || echo Nothing to clean
distclean:
@rm -rf ${BUILD_DIR}
-configure: ${BUILD_DIR}/Makefile
+configure:
+ @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
+ @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..)
build: configure
@cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all
@@ -56,12 +58,18 @@ package: build
@mkdir -p ${BUILD_DIR}/$@/lib
@mkdir -p ${BUILD_DIR}/$@/htdocs
@mkdir -p ${BUILD_DIR}/$@/var
- @cmake --build ${BUILD_DIR} --target widget
- @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST}
+ @cmake --build ${BUILD_DIR} ${PACKAGE_ARGS} --target widget
+ @mkdir -p ${DEST} && cp ${BUILD_DIR}/*.wgt ${DEST}
-install: build
- @cmake --build ${BUILD_DIR} --target install
+package-test: build
+ @mkdir -p ${BUILD_DIR}/$@/bin
+ @mkdir -p ${BUILD_DIR}/$@/etc
+ @mkdir -p ${BUILD_DIR}/$@/lib
+ @mkdir -p ${BUILD_DIR}/$@/htdocs
+ @mkdir -p ${BUILD_DIR}/$@/var
+ @cmake --build ${BUILD_DIR} ${PACKAGE_ARGS} --target widget
+ @cmake --build ${BUILD_DIR} ${PACKAGE_ARGS} --target test_widget
+ @mkdir -p ${DEST} && cp ${BUILD_DIR}/*.wgt ${DEST}
-${BUILD_DIR}/Makefile:
- @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
- @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..)
+install: build
+ @cmake --build ${BUILD_DIR} ${INSTALL_ARGS} --target install
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
index 4e1a631..d932fd1 100644
--- a/conf.d/cmake/config.cmake
+++ b/conf.d/cmake/config.cmake
@@ -18,10 +18,10 @@
# Project Info
# ------------------
-set(PROJECT_NAME vshl)
+set(PROJECT_NAME vshl-core)
set(PROJECT_VERSION "1.0")
-set(PROJECT_PRETTY_NAME "High Level Voice Service APIs")
-set(PROJECT_DESCRIPTION "Binding that provide voice services to AGL apps.")
+set(PROJECT_PRETTY_NAME "High Level Voice Service Core APIs")
+set(PROJECT_DESCRIPTION "Binding that provides core voice service arbitration API to AGL apps.")
set(PROJECT_ICON "icon.png")
set(PROJECT_AUTHOR "Naveen Bobbili")
set(PROJECT_AUTHOR_MAIL "nbobbili@amazon.com")
@@ -165,7 +165,7 @@ set(WIDGET_TYPE application/vnd.agl.service)
# This is the file that will be executed, loaded,
# at launch time by the application framework.
#
-set(WIDGET_ENTRY_POINT lib/afb-vshl.so)
+set(WIDGET_ENTRY_POINT lib/afb-vshl-core.so)
# Optional dependencies order
# ---------------------------
diff --git a/conf.d/project/etc/CMakeLists.txt b/conf.d/project/etc/CMakeLists.txt
index 3aacae6..3635ed0 100644
--- a/conf.d/project/etc/CMakeLists.txt
+++ b/conf.d/project/etc/CMakeLists.txt
@@ -19,7 +19,7 @@
##################################################
# Control Policy Config file
##################################################
-PROJECT_TARGET_ADD(vshl-api-config)
+PROJECT_TARGET_ADD(vshl-core-api-config)
file(GLOB CONF_FILES "*.json")
diff --git a/conf.d/project/etc/vshl-api.json b/conf.d/project/etc/vshl-api.json
deleted file mode 100644
index 3f92f76..0000000
--- a/conf.d/project/etc/vshl-api.json
+++ /dev/null
@@ -1,96 +0,0 @@
-{
- "$schema": "http://iot.bzh/download/public/schema/json/ctl-schema.json",
- "metadata": {
- "uid": "vshl",
- "version": "1.0",
- "api": "vshl",
- "info": "High Level Voice Service APIs"
- },
-
- "onload": [{
- "uid": "loadVoiceAgentsConfig",
- "info": "Loading the information about voice agents managed by the high level voice service.",
- "action": "plugin://vshl#loadVoiceAgentsConfig",
- "args": {
- "default": "VA-001",
- "agents": [
- {
- "id": "VA-001",
- "active": true,
- "name": "Alexa",
- "api": "alexa-voiceagent",
- "wakewords": [
- "alexa",
- "computer",
- "echo"
- ],
- "activewakeword": "alexa",
- "description": "Alexa voice assistant by Amazon.",
- "vendor": "Amazon.com Services Inc"
- }
- ]
- }
- }],
-
- "plugins": [{
- "uid": "vshl",
- "info": "Plugin to handle high level voice service interface implementation",
- "libs": [
- "vshl-api.ctlso"
- ]
- }],
-
- "events": [{
- "uid": "alexa-voiceagent/voice_authstate_event",
- "action": "plugin://vshl#onAuthStateEvent"
- },{
- "uid": "alexa-voiceagent/voice_connectionstate_event",
- "action": "plugin://vshl#onConnectionStateEvent"
- },{
- "uid": "alexa-voiceagent/voice_dialogstate_event",
- "action": "plugin://vshl#onDialogStateEvent"
- }],
-
- "controls": [{
- "uid": "startListening",
- "action": "plugin://vshl#startListening"
- }, {
- "uid": "cancelListening",
- "action": "plugin://vshl#cancelListening"
- }, {
- "uid": "subscribe",
- "action": "plugin://vshl#subscribe"
- }, {
- "uid": "enumerateVoiceAgents",
- "privileges": "urn:AGL:permission:vshl:voiceagents:public",
- "action": "plugin://vshl#enumerateVoiceAgents"
- }, {
- "uid": "setDefaultVoiceAgent",
- "privileges": "urn:AGL:permission:vshl:voiceagents:public",
- "action": "plugin://vshl#setDefaultVoiceAgent"
- }, {
- "uid": "guiMetadata/publish",
- "privileges": "urn:AGL:permission:vshl:guiMetadata:public",
- "action": "plugin://vshl#guiMetadataPublish"
- }, {
- "uid": "guiMetadata/subscribe",
- "privileges": "urn:AGL:permission:vshl:guiMetadata:public",
- "action": "plugin://vshl#guiMetadataSubscribe"
- }, {
- "uid": "phonecontrol/publish",
- "privileges": "urn:AGL:permission:vshl:phonecontrol:public",
- "action": "plugin://vshl#phonecontrolPublish"
- }, {
- "uid": "phonecontrol/subscribe",
- "privileges": "urn:AGL:permission:vshl:phonecontrol:public",
- "action": "plugin://vshl#phonecontrolSubscribe"
- }, {
- "uid": "navigation/publish",
- "privileges": "urn:AGL:permission:vshl:navigation:public",
- "action": "plugin://vshl#navigationPublish"
- }, {
- "uid": "navigation/subscribe",
- "privileges": "urn:AGL:permission:vshl:navigation:public",
- "action": "plugin://vshl#navigationSubscribe"
- }]
-} \ No newline at end of file
diff --git a/conf.d/project/etc/vshl-core-api.json b/conf.d/project/etc/vshl-core-api.json
new file mode 100644
index 0000000..f370a32
--- /dev/null
+++ b/conf.d/project/etc/vshl-core-api.json
@@ -0,0 +1,72 @@
+{
+ "$schema": "http://iot.bzh/download/public/schema/json/ctl-schema.json",
+ "metadata": {
+ "uid": "vshl-core",
+ "version": "1.0",
+ "api": "vshl-core",
+ "info": "High Level Voice Service Core APIs"
+ },
+
+ "onload": [{
+ "uid": "loadVoiceAgentsConfig",
+ "info": "Loading the information about voice agents managed by the high level voice service.",
+ "action": "plugin://vshl-core#loadVoiceAgentsConfig",
+ "args": {
+ "default": "VA-001",
+ "agents": [
+ {
+ "id": "VA-001",
+ "active": true,
+ "name": "Alexa",
+ "api": "alexa-voiceagent",
+ "wakewords": [
+ "alexa",
+ "computer",
+ "echo"
+ ],
+ "activewakeword": "alexa",
+ "description": "Alexa voice assistant by Amazon.",
+ "vendor": "Amazon.com Services Inc"
+ }
+ ]
+ }
+ }],
+
+ "plugins": [{
+ "uid": "vshl-core",
+ "info": "Plugin to handle high level voice service core API implementation",
+ "libs": [
+ "vshl-core-api.ctlso"
+ ]
+ }],
+
+ "events": [{
+ "uid": "alexa-voiceagent/voice_authstate_event",
+ "action": "plugin://vshl-core#onAuthStateEvent"
+ },{
+ "uid": "alexa-voiceagent/voice_connectionstate_event",
+ "action": "plugin://vshl-core#onConnectionStateEvent"
+ },{
+ "uid": "alexa-voiceagent/voice_dialogstate_event",
+ "action": "plugin://vshl-core#onDialogStateEvent"
+ }],
+
+ "controls": [{
+ "uid": "startListening",
+ "action": "plugin://vshl-core#startListening"
+ }, {
+ "uid": "cancelListening",
+ "action": "plugin://vshl-core#cancelListening"
+ }, {
+ "uid": "subscribe",
+ "action": "plugin://vshl-core#subscribe"
+ }, {
+ "uid": "enumerateVoiceAgents",
+ "privileges": "urn:AGL:permission:vshl-core:voiceagents:public",
+ "action": "plugin://vshl-core#enumerateVoiceAgents"
+ }, {
+ "uid": "setDefaultVoiceAgent",
+ "privileges": "urn:AGL:permission:vshl-core:voiceagents:public",
+ "action": "plugin://vshl-core#setDefaultVoiceAgent"
+ }]
+} \ No newline at end of file
diff --git a/conf.d/wgt/config.xml.in b/conf.d/wgt/config.xml.in
index 0378f37..6d0690c 100644
--- a/conf.d/wgt/config.xml.in
+++ b/conf.d/wgt/config.xml.in
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<widget xmlns="http://www.w3.org/ns/widgets" id="@PROJECT_NAME@" version="@PROJECT_VERSION@">
+<widget xmlns="http://www.w3.org/ns/widgets" id="@PROJECT_NAME@" version="0.1">
<name>@PROJECT_NAME@</name>
<icon src="@PROJECT_ICON@"/>
<content src="@WIDGET_ENTRY_POINT@" type="@WIDGET_TYPE@"/>
@@ -7,7 +7,7 @@
<author>@PROJECT_AUTHOR@ &lt;@PROJECT_AUTHOR_MAIL@&gt;</author>
<license>@PROJECT_LICENSE@</license>
<feature name="urn:AGL:widget:provided-api">
- <param name="vshl" value="ws" />
+ <param name="vshl-core" value="ws" />
</feature>
<feature name="urn:AGL:widget:required-binding">
<param name="@WIDGET_ENTRY_POINT@" value="local" />
@@ -15,19 +15,8 @@
<feature name="urn:AGL:widget:required-api">
<param name="alexa-voiceagent" value="ws" />
</feature>
-
- <!-- HTML UI FOR TESTING -->
- <feature name="urn:AGL:widget:provided-unit">
- <param name="#target" value="test-ui" />
- <param name="description" value="HTML UI for testing VSHL service" />
- <param name="content.src" value="index.html" />
- <param name="content.type" value="text/html" />
- <param name="icon.src" value="@PROJECT_ICON@" />
- </feature>
- <feature name="urn:AGL:widget:required-binding">
- <param name="#target" value="test-ui" />
- <param name="windowmanager" value="ws" />
- <param name="homescreen" value="ws" />
- <param name="vshl" value="ws" />
+ <feature name="urn:AGL:widget:required-permission">
+ <param name="urn:AGL:permission:afm:system:widget:start" value="required" />
+ <param name="urn:AGL:permission::public:hidden" value="required" />
</feature>
</widget> \ No newline at end of file
diff --git a/htdocs/AFB.js b/htdocs/AFB.js
index b07efc5..2cf3aec 100644
--- a/htdocs/AFB.js
+++ b/htdocs/AFB.js
@@ -210,7 +210,8 @@ var AFB_websocket;
/*********************************************/
return {
context: AFB_context,
- ws: AFB_websocket
+ ws: AFB_websocket,
+ url: urlws
};
};
diff --git a/htdocs/CMakeLists.txt b/htdocs/CMakeLists.txt
deleted file mode 100644
index 7aa0ce1..0000000
--- a/htdocs/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-###########################################################################
-# Copyright 2015, 2016, 2017 IoT.bzh
-#
-# author: Fulup Ar Foll <fulup@iot.bzh>
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-###########################################################################
-
-
-
-##################################################
-# HTML Testing Files
-##################################################
-PROJECT_TARGET_ADD(htdocs)
-
- file(GLOB SOURCE_FILES "*.html" "*.js" "*.jpg" "*.css" "assets")
-
- add_input_files("${SOURCE_FILES}")
-
- SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES
- LABELS "HTDOCS"
- OUTPUT_NAME ${TARGET_NAME}
- )
diff --git a/htdocs/amazon.js b/htdocs/amazon.js
deleted file mode 100644
index 05704f1..0000000
--- a/htdocs/amazon.js
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-AMAZON = function() {
-
-var afb;
-var alexaWs;
-
-var base = {
- base: "api",
- token: "HELLO",
-};
-
-// GUID generator for generating device serial number.
-function guid() {
- function s4() {
- return Math.floor((1 + Math.random()) * 0x10000)
- .toString(16)
- .substring(1);
- }
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
-}
-
-/*********************************************/
-/**** ****/
-/**** AMAZON_cbl ****/
-/**** ****/
-/*********************************************/
-var AMAZON_Cbl;
-{
- const amazonHostUrl = "https://api.amazon.com";
- const amazonCodePairUrl = amazonHostUrl + "/auth/O2/create/codepair";
- const amazonTokenUrl = amazonHostUrl + "/auth/O2/token";
- const deviceSerialNumber = guid();
- var clientID = localStorage.getItem("client_id");
- var productID = localStorage.getItem("product_id");
- var alexaVAAddress = localStorage.getItem("alexa_va_address");
- var alexaVAConnected = false;
- var alexaVAAddressInput;
- var clientIDInput;
- var productIDInput;
-
- AMAZON_Cbl = function() {
- // Alexa VA Address
- const alexaVAAddressInput = document.getElementById('alexa-va-address');
- alexaVAAddress = alexaVAAddressInput.value;
- connectToAlexaVA(alexaVAAddress);
-
- alexaVAAddressInput.addEventListener("change",(evt) => {
- var newAlexaVAAddress = alexaVAAddressInput.value;
- if (alexaVAAddress != newAlexaVAAddress) {
- connectToAlexaVA(newAlexaVAAddress);
- localStorage.setItem("alexa_va_address", newAlexaVAAddress);
- }
- });
-
- // Client ID
- const clientIDInput = document.getElementById('client-id');
- clientIDInput.addEventListener("change",(evt) => {
- var newClientID = clientIDInput.value;
- if (clientID != newClientID) {
- clientID = newClientID;
- localStorage.setItem("client_id", newClientID);
- }
- });
-
- // Product ID
- const productIDInput = document.getElementById('product-id');
- productIDInput.addEventListener("change",(evt) => {
- var newProductID = productIDInput.value;
- if (productID != newProductID) {
- productID = newProductID;
- localStorage.setItem("product_id", newProductID);
- }
- });
- }
-
- function connectToAlexaVA(address) {
- base.host = address;
- afb = new AFB(base, "secret");
-
- function onopen() {
- console.log("Connected to Alexa VA");
- alexaVAConnected = true;
- }
-
- function onabort() {
- console.log("Alexa VA connection aborted.");
- alexaVAConnected = false;
- }
-
- alexaWs = new afb.ws(onopen, onabort);
- }
-
- function sendRequest(httpReq, paramsJson, url, responseCb) {
- httpReq.onreadystatechange = responseCb;
- var paramsQueryString = Object.keys(paramsJson).map(key => key + '=' + paramsJson[key]).join('&');
- httpReq.open("POST", url, true);
- httpReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- httpReq.send(paramsQueryString);
- }
-
- //**********************************************
- // Generic function to call VA binder
- //***********************************************
- function callVABinder(voiceAgent, verb, query) {
- console.log(voiceAgent.api, verb, query);
-
- // ws.call return a Promise
- return alexaWs.call(voiceAgent.api + '/' + verb, query)
- .then(function (res) {
- log.reply(res);
- count++;
- return res;
- })
- .catch(function (err) {
- log.reply(err);
- count++;
- throw err;
- });
- };
-
- function updateAccessToken(voiceAgent, tokenResponseJson) {
- if (alexaVAAddress === undefined || alexaVAAddress === null) {
- console.log("No Alexa VA. So not updating the access token.");
- return;
- }
-
- // store the access and refresh tokens.
- if (typeof(Storage) !== "undefined") {
- localStorage.setItem("access_token", tokenResponseJson["access_token"]);
- localStorage.setItem("refresh_token", tokenResponseJson["refresh_token"]);
- }
-
- // Set the auth token
- if (alexaVAConnected) {
- // Set new token
- const query = {"token": tokenResponseJson["access_token"]};
- callVABinder(voiceAgent, 'setAuthToken', query);
- }
-
- // Refresh the token as soon as it expires.
- setTimeout(refreshToken, tokenResponseJson["expires_in"] * 1000);
- }
-
- function refreshToken(voiceAgent) {
- if (voiceAgent == "undefined") {
- console.log("Error: VoiceAgent undefined");
- return;
- }
-
- var refreshToken = localStorage.getItem("refresh_token");
- if (refreshToken == null) {
- console.log("Error: No refresh token");
- return;
- }
-
- var paramsJson = {
- "grant_type":"refresh_token",
- "refresh_token":refreshToken,
- "client_id":clientID,
- };
-
- const tokenRefreshReq = new XMLHttpRequest();
- sendRequest(tokenRefreshReq, paramsJson, amazonTokenUrl, function() {
- if (tokenRefreshReq.readyState == 4) {
- if (tokenRefreshReq.status == 200) {
- console.log("Got access token " + tokenRefreshReq.responseText);
- var tokenResponseJson = JSON.parse(tokenRefreshReq.responseText);
- updateAccessToken(voiceAgent, tokenResponseJson);
- } else {
- console.log("Failed to refresh access token: " + tokenRefreshReq.responseText);
- }
- }
- });
- }
-
- function displayUserCodeAndURI(authResponseJson) {
- const modal = document.getElementById('login-with-amazon');
- const cblStatusDiv = document.createElement("div");
- const cblStatusMsg = document.createElement("p");
- const blank = "_blank";
-
- var cblPage = authResponseJson["verification_uri"] + "?cbl-code=" + authResponseJson["user_code"]
- var msg = "To use Alexa,you must sign in to Amazon.<br> Go to " +
- "<a href=" + cblPage + " target="+ blank+ " >" +
- cblPage + "</a>";
- cblStatusMsg.innerHTML = msg;
- cblStatusDiv.appendChild(cblStatusMsg);
- modal.appendChild(cblStatusDiv);
-
- const closeBtn = document.createElement("button");
- closeBtn.addEventListener('click', (evt) => {
- modal.close();
- });
- closeBtn.style = "margin: 10px";
- closeBtn.innerHTML = "Close";
- modal.appendChild(closeBtn);
- }
-
- function hideLoginUI() {
- const loginDiv = document.getElementById('login-area');
- loginDiv.style.display = "none";
- }
-
- function login(voiceAgent) {
- if (voiceAgent == undefined) {
- console.log("Error: VoiceAgent undefined");
- return;
- }
-
- const modal = document.getElementById('login-with-amazon');
- const submitBtn = document.getElementById('submit-btn');
- const cancelBtn = document.getElementById('cancel-btn');
- submitBtn.addEventListener('click', (evt) => {
- console.log("Alexa Destination address set to: " + alexaVAAddress);
- startLoginProcess(voiceAgent);
- });
-
- cancelBtn.addEventListener('click', (evt) => {
- modal.close();
- });
-
- const alexaVAAddressInput = document.getElementById('alexa-va-address');
- alexaVAAddressInput.value = alexaVAAddress;
-
- const clientIDInput = document.getElementById('client-id');
- clientIDInput.value = clientID;
-
- const productIDInput = document.getElementById('product-id');
- productIDInput.value = productID;
-
- modal.showModal();
- }
-
- function startLoginProcess(voiceAgent) {
- if (clientID == null || productID == null || alexaVAAddress == null) {
- console.log("Required information missing to start login process.");
- return;
- }
-
- var reqJson = {
- "response_type": "device_code",
- "client_id": clientID,
- "scope":"alexa:all",
- "scope_data": JSON.stringify({
- "alexa:all": {
- "productID":productID,
- "productInstanceAttributes" : {
- "deviceSerialNumber": deviceSerialNumber
- }
- }
- })
- };
-
- const authReq = new XMLHttpRequest();
- var tokenUrl = amazonTokenUrl;
- sendRequest(authReq, reqJson, amazonCodePairUrl, function() {
- if (authReq.readyState == 4) {
- if (authReq.status == 200) {
- var authResponse = JSON.parse(authReq.responseText);
- console.log("Got auth codepair " + authReq.responseText);
- hideLoginUI();
- displayUserCodeAndURI(authResponse);
- var maxTokenReqCnt = authResponse["expires_in"] / authResponse["interval"];
- var tokenReqFuncId = setTimeout(function tokenReqFunc() {
- var reqJson = {
- "grant_type":"device_code",
- "device_code":authResponse["device_code"],
- "user_code":authResponse["user_code"]
- };
- const tokenReq = new XMLHttpRequest();
- sendRequest(tokenReq, reqJson, tokenUrl, function() {
- if (tokenReq.readyState == 4) {
- if (tokenReq.status == 200) {
- console.log("Got access token " + tokenReq.responseText);
- var tokenResponseJson = JSON.parse(tokenReq.responseText);
- updateAccessToken(voiceAgent, tokenResponseJson);
- }
- else {
- maxTokenReqCnt--;
- console.log("Retrying... " + tokenReq.responseText);
- setTimeout(tokenReqFunc, authResponse["interval"] * 1000);
- }
- }
- });
- }, authResponse["interval"] * 1000);
- // Cancel if max token request attempts are reached.
- if (maxTokenReqCnt == 0) {
- console.log("Reached max token request attemps limit.");
- }
- } else {
- console.log(authReq.status);
- }
- }
- });
- }
-
- AMAZON_Cbl.prototype = {
- login: login,
- refreshToken: refreshToken,
- };
-}
-/*********************************************/
-/**** ****/
-/**** ****/
-/**** ****/
-/*********************************************/
-return {
- cbl: AMAZON_Cbl
-};
-}; \ No newline at end of file
diff --git a/htdocs/binding.js b/htdocs/binding.js
index 7e7439b..c5ceb06 100644
--- a/htdocs/binding.js
+++ b/htdocs/binding.js
@@ -1,18 +1,14 @@
-var afb = new AFB("api", "mysecret");
+var afbVshlCore;
var ws;
var evtIdx = 0;
var count = 0;
-
-var amazon = new AMAZON();
-var amazonCbl;
-
//**********************************************
// Logger
//**********************************************
var log = {
- command: function (api, verb, query) {
+ command: function (url, api, verb, query) {
console.log("subscribe api=" + api + " verb=" + verb + " query=", query);
- var question = afb.url + "/" + api + "/" + verb + "?query=" + JSON.stringify(query);
+ var question = url + "/" + api + "/" + verb + "?query=" + JSON.stringify(query);
log._write("question", count + ": " + log.syntaxHighlight(question));
},
@@ -67,8 +63,8 @@ var log = {
//**********************************************
// Generic function to call binder
//***********************************************
-function callbinder(api, verb, query) {
- log.command(api, verb, query);
+function callbinder(url, api, verb, query) {
+ log.command(url, api, verb, query);
// ws.call return a Promise
return ws.call(api + '/' + verb, query)
@@ -84,10 +80,15 @@ function callbinder(api, verb, query) {
});
};
+
//**********************************************
-// Init - establish Websocket connection
+// connect - establish Websocket connection
//**********************************************
-function init(elemID, api, verb, query) {
+function connect(elemID, api, verb, query) {
+ connectVshlCore(elemID, api, verb, query);
+}
+
+function connectVshlCore(elemID, api, verb, query) {
function onopen() {
document.getElementById("main").style.visibility = "visible";
@@ -104,7 +105,15 @@ function init(elemID, api, verb, query) {
document.getElementById("connected").style.background = "red";
}
- ws = new afb.ws(onopen, onabort);
+ var urlparams = {
+ base: "api",
+ token: "HELLO",
+ };
+ const vshlCoreAddressInput = document.getElementById('vshl-core-address');
+ urlparams.host = vshlCoreAddressInput.value;
+
+ afbVshlCore = new AFB(urlparams, "HELLO");
+ ws = new afbVshlCore.ws(onopen, onabort);
}
function clearPre(preId) {
@@ -120,11 +129,11 @@ function fetchAndRenderVoiceAgents() {
agentsDiv.removeChild(agentsDiv.firstChild);
}
- const api = 'vshl';
+ const api = 'vshl-core';
const verb = 'enumerateVoiceAgents';
const query = {};
- log.command(api, verb, query);
+ log.command(afbVshlCore.url, api, verb, query);
return ws.call(api + '/' + verb, query)
.then(function (res) {
@@ -155,7 +164,7 @@ function addVoiceAgent(containerDiv, voiceAgent, isDefault) {
const setDefaultBtn = document.createElement("button");
setDefaultBtn.addEventListener('click', (evt) => {
const query = {"id": voiceAgent.id};
- callbinder('vshl', 'setDefaultVoiceAgent', query);
+ callbinder(afbVshlCore.url, 'vshl-core', 'setDefaultVoiceAgent', query);
fetchAndRenderVoiceAgents();
});
setDefaultBtn.innerHTML = 'SetDefault';
@@ -169,24 +178,6 @@ function addVoiceAgent(containerDiv, voiceAgent, isDefault) {
subscribeBtn.innerHTML = 'Subscribe';
agentDiv.appendChild(subscribeBtn);
- // Login implementation for Alexa Voice Agent
- if (voiceAgent.name == "Alexa") {
- amazonCbl = new amazon.cbl();
- if (typeof(Storage) !== "undefined" &&
- localStorage.getItem("access_token") !== null &&
- localStorage.getItem("refresh_token") !== null) {
- amazonCbl.refreshToken(voiceAgent);
- } else {
- const loginWithAmazonBtn = document.createElement("button");
- loginWithAmazonBtn.addEventListener('click', (evt) => {
- loginWithAmazonBtn.style.visibility = "hidden";
- amazonCbl.login(voiceAgent);
- });
- loginWithAmazonBtn.innerHTML = 'Login With Amazon!!';
- agentDiv.appendChild(loginWithAmazonBtn);
- }
- }
-
containerDiv.appendChild(agentDiv);
}
@@ -210,7 +201,7 @@ function showAgentEventChooserDialog(voiceAgentId) {
if (connectionState)
query.events.push('voice_connectionstate_event');
- callbinder('vshl', 'subscribe', query);
+ callbinder(afbVshlCore.url, 'vshl-core', 'subscribe', query);
modal.close();
});
@@ -218,31 +209,6 @@ function showAgentEventChooserDialog(voiceAgentId) {
modal.showModal();
}
-function showTemplateUIEventChooserDialog() {
- const modal = document.getElementById('templateui-event-chooser');
- const subscribeBtn = document.getElementById('templateui-subscribe-btn');
-
- subscribeBtn.addEventListener('click', (evt) => {
- const renderTemplate = document.getElementById('render_template').checked;
- const clearTemplate = document.getElementById('clear_template').checked;
- const renderPlayerInfo = document.getElementById('render_player_info').checked;
- const clearPlayerInfo = document.getElementById('clear_player_info').checked;
-
- const query = {"actions":[]};
-
- if (renderTemplate)
- query.actions.push('render_template');
- if (clearTemplate)
- query.actions.push('clear_template');
- if (renderPlayerInfo)
- query.actions.push('render_player_info');
- if (clearPlayerInfo)
- query.actions.push('clear_player_info');
-
- callbinder('vshl', 'guiMetadata/subscribe', query);
- modal.close();
- });
-
- // makes modal appear (adds `open` attribute)
- modal.showModal();
+function startListening() {
+ callbinder(afbVshlCore.url, 'vshl-core', 'startListening', {});
} \ No newline at end of file
diff --git a/htdocs/index.html b/htdocs/index.html
index bf5f840..4e10f66 100644
--- a/htdocs/index.html
+++ b/htdocs/index.html
@@ -1,22 +1,22 @@
<html>
<head>
- <title>VSHL API Test</title>
+ <title>VSHL CORE API Test</title>
<link rel="stylesheet" href="binding.css">
<script type="text/javascript" src="AFB.js"></script>
<script type="text/javascript" src="amazon.js"></script>
<script type="text/javascript" src="binding.js"></script>
</head>
-<body class="page-content" onload="init()">
+<body class="page-content" onload="connect()">
<h1>Voice Service High Level API Tester</h1>
<button id="connected" onclick="init()">Binder WS Fail</button>
<button id="monitoring" onclick="window.open('/monitoring/monitor.html','_monitor_ctl')">Debug/Monitoring</a>
</button>
- <button onclick="clearPre('question'); clearPre('output'); clearPre('outevt');">Clear</button>
-
+ <button onclick="clearPre('question'); clearPre('output'); clearPre('outevt');">Clear</button> <br><br>
+ VSHL CORE URL: <input type="text" id="vshl-core-address" value="localhost:1111" onchange="connectVshlCore()"> <br><br>
<br>
<br>
@@ -43,60 +43,13 @@
</footer>
</dialog>
- <dialog id="templateui-event-chooser">
- <h3 class="dialogheader">Subscribe to the following GUI Metadata Messages</h3>
- <div>
- <ol>
- <li>
- <input type="checkbox" id="render_template" checked>
- <label>render_template</label>
- </li>
- <li>
- <input type="checkbox" id="clear_template" checked>
- <label>clear_template</label>
- </li>
- <li>
- <input type="checkbox" id="render_player_info" checked>
- <label>render_player_info</label>
- </li>
- <li>
- <input type="checkbox" id="clear_player_info" checked>
- <label>clear_player_info</label>
- </li>
- </ol>
- </div>
- <footer>
- <button id="templateui-subscribe-btn" type="button" style="margin: 10px">Subscribe</button>
- </footer>
- </dialog>
-
- <dialog id="login-with-amazon">
- <h3 class="dialogheader">Login with Amazon !!</h3>
- <div id="login-area">
- <div>
- Alexa VA URL: <input type="text" id="alexa-va-address" value="localhost:1111"> <br><br>
- Client ID : <input type="text" id="client-id"> <br><br>
- Product ID : <input type="text" id="product-id"> <br><br>
- To generate client and product ID, please register a new AVS product for
- <i><b>Other devices and platforms</b></i> using instructions in
- <a href="https://developer.amazon.com/docs/alexa-voice-service/register-a-product.html" target="_blank">this </a>
- link.<br><br>
- </div>
- <footer id ="login-with-amazon-footer">
- <button id="submit-btn" type="button" style="margin: 10px">Login</button>
- <button id="cancel-btn" type="button" style="margin: 10px">Cancel</button>
- </footer>
- </div>
- </dialog>
-
<div id="top" class="row">
<div id='actions' class="col1">
<div>
- <h2>VSHL APIs</h2>
- <p>APIs that are voiceagent agnostic</p>
- <button onclick="callbinder('vshl','startListening',{});">startListening</button>
+ <h2>VSHL CORE APIs</h2>
+ <p>Speech framework's VSHL Core APIs</p>
+ <button onclick="startListening()">startListening</button>
<button onclick="fetchAndRenderVoiceAgents();">enumerateAgents</button>
- <button onclick="showTemplateUIEventChooserDialog();">Subscribe to GUI Metadata</button>
</div>
<div id="agentsDiv">
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 729dcb6..949156a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -15,7 +15,7 @@
###########################################################################
# Add target to project dependency list
-PROJECT_TARGET_ADD(vshl)
+PROJECT_TARGET_ADD(vshl-core)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt
index 06ef7a4..49c6a78 100644
--- a/src/plugins/CMakeLists.txt
+++ b/src/plugins/CMakeLists.txt
@@ -14,19 +14,18 @@
# limitations under the License.
###########################################################################
-PROJECT_TARGET_ADD(vshl-api)
+PROJECT_TARGET_ADD(vshl-core-api)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
- set(VSHL_LIB_SRC
- ${CMAKE_CURRENT_SOURCE_DIR}/VshlApi.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/VshlApi.h
+ set(VSHL_CORE_LIB_SRC
+ ${CMAKE_CURRENT_SOURCE_DIR}/VshlCoreApi.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/VshlCoreApi.h
# Interfaces
${CMAKE_CURRENT_SOURCE_DIR}/interfaces/afb/IAFBApi.h
- ${CMAKE_CURRENT_SOURCE_DIR}/interfaces/capabilities/ICapability.h
${CMAKE_CURRENT_SOURCE_DIR}/interfaces/utilities/events/IEventFilter.h
${CMAKE_CURRENT_SOURCE_DIR}/interfaces/utilities/logging/ILogger.h
${CMAKE_CURRENT_SOURCE_DIR}/interfaces/voiceagents/IVoiceAgent.h
@@ -59,27 +58,6 @@ PROJECT_TARGET_ADD(vshl-api)
${CMAKE_CURRENT_SOURCE_DIR}/core/include/VRRequestProcessorDelegate.h
${CMAKE_CURRENT_SOURCE_DIR}/core/src/VRRequestProcessorDelegateImpl.cpp
- #Capabilities
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/CapabilitiesFactory.h
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/CapabilitiesFactory.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/CapabilityMessagingService.h
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/CapabilityMessagingService.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/include/MessageChannel.h
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/src/MessageChannel.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/include/PublisherForwarder.h
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/src/PublisherForwarder.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/include/SubscriberForwarder.h
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/core/src/SubscriberForwarder.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/communication/include/PhoneControlMessages.h
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/communication/include/PhoneControlCapability.h
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/communication/src/PhoneControlCapability.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/navigation/include/NavigationMessages.h
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/navigation/include/NavigationCapability.h
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/navigation/src/NavigationCapability.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/guimetadata/include/GuiMetadataMessages.h
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/guimetadata/include/GuiMetadataCapability.h
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/guimetadata/src/GuiMetadataCapability.cpp
-
#Utilities
${CMAKE_CURRENT_SOURCE_DIR}/utilities/events/EventRouter.h
${CMAKE_CURRENT_SOURCE_DIR}/utilities/events/EventRouter.cpp
@@ -91,7 +69,7 @@ PROJECT_TARGET_ADD(vshl-api)
# Define targets
ADD_LIBRARY(${TARGET_NAME} MODULE
- ${VSHL_LIB_SRC}
+ ${VSHL_CORE_LIB_SRC}
)
# VSHL plugin properties
@@ -129,8 +107,8 @@ PROJECT_TARGET_ADD(vshl-api)
include(cmake/gtest.cmake)
- set(VSHL_TEST_SRC ${VSHL_LIB_SRC})
- list(APPEND VSHL_TEST_SRC
+ set(VSHL_CORE_TEST_SRC ${VSHL_CORE_LIB_SRC})
+ list(APPEND VSHL_CORE_TEST_SRC
# Main
${CMAKE_CURRENT_SOURCE_DIR}/TestMain.cpp
@@ -142,14 +120,8 @@ PROJECT_TARGET_ADD(vshl-api)
${CMAKE_CURRENT_SOURCE_DIR}/test/mocks/AFBApiMock.h
${CMAKE_CURRENT_SOURCE_DIR}/test/mocks/AFBEventMock.h
${CMAKE_CURRENT_SOURCE_DIR}/test/mocks/AFBRequestMock.h
- ${CMAKE_CURRENT_SOURCE_DIR}/test/mocks/CapabilityMock.h
${CMAKE_CURRENT_SOURCE_DIR}/test/mocks/VoiceAgentsChangeObserverMock.h
- # Capabilities
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/test/CapabilityMessagingServiceTest.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/test/PublisherForwarderTest.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/capabilities/test/SubscriberForwarderTest.cpp
-
# Core
${CMAKE_CURRENT_SOURCE_DIR}/core/test/VRRequestTest.cpp
${CMAKE_CURRENT_SOURCE_DIR}/core/test/VRRequestProcessorTest.cpp
@@ -160,7 +132,7 @@ PROJECT_TARGET_ADD(vshl-api)
)
ADD_EXECUTABLE(${TARGET_NAME}_Test
- ${VSHL_TEST_SRC}
+ ${VSHL_CORE_TEST_SRC}
)
TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME}_Test
@@ -178,5 +150,5 @@ PROJECT_TARGET_ADD(vshl-api)
)
ENABLE_TESTING()
- ADD_TEST(VshlTest ${TARGET_NAME}_Test)
+ ADD_TEST(VshlCoreTest ${TARGET_NAME}_Test)
endif() \ No newline at end of file
diff --git a/src/plugins/VshlApi.cpp b/src/plugins/VshlApi.cpp
deleted file mode 100644
index f2c7b7c..0000000
--- a/src/plugins/VshlApi.cpp
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "VshlApi.h"
-
-#include <list>
-
-#include "afb/AFBApiImpl.h"
-#include "afb/AFBRequestImpl.h"
-#include "capabilities/CapabilitiesFactory.h"
-#include "capabilities/CapabilityMessagingService.h"
-#include "core/VRRequestProcessor.h"
-#include "utilities/events/EventRouter.h"
-#include "utilities/logging/Logger.h"
-#include "voiceagents/VoiceAgentEventNames.h"
-#include "voiceagents/VoiceAgentsDataManager.h"
-
-#include "json.hpp"
-
-using namespace std;
-
-CTLP_CAPI_REGISTER("vshl-api");
-
-static std::string TAG = "vshl::plugins::VshlAPI";
-
-static std::string VA_JSON_ATTR_DEFAULT = "default";
-static std::string VA_JSON_ATTR_AGENTS = "agents";
-static std::string VA_JSON_ATTR_ID = "id";
-static std::string VA_JSON_ATTR_NAME = "name";
-static std::string VA_JSON_ATTR_API = "api";
-static std::string VA_JSON_ATTR_ACTIVE = "active";
-static std::string VA_JSON_ATTR_WWS = "wakewords";
-static std::string VA_JSON_ATTR_ACTIVE_WW = "activewakeword";
-static std::string VA_JSON_ATTR_DESCRIPTION = "description";
-static std::string VA_JSON_ATTR_VENDOR = "vendor";
-
-static std::string STARTLISTENING_JSON_ATTR_REQUEST = "request_id";
-
-static std::string EVENTS_JSON_ATTR_VA_ID = "va_id";
-static std::string EVENTS_JSON_ATTR_EVENTS = "events";
-
-static std::string CAPABILITIES_JSON_ATTR_ACTION = "action";
-static std::string CAPABILITIES_JSON_ATTR_ACTIONS = "actions";
-static std::string CAPABILITIES_JSON_ATTR_PAYLOAD = "payload";
-
-static std::shared_ptr<vshl::utilities::logging::Logger> sLogger;
-static std::shared_ptr<vshl::common::interfaces::IAFBApi> sAfbApi;
-static std::unique_ptr<vshl::capabilities::CapabilitiesFactory> sCapabilitiesFactory;
-static std::unique_ptr<vshl::capabilities::CapabilityMessagingService> sCapabilityMessagingService;
-static std::unique_ptr<vshl::core::VRRequestProcessor> sVRRequestProcessor;
-static std::unique_ptr<vshl::voiceagents::VoiceAgentsDataManager> sVoiceAgentsDataManager;
-static std::unique_ptr<vshl::utilities::events::EventRouter> sEventRouter;
-
-using json = nlohmann::json;
-using Level = vshl::utilities::logging::Logger::Level;
-
-CTLP_ONLOAD(plugin, ret) {
- if (plugin->api == nullptr) {
- return -1;
- }
-
- // Logger
- sLogger = vshl::utilities::logging::Logger::create(plugin->api);
- // sLogger->log(Level::INFO, TAG, "Vshl plugin loaded & initialized.");
-
- // AFB Wrapper
- sAfbApi = vshl::afb::AFBApiImpl::create(plugin->api);
-
- // VRRequestProcessor
- auto vrRequestProcessorDelegate = vshl::core::VRRequestProcessorDelegate::create(sLogger, sAfbApi);
- sVRRequestProcessor = vshl::core::VRRequestProcessor::create(sLogger, vrRequestProcessorDelegate);
- if (!sVRRequestProcessor) {
- sLogger->log(Level::ERROR, TAG, "Failed to create VRRequestProcessor");
- return -1;
- }
-
- // VoiceAgentDataManager
- sVoiceAgentsDataManager = vshl::voiceagents::VoiceAgentsDataManager::create(sLogger, sAfbApi);
- if (!sVoiceAgentsDataManager) {
- sLogger->log(Level::ERROR, TAG, "Failed to create VoiceAgentsDataManager");
- return -1;
- }
- sVoiceAgentsDataManager->addVoiceAgentsChangeObserver(sVRRequestProcessor->getVoiceAgentsChangeObserver());
-
- // EventRouter
- sEventRouter = vshl::utilities::events::EventRouter::create(sLogger);
- if (!sEventRouter) {
- sLogger->log(Level::ERROR, TAG, "Failed to create EventRouter");
- return -1;
- }
- sEventRouter->addEventFilter(sVoiceAgentsDataManager->getEventFilter());
-
- sCapabilitiesFactory = vshl::capabilities::CapabilitiesFactory::create();
- if (!sCapabilitiesFactory) {
- sLogger->log(Level::ERROR, TAG, "Failed to create CapabilitiesFactory");
- return -1;
- }
-
- sCapabilityMessagingService = vshl::capabilities::CapabilityMessagingService::create(sLogger, sAfbApi);
- if (!sCapabilityMessagingService) {
- sLogger->log(Level::ERROR, TAG, "Failed to create CapabilityMessagingService");
- return -1;
- }
-
- return 0;
-}
-
-CTLP_CAPI(onAuthStateEvent, source, argsJ, eventJ) {
- if (sEventRouter == nullptr) {
- return -1;
- }
-
- string eventName = vshl::voiceagents::VSHL_EVENT_AUTH_STATE_EVENT;
- json eventJson = json::parse(json_object_to_json_string(eventJ));
- if (eventJson.find(EVENTS_JSON_ATTR_VA_ID) == eventJson.end()) {
- sLogger->log(Level::ERROR, TAG, "onAuthStateEvent: No voiceagent id found.");
- return -1;
- }
- std::string voiceAgentId(eventJson[EVENTS_JSON_ATTR_VA_ID].get<string>());
-
- if (!sEventRouter->handleIncomingEvent(eventName, voiceAgentId, json_object_to_json_string(eventJ))) {
- sLogger->log(Level::ERROR, TAG, "onAuthStateEvent: Failed to handle.");
- return -1;
- }
-
- return 0;
-}
-
-CTLP_CAPI(onConnectionStateEvent, source, argsJ, eventJ) {
- if (sEventRouter == nullptr) {
- return -1;
- }
-
- string eventName = vshl::voiceagents::VSHL_EVENT_CONNECTION_STATE_EVENT;
- json eventJson = json::parse(json_object_to_json_string(eventJ));
- if (eventJson.find(EVENTS_JSON_ATTR_VA_ID) == eventJson.end()) {
- sLogger->log(Level::ERROR, TAG, "onConnectionStateEvent: No voiceagent id found.");
- return -1;
- }
- std::string voiceAgentId(eventJson[EVENTS_JSON_ATTR_VA_ID].get<string>());
-
- if (!sEventRouter->handleIncomingEvent(eventName, voiceAgentId, json_object_to_json_string(eventJ))) {
- sLogger->log(Level::ERROR, TAG, "onConnectionStateEvent: Failed to handle.");
- return -1;
- }
-
- return 0;
-}
-
-CTLP_CAPI(onDialogStateEvent, source, argsJ, eventJ) {
- if (sEventRouter == nullptr) {
- return -1;
- }
-
- string eventName = vshl::voiceagents::VSHL_EVENT_DIALOG_STATE_EVENT;
- json eventJson = json::parse(json_object_to_json_string(eventJ));
- if (eventJson.find(EVENTS_JSON_ATTR_VA_ID) == eventJson.end()) {
- sLogger->log(Level::ERROR, TAG, "onDialogStateEvent: No voiceagent id found.");
- return -1;
- }
- std::string voiceAgentId(eventJson[EVENTS_JSON_ATTR_VA_ID].get<string>());
-
- if (!sEventRouter->handleIncomingEvent(eventName, voiceAgentId, json_object_to_json_string(eventJ))) {
- sLogger->log(Level::ERROR, TAG, "onDialogStateEvent: Failed to handle.");
- return -1;
- }
-
- return 0;
-}
-
-CTLP_CAPI(loadVoiceAgentsConfig, source, argsJ, eventJ) {
- if (sVoiceAgentsDataManager == nullptr) {
- sLogger->log(Level::WARNING, TAG, "loadVoiceAgentsConfig: Voice service not initialized.");
- return -1;
- }
-
- if (argsJ == nullptr) {
- sLogger->log(Level::WARNING, TAG, "loadVoiceAgentsConfig: No arguments supplied.");
- return -1;
- }
-
- json agentsConfigJson = json::parse(json_object_to_json_string(argsJ));
- if (agentsConfigJson.find(VA_JSON_ATTR_AGENTS) == agentsConfigJson.end()) {
- sLogger->log(Level::ERROR, TAG, "loadVoiceAgentsConfig: No agents object found in agents json");
- return -1;
- }
-
- json agentsJson = agentsConfigJson[VA_JSON_ATTR_AGENTS];
- for (auto agentIt = agentsJson.begin(); agentIt != agentsJson.end(); ++agentIt) {
- json agentJson = *agentIt;
-
- if (agentJson.find(VA_JSON_ATTR_ID) == agentJson.end() ||
- agentJson.find(VA_JSON_ATTR_ACTIVE) == agentJson.end() ||
- agentJson.find(VA_JSON_ATTR_NAME) == agentJson.end() ||
- agentJson.find(VA_JSON_ATTR_API) == agentJson.end() ||
- agentJson.find(VA_JSON_ATTR_WWS) == agentJson.end() ||
- agentJson.find(VA_JSON_ATTR_ACTIVE_WW) == agentJson.end() ||
- agentJson.find(VA_JSON_ATTR_DESCRIPTION) == agentJson.end() ||
- agentJson.find(VA_JSON_ATTR_VENDOR) == agentJson.end()) {
- std::stringstream error;
- error << "loadVoiceAgentsConfig: One or more missing params in agent "
- "config "
- << agentJson.dump();
- sLogger->log(Level::WARNING, TAG, error.str().c_str());
- continue;
- }
-
- std::string id(agentJson[VA_JSON_ATTR_ID].get<string>());
- std::string name(agentJson[VA_JSON_ATTR_NAME].get<string>());
- std::string api(agentJson[VA_JSON_ATTR_API].get<string>());
- std::string description(agentJson[VA_JSON_ATTR_DESCRIPTION].get<string>());
- std::string vendor(agentJson[VA_JSON_ATTR_VENDOR].get<string>());
- std::string activeWakeword(agentJson[VA_JSON_ATTR_ACTIVE_WW].get<string>());
- bool isActive(agentJson[VA_JSON_ATTR_ACTIVE].get<bool>());
-
- shared_ptr<unordered_set<string>> wakewords = std::make_shared<unordered_set<string>>();
- json wakewordsJson = agentJson[VA_JSON_ATTR_WWS];
- for (auto wwIt = wakewordsJson.begin(); wwIt != wakewordsJson.end(); ++wwIt) {
- wakewords->insert(wwIt->get<string>());
- }
-
- sVoiceAgentsDataManager->addNewVoiceAgent(
- id, name, description, api, vendor, activeWakeword, isActive, wakewords);
- }
-
- // Set the default agent.
- if (agentsConfigJson.find(VA_JSON_ATTR_DEFAULT) == agentsConfigJson.end()) {
- sLogger->log(Level::ERROR, TAG, "loadVoiceAgentsConfig: No default agent found in agents json");
- return -1;
- }
- std::string defaultAgentId(agentsConfigJson[VA_JSON_ATTR_DEFAULT].get<string>());
- sVoiceAgentsDataManager->setDefaultVoiceAgent(defaultAgentId);
-
- return 0;
-}
-
-CTLP_CAPI(startListening, source, argsJ, eventJ) {
- if (sVRRequestProcessor == nullptr) {
- return -1;
- }
-
- int result = 0;
- string requestId = sVRRequestProcessor->startListening();
-
- if (!requestId.empty()) {
- json responseJson;
- responseJson[STARTLISTENING_JSON_ATTR_REQUEST] = requestId;
- AFB_ReqSuccess(source->request, json_tokener_parse(responseJson.dump().c_str()), NULL);
- } else {
- AFB_ReqFail(source->request, NULL, "Failed to startListening...");
- }
-
- return 0;
-}
-
-CTLP_CAPI(cancelListening, source, argsJ, eventJ) {
- return 0;
-}
-
-CTLP_CAPI(enumerateVoiceAgents, source, argsJ, eventJ) {
- if (sVoiceAgentsDataManager == nullptr) {
- return -1;
- }
-
- auto agents = sVoiceAgentsDataManager->getAllVoiceAgents();
- std::string defaultAgentId(sVoiceAgentsDataManager->getDefaultVoiceAgent());
-
- json responseJson;
- json agentsJson = json::array();
-
- for (auto agent : agents) {
- json agentJson;
- agentJson[VA_JSON_ATTR_ID] = agent->getId();
- agentJson[VA_JSON_ATTR_NAME] = agent->getName();
- agentJson[VA_JSON_ATTR_DESCRIPTION] = agent->getDescription();
- agentJson[VA_JSON_ATTR_API] = agent->getApi();
- agentJson[VA_JSON_ATTR_VENDOR] = agent->getVendor();
- agentJson[VA_JSON_ATTR_ACTIVE] = agent->isActive();
- agentJson[VA_JSON_ATTR_ACTIVE_WW] = agent->getActiveWakeword();
-
- auto wakewords = agent->getWakeWords();
- if (wakewords != nullptr) {
- json wakewordsJson;
- for (auto wakeword : *wakewords) {
- wakewordsJson.push_back(wakeword);
- }
- agentJson[VA_JSON_ATTR_WWS] = wakewordsJson;
- }
-
- agentsJson.push_back(agentJson);
- }
-
- responseJson[VA_JSON_ATTR_AGENTS] = agentsJson;
- responseJson[VA_JSON_ATTR_DEFAULT] = defaultAgentId;
-
- AFB_ReqSuccess(source->request, json_tokener_parse(responseJson.dump().c_str()), NULL);
-
- return 0;
-}
-
-CTLP_CAPI(subscribe, source, argsJ, eventJ) {
- if (sVoiceAgentsDataManager == nullptr) {
- return -1;
- }
-
- if (eventJ == nullptr) {
- sLogger->log(Level::WARNING, TAG, "subscribe: No arguments supplied.");
- return -1;
- }
-
- json subscribeJson = json::parse(json_object_to_json_string(eventJ));
- if (subscribeJson.find(EVENTS_JSON_ATTR_VA_ID) == subscribeJson.end()) {
- sLogger->log(Level::ERROR, TAG, "subscribe: No voiceagent id found in subscribe json");
- return -1;
- }
- std::string voiceAgentId(subscribeJson[EVENTS_JSON_ATTR_VA_ID].get<string>());
-
- if (subscribeJson.find(EVENTS_JSON_ATTR_EVENTS) == subscribeJson.end()) {
- sLogger->log(Level::ERROR, TAG, "subscribe: No events array found in subscribe json");
- return -1;
- }
- list<string> events(subscribeJson[EVENTS_JSON_ATTR_EVENTS].get<list<string>>());
-
- // Subscribe this client for the listed events.
- auto request = vshl::afb::AFBRequestImpl::create(source->request);
- for (auto event : events) {
- if (!sVoiceAgentsDataManager->subscribeToVshlEventFromVoiceAgent(*request, event, voiceAgentId)) {
- sLogger->log(Level::ERROR, TAG, "subscribe: Failed to subscribe to event: " + event);
- return -1;
- }
- }
-
- AFB_ReqSuccess(source->request, json_object_new_string("Subscription to events successfully completed."), NULL);
-
- return 0;
-}
-
-CTLP_CAPI(setDefaultVoiceAgent, source, argsJ, eventJ) {
- if (sVoiceAgentsDataManager == nullptr) {
- return -1;
- }
-
- if (eventJ == nullptr) {
- sLogger->log(Level::WARNING, TAG, "setDefaultVoiceAgent: No arguments supplied.");
- return -1;
- }
-
- json jsonRequest = json::parse(json_object_to_json_string(eventJ));
- if (jsonRequest.find(VA_JSON_ATTR_ID) == jsonRequest.end()) {
- sLogger->log(Level::ERROR, TAG, "setDefaultVoiceAgent: voice agent id not found in request json");
- return -1;
- }
-
- std::string voiceAgentId(jsonRequest[VA_JSON_ATTR_ID].get<string>());
- if (!sVoiceAgentsDataManager->setDefaultVoiceAgent(voiceAgentId)) {
- sLogger->log(Level::ERROR, TAG, "setDefaultVoiceAgent: Failed to set default agent");
- return -1;
- }
-
- AFB_ReqSuccess(source->request, NULL, NULL);
- return 0;
-}
-
-CTLP_CAPI(guiMetadataSubscribe, source, argsJ, eventJ) {
- if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
- return -1;
- }
-
- shared_ptr<vshl::common::interfaces::ICapability> guMetadataCapability = sCapabilitiesFactory->getGuiMetadata();
- if (!guMetadataCapability) {
- sLogger->log(
- Level::WARNING,
- TAG,
- "guimetadataSubscribe: Failed to "
- "fetch guimetadata capability "
- "object.");
- return -1;
- }
-
- if (eventJ == nullptr) {
- sLogger->log(Level::WARNING, TAG, "guimetadataSubscribe: No arguments supplied.");
- return -1;
- }
-
- json subscribeJson = json::parse(json_object_to_json_string(eventJ));
- if (subscribeJson.find(CAPABILITIES_JSON_ATTR_ACTIONS) == subscribeJson.end()) {
- sLogger->log(Level::ERROR, TAG, "guimetadataSubscribe: No events array found in subscribe json");
- return -1;
- }
- list<string> events(subscribeJson[CAPABILITIES_JSON_ATTR_ACTIONS].get<list<string>>());
-
- // SUbscribe this client for the guimetadata events.
- auto request = vshl::afb::AFBRequestImpl::create(source->request);
- for (auto event : events) {
- if (!sCapabilityMessagingService->subscribe(*request, guMetadataCapability, event)) {
- sLogger->log(Level::ERROR, TAG, "guimetadataSubscribe: Failed to subscribe to event: " + event);
- return -1;
- }
- }
-
- AFB_ReqSuccess(
- source->request, json_object_new_string("Subscription to guimetadata events successfully completed."), NULL);
- return 0;
-}
-
-CTLP_CAPI(guiMetadataPublish, source, argsJ, eventJ) {
- if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
- return -1;
- }
-
- shared_ptr<vshl::common::interfaces::ICapability> guMetadataCapability = sCapabilitiesFactory->getGuiMetadata();
- if (!guMetadataCapability) {
- sLogger->log(
- Level::WARNING,
- TAG,
- "guimetadataPublish: Failed to fetch "
- "guimetadata capability object.");
- return -1;
- }
-
- if (eventJ == nullptr) {
- sLogger->log(Level::WARNING, TAG, "guimetadataPublish: No arguments supplied.");
- return -1;
- }
-
- json publishJson = json::parse(json_object_to_json_string(eventJ));
- if (publishJson.find(CAPABILITIES_JSON_ATTR_ACTION) == publishJson.end()) {
- sLogger->log(Level::ERROR, TAG, "guimetadataPublish: No action found in publish json");
- return -1;
- }
- std::string action(publishJson[CAPABILITIES_JSON_ATTR_ACTION].get<string>());
-
- if (publishJson.find(CAPABILITIES_JSON_ATTR_PAYLOAD) == publishJson.end()) {
- sLogger->log(Level::ERROR, TAG, "guimetadataPublish: No payload found in publish json");
- return -1;
- }
- std::string payload(publishJson[CAPABILITIES_JSON_ATTR_PAYLOAD].get<string>());
-
- if (!sCapabilityMessagingService->publish(guMetadataCapability, action, payload)) {
- sLogger->log(Level::ERROR, TAG, "guimetadataPublish: Failed to publish message: " + action);
- return -1;
- }
-
- AFB_ReqSuccess(source->request, json_object_new_string("Successfully published guimetadata messages."), NULL);
- return 0;
-}
-
-CTLP_CAPI(phonecontrolSubscribe, source, argsJ, eventJ) {
- if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
- return -1;
- }
-
- shared_ptr<vshl::common::interfaces::ICapability> phoneControlCapability = sCapabilitiesFactory->getPhoneControl();
- if (!phoneControlCapability) {
- sLogger->log(Level::WARNING, TAG, "phoneControlSubscribe: Failed to fetch phone control capability object.");
- return -1;
- }
-
- if (eventJ == nullptr) {
- sLogger->log(Level::WARNING, TAG, "phoneControlSubscribe: No arguments supplied.");
- return -1;
- }
-
- json subscribeJson = json::parse(json_object_to_json_string(eventJ));
- if (subscribeJson.find(CAPABILITIES_JSON_ATTR_ACTIONS) == subscribeJson.end()) {
- sLogger->log(Level::ERROR, TAG, "phoneControlSubscribe: No events array found in subscribe json");
- return -1;
- }
- list<string> events(subscribeJson[CAPABILITIES_JSON_ATTR_ACTIONS].get<list<string>>());
-
- // SUbscribe this client for the phone call control events.
- auto request = vshl::afb::AFBRequestImpl::create(source->request);
- for (auto event : events) {
- if (!sCapabilityMessagingService->subscribe(*request, phoneControlCapability, event)) {
- sLogger->log(Level::ERROR, TAG, "phoneControlSubscribe: Failed to subscribe to event: " + event);
- return -1;
- }
- }
-
- AFB_ReqSuccess(
- source->request, json_object_new_string("Subscription to phone control events successfully completed."), NULL);
- return 0;
-}
-
-CTLP_CAPI(phonecontrolPublish, source, argsJ, eventJ) {
- if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
- return -1;
- }
-
- shared_ptr<vshl::common::interfaces::ICapability> phoneControlCapability = sCapabilitiesFactory->getPhoneControl();
- if (!phoneControlCapability) {
- sLogger->log(Level::WARNING, TAG, "phoneControlPublish: Failed to fetch navigation capability object.");
- return -1;
- }
-
- if (eventJ == nullptr) {
- sLogger->log(Level::WARNING, TAG, "phoneControlPublish: No arguments supplied.");
- return -1;
- }
-
- json publishJson = json::parse(json_object_to_json_string(eventJ));
- if (publishJson.find(CAPABILITIES_JSON_ATTR_ACTION) == publishJson.end()) {
- sLogger->log(Level::ERROR, TAG, "phoneControlPublish: No action found in publish json");
- return -1;
- }
- std::string action(publishJson[CAPABILITIES_JSON_ATTR_ACTION].get<string>());
-
- if (publishJson.find(CAPABILITIES_JSON_ATTR_PAYLOAD) == publishJson.end()) {
- sLogger->log(Level::ERROR, TAG, "phoneControlPublish: No payload found in publish json");
- return -1;
- }
- std::string payload(publishJson[CAPABILITIES_JSON_ATTR_PAYLOAD].get<string>());
-
- if (!sCapabilityMessagingService->publish(phoneControlCapability, action, payload)) {
- sLogger->log(Level::ERROR, TAG, "phoneControlPublish: Failed to publish message: " + action);
- return -1;
- }
-
- AFB_ReqSuccess(source->request, json_object_new_string("Successfully published phone control messages."), NULL);
- return 0;
-}
-
-CTLP_CAPI(navigationSubscribe, source, argsJ, eventJ) {
- if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
- return -1;
- }
-
- shared_ptr<vshl::common::interfaces::ICapability> navigationCapability = sCapabilitiesFactory->getNavigation();
- if (!navigationCapability) {
- sLogger->log(Level::WARNING, TAG, "navigationSubscribe: Failed to fetch navigation capability object.");
- return -1;
- }
-
- if (eventJ == nullptr) {
- sLogger->log(Level::WARNING, TAG, "navigationSubscribe: No arguments supplied.");
- return -1;
- }
-
- json subscribeJson = json::parse(json_object_to_json_string(eventJ));
- if (subscribeJson.find(CAPABILITIES_JSON_ATTR_ACTIONS) == subscribeJson.end()) {
- sLogger->log(Level::ERROR, TAG, "navigationSubscribe: No events array found in subscribe json");
- return -1;
- }
- list<string> events(subscribeJson[CAPABILITIES_JSON_ATTR_ACTIONS].get<list<string>>());
-
- // SUbscribe this client for the navigation events.
- auto request = vshl::afb::AFBRequestImpl::create(source->request);
- for (auto event : events) {
- if (!sCapabilityMessagingService->subscribe(*request, navigationCapability, event)) {
- sLogger->log(Level::ERROR, TAG, "navigationSubscribe: Failed to subscribe to event: " + event);
- return -1;
- }
- }
-
- AFB_ReqSuccess(
- source->request, json_object_new_string("Subscription to navigation events successfully completed."), NULL);
- return 0;
-}
-
-CTLP_CAPI(navigationPublish, source, argsJ, eventJ) {
- if (sCapabilitiesFactory == nullptr || sCapabilityMessagingService == nullptr) {
- return -1;
- }
-
- shared_ptr<vshl::common::interfaces::ICapability> navigationCapability = sCapabilitiesFactory->getNavigation();
- if (!navigationCapability) {
- sLogger->log(Level::WARNING, TAG, "navigationPublish: Failed to fetch navigation capability object.");
- return -1;
- }
-
- if (eventJ == nullptr) {
- sLogger->log(Level::WARNING, TAG, "navigationPublish: No arguments supplied.");
- return -1;
- }
-
- json publishJson = json::parse(json_object_to_json_string(eventJ));
- if (publishJson.find(CAPABILITIES_JSON_ATTR_ACTION) == publishJson.end()) {
- sLogger->log(Level::ERROR, TAG, "navigationPublish: No action found in publish json");
- return -1;
- }
- std::string action(publishJson[CAPABILITIES_JSON_ATTR_ACTION].get<string>());
-
- if (publishJson.find(CAPABILITIES_JSON_ATTR_PAYLOAD) == publishJson.end()) {
- sLogger->log(Level::ERROR, TAG, "navigationPublish: No payload found in publish json");
- return -1;
- }
- std::string payload(publishJson[CAPABILITIES_JSON_ATTR_PAYLOAD].get<string>());
-
- if (!sCapabilityMessagingService->publish(navigationCapability, action, payload)) {
- sLogger->log(Level::ERROR, TAG, "navigationPublish: Failed to publish message: " + action);
- return -1;
- }
-
- AFB_ReqSuccess(source->request, json_object_new_string("Successfully published navigation messages."), NULL);
- return 0;
-}
diff --git a/src/plugins/VshlCoreApi.cpp b/src/plugins/VshlCoreApi.cpp
new file mode 100644
index 0000000..a91ca3e
--- /dev/null
+++ b/src/plugins/VshlCoreApi.cpp
@@ -0,0 +1,348 @@
+/*
+ * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License").
+ * You may not use this file except in compliance with the License.
+ * A copy of the License is located at
+ *
+ * http://aws.amazon.com/apache2.0/
+ *
+ * or in the "license" file accompanying this file. This file is distributed
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+#include "VshlCoreApi.h"
+
+#include <list>
+
+#include "afb/AFBApiImpl.h"
+#include "afb/AFBRequestImpl.h"
+#include "core/VRRequestProcessor.h"
+#include "utilities/events/EventRouter.h"
+#include "utilities/logging/Logger.h"
+#include "voiceagents/VoiceAgentEventNames.h"
+#include "voiceagents/VoiceAgentsDataManager.h"
+
+#include "json.hpp"
+
+using namespace std;
+
+CTLP_CAPI_REGISTER("vshl-core-api");
+
+static std::string TAG = "vshlcore::plugins::VshlCoreAPI";
+
+static std::string VA_JSON_ATTR_DEFAULT = "default";
+static std::string VA_JSON_ATTR_AGENTS = "agents";
+static std::string VA_JSON_ATTR_ID = "id";
+static std::string VA_JSON_ATTR_NAME = "name";
+static std::string VA_JSON_ATTR_API = "api";
+static std::string VA_JSON_ATTR_ACTIVE = "active";
+static std::string VA_JSON_ATTR_WWS = "wakewords";
+static std::string VA_JSON_ATTR_ACTIVE_WW = "activewakeword";
+static std::string VA_JSON_ATTR_DESCRIPTION = "description";
+static std::string VA_JSON_ATTR_VENDOR = "vendor";
+
+static std::string STARTLISTENING_JSON_ATTR_REQUEST = "request_id";
+
+static std::string EVENTS_JSON_ATTR_VA_ID = "va_id";
+static std::string EVENTS_JSON_ATTR_EVENTS = "events";
+
+static std::shared_ptr<vshlcore::utilities::logging::Logger> sLogger;
+static std::shared_ptr<vshlcore::common::interfaces::IAFBApi> sAfbApi;
+static std::unique_ptr<vshlcore::core::VRRequestProcessor> sVRRequestProcessor;
+static std::unique_ptr<vshlcore::voiceagents::VoiceAgentsDataManager> sVoiceAgentsDataManager;
+static std::unique_ptr<vshlcore::utilities::events::EventRouter> sEventRouter;
+
+using json = nlohmann::json;
+using Level = vshlcore::utilities::logging::Logger::Level;
+
+CTLP_ONLOAD(plugin, ret) {
+ if (plugin->api == nullptr) {
+ return -1;
+ }
+
+ // Logger
+ sLogger = vshlcore::utilities::logging::Logger::create(plugin->api);
+ // sLogger->log(Level::INFO, TAG, "Vshl plugin loaded & initialized.");
+
+ // AFB Wrapper
+ sAfbApi = vshlcore::afb::AFBApiImpl::create(plugin->api);
+
+ // VRRequestProcessor
+ auto vrRequestProcessorDelegate = vshlcore::core::VRRequestProcessorDelegate::create(sLogger, sAfbApi);
+ sVRRequestProcessor = vshlcore::core::VRRequestProcessor::create(sLogger, vrRequestProcessorDelegate);
+ if (!sVRRequestProcessor) {
+ sLogger->log(Level::ERROR, TAG, "Failed to create VRRequestProcessor");
+ return -1;
+ }
+
+ // VoiceAgentDataManager
+ sVoiceAgentsDataManager = vshlcore::voiceagents::VoiceAgentsDataManager::create(sLogger, sAfbApi);
+ if (!sVoiceAgentsDataManager) {
+ sLogger->log(Level::ERROR, TAG, "Failed to create VoiceAgentsDataManager");
+ return -1;
+ }
+ sVoiceAgentsDataManager->addVoiceAgentsChangeObserver(sVRRequestProcessor->getVoiceAgentsChangeObserver());
+
+ // EventRouter
+ sEventRouter = vshlcore::utilities::events::EventRouter::create(sLogger);
+ if (!sEventRouter) {
+ sLogger->log(Level::ERROR, TAG, "Failed to create EventRouter");
+ return -1;
+ }
+ sEventRouter->addEventFilter(sVoiceAgentsDataManager->getEventFilter());
+
+ return 0;
+}
+
+CTLP_CAPI(onAuthStateEvent, source, argsJ, eventJ) {
+ if (sEventRouter == nullptr) {
+ return -1;
+ }
+
+ string eventName = vshlcore::voiceagents::VSHL_EVENT_AUTH_STATE_EVENT;
+ json eventJson = json::parse(json_object_to_json_string(eventJ));
+ if (eventJson.find(EVENTS_JSON_ATTR_VA_ID) == eventJson.end()) {
+ sLogger->log(Level::ERROR, TAG, "onAuthStateEvent: No voiceagent id found.");
+ return -1;
+ }
+ std::string voiceAgentId(eventJson[EVENTS_JSON_ATTR_VA_ID].get<string>());
+
+ sEventRouter->handleIncomingEvent(eventName, voiceAgentId, json_object_to_json_string(eventJ));
+
+ return 0;
+}
+
+CTLP_CAPI(onConnectionStateEvent, source, argsJ, eventJ) {
+ if (sEventRouter == nullptr) {
+ return -1;
+ }
+
+ string eventName = vshlcore::voiceagents::VSHL_EVENT_CONNECTION_STATE_EVENT;
+ json eventJson = json::parse(json_object_to_json_string(eventJ));
+ if (eventJson.find(EVENTS_JSON_ATTR_VA_ID) == eventJson.end()) {
+ sLogger->log(Level::ERROR, TAG, "onConnectionStateEvent: No voiceagent id found.");
+ return -1;
+ }
+ std::string voiceAgentId(eventJson[EVENTS_JSON_ATTR_VA_ID].get<string>());
+
+ sEventRouter->handleIncomingEvent(eventName, voiceAgentId, json_object_to_json_string(eventJ));
+
+ return 0;
+}
+
+CTLP_CAPI(onDialogStateEvent, source, argsJ, eventJ) {
+ if (sEventRouter == nullptr) {
+ return -1;
+ }
+
+ string eventName = vshlcore::voiceagents::VSHL_EVENT_DIALOG_STATE_EVENT;
+ json eventJson = json::parse(json_object_to_json_string(eventJ));
+ if (eventJson.find(EVENTS_JSON_ATTR_VA_ID) == eventJson.end()) {
+ sLogger->log(Level::ERROR, TAG, "onDialogStateEvent: No voiceagent id found.");
+ return -1;
+ }
+ std::string voiceAgentId(eventJson[EVENTS_JSON_ATTR_VA_ID].get<string>());
+
+ sEventRouter->handleIncomingEvent(eventName, voiceAgentId, json_object_to_json_string(eventJ));
+
+ return 0;
+}
+
+CTLP_CAPI(loadVoiceAgentsConfig, source, argsJ, eventJ) {
+ if (sVoiceAgentsDataManager == nullptr) {
+ sLogger->log(Level::WARNING, TAG, "loadVoiceAgentsConfig: Voice service not initialized.");
+ return -1;
+ }
+
+ if (argsJ == nullptr) {
+ sLogger->log(Level::WARNING, TAG, "loadVoiceAgentsConfig: No arguments supplied.");
+ return -1;
+ }
+
+ json agentsConfigJson = json::parse(json_object_to_json_string(argsJ));
+ if (agentsConfigJson.find(VA_JSON_ATTR_AGENTS) == agentsConfigJson.end()) {
+ sLogger->log(Level::ERROR, TAG, "loadVoiceAgentsConfig: No agents object found in agents json");
+ return -1;
+ }
+
+ json agentsJson = agentsConfigJson[VA_JSON_ATTR_AGENTS];
+ for (auto agentIt = agentsJson.begin(); agentIt != agentsJson.end(); ++agentIt) {
+ json agentJson = *agentIt;
+
+ if (agentJson.find(VA_JSON_ATTR_ID) == agentJson.end() ||
+ agentJson.find(VA_JSON_ATTR_ACTIVE) == agentJson.end() ||
+ agentJson.find(VA_JSON_ATTR_NAME) == agentJson.end() ||
+ agentJson.find(VA_JSON_ATTR_API) == agentJson.end() ||
+ agentJson.find(VA_JSON_ATTR_WWS) == agentJson.end() ||
+ agentJson.find(VA_JSON_ATTR_ACTIVE_WW) == agentJson.end() ||
+ agentJson.find(VA_JSON_ATTR_DESCRIPTION) == agentJson.end() ||
+ agentJson.find(VA_JSON_ATTR_VENDOR) == agentJson.end()) {
+ std::stringstream error;
+ error << "loadVoiceAgentsConfig: One or more missing params in agent "
+ "config "
+ << agentJson.dump();
+ sLogger->log(Level::WARNING, TAG, error.str().c_str());
+ continue;
+ }
+
+ std::string id(agentJson[VA_JSON_ATTR_ID].get<string>());
+ std::string name(agentJson[VA_JSON_ATTR_NAME].get<string>());
+ std::string api(agentJson[VA_JSON_ATTR_API].get<string>());
+ std::string description(agentJson[VA_JSON_ATTR_DESCRIPTION].get<string>());
+ std::string vendor(agentJson[VA_JSON_ATTR_VENDOR].get<string>());
+ std::string activeWakeword(agentJson[VA_JSON_ATTR_ACTIVE_WW].get<string>());
+ bool isActive(agentJson[VA_JSON_ATTR_ACTIVE].get<bool>());
+
+ shared_ptr<unordered_set<string>> wakewords = std::make_shared<unordered_set<string>>();
+ json wakewordsJson = agentJson[VA_JSON_ATTR_WWS];
+ for (auto wwIt = wakewordsJson.begin(); wwIt != wakewordsJson.end(); ++wwIt) {
+ wakewords->insert(wwIt->get<string>());
+ }
+
+ sVoiceAgentsDataManager->addNewVoiceAgent(
+ id, name, description, api, vendor, activeWakeword, isActive, wakewords);
+ }
+
+ // Set the default agent.
+ if (agentsConfigJson.find(VA_JSON_ATTR_DEFAULT) == agentsConfigJson.end()) {
+ sLogger->log(Level::ERROR, TAG, "loadVoiceAgentsConfig: No default agent found in agents json");
+ return -1;
+ }
+ std::string defaultAgentId(agentsConfigJson[VA_JSON_ATTR_DEFAULT].get<string>());
+ sVoiceAgentsDataManager->setDefaultVoiceAgent(defaultAgentId);
+
+ return 0;
+}
+
+CTLP_CAPI(startListening, source, argsJ, eventJ) {
+ if (sVoiceAgentsDataManager == nullptr) {
+ return -1;
+ }
+
+ if (sVRRequestProcessor == nullptr) {
+ return -1;
+ }
+
+ int result = 0;
+ string requestId = sVRRequestProcessor->startListening();
+
+ if (!requestId.empty()) {
+ json responseJson;
+ responseJson[STARTLISTENING_JSON_ATTR_REQUEST] = requestId;
+ AFB_ReqSuccess(source->request, json_tokener_parse(responseJson.dump().c_str()), NULL);
+ } else {
+ AFB_ReqFail(source->request, NULL, "Failed to startListening...");
+ }
+
+ return 0;
+}
+
+CTLP_CAPI(cancelListening, source, argsJ, eventJ) {
+ return 0;
+}
+
+CTLP_CAPI(enumerateVoiceAgents, source, argsJ, eventJ) {
+ if (sVoiceAgentsDataManager == nullptr) {
+ return -1;
+ }
+
+ auto agents = sVoiceAgentsDataManager->getAllVoiceAgents();
+ std::string defaultAgentId(sVoiceAgentsDataManager->getDefaultVoiceAgent());
+
+ json responseJson;
+ json agentsJson = json::array();
+
+ for (auto agent : agents) {
+ json agentJson;
+ agentJson[VA_JSON_ATTR_ID] = agent->getId();
+ agentJson[VA_JSON_ATTR_NAME] = agent->getName();
+ agentJson[VA_JSON_ATTR_DESCRIPTION] = agent->getDescription();
+ agentJson[VA_JSON_ATTR_API] = agent->getApi();
+ agentJson[VA_JSON_ATTR_VENDOR] = agent->getVendor();
+ agentJson[VA_JSON_ATTR_ACTIVE] = agent->isActive();
+ agentJson[VA_JSON_ATTR_ACTIVE_WW] = agent->getActiveWakeword();
+
+ auto wakewords = agent->getWakeWords();
+ if (wakewords != nullptr) {
+ json wakewordsJson;
+ for (auto wakeword : *wakewords) {
+ wakewordsJson.push_back(wakeword);
+ }
+ agentJson[VA_JSON_ATTR_WWS] = wakewordsJson;
+ }
+
+ agentsJson.push_back(agentJson);
+ }
+
+ responseJson[VA_JSON_ATTR_AGENTS] = agentsJson;
+ responseJson[VA_JSON_ATTR_DEFAULT] = defaultAgentId;
+
+ AFB_ReqSuccess(source->request, json_tokener_parse(responseJson.dump().c_str()), NULL);
+
+ return 0;
+}
+
+CTLP_CAPI(subscribe, source, argsJ, eventJ) {
+ if (sVoiceAgentsDataManager == nullptr) {
+ return -1;
+ }
+
+ if (eventJ == nullptr) {
+ sLogger->log(Level::WARNING, TAG, "subscribe: No arguments supplied.");
+ return -1;
+ }
+
+ json subscribeJson = json::parse(json_object_to_json_string(eventJ));
+ if (subscribeJson.find(EVENTS_JSON_ATTR_VA_ID) == subscribeJson.end()) {
+ sLogger->log(Level::ERROR, TAG, "subscribe: No voiceagent id found in subscribe json");
+ return -1;
+ }
+ std::string voiceAgentId(subscribeJson[EVENTS_JSON_ATTR_VA_ID].get<string>());
+
+ if (subscribeJson.find(EVENTS_JSON_ATTR_EVENTS) == subscribeJson.end()) {
+ sLogger->log(Level::ERROR, TAG, "subscribe: No events array found in subscribe json");
+ return -1;
+ }
+ list<string> events(subscribeJson[EVENTS_JSON_ATTR_EVENTS].get<list<string>>());
+
+ // Subscribe this client for the listed events.
+ auto request = vshlcore::afb::AFBRequestImpl::create(source->request);
+ for (auto event : events) {
+ if (!sVoiceAgentsDataManager->subscribeToVshlEventFromVoiceAgent(*request, event, voiceAgentId)) {
+ sLogger->log(Level::ERROR, TAG, "subscribe: Failed to subscribe to event: " + event);
+ return -1;
+ }
+ }
+
+ AFB_ReqSuccess(source->request, json_object_new_string("Subscription to events successfully completed."), NULL);
+
+ return 0;
+}
+
+CTLP_CAPI(setDefaultVoiceAgent, source, argsJ, eventJ) {
+ if (sVoiceAgentsDataManager == nullptr) {
+ return -1;
+ }
+
+ if (eventJ == nullptr) {
+ sLogger->log(Level::WARNING, TAG, "setDefaultVoiceAgent: No arguments supplied.");
+ return -1;
+ }
+
+ json jsonRequest = json::parse(json_object_to_json_string(eventJ));
+ if (jsonRequest.find(VA_JSON_ATTR_ID) == jsonRequest.end()) {
+ sLogger->log(Level::ERROR, TAG, "setDefaultVoiceAgent: voice agent id not found in request json");
+ return -1;
+ }
+
+ std::string voiceAgentId(jsonRequest[VA_JSON_ATTR_ID].get<string>());
+ if (!sVoiceAgentsDataManager->setDefaultVoiceAgent(voiceAgentId)) {
+ sLogger->log(Level::ERROR, TAG, "setDefaultVoiceAgent: Failed to set default agent");
+ return -1;
+ }
+
+ AFB_ReqSuccess(source->request, NULL, NULL);
+ return 0;
+} \ No newline at end of file
diff --git a/src/plugins/VshlApi.h b/src/plugins/VshlCoreApi.h
index f228943..557cecc 100644
--- a/src/plugins/VshlApi.h
+++ b/src/plugins/VshlCoreApi.h
@@ -12,8 +12,8 @@
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
-#ifndef VSHL_API_INCLUDE
-#define VSHL_API_INCLUDE
+#ifndef VSHL_CORE_API_INCLUDE
+#define VSHL_CORE_API_INCLUDE
#include "ctl-plugin.h"
@@ -32,15 +32,9 @@ int cancelListening(CtlSourceT* source, json_object* argsJ, json_object* queryJ)
int enumerateVoiceAgents(CtlSourceT* source, json_object* argsJ, json_object* queryJ);
int subscribe(CtlSourceT* source, json_object* argsJ, json_object* queryJ);
int setDefaultVoiceAgent(CtlSourceT* source, json_object* argsJ, json_object* queryJ);
-int guiMetadataSubscribe(CtlSourceT* source, json_object* argsJ, json_object* queryJ);
-int guiMetadataPublish(CtlSourceT* source, json_object* argsJ, json_object* queryJ);
-int phonecontrolSubscribe(CtlSourceT* source, json_object* argsJ, json_object* queryJ);
-int phonecontrolPublish(CtlSourceT* source, json_object* argsJ, json_object* queryJ);
-int navigationSubscribe(CtlSourceT* source, json_object* argsJ, json_object* queryJ);
-int navigationPublish(CtlSourceT* source, json_object* argsJ, json_object* queryJ);
#ifdef __cplusplus
}
#endif
-#endif // VSHL_API_INCLUDE
+#endif // VSHL_CORE_API_INCLUDE
diff --git a/src/plugins/afb/AFBApiImpl.cpp b/src/plugins/afb/AFBApiImpl.cpp
index 88d1e7e..9af4fbc 100644
--- a/src/plugins/afb/AFBApiImpl.cpp
+++ b/src/plugins/afb/AFBApiImpl.cpp
@@ -20,29 +20,19 @@
extern "C" {
#define AFB_BINDING_VERSION 3
-#define FREEIF(x) \
- if (!x) { \
- free(x); \
- }
-#define BREAKIF(x) \
- if (x) { \
- result = false; \
- break; \
- }
#include "afb-definitions.h"
}
-static std::string TAG = "vshl::afb::AFBApiImpl";
+static std::string TAG = "vshlcore::afb::AFBApiImpl";
/**
* Specifies the severity level of a log message
*/
-using Level = vshl::common::interfaces::ILogger::Level;
-using namespace vshl::common::interfaces;
-using namespace vshl::utilities::logging;
-
-namespace vshl {
+using Level = vshlcore::common::interfaces::ILogger::Level;
+using namespace vshlcore::common::interfaces;
+using namespace vshlcore::utilities::logging;
+namespace vshlcore {
namespace afb {
std::unique_ptr<AFBApiImpl> AFBApiImpl::create(AFB_ApiT api) {
diff --git a/src/plugins/afb/AFBApiImpl.h b/src/plugins/afb/AFBApiImpl.h
index 74aa7ef..d6b7b31 100644
--- a/src/plugins/afb/AFBApiImpl.h
+++ b/src/plugins/afb/AFBApiImpl.h
@@ -25,11 +25,10 @@ extern "C" {
#include "interfaces/utilities/logging/ILogger.h"
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace afb {
-class AFBApiImpl : public vshl::common::interfaces::IAFBApi {
+class AFBApiImpl : public vshlcore::common::interfaces::IAFBApi {
public:
static std::unique_ptr<AFBApiImpl> create(AFB_ApiT api);
@@ -52,7 +51,7 @@ private:
AFB_ApiT mApi;
// Logger
- std::shared_ptr<vshl::common::interfaces::ILogger> mLogger;
+ std::shared_ptr<vshlcore::common::interfaces::ILogger> mLogger;
};
} // namespace afb
diff --git a/src/plugins/afb/AFBRequestImpl.cpp b/src/plugins/afb/AFBRequestImpl.cpp
index 8ec5691..6e0f177 100644
--- a/src/plugins/afb/AFBRequestImpl.cpp
+++ b/src/plugins/afb/AFBRequestImpl.cpp
@@ -18,8 +18,7 @@
extern "C" {
#include "afb-definitions.h"
}
-
-namespace vshl {
+namespace vshlcore {
namespace afb {
std::unique_ptr<AFBRequestImpl> AFBRequestImpl::create(AFB_ReqT afbRequest) {
diff --git a/src/plugins/afb/AFBRequestImpl.h b/src/plugins/afb/AFBRequestImpl.h
index 2e6f3ab..82772fb 100644
--- a/src/plugins/afb/AFBRequestImpl.h
+++ b/src/plugins/afb/AFBRequestImpl.h
@@ -22,14 +22,13 @@ extern "C" {
}
#include "interfaces/afb/IAFBApi.h"
-
-namespace vshl {
+namespace vshlcore {
namespace afb {
/**
* AFB Request impl
*/
-class AFBRequestImpl : public vshl::common::interfaces::IAFBRequest {
+class AFBRequestImpl : public vshlcore::common::interfaces::IAFBRequest {
public:
static std::unique_ptr<AFBRequestImpl> create(AFB_ReqT afbRequest);
diff --git a/src/plugins/afb/include/AFBEventImpl.h b/src/plugins/afb/include/AFBEventImpl.h
index 45f85f9..924c966 100644
--- a/src/plugins/afb/include/AFBEventImpl.h
+++ b/src/plugins/afb/include/AFBEventImpl.h
@@ -28,15 +28,15 @@ extern "C" {
using namespace std;
-namespace vshl {
+namespace vshlcore {
namespace afb {
/*
* This class encapsulates AFB Event.
*/
-class AFBEventImpl : public vshl::common::interfaces::IAFBApi::IAFBEvent {
+class AFBEventImpl : public vshlcore::common::interfaces::IAFBApi::IAFBEvent {
public:
static unique_ptr<AFBEventImpl>
- create(shared_ptr<vshl::common::interfaces::ILogger> logger, AFB_ApiT api,
+ create(shared_ptr<vshlcore::common::interfaces::ILogger> logger, AFB_ApiT api,
const string &eventName);
// Destructor
@@ -46,12 +46,12 @@ public:
string getName() const override;
bool isValid() override;
int publishEvent(struct json_object *payload) override;
- bool subscribe(vshl::common::interfaces::IAFBRequest &request) override;
- bool unsubscribe(vshl::common::interfaces::IAFBRequest &request) override;
+ bool subscribe(vshlcore::common::interfaces::IAFBRequest &request) override;
+ bool unsubscribe(vshlcore::common::interfaces::IAFBRequest &request) override;
/// @c IAFBEvent implementation }
private:
- AFBEventImpl(shared_ptr<vshl::common::interfaces::ILogger> logger,
+ AFBEventImpl(shared_ptr<vshlcore::common::interfaces::ILogger> logger,
AFB_ApiT api, const string &eventName);
// Make the event. This is a lazy make that happens
@@ -68,10 +68,10 @@ private:
string mEventName;
// Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
+ shared_ptr<vshlcore::common::interfaces::ILogger> mLogger;
};
} // namespace afb
-} // namespace vshl
+} // namespace vshlcore
#endif // VSHL_AFB_EVENT_H_
diff --git a/src/plugins/afb/src/AFBEventImpl.cpp b/src/plugins/afb/src/AFBEventImpl.cpp
index e3c902d..b7837bb 100644
--- a/src/plugins/afb/src/AFBEventImpl.cpp
+++ b/src/plugins/afb/src/AFBEventImpl.cpp
@@ -14,23 +14,22 @@
*/
#include "afb/include/AFBEventImpl.h"
-static string TAG = "vshl::afb::Event";
+static string TAG = "vshlcore::afb::Event";
-using Level = vshl::common::interfaces::ILogger::Level;
-using namespace vshl::common::interfaces;
-
-namespace vshl {
+using Level = vshlcore::common::interfaces::ILogger::Level;
+using namespace vshlcore::common::interfaces;
+namespace vshlcore {
namespace afb {
unique_ptr<AFBEventImpl> AFBEventImpl::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
AFB_ApiT api,
const string& eventName) {
return unique_ptr<AFBEventImpl>(new AFBEventImpl(logger, api, eventName));
}
AFBEventImpl::AFBEventImpl(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
AFB_ApiT api,
const string& eventName) :
mLogger(logger),
diff --git a/src/plugins/capabilities/CapabilitiesFactory.cpp b/src/plugins/capabilities/CapabilitiesFactory.cpp
deleted file mode 100644
index 2f92519..0000000
--- a/src/plugins/capabilities/CapabilitiesFactory.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#include "capabilities/CapabilitiesFactory.h"
-
-#include "capabilities/communication/include/PhoneControlCapability.h"
-#include "capabilities/guimetadata/include/GuiMetadataCapability.h"
-#include "capabilities/navigation/include/NavigationCapability.h"
-
-static string TAG = "vshl::core::CapabilitiesFactory";
-
-using Level = vshl::utilities::logging::Logger::Level;
-
-namespace vshl {
-namespace capabilities {
-
-// Create CapabilitiesFactory
-std::unique_ptr<CapabilitiesFactory> CapabilitiesFactory::create() {
- auto capabilitiesFactory = std::unique_ptr<CapabilitiesFactory>(new CapabilitiesFactory());
- return capabilitiesFactory;
-}
-
-std::shared_ptr<common::interfaces::ICapability> CapabilitiesFactory::getGuiMetadata() {
- if (!mGuiMetadata) {
- mGuiMetadata = vshl::capabilities::guimetadata::GuiMetadata::create();
- }
- return mGuiMetadata;
-}
-
-std::shared_ptr<common::interfaces::ICapability> CapabilitiesFactory::getPhoneControl() {
- if (!mPhoneControl) {
- mPhoneControl = vshl::capabilities::phonecontrol::PhoneControl::create();
- }
- return mPhoneControl;
-}
-
-std::shared_ptr<common::interfaces::ICapability> CapabilitiesFactory::getNavigation() {
- if (!mNavigation) {
- mNavigation = vshl::capabilities::navigation::Navigation::create();
- }
- return mNavigation;
-}
-
-} // namespace capabilities
-} // namespace vshl \ No newline at end of file
diff --git a/src/plugins/capabilities/CapabilitiesFactory.h b/src/plugins/capabilities/CapabilitiesFactory.h
deleted file mode 100644
index b73909b..0000000
--- a/src/plugins/capabilities/CapabilitiesFactory.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_CAPABILITIESFACTORY_H_
-#define VSHL_CAPABILITIES_CAPABILITIESFACTORY_H_
-
-#include <memory>
-
-#include "interfaces/capabilities/ICapability.h"
-#include "utilities/logging/Logger.h"
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-/*
- * Factory for creating different capability objects.
- */
-class CapabilitiesFactory {
-public:
- // Create CapabilitiesFactory
- static std::unique_ptr<CapabilitiesFactory> create();
-
- // GUI Metadata capability
- std::shared_ptr<common::interfaces::ICapability> getGuiMetadata();
-
- // Phone call control capability
- std::shared_ptr<common::interfaces::ICapability> getPhoneControl();
-
- // Navigation capability
- std::shared_ptr<common::interfaces::ICapability> getNavigation();
-
- // Destructor
- ~CapabilitiesFactory() = default;
-
-private:
- // Constructor
- CapabilitiesFactory() = default;
-
- // Capabilities
- shared_ptr<vshl::common::interfaces::ICapability> mGuiMetadata;
- shared_ptr<vshl::common::interfaces::ICapability> mPhoneControl;
- shared_ptr<vshl::common::interfaces::ICapability> mNavigation;
-
- // Logger
- unique_ptr<vshl::utilities::logging::Logger> mLogger;
-};
-
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_CAPABILITIESFACTORY_H_
diff --git a/src/plugins/capabilities/CapabilityMessagingService.cpp b/src/plugins/capabilities/CapabilityMessagingService.cpp
deleted file mode 100644
index 91b5f2b..0000000
--- a/src/plugins/capabilities/CapabilityMessagingService.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/CapabilityMessagingService.h"
-
-#include "capabilities/core/include/PublisherForwarder.h"
-#include "capabilities/core/include/SubscriberForwarder.h"
-
-static string TAG = "vshl::capabilities::CapabilityMessagingService";
-
-using Level = vshl::common::interfaces::ILogger::Level;
-
-namespace vshl {
-namespace capabilities {
-
-// Create a CapabilityMessagingService.
-unique_ptr<CapabilityMessagingService> CapabilityMessagingService::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) {
- if (logger == nullptr) {
- return nullptr;
- }
-
- if (afbApi == nullptr) {
- logger->log(Level::ERROR, TAG, "Failed to create CapabilityMessagingService: AFB API null");
- return nullptr;
- }
-
- auto capabilityMessageService =
- std::unique_ptr<CapabilityMessagingService>(new CapabilityMessagingService(logger, afbApi));
- return capabilityMessageService;
-}
-
-CapabilityMessagingService::~CapabilityMessagingService() {
- mMessageChannelsMap.clear();
-}
-
-CapabilityMessagingService::CapabilityMessagingService(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) :
- mAfbApi(afbApi),
- mLogger(logger) {
-}
-
-// Subscribe to capability specific messages.
-bool CapabilityMessagingService::subscribe(
- vshl::common::interfaces::IAFBRequest& request,
- shared_ptr<common::interfaces::ICapability> capability,
- const string action) {
- auto capabilityName = capability->getName();
-
- if (capabilityName.empty()) {
- mLogger->log(Level::ERROR, TAG, "Failed to subscribe to message. Invalid input.");
- return false;
- }
-
- auto messageChannel = getMessageChannel(capability);
- return messageChannel->subscribe(request, action);
-}
-
-// Publish capability messages.
-bool CapabilityMessagingService::publish(
- shared_ptr<common::interfaces::ICapability> capability,
- const string action,
- const string payload) {
- auto capabilityName = capability->getName();
-
- if (capabilityName.empty()) {
- mLogger->log(Level::ERROR, TAG, "Failed to publish message. Invalid input.");
- return false;
- }
-
- auto messageChannelIt = mMessageChannelsMap.find(capabilityName);
- if (messageChannelIt == mMessageChannelsMap.end()) {
- mLogger->log(
- Level::ERROR,
- TAG,
- "Failed to publish message. Message channel doesn't exist for capability " + capabilityName);
- return false;
- }
-
- return messageChannelIt->second->publish(action, payload);
-}
-
-shared_ptr<vshl::capabilities::core::MessageChannel> CapabilityMessagingService::getMessageChannel(
- shared_ptr<common::interfaces::ICapability> capability) {
- auto capabilityName = capability->getName();
-
- if (capabilityName.empty()) {
- mLogger->log(Level::ERROR, TAG, "Failed to create message channel. Invalid input.");
- return nullptr;
- }
-
- auto messageChannelIt = mMessageChannelsMap.find(capabilityName);
- if (messageChannelIt == mMessageChannelsMap.end()) {
- mLogger->log(Level::INFO, TAG, "Creating new message channel for capability: " + capabilityName);
- auto messageChannel = vshl::capabilities::core::MessageChannel::create(mLogger, mAfbApi, capability);
- mMessageChannelsMap.insert(make_pair(capabilityName, messageChannel));
- return messageChannel;
- }
-
- return messageChannelIt->second;
-}
-
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/CapabilityMessagingService.h b/src/plugins/capabilities/CapabilityMessagingService.h
deleted file mode 100644
index 535e806..0000000
--- a/src/plugins/capabilities/CapabilityMessagingService.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_CAPABILITYMESSAGINGSERVICE_H_
-#define VSHL_CAPABILITIES_CAPABILITYMESSAGINGSERVICE_H_
-
-#include <memory>
-#include <string>
-#include <unordered_map>
-
-#include "capabilities/core/include/MessageChannel.h"
-#include "interfaces/afb/IAFBApi.h"
-#include "interfaces/capabilities/ICapability.h"
-#include "interfaces/utilities/logging/ILogger.h"
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-/*
- * This hosts service APIs that clients can use to subscribe and
- * forward capability messages. Each capability has a name and
- * direction (upstream/downstream). Upstream messages are from
- * voiceagents to Apps and downstream messages are Apps to voiceagents.
- * This class will use a factory to create publisher and subcribers for
- * each capability and create assiociations between them.
- */
-class CapabilityMessagingService {
-public:
- // Create a CapabilityMessagingService.
- static std::unique_ptr<CapabilityMessagingService>
- create(shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi);
-
- // Subscribe to capability specific messages.
- bool subscribe(vshl::common::interfaces::IAFBRequest &request,
- shared_ptr<common::interfaces::ICapability> capability,
- const string action);
-
- // Publish capability messages.
- bool publish(shared_ptr<common::interfaces::ICapability> capability,
- const string action, const string payload);
-
- // Destructor
- ~CapabilityMessagingService();
-
-private:
- // Constructor
- CapabilityMessagingService(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi);
-
- // Binding API reference
- shared_ptr<vshl::common::interfaces::IAFBApi> mAfbApi;
-
- // Create a message channel for the capability.
- shared_ptr<vshl::capabilities::core::MessageChannel>
- getMessageChannel(shared_ptr<common::interfaces::ICapability> capability);
-
- // Map of capabilities to message channels.
- unordered_map<string, shared_ptr<vshl::capabilities::core::MessageChannel>>
- mMessageChannelsMap;
-
- // Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
-};
-
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_CAPABILITYMESSAGINGSERVICE_H_
diff --git a/src/plugins/capabilities/communication/include/PhoneControlCapability.h b/src/plugins/capabilities/communication/include/PhoneControlCapability.h
deleted file mode 100644
index 55ada8d..0000000
--- a/src/plugins/capabilities/communication/include/PhoneControlCapability.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#ifndef VSHL_CAPABILITIES_PHONECONTROL_CAPABILITY_H_
-#define VSHL_CAPABILITIES_PHONECONTROL_CAPABILITY_H_
-
-#include <memory>
-
-#include "interfaces/capabilities/ICapability.h"
-
-namespace vshl {
-namespace capabilities {
-namespace phonecontrol {
-
-/*
- * PhoneControl capability. Calls are initiated in the endpoint.
- */
-class PhoneControl : public common::interfaces::ICapability {
-public:
- // Create a PhoneControl.
- static std::shared_ptr<PhoneControl> create();
-
- ~PhoneControl() = default;
-
-protected:
- string getName() const override;
-
- list<string> getUpstreamMessages() const override;
-
- list<string> getDownstreamMessages() const override;
-
-private:
- PhoneControl() = default;
-};
-
-} // namespace phonecontrol
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_PHONECONTROL_CAPABILITY_H_
diff --git a/src/plugins/capabilities/communication/include/PhoneControlMessages.h b/src/plugins/capabilities/communication/include/PhoneControlMessages.h
deleted file mode 100644
index 4c68455..0000000
--- a/src/plugins/capabilities/communication/include/PhoneControlMessages.h
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_PHONECONTROL_MESSAGES_H_
-#define VSHL_CAPABILITIES_PHONECONTROL_MESSAGES_H_
-
-#include <list>
-#include <string>
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace phonecontrol {
-
-static string NAME = "phonecontrol";
-
-// Supported actions from VA -> Apps
-/* Dial message sent from VA to app handling the calling.
- *
- * Payload
- * {
- * "callId": "{{STRING}}",
- * "callee": {
- * "details": "{{STRING}}",
- * "defaultAddress": {
- * "protocol": "{{STRING}}",
- * "format": "{{STRING}}",
- * "value": "{{STRING}}"
- * },
- * "alternativeAddresses": [{
- * "protocol": "{{STRING}}",
- * "format": "{{STRING}}",
- * "value": {{STRING}}
- * }]
- * }
- * }
- * }
- *
- * callId (required): A unique identifier for the call
- * callee (required): The destination of the outgoing call
- * callee.details (optional): Descriptive information about the callee
- * callee.defaultAddress (required): The default address to use for calling the callee
- * callee.alternativeAddresses (optional): An array of alternate addresses for the existing callee
- * address.protocol (required): The protocol for this address of the callee (e.g. PSTN, SIP, H323, etc.)
- * address.format (optional): The format for this address of the callee (e.g. E.164, E.163, E.123, DIN5008, etc.)
- * address.value (required): The address of the callee.
- *
- */
-static string PHONECONTROL_DIAL = "dial";
-
-// Supported actions from Apps -> VA
-/*
- * App notifies the voiceagents of a change in connection state of a calling device.
- *
- * Payload
- * {
- * "state" : "{{STRING}}" // CONNECTED or DISCONNECTED
- * }
- */
-static string PHONECONTROL_CONNECTIONSTATE_CHANGED = "connection_state_changed";
-/*
- * App notifies the voiceagents that call is activated
- *
- * callId must match the one that is sent by VA with DIAL message above.
- *
- * Payload
- * {
- * "callId" : "{{STRING}}"
- * }
- */
-static string PHONECONTROL_CALL_ACTIVATED = "call_activated";
-/*
- * App notifies the voiceagents of an error in initiating or maintaining a
- * call on a calling device
- *
- * callId must match the one that is sent by VA with DIAL message above.
- * error: below status codes.
- * 4xx: Validation failure for the input from the DIAL message
- * 500: Internal error on the platform unrelated to the cellular network
- * 503: Error on the platform related to the cellular network
- *
- * Payload
- * {
- * "callId" : "{{STRING}}"
- * "error" : "{{STRING}}"
- * }
- */
-static string PHONECONTROL_CALL_FAILED = "call_failed";
-/*
- * App notifies the voiceagents that call is terminated
- *
- * callId must match the one that is sent by VA with DIAL message above.
- *
- * Payload
- * {
- * "callId" : "{{STRING}}"
- * }
- */
-static string PHONECONTROL_CALL_TERMINATED = "call_terminated";
-
-// List of actions that are delivered from VA -> Apps
-static list<string> PHONECONTROL_UPSTREAM_ACTIONS = {
- PHONECONTROL_DIAL,
-};
-
-// List of actions that are delivered from Apps -> VA
-static list<string> PHONECONTROL_DOWNSTREAM_ACTIONS = {PHONECONTROL_CONNECTIONSTATE_CHANGED,
- PHONECONTROL_CALL_ACTIVATED,
- PHONECONTROL_CALL_FAILED,
- PHONECONTROL_CALL_TERMINATED};
-
-} // namespace phonecontrol
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_PHONECONTROL_MESSAGES_H_
diff --git a/src/plugins/capabilities/communication/src/PhoneControlCapability.cpp b/src/plugins/capabilities/communication/src/PhoneControlCapability.cpp
deleted file mode 100644
index 6a74d5a..0000000
--- a/src/plugins/capabilities/communication/src/PhoneControlCapability.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/communication/include/PhoneControlCapability.h"
-#include "capabilities/communication/include/PhoneControlMessages.h"
-
-namespace vshl {
-namespace capabilities {
-namespace phonecontrol {
-
-// Create a phonecontrol.
-shared_ptr<PhoneControl> PhoneControl::create() {
- auto phonecontrol = std::shared_ptr<PhoneControl>(new PhoneControl());
- return phonecontrol;
-}
-
-string PhoneControl::getName() const {
- return NAME;
-}
-
-list<string> PhoneControl::getUpstreamMessages() const {
- return PHONECONTROL_UPSTREAM_ACTIONS;
-}
-
-list<string> PhoneControl::getDownstreamMessages() const {
- return PHONECONTROL_DOWNSTREAM_ACTIONS;
-}
-
-} // namespace phonecontrol
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/core/include/MessageChannel.h b/src/plugins/capabilities/core/include/MessageChannel.h
deleted file mode 100644
index 504e241..0000000
--- a/src/plugins/capabilities/core/include/MessageChannel.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_CORE_MESSAGECHANNEL_H_
-#define VSHL_CAPABILITIES_CORE_MESSAGECHANNEL_H_
-
-#include <memory>
-
-#include "capabilities/core/include/PublisherForwarder.h"
-#include "capabilities/core/include/SubscriberForwarder.h"
-#include "interfaces/afb/IAFBApi.h"
-#include "interfaces/capabilities/ICapability.h"
-#include "interfaces/utilities/logging/ILogger.h"
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-/*
- * MessageChannel has one end as publisher forwarder and the other end
- * as subscriber forwarder.
- */
-class MessageChannel {
-public:
- // Create a MessageChannel.
- static std::shared_ptr<MessageChannel>
- create(shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Sends the message
- bool publish(const string action, const string payload);
-
- // Subscribe
- bool subscribe(vshl::common::interfaces::IAFBRequest &request,
- const string action);
-
- // Destructor
- virtual ~MessageChannel() = default;
-
-private:
- // Constructor
- MessageChannel(shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Forwarders
- shared_ptr<PublisherForwarder> mPublisherForwarder;
- shared_ptr<SubscriberForwarder> mSubscriberForwarder;
-};
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_CORE_MESSAGECHANNEL_H_
diff --git a/src/plugins/capabilities/core/include/PublisherForwarder.h b/src/plugins/capabilities/core/include/PublisherForwarder.h
deleted file mode 100644
index 9cc89b5..0000000
--- a/src/plugins/capabilities/core/include/PublisherForwarder.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_CORE_PUBLISHERFORWARDER_H_
-#define VSHL_CAPABILITIES_CORE_PUBLISHERFORWARDER_H_
-
-#include <memory>
-
-#include "capabilities/core/include/SubscriberForwarder.h"
-
-#include "interfaces/afb/IAFBApi.h"
-#include "interfaces/capabilities/ICapability.h"
-#include "interfaces/utilities/logging/ILogger.h"
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-/*
- * This class is responsible for forwarding the messages to be published
- * to subscriber forwarder. Subscriber forwarder will deliver the messages
- * as AFB Events to all the subscribed clients.
- * There is one PublisherForwarder and one SubscriberForwarder per capability.
- */
-class PublisherForwarder {
-public:
- // Create a PublisherForwarder.
- static std::shared_ptr<PublisherForwarder> create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Connect a subscriber forwarder to this publisher forwarder
- void setSubscriberForwarder(shared_ptr<SubscriberForwarder> subscriberForwarder);
-
- // Forward message to the subscriber forwarder
- bool forwardMessage(const string action, const string payload);
-
- // Destructor
- ~PublisherForwarder();
-
-private:
- // Constructor
- PublisherForwarder(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Subscriber forwarder connected to this publisher forwarder.
- shared_ptr<SubscriberForwarder> mSubscriberForwarder;
-
- // Capability
- shared_ptr<vshl::common::interfaces::ICapability> mCapability;
-
- // Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
-};
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_CORE_PUBLISHERFORWARDER_H_
diff --git a/src/plugins/capabilities/core/include/SubscriberForwarder.h b/src/plugins/capabilities/core/include/SubscriberForwarder.h
deleted file mode 100644
index 94c04bf..0000000
--- a/src/plugins/capabilities/core/include/SubscriberForwarder.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_CORE_SUBSCRIBERFORWARDER_H_
-#define VSHL_CAPABILITIES_CORE_SUBSCRIBERFORWARDER_H_
-
-#include <memory>
-#include <string>
-#include <unordered_map>
-
-#include "interfaces/afb/IAFBApi.h"
-#include "interfaces/capabilities/ICapability.h"
-#include "interfaces/utilities/logging/ILogger.h"
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-/*
- * This class is responsible for forwarding the messages publishing
- * to the actual clients using AFB.
- */
-class SubscriberForwarder {
-public:
- // Create a SubscriberForwarder.
- static std::shared_ptr<SubscriberForwarder>
- create(shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Publish a capability message to the actual client.
- bool forwardMessage(const string action, const string payload);
-
- // Subscribe
- bool subscribe(vshl::common::interfaces::IAFBRequest &request,
- const string action);
-
- // Destructor
- ~SubscriberForwarder();
-
-private:
- // Constructor
- SubscriberForwarder(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability);
-
- // Creates both upstream and downstream events
- void createEvents();
-
- // Binding API reference
- shared_ptr<vshl::common::interfaces::IAFBApi> mAfbApi;
-
- // Capability
- shared_ptr<vshl::common::interfaces::ICapability> mCapability;
-
- // Maps of capability action events to its corresponding Event object.
- // Event name maps to Action Name
- unordered_map<string, shared_ptr<common::interfaces::IAFBApi::IAFBEvent>>
- mUpstreamEventsMap;
- unordered_map<string, shared_ptr<common::interfaces::IAFBApi::IAFBEvent>>
- mDownstreamEventsMap;
-
- // Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
-};
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_CORE_SUBSCRIBERFORWARDER_H_
diff --git a/src/plugins/capabilities/core/src/MessageChannel.cpp b/src/plugins/capabilities/core/src/MessageChannel.cpp
deleted file mode 100644
index eaa1349..0000000
--- a/src/plugins/capabilities/core/src/MessageChannel.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/core/include/MessageChannel.h"
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-
-// Create a MessageChannel.
-std::shared_ptr<MessageChannel> MessageChannel::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> api,
- shared_ptr<vshl::common::interfaces::ICapability> capability) {
- auto messageChannel = std::shared_ptr<MessageChannel>(new MessageChannel(logger, api, capability));
- return messageChannel;
-}
-
-MessageChannel::MessageChannel(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> api,
- shared_ptr<vshl::common::interfaces::ICapability> capability) {
- // Subscriber forwarder
- mSubscriberForwarder = SubscriberForwarder::create(logger, api, capability);
- // Publisher forwarder
- mPublisherForwarder = PublisherForwarder::create(logger, capability);
- mPublisherForwarder->setSubscriberForwarder(mSubscriberForwarder);
-}
-
-bool MessageChannel::publish(const string action, const string payload) {
- return mPublisherForwarder->forwardMessage(action, payload);
-}
-
-bool MessageChannel::subscribe(vshl::common::interfaces::IAFBRequest& request, const string action) {
- return mSubscriberForwarder->subscribe(request, action);
-}
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/core/src/PublisherForwarder.cpp b/src/plugins/capabilities/core/src/PublisherForwarder.cpp
deleted file mode 100644
index 81de6a0..0000000
--- a/src/plugins/capabilities/core/src/PublisherForwarder.cpp
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/core/include/PublisherForwarder.h"
-
-static string TAG = "vshl::capabilities::PublisherForwarder";
-
-using Level = vshl::common::interfaces::ILogger::Level;
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-
-// Create a PublisherForwarder.
-std::shared_ptr<PublisherForwarder> PublisherForwarder::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::ICapability> capability) {
- if (logger == nullptr) {
- return nullptr;
- }
-
- if (capability == nullptr) {
- logger->log(Level::ERROR, TAG, "Failed to create PublisherForwarder: Capability null");
- return nullptr;
- }
-
- auto publisherForwarder = std::shared_ptr<PublisherForwarder>(new PublisherForwarder(logger, capability));
- return publisherForwarder;
-}
-
-// Constructor
-PublisherForwarder::PublisherForwarder(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::ICapability> capability) {
- mCapability = capability;
- mLogger = logger;
-}
-
-// Destructor
-PublisherForwarder::~PublisherForwarder() {
-}
-
-void PublisherForwarder::setSubscriberForwarder(shared_ptr<SubscriberForwarder> subscriberForwarder) {
- mSubscriberForwarder = subscriberForwarder;
-}
-
-bool PublisherForwarder::forwardMessage(const string action, const string payload) {
- if (!mSubscriberForwarder) {
- mLogger->log(Level::ERROR, TAG, "Failed to forward message for capability: " + mCapability->getName());
- return false;
- }
-
- return mSubscriberForwarder->forwardMessage(action, payload);
-}
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/core/src/SubscriberForwarder.cpp b/src/plugins/capabilities/core/src/SubscriberForwarder.cpp
deleted file mode 100644
index ea42305..0000000
--- a/src/plugins/capabilities/core/src/SubscriberForwarder.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/core/include/SubscriberForwarder.h"
-
-static string TAG = "vshl::capabilities::SubscriberForwarder";
-
-using Level = vshl::common::interfaces::ILogger::Level;
-
-namespace vshl {
-namespace capabilities {
-namespace core {
-
-// Create a SubscriberForwarder.
-std::shared_ptr<SubscriberForwarder> SubscriberForwarder::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability) {
- if (logger == nullptr) {
- return nullptr;
- }
-
- if (afbApi == nullptr) {
- logger->log(Level::ERROR, TAG, "Failed to create SubscriberForwarder: AFB API null");
- return nullptr;
- }
-
- if (capability == nullptr) {
- logger->log(Level::ERROR, TAG, "Failed to create SubscriberForwarder: Capability null");
- return nullptr;
- }
-
- auto subscriberForwarder =
- std::shared_ptr<SubscriberForwarder>(new SubscriberForwarder(logger, afbApi, capability));
- return subscriberForwarder;
-}
-
-SubscriberForwarder::SubscriberForwarder(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
- shared_ptr<vshl::common::interfaces::ICapability> capability) :
- mAfbApi(afbApi),
- mLogger(logger),
- mCapability(capability) {
- createEvents();
-}
-
-SubscriberForwarder::~SubscriberForwarder() {
- mUpstreamEventsMap.clear();
- mDownstreamEventsMap.clear();
-}
-
-void SubscriberForwarder::createEvents() {
- if (!mCapability) {
- mLogger->log(Level::NOTICE, TAG, "Create Events failed. No capability assigned.");
- return;
- }
-
- // Upstream events
- auto upstreamEvents = mCapability->getUpstreamMessages();
- for (auto upstreamEventName : upstreamEvents) {
- auto it = mUpstreamEventsMap.find(upstreamEventName);
- if (it == mUpstreamEventsMap.end() && mAfbApi) {
- // create a new event and add it to the map.
- shared_ptr<common::interfaces::IAFBApi::IAFBEvent> event = mAfbApi->createEvent(upstreamEventName);
- if (event == nullptr) {
- mLogger->log(Level::ERROR, TAG, "Failed to create upstream event: " + upstreamEventName);
- } else {
- mUpstreamEventsMap.insert(make_pair(upstreamEventName, event));
- }
- }
- }
-
- // Downstream events
- auto downstreamEvents = mCapability->getDownstreamMessages();
- for (auto downstreamEventName : downstreamEvents) {
- auto it = mDownstreamEventsMap.find(downstreamEventName);
- if (it == mDownstreamEventsMap.end() && mAfbApi) {
- // create a new event and add it to the map.
- shared_ptr<common::interfaces::IAFBApi::IAFBEvent> event = mAfbApi->createEvent(downstreamEventName);
- if (event == nullptr) {
- mLogger->log(Level::ERROR, TAG, "Failed to create downstream event: " + downstreamEventName);
- } else {
- mDownstreamEventsMap.insert(make_pair(downstreamEventName, event));
- }
- }
- }
-}
-
-bool SubscriberForwarder::forwardMessage(const string action, const string payload) {
- auto upstreamEventIt = mUpstreamEventsMap.find(action);
- if (upstreamEventIt != mUpstreamEventsMap.end()) {
- mLogger->log(Level::NOTICE, TAG, "Publishing upstream event: " + action);
- upstreamEventIt->second->publishEvent(json_object_new_string(payload.c_str()));
- return true;
- }
-
- auto downstreamEventIt = mDownstreamEventsMap.find(action);
- if (downstreamEventIt != mDownstreamEventsMap.end()) {
- mLogger->log(Level::NOTICE, TAG, "Publishing downstream event: " + action);
- downstreamEventIt->second->publishEvent(json_object_new_string(payload.c_str()));
- return true;
- }
-
- mLogger->log(Level::NOTICE, TAG, "Failed to publish upstream event: " + action);
- return false;
-}
-
-bool SubscriberForwarder::subscribe(vshl::common::interfaces::IAFBRequest& request, const string action) {
- auto upstreamEventIt = mUpstreamEventsMap.find(action);
- if (upstreamEventIt != mUpstreamEventsMap.end()) {
- mLogger->log(Level::NOTICE, TAG, "Subscribing to upstream event: " + action);
- return upstreamEventIt->second->subscribe(request);
- }
-
- auto downstreamEventIt = mDownstreamEventsMap.find(action);
- if (downstreamEventIt != mDownstreamEventsMap.end()) {
- mLogger->log(Level::NOTICE, TAG, "Subscribing to downstream event: " + action);
- return downstreamEventIt->second->subscribe(request);
- }
-
- mLogger->log(Level::NOTICE, TAG, "Failed to subscribe to upstream event: " + action);
- return false;
-}
-
-} // namespace core
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/guimetadata/include/GuiMetadataCapability.h b/src/plugins/capabilities/guimetadata/include/GuiMetadataCapability.h
deleted file mode 100644
index 199f49a..0000000
--- a/src/plugins/capabilities/guimetadata/include/GuiMetadataCapability.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#ifndef VSHL_CAPABILITIES_GUIMETADATA_CAPABILITY_H_
-#define VSHL_CAPABILITIES_GUIMETADATA_CAPABILITY_H_
-
-#include <memory>
-
-#include "interfaces/capabilities/ICapability.h"
-
-namespace vshl {
-namespace capabilities {
-namespace guimetadata {
-
-/*
- * GuiMetadata capability
- */
-class GuiMetadata : public common::interfaces::ICapability {
-public:
- // Create a GuiMetadata.
- static std::shared_ptr<GuiMetadata> create();
-
- ~GuiMetadata() = default;
-
-protected:
- string getName() const override;
-
- list<string> getUpstreamMessages() const override;
-
- list<string> getDownstreamMessages() const override;
-
-private:
- GuiMetadata() = default;
-};
-
-} // namespace guimetadata
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_GUIMETADATA_CAPABILITY_H_
diff --git a/src/plugins/capabilities/guimetadata/include/GuiMetadataMessages.h b/src/plugins/capabilities/guimetadata/include/GuiMetadataMessages.h
deleted file mode 100644
index 783b401..0000000
--- a/src/plugins/capabilities/guimetadata/include/GuiMetadataMessages.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_GUIMETADATA_ACTIONS_H_
-#define VSHL_CAPABILITIES_GUIMETADATA_ACTIONS_H_
-
-#include <list>
-#include <string>
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace guimetadata {
-
-static string NAME = "guimetadata";
-
-// Supported actions from VA -> Apps
-static string GUIMETADATA_RENDER_TEMPLATE = "render_template";
-static string GUIMETADATA_CLEAR_TEMPLATE = "clear_template";
-static string GUIMETADATA_RENDER_PLAYER_INFO = "render_player_info";
-static string GUIMETADATA_CLEAR_PLAYER_INFO = "clear_player_info";
-
-// Supported actions from Apps -> VA
-
-// List of actions that are delivered from VA -> Apps
-static list<string> GUIMETADATA_UPSTREAM_ACTIONS = {GUIMETADATA_RENDER_TEMPLATE,
- GUIMETADATA_CLEAR_TEMPLATE,
- GUIMETADATA_RENDER_PLAYER_INFO,
- GUIMETADATA_CLEAR_PLAYER_INFO};
-
-// List of actions that are delivered from Apps -> VA
-static list<string> GUIMETADATA_DOWNSTREAM_ACTIONS = {};
-
-} // namespace guimetadata
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_GUIMETADATA_ACTIONS_H_
diff --git a/src/plugins/capabilities/guimetadata/src/GuiMetadataCapability.cpp b/src/plugins/capabilities/guimetadata/src/GuiMetadataCapability.cpp
deleted file mode 100644
index 106fe99..0000000
--- a/src/plugins/capabilities/guimetadata/src/GuiMetadataCapability.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/guimetadata/include/GuiMetadataCapability.h"
-#include "capabilities/guimetadata/include/GuiMetadataMessages.h"
-
-namespace vshl {
-namespace capabilities {
-namespace guimetadata {
-
-// Create a GuiMetadata.
-shared_ptr<GuiMetadata> GuiMetadata::create() {
- auto guiMetadata = std::shared_ptr<GuiMetadata>(new GuiMetadata());
- return guiMetadata;
-}
-
-string GuiMetadata::getName() const {
- return NAME;
-}
-
-list<string> GuiMetadata::getUpstreamMessages() const {
- return GUIMETADATA_UPSTREAM_ACTIONS;
-}
-
-list<string> GuiMetadata::getDownstreamMessages() const {
- return GUIMETADATA_DOWNSTREAM_ACTIONS;
-}
-
-} // namespace guimetadata
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/navigation/include/NavigationCapability.h b/src/plugins/capabilities/navigation/include/NavigationCapability.h
deleted file mode 100644
index 66109d5..0000000
--- a/src/plugins/capabilities/navigation/include/NavigationCapability.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#ifndef VSHL_CAPABILITIES_NAVIGATION_CAPABILITY_H_
-#define VSHL_CAPABILITIES_NAVIGATION_CAPABILITY_H_
-
-#include <memory>
-
-#include "interfaces/capabilities/ICapability.h"
-
-namespace vshl {
-namespace capabilities {
-namespace navigation {
-
-/*
- * Navigation capability
- */
-class Navigation : public common::interfaces::ICapability {
-public:
- // Create a Navigation.
- static std::shared_ptr<Navigation> create();
-
- ~Navigation() = default;
-
-protected:
- string getName() const override;
-
- list<string> getUpstreamMessages() const override;
-
- list<string> getDownstreamMessages() const override;
-
-private:
- Navigation() = default;
-};
-
-} // namespace navigation
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_NAVIGATION_CAPABILITY_H_
diff --git a/src/plugins/capabilities/navigation/include/NavigationMessages.h b/src/plugins/capabilities/navigation/include/NavigationMessages.h
deleted file mode 100644
index aed9b9e..0000000
--- a/src/plugins/capabilities/navigation/include/NavigationMessages.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_CAPABILITIES_NAVIGATION_ACTIONS_H_
-#define VSHL_CAPABILITIES_NAVIGATION_ACTIONS_H_
-
-#include <list>
-#include <string>
-
-using namespace std;
-
-namespace vshl {
-namespace capabilities {
-namespace navigation {
-
-static string NAME = "navigation";
-
-// Supported actions from VA -> Apps
-static string NAVIGATION_SET_DESTINATION = "set_destination";
-static string NAVIGATION_CANCEL = "cancel_navigation";
-
-// Supported actions from Apps -> VA
-
-// List of actions that are delivered from VA -> Apps
-static list<string> NAVIGATION_UPSTREAM_ACTIONS = {
- NAVIGATION_SET_DESTINATION,
- NAVIGATION_CANCEL,
-};
-
-// List of actions that are delivered from Apps -> VA
-static list<string> NAVIGATION_DOWNSTREAM_ACTIONS = {};
-
-} // namespace navigation
-} // namespace capabilities
-} // namespace vshl
-
-#endif // VSHL_CAPABILITIES_NAVIGATION_ACTIONS_H_
diff --git a/src/plugins/capabilities/navigation/src/NavigationCapability.cpp b/src/plugins/capabilities/navigation/src/NavigationCapability.cpp
deleted file mode 100644
index d4a5119..0000000
--- a/src/plugins/capabilities/navigation/src/NavigationCapability.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include "capabilities/navigation/include/NavigationCapability.h"
-#include "capabilities/navigation/include/NavigationMessages.h"
-
-namespace vshl {
-namespace capabilities {
-namespace navigation {
-
-// Create a Navigation.
-shared_ptr<Navigation> Navigation::create() {
- auto navigation = std::shared_ptr<Navigation>(new Navigation());
- return navigation;
-}
-
-string Navigation::getName() const {
- return NAME;
-}
-
-list<string> Navigation::getUpstreamMessages() const {
- return NAVIGATION_UPSTREAM_ACTIONS;
-}
-
-list<string> Navigation::getDownstreamMessages() const {
- return NAVIGATION_DOWNSTREAM_ACTIONS;
-}
-
-} // namespace navigation
-} // namespace capabilities
-} // namespace vshl
diff --git a/src/plugins/capabilities/test/CapabilityMessagingServiceTest.cpp b/src/plugins/capabilities/test/CapabilityMessagingServiceTest.cpp
deleted file mode 100644
index 741a8aa..0000000
--- a/src/plugins/capabilities/test/CapabilityMessagingServiceTest.cpp
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include <gtest/gtest.h>
-
-#include "capabilities/CapabilityMessagingService.h"
-
-#include "test/common/ConsoleLogger.h"
-#include "test/mocks/AFBApiMock.h"
-#include "test/mocks/AFBEventMock.h"
-#include "test/mocks/AFBRequestMock.h"
-#include "test/mocks/CapabilityMock.h"
-
-using namespace vshl::common::interfaces;
-using namespace vshl::capabilities;
-using namespace vshl::test::common;
-
-namespace vshl {
-namespace test {
-
-class CapabilityMessagingServiceTest : public ::testing::Test {
-protected:
- void SetUp() override {
- mConsoleLogger = std::make_shared<ConsoleLogger>();
- mAfbApi = std::make_shared<::testing::NiceMock<AFBApiMock>>();
- }
-
- std::shared_ptr<::testing::NiceMock<AFBApiMock>> mAfbApi;
- std::shared_ptr<ConsoleLogger> mConsoleLogger;
-};
-
-TEST_F(CapabilityMessagingServiceTest, failsInitializationOnInvalidParams) {
- auto service = CapabilityMessagingService::create(mConsoleLogger, nullptr);
- ASSERT_EQ(service, nullptr);
-
- service = CapabilityMessagingService::create(nullptr, mAfbApi);
- ASSERT_EQ(service, nullptr);
-}
-
-TEST_F(CapabilityMessagingServiceTest, initializesSuccessfully) {
- auto service = CapabilityMessagingService::create(mConsoleLogger, mAfbApi);
- ASSERT_NE(service, nullptr);
-}
-
-TEST_F(CapabilityMessagingServiceTest, canSubscribeAndPublishCapabilityEvents) {
- auto service = CapabilityMessagingService::create(mConsoleLogger, mAfbApi);
-
- auto capability = std::make_shared<::testing::NiceMock<CapabilityMock>>();
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
- std::string capabilityName = "weather";
-
- ON_CALL(*capability, getName()).WillByDefault(::testing::Return(capabilityName));
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- // We don't care if and how many times subscribe method is called on event.
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::NiceMock<AFBEventMock>());
- ON_CALL(*mockEvent, subscribe(::testing::_)).WillByDefault(::testing::Return(true));
- ON_CALL(*mockEvent, publishEvent(::testing::_)).WillByDefault(::testing::Return(true));
- auto eventCreator = [mockEvent](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- mockEvent->setName(eventName);
- return mockEvent;
- };
-
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(eventCreator));
-
- auto request = std::make_shared<::testing::StrictMock<AFBRequestMock>>();
- std::string payload = "The answer to life the universe and everything = 42";
-
- bool result = service->publish(capability, *upstreamEvents.begin(), payload);
- ASSERT_FALSE(result); // Without subscribing to the event. Publish should fail.
-
- result = service->subscribe(*request, capability, *upstreamEvents.begin());
- ASSERT_TRUE(result);
-
- result = service->subscribe(*request, capability, *downstreamEvents.begin());
- ASSERT_TRUE(result);
-
- result = service->publish(capability, *downstreamEvents.begin(), payload);
- ASSERT_TRUE(result);
-}
-
-} // namespace test
-} // namespace vshl \ No newline at end of file
diff --git a/src/plugins/capabilities/test/PublisherForwarderTest.cpp b/src/plugins/capabilities/test/PublisherForwarderTest.cpp
deleted file mode 100644
index d0ba319..0000000
--- a/src/plugins/capabilities/test/PublisherForwarderTest.cpp
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include <gtest/gtest.h>
-
-#include "capabilities/core/include/PublisherForwarder.h"
-#include "capabilities/core/include/SubscriberForwarder.h"
-
-#include "test/common/ConsoleLogger.h"
-#include "test/mocks/AFBApiMock.h"
-#include "test/mocks/AFBEventMock.h"
-#include "test/mocks/CapabilityMock.h"
-
-using namespace vshl::common::interfaces;
-using namespace vshl::capabilities::core;
-using namespace vshl::test::common;
-
-namespace vshl {
-namespace test {
-
-class PublisherForwarderTest : public ::testing::Test {
-protected:
- void SetUp() override {
- mConsoleLogger = std::make_shared<ConsoleLogger>();
- mAfbApi = std::make_shared<::testing::StrictMock<AFBApiMock>>();
-
- mEventCreatorFn = [](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- mockEvent->setName(eventName);
- return mockEvent;
- };
- }
-
- std::shared_ptr<SubscriberForwarder> createSubscriberForwarder(
- std::shared_ptr<::testing::StrictMock<CapabilityMock>> capability) {
- EXPECT_CALL(*capability, getUpstreamMessages()).Times(1);
- EXPECT_CALL(*capability, getDownstreamMessages()).Times(1);
-
- return SubscriberForwarder::create(mConsoleLogger, mAfbApi, capability);
- }
-
- std::shared_ptr<PublisherForwarder> createPublisherForwarder(
- std::shared_ptr<::testing::StrictMock<CapabilityMock>> capability) {
- return PublisherForwarder::create(mConsoleLogger, capability);
- }
-
- std::shared_ptr<::testing::StrictMock<AFBApiMock>> mAfbApi;
- std::shared_ptr<ConsoleLogger> mConsoleLogger;
- std::function<std::shared_ptr<IAFBApi::IAFBEvent>(const std::string&)> mEventCreatorFn;
- std::shared_ptr<::testing::StrictMock<AFBEventMock>> mAfbEventMock;
-};
-
-TEST_F(PublisherForwarderTest, failsInitializationOnInvalidParams) {
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
-
- auto forwarder = PublisherForwarder::create(mConsoleLogger, nullptr);
- ASSERT_EQ(forwarder, nullptr);
-
- forwarder = PublisherForwarder::create(nullptr, capability);
- ASSERT_EQ(forwarder, nullptr);
-}
-
-TEST_F(PublisherForwarderTest, initializesCorrectly) {
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- auto forwarder = createPublisherForwarder(capability);
-
- ASSERT_NE(forwarder, nullptr);
-}
-
-TEST_F(PublisherForwarderTest, canForwardMessages) {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- ON_CALL(*mockEvent, publishEvent(::testing::_)).WillByDefault(::testing::Return(true));
- EXPECT_CALL(*mockEvent, publishEvent(::testing::_)).Times(4);
- auto eventCreator = [mockEvent](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- return mockEvent;
- };
-
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(eventCreator));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto publisherForwarder = createPublisherForwarder(capability);
- ASSERT_NE(publisherForwarder, nullptr);
-
- auto subscriberForwarder = createSubscriberForwarder(capability);
- ASSERT_NE(subscriberForwarder, nullptr);
-
- std::string payload = "The answer to life the universe and everything = 42";
- publisherForwarder->setSubscriberForwarder(subscriberForwarder);
-
- auto itCapability = downstreamEvents.begin();
- ASSERT_TRUE(publisherForwarder->forwardMessage(*itCapability++, payload));
- ASSERT_TRUE(publisherForwarder->forwardMessage(*itCapability++, payload));
- itCapability = upstreamEvents.begin();
- ASSERT_TRUE(publisherForwarder->forwardMessage(*itCapability++, payload));
- ASSERT_TRUE(publisherForwarder->forwardMessage(*itCapability++, payload));
-}
-
-} // namespace test
-} // namespace vshl \ No newline at end of file
diff --git a/src/plugins/capabilities/test/SubscriberForwarderTest.cpp b/src/plugins/capabilities/test/SubscriberForwarderTest.cpp
deleted file mode 100644
index ff438df..0000000
--- a/src/plugins/capabilities/test/SubscriberForwarderTest.cpp
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#include <gtest/gtest.h>
-
-#include "capabilities/core/include/SubscriberForwarder.h"
-
-#include "test/common/ConsoleLogger.h"
-#include "test/mocks/AFBApiMock.h"
-#include "test/mocks/AFBEventMock.h"
-#include "test/mocks/AFBRequestMock.h"
-#include "test/mocks/CapabilityMock.h"
-
-using namespace vshl::common::interfaces;
-using namespace vshl::capabilities::core;
-using namespace vshl::test::common;
-
-namespace vshl {
-namespace test {
-
-class SubscriberForwarderTest : public ::testing::Test {
-protected:
- void SetUp() override {
- mConsoleLogger = std::make_shared<ConsoleLogger>();
- mAfbApi = std::make_shared<::testing::StrictMock<AFBApiMock>>();
-
- mEventCreatorFn = [](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- mockEvent->setName(eventName);
- return mockEvent;
- };
- }
-
- std::shared_ptr<SubscriberForwarder> createSubscriberForwarder(
- std::shared_ptr<::testing::StrictMock<CapabilityMock>> capability) {
- EXPECT_CALL(*capability, getUpstreamMessages()).Times(1);
- EXPECT_CALL(*capability, getDownstreamMessages()).Times(1);
-
- return SubscriberForwarder::create(mConsoleLogger, mAfbApi, capability);
- }
-
- std::shared_ptr<::testing::StrictMock<AFBApiMock>> mAfbApi;
- std::shared_ptr<ConsoleLogger> mConsoleLogger;
- std::function<std::shared_ptr<IAFBApi::IAFBEvent>(const std::string&)> mEventCreatorFn;
- std::shared_ptr<::testing::StrictMock<AFBEventMock>> mAfbEventMock;
-};
-
-TEST_F(SubscriberForwarderTest, failsInitializationOnInvalidParams) {
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
-
- auto forwarder = SubscriberForwarder::create(mConsoleLogger, mAfbApi, nullptr);
- ASSERT_EQ(forwarder, nullptr);
-
- forwarder = SubscriberForwarder::create(mConsoleLogger, nullptr, capability);
- ASSERT_EQ(forwarder, nullptr);
-
- forwarder = SubscriberForwarder::create(nullptr, mAfbApi, capability);
- ASSERT_EQ(forwarder, nullptr);
-}
-
-TEST_F(SubscriberForwarderTest, initializesCorrectly) {
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- auto forwarder = createSubscriberForwarder(capability);
-
- ASSERT_NE(forwarder, nullptr);
-}
-
-TEST_F(SubscriberForwarderTest, createsEventsOnInitialization) {
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(mEventCreatorFn));
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto itCapability = upstreamEvents.begin();
- EXPECT_CALL(*mAfbApi, createEvent(*itCapability)).Times(1);
- itCapability++;
- EXPECT_CALL(*mAfbApi, createEvent(*itCapability)).Times(1);
-
- itCapability = downstreamEvents.begin();
- EXPECT_CALL(*mAfbApi, createEvent(*itCapability)).Times(1);
- itCapability++;
- EXPECT_CALL(*mAfbApi, createEvent(*itCapability)).Times(1);
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-}
-
-TEST_F(SubscriberForwarderTest, canNotSubscribeToNonExistentEvents) {
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(mEventCreatorFn));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto nonExistentEvents = std::list<std::string>({"non", "existent", "events"});
- auto itCapability = nonExistentEvents.begin();
- auto request = std::make_shared<::testing::StrictMock<AFBRequestMock>>();
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
-}
-
-TEST_F(SubscriberForwarderTest, canNotSubscribeOnEventCreationFailure) {
- // Fail the event creation and return null event.
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Return(nullptr));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto itCapability = downstreamEvents.begin();
- auto request = std::make_shared<::testing::StrictMock<AFBRequestMock>>();
- std::string payload = "The answer to life the universe and everything = 42";
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
- itCapability = upstreamEvents.begin();
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_FALSE(forwarder->subscribe(*request, *itCapability++));
-}
-
-TEST_F(SubscriberForwarderTest, canSubscribeToEvents) {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- ON_CALL(*mockEvent, subscribe(::testing::_)).WillByDefault(::testing::Return(true));
- EXPECT_CALL(*mockEvent, subscribe(::testing::_)).Times(4);
- auto eventCreator = [mockEvent](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- return mockEvent;
- };
-
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(eventCreator));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto itCapability = downstreamEvents.begin();
- auto request = std::make_shared<::testing::StrictMock<AFBRequestMock>>();
- ASSERT_TRUE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_TRUE(forwarder->subscribe(*request, *itCapability));
- itCapability = upstreamEvents.begin();
- ASSERT_TRUE(forwarder->subscribe(*request, *itCapability++));
- ASSERT_TRUE(forwarder->subscribe(*request, *itCapability));
-}
-
-TEST_F(SubscriberForwarderTest, canNotPublishNonExistentEvents) {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- EXPECT_CALL(*mockEvent, publishEvent(::testing::_)).Times(0);
- auto eventCreator = [mockEvent](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- return mockEvent;
- };
-
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(eventCreator));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto nonExistentEvents = std::list<std::string>({"non", "existent", "events"});
- auto itCapability = nonExistentEvents.begin();
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, "My-Payload"));
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, "My-Payload"));
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, "My-Payload"));
-}
-
-TEST_F(SubscriberForwarderTest, canNotPublishOnEventCreationFailure) {
- // Fail the event creation and return null event.
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Return(nullptr));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto itCapability = downstreamEvents.begin();
- std::string payload = "The answer to life the universe and everything = 42";
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, payload));
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, payload));
- itCapability = upstreamEvents.begin();
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, payload));
- ASSERT_FALSE(forwarder->forwardMessage(*itCapability++, payload));
-}
-
-TEST_F(SubscriberForwarderTest, canPublishEvents) {
- std::shared_ptr<AFBEventMock> mockEvent(new ::testing::StrictMock<AFBEventMock>());
- ON_CALL(*mockEvent, publishEvent(::testing::_)).WillByDefault(::testing::Return(true));
- EXPECT_CALL(*mockEvent, publishEvent(::testing::_)).Times(4);
- auto eventCreator = [mockEvent](const std::string& eventName) -> std::shared_ptr<IAFBApi::IAFBEvent> {
- return mockEvent;
- };
-
- ON_CALL(*mAfbApi, createEvent(::testing::_)).WillByDefault(::testing::Invoke(eventCreator));
- EXPECT_CALL(*mAfbApi, createEvent(::testing::_)).Times(4);
-
- std::list<std::string> upstreamEvents({"up-ev1", "up-ev2"});
- std::list<std::string> downstreamEvents({"down-ev1", "down-ev2"});
-
- auto capability = std::make_shared<::testing::StrictMock<CapabilityMock>>();
- ON_CALL(*capability, getUpstreamMessages()).WillByDefault(::testing::Return(upstreamEvents));
- ON_CALL(*capability, getDownstreamMessages()).WillByDefault(::testing::Return(downstreamEvents));
-
- auto forwarder = createSubscriberForwarder(capability);
- ASSERT_NE(forwarder, nullptr);
-
- auto itCapability = downstreamEvents.begin();
- std::string payload = "The answer to life the universe and everything = 42";
- ASSERT_TRUE(forwarder->forwardMessage(*itCapability++, payload));
- ASSERT_TRUE(forwarder->forwardMessage(*itCapability++, payload));
- itCapability = upstreamEvents.begin();
- ASSERT_TRUE(forwarder->forwardMessage(*itCapability++, payload));
- ASSERT_TRUE(forwarder->forwardMessage(*itCapability++, payload));
-}
-
-} // namespace test
-} // namespace vshl \ No newline at end of file
diff --git a/src/plugins/core/VRRequestProcessor.h b/src/plugins/core/VRRequestProcessor.h
index c349a19..97e277a 100644
--- a/src/plugins/core/VRRequestProcessor.h
+++ b/src/plugins/core/VRRequestProcessor.h
@@ -25,8 +25,7 @@
#include "interfaces/voiceagents/IVoiceAgentsChangeObserver.h"
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace core {
/*
* This class is the entry point for all the voice recognition request
@@ -36,8 +35,8 @@ class VRRequestProcessor {
public:
// Create a VRRequestProcessor.
static unique_ptr<VRRequestProcessor> create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::core::VRRequestProcessorDelegate> delegate);
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::core::VRRequestProcessorDelegate> delegate);
// Triggers a voiceagent to start listening to user speech input.
// Returns the request ID. If start fails, then empty request ID
@@ -48,7 +47,7 @@ public:
void cancel();
// Returns the voiceagents observer that belongs to the core module.
- shared_ptr<vshl::common::interfaces::IVoiceAgentsChangeObserver> getVoiceAgentsChangeObserver() const;
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgentsChangeObserver> getVoiceAgentsChangeObserver() const;
// Destructor
~VRRequestProcessor();
@@ -56,17 +55,17 @@ public:
private:
// Constructor
VRRequestProcessor(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::core::VRRequestProcessorDelegate> delegate);
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::core::VRRequestProcessorDelegate> delegate);
// Voiceagents observer
- shared_ptr<vshl::common::interfaces::IVoiceAgentsChangeObserver> mVoiceAgentsChangeObserver;
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgentsChangeObserver> mVoiceAgentsChangeObserver;
// Request Processor Delegate
- shared_ptr<vshl::core::VRRequestProcessorDelegate> mDelegate;
+ shared_ptr<vshlcore::core::VRRequestProcessorDelegate> mDelegate;
// Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
+ shared_ptr<vshlcore::common::interfaces::ILogger> mLogger;
};
} // namespace core
diff --git a/src/plugins/core/VRRequestProcessorImpl.cpp b/src/plugins/core/VRRequestProcessorImpl.cpp
index 7441a7d..c07f745 100644
--- a/src/plugins/core/VRRequestProcessorImpl.cpp
+++ b/src/plugins/core/VRRequestProcessorImpl.cpp
@@ -16,23 +16,22 @@
#include "core/include/VRAgentsObserver.h"
-static string TAG = "vshl::core::VRRequestProcessor";
+static string TAG = "vshlcore::core::VRRequestProcessor";
-using Level = vshl::utilities::logging::Logger::Level;
-
-namespace vshl {
+using Level = vshlcore::utilities::logging::Logger::Level;
+namespace vshlcore {
namespace core {
// Create a VRRequestProcessor.
unique_ptr<VRRequestProcessor> VRRequestProcessor::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::core::VRRequestProcessorDelegate> delegate) {
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::core::VRRequestProcessorDelegate> delegate) {
auto processor = std::unique_ptr<VRRequestProcessor>(new VRRequestProcessor(logger, delegate));
return processor;
}
VRRequestProcessor::VRRequestProcessor(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::core::VRRequestProcessorDelegate> delegate) :
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::core::VRRequestProcessorDelegate> delegate) :
mLogger(logger),
mDelegate(delegate) {
mVoiceAgentsChangeObserver = VRAgentsObserver::create(mDelegate);
@@ -46,7 +45,7 @@ string VRRequestProcessor::startListening() {
// Currently start is simply going to send the request to
// the default voice agent as the wake word detection is not
// enabled.
- shared_ptr<vshl::common::interfaces::IVoiceAgent> defaultVA = mDelegate->getDefaultVoiceAgent();
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> defaultVA = mDelegate->getDefaultVoiceAgent();
if (!defaultVA) {
mLogger->log(Level::ERROR, TAG, "Failed to start. No default voiceagent found.");
return "";
@@ -63,7 +62,7 @@ void VRRequestProcessor::cancel() {
mDelegate->cancelAllRequests();
}
-shared_ptr<vshl::common::interfaces::IVoiceAgentsChangeObserver> VRRequestProcessor::getVoiceAgentsChangeObserver()
+shared_ptr<vshlcore::common::interfaces::IVoiceAgentsChangeObserver> VRRequestProcessor::getVoiceAgentsChangeObserver()
const {
return mVoiceAgentsChangeObserver;
}
diff --git a/src/plugins/core/include/VRAgentsObserver.h b/src/plugins/core/include/VRAgentsObserver.h
index d4c0c7b..ce1bd43 100644
--- a/src/plugins/core/include/VRAgentsObserver.h
+++ b/src/plugins/core/include/VRAgentsObserver.h
@@ -22,15 +22,14 @@
#include "utilities/logging/Logger.h"
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace core {
/*
* This class will observe the changes to the voiceagents data and transfers
* the actual handling responsibility to its delegate.
*/
class VRAgentsObserver
- : public vshl::common::interfaces::IVoiceAgentsChangeObserver {
+ : public vshlcore::common::interfaces::IVoiceAgentsChangeObserver {
public:
// Create a VRAgentsObserver.
static shared_ptr<VRAgentsObserver>
@@ -40,18 +39,18 @@ public:
protected:
void OnDefaultVoiceAgentChanged(
- shared_ptr<vshl::common::interfaces::IVoiceAgent> defaultVoiceAgent)
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> defaultVoiceAgent)
override;
void OnVoiceAgentAdded(
- shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) override;
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) override;
void OnVoiceAgentRemoved(
- shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) override;
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) override;
void OnVoiceAgentActiveWakeWordChanged(
- shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) override;
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) override;
void OnVoiceAgentActivated(
- shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) override;
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) override;
void OnVoiceAgentDeactivated(
- shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) override;
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) override;
private:
// Constructor
diff --git a/src/plugins/core/include/VRRequest.h b/src/plugins/core/include/VRRequest.h
index 522ec78..8b9e842 100644
--- a/src/plugins/core/include/VRRequest.h
+++ b/src/plugins/core/include/VRRequest.h
@@ -22,8 +22,7 @@
#include "interfaces/voiceagents/IVoiceAgent.h"
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace core {
/*
* This class implements the notion of a Voice Recognition Request.
@@ -37,10 +36,10 @@ public:
// Create a VRRequest.
static unique_ptr<VRRequest> create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi,
string requestId,
- shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent);
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent);
// Destructor
~VRRequest();
@@ -56,22 +55,22 @@ public:
private:
// Constructor
VRRequest(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi,
const string requestId,
- shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent);
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent);
// Binding API reference.
- shared_ptr<vshl::common::interfaces::IAFBApi> mApi;
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> mApi;
// Voice agent associated with this request
- shared_ptr<vshl::common::interfaces::IVoiceAgent> mVoiceAgent;
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> mVoiceAgent;
// Request ID
string mRequestId;
// Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
+ shared_ptr<vshlcore::common::interfaces::ILogger> mLogger;
};
} // namespace core
diff --git a/src/plugins/core/include/VRRequestProcessorDelegate.h b/src/plugins/core/include/VRRequestProcessorDelegate.h
index 94b7304..2c36d38 100644
--- a/src/plugins/core/include/VRRequestProcessorDelegate.h
+++ b/src/plugins/core/include/VRRequestProcessorDelegate.h
@@ -25,8 +25,7 @@
#include "utilities/uuid/UUIDGeneration.h"
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace core {
/*
* This is a delegate for VRRequestProcessor actions.
@@ -39,22 +38,22 @@ class VRRequestProcessorDelegate {
public:
// create method
static shared_ptr<VRRequestProcessorDelegate> create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi);
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi);
// Destructor
~VRRequestProcessorDelegate();
// Set default voiceagent
- void setDefaultVoiceAgent(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent);
+ void setDefaultVoiceAgent(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent);
// Get the default voiceagent
- shared_ptr<vshl::common::interfaces::IVoiceAgent> getDefaultVoiceAgent() const;
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> getDefaultVoiceAgent() const;
// Add new request to the list and start processing it.
// New request is created and startListening on the
// voiceagent is called.
- string startRequestForVoiceAgent(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent);
+ string startRequestForVoiceAgent(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent);
// Cancel all requests
void cancelAllRequests();
@@ -66,20 +65,20 @@ public:
private:
// Constructor
VRRequestProcessorDelegate(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi);
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi);
// Binding API reference
- shared_ptr<vshl::common::interfaces::IAFBApi> mApi;
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> mApi;
// Default voiceagent
- shared_ptr<vshl::common::interfaces::IVoiceAgent> mDefaultVoiceAgent;
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> mDefaultVoiceAgent;
// A map of voiceagent IDs and their respective VR Request objects.
unordered_map<string, shared_ptr<VRRequest>> mVRRequests;
// Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
+ shared_ptr<vshlcore::common::interfaces::ILogger> mLogger;
};
} // namespace core
diff --git a/src/plugins/core/src/VRAgentsObserverImpl.cpp b/src/plugins/core/src/VRAgentsObserverImpl.cpp
index 7ee4a7e..b44a9a0 100644
--- a/src/plugins/core/src/VRAgentsObserverImpl.cpp
+++ b/src/plugins/core/src/VRAgentsObserverImpl.cpp
@@ -13,8 +13,7 @@
* permissions and limitations under the License.
*/
#include "core/include/VRAgentsObserver.h"
-
-namespace vshl {
+namespace vshlcore {
namespace core {
shared_ptr<VRAgentsObserver> VRAgentsObserver::create(weak_ptr<VRRequestProcessorDelegate> delegate) {
@@ -29,26 +28,26 @@ VRAgentsObserver::VRAgentsObserver(weak_ptr<VRRequestProcessorDelegate> delegate
VRAgentsObserver::~VRAgentsObserver() {
}
-void VRAgentsObserver::OnDefaultVoiceAgentChanged(shared_ptr<vshl::common::interfaces::IVoiceAgent> defaultVoiceAgent) {
+void VRAgentsObserver::OnDefaultVoiceAgentChanged(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> defaultVoiceAgent) {
if (auto delegate = mWeakDelegate.lock()) {
delegate->setDefaultVoiceAgent(defaultVoiceAgent);
}
}
-void VRAgentsObserver::OnVoiceAgentAdded(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) {
+void VRAgentsObserver::OnVoiceAgentAdded(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) {
}
-void VRAgentsObserver::OnVoiceAgentRemoved(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) {
+void VRAgentsObserver::OnVoiceAgentRemoved(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) {
}
-void VRAgentsObserver::OnVoiceAgentActiveWakeWordChanged(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) {
+void VRAgentsObserver::OnVoiceAgentActiveWakeWordChanged(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) {
// Not Implemented
}
-void VRAgentsObserver::OnVoiceAgentActivated(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) {
+void VRAgentsObserver::OnVoiceAgentActivated(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) {
}
-void VRAgentsObserver::OnVoiceAgentDeactivated(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) {
+void VRAgentsObserver::OnVoiceAgentDeactivated(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) {
}
} // namespace core
} // namespace vshl
diff --git a/src/plugins/core/src/VRRequestImpl.cpp b/src/plugins/core/src/VRRequestImpl.cpp
index 00adf96..63302d8 100644
--- a/src/plugins/core/src/VRRequestImpl.cpp
+++ b/src/plugins/core/src/VRRequestImpl.cpp
@@ -24,21 +24,20 @@
break; \
}
-static string TAG = "vshl::core::VRRequest";
+static string TAG = "vshlcore::core::VRRequest";
-using Level = vshl::common::interfaces::ILogger::Level;
-
-namespace vshl {
+using Level = vshlcore::common::interfaces::ILogger::Level;
+namespace vshlcore {
namespace core {
string VRRequest::VA_VERB_STARTLISTENING = "startListening";
string VRRequest::VA_VERB_CANCEL = "cancel";
unique_ptr<VRRequest> VRRequest::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi,
const string requestId,
- shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) {
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) {
if (logger == nullptr) {
return nullptr;
}
@@ -53,10 +52,10 @@ unique_ptr<VRRequest> VRRequest::create(
}
VRRequest::VRRequest(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi,
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi,
string requestId,
- shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) :
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) :
mApi(afbApi),
mRequestId(requestId),
mVoiceAgent(voiceAgent),
diff --git a/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp b/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp
index e20b22e..78ef10a 100644
--- a/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp
+++ b/src/plugins/core/src/VRRequestProcessorDelegateImpl.cpp
@@ -14,22 +14,21 @@
*/
#include "core/include/VRRequestProcessorDelegate.h"
-static string TAG = "vshl::core::VRRequestProcessorDelegate";
+static string TAG = "vshlcore::core::VRRequestProcessorDelegate";
-using Level = vshl::common::interfaces::ILogger::Level;
-
-namespace vshl {
+using Level = vshlcore::common::interfaces::ILogger::Level;
+namespace vshlcore {
namespace core {
shared_ptr<VRRequestProcessorDelegate> VRRequestProcessorDelegate::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) {
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi) {
auto delegate = std::shared_ptr<VRRequestProcessorDelegate>(new VRRequestProcessorDelegate(logger, afbApi));
return delegate;
}
VRRequestProcessorDelegate::VRRequestProcessorDelegate(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) :
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi) :
mApi(afbApi),
mLogger(logger) {
}
@@ -39,14 +38,14 @@ VRRequestProcessorDelegate::~VRRequestProcessorDelegate() {
}
string VRRequestProcessorDelegate::startRequestForVoiceAgent(
- shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) {
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) {
if (!mApi) {
mLogger->log(Level::ERROR, TAG, "Failed to startRequestForVoiceAgent: " + voiceAgent->getId() + ", No API.");
return "";
}
// Generate a new request ID.
- string newReqId = vshl::utilities::uuid::generateUUID();
+ string newReqId = vshlcore::utilities::uuid::generateUUID();
// Create a new request and start listening.
shared_ptr<VRRequest> newRequest = VRRequest::create(mLogger, mApi, newReqId, voiceAgent);
@@ -81,11 +80,11 @@ unordered_map<string, shared_ptr<VRRequest>> VRRequestProcessorDelegate::getAllR
return mVRRequests;
}
-void VRRequestProcessorDelegate::setDefaultVoiceAgent(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent) {
+void VRRequestProcessorDelegate::setDefaultVoiceAgent(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent) {
mDefaultVoiceAgent = voiceAgent;
}
-shared_ptr<vshl::common::interfaces::IVoiceAgent> VRRequestProcessorDelegate::getDefaultVoiceAgent() const {
+shared_ptr<vshlcore::common::interfaces::IVoiceAgent> VRRequestProcessorDelegate::getDefaultVoiceAgent() const {
return mDefaultVoiceAgent;
}
diff --git a/src/plugins/core/test/VRRequestProcessorTest.cpp b/src/plugins/core/test/VRRequestProcessorTest.cpp
index c1a37df..caa62b8 100644
--- a/src/plugins/core/test/VRRequestProcessorTest.cpp
+++ b/src/plugins/core/test/VRRequestProcessorTest.cpp
@@ -22,11 +22,10 @@
#include "test/common/ConsoleLogger.h"
#include "test/mocks/AFBApiMock.h"
-using namespace vshl::core;
-using namespace vshl::voiceagents;
-using namespace vshl::test::common;
-
-namespace vshl {
+using namespace vshlcore::core;
+using namespace vshlcore::voiceagents;
+using namespace vshlcore::test::common;
+namespace vshlcore {
namespace test {
class VRRequestProcessorTest : public ::testing::Test {
diff --git a/src/plugins/core/test/VRRequestTest.cpp b/src/plugins/core/test/VRRequestTest.cpp
index b1cd0a6..a7bb3db 100644
--- a/src/plugins/core/test/VRRequestTest.cpp
+++ b/src/plugins/core/test/VRRequestTest.cpp
@@ -22,11 +22,10 @@
#include "test/common/ConsoleLogger.h"
#include "test/mocks/AFBApiMock.h"
-using namespace vshl::core;
-using namespace vshl::voiceagents;
-using namespace vshl::test::common;
-
-namespace vshl {
+using namespace vshlcore::core;
+using namespace vshlcore::voiceagents;
+using namespace vshlcore::test::common;
+namespace vshlcore {
namespace test {
class VRRequestTest : public ::testing::Test {
diff --git a/src/plugins/interfaces/afb/IAFBApi.h b/src/plugins/interfaces/afb/IAFBApi.h
index cd98006..ba0de72 100644
--- a/src/plugins/interfaces/afb/IAFBApi.h
+++ b/src/plugins/interfaces/afb/IAFBApi.h
@@ -22,7 +22,7 @@
using namespace std;
-namespace vshl {
+namespace vshlcore {
namespace common {
namespace interfaces {
diff --git a/src/plugins/interfaces/capabilities/ICapability.h b/src/plugins/interfaces/capabilities/ICapability.h
deleted file mode 100644
index 4b134b7..0000000
--- a/src/plugins/interfaces/capabilities/ICapability.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-#ifndef VSHL_COMMON_INTERFACES_ICAPABILITY_H_
-#define VSHL_COMMON_INTERFACES_ICAPABILITY_H_
-
-#include <list>
-#include <string>
-
-using namespace std;
-
-namespace vshl {
-namespace common {
-namespace interfaces {
-
-/*
- * This interface defines the structure for a specific voiceagent capability.
- */
-class ICapability {
-public:
- /*
- * Returns the capability's name.
- */
- virtual string getName() const = 0;
-
- /*
- * Returns the list of upstream messages.
- */
- virtual list<string> getUpstreamMessages() const = 0;
-
- /*
- * Returns the list of downstream messages
- */
- virtual list<string> getDownstreamMessages() const = 0;
-
- /**
- * Virtual destructor to assure proper cleanup of derived types.
- */
- virtual ~ICapability() = default;
-};
-
-} // namespace interfaces
-} // namespace common
-} // namespace vshl
-
-#endif // VSHL_COMMON_INTERFACES_ICAPABILITY_H_
diff --git a/src/plugins/interfaces/utilities/events/IEventFilter.h b/src/plugins/interfaces/utilities/events/IEventFilter.h
index 33d8202..3d99c87 100644
--- a/src/plugins/interfaces/utilities/events/IEventFilter.h
+++ b/src/plugins/interfaces/utilities/events/IEventFilter.h
@@ -18,8 +18,7 @@
#include <string>
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace common {
namespace interfaces {
/*
diff --git a/src/plugins/interfaces/utilities/logging/ILogger.h b/src/plugins/interfaces/utilities/logging/ILogger.h
index a2618bc..d8ae358 100644
--- a/src/plugins/interfaces/utilities/logging/ILogger.h
+++ b/src/plugins/interfaces/utilities/logging/ILogger.h
@@ -16,8 +16,7 @@
#define VSHL_COMMON_INTERFACES_LOGGER_H_
#include <string>
-
-namespace vshl {
+namespace vshlcore {
namespace common {
namespace interfaces {
diff --git a/src/plugins/interfaces/voiceagents/IVoiceAgent.h b/src/plugins/interfaces/voiceagents/IVoiceAgent.h
index 367ad72..6585c2b 100644
--- a/src/plugins/interfaces/voiceagents/IVoiceAgent.h
+++ b/src/plugins/interfaces/voiceagents/IVoiceAgent.h
@@ -21,8 +21,7 @@
#include <unordered_set>
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace common {
namespace interfaces {
diff --git a/src/plugins/interfaces/voiceagents/IVoiceAgentsChangeObserver.h b/src/plugins/interfaces/voiceagents/IVoiceAgentsChangeObserver.h
index e552ab5..8697d51 100644
--- a/src/plugins/interfaces/voiceagents/IVoiceAgentsChangeObserver.h
+++ b/src/plugins/interfaces/voiceagents/IVoiceAgentsChangeObserver.h
@@ -22,8 +22,7 @@
#include "interfaces/voiceagents/IVoiceAgent.h"
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace common {
namespace interfaces {
diff --git a/src/plugins/test/common/ConsoleLogger.cpp b/src/plugins/test/common/ConsoleLogger.cpp
index d4f9eef..d6735f4 100644
--- a/src/plugins/test/common/ConsoleLogger.cpp
+++ b/src/plugins/test/common/ConsoleLogger.cpp
@@ -16,8 +16,7 @@
#include <iostream>
#include "test/common/ConsoleLogger.h"
-
-namespace vshl {
+namespace vshlcore {
namespace test {
namespace common {
diff --git a/src/plugins/test/common/ConsoleLogger.h b/src/plugins/test/common/ConsoleLogger.h
index 11bc0d8..916b48f 100644
--- a/src/plugins/test/common/ConsoleLogger.h
+++ b/src/plugins/test/common/ConsoleLogger.h
@@ -18,12 +18,11 @@
#include "interfaces/utilities/logging/ILogger.h"
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace test {
namespace common {
-class ConsoleLogger : public vshl::common::interfaces::ILogger {
+class ConsoleLogger : public vshlcore::common::interfaces::ILogger {
public:
// ILogger interface
void log(Level level, const std::string &tag,
diff --git a/src/plugins/test/mocks/AFBApiMock.h b/src/plugins/test/mocks/AFBApiMock.h
index 46e2e99..846468d 100644
--- a/src/plugins/test/mocks/AFBApiMock.h
+++ b/src/plugins/test/mocks/AFBApiMock.h
@@ -18,11 +18,10 @@
#include <gmock/gmock.h>
#include "interfaces/afb/IAFBApi.h"
-
-namespace vshl {
+namespace vshlcore {
namespace test {
-class AFBApiMock : public vshl::common::interfaces::IAFBApi {
+class AFBApiMock : public vshlcore::common::interfaces::IAFBApi {
public:
MOCK_METHOD1(createEvent, std::shared_ptr<IAFBEvent>(const std::string& eventName));
MOCK_METHOD6(
diff --git a/src/plugins/test/mocks/AFBEventMock.h b/src/plugins/test/mocks/AFBEventMock.h
index 3d78e9f..0e47029 100644
--- a/src/plugins/test/mocks/AFBEventMock.h
+++ b/src/plugins/test/mocks/AFBEventMock.h
@@ -18,11 +18,10 @@
#include <gmock/gmock.h>
#include "interfaces/afb/IAFBApi.h"
-
-namespace vshl {
+namespace vshlcore {
namespace test {
-class AFBEventMock : public vshl::common::interfaces::IAFBApi::IAFBEvent {
+class AFBEventMock : public vshlcore::common::interfaces::IAFBApi::IAFBEvent {
public:
void setName(const std::string& name) {
mName = name;
@@ -34,8 +33,8 @@ public:
MOCK_METHOD0(isValid, bool());
MOCK_METHOD1(publishEvent, int(struct json_object* payload));
- MOCK_METHOD1(subscribe, bool(vshl::common::interfaces::IAFBRequest& request));
- MOCK_METHOD1(unsubscribe, bool(vshl::common::interfaces::IAFBRequest& request));
+ MOCK_METHOD1(subscribe, bool(vshlcore::common::interfaces::IAFBRequest& request));
+ MOCK_METHOD1(unsubscribe, bool(vshlcore::common::interfaces::IAFBRequest& request));
private:
std::string mName;
diff --git a/src/plugins/test/mocks/AFBRequestMock.h b/src/plugins/test/mocks/AFBRequestMock.h
index 5557565..02cc34e 100644
--- a/src/plugins/test/mocks/AFBRequestMock.h
+++ b/src/plugins/test/mocks/AFBRequestMock.h
@@ -18,11 +18,10 @@
#include <gmock/gmock.h>
#include "interfaces/afb/IAFBApi.h"
-
-namespace vshl {
+namespace vshlcore {
namespace test {
-class AFBRequestMock : public vshl::common::interfaces::IAFBRequest {
+class AFBRequestMock : public vshlcore::common::interfaces::IAFBRequest {
public:
MOCK_METHOD0(getNativeRequest, void*());
};
diff --git a/src/plugins/test/mocks/CapabilityMock.h b/src/plugins/test/mocks/CapabilityMock.h
deleted file mode 100644
index a2201df..0000000
--- a/src/plugins/test/mocks/CapabilityMock.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License").
- * You may not use this file except in compliance with the License.
- * A copy of the License is located at
- *
- * http://aws.amazon.com/apache2.0/
- *
- * or in the "license" file accompanying this file. This file is distributed
- * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-#ifndef VSHL_TEST_MOCKS_CAPABILITYMOCK_H_
-#define VSHL_TEST_MOCKS_CAPABILITYMOCK_H_
-
-#include <gmock/gmock.h>
-
-#include "interfaces/capabilities/ICapability.h"
-
-namespace vshl {
-namespace test {
-
-class CapabilityMock : public vshl::common::interfaces::ICapability {
-public:
- MOCK_CONST_METHOD0(getName, std::string());
- MOCK_CONST_METHOD0(getUpstreamMessages, std::list<std::string>());
- MOCK_CONST_METHOD0(getDownstreamMessages, std::list<std::string>());
-};
-
-} // namespace test
-} // namespace vshl
-
-#endif // VSHL_TEST_MOCKS_CAPABILITYMOCK_H_ \ No newline at end of file
diff --git a/src/plugins/test/mocks/VoiceAgentsChangeObserverMock.h b/src/plugins/test/mocks/VoiceAgentsChangeObserverMock.h
index 6edeea2..5935ab6 100644
--- a/src/plugins/test/mocks/VoiceAgentsChangeObserverMock.h
+++ b/src/plugins/test/mocks/VoiceAgentsChangeObserverMock.h
@@ -18,18 +18,17 @@
#include <gmock/gmock.h>
#include "interfaces/voiceagents/IVoiceAgentsChangeObserver.h"
-
-namespace vshl {
+namespace vshlcore {
namespace test {
-class VoiceAgentsChangeObserverMock : public vshl::common::interfaces::IVoiceAgentsChangeObserver {
+class VoiceAgentsChangeObserverMock : public vshlcore::common::interfaces::IVoiceAgentsChangeObserver {
public:
- MOCK_METHOD1(OnDefaultVoiceAgentChanged, void(shared_ptr<vshl::common::interfaces::IVoiceAgent> defaultVoiceAgent));
- MOCK_METHOD1(OnVoiceAgentAdded, void(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent));
- MOCK_METHOD1(OnVoiceAgentRemoved, void(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent));
- MOCK_METHOD1(OnVoiceAgentActiveWakeWordChanged, void(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent));
- MOCK_METHOD1(OnVoiceAgentActivated, void(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent));
- MOCK_METHOD1(OnVoiceAgentDeactivated, void(shared_ptr<vshl::common::interfaces::IVoiceAgent> voiceAgent));
+ MOCK_METHOD1(OnDefaultVoiceAgentChanged, void(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> defaultVoiceAgent));
+ MOCK_METHOD1(OnVoiceAgentAdded, void(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent));
+ MOCK_METHOD1(OnVoiceAgentRemoved, void(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent));
+ MOCK_METHOD1(OnVoiceAgentActiveWakeWordChanged, void(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent));
+ MOCK_METHOD1(OnVoiceAgentActivated, void(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent));
+ MOCK_METHOD1(OnVoiceAgentDeactivated, void(shared_ptr<vshlcore::common::interfaces::IVoiceAgent> voiceAgent));
};
} // namespace test
diff --git a/src/plugins/utilities/events/EventRouter.cpp b/src/plugins/utilities/events/EventRouter.cpp
index 999c3dd..4564953 100644
--- a/src/plugins/utilities/events/EventRouter.cpp
+++ b/src/plugins/utilities/events/EventRouter.cpp
@@ -14,19 +14,18 @@
*/
#include "utilities/events/EventRouter.h"
-static string TAG = "vshl::utilities::events::EventRouter";
+static string TAG = "vshlcore::utilities::events::EventRouter";
-using Level = vshl::common::interfaces::ILogger::Level;
-
-namespace vshl {
+using Level = vshlcore::common::interfaces::ILogger::Level;
+namespace vshlcore {
namespace utilities {
namespace events {
-unique_ptr<EventRouter> EventRouter::create(shared_ptr<vshl::common::interfaces::ILogger> logger) {
+unique_ptr<EventRouter> EventRouter::create(shared_ptr<vshlcore::common::interfaces::ILogger> logger) {
return std::unique_ptr<EventRouter>(new EventRouter(logger));
}
-EventRouter::EventRouter(shared_ptr<vshl::common::interfaces::ILogger> logger) : mLogger(logger) {
+EventRouter::EventRouter(shared_ptr<vshlcore::common::interfaces::ILogger> logger) : mLogger(logger) {
}
EventRouter::~EventRouter() {
@@ -43,7 +42,7 @@ bool EventRouter::handleIncomingEvent(const string eventName, const string voice
return false;
}
-bool EventRouter::addEventFilter(shared_ptr<vshl::common::interfaces::IEventFilter> filter) {
+bool EventRouter::addEventFilter(shared_ptr<vshlcore::common::interfaces::IEventFilter> filter) {
if (!filter) {
mLogger->log(Level::ERROR, TAG, "Failed to add event filter. Invalid arguments.");
return false;
@@ -53,7 +52,7 @@ bool EventRouter::addEventFilter(shared_ptr<vshl::common::interfaces::IEventFilt
return true;
}
-bool EventRouter::removeEventFilter(shared_ptr<vshl::common::interfaces::IEventFilter> filter) {
+bool EventRouter::removeEventFilter(shared_ptr<vshlcore::common::interfaces::IEventFilter> filter) {
if (!filter) {
mLogger->log(Level::ERROR, TAG, "Failed to add remove filter. Invalid arguments.");
return false;
diff --git a/src/plugins/utilities/events/EventRouter.h b/src/plugins/utilities/events/EventRouter.h
index fd7f0c2..752973a 100644
--- a/src/plugins/utilities/events/EventRouter.h
+++ b/src/plugins/utilities/events/EventRouter.h
@@ -23,8 +23,7 @@
#include "interfaces/utilities/logging/ILogger.h"
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace utilities {
namespace events {
/*
@@ -34,29 +33,29 @@ namespace events {
*/
class EventRouter {
public:
- static unique_ptr<EventRouter> create(shared_ptr<vshl::common::interfaces::ILogger> logger);
+ static unique_ptr<EventRouter> create(shared_ptr<vshlcore::common::interfaces::ILogger> logger);
// Destructor
~EventRouter();
// Add event filter as listerner.
- bool addEventFilter(shared_ptr<vshl::common::interfaces::IEventFilter> filter);
+ bool addEventFilter(shared_ptr<vshlcore::common::interfaces::IEventFilter> filter);
// Remove event filter as listerner.
- bool removeEventFilter(shared_ptr<vshl::common::interfaces::IEventFilter> filter);
+ bool removeEventFilter(shared_ptr<vshlcore::common::interfaces::IEventFilter> filter);
// This method is called by the controller for routing
// the event to appropriate listener.
bool handleIncomingEvent(const string eventName, const string voiceAgentId, const string payload);
private:
- EventRouter(shared_ptr<vshl::common::interfaces::ILogger> logger);
+ EventRouter(shared_ptr<vshlcore::common::interfaces::ILogger> logger);
// set of event filters.
- unordered_set<shared_ptr<vshl::common::interfaces::IEventFilter>> mEventFilters;
+ unordered_set<shared_ptr<vshlcore::common::interfaces::IEventFilter>> mEventFilters;
// Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
+ shared_ptr<vshlcore::common::interfaces::ILogger> mLogger;
};
} // namespace events
diff --git a/src/plugins/utilities/logging/Logger.cpp b/src/plugins/utilities/logging/Logger.cpp
index 6374e19..b310695 100644
--- a/src/plugins/utilities/logging/Logger.cpp
+++ b/src/plugins/utilities/logging/Logger.cpp
@@ -13,8 +13,7 @@
* permissions and limitations under the License.
*/
#include "utilities/logging/Logger.h"
-
-namespace vshl {
+namespace vshlcore {
namespace utilities {
namespace logging {
diff --git a/src/plugins/utilities/logging/Logger.h b/src/plugins/utilities/logging/Logger.h
index 79c89a5..d1d0196 100644
--- a/src/plugins/utilities/logging/Logger.h
+++ b/src/plugins/utilities/logging/Logger.h
@@ -26,12 +26,11 @@ extern "C" {
#include "interfaces/utilities/logging/ILogger.h"
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace utilities {
namespace logging {
-class Logger : public vshl::common::interfaces::ILogger {
+class Logger : public vshlcore::common::interfaces::ILogger {
public:
static std::unique_ptr<Logger> create(AFB_ApiT api);
diff --git a/src/plugins/utilities/uuid/UUIDGeneration.cpp b/src/plugins/utilities/uuid/UUIDGeneration.cpp
index bb03fc6..c006a0e 100644
--- a/src/plugins/utilities/uuid/UUIDGeneration.cpp
+++ b/src/plugins/utilities/uuid/UUIDGeneration.cpp
@@ -25,8 +25,7 @@
#include <functional>
#include "utilities/uuid/UUIDGeneration.h"
-
-namespace vshl {
+namespace vshlcore {
namespace utilities {
namespace uuid {
diff --git a/src/plugins/utilities/uuid/UUIDGeneration.h b/src/plugins/utilities/uuid/UUIDGeneration.h
index 7af9cb1..070c373 100644
--- a/src/plugins/utilities/uuid/UUIDGeneration.h
+++ b/src/plugins/utilities/uuid/UUIDGeneration.h
@@ -19,8 +19,7 @@
#define VSHL_UTILITIES_UUID_UUIDGENERATION_H_
#include <string>
-
-namespace vshl {
+namespace vshlcore {
namespace utilities {
namespace uuid {
diff --git a/src/plugins/voiceagents/VoiceAgentEventNames.h b/src/plugins/voiceagents/VoiceAgentEventNames.h
index 4575528..92cc8dc 100644
--- a/src/plugins/voiceagents/VoiceAgentEventNames.h
+++ b/src/plugins/voiceagents/VoiceAgentEventNames.h
@@ -19,8 +19,7 @@
#include <string>
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace voiceagents {
static string VSHL_EVENT_AUTH_STATE_EVENT = "voice_authstate_event";
diff --git a/src/plugins/voiceagents/VoiceAgentsDataManager.h b/src/plugins/voiceagents/VoiceAgentsDataManager.h
index a4c9143..a91d7eb 100644
--- a/src/plugins/voiceagents/VoiceAgentsDataManager.h
+++ b/src/plugins/voiceagents/VoiceAgentsDataManager.h
@@ -27,8 +27,7 @@
#include "interfaces/voiceagents/IVoiceAgentsChangeObserver.h"
#include "voiceagents/include/VoiceAgent.h"
#include "voiceagents/include/VoiceAgentEventsHandler.h"
-
-namespace vshl {
+namespace vshlcore {
namespace voiceagents {
/*
* This class implements the data model for voiceagents.
@@ -39,8 +38,8 @@ class VoiceAgentsDataManager {
public:
// Create a VoiceAgentsDataManager.
static std::unique_ptr<VoiceAgentsDataManager> create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi);
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi);
/**
* Activates the list of voiceagents.
@@ -84,22 +83,22 @@ public:
bool removeVoiceAgent(const string& voiceAgentId);
// Returns the set of all voice agents in @c VoiceAgentsDataManger cache
- std::set<std::shared_ptr<vshl::common::interfaces::IVoiceAgent>> getAllVoiceAgents();
+ std::set<std::shared_ptr<vshlcore::common::interfaces::IVoiceAgent>> getAllVoiceAgents();
// Returns the event filter that belongs to the core module.
- shared_ptr<vshl::common::interfaces::IEventFilter> getEventFilter() const;
+ shared_ptr<vshlcore::common::interfaces::IEventFilter> getEventFilter() const;
// Subscribe to an event coming from the voiceagent.
bool subscribeToVshlEventFromVoiceAgent(
- vshl::common::interfaces::IAFBRequest& request,
+ vshlcore::common::interfaces::IAFBRequest& request,
const string eventName,
const string voiceagentId);
// Adds a new voiceagent change observer.
- bool addVoiceAgentsChangeObserver(shared_ptr<vshl::common::interfaces::IVoiceAgentsChangeObserver> observer);
+ bool addVoiceAgentsChangeObserver(shared_ptr<vshlcore::common::interfaces::IVoiceAgentsChangeObserver> observer);
// Removes the voiceagent change observer from the list.
- bool removeVoiceAgentsChangeObserver(shared_ptr<vshl::common::interfaces::IVoiceAgentsChangeObserver> observer);
+ bool removeVoiceAgentsChangeObserver(shared_ptr<vshlcore::common::interfaces::IVoiceAgentsChangeObserver> observer);
// Destructor
~VoiceAgentsDataManager();
@@ -107,14 +106,17 @@ public:
private:
// Constructor
VoiceAgentsDataManager(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi);
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi);
+
+ // Sets the voiceagent ID
+ bool sendVoiceAgentIdToVA(const shared_ptr<VoiceAgent>& voiceAgent);
// Binding API reference
- shared_ptr<vshl::common::interfaces::IAFBApi> mAfbApi;
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> mAfbApi;
// A list of all the voiceagent change observers
- unordered_set<shared_ptr<vshl::common::interfaces::IVoiceAgentsChangeObserver>> mVoiceAgentChangeObservers;
+ unordered_set<shared_ptr<vshlcore::common::interfaces::IVoiceAgentsChangeObserver>> mVoiceAgentChangeObservers;
// A map of voiceagents grouped by ID
unordered_map<string, shared_ptr<VoiceAgent>> mVoiceAgents;
@@ -126,7 +128,9 @@ private:
string mDefaultVoiceAgentId;
// Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
+ shared_ptr<vshlcore::common::interfaces::ILogger> mLogger;
+
+ bool mAlreadyPeformedSubscriptions;
};
} // namespace voiceagents
diff --git a/src/plugins/voiceagents/VoiceAgentsDataManagerImpl.cpp b/src/plugins/voiceagents/VoiceAgentsDataManagerImpl.cpp
index 626a7fc..00f57e3 100644
--- a/src/plugins/voiceagents/VoiceAgentsDataManagerImpl.cpp
+++ b/src/plugins/voiceagents/VoiceAgentsDataManagerImpl.cpp
@@ -16,29 +16,30 @@
#include "voiceagents/include/VoiceAgentEventsHandler.h"
-static string TAG = "vshl::voiceagents::VoiceAgentsDataManager";
+static string VA_VERB_SETVOICEAGENTID = "setVoiceAgentId";
+static string TAG = "vshlcore::voiceagents::VoiceAgentsDataManager";
/**
* Specifies the severity level of a log message
*/
-using Level = vshl::common::interfaces::ILogger::Level;
-
-namespace vshl {
+using Level = vshlcore::common::interfaces::ILogger::Level;
+namespace vshlcore {
namespace voiceagents {
std::unique_ptr<VoiceAgentsDataManager> VoiceAgentsDataManager::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) {
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi) {
return std::unique_ptr<VoiceAgentsDataManager>(new VoiceAgentsDataManager(logger, afbApi));
}
// Constructor
VoiceAgentsDataManager::VoiceAgentsDataManager(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) :
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi) :
mLogger(logger),
mAfbApi(afbApi) {
mVoiceAgentEventsHandler = VoiceAgentEventsHandler::create(mLogger, mAfbApi);
+ mAlreadyPeformedSubscriptions = false;
}
// Destructor
@@ -178,6 +179,7 @@ bool VoiceAgentsDataManager::addNewVoiceAgent(
}
mVoiceAgents.insert(make_pair(voiceAgent->getId(), voiceAgent));
+ sendVoiceAgentIdToVA(voiceAgent);
// Notify the observers
for (auto observer : mVoiceAgentChangeObservers) {
@@ -218,8 +220,8 @@ bool VoiceAgentsDataManager::removeVoiceAgent(const string& voiceAgentId) {
return true;
}
-std::set<std::shared_ptr<vshl::common::interfaces::IVoiceAgent>> VoiceAgentsDataManager::getAllVoiceAgents() {
- std::set<std::shared_ptr<vshl::common::interfaces::IVoiceAgent>> voiceAgentsSet;
+std::set<std::shared_ptr<vshlcore::common::interfaces::IVoiceAgent>> VoiceAgentsDataManager::getAllVoiceAgents() {
+ std::set<std::shared_ptr<vshlcore::common::interfaces::IVoiceAgent>> voiceAgentsSet;
for (auto element : mVoiceAgents) {
voiceAgentsSet.insert(element.second);
}
@@ -228,12 +230,12 @@ std::set<std::shared_ptr<vshl::common::interfaces::IVoiceAgent>> VoiceAgentsData
}
// Returns the event filter that belongs to the core module.
-shared_ptr<vshl::common::interfaces::IEventFilter> VoiceAgentsDataManager::getEventFilter() const {
+shared_ptr<vshlcore::common::interfaces::IEventFilter> VoiceAgentsDataManager::getEventFilter() const {
return mVoiceAgentEventsHandler;
}
bool VoiceAgentsDataManager::subscribeToVshlEventFromVoiceAgent(
- vshl::common::interfaces::IAFBRequest& request,
+ vshlcore::common::interfaces::IAFBRequest& request,
const string eventName,
const string voiceAgentId) {
auto voiceAgentIt = mVoiceAgents.find(voiceAgentId);
@@ -250,7 +252,7 @@ bool VoiceAgentsDataManager::subscribeToVshlEventFromVoiceAgent(
}
bool VoiceAgentsDataManager::addVoiceAgentsChangeObserver(
- shared_ptr<vshl::common::interfaces::IVoiceAgentsChangeObserver> observer) {
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgentsChangeObserver> observer) {
if (!observer) {
return false;
}
@@ -260,7 +262,7 @@ bool VoiceAgentsDataManager::addVoiceAgentsChangeObserver(
}
bool VoiceAgentsDataManager::removeVoiceAgentsChangeObserver(
- shared_ptr<vshl::common::interfaces::IVoiceAgentsChangeObserver> observer) {
+ shared_ptr<vshlcore::common::interfaces::IVoiceAgentsChangeObserver> observer) {
if (!observer) {
return false;
}
@@ -268,5 +270,29 @@ bool VoiceAgentsDataManager::removeVoiceAgentsChangeObserver(
mVoiceAgentChangeObservers.erase(observer);
return true;
}
+
+bool VoiceAgentsDataManager::sendVoiceAgentIdToVA(const shared_ptr<VoiceAgent>& voiceAgent) {
+ if (!mAfbApi) {
+ mLogger->log(
+ Level::ERROR, TAG, "Failed to call sendVoiceAgentIdToVA on voicegent: " + voiceAgent->getId() + ", No API.");
+ return false;
+ }
+
+ json_object* argsJ = json_object_new_object();
+ json_object* idJ = json_object_new_string(voiceAgent->getId().c_str());
+ json_object_object_add(argsJ, "va_id", idJ);
+
+ std::string error, info;
+ json_object* resultJ;
+
+ int rc = mAfbApi->callSync(voiceAgent->getApi(), VA_VERB_SETVOICEAGENTID, argsJ, &resultJ, error, info);
+
+ if (resultJ) {
+ free(resultJ);
+ }
+
+ return true;
+}
+
} // namespace voiceagents
} // namespace vshl
diff --git a/src/plugins/voiceagents/include/VoiceAgent.h b/src/plugins/voiceagents/include/VoiceAgent.h
index 4dd55d4..684baf0 100644
--- a/src/plugins/voiceagents/include/VoiceAgent.h
+++ b/src/plugins/voiceagents/include/VoiceAgent.h
@@ -22,17 +22,16 @@
#include "interfaces/voiceagents/IVoiceAgent.h"
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace voiceagents {
/*
* Default implementation of IVoiceAgent interface.
*/
-class VoiceAgent : public vshl::common::interfaces::IVoiceAgent {
+class VoiceAgent : public vshlcore::common::interfaces::IVoiceAgent {
public:
// Creates @c VoiceAgent instance
static shared_ptr<VoiceAgent>
- create(shared_ptr<vshl::common::interfaces::ILogger> logger, const string &id,
+ create(shared_ptr<vshlcore::common::interfaces::ILogger> logger, const string &id,
const string &name, const string &description, const string &api,
const string &vendor, const string &activeWakeword,
const bool isActive,
@@ -55,14 +54,14 @@ public:
private:
// Constructor
- VoiceAgent(shared_ptr<vshl::common::interfaces::ILogger> logger,
+ VoiceAgent(shared_ptr<vshlcore::common::interfaces::ILogger> logger,
const string &id, const string &name, const string &description,
const string &api, const string &vendor,
const string &activeWakeword, const bool isActive,
const shared_ptr<unordered_set<string>> wakewords);
// Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
+ shared_ptr<vshlcore::common::interfaces::ILogger> mLogger;
// Id
string mId;
diff --git a/src/plugins/voiceagents/include/VoiceAgentEventsHandler.h b/src/plugins/voiceagents/include/VoiceAgentEventsHandler.h
index 3c1ca6c..00acfe1 100644
--- a/src/plugins/voiceagents/include/VoiceAgentEventsHandler.h
+++ b/src/plugins/voiceagents/include/VoiceAgentEventsHandler.h
@@ -26,8 +26,7 @@
#include "voiceagents/include/VoiceAgent.h"
using namespace std;
-
-namespace vshl {
+namespace vshlcore {
namespace voiceagents {
/*
* This class is reponsible for handling agent specific events
@@ -35,12 +34,12 @@ namespace voiceagents {
* This class also listen to the incoming events from voice agents
* and implements propagation to application layer.
*/
-class VoiceAgentEventsHandler : public vshl::common::interfaces::IEventFilter {
+class VoiceAgentEventsHandler : public vshlcore::common::interfaces::IEventFilter {
public:
// Create a VREventFilter.
static shared_ptr<VoiceAgentEventsHandler> create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi);
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi);
// Creates all the vshl events for a specific voiceagent id.
// For e.g if voiceagent is VA-001 then a new vshl event
@@ -53,7 +52,7 @@ public:
// Subscribe to a vshl event corresponding to a voiceagent.
bool subscribeToVshlEventFromVoiceAgent(
- vshl::common::interfaces::IAFBRequest& request,
+ vshlcore::common::interfaces::IAFBRequest& request,
const string eventName,
const shared_ptr<VoiceAgent> voiceAgent);
@@ -68,8 +67,8 @@ protected:
private:
// Constructor
VoiceAgentEventsHandler(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi);
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi);
// Helper method to generate the event name with voiceagent Id
// concatenated.
@@ -80,13 +79,13 @@ private:
bool callSubscribeVerb(const shared_ptr<VoiceAgent> voiceAgent);
// Binding API reference
- shared_ptr<vshl::common::interfaces::IAFBApi> mAfbApi;
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> mAfbApi;
// A map of VSHL event ID to its Event object
unordered_map<string, shared_ptr<common::interfaces::IAFBApi::IAFBEvent>> mEventsMap;
// Logger
- shared_ptr<vshl::common::interfaces::ILogger> mLogger;
+ shared_ptr<vshlcore::common::interfaces::ILogger> mLogger;
};
} // namespace voiceagents
diff --git a/src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp b/src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp
index 4952721..3b55505 100644
--- a/src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp
+++ b/src/plugins/voiceagents/src/VoiceAgentEventsHandler.cpp
@@ -14,25 +14,24 @@
*/
#include "voiceagents/include/VoiceAgentEventsHandler.h"
-static string TAG = "vshl::voiceagents::VoiceAgentEventsHandler";
+static string TAG = "vshlcore::voiceagents::VoiceAgentEventsHandler";
static string VA_VERB_SUBSCRIBE = "subscribe";
-using Level = vshl::common::interfaces::ILogger::Level;
-using namespace vshl::common::interfaces;
-
-namespace vshl {
+using Level = vshlcore::common::interfaces::ILogger::Level;
+using namespace vshlcore::common::interfaces;
+namespace vshlcore {
namespace voiceagents {
shared_ptr<VoiceAgentEventsHandler> VoiceAgentEventsHandler::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) {
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi) {
auto eventFilter = std::shared_ptr<VoiceAgentEventsHandler>(new VoiceAgentEventsHandler(logger, afbApi));
return eventFilter;
}
VoiceAgentEventsHandler::VoiceAgentEventsHandler(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
- shared_ptr<vshl::common::interfaces::IAFBApi> afbApi) :
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::IAFBApi> afbApi) :
mAfbApi(afbApi),
mLogger(logger) {
}
@@ -70,7 +69,7 @@ void VoiceAgentEventsHandler::removeVshlEventsForVoiceAgent(const string voiceAg
}
bool VoiceAgentEventsHandler::subscribeToVshlEventFromVoiceAgent(
- vshl::common::interfaces::IAFBRequest& request,
+ vshlcore::common::interfaces::IAFBRequest& request,
const string eventName,
const shared_ptr<VoiceAgent> voiceAgent) {
auto supportedEventsIt = find(VSHL_EVENTS.begin(), VSHL_EVENTS.end(), eventName);
diff --git a/src/plugins/voiceagents/src/VoiceAgentImpl.cpp b/src/plugins/voiceagents/src/VoiceAgentImpl.cpp
index f2ef8a1..39a92c4 100644
--- a/src/plugins/voiceagents/src/VoiceAgentImpl.cpp
+++ b/src/plugins/voiceagents/src/VoiceAgentImpl.cpp
@@ -16,18 +16,17 @@
#include "voiceagents/include/VoiceAgent.h"
-static string TAG = "vshl::voiceagents::VoiceAgent";
+static string TAG = "vshlcore::voiceagents::VoiceAgent";
/**
* Specifies the severity level of a log message
*/
-using Level = vshl::common::interfaces::ILogger::Level;
-
-namespace vshl {
+using Level = vshlcore::common::interfaces::ILogger::Level;
+namespace vshlcore {
namespace voiceagents {
// Creates @c VoiceAgent instance
shared_ptr<VoiceAgent> VoiceAgent::create(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
const string& id,
const string& name,
const string& description,
@@ -51,7 +50,7 @@ shared_ptr<VoiceAgent> VoiceAgent::create(
}
VoiceAgent::VoiceAgent(
- shared_ptr<vshl::common::interfaces::ILogger> logger,
+ shared_ptr<vshlcore::common::interfaces::ILogger> logger,
const string& id,
const string& name,
const string& description,
diff --git a/src/plugins/voiceagents/test/VoiceAgentTest.cpp b/src/plugins/voiceagents/test/VoiceAgentTest.cpp
index e5ad15e..9730182 100644
--- a/src/plugins/voiceagents/test/VoiceAgentTest.cpp
+++ b/src/plugins/voiceagents/test/VoiceAgentTest.cpp
@@ -20,10 +20,9 @@
#include "voiceagents/test/VoiceAgentsTestData.h"
#include "test/common/ConsoleLogger.h"
-using namespace vshl::voiceagents;
-using namespace vshl::test::common;
-
-namespace vshl {
+using namespace vshlcore::voiceagents;
+using namespace vshlcore::test::common;
+namespace vshlcore {
namespace test {
class VoiceAgentTest : public ::testing::Test {
diff --git a/src/plugins/voiceagents/test/VoiceAgentsDataManagerTest.cpp b/src/plugins/voiceagents/test/VoiceAgentsDataManagerTest.cpp
index 58c62ed..9f63c73 100644
--- a/src/plugins/voiceagents/test/VoiceAgentsDataManagerTest.cpp
+++ b/src/plugins/voiceagents/test/VoiceAgentsDataManagerTest.cpp
@@ -22,12 +22,11 @@
#include "test/mocks/VoiceAgentsChangeObserverMock.h"
#include "voiceagents/test/VoiceAgentsTestData.h"
-using namespace vshl::common::interfaces;
-using namespace vshl::voiceagents;
+using namespace vshlcore::common::interfaces;
+using namespace vshlcore::voiceagents;
-using namespace vshl::test::common;
-
-namespace vshl {
+using namespace vshlcore::test::common;
+namespace vshlcore {
namespace test {
class VoiceAgentDataManagerTest : public ::testing::Test {
diff --git a/src/plugins/voiceagents/test/VoiceAgentsTestData.h b/src/plugins/voiceagents/test/VoiceAgentsTestData.h
index ced068f..104123b 100644
--- a/src/plugins/voiceagents/test/VoiceAgentsTestData.h
+++ b/src/plugins/voiceagents/test/VoiceAgentsTestData.h
@@ -17,8 +17,7 @@
#include <string>
#include <unordered_set>
#include <vector>
-
-namespace vshl {
+namespace vshlcore {
namespace test {
typedef std::shared_ptr<std::unordered_set<std::string>> WakeWords;
diff --git a/src/vshl-apidef.h b/src/vshl-apidef.h
deleted file mode 100644
index 7a14498..0000000
--- a/src/vshl-apidef.h
+++ /dev/null
@@ -1,43 +0,0 @@
-
-static const char _afb_description_vshl[] =
- "{\"openapi\":\"3.0.0\",\"$schema\":\"http://iot.bzh/download/openapi/sch"
- "ema-3.0/default-schema.json\",\"info\":{\"description\":\"\",\"title\":\""
- "High Level Voice Service API\",\"version\":\"1.0\",\"x-binding-c-generat"
- "or\":{\"api\":\"vshl\",\"version\":3,\"prefix\":\"afv_\",\"postfix\":\"\""
- ",\"start\":null,\"onevent\":null,\"init\":\"init\",\"scope\":\"\",\"priv"
- "ate\":false,\"noconcurrency\":true}},\"servers\":[{\"url\":\"ws://{host}"
- ":{port}/api/monitor\",\"description\":\"TS caching binding\",\"variables"
- "\":{\"host\":{\"default\":\"localhost\"},\"port\":{\"default\":\"1234\"}"
- "},\"x-afb-events\":[{\"$ref\":\"#/components/schemas/afb-event\"}]}],\"c"
- "omponents\":{\"schemas\":{\"afb-reply\":{\"$ref\":\"#/components/schemas"
- "/afb-reply-v3\"},\"afb-event\":{\"$ref\":\"#/components/schemas/afb-even"
- "t-v3\"},\"afb-reply-v3\":{\"title\":\"Generic response.\",\"type\":\"obj"
- "ect\",\"required\":[\"jtype\",\"request\"],\"properties\":{\"jtype\":{\""
- "type\":\"string\",\"const\":\"afb-reply\"},\"request\":{\"type\":\"objec"
- "t\",\"required\":[\"status\"],\"properties\":{\"status\":{\"type\":\"str"
- "ing\"},\"info\":{\"type\":\"string\"},\"token\":{\"type\":\"string\"},\""
- "uuid\":{\"type\":\"string\"},\"reqid\":{\"type\":\"string\"}}},\"respons"
- "e\":{\"type\":\"object\"}}},\"afb-event-v3\":{\"type\":\"object\",\"requ"
- "ired\":[\"jtype\",\"event\"],\"properties\":{\"jtype\":{\"type\":\"strin"
- "g\",\"const\":\"afb-event\"},\"event\":{\"type\":\"string\"},\"data\":{\""
- "type\":\"object\"}}}},\"responses\":{\"200\":{\"description\":\"A comple"
- "x object array response\",\"content\":{\"application/json\":{\"schema\":"
- "{\"$ref\":\"#/components/schemas/afb-reply\"}}}}}}}";
-
-static const struct afb_verb_v3 _afb_verbs_vshl[] = {
- {.verb = NULL, .callback = NULL, .auth = NULL, .info = NULL, .vcbdata = NULL, .session = 0, .glob = 0}};
-
-int init(afb_api_t api);
-
-const struct afb_binding_v3 afbBindingV3 = {.api = "vshl",
- .specification = _afb_description_vshl,
- .info = "",
- .verbs = _afb_verbs_vshl,
- .preinit = NULL,
- .init = init,
- .onevent = NULL,
- .userdata = NULL,
- .provide_class = NULL,
- .require_class = NULL,
- .require_api = NULL,
- .noconcurrency = 1};
diff --git a/src/vshl-core-apidef.h b/src/vshl-core-apidef.h
new file mode 100644
index 0000000..93d880e
--- /dev/null
+++ b/src/vshl-core-apidef.h
@@ -0,0 +1,52 @@
+
+static const char _afb_description_vshl_core[] =
+ "{\"openapi\":\"3.0.0\",\"$schema\":\"http://iot.bzh/download/openapi/sch"
+ "ema-3.0/default-schema.json\",\"info\":{\"description\":\"\",\"title\":\""
+ "High Level Voice Service Core API\",\"version\":\"1.0\",\"x-binding-c-ge"
+ "nerator\":{\"api\":\"vshl-core\",\"version\":3,\"prefix\":\"afv_\",\"pos"
+ "tfix\":\"\",\"start\":null,\"onevent\":null,\"init\":\"init\",\"scope\":"
+ "\"\",\"private\":false,\"noconcurrency\":true}},\"servers\":[{\"url\":\""
+ "ws://{host}:{port}/api/monitor\",\"description\":\"TS caching binding\","
+ "\"variables\":{\"host\":{\"default\":\"localhost\"},\"port\":{\"default\""
+ ":\"1234\"}},\"x-afb-events\":[{\"$ref\":\"#/components/schemas/afb-event"
+ "\"}]}],\"components\":{\"schemas\":{\"afb-reply\":{\"$ref\":\"#/componen"
+ "ts/schemas/afb-reply-v3\"},\"afb-event\":{\"$ref\":\"#/components/schema"
+ "s/afb-event-v3\"},\"afb-reply-v3\":{\"title\":\"Generic response.\",\"ty"
+ "pe\":\"object\",\"required\":[\"jtype\",\"request\"],\"properties\":{\"j"
+ "type\":{\"type\":\"string\",\"const\":\"afb-reply\"},\"request\":{\"type"
+ "\":\"object\",\"required\":[\"status\"],\"properties\":{\"status\":{\"ty"
+ "pe\":\"string\"},\"info\":{\"type\":\"string\"},\"token\":{\"type\":\"st"
+ "ring\"},\"uuid\":{\"type\":\"string\"},\"reqid\":{\"type\":\"string\"}}}"
+ ",\"response\":{\"type\":\"object\"}}},\"afb-event-v3\":{\"type\":\"objec"
+ "t\",\"required\":[\"jtype\",\"event\"],\"properties\":{\"jtype\":{\"type"
+ "\":\"string\",\"const\":\"afb-event\"},\"event\":{\"type\":\"string\"},\""
+ "data\":{\"type\":\"object\"}}}},\"responses\":{\"200\":{\"description\":"
+ "\"A complex object array response\",\"content\":{\"application/json\":{\""
+ "schema\":{\"$ref\":\"#/components/schemas/afb-reply\"}}}}}}}"
+;
+
+
+static const struct afb_verb_v3 _afb_verbs_vshl_core[] = {
+ {
+ .verb = NULL,
+ .callback = NULL,
+ .auth = NULL,
+ .info = NULL,
+ .session = 0,
+ .vcbdata = NULL,
+ .glob = 0
+ }
+};
+
+const struct afb_binding_v3 afbBindingV3 = {
+ .api = "vshl-core",
+ .specification = _afb_description_vshl_core,
+ .info = "",
+ .verbs = _afb_verbs_vshl_core,
+ .preinit = NULL,
+ .init = init,
+ .onevent = NULL,
+ .userdata = NULL,
+ .noconcurrency = 1
+};
+
diff --git a/src/vshl-apidef.json b/src/vshl-core-apidef.json
index 67bda88..0079dfd 100644
--- a/src/vshl-apidef.json
+++ b/src/vshl-core-apidef.json
@@ -3,10 +3,10 @@
"$schema": "http://iot.bzh/download/openapi/schema-3.0/default-schema.json",
"info": {
"description": "",
- "title": "High Level Voice Service API",
+ "title": "High Level Voice Service Core API",
"version": "1.0",
"x-binding-c-generator": {
- "api": "vshl",
+ "api": "vshl-core",
"version": 3,
"prefix": "afv_",
"postfix": "",
diff --git a/src/vshl-binding.c b/src/vshl-core-binding.c
index 17afbad..a832f66 100644
--- a/src/vshl-binding.c
+++ b/src/vshl-core-binding.c
@@ -13,16 +13,16 @@
* permissions and limitations under the License.
*/
#define _GNU_SOURCE
-#include "vshl-binding.h"
+#include "vshl-core-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 = "onload", .loadCB = OnloadConfig},
{.key = "controls", .loadCB = ControlConfig},
{.key = "events", .loadCB = EventConfig},
+ {.key = "onload", .loadCB = OnloadConfig},
{.key = NULL}};
static AFB_ApiVerbs ctrlApiVerbs[] = {
@@ -49,6 +49,21 @@ static int ctrlLoadStaticVerbs(afb_dynapi* apiHandle, AFB_ApiVerbs* verbs) {
// next generation dynamic API-V3 mode
#include <signal.h>
+static int CtrlInitOneApi(AFB_ApiT apiHandle)
+{
+ CtlConfigT *ctrlConfig;
+
+ if(!apiHandle)
+ return -1;
+
+ // Retrieve section config from api handle
+ ctrlConfig = (CtlConfigT *) AFB_ApiGetUserData(apiHandle);
+ if(!ctrlConfig)
+ return -2;
+
+ return CtlConfigExec(apiHandle, ctrlConfig);
+}
+
static int ctrlLoadOneApi(void* cbdata, AFB_ApiT apiHandle) {
CtlConfigT* ctrlConfig = (CtlConfigT*)cbdata;
@@ -73,7 +88,7 @@ static int ctrlLoadOneApi(void* cbdata, AFB_ApiT apiHandle) {
afb_dynapi_on_event(apiHandle, CtrlDispatchApiEvent);
// init API function (does not receive user closure ???
- // afb_dynapi_on_init(apiHandle, CtrlInitOneApi);
+ afb_dynapi_on_init(apiHandle, CtrlInitOneApi);
afb_dynapi_seal(apiHandle);
return err;
@@ -109,8 +124,5 @@ int afbBindingEntry(afb_dynapi* apiHandle) {
// 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);
- // config exec should be done after api init in order to enable onload to use newly defined ctl API.
- if (!status) status = CtlConfigExec(apiHandle, ctrlConfig);
-
return status;
}
diff --git a/src/vshl-binding.h b/src/vshl-core-binding.h
index 75e7c91..75e7c91 100644
--- a/src/vshl-binding.h
+++ b/src/vshl-core-binding.h