summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2018-06-15 23:31:34 +0200
committerLoïc Collignon <loic.collignon@iot.bzh>2018-06-16 18:44:22 +0200
commit62bb1f0ceab710c594021c715017560f4e5f25da (patch)
treeb3a656bea2adce533b4336e246a3fd60e6b173df
parent2aabd6ae0f05d91253f492ff1659626d3090cabe (diff)
WIP version based on 4a High Level APIeel_5.1.0eel/5.1.05.1.0eel
This is a non-completly working version based on the 4a High Level API. It displays one slider per audio role, should be able to set volume on roles, but sliders are not in sync and moving a slider cause a lot of calls due to bug. Supposed to be fixed soon. Also, had to hack the autobuild script cause it make cmake to fail. Obsiously, target 'package' should run 'make widget'... Change-Id: Ic16ed484e090ebc853e59b836ff1570afdcfce3b Signed-off-by: Loïc Collignon <loic.collignon@iot.bzh>
-rw-r--r--CMakeLists.txt2
-rw-r--r--app/CMakeLists.txt7
-rw-r--r--app/Mixer.qml130
-rw-r--r--app/mixer.cpp220
-rw-r--r--app/mixer.h66
-rw-r--r--app/qafbwsclient.cpp152
-rw-r--r--app/qafbwsclient.h66
-rw-r--r--app/qafbwsmsg.cpp60
-rw-r--r--app/qafbwsmsg.h49
-rwxr-xr-xconf.d/autobuild/agl/autobuild21
-rwxr-xr-xconf.d/autobuild/linux/autobuild67
-rw-r--r--conf.d/cmake/config.cmake5
12 files changed, 204 insertions, 641 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 98f181e..8c1fc7c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,4 +18,6 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
+set(AFB_HELPERS_QTWSCLIENT ON CACHE BOOL "enable Qt's WebSocket client" FORCE)
+
include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake)
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index c40daa7..8f8bd1e 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -20,16 +20,15 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD 14)
-find_package(Qt5QuickControls2)
-find_package(Qt5WebSockets)
+find_package(Qt5 COMPONENTS Core Gui QuickControls2 WebSockets QuickWidgets REQUIRED)
+qt5_add_resources(RESOURCES Mixer.qrc)
PROJECT_TARGET_ADD(mixer)
add_executable(mixer
main.cpp
mixer.cpp
- qafbwsclient.cpp
- qafbwsmsg.cpp
+ ${RESOURCES}
)
set_target_properties(mixer PROPERTIES
diff --git a/app/Mixer.qml b/app/Mixer.qml
index 2b6d5cc..8b1ba06 100644
--- a/app/Mixer.qml
+++ b/app/Mixer.qml
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+// BUG: ValueChanged event is raised by sliders when you are moving the caret, should be raised only when you release it.
+// TODO: Call mixer.setVolume(sliderName, Value) on value change
+// TODO: Call mixer.getVolume(sliderName) on load
+
import QtQuick 2.6
import QtQuick.Layouts 1.1
import QtQuick.Controls 2.0
@@ -21,111 +25,83 @@ import AGL.Demo.Controls 1.0
import Mixer 1.0
ApplicationWindow {
- id: root
+ id: root
Mixer {
id: mixer
Component.objectName: {
mixer.open(bindingAddress)
}
- onMasterVolumeChanged: sliderMasterVolume.value = masterVolume
- onPcmVolumeChanged: sliderPcmVolume.value = pcmVolume
- onMicrophoneVolumeChanged: sliderMicrophoneVolume.value = microphoneVolume
- }
-
- Label {
- id: title
- font.pixelSize: 48
- text: "Mixer"
- anchors.horizontalCenter: parent.horizontalCenter
- }
-
- ColumnLayout {
- anchors.margins: 80
- anchors.top: title.bottom
- anchors.left: parent.left
- anchors.right: parent.right
+ onRolesChanged: {
+ // Remove existing sliders
+ for(var i = sliders.children.length; i > 0 ; --i) {
+ console.log("destroying: " + i)
+ sliders.children[i-1].destroy()
+ }
- ComboBox {
- id: soundCardSelector
- anchors.left: parent.left
- anchors.right: parent.right
- model: mixer.hals
- onCurrentIndexChanged: mixer.ActiveHal = currentIndex
+ // Add slider for each role
+ for(var j = 0; j < mixer.roles.length; ++j) {
+ addSlider(mixer.roles[j])
+ }
}
- RowLayout {
+ function addSlider(name) {
+ Qt.createQmlObject("
+import QtQuick.Layouts 1.1
+import QtQuick.Controls 2.0
+RowLayout {
+ property int value
+ id: slider_" + name + "
Layout.minimumHeight: 75
Label {
font.pixelSize: 24
- text: "Master"
+ text: \"" + name+ "\"
Layout.minimumWidth: 150
}
Label {
- id: textMasterVolume
+ id: slider_" + name + "_textvalue
font.pixelSize: 24
- text: "0 %"
+ text: \"0 %\"
}
Slider {
- id: sliderMasterVolume
+ id: slider_" + name + "_slider
Layout.fillWidth: true
from: 0
to: 100
stepSize: 1
snapMode: Slider.SnapOnRelease
onValueChanged: {
- textMasterVolume.text = value + " %"
- mixer.masterVolume = value
+ slider_" + name + "_textvalue.text = value + \" %\"
+ mixer.setVolume(\"" + name + "\", value)
+ }
+ Component.objectName: {
+ mixer.getVolume(\"" + name + "\")
}
}
+ }", sliders, "volumeslider")
}
-/*
- RowLayout {
- Layout.minimumHeight: 75
- Label {
- font.pixelSize: 24
- text: "PCM"
- Layout.minimumWidth: 150
- }
- Label {
- font.pixelSize: 24
- text: "0 %"
- }
- Slider {
- id: sliderPcmVolume
- Layout.fillWidth: true
- from: 0
- to: 100
- stepSize: 1
- snapMode: Slider.SnapOnRelease
- onValueChanged: mixer.pcmVolume = value
- }
- }
-*/
- RowLayout {
- Layout.minimumHeight: 75
- Label {
- font.pixelSize: 24
- text: "Microphone"
- Layout.minimumWidth: 150
- }
- Label {
- id: textMicrophoneVolume
- font.pixelSize: 24
- text: "0 %"
- }
- Slider {
- id: sliderMicrophoneVolume
- Layout.fillWidth: true
- from: 0
- to: 100
- stepSize: 1
- snapMode: Slider.SnapOnRelease
- onValueChanged: {
- textMicrophoneVolume.text = value + " %"
- mixer.microphoneVolume = value
- }
+
+ function deleteChilds(item) {
+ for(var i = item.children.length; i > 0 ; i--) {
+ deleteChilds(item.children[i-1])
}
+ item.destroy()
}
}
+
+ Label {
+ id: title
+ font.pixelSize: 48
+ text: "Mixer"
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ ColumnLayout {
+ id: sliders
+ anchors.margins: 80
+ anchors.top: title.bottom
+ anchors.left: parent.left
+ anchors.right: parent.right
+ }
}
+
diff --git a/app/mixer.cpp b/app/mixer.cpp
index adaad81..6614569 100644
--- a/app/mixer.cpp
+++ b/app/mixer.cpp
@@ -23,104 +23,13 @@
Mixer::Mixer(QObject* parent)
: QObject(parent)
- , m_masterVolume{0}
- , m_pcmVolume{0}
- , m_microphoneVolume{0}
{
connect(&m_client, SIGNAL(connected()), this, SLOT(onClientConnected()));
}
-QVariantList Mixer::hals() const
+QStringList Mixer::roles() const
{
- return m_hallist;
-}
-
-int Mixer::masterVolume() const
-{
- return m_masterVolume;
-}
-
-int Mixer::pcmVolume() const
-{
- return m_pcmVolume;
-}
-
-int Mixer::microphoneVolume() const
-{
- return m_microphoneVolume;
-}
-
-void Mixer::setMasterVolume(int v)
-{
- qDebug() << "Mixer::setMasterVolume(" << v << ")";
- if (v != m_masterVolume)
- {
- m_masterVolumePending = v;
- QJsonObject arg;
- arg["label"] = "Master_Playback_Volume";
- arg["val"] = static_cast<int>(v);
- m_setMasterVolume = m_client.call(m_activeHal, "ctlset", arg);
- connect(m_setMasterVolume.data(), SIGNAL(closed()), this, SLOT(onSetMasterVolume()));
- }
-}
-
-void Mixer::setPcmVolume(int v)
-{
- qDebug() << "Mixer::setPcmVolume(" << v << ")";
- if (v != m_pcmVolume)
- {
- m_pcmVolumePending = v;
- QJsonObject arg;
- arg["label"] = "PCM_Playback_Volume";
- arg["val"] = static_cast<int>(v);
- m_setPcmVolume = m_client.call(m_activeHal, "ctlset", arg);
- connect(m_setPcmVolume.data(), SIGNAL(closed()), this, SLOT(onSetPcmVolume()));
- }
-}
-
-void Mixer::setMicrophoneVolume(int v)
-{
- qDebug() << "Mixer::setMicrophoneVolume(" << v << ")";
- if (v != m_microphoneVolume)
- {
- m_microphoneVolumePending = v;
- QJsonObject arg;
- arg["label"] = "Capture_Volume";
- arg["val"] = static_cast<int>(v);
- m_setMicrophoneVolume = m_client.call(m_activeHal, "ctlset", arg);
- connect(m_setMicrophoneVolume.data(), SIGNAL(closed()), this, SLOT(onSetMicrophoneVolume()));
- }
-}
-
-QString Mixer::activeHal() const
-{
- return m_activeHal;
-}
-
-void Mixer::setActiveHal(QString h)
-{
- if (h != m_activeHal)
- {
- m_activeHal = h;
- qDebug() << "Mixer::setActiveHal: " << h;
- // Get volumes for this card
-
- QJsonObject arg;
-
- arg["label"] = "Master_Playback_Volume";
- m_getMasterVolume = m_client.call(m_activeHal, "ctlget", arg);
- connect(m_getMasterVolume.data(), SIGNAL(closed()), this, SLOT(onGetMasterVolume()));
-
- arg["label"] = "PCM_Playback_Volume";
- m_getPcmVolume = m_client.call(m_activeHal, "ctlget", arg);
- connect(m_getPcmVolume.data(), SIGNAL(closed()), this, SLOT(onGetPcmVolume()));
-
- arg["label"] = "Capture_Volume";
- m_getMicrophoneVolume = m_client.call(m_activeHal, "ctlget", arg);
- connect(m_getMicrophoneVolume.data(), SIGNAL(closed()), this, SLOT(onGetMicrophoneVolume()));
-
- emit activeHalChanged();
- }
+ return m_roles;
}
void Mixer::open(const QUrl &url)
@@ -131,97 +40,52 @@ void Mixer::open(const QUrl &url)
void Mixer::onClientConnected()
{
// Call HAL to populate list
- m_alsacoreHallist = m_client.call("alsacore", "hallist");
- connect(m_alsacoreHallist.data(), SIGNAL(closed()), this, SLOT(onHalListClosed()));
-}
-
-void Mixer::onHalListClosed()
-{
- qDebug() << "Mixer::onHalListClosed";
- if(m_alsacoreHallist->messageType() == AfMsgType::RetOk)
- {
- m_hallist.clear();
-
- QJsonArray cards = m_alsacoreHallist->value().toObject()["response"].toArray();
- qDebug() << "Mixer::onHalListClosed - founds: " << cards;
- foreach (const QJsonValue& card, cards)
+ m_client.call("ahl-4a", "get_roles", QJsonValue(), [this](bool r, const QJsonValue& val) {
+ if (r)
{
- QJsonObject c = card.toObject();
- QVariant v(c["api"].toString());
- m_hallist.append(v);
- qDebug() << "Mixer::onHalListClosed - added this HAL: " << v;
+ m_roles.clear();
+ //BUG: should be able to add this, but not handled right now: m_roles.append("playback");
+ QJsonArray cards = val.toObject()["response"].toArray();
+ foreach (const QJsonValue& card, cards)
+ {
+ m_roles.append(card.toString());
+ qDebug() << "Mixer::onClientConnected - added this HAL: " << card.toString();
+ }
+ emit rolesChanged();
}
-
- m_alsacoreHallist.clear();
-
- setActiveHal(m_hallist[0].toString());
-
- emit halsChanged();
- }
+ });
}
-void Mixer::onGetMasterVolume()
+void Mixer::setVolume(const QString& name, int value)
{
- qDebug() << "Mixer::onGetMasterVolume()";
- disconnect(m_getMasterVolume.data(), SIGNAL(closed()), this, SLOT(onGetMasterVolume()));
- if (m_getMasterVolume->messageType() == AfMsgType::RetOk && m_getMasterVolume->value().isObject())
- {
- setMasterVolume(m_getMasterVolume->value().toObject()["response"].toObject()["val"].toArray()[0].toInt());
- }
-}
-
-void Mixer::onGetPcmVolume()
-{
- qDebug() << "Mixer::onGetPcmVolume()";
- disconnect(m_getPcmVolume.data(), SIGNAL(closed()), this, SLOT(onGetPcmVolume()));
- if (m_getPcmVolume->messageType() == AfMsgType::RetOk && m_getPcmVolume->value().isObject())
- {
- setPcmVolume(m_getPcmVolume->value().toObject()["response"].toObject()["val"].toArray()[0].toInt());
- }
-}
-
-void Mixer::onGetMicrophoneVolume()
-{
- qDebug() << "Mixer::onGetMicrophoneVolume()";
- disconnect(m_getMicrophoneVolume.data(), SIGNAL(closed()), this, SLOT(onGetMicrophoneVolume()));
- if (m_getMicrophoneVolume->messageType() == AfMsgType::RetOk && m_getMicrophoneVolume->value().isObject())
- {
- setMicrophoneVolume(m_getMicrophoneVolume->value().toObject()["response"].toObject()["val"].toArray()[0].toInt());
- }
-}
-
-void Mixer::onSetMasterVolume()
-{
- qDebug() << "Mixer::onSetMasterVolume()";
- disconnect(m_setMasterVolume.data(), SIGNAL(closed()), this, SLOT(onSetMasterVolume()));
- if (m_setMasterVolume->messageType() == AfMsgType::RetOk && m_setMasterVolume->value().isObject())
- {
- m_masterVolume = m_masterVolumePending;
- emit masterVolumeChanged();
- }
-}
-
-void Mixer::onSetPcmVolume()
-{
- qDebug() << "Mixer::onSetPcmVolume()";
- disconnect(m_setPcmVolume.data(), SIGNAL(closed()), this, SLOT(onSetPcmVolume()));
- if (m_setPcmVolume->messageType() == AfMsgType::RetOk && m_setPcmVolume->value().isObject())
- {
- m_pcmVolume = m_pcmVolumePending;
- emit pcmVolumeChanged();
- }
+ QJsonObject arg;
+ arg.insert("action", "volume");
+ arg.insert("value", QJsonValue(value));
+ m_client.call("ahl-4a", name, arg, [this, name](bool r, const QJsonValue& v) {
+ if (r && v.isObject())
+ {
+ // TODO: Success, update the slider
+ }
+ else
+ {
+ // TODO: Failed, reset the slider to previous value
+ }
+ });
}
-void Mixer::onSetMicrophoneVolume()
+void Mixer::getVolume(const QString& name)
{
- qDebug() << "Mixer::onSetMicrophoneVolume()";
- disconnect(m_setMicrophoneVolume.data(), SIGNAL(closed()), this, SLOT(onSetMicrophoneVolume()));
- if (m_setMicrophoneVolume->messageType() == AfMsgType::RetOk && m_setMicrophoneVolume->value().isObject())
- {
- m_microphoneVolume = m_microphoneVolumePending;
- qDebug() << "Mixer::onSetMicrophoneVolume() - ";
- emit microphoneVolumeChanged();
- }
+ QJsonObject arg;
+ arg.insert("action", "volume");
+ arg.insert("value", QJsonValue("+0")); // FIXME: Hack to get volume: ask for a relative change with a delta of zero
+ m_client.call("ahl-4a", name, arg, [this, name](bool r, const QJsonValue& v) {
+ if (r && v.isObject())
+ {
+ // TODO: Success, update the slider
+ }
+ else
+ {
+ // TODO: Failed, what to do ?
+ }
+ });
}
-
-
diff --git a/app/mixer.h b/app/mixer.h
index b09e1c0..a46c8a1 100644
--- a/app/mixer.h
+++ b/app/mixer.h
@@ -15,78 +15,40 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-#ifndef MIXER_H
-#define MIXER_H
+#pragma once
#include <QObject>
+#include <QString>
#include <QSharedPointer>
-#include <QVariantList>
-#include "qafbwsclient.h"
-#include "qafbwsmsg.h"
+#include <QStringList>
+#include "qafbwebsocketclient.h"
+//#include "volumeslider.h"
class Mixer
: public QObject
{
Q_OBJECT
- Q_PROPERTY(QVariantList hals READ hals NOTIFY halsChanged)
- Q_PROPERTY(QString activeHal READ activeHal WRITE setActiveHal NOTIFY activeHalChanged)
+ Q_PROPERTY(QStringList roles READ roles NOTIFY rolesChanged)
- Q_PROPERTY(int masterVolume READ masterVolume WRITE setMasterVolume NOTIFY masterVolumeChanged)
- Q_PROPERTY(int pcmVolume READ pcmVolume WRITE setPcmVolume NOTIFY pcmVolumeChanged)
- Q_PROPERTY(int microphoneVolume READ microphoneVolume WRITE setMicrophoneVolume NOTIFY microphoneVolumeChanged)
+private:
public:
explicit Mixer(QObject* parent = nullptr);
Mixer(const Mixer&) = delete;
Q_INVOKABLE void open(const QUrl& url);
- Q_INVOKABLE QVariantList hals() const;
- Q_INVOKABLE QString activeHal() const;
- Q_INVOKABLE void setActiveHal(QString h);
-
- Q_INVOKABLE int masterVolume() const;
- Q_INVOKABLE int pcmVolume() const;
- Q_INVOKABLE int microphoneVolume() const;
-
- Q_INVOKABLE void setMasterVolume(int v);
- Q_INVOKABLE void setPcmVolume(int v);
- Q_INVOKABLE void setMicrophoneVolume(int v);
+ Q_INVOKABLE QStringList roles() const;
+ Q_INVOKABLE void setVolume(const QString& name, int value);
+ Q_INVOKABLE void getVolume(const QString& name);
signals:
- void halsChanged();
- void activeHalChanged();
- void masterVolumeChanged();
- void pcmVolumeChanged();
- void microphoneVolumeChanged();
+ void rolesChanged();
+ void volumeChanged(const QString& name, int value);
private slots:
void onClientConnected();
- void onHalListClosed();
- void onGetMasterVolume();
- void onGetPcmVolume();
- void onGetMicrophoneVolume();
- void onSetMasterVolume();
- void onSetPcmVolume();
- void onSetMicrophoneVolume();
private:
- int m_masterVolume;
- int m_pcmVolume;
- int m_microphoneVolume;
- int m_masterVolumePending;
- int m_pcmVolumePending;
- int m_microphoneVolumePending;
- QAfbWsClient m_client;
- QVariantList m_hallist;
- QString m_activeHal;
- QSharedPointer<QAfbWsMsg> m_alsacoreHallist;
- QSharedPointer<QAfbWsMsg> m_getMasterVolume;
- QSharedPointer<QAfbWsMsg> m_getPcmVolume;
- QSharedPointer<QAfbWsMsg> m_getMicrophoneVolume;
- QSharedPointer<QAfbWsMsg> m_setMasterVolume;
- QSharedPointer<QAfbWsMsg> m_setPcmVolume;
- QSharedPointer<QAfbWsMsg> m_setMicrophoneVolume;
+ QStringList m_roles;
+ QAfbWebsocketClient m_client;
};
-
-#endif // MIXER_H
diff --git a/app/qafbwsclient.cpp b/app/qafbwsclient.cpp
deleted file mode 100644
index 633a66f..0000000
--- a/app/qafbwsclient.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#include "qafbwsclient.h"
-#include "qafbwsmsg.h"
-#include <QJsonDocument>
-#include <QJsonArray>
-#include <QtDebug>
-
-QAfbWsClient::QAfbWsClient(QObject* parent)
- : QObject{parent}
- , m_nextCallId{0}
-{
- connect(&m_socket, SIGNAL(connected()), this, SLOT(onSocketConnected()));
- connect(&m_socket, SIGNAL(disconnected()), this, SLOT(onSocketDisconnected()));
- connect(&m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError)));
-}
-
-QUrl QAfbWsClient::url() const
-{
- return m_socket.requestUrl();
-}
-
-QSharedPointer<QAfbWsMsg> QAfbWsClient::call(const QString& api, const QString& verb, const QJsonValue& args)
-{
- while(m_calls.constFind(m_nextCallId) != m_calls.cend()) m_nextCallId++; // Make sure that callId is not currently used
-
- qDebug() << "QAfbWsClient::call(" << api << ", " << verb << ", " << args << ")";
- QJsonArray arr;
- arr.append(static_cast<int>(AfMsgType::Call));
- arr.append(m_nextCallId);
- arr.append(api + "/" + verb);
- arr.append(args);
-
- QJsonDocument doc;
- doc.setArray(arr);
-
- QSharedPointer<QAfbWsMsg> msg(new QAfbWsMsg(m_nextCallId, api, verb));
- m_calls[m_nextCallId] = msg;
-
- // TODO: handle failure of sendTextMessage
- m_socket.sendTextMessage(doc.toJson(QJsonDocument::Compact));
- qDebug() << "m_socket.sendTextMessage(" << doc.toJson(QJsonDocument::Compact) << ")";
-
- m_nextCallId++;
-
- return msg;
-}
-
-void QAfbWsClient::onSocketConnected()
-{
- qDebug() << "QAfbWsClient::onSocketConnected()";
- connect(&m_socket, SIGNAL(textMessageReceived(QString)), this, SLOT(onSocketTextMessageReceived(QString)));
- emit connected();
-}
-
-void QAfbWsClient::onSocketDisconnected()
-{
- qDebug() << "QAfbWsClient::onSocketDisconnected()";
- m_nextCallId = 0;
- disconnect(&m_socket, SIGNAL(textMessageReceived(QString)), this, SLOT(onSocketTextMessageReceived(QString)));
- emit disconnected();
-}
-
-void QAfbWsClient::onSocketError(QAbstractSocket::SocketError err)
-{
- qDebug() << "QAfbWsClient::onSocketError(" << err << ")";
- emit error(err, m_socket.errorString());
-}
-
-void QAfbWsClient::onSocketTextMessageReceived(QString msg)
-{
- qDebug() << "QAfbWsClient::onSocketTextMessageReceived(" << msg << ")";
-
- if (msg.size() == 0)
- {
- qCritical() << "QAfbWsClient::onSocketTextMessageReceived: received an empty message.";
- return;
- }
-
- QJsonDocument doc = QJsonDocument::fromJson(msg.toUtf8());
- if (doc.isEmpty() || doc.isNull() || !doc.isArray())
- {
- qCritical() << "QAfbWsClient::onSocketTextMessageReceived: received an invalid message.";
- return;
- }
-
- QJsonArray arr = doc.array();
- AfMsgType msgType = static_cast<AfMsgType>(arr[0].toInt());
- int callId = arr[1].isString() ? arr[1].toString().toInt() : arr[1].toInt();
- QString api;
- QJsonValue value;
-
- switch(msgType)
- {
- case AfMsgType::Call:
- qCritical() << "QAfbWsClient::onSocketTextMessageReceived: Client received a call, which should not happen.";
- break;
-
- case AfMsgType::Event:
- qDebug() << "QAfbWsClient::onSocketTextMessageReceived: Client received an event.";
- // TODO: handle events
- value = arr[3];
- break;
-
- case AfMsgType::RetOk:
- case AfMsgType::RetErr:
- {
- value = arr[2];
- QMap<int, QSharedPointer<QAfbWsMsg>>::const_iterator it = m_calls.find(callId);
- if (it == m_calls.end())
- {
- qCritical() << "QAfbWsClient::onSocketTextMessageReceived: received a response to a not found query.";
- return;
- }
-
- QSharedPointer<QAfbWsMsg> m = *it;
- m_calls.remove(callId);
- m->close(msgType, value);
- }
- break;
-
- default:
- qCritical() << "QAfbWsClient::onSocketTextMessageReceived: Client received an unsupported message.";
- break;
- }
-}
-
-void QAfbWsClient::open(const QUrl& url)
-{
- qDebug() << "QAfbWsClient::open(" << url << ")";
- m_socket.open(url);
-}
-
-void QAfbWsClient::close()
-{
- qDebug() << "QAfbWsClient::close()";
- m_socket.close();
-}
diff --git a/app/qafbwsclient.h b/app/qafbwsclient.h
deleted file mode 100644
index ac458b7..0000000
--- a/app/qafbwsclient.h
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#ifndef QAFBWSCLIENT_H
-#define QAFBWSCLIENT_H
-
-#include <QObject>
-#include <QMap>
-#include <QSharedPointer>
-#include <QWebSocket>
-#include <QJsonValue>
-
-enum class AfMsgType
- : int
-{
- Call = 2,
- RetOk = 3,
- RetErr = 4,
- Event = 5
-};
-
-class QAfbWsMsg;
-
-class QAfbWsClient
- : public QObject
-{
- Q_OBJECT
-public:
- explicit QAfbWsClient(QObject* parent = nullptr);
-
- void open(const QUrl& url);
- void close();
- QUrl url() const;
- QSharedPointer<QAfbWsMsg> call(const QString &api, const QString &verb, const QJsonValue &args = QJsonValue());
-
-signals:
- void connected();
- void disconnected();
- void error(QAbstractSocket::SocketError err, QString errStr);
-
-private slots:
- void onSocketConnected();
- void onSocketDisconnected();
- void onSocketError(QAbstractSocket::SocketError err);
- void onSocketTextMessageReceived(QString msg);
-
-private:
- int m_nextCallId;
- QWebSocket m_socket;
- QMap<int, QSharedPointer<QAfbWsMsg>> m_calls;
-};
-
-#endif // QAFBWSCLIENT_H
diff --git a/app/qafbwsmsg.cpp b/app/qafbwsmsg.cpp
deleted file mode 100644
index 44d0f1b..0000000
--- a/app/qafbwsmsg.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#include "qafbwsmsg.h"
-
-QAfbWsMsg::QAfbWsMsg(int callId, const QString& api, const QString& verb, QObject* parent)
- : QObject{parent}
- , m_callId{callId}
-{
- m_api = api;
- m_verb = verb;
-}
-
-void QAfbWsMsg::close(AfMsgType type, const QJsonValue& result)
-{
- m_type = type;
- m_value = result;
-
- qDebug() << "QAfbWsMsg::close: type=" << static_cast<int>(m_type) << ", api=" << m_api << ", verb=" << m_verb << ", value=" << m_value;
-
- emit closed();
-}
-
-int QAfbWsMsg::callId() const
-{
- return m_callId;
-}
-
-AfMsgType QAfbWsMsg::messageType() const
-{
- return m_type;
-}
-
-QString QAfbWsMsg::api() const
-{
- return m_api;
-}
-
-QString QAfbWsMsg::verb() const
-{
- return m_verb;
-}
-
-QJsonValue QAfbWsMsg::value() const
-{
- return m_value;
-}
diff --git a/app/qafbwsmsg.h b/app/qafbwsmsg.h
deleted file mode 100644
index 1ad9298..0000000
--- a/app/qafbwsmsg.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#ifndef QAFBWSMSG_H
-#define QAFBWSMSG_H
-
-#include <QObject>
-#include <QJsonValue>
-#include "qafbwsclient.h"
-
-class QAfbWsMsg
- : public QObject
-{
- Q_OBJECT
-public:
- explicit QAfbWsMsg(int callId = 0, const QString& api = "", const QString& verb = "", QObject* parent = nullptr);
- void close(AfMsgType type, const QJsonValue& result);
-
- int callId() const;
- AfMsgType messageType() const;
- QString api() const;
- QString verb() const;
- QJsonValue value() const;
-
-signals:
- void closed();
-
-private:
- int m_callId;
- AfMsgType m_type;
- QString m_api;
- QString m_verb;
- QJsonValue m_value;
-};
-
-#endif // QAFBWSMSG_H
diff --git a/conf.d/autobuild/agl/autobuild b/conf.d/autobuild/agl/autobuild
new file mode 100755
index 0000000..ea352e7
--- /dev/null
+++ b/conf.d/autobuild/agl/autobuild
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/../../../"
+BUILD_DIR=$( echo "$2" | cut -d'=' -f2 )
+
+# HACK: alias should be expanded in script for cmake to work properly
+shopt -s expand_aliases
+# HACK: source again the SDK because of the alias
+source $SDKTARGETSYSROOT/../../environment-setup-*
+
+pushd $BUILD_DIR
+
+ cmake $SOURCE_DIR
+ make
+
+ if [ "$1" == "package" ]; then
+ make widget
+ fi
+
+popd
+
diff --git a/conf.d/autobuild/linux/autobuild b/conf.d/autobuild/linux/autobuild
new file mode 100755
index 0000000..3a1ba5f
--- /dev/null
+++ b/conf.d/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
index cbe3878..03bf212 100644
--- a/conf.d/cmake/config.cmake
+++ b/conf.d/cmake/config.cmake
@@ -68,9 +68,8 @@ set (PKG_REQUIRED_LIST
json-c
libsystemd>=222
afb-daemon
- libmicrohttpd>=0.9.55
- libhomescreen
- qlibwindowmanager
+ #libhomescreen
+ # qlibwindowmanager
)
# Prefix path where will be installed the files