summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.gitreview5
-rw-r--r--CMakeLists.txt21
-rw-r--r--LICENSE54
-rw-r--r--app/BodyTemplateDialog.qml164
-rw-r--r--app/CMakeLists.txt66
-rw-r--r--app/Main.qml121
-rw-r--r--app/WeatherTemplateDialog.qml239
-rw-r--r--app/afbclient.cpp245
-rw-r--r--app/afbclient.h67
-rw-r--r--app/alexa-viewer.qrc7
-rw-r--r--app/main.cpp207
-rwxr-xr-xautobuild/agl/autobuild65
-rwxr-xr-xautobuild/linux/autobuild67
-rw-r--r--conf.d/cmake/config.cmake204
-rw-r--r--conf.d/wgt/config.xml.in21
16 files changed, 1555 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5975d97
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+*~
+build/
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..6937d76
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.automotivelinux.org
+port=29418
+project=apps/alexa-viewer
+defaultbranch=master
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..bf284f7
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,21 @@
+###########################################################################
+# Copyright 2015, 2016, 2017 IoT.bzh
+#
+# Author: romain Forlot <romain.forlot@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.
+###########################################################################
+
+CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
+
+include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..31c692a
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,54 @@
+Apache License
+
+Version 2.0, January 2004
+
+http://www.apache.org/licenses/
+
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+1. Definitions.
+
+"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
+
+"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
+
+"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
+
+"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
+
+"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
+
+"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
+
+"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
+
+"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
+
+"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
+
+"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
+
+2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
+
+3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
+
+4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
+
+ You must give any other recipients of the Work or Derivative Works a copy of this License; and
+ You must cause any modified files to carry prominent notices stating that You changed the files; and
+ You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
+ If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
+
+5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
+
+6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
+
+7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
+
+8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
+
+9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
+
+END OF TERMS AND CONDITIONS
diff --git a/app/BodyTemplateDialog.qml b/app/BodyTemplateDialog.qml
new file mode 100644
index 0000000..4da85d9
--- /dev/null
+++ b/app/BodyTemplateDialog.qml
@@ -0,0 +1,164 @@
+/*
+ * Copyright (C) 2020 Konsulko Group
+ *
+ * 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.
+ */
+
+import QtQuick 2.2
+import QtQuick.Layouts 1.1
+import QtQuick.Controls 2.0
+
+Rectangle {
+ id: body_main
+ width: 1000
+ height: 1000
+ radius: 2
+
+ color: "black"
+
+ ColumnLayout {
+ id: body_col
+ anchors.fill: parent.fill
+
+ Label {
+ id: body_title
+ Layout.fillWidth: true
+ Layout.fillHeight: false
+ Layout.topMargin: 20
+ Layout.leftMargin: 20
+ Layout.rightMargin: 20
+
+ text: bodyTemplate.title
+ color: "white"
+ font.pixelSize: 32
+ font.bold: true
+ maximumLineCount: 1
+ wrapMode: Text.Wrap
+ elide: Text.ElideRight
+ horizontalAlignment: Label.AlignLeft
+ verticalAlignment: Label.AlignVCenter
+ }
+
+ Label {
+ id: body_subtitle
+ Layout.fillWidth: true
+ Layout.fillHeight: false
+ Layout.topMargin: 0
+ Layout.leftMargin: 20
+ Layout.rightMargin: 20
+
+ text: bodyTemplate.subtitle
+ visible: bodyTemplate.subtitle != ""
+ color: "white"
+ font.pixelSize: 22
+ font.bold: false
+ maximumLineCount: 1
+ wrapMode: Text.Wrap
+ elide: Text.ElideRight
+ horizontalAlignment: Label.AlignLeft
+ verticalAlignment: Label.AlignVCenter
+ }
+
+ RowLayout {
+ id: body_row
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.topMargin: 20
+ Layout.leftMargin: 20
+ Layout.rightMargin: 20
+ spacing: 20
+
+ Text {
+ id: body_textContent
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+
+ text: bodyTemplate.textContent
+ color: "white"
+ font.pixelSize: 32
+ font.bold: false
+ wrapMode: Text.Wrap
+ verticalAlignment: Text.AlignTop
+ maximumLineCount: 21
+
+ states: [
+ State {
+ name: "BodyTemplate2"
+ when: bodyTemplate.imageContentSource != ""
+ PropertyChanges {
+ target: body_textContent
+ Layout.maximumWidth: (body_main.width - 3 * parent.spacing) / 2
+ Layout.preferredWidth: (body_main.width - 3 * parent.spacing) / 2
+ }
+ },
+ State {
+ name: "BodyTemplate1"
+ when: bodyTemplate.imageContentSource == ""
+ PropertyChanges {
+ target: body_textContent
+ Layout.maximumWidth: body_main.width - 2 * parent.spacing
+ Layout.preferredWidth: body_main.width - 2 * parent.spacing
+ }
+ }
+ ]
+ }
+
+ Image {
+ id: body_imageContent
+ Layout.fillWidth: true
+ Layout.fillHeight: false
+ Layout.maximumWidth: (body_main.width - 3 * parent.spacing) / 2
+ Layout.preferredWidth: (body_main.width - 3 * parent.spacing) / 2
+ Layout.alignment: Qt.AlignTop
+
+ source: bodyTemplate.imageContentSource
+ visible: bodyTemplate.imageContentSource != ""
+ fillMode: Image.PreserveAspectFit
+ horizontalAlignment: Image.AlignHCenter
+ verticalAlignment: Image.AlignTop
+ }
+ }
+ }
+
+ Button {
+ id: body_close
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottomMargin: 20
+
+ text: "Close"
+
+ onReleased: {
+ body_close.highlighted = false
+ clear()
+ hide()
+ }
+ onPressed: {
+ body_close.highlighted = true
+ }
+ onCanceled: {
+ body_close.highlighted = false
+ }
+ }
+
+ // Functions
+
+ function clear() {
+ bodyTemplate.visible = false
+
+ bodyTemplate.title = ""
+ bodyTemplate.subtitle = ""
+ bodyTemplate.textContent = ""
+ bodyTemplate.imageContentSource = ""
+ }
+}
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
new file mode 100644
index 0000000..836d473
--- /dev/null
+++ b/app/CMakeLists.txt
@@ -0,0 +1,66 @@
+###########################################################################
+# Copyright 2018-2020 Konsulko Group
+#
+# Author: Scott Murray <scott.murray@konsulko.com>
+#
+# 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.
+###########################################################################
+
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(CMAKE_AUTOMOC ON)
+set(CMAKE_AUTORCC ON)
+set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED ON)
+set(OE_QMAKE_PATH_EXTERNAL_HOST_BINS $ENV{OE_QMAKE_PATH_HOST_BINS})
+
+find_package(Qt5 COMPONENTS Core Gui QuickControls2 QuickWidgets REQUIRED)
+find_package(PkgConfig REQUIRED)
+
+qt5_add_resources(RESOURCES alexa-viewer.qrc)
+
+PROJECT_TARGET_ADD(alexa-viewer)
+
+add_executable(${TARGET_NAME}
+ main.cpp
+ afbclient.cpp
+ ${RESOURCES}
+)
+
+pkg_check_modules(QLIBWINDOWMGR REQUIRED qlibwindowmanager)
+pkg_check_modules(QLIBHOMESCREEN REQUIRED qlibhomescreen)
+pkg_check_modules(QTAPPFW REQUIRED qtappfw)
+pkg_check_modules(LIBAFBWSC REQUIRED libafbwsc)
+
+include_directories(
+ ${QTAPPFW_INCLUDE_DIRS}
+ ${LIBAFBWSC_INCLUDE_DIRS}
+)
+
+set_target_properties(${TARGET_NAME} PROPERTIES
+ LABELS "EXECUTABLE"
+ PREFIX ""
+ COMPILE_FLAGS "${QLIBWINDOWMGR_FLAGS} ${QLIBHOMESCREEN} ${QTAPPFW_FLAGS} ${EXTRAS_CFLAGS} -DFOR_AFB_BINDING"
+ LINK_FLAGS "${BINDINGS_LINK_FLAG}"
+ LINK_LIBRARIES "${EXTRAS_LIBRARIES}"
+ OUTPUT_NAME "${TARGET_NAME}"
+)
+
+target_link_libraries(${TARGET_NAME}
+ Qt5::QuickControls2
+ Qt5::QuickWidgets
+ ${QLIBWINDOWMGR_LIBRARIES}
+ ${QLIBHOMESCREEN_LIBRARIES}
+ ${QTAPPFW_LIBRARIES}
+ ${LIBAFBWSC_LIBRARIES}
+ -lpthread
+)
diff --git a/app/Main.qml b/app/Main.qml
new file mode 100644
index 0000000..7060b9b
--- /dev/null
+++ b/app/Main.qml
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2020 Konsulko Group
+ *
+ * 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.
+ */
+
+import QtQuick 2.2
+import QtQuick.Window 2.1
+import QtQuick.Controls 1.4
+import QtQuick.Controls.Styles 1.4
+import QtQuick.Extras 1.4
+
+Window {
+ id: root
+ width: 1080
+ height: 1488
+ color: '#00000000'
+
+ visible: true
+ flags: Qt.FramelessWindowHint
+
+ BodyTemplateDialog {
+ id: bodyTemplate
+ anchors.centerIn: parent
+ visible: true
+
+ property string title: ""
+ property string subtitle: ""
+
+ property string textContent: ""
+ property url imageContentSource: ""
+ }
+
+ WeatherTemplateDialog {
+ id: weatherTemplate
+ anchors.centerIn: parent
+ visible: false
+
+ property string title: ""
+ property string subtitle: ""
+
+ property string currentTemperature: ""
+ property url currentWeatherIconSource: ""
+ property string lowTemperature: ""
+ property url lowTemperatureArrowSource: ""
+ property string highTemperature: ""
+ property url highTemperatureArrowSource: ""
+ }
+
+ Connections {
+ target: GuiMetadata
+
+ onRenderTemplate: {
+ console.log("Received renderTemplate, type = " + GuiMetadata.type)
+ if(GuiMetadata.type == "BodyTemplate1" || GuiMetadata.type == "BodyTemplate2") {
+ // Normally setting the target to visible would be after changes to the
+ // content, but I was seeing better behavior during testing by doing it
+ // here. Further investigation is required, and likely hooking up
+ // loading indication on the Images in the template dialogs.
+ weatherTemplate.visible = false
+ bodyTemplate.visible = true
+
+ bodyTemplate.title = GuiMetadata.title
+ bodyTemplate.subtitle = GuiMetadata.subtitle
+ bodyTemplate.textContent = GuiMetadata.bodyText
+
+ if(GuiMetadata.type == "BodyTemplate1") {
+ bodyTemplate.imageContentSource = ""
+ } else {
+ bodyTemplate.imageContentSource = GuiMetadata.bodyImageSmallUrl
+ }
+ } else if(GuiMetadata.type == "WeatherTemplate") {
+ bodyTemplate.visible = false
+ weatherTemplate.visible = true
+
+ weatherTemplate.title = GuiMetadata.title
+ weatherTemplate.subtitle = GuiMetadata.subtitle
+
+ weatherTemplate.currentTemperature = GuiMetadata.weatherCurrentTemperature
+ weatherTemplate.currentWeatherIconSource = GuiMetadata.weatherCurrentWeatherIconMediumDarkBgUrl
+ weatherTemplate.lowTemperature = GuiMetadata.weatherLowTemperature
+ weatherTemplate.lowTemperatureArrowSource = GuiMetadata.weatherLowTemperatureArrowMediumDarkBgUrl
+ weatherTemplate.highTemperature = GuiMetadata.weatherHighTemperature
+ weatherTemplate.highTemperatureArrowSource = GuiMetadata.weatherHighTemperatureArrowMediumDarkBgUrl
+ } else {
+ // Should not happen, but just in case
+ bodyTemplate.title = "Unsupported Template"
+ bodyTemplate.subtitle = ""
+ bodyTemplate.textContent = "The display template for this response is currently unsupported."
+ bodyTemplate.imageContentSource = ""
+
+ weatherTemplate.visible = false
+ bodyTemplate.visible = false
+ }
+ }
+
+ onClearTemplate: {
+ console.log("Received clearTemplate!")
+ bodyTemplate.clear()
+ weatherTemplate.clear()
+ hide()
+ }
+ }
+
+ // Functions
+
+ function hide() {
+ console.log("hiding window!")
+ homescreen.hideWindow("alexa-viewer")
+ }
+}
diff --git a/app/WeatherTemplateDialog.qml b/app/WeatherTemplateDialog.qml
new file mode 100644
index 0000000..6205695
--- /dev/null
+++ b/app/WeatherTemplateDialog.qml
@@ -0,0 +1,239 @@
+/*
+ * Copyright (C) 2020 Konsulko Group
+ *
+ * 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.
+ */
+
+import QtQuick 2.2
+import QtQuick.Layouts 1.1
+import QtQuick.Controls 2.0
+
+Rectangle {
+ id: weather_main
+ width: 1000
+ height: 1000
+ radius: 2
+
+ color: "black"
+
+ ColumnLayout {
+ id: weather_col
+ anchors.fill: parent.fill
+
+ Label {
+ id: weather_title
+ Layout.fillWidth: true
+ Layout.fillHeight: false
+ Layout.topMargin: 20
+ Layout.leftMargin: 20
+ Layout.rightMargin: 20
+
+ text: weatherTemplate.title
+ color: "white"
+ font.pixelSize: 48
+ font.bold: true
+ maximumLineCount: 1
+ wrapMode: Text.Wrap
+ elide: Text.ElideRight
+ horizontalAlignment: Label.AlignLeft
+ verticalAlignment: Label.AlignVCenter
+ }
+
+ Label {
+ id: weather_subtitle
+ Layout.fillWidth: true
+ Layout.fillHeight: false
+ Layout.topMargin: 0
+ Layout.leftMargin: 20
+ Layout.rightMargin: 20
+
+ text: weatherTemplate.subtitle
+ visible: weatherTemplate.subtitle != ""
+ color: "white"
+ font.pixelSize: 32
+ font.bold: false
+ maximumLineCount: 1
+ wrapMode: Text.Wrap
+ elide: Text.ElideRight
+ horizontalAlignment: Label.AlignLeft
+ verticalAlignment: Label.AlignVCenter
+ }
+
+ RowLayout {
+ id: weather_row
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+ Layout.topMargin: 200
+ Layout.leftMargin: 20
+ Layout.rightMargin: 20
+ spacing: 0
+
+ Image {
+ id: weather_currentWeatherIcon_imageContent
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.maximumWidth: (weather_main.width - 3 * parent.spacing) / 3
+ Layout.preferredWidth: (weather_main.width - 3 * parent.spacing) / 3
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+
+ source: weatherTemplate.currentWeatherIconSource
+ fillMode: Image.PreserveAspectFit
+ horizontalAlignment: Image.AlignHCenter
+ verticalAlignment: Image.AlignVCenter
+ }
+
+ Text {
+ id: weather_currentWeather_textContent
+ Layout.fillWidth: true
+ Layout.fillHeight: false
+ Layout.maximumWidth: (weather_main.width - 3 * parent.spacing) / 3
+ Layout.preferredWidth: (weather_main.width - 3 * parent.spacing) / 3
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+
+ text: weatherTemplate.currentTemperature
+ color: "white"
+ font.pixelSize: 150
+ font.bold: false
+ wrapMode: Text.Wrap
+ verticalAlignment: Text.AlignTop
+ horizontalAlignment: Text.AlignHCenter
+ maximumLineCount: 1
+ }
+
+ ColumnLayout {
+ id: weather_low_high_col
+ Layout.fillWidth: true
+ Layout.fillHeight: false
+ Layout.maximumWidth: (weather_main.width - 3 * parent.spacing) / 3
+ Layout.preferredWidth: (weather_main.width - 3 * parent.spacing) / 3
+
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+
+ RowLayout {
+ id: weather_high_row
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+ spacing: 20
+
+ Image {
+ id: weather_highTempArrow_imageContent
+ Layout.fillWidth: false
+ Layout.fillHeight: false
+ Layout.maximumWidth: (weather_main.width - 3 * parent.spacing) / 6
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+
+ source: weatherTemplate.highTemperatureArrowSource
+ fillMode: Image.PreserveAspectFit
+ horizontalAlignment: Image.AlignHCenter
+ verticalAlignment: Image.AlignVCenter
+ }
+
+ Text {
+ id: weather_highTemp_textContent
+ Layout.fillWidth: false
+ Layout.fillHeight: false
+ Layout.maximumWidth: (weather_main.width - 3 * parent.spacing) / 6
+ Layout.preferredWidth: (weather_main.width - 3 * parent.spacing) / 6
+ Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
+
+ text: weatherTemplate.highTemperature
+ color: "white"
+ font.pixelSize: 60
+ font.bold: false
+ wrapMode: Text.Wrap
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignLeft
+ maximumLineCount: 1
+ }
+ }
+
+ RowLayout {
+ id: weather_low_row
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+ spacing: 20
+
+ Image {
+ id: weather_lowTempArrow_imageContent
+ Layout.fillWidth: false
+ Layout.fillHeight: false
+ Layout.maximumWidth: (weather_main.width - 3 * parent.spacing) / 6
+ Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
+
+ source: weatherTemplate.lowTemperatureArrowSource
+ fillMode: Image.PreserveAspectFit
+ horizontalAlignment: Image.AlignHCenter
+ verticalAlignment: Image.AlignVCenter
+ }
+
+ Text {
+ id: weather_lowTemp_textContent
+ Layout.fillWidth: false
+ Layout.fillHeight: false
+ Layout.maximumWidth: (weather_main.width - 3 * parent.spacing) / 6
+ Layout.preferredWidth: (weather_main.width - 3 * parent.spacing) / 6
+ Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
+
+ text: weatherTemplate.lowTemperature
+ color: "white"
+ font.pixelSize: 60
+ font.bold: false
+ wrapMode: Text.Wrap
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignLeft
+ maximumLineCount: 1
+ }
+ }
+ }
+ }
+ }
+
+ Button {
+ id: weather_close
+ anchors.bottom: parent.bottom
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.bottomMargin: 20
+
+ text: "Close"
+
+ onReleased: {
+ weather_close.highlighted = false
+ clear()
+ hide()
+ }
+ onPressed: {
+ weather_close.highlighted = true
+ }
+ onCanceled: {
+ weather_close.highlighted = false
+ }
+ }
+
+ // Functions
+
+ function clear() {
+ weatherTemplate.visible = false
+
+ weatherTemplate.title = ""
+ weatherTemplate.subtitle = ""
+ weatherTemplate.currentTemperature = ""
+ weatherTemplate.currentWeatherIconSource = ""
+ weatherTemplate.lowTemperature = ""
+ weatherTemplate.lowTemperatureArrowSource = ""
+ weatherTemplate.highTemperature = ""
+ weatherTemplate.highTemperatureArrowSource = ""
+ }
+}
diff --git a/app/afbclient.cpp b/app/afbclient.cpp
new file mode 100644
index 0000000..4b136cb
--- /dev/null
+++ b/app/afbclient.cpp
@@ -0,0 +1,245 @@
+/*
+ * Copyright (C) 2019,2020 Konsulko Group
+ *
+ * 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.
+ */
+
+#include "afbclient.h"
+#include <string>
+#include <cstring>
+#include <iostream>
+#include <mutex>
+#include <condition_variable>
+
+#undef DEBUG
+//#define DEBUG
+
+struct call_data
+{
+ bool sync;
+ std::mutex mutex;
+ std::condition_variable cv;
+ bool ready;
+ std::function<void(json_object*)> cb;
+ json_object *resp;
+};
+
+static void on_hangup_cb(void *closure, struct afb_wsj1 *wsj)
+{
+}
+
+static void on_call_cb(void *closure, const char *api, const char *verb, struct afb_wsj1_msg *msg)
+{
+}
+
+static void on_reply_cb(void *closure, struct afb_wsj1_msg *msg)
+{
+ call_data *data = (call_data*) closure;
+ struct json_object* reply;
+
+ if(!data)
+ goto reply_done;
+
+ reply = afb_wsj1_msg_object_j(msg);
+ if(reply) {
+#ifdef DEBUG
+ std::cerr << __FUNCTION__ << ": reply = " << \
+ json_object_to_json_string_ext(reply, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY) << \
+ std::endl;
+#endif
+ if(data->sync) {
+ data->resp = reply;
+
+ // Increase reference count since we are going to use
+ // reply after this callback returns, caller must do a
+ // put.
+ json_object_get(reply);
+ } else if(data->cb != nullptr) {
+ data->cb(reply);
+ }
+ }
+reply_done:
+ if(data->sync) {
+ // Signal reply is done
+ {
+ std::lock_guard<std::mutex> lk(data->mutex);
+ data->ready = true;
+ }
+ data->cv.notify_one();
+ }
+}
+
+//
+// on_event_cb is inline in afbclient.h
+//
+
+static void *afb_loop_thread(struct sd_event* loop)
+{
+ for(;;)
+ sd_event_run(loop, 30000000);
+}
+
+AfbClient::AfbClient(const int port, const std::string &token)
+{
+ std::string uri;
+
+ if(sd_event_new(&m_afb_loop) < 0) {
+ std::cerr << __FUNCTION__ << ": Failed to create event loop" << std::endl;
+ return;
+ }
+
+ // Initialize interface for websocket
+ m_itf.on_hangup = on_hangup_cb;
+ m_itf.on_call = on_call_cb;
+ m_itf.on_event = on_event_cb;
+
+ uri = "ws://localhost:" + std::to_string(port) + "/api?token=" + token;
+#ifdef DEBUG
+ std::cerr << "Using URI: " << uri << std::endl;
+#endif
+ m_ws = afb_ws_client_connect_wsj1(m_afb_loop, uri.c_str(), &m_itf, this);
+ if(m_ws) {
+ m_afb_thread = std::thread(afb_loop_thread, m_afb_loop);
+ } else {
+ std::cerr << __FUNCTION__ << ": Failed to create websocket connection" << std::endl;
+ goto error;
+ }
+
+ m_valid = true;
+ return;
+error:
+ if(m_afb_loop) {
+ sd_event_unref(m_afb_loop);
+ m_afb_loop = nullptr;
+ }
+ return;
+}
+
+AfbClient::~AfbClient(void)
+{
+ sd_event_unref(m_afb_loop);
+ afb_wsj1_unref(m_ws);
+}
+
+int AfbClient::call(const std::string &api, const std::string &verb, struct json_object *arg, reply_callback_fn cb)
+{
+ if(!m_valid)
+ return -1;
+
+ call_data data;
+ data.sync = false;
+ data.cb = cb;
+ int rc = afb_wsj1_call_j(m_ws, api.c_str(), verb.c_str(), arg, on_reply_cb, (void*) &data);
+ if(rc < 0) {
+ std::cerr << __FUNCTION__ << \
+ ": Failed to call " << \
+ api.c_str() << \
+ "/" << \
+ verb.c_str() << \
+ std::endl;
+ }
+ return rc;
+}
+
+int AfbClient::call_sync(const std::string &api, const std::string &verb, struct json_object *arg, struct json_object **resp)
+{
+ if(!m_valid)
+ return -1;
+
+ call_data data;
+ data.sync = true;
+ data.ready = false;
+ data.cb = nullptr;
+ int rc = afb_wsj1_call_j(m_ws, api.c_str(), verb.c_str(), arg, on_reply_cb, (void*) &data);
+ if(rc >= 0) {
+ // Wait for response
+ std::unique_lock<std::mutex> lk(data.mutex);
+ data.cv.wait(lk, [&]{ return data.ready; });
+
+ if(resp)
+ *resp = data.resp;
+ else
+ json_object_put(data.resp);
+ } else {
+ std::cerr << __FUNCTION__ << \
+ ": Failed to call " << \
+ api.c_str() << \
+ "/" << \
+ verb.c_str() << \
+ std::endl;
+ }
+ return rc;
+}
+
+// subscribe call for simple forms like { "event": "foo" } or { "signal": "foo" }
+int AfbClient::subscribe(const std::string &api, const std::string &event, const std::string &eventValueString)
+{
+ if(!m_valid)
+ return -1;
+
+ struct json_object *j_obj = json_object_new_object();
+ json_object_object_add(j_obj, eventValueString.c_str(), json_object_new_string(event.c_str()));
+ return call_sync(api, std::string("subscribe"), j_obj);
+}
+
+// subscribe call allowing passing in complete json_object for argument, for subscribing with e.g. arrays
+int AfbClient::subscribe(const std::string &api, json_object *j_obj, const std::string &subscribeValueString)
+{
+ if(!m_valid || j_obj == nullptr)
+ return -1;
+
+ return call_sync(api, subscribeValueString, j_obj);
+}
+
+// unsubscribe call for simple forms like { "event": "foo" } or { "signal": "foo" }
+int AfbClient::unsubscribe(const std::string &api, const std::string &event, const std::string &eventValueString)
+{
+ if(!m_valid)
+ return -1;
+
+ struct json_object *j_obj = json_object_new_object();
+ json_object_object_add(j_obj, eventValueString.c_str(), json_object_new_string(event.c_str()));
+ return call_sync(api, std::string("unsubscribe"), j_obj);
+}
+
+// unsubscribe call allowing passing in complete json_object for argument, for unsubscribing with e.g. arrays
+int AfbClient::unsubscribe(const std::string &api, json_object *j_obj, const std::string &unsubscribeValueString)
+{
+ if(!m_valid || j_obj == nullptr)
+ return -1;
+
+ return call_sync(api, unsubscribeValueString, j_obj);
+}
+
+void AfbClient::set_event_callback(event_callback_fn cb, void *closure)
+{
+ m_event_cb = cb;
+ m_event_cb_closure = closure;
+}
+
+void AfbClient::on_event(const char* event, struct afb_wsj1_msg *msg)
+{
+ if(m_event_cb == nullptr)
+ return;
+
+ struct json_object *contents = afb_wsj1_msg_object_j(msg);
+#ifdef DEBUG
+ std::cerr << __FUNCTION__ << ": contents = " << \
+ json_object_to_json_string_ext(contents, JSON_C_TO_STRING_SPACED | JSON_C_TO_STRING_PRETTY) << \
+ std::endl;
+#endif
+ struct json_object *data;
+ if(json_object_object_get_ex(contents, "data", &data)) {
+ m_event_cb(event, data, m_event_cb_closure);
+ }
+}
diff --git a/app/afbclient.h b/app/afbclient.h
new file mode 100644
index 0000000..596a43f
--- /dev/null
+++ b/app/afbclient.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019,2020 Konsulko Group
+ *
+ * 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.
+ */
+
+#ifndef AFBCLIENT_H
+#define AFBCLIENT_H
+
+#include <string>
+#include <thread>
+#include <map>
+#include <functional>
+#include <systemd/sd-event.h>
+#include <json-c/json.h>
+
+extern "C"
+{
+#include <afb/afb-wsj1.h>
+#include <afb/afb-ws-client.h>
+}
+
+class AfbClient
+{
+public:
+ AfbClient(int port, const std::string &token);
+ ~AfbClient();
+
+ using reply_callback_fn = std::function<void(json_object*)>;
+ using event_callback_fn = std::function<void(const char*, json_object*, void*)>;
+
+ int call(const std::string &api, const std::string &verb, struct json_object* arg, reply_callback_fn cb = nullptr);
+ int call_sync(const std::string &api, const std::string &verb, struct json_object* arg, struct json_object **resp = NULL);
+ int subscribe(const std::string &api, const std::string &event, const std::string &eventValueString = "event");
+ int subscribe(const std::string &api, json_object *j_obj, const std::string &subscribeValueString = "subscribe");
+ int unsubscribe(const std::string &api, const std::string &eventString, const std::string &eventValueString = "event");
+ int unsubscribe(const std::string &api, json_object *j_obj, const std::string &unsubscribeValueString = "unsubscribe");
+ void set_event_callback(event_callback_fn cb, void *closure);
+
+ static void on_event_cb(void *closure, const char* event, struct afb_wsj1_msg *msg) {
+ if(closure)
+ static_cast<AfbClient*>(closure)->on_event(event, msg);
+ }
+
+private:
+ struct afb_wsj1 *m_ws = nullptr;
+ struct afb_wsj1_itf m_itf;
+ std::thread m_afb_thread;
+ sd_event *m_afb_loop = nullptr;
+ bool m_valid = false;
+ event_callback_fn m_event_cb = nullptr;
+ void *m_event_cb_closure = nullptr;
+
+ void on_event(const char* event, struct afb_wsj1_msg *msg);
+};
+
+#endif // AFBCLIENT_H
diff --git a/app/alexa-viewer.qrc b/app/alexa-viewer.qrc
new file mode 100644
index 0000000..e039215
--- /dev/null
+++ b/app/alexa-viewer.qrc
@@ -0,0 +1,7 @@
+<RCC>
+ <qresource prefix="/">
+ <file>Main.qml</file>
+ <file>BodyTemplateDialog.qml</file>
+ <file>WeatherTemplateDialog.qml</file>
+ </qresource>
+</RCC>
diff --git a/app/main.cpp b/app/main.cpp
new file mode 100644
index 0000000..669341e
--- /dev/null
+++ b/app/main.cpp
@@ -0,0 +1,207 @@
+/*
+ * Copyright (C) 2016 The Qt Company Ltd.
+ * Copyright (C) 2020 Konsulko Group
+ *
+ * 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.
+ */
+
+#include <QtCore/QDebug>
+#include <QtCore/QCommandLineParser>
+#include <QtCore/QUrlQuery>
+#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlApplicationEngine>
+#include <QtQml/QQmlContext>
+#include <QtQml/qqml.h>
+#include <QQuickWindow>
+#include <QtQuickControls2/QQuickStyle>
+
+#include <json-c/json.h>
+#include <qlibwindowmanager.h>
+#include <qlibhomescreen.h>
+#include <guimetadata.h>
+#include "afbclient.h"
+#include <iostream>
+
+// Disable window activation at launch by default, but keep option
+// for potential debug use.
+#define HIDE_AT_LAUNCH
+
+bool check_template_supported(json_object *data)
+{
+ json_object *jtype = NULL;
+ json_object_object_get_ex(data, "type", &jtype);
+ if(!jtype) {
+ qWarning("render_template event missing type element");
+ return false;
+ }
+ const char *type_value = json_object_get_string(jtype);
+ if(!type_value) {
+ qWarning("render_template event type element not parsed");
+ return false;
+ }
+ // We only handle BodyTemplate[12] and WeatherTemplate, ignore
+ // others
+ if(!(strcmp(type_value, "BodyTemplate1") &&
+ strcmp(type_value, "BodyTemplate2") &&
+ strcmp(type_value, "WeatherTemplate")))
+ return true;
+
+ return false;
+}
+
+void async_event_cb(const char *event, json_object *data, void *closure)
+{
+ if(!data)
+ return;
+
+ if(!strcmp(event, "vshl-capabilities/setDestination")) {
+ // Slight hack here, there's currently no convenient place to hook up raising
+ // the navigation app when a route is set by Alexa, so do so here for now.
+ if(closure != nullptr) {
+ static_cast<QLibHomeScreen*>(closure)->showWindow("navigation", "normal");
+ }
+ } else if(!strcmp(event, "vshl-capabilities/render_template")) {
+ // Raise ourselves, the UI code will receive the event as well and render it
+ if(closure != nullptr) {
+ if(!check_template_supported(data)) {
+ qDebug() << "Unsupported template type, ignoring!";
+ return;
+ }
+ static_cast<QLibHomeScreen*>(closure)->showWindow("alexa-viewer", "on_screen");
+ }
+ } else if(!strcmp(event, "vshl-capabilities/clear_template")) {
+ // Hide ourselves
+ if(closure != nullptr) {
+ static_cast<QLibHomeScreen*>(closure)->hideWindow("alexa-viewer");
+ }
+ }
+}
+
+void subscribe_async_events(AfbClient &client)
+{
+ const char *vshl_capabilities_nav_events[] = {
+ "setDestination",
+ NULL,
+ };
+ const char **tmp = vshl_capabilities_nav_events;
+ json_object *args = json_object_new_object();
+ json_object *actions = json_object_new_array();
+ while (*tmp) {
+ json_object_array_add(actions, json_object_new_string(*tmp++));
+ }
+ json_object_object_add(args, "actions", actions);
+ if(json_object_array_length(actions)) {
+ client.subscribe("vshl-capabilities", args, "navigation/subscribe");
+ } else {
+ json_object_put(args);
+ }
+
+ // NOTE: Not subscribing to "clear_template", as it will be passed to
+ // the app QML to handle by the libqtappfw wrapper.
+ const char *vshl_capabilities_guimetadata_events[] = {
+ "render_template",
+ NULL,
+ };
+ tmp = vshl_capabilities_guimetadata_events;
+ args = json_object_new_object();
+ actions = json_object_new_array();
+ while (*tmp) {
+ json_object_array_add(actions, json_object_new_string(*tmp++));
+ }
+ json_object_object_add(args, "actions", actions);
+ if(json_object_array_length(actions)) {
+ client.subscribe("vshl-capabilities", args, "guimetadata/subscribe");
+ } else {
+ json_object_put(args);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ QString graphic_role = QString("on_screen");
+
+ QGuiApplication app(argc, argv);
+
+ QCommandLineParser parser;
+ parser.addPositionalArgument("port", app.translate("main", "port for binding"));
+ parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.process(app);
+ QStringList positionalArguments = parser.positionalArguments();
+ QUrl bindingAddress;
+
+ int port = 0;
+ QString token;
+ if (positionalArguments.length() == 2) {
+ port = positionalArguments.takeFirst().toInt();
+ token = positionalArguments.takeFirst();
+ bindingAddress.setScheme(QStringLiteral("ws"));
+ bindingAddress.setHost(QStringLiteral("localhost"));
+ bindingAddress.setPort(port);
+ bindingAddress.setPath(QStringLiteral("/api"));
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("token"), token);
+ bindingAddress.setQuery(query);
+ }
+
+ // QLibWM
+ QLibWindowmanager* qwmHandler = new QLibWindowmanager();
+ int res;
+ if((res = qwmHandler->init(port, token)) != 0){
+ qCritical("init qlibwm err(%d)", res);
+ return -1;
+ }
+ if((res = qwmHandler->requestSurface(graphic_role)) != 0) {
+ qCritical("requestSurface error(%d)", res);
+ return -1;
+ }
+ qwmHandler->set_event_handler(QLibWindowmanager::Event_SyncDraw,
+ [qwmHandler, &graphic_role](json_object *object) {
+ qwmHandler->endDraw(graphic_role);
+ });
+
+ // QLibHS
+ QLibHomeScreen* qhsHandler = new QLibHomeScreen();
+ qhsHandler->init(port, token.toStdString().c_str());
+ qhsHandler->set_event_handler(QLibHomeScreen::Event_ShowWindow,
+ [qwmHandler, &graphic_role](json_object *object){
+ qDebug("Surface %s got showWindow\n", graphic_role.toStdString().c_str());
+ qwmHandler->activateWindow(graphic_role, "on_screen");
+ });
+ qhsHandler->set_event_handler(QLibHomeScreen::Event_HideWindow,
+ [qwmHandler, &graphic_role](json_object *object){
+ qDebug("Surface %s got hideWindow\n", graphic_role.toStdString().c_str());
+ qwmHandler->deactivateWindow(graphic_role);
+ });
+
+ // Load qml
+ QQmlApplicationEngine engine;
+ QQmlContext *context = engine.rootContext();
+
+ context->setContextProperty("homescreen", qhsHandler);
+ context->setContextProperty("GuiMetadata", new GuiMetadata(bindingAddress, context));
+ engine.load(QUrl(QStringLiteral("qrc:/Main.qml")));
+
+#ifndef HIDE_AT_LAUNCH
+ QObject *root = engine.rootObjects().first();
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
+ QObject::connect(window, SIGNAL(frameSwapped()), qwmHandler, SLOT(slotActivateWindow()));
+#endif
+ // Create app framework client to handle events when window is not visible
+ AfbClient client(port, token.toStdString());
+ client.set_event_callback(async_event_cb, (void*) qhsHandler);
+ subscribe_async_events(client);
+
+ return app.exec();
+}
diff --git a/autobuild/agl/autobuild b/autobuild/agl/autobuild
new file mode 100755
index 0000000..b306eb0
--- /dev/null
+++ b/autobuild/agl/autobuild
@@ -0,0 +1,65 @@
+#!/usr/bin/make -f
+# Copyright (C) 2015 - 2018 "IoT.bzh"
+# Author "Romain Forlot" <romain.forlot@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.
+
+THISFILE := $(lastword $(MAKEFILE_LIST))
+BUILD_DIR := $(abspath $(dir $(THISFILE))/../../build)
+DEST := ${BUILD_DIR}
+
+.PHONY: all clean distclean configure build package help update
+
+all: help
+
+help:
+ @echo "List of targets available:"
+ @echo ""
+ @echo "- all"
+ @echo "- clean"
+ @echo "- distclean"
+ @echo "- configure"
+ @echo "- build: compilation, link and prepare files for package into a widget"
+ @echo "- package: output a widget file '*.wgt'"
+ @echo "- install: install in your ${CMAKE_INSTALL_DIR} directory"
+ @echo ""
+ @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"
+
+clean:
+ @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} ${CLEAN_ARGS} clean) || echo Nothing to clean
+
+distclean:
+ @rm -rf ${BUILD_DIR}
+
+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
+
+package: 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
+ @if [ "${DEST}" != "${BUILD_DIR}" ]; then \
+ mkdir -p ${DEST} && cp ${BUILD_DIR}/*.wgt ${DEST}; \
+ fi
+
+install: build
+ @cmake --build ${BUILD_DIR} ${INSTALL_ARGS} --target install
+
diff --git a/autobuild/linux/autobuild b/autobuild/linux/autobuild
new file mode 100755
index 0000000..035db15
--- /dev/null
+++ b/autobuild/linux/autobuild
@@ -0,0 +1,67 @@
+#!/usr/bin/make -f
+# Copyright (C) 2015, 2016 "IoT.bzh"
+# Author "Romain Forlot" <romain.forlot@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.
+
+THISFILE := $(lastword $(MAKEFILE_LIST))
+BUILD_DIR := $(abspath $(dir $(THISFILE))/../../build)
+DEST := ${BUILD_DIR}/target
+
+.PHONY: all clean distclean configure build package help update
+
+all: help
+
+help:
+ @echo "List of targets available:"
+ @echo ""
+ @echo "- all"
+ @echo "- clean"
+ @echo "- distclean"
+ @echo "- configure"
+ @echo "- build: compilation, link and prepare files for package into a widget"
+ @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 "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
+
+distclean:
+ @rm -rf ${BUILD_DIR}
+
+configure: ${BUILD_DIR}/Makefile
+
+build: configure
+ @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all
+
+package: 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}/$@/data
+ @cmake --build ${BUILD_DIR} --target widget
+ @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST}
+
+install: build
+ @cmake --build ${BUILD_DIR} --target install
+
+${BUILD_DIR}/Makefile:
+ @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR}
+ @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..)
diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake
new file mode 100644
index 0000000..5f1790e
--- /dev/null
+++ b/conf.d/cmake/config.cmake
@@ -0,0 +1,204 @@
+###########################################################################
+# Copyright 2015-2018 IoT.bzh
+# Copyright 2019,2020 Konsulko Group
+#
+# author: Fulup Ar Foll <fulup@iot.bzh>
+# alexa-viewer: Scott Murray <scott.murray@konsulko.com>
+#
+# 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.
+###########################################################################
+
+# Project Info
+# ------------------
+set(PROJECT_NAME alexa-viewer)
+set(PROJECT_PRETTY_NAME "Alexa Viewer")
+set(PROJECT_DESCRIPTION "Alexa viewer demo application")
+set(PROJECT_URL "https://gerrit.automotivelinux.org/gerrit/apps/alexa-viewer")
+set(PROJECT_VERSION "1.0")
+set(PROJECT_ICON "icon.png")
+set(PROJECT_AUTHOR "Scott Murray")
+set(PROJECT_AUTHOR_MAIL "scott.murray@konsulko.com")
+set(PROJECT_LICENSE "APL2.0")
+set(PROJECT_LANGUAGES "CXX")
+
+# Where are stored the project configuration files
+# relative to the root project directory
+set(PROJECT_CMAKE_CONF_DIR "conf.d")
+
+# Where are stored your external libraries for your project. This is 3rd party library that you don't maintain
+# but used and must be built and linked.
+# set(PROJECT_LIBDIR "libs")
+
+# Which directories inspect to find CMakeLists.txt target files
+# set(PROJECT_SRC_DIR_PATTERN "*")
+
+# Compilation Mode (DEBUG, RELEASE)
+# ----------------------------------
+#set(CMAKE_BUILD_TYPE "DEBUG")
+set(USE_EFENCE 1)
+
+# Kernel selection if needed. You can choose between a
+# mandatory version to impose a minimal version.
+# Or check Kernel minimal version and just print a Warning
+# about missing features and define a preprocessor variable
+# to be used as preprocessor condition in code to disable
+# incompatibles features. Preprocessor define is named
+# KERNEL_MINIMAL_VERSION_OK.
+#
+# NOTE*** FOR NOW IT CHECKS KERNEL Yocto environment and
+# Yocto SDK Kernel version.
+# -----------------------------------------------
+#set (kernel_mandatory_version 4.8)
+#set (kernel_minimal_version 4.8)
+
+# Compiler selection if needed. Impose a minimal version.
+# -----------------------------------------------
+set (gcc_minimal_version 4.9)
+
+# PKG_CONFIG required packages
+# -----------------------------
+set (PKG_REQUIRED_LIST
+ json-c
+ afb-daemon
+)
+
+# Prefix path where will be installed the files
+# Default: /usr/local (need root permission to write in)
+# ------------------------------------------------------
+#set(CMAKE_INSTALL_PREFIX $ENV{HOME}/opt)
+
+# Customize link option
+# -----------------------------
+#list(APPEND link_libraries -an-option)
+
+# Compilation options definition
+# Use CMake generator expressions to specify only for a specific language
+# Values are prefilled with default options that is currently used.
+# Either separate options with ";", or each options must be quoted separately
+# DO NOT PUT ALL OPTION QUOTED AT ONCE , COMPILATION COULD FAILED !
+# ----------------------------------------------------------------------------
+#set(COMPILE_OPTIONS
+# -Wall
+# -Wextra
+# -Wconversion
+# -Wno-unused-parameter
+# -Wno-sign-compare
+# -Wno-sign-conversion
+# -Werror=maybe-uninitialized
+# -Werror=implicit-function-declaration
+# -ffunction-sections
+# -fdata-sections
+# -fPIC
+# CACHE STRING "Compilation flags")
+#set(C_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C language.")
+#set(CXX_COMPILE_OPTIONS "" CACHE STRING "Compilation flags for C++ language.")
+#set(PROFILING_COMPILE_OPTIONS
+# -g
+# -O0
+# -pg
+# -Wp,-U_FORTIFY_SOURCE
+# CACHE STRING "Compilation flags for PROFILING build type.")
+#set(DEBUG_COMPILE_OPTIONS
+# -g
+# -ggdb
+# -Wp,-U_FORTIFY_SOURCE
+# CACHE STRING "Compilation flags for DEBUG build type.")
+#set(CCOV_COMPILE_OPTIONS
+# -g
+# -O2
+# --coverage
+# CACHE STRING "Compilation flags for CCOV build type.")
+#set(RELEASE_COMPILE_OPTIONS
+# -g
+# -O2
+# CACHE STRING "Compilation flags for RELEASE build type.")
+
+# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable]
+# ---------------------------------------------------------------------
+set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig)
+set(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib)
+
+# Optional location for config.xml.in
+# -----------------------------------
+#set(WIDGET_ICON "\"conf.d/wgt/${PROJECT_ICON}\"" CACHE PATH "Path to the widget icon")
+set(WIDGET_CONFIG_TEMPLATE "${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/config.xml.in" CACHE PATH "Path to widget config file template (config.xml.in)")
+
+# Mandatory widget Mimetype specification of the main unit
+# --------------------------------------------------------------------------
+# Choose between :
+#- text/html : HTML application,
+# content.src designates the home page of the application
+#
+#- application/vnd.agl.native : AGL compatible native,
+# content.src designates the relative path of the binary.
+#
+# - application/vnd.agl.service: AGL service, content.src is not used.
+#
+#- ***application/x-executable***: Native application,
+# content.src designates the relative path of the binary.
+# For such application, only security setup is made.
+#
+set(WIDGET_TYPE application/vnd.agl.native)
+
+# Mandatory Widget entry point file of the main unit
+# --------------------------------------------------------------
+# This is the file that will be executed, loaded,
+# at launch time by the application framework.
+#
+set(WIDGET_ENTRY_POINT bin/alexa-viewer)
+
+# Optional dependencies order
+# ---------------------------
+#set(EXTRA_DEPENDENCIES_ORDER)
+
+# Optional Extra global include path
+# -----------------------------------
+#set(EXTRA_INCLUDE_DIRS)
+
+# Optional extra libraries
+# -------------------------
+#set(EXTRA_LINK_LIBRARIES)
+
+# Optional force binding Linking flag
+# ------------------------------------
+# set(BINDINGS_LINK_FLAG LinkOptions )
+
+# Optional force package prefix generation, like widget
+# -----------------------------------------------------
+# set(PKG_PREFIX DestinationPath)
+
+# Optional Application Framework security token
+# and port use for remote debugging.
+#------------------------------------------------------------
+set(AFB_TOKEN "" CACHE PATH "Default binder security token")
+set(AFB_REMPORT "1234" CACHE PATH "Default binder listening port")
+
+# Print a helper message when every thing is finished
+# ----------------------------------------------------
+set(CLOSING_MESSAGE "Typical binding launch: afb-daemon --port=${AFB_REMPORT} --workdir=${CMAKE_BINARY_DIR}/package --ldpaths=lib --roothttp=htdocs --token=\"${AFB_TOKEN}\" --tracereq=common --verbose")
+set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt")
+
+# Optional schema validator about now only XML, LUA and JSON
+# are supported
+#------------------------------------------------------------
+#set(LUA_CHECKER "luac" "-p" CACHE STRING "LUA compiler")
+#set(XML_CHECKER "xmllint" CACHE STRING "XML linter")
+#set(JSON_CHECKER "json_verify" CACHE STRING "JSON linter")
+
+# This include is mandatory and MUST happens at the end
+# of this file, else you expose you to unexpected behavior
+#
+# This CMake module could be found at the following url:
+# https://gerrit.automotivelinux.org/gerrit/#/admin/projects/src/cmake-apps-module
+# -----------------------------------------------------------
+include(CMakeAfbTemplates)
diff --git a/conf.d/wgt/config.xml.in b/conf.d/wgt/config.xml.in
new file mode 100644
index 0000000..a374f28
--- /dev/null
+++ b/conf.d/wgt/config.xml.in
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<widget xmlns="http://www.w3.org/ns/widgets" id="@PROJECT_NAME@" version="@PROJECT_VERSION@">
+ <name>@PROJECT_NAME@</name>
+ <icon src="@PROJECT_ICON@"/>
+ <content src="@WIDGET_ENTRY_POINT@" type="@WIDGET_TYPE@"/>
+ <description>@PROJECT_DESCRIPTION@</description>
+ <author>@PROJECT_AUTHOR@ &lt;@PROJECT_AUTHOR_MAIL@&gt;</author>
+ <license>@PROJECT_LICENSE@</license>
+ <feature name="urn:AGL:widget:required-api">
+ <param name="windowmanager" value="ws" />
+ <param name="homescreen" value="ws" />
+ <param name="vshl-capabilities" value="ws" />
+ <param name="signal-composer" value="ws" />
+ </feature>
+ <feature name="urn:AGL:widget:required-permission">
+ <param name="urn:AGL:permission::public:display" value="required" />
+ <param name="urn:AGL:permission::public:no-htdocs" value="required" />
+ <param name="urn:AGL:permission::system:run-by-default" value="required" />
+ <param name="urn:AGL:permission::public:hidden" value="required" />
+ </feature>
+</widget>