summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2017-11-08 14:32:52 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2017-11-08 14:32:52 +0900
commit269f57ebab8c234a6355a310eb7990331ffdb12a (patch)
tree6c002e25617823abbaaf630cffa09519e96e39d2
parent866fc80a1010eb14a30ead1685a2066e04a0c473 (diff)
Test for Mediaplayer of HMI Framework at dab versionsandbox/knimitz/hmi-framework-test-dab
Change-Id: Ie4b9c0116665fa9fdfb36fbb0bd9e4c11f2b4ea9 Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--app/MediaPlayer.qml182
-rw-r--r--app/app.pri2
-rw-r--r--app/app.pro11
-rw-r--r--app/main.cpp106
-rw-r--r--app/qlibsoundmanager.cpp154
-rw-r--r--app/qlibsoundmanager.h60
-rw-r--r--app/qlibwindowmanager.cpp74
-rw-r--r--app/qlibwindowmanager.h71
-rw-r--r--package/config.xml4
9 files changed, 613 insertions, 51 deletions
diff --git a/app/MediaPlayer.qml b/app/MediaPlayer.qml
index 77538a6..f9644ad 100644
--- a/app/MediaPlayer.qml
+++ b/app/MediaPlayer.qml
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Qt Company Ltd.
+ * Copyright (C) 2017 Toyota Motor Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,10 +21,21 @@ import QtQuick.Controls 2.0
import QtMultimedia 5.6
import AGL.Demo.Controls 1.0
import MediaPlayer 1.0
+import QtQml.StateMachine 1.0 as MPSM
import 'api' as API
ApplicationWindow {
id: root
+
+ property int sourceID: 0
+ property int connectionID
+ property int sourceIndex
+
+ signal playMediaplayer
+ signal stopMediaplayer
+ signal disconnected
+ signal paused
+ signal connected
API.LightMediaScanner {
id: binding
@@ -46,6 +58,159 @@ ApplicationWindow {
}
}
+ MPSM.StateMachine{
+ id: mediaplayerState
+ initialState: stop
+ running: true
+ MPSM.State{
+ id: haveSoundRight
+ MPSM.SignalTransition{
+ targetState: stop
+ signal: disconnected
+ }
+ MPSM.SignalTransition{
+ targetState: pause
+ signal: paused
+ }
+ MPSM.SignalTransition{
+ targetState: playing
+ signal: playMediaplayer
+ }
+ onEntered: {
+ console.log("enter haveSoundRight")
+ }
+ onExited : {
+ // Nothing to do
+ }
+ }
+ MPSM.State{
+ id: stop
+ MPSM.SignalTransition{
+ targetState: haveSoundRight
+ signal: connected
+ }
+ onEntered: {
+ console.log("enter stop state")
+ }
+ onExited : {
+ // Nothing to do
+ }
+ }
+ MPSM.State{
+ id: pause
+ MPSM.SignalTransition{
+ targetState: haveSoundRight
+ signal: connected
+ }
+ MPSM.SignalTransition{
+ targetState: stop
+ signal: disconnected
+ }
+ onEntered: {
+ console.log("enter pause state")
+ }
+ onExited : {
+ // Nothing to do
+ }
+ }
+ MPSM.State{
+ id: playing
+ MPSM.SignalTransition{
+ targetState: haveSoundRight
+ signal: stopMediaplayer
+ }
+ MPSM.SignalTransition{
+ targetState: lostSoundRight
+ signal: disconnected
+ }
+ onEntered: {
+ console.log("enter playing state")
+ player.play()
+ }
+ onExited : {
+ player.pause()
+ }
+ }
+ MPSM.State{
+ id: lostSoundRight
+ MPSM.SignalTransition{
+ targetState: playing
+ signal: connected
+ }
+ onEntered: {
+ console.log("enter lostSoundRight")
+ }
+ onExited : {
+ }
+ }
+ MPSM.State{
+ id: temporaryLostSoundRight
+ MPSM.SignalTransition{
+ targetState: playing
+ signal: connected
+ }
+ MPSM.SignalTransition{
+ targetState: lostSoundRight
+ signal: disconnected
+ }
+ onEntered: {
+ console.log("enter lostSoundRight")
+ }
+ onExited : {
+ }
+ }
+ }
+
+ function slotReply(msg){
+ var jstr = JSON.stringify(msg)
+ var content = JSON.parse(jstr);
+ var verb = content.response.verb
+ var err = content.response.error
+ switch(verb)
+ {
+ case "connect":
+ if(err == 0){
+ connectionID = content.response.mainConnectionID
+ }
+ break;
+ case "registerSource":
+ if(err == 0){
+ sourceID = content.response.sourceID
+ }
+ }
+ }
+
+ function slotEvent(event,msg){
+ var jstr = JSON.stringify(msg)
+ var content = JSON.parse(jstr);
+ var eventName = content.event
+ switch(eventName)
+ {
+ case "soundmanager\/asyncSetSourceState":
+ // This event doesn't come for now
+ if(sourceID == content.data.sourceID){
+ console.log("mediaplayer: call ackSetSourceState")
+ smw.ackSetSourceState(content.data.handle, 0)
+ switch(content.data.sourceState){
+ case "on":
+ connected()
+ break;
+ case "off":
+ disconnected()
+ break;
+ case "paused":
+ paused()
+ break;
+ default:
+ break;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
Timer {
id: timer
interval: 250
@@ -187,7 +352,7 @@ ApplicationWindow {
if (bluetooth.av_connected) {
bluetooth.sendMediaCommand("Play")
} else {
- player.play()
+ playMediaplayer()
}
}
states: [
@@ -196,7 +361,9 @@ ApplicationWindow {
PropertyChanges {
target: play
offImage: './images/AGL_MediaPlayer_Player_Pause.svg'
- onClicked: player.pause()
+ onClicked: {
+ stopMediaplayer()
+ }
}
},
State {
@@ -247,8 +414,8 @@ ApplicationWindow {
Layout.fillHeight: true
Layout.preferredHeight: 407
- PlaylistWithMetadata {
- id: playlistmodel
+ PlaylistWithMetadata {
+ id: playlistmodel
source: playlist
}
@@ -300,7 +467,9 @@ ApplicationWindow {
}
onClicked: {
playlist.currentIndex = model.index
- player.play()
+ sourceIndex = model.index;
+ console.log("mediaplayer: call connect")
+ playMediaplayer()
}
}
@@ -310,5 +479,8 @@ ApplicationWindow {
}
}
}
+ Component.onCompleted: {
+ smw.registerSource("mediaplayer")
+ }
}
}
diff --git a/app/app.pri b/app/app.pri
index 7ec39b1..8671c5a 100644
--- a/app/app.pri
+++ b/app/app.pri
@@ -5,7 +5,7 @@ qtCompileTest(libhomescreen)
config_libhomescreen {
CONFIG += link_pkgconfig
- PKGCONFIG += homescreen
+ PKGCONFIG += homescreen soundmanager
DEFINES += HAVE_LIBHOMESCREEN
}
diff --git a/app/app.pro b/app/app.pro
index 23ecfea..795a141 100644
--- a/app/app.pro
+++ b/app/app.pro
@@ -1,14 +1,17 @@
TARGET = mediaplayer
-QT = quickcontrols2 multimedia
+QT = quickcontrols2 multimedia qml
HEADERS += \
- playlistwithmetadata.h
+ playlistwithmetadata.h qlibsoundmanager.h \
+ qlibwindowmanager.h
SOURCES = main.cpp \
- playlistwithmetadata.cpp
+ playlistwithmetadata.cpp qlibsoundmanager.cpp \
+ qlibwindowmanager.cpp
+CONFIG += link_pkgconfig
+PKGCONFIG += libsoundmanager libwindowmanager libhomescreen
RESOURCES += \
mediaplayer.qrc \
images/images.qrc
-
include(app.pri)
diff --git a/app/main.cpp b/app/main.cpp
index 5ad9577..38ad231 100644
--- a/app/main.cpp
+++ b/app/main.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2016 The Qt Company Ltd.
+ * Copyright (C) 2017 Toyota Motor Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,44 +24,29 @@
#include <QtQml/QQmlApplicationEngine>
#include <QtQml/QQmlContext>
#include <QtQml/qqml.h>
+#include <QQuickWindow>
#include <QtQuickControls2/QQuickStyle>
-
-#ifdef HAVE_LIBHOMESCREEN
+#include "qlibsoundmanager.h"
#include <libhomescreen.hpp>
-#endif
#include "playlistwithmetadata.h"
+#include "qlibwindowmanager.h"
-#ifndef HAVE_LIGHTMEDIASCANNER
-QVariantList readMusicFile(const QString &path)
-{
- QVariantList ret;
- QDir dir(path);
- for (const auto &entry : dir.entryList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot, QDir::Name)) {
- QFileInfo fileInfo(dir.absoluteFilePath(entry));
- if (fileInfo.isDir()) {
- ret.append(readMusicFile(fileInfo.absoluteFilePath()));
- } else if (fileInfo.isFile()) {
- ret.append(QUrl::fromLocalFile(fileInfo.absoluteFilePath()));
- }
- }
- return ret;
-}
-#endif
+static LibHomeScreen* hs;
+static QLibWindowmanager* qwm;
+static QLibSoundmanager* smw;
+static std::string myname = std::string("MediaPlayer");
+
+using namespace std;
+static void onRep(struct json_object* reply_contents);
+static void onEv(const std::string& event, struct json_object* event_contents);
int main(int argc, char *argv[])
{
-#ifdef HAVE_LIBHOMESCREEN
- LibHomeScreen libHomeScreen;
-
- if (!libHomeScreen.renderAppToAreaAllowed(0, 1)) {
- qWarning() << "renderAppToAreaAllowed is denied";
- return -1;
- }
-#endif
QGuiApplication app(argc, argv);
-
+ qwm = new QLibWindowmanager();
+ hs = new LibHomeScreen();
QQuickStyle::setStyle("AGL");
qmlRegisterType<PlaylistWithMetadata>("MediaPlayer", 1, 0, "PlaylistWithMetadata");
@@ -68,17 +54,6 @@ int main(int argc, char *argv[])
QQmlApplicationEngine engine;
QQmlContext *context = engine.rootContext();
-#ifndef HAVE_LIGHTMEDIASCANNER
- QVariantList mediaFiles;
- QString music;
-
- for (const auto &music : QStandardPaths::standardLocations(QStandardPaths::MusicLocation)) {
- mediaFiles.append(readMusicFile(music));
- }
-
- context->setContextProperty("mediaFiles", mediaFiles);
-#endif
-
QCommandLineParser parser;
parser.addPositionalArgument("port", app.translate("main", "port for binding"));
parser.addPositionalArgument("secret", app.translate("main", "secret for binding"));
@@ -99,9 +74,58 @@ int main(int argc, char *argv[])
query.addQueryItem(QStringLiteral("token"), secret);
bindingAddress.setQuery(query);
context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress);
- }
+ /* This is window manager test */
+ std::string token = secret.toStdString();
+
+ if(qwm->init(port,token.c_str()) != 0){
+ exit(EXIT_FAILURE);
+ }
+
+ if (qwm->requestSurface(myname.c_str()) != 0) {
+ exit(EXIT_FAILURE);
+ }
+
+ // prepare to use homescreen
+ hs->init(port, token.c_str());
+
+ hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [qwm](json_object *object){
+ const char *appname = json_object_get_string(
+ json_object_object_get(object, "application_name"));
+ if(myname == appname)
+ {
+ qDebug("[HS]mediaplayer: activateSurface\n");
+ qwm->activateSurface(myname.c_str());
+ }
+ });
+
+ // prepare to use soundmangaer
+ smw = new QLibSoundmanager();
+ smw->init(port, secret);
+ engine.rootContext()->setContextProperty("smw",smw);
+
+ qwm->set_event_handler(QLibWindowmanager::Event_SyncDraw, [smw, qwm](json_object *object) {
+ fprintf(stderr, "[WM]Surface got syncDraw!\n");
+ qwm->endDraw(myname.c_str());
+ // Something to to if needed
+ });
+ qwm->set_event_handler(QLibWindowmanager::Event_FlushDraw, [smw, &engine](json_object *object) {
+ fprintf(stderr, "[WM]Surface got FlushDraw!\n");
+ // Something to to if needed
+ QObject *root = engine.rootObjects().first();
+ int sourceID = root->property("sourceID").toInt();
+ smw->connect(sourceID, "default");
+ });
+ }
engine.load(QUrl(QStringLiteral("qrc:/MediaPlayer.qml")));
+ QObject *root = engine.rootObjects().first();
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(root);
+ QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface()));
+ QObject::connect(smw, SIGNAL(reply(QVariant)),
+ root, SLOT(slotReply(QVariant)));
+ QObject::connect(smw, SIGNAL(event(QVariant, QVariant)),
+ root, SLOT(slotEvent(QVariant, QVariant)));
+
return app.exec();
-}
+} \ No newline at end of file
diff --git a/app/qlibsoundmanager.cpp b/app/qlibsoundmanager.cpp
new file mode 100644
index 0000000..5bcbf10
--- /dev/null
+++ b/app/qlibsoundmanager.cpp
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * 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 "qlibsoundmanager.h"
+#include <QJsonDocument>
+using namespace std;
+
+static int create_json_object(const QJsonObject& obj, struct json_object* jobj);
+static bool put_val_to_jobj(const char* key, const QJsonValue& val, struct json_object* jobj);
+QLibSoundmanager* me;
+
+static void cbEvent_static(const std::string& event, struct json_object* event_contents)
+{
+ const QString event_name = QString(event.c_str());
+ QString str = QString(json_object_get_string(event_contents));
+ QJsonParseError error;
+ QJsonDocument jdoc = QJsonDocument::fromJson(str.toUtf8(), &error);
+ const QJsonObject jobj = jdoc.object();
+ emit me->event(event_name, jobj);
+}
+
+static void cbReply_static(struct json_object* replyContents)
+{
+ if(me == nullptr){
+ return;
+ }
+ QString str = QString(json_object_get_string(replyContents));
+ QJsonParseError error;
+ QJsonDocument jdoc = QJsonDocument::fromJson(str.toUtf8(), &error);
+ QJsonObject jobj = jdoc.object();
+ emit me->reply(jobj);
+}
+
+QLibSoundmanager::QLibSoundmanager(QObject *parent) :
+ QObject(parent)
+{
+ /* This is not enabled */
+ libsm = new LibSoundmanager();
+}
+
+QLibSoundmanager::~QLibSoundmanager()
+{
+ delete libsm;
+}
+
+int QLibSoundmanager::init(int port, const QString& token)
+{
+ if(libsm == nullptr){
+ return -1;
+ }
+ string ctoken = token.toStdString();
+ int rc = libsm->init(port, ctoken);
+ if(rc != 0){
+ return rc;
+ }
+ me = this;
+
+ libsm->register_callback(
+ cbEvent_static,
+ cbReply_static);
+ return rc;
+}
+
+int QLibSoundmanager::call(const QString &verb, const QJsonObject &arg)
+{
+ // translate QJsonObject to struct json_object
+ struct json_object* jobj = json_object_new_object();
+ int ret = create_json_object(arg, jobj);
+ if(ret < 0)
+ {
+ return -1;
+ }
+ return libsm->call(verb.toStdString().c_str(), jobj);
+}
+
+int QLibSoundmanager::connect(int sourceID, const QString& sinkName){
+ string str = sinkName.toStdString();
+ return libsm->connect(sourceID, str);
+}
+int QLibSoundmanager::disconnect(int connectionID){
+ return libsm->disconnect(connectionID);
+}
+int QLibSoundmanager::ackSetSourceState(int handle, int errorcode){
+ return libsm->ackSetSourceState(handle, errorcode);
+}
+int QLibSoundmanager::registerSource(const QString& name){
+ string str = name.toStdString();
+ return libsm->registerSource(str);
+}
+
+static int create_json_object(const QJsonObject& obj, struct json_object* jobj)
+{
+ try{
+ for(auto itr = obj.begin(); itr != obj.end();++itr)
+ {
+ string key = itr.key().toStdString();
+ //const char* key = itr.key().toStdString().c_str(); // Do not code like this. string is removed if size is over 16!!
+
+ bool ret = put_val_to_jobj(key.c_str(), itr.value(),jobj);
+ if(!ret){
+ /*This is not implemented*/
+ qDebug("JsonArray can't parse for now");
+ return -1;
+ }
+ }
+ }
+ catch(...){
+ qDebug("Json parse error occured");
+ return -1;
+ }
+ return 0;
+}
+
+static bool put_val_to_jobj(const char* key, const QJsonValue& val, struct json_object* jobj)
+{
+ if(val.isArray()){
+ return false; // Array can't input
+ }
+ if(val.isString()){
+ string value = val.toString().toStdString();
+ json_object_object_add(jobj, key, json_object_new_string(value.c_str()));
+ }
+ else{
+ const int value = val.toInt();
+ json_object_object_add(jobj, key, json_object_new_int(value));
+ }
+ return true;
+}
+
+
+void QLibSoundmanager::subscribe(const QString &event_name)
+{
+ std::string str = event_name.toStdString();
+ libsm->subscribe(str);
+}
+
+void QLibSoundmanager::unsubscribe(const QString &event_name)
+{
+ std::string str = event_name.toStdString();
+ libsm->unsubscribe(str);
+}
diff --git a/app/qlibsoundmanager.h b/app/qlibsoundmanager.h
new file mode 100644
index 0000000..a7bdc98
--- /dev/null
+++ b/app/qlibsoundmanager.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * 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 QLIBSOUNDMANAGER_H
+#define QLIBSOUNDMANAGER_H
+
+ #include <QObject>
+ #include <QVariant>
+ #include <QtCore/QJsonObject>
+ #include <libsoundmanager.hpp>
+ #include <QString>
+ #include <string>
+
+
+class QLibSoundmanager : public QObject
+{
+ Q_OBJECT
+public: // method
+ explicit QLibSoundmanager(QObject *parent = nullptr);
+ ~QLibSoundmanager();
+ int init(int port, const QString& token);
+
+ using sm_event_handler = std::function<void(int sourceid, int handle)>;
+
+ void subscribe(const QString &event_name);
+ void unsubscribe(const QString &event_name);
+
+ void emit_event(const QString &event, const QJsonObject &msg);
+ void emit_reply(const QJsonObject &msg);
+
+public:
+
+ Q_INVOKABLE int call(const QString &verb, const QJsonObject &arg);
+ Q_INVOKABLE int connect(int sourceID, const QString& sinkName);
+ Q_INVOKABLE int disconnect(int connectionID);
+ Q_INVOKABLE int ackSetSourceState(int handle, int errorcode);
+ Q_INVOKABLE int registerSource(const QString& name);
+
+signals:
+ void reply(const QVariant &msg);
+ void event(const QVariant &event, const QVariant &msg);
+
+private:
+ LibSoundmanager* libsm;
+};
+
+
+#endif /*QLIBSOUNDMANAGER_H*/
diff --git a/app/qlibwindowmanager.cpp b/app/qlibwindowmanager.cpp
new file mode 100644
index 0000000..993a204
--- /dev/null
+++ b/app/qlibwindowmanager.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * 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 "qlibwindowmanager.h"
+#include <unistd.h>
+
+int QLibWindowmanager::init(int port, char const *token) {
+ return this->wm->init(port, token);
+}
+
+int QLibWindowmanager::requestSurface(const char *label) {
+ applabel = label;
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(label));
+ return this->wm->requestSurface(obj);
+}
+
+int QLibWindowmanager::activateSurface(const char *label) {
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(label));
+ json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full"));
+ return this->wm->activateSurface(obj);
+}
+
+int QLibWindowmanager::deactivateSurface(const char *label) {
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(label));
+ return this->wm->deactivateSurface(obj);
+}
+
+int QLibWindowmanager::endDraw(const char *label) {
+ json_object *obj = json_object_new_object();
+ json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(label));
+ return this->wm->endDraw(obj);
+ }
+
+void QLibWindowmanager::set_event_handler(enum QEventType et,
+ handler_fun f) {
+ LibWindowmanager::EventType wet = (LibWindowmanager::EventType)et;
+ return this->wm->set_event_handler(wet, std::move(f));
+}
+
+void QLibWindowmanager::slotActivateSurface(){
+ if(!isActive){
+ qDebug("Let's snow mediaplayer");;
+ isActive = true;
+ this->activateSurface(applabel.c_str());
+ }
+}
+
+/*void QLibWindowmanager::setVisible(bool visible){
+ isVisible = visible;
+}*/
+
+QLibWindowmanager::QLibWindowmanager(QObject *parent)
+ :QObject(parent) , isActive(false)
+{
+ wm = new LibWindowmanager();
+}
+
+QLibWindowmanager::~QLibWindowmanager() { }
diff --git a/app/qlibwindowmanager.h b/app/qlibwindowmanager.h
new file mode 100644
index 0000000..42bdff3
--- /dev/null
+++ b/app/qlibwindowmanager.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * 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 QLIBWINDOWMANAGER_H
+#define QLIBWINDOWMANAGER_H
+#include <libwindowmanager.h>
+#include <functional>
+ #include <QObject>
+ #include <QUrl>
+ #include <QVariant>
+ #include <string>
+ #include <vector>
+
+class QLibWindowmanager : public QObject{
+Q_OBJECT
+public:
+ explicit QLibWindowmanager(QObject *parent = nullptr);
+ ~QLibWindowmanager();
+
+ QLibWindowmanager(const QLibWindowmanager &) = delete;
+ QLibWindowmanager &operator=(const QLibWindowmanager &) = delete;
+
+public:
+ using handler_fun = std::function<void(json_object *object)>;
+
+ enum QEventType {
+ Event_Active = 0,
+ Event_Inactive,
+
+ Event_Visible,
+ Event_Invisible,
+
+ Event_SyncDraw,
+ Event_FlushDraw,
+ };
+
+ static QLibWindowmanager &instance();
+
+ int init(int port, char const *token);
+
+ // WM API
+ int requestSurface(const char *label);
+ int activateSurface(const char *label);
+ int deactivateSurface(const char *label);
+ int endDraw(const char *label);
+ /*void setVisible(bool visible);*/
+ void set_event_handler(enum QEventType et, handler_fun f);
+
+public slots:
+ void slotActivateSurface();
+
+private:
+ LibWindowmanager* wm;
+ std::string applabel;
+ std::vector<int> surfaceIDs;
+ bool isActive;
+};
+#endif // LIBWINDOWMANAGER_H
diff --git a/package/config.xml b/package/config.xml
index 1091f17..c0ca7c8 100644
--- a/package/config.xml
+++ b/package/config.xml
@@ -7,6 +7,10 @@
<author>Tasuku Suzuki &lt;tasuku.suzuki@qt.io&gt;</author>
<license>APL 2.0</license>
<feature name="urn:AGL:widget:required-api">
+ <!-- Add Sound Manager service -->
+ <param name="soundmanager" value="ws" />
+ <param name="windowmanager" value="ws" />
+ <param name="homescreen" value="ws" />
<param name="lib/libmediaplayer-binding.so" value="local" />
<param name="Bluetooth-Manager" value="ws" />
</feature>