summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2018-01-03 02:39:23 +0900
committerTadao Tanikawa <tanikawa.tadao@jp.panasonic.com>2018-01-03 03:18:29 +0900
commit7cd388558f49166b7df2811fdf649e93230017b5 (patch)
tree9fb17056c416f7b960fe68375af589634c6427fb
parent8655fb6da62f8617b946e7c933ea151b43de2234 (diff)
Initial import of QtAGLExtraseel_5.0.0eel/5.0.05.0.0
Qt AGLExtras module provides a set of easy to create AGL Qt application. It uses the AGL HMI and application framework, therefore the application can be easily integrated to AGL HomeScreen/WindowManager on AGL Demo Platform. Change-Id: I38a47aefcda8ee4ded759d56c5149ebbe22f94a9 Signed-off-by: Tadao Tanikawa <tanikawa.tadao@jp.panasonic.com>
-rw-r--r--.qmake.conf2
-rw-r--r--README48
-rw-r--r--examples/aglextras/aglextras.pro3
-rw-r--r--examples/aglextras/helloworld/helloworld.pro10
-rw-r--r--examples/aglextras/helloworld/main.cpp28
-rw-r--r--examples/aglextras/helloworld/qml/helloworld/main.qml15
-rw-r--r--examples/aglextras/helloworld/resources.qrc5
-rw-r--r--examples/examples.pro2
-rw-r--r--qtaglextras.pro3
-rw-r--r--src/aglextras/aglextras.pro13
-rw-r--r--src/aglextras/aglextrasglobal.h20
-rw-r--r--src/aglextras/hmi/aglapplication.cpp112
-rw-r--r--src/aglextras/hmi/aglapplication.h48
-rw-r--r--src/aglextras/hmi/aglapplication_p.h42
-rw-r--r--src/aglextras/hmi/aglwindow.cpp106
-rw-r--r--src/aglextras/hmi/aglwindow.h47
-rw-r--r--src/aglextras/hmi/aglwindow_p.h36
-rw-r--r--src/aglextras/hmi/hmi.pri9
-rw-r--r--src/aglextras/hmi/main.cpp225
-rw-r--r--src/src.pro2
-rw-r--r--sync.profile8
-rw-r--r--tests/auto/auto.pro2
-rw-r--r--tests/auto/cmake/cmake.pro6
-rw-r--r--tests/tests.pro2
24 files changed, 569 insertions, 225 deletions
diff --git a/.qmake.conf b/.qmake.conf
new file mode 100644
index 0000000..7ba2357
--- /dev/null
+++ b/.qmake.conf
@@ -0,0 +1,2 @@
+load(qt_build_config)
+MODULE_VERSION = 1.0.0
diff --git a/README b/README
new file mode 100644
index 0000000..62a6446
--- /dev/null
+++ b/README
@@ -0,0 +1,48 @@
+---------------
+Qt AGLExtras
+---------------
+
+Qt AGLExtras module provides a set of easy to create AGL Qt application.
+It uses the AGL HMI and application framework, therefore the application
+can be easily integrated to AGL HomeScreen/WindowManager on AGL Demo
+Platform.
+
+System Requirements
+===================
+
+- Qt 5.8 or newer
+- QtQuick 2 is required
+- AGL Application Framework 2.0 or newer
+- AGL HMI Framework 2017 or newer
+
+Building
+========
+
+Configure the project with qmake:
+ qmake
+
+After running qmake, build the project with make:
+ make
+
+The above generates the default makefiles for your configuration, which is
+typically the release build if you are using precompiled binary AGL
+distribution. To build both debug and release, or one specifically, use
+of the following qmake lines instead.
+
+For debug builds:
+ qmake CONFIG+=debug
+ make
+ or
+ qmake CONFIG+=debug_and_release
+ make debug
+
+For release builds:
+ qmake CONFIG+=release
+ or
+ qmake CONFIG+=debug_and_release
+
+After building, install the module to your AGL SDK directory:
+ make install
+
+If you want to uninstall the module:
+ make uninstall
diff --git a/examples/aglextras/aglextras.pro b/examples/aglextras/aglextras.pro
new file mode 100644
index 0000000..309f27f
--- /dev/null
+++ b/examples/aglextras/aglextras.pro
@@ -0,0 +1,3 @@
+TEMPLATE = subdirs
+SUBDIRS += \
+ helloworld
diff --git a/examples/aglextras/helloworld/helloworld.pro b/examples/aglextras/helloworld/helloworld.pro
new file mode 100644
index 0000000..6db8e40
--- /dev/null
+++ b/examples/aglextras/helloworld/helloworld.pro
@@ -0,0 +1,10 @@
+QT += aglextras qml quick
+
+SOURCES += \
+ main.cpp
+
+RESOURCES += \
+ resources.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/aglextras/helloworld
+INSTALLS += target
diff --git a/examples/aglextras/helloworld/main.cpp b/examples/aglextras/helloworld/main.cpp
new file mode 100644
index 0000000..08b2e97
--- /dev/null
+++ b/examples/aglextras/helloworld/main.cpp
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2017 The Qt Company Ltd.
+ * Copyright (c) 2017 Panasonic 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 <QtAGLExtras/AGLApplication>
+#include <QtCore/QUrlQuery>
+
+int main(int argc, char *argv[])
+{
+ AGLApplication app(argc, argv);
+ app.setApplicationName("HelloWorld");
+ app.setupApplicationRole("Settings");
+ app.load(QUrl(QStringLiteral("qrc:/helloworld.qml")));
+ return app.exec();
+}
diff --git a/examples/aglextras/helloworld/qml/helloworld/main.qml b/examples/aglextras/helloworld/qml/helloworld/main.qml
new file mode 100644
index 0000000..f0c5be1
--- /dev/null
+++ b/examples/aglextras/helloworld/qml/helloworld/main.qml
@@ -0,0 +1,15 @@
+import QtQuick 2.0
+
+Rectangle {
+ id: page
+ width: 320; height: 480
+ color: "lightgray"
+
+ Text {
+ id: helloText
+ text: "Hello world!"
+ y: 30
+ anchors.horizontalCenter: page.horizontalCenter
+ font.pointSize: 24; font.bold: true
+ }
+}
diff --git a/examples/aglextras/helloworld/resources.qrc b/examples/aglextras/helloworld/resources.qrc
new file mode 100644
index 0000000..8a1a2e2
--- /dev/null
+++ b/examples/aglextras/helloworld/resources.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>qml/helloworld/main.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/examples.pro b/examples/examples.pro
new file mode 100644
index 0000000..02d0ae0
--- /dev/null
+++ b/examples/examples.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += aglextras
diff --git a/qtaglextras.pro b/qtaglextras.pro
new file mode 100644
index 0000000..2e29e90
--- /dev/null
+++ b/qtaglextras.pro
@@ -0,0 +1,3 @@
+load(configure)
+
+load(qt_parts)
diff --git a/src/aglextras/aglextras.pro b/src/aglextras/aglextras.pro
new file mode 100644
index 0000000..4b013fb
--- /dev/null
+++ b/src/aglextras/aglextras.pro
@@ -0,0 +1,13 @@
+TARGET = QtAGLExtras
+
+CONFIG += link_pkgconfig
+PKGCONFIG += libhomescreen qlibwindowmanager
+
+QT += quick
+QT += core-private
+
+include(hmi/hmi.pri)
+
+load(qt_module)
+
+CONFIG-=create_cmake
diff --git a/src/aglextras/aglextrasglobal.h b/src/aglextras/aglextrasglobal.h
new file mode 100644
index 0000000..24f23b7
--- /dev/null
+++ b/src/aglextras/aglextrasglobal.h
@@ -0,0 +1,20 @@
+#ifndef AGLEXTRASGLOBAL_H
+#define AGLEXTRASGLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_NAMESPACE
+
+#ifndef QT_STATIC
+#if defined (QT_BUILD_AGLEXTRAS_LIB)
+#define AGLEXTRAS_EXPORT Q_DECL_EXPORT
+#else
+#define AGLEXTRAS_EXPORT Q_DECL_IMPORT
+#endif
+#else
+#define AGLEXTRAS_EXPORT
+#endif
+
+QT_END_NAMESPACE
+
+#endif // AGLEXTRASGLOBAL_H
diff --git a/src/aglextras/hmi/aglapplication.cpp b/src/aglextras/hmi/aglapplication.cpp
new file mode 100644
index 0000000..295c017
--- /dev/null
+++ b/src/aglextras/hmi/aglapplication.cpp
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ * Copyright (C) 2017 The Qt Company Ltd.
+ * Copyright (c) 2017 Panasonic 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 "aglapplication.h"
+#include "aglapplication_p.h"
+#include "aglwindow.h"
+#include "aglwindow_p.h"
+
+#include <QtCore/QCommandLineParser>
+#include <QtCore/QUrlQuery>
+#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlContext>
+#include <QtQml/QQmlApplicationEngine>
+
+QT_BEGIN_NAMESPACE
+
+AGLApplicationPrivate::AGLApplicationPrivate (AGLApplication*)
+ : binding_address(new QUrl)
+{
+ ;
+}
+
+AGLApplicationPrivate::~AGLApplicationPrivate (void)
+{
+ ;
+}
+
+AGLApplication::AGLApplication (int& argc, char** argv)
+ : QGuiApplication(argc, argv),
+ d_ptr(new AGLApplicationPrivate(this))
+{
+ setApplicationVersion(QStringLiteral("4.99.5"));
+ setOrganizationDomain(QStringLiteral("automotivelinux.org"));
+ setOrganizationName(QStringLiteral("AutomotiveGradeLinux"));
+
+ QCommandLineParser parser;
+ parser.addPositionalArgument(QLatin1String("port"),
+ translate("main", "port for binding"));
+ parser.addPositionalArgument(QLatin1String("secret"),
+ translate("main", "secret for binding"));
+ parser.addHelpOption();
+ parser.addVersionOption();
+ parser.process(*this);
+ QStringList positionalArguments = parser.positionalArguments();
+
+ if (positionalArguments.length() < 2) {
+ return;
+ }
+
+ d_ptr->port = positionalArguments.takeFirst().toInt();
+ d_ptr->secret = positionalArguments.takeFirst();
+
+ d_ptr->binding_address->setScheme(QStringLiteral("ws"));
+ d_ptr->binding_address->setHost(QStringLiteral("localhost"));
+ d_ptr->binding_address->setPort(d_ptr->port);
+ d_ptr->binding_address->setPath(QStringLiteral("/api"));
+
+ QUrlQuery query;
+ query.addQueryItem(QStringLiteral("token"), d_ptr->secret);
+ d_ptr->binding_address->setQuery(query);
+
+ d_ptr->engine = new QQmlApplicationEngine();
+ if (!d_ptr->engine) {
+ qDebug("Cannot initialize QML Engine");
+ exit(EXIT_FAILURE);
+ }
+
+ d_ptr->engine->rootContext()->setContextProperty(QStringLiteral("bindingAddress"),
+ *d_ptr->binding_address);
+}
+
+void
+AGLApplication::load (const QUrl &url)
+{
+ d_ptr->engine->load(url);
+}
+
+void
+AGLApplication::load (const QString &filePath)
+{
+ d_ptr->engine->load(filePath);
+}
+
+int
+AGLApplication::exec (void)
+{
+ if (d_ptr->window) {
+ d_ptr->window->attach(d_ptr->engine);
+ }
+ return QGuiApplication::exec();
+}
+
+void AGLApplication::setupApplicationRole (const QString &role)
+{
+ d_ptr->window = new AGLWindow(role, d_ptr->port, d_ptr->secret);
+}
+
+QT_END_NAMESPACE
diff --git a/src/aglextras/hmi/aglapplication.h b/src/aglextras/hmi/aglapplication.h
new file mode 100644
index 0000000..df68979
--- /dev/null
+++ b/src/aglextras/hmi/aglapplication.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ * Copyright (C) 2017 The Qt Company Ltd.
+ * Copyright (c) 2017 Panasonic 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 AGLAPPLICATION_H
+#define AGLAPPLICATION_H
+
+#include <QtAGLExtras/aglextrasglobal.h>
+#include <QSharedPointer>
+
+#include <QtGui/QGuiApplication>
+
+QT_BEGIN_NAMESPACE
+class AGLApplicationPrivate;
+class AGLEXTRAS_EXPORT AGLApplication : public QGuiApplication
+{
+ Q_OBJECT
+
+public:
+ AGLApplication (int& argc, char** argv);
+
+ void setupApplicationRole(const QString& role);
+
+ void load (const QUrl &url);
+ void load (const QString &filePath);
+
+ int exec (void);
+
+private:
+ friend class AGLApplicationPrivate;
+ QSharedPointer<AGLApplicationPrivate> d_ptr;
+};
+QT_END_NAMESPACE
+
+#endif // AGLAPPLICATION_H
diff --git a/src/aglextras/hmi/aglapplication_p.h b/src/aglextras/hmi/aglapplication_p.h
new file mode 100644
index 0000000..b12b5f4
--- /dev/null
+++ b/src/aglextras/hmi/aglapplication_p.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ * Copyright (C) 2017 The Qt Company Ltd.
+ * Copyright (c) 2017 Panasonic 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 AGLAPPLICATION_P_H
+#define AGLAPPLICATION_P_H
+
+QT_BEGIN_NAMESPACE
+class QUrl;
+class QQmlApplicationEngine;
+class AGLWindow;
+class AGLApplication;
+class AGLApplicationPrivate
+{
+ public:
+ explicit AGLApplicationPrivate (AGLApplication *app);
+ ~AGLApplicationPrivate (void);
+
+ private:
+ int port = -1;
+ QString secret;
+ QUrl* binding_address;
+ QQmlApplicationEngine *engine;
+ AGLWindow* window;
+ friend class AGLApplication;
+};
+QT_END_NAMESPACE
+
+#endif // AGLAPPLICATION_P_H
diff --git a/src/aglextras/hmi/aglwindow.cpp b/src/aglextras/hmi/aglwindow.cpp
new file mode 100644
index 0000000..f1f55e6
--- /dev/null
+++ b/src/aglextras/hmi/aglwindow.cpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ * Copyright (C) 2017 The Qt Company Ltd.
+ * Copyright (c) 2017 Panasonic 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 "aglwindow.h"
+#include "aglwindow_p.h"
+
+#include <QtQuick/QQuickWindow>
+#include <QtQml/QQmlApplicationEngine>
+
+QT_BEGIN_NAMESPACE
+
+AGLWindowPrivate::AGLWindowPrivate (AGLWindow*)
+{
+ ;
+}
+
+AGLWindowPrivate::~AGLWindowPrivate (void)
+{
+ ;
+}
+
+void AGLWindow::activate_surface (void)
+{
+ qDebug("Disconnect!! SLOT activate_surface()");
+ QLibWindowmanager::disconnect(d_ptr->loading);
+
+ activateSurface(QString(d_ptr->layout));
+}
+
+void AGLWindow::attach (QQmlApplicationEngine* engine)
+{
+ if (d_ptr->binding) {
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(engine->rootObjects().first());
+
+ qDebug("Connect!! frameSapped! (activate_surface())");
+ d_ptr->loading = QLibWindowmanager::connect(window, SIGNAL(frameSwapped()),
+ this, SLOT(activate_surface()));
+ }
+}
+
+AGLWindow::AGLWindow (const QString& layout, int port, QString secret)
+ : QLibWindowmanager(nullptr),
+ d_ptr(new AGLWindowPrivate(this))
+
+{
+ if (port == -1) {
+ qDebug("This is not AGL binding application");
+ return;
+ }
+
+ if (QLibWindowmanager::init(port, secret) != 0 ||
+ LibHomeScreen::init(port, secret.toStdString().c_str()) != 0) {
+ qDebug("Cannot get binding API");
+ return;
+ }
+
+ d_ptr->layout = layout;
+
+ // Request a surface as described in layers.json windowmanager’s file
+ if (requestSurface(d_ptr->layout) != 0) {
+ qDebug("Cannot get surface for %s", qPrintable(d_ptr->layout));
+ return;
+ }
+
+ d_ptr->binding = true;
+
+ // Create an event callback against an event type. Here a lambda is called when SyncDraw event occurs
+ QLibWindowmanager::set_event_handler (
+ QLibWindowmanager::Event_SyncDraw,
+ [this](json_object*) {
+ qDebug("Surface got syncDraw!\n");
+ endDraw(d_ptr->layout);
+ }
+ );
+
+ // Set the event handler for Event_TapShortcut which will activate the surface for windowmanager
+ LibHomeScreen::set_event_handler (
+ LibHomeScreen::Event_TapShortcut,
+ [this](json_object* object) {
+ json_object *jo_app_name = nullptr;
+ if(json_object_object_get_ex(object, "application_name", &jo_app_name)) {
+ QString name(QLatin1String(json_object_get_string(jo_app_name)));
+ if(d_ptr->layout == name) {
+ qDebug("Surface %s got tapShortcut\n", qPrintable(name));
+ activateSurface(d_ptr->layout);
+ }
+ }
+ }
+ );
+}
+
+QT_END_NAMESPACE
diff --git a/src/aglextras/hmi/aglwindow.h b/src/aglextras/hmi/aglwindow.h
new file mode 100644
index 0000000..4c5261b
--- /dev/null
+++ b/src/aglextras/hmi/aglwindow.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ * Copyright (C) 2017 The Qt Company Ltd.
+ * Copyright (c) 2017 Panasonic 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 AGLWINDOW_H
+#define AGLWINDOW_H
+
+#include <QtAGLExtras/aglextrasglobal.h>
+#include <QSharedPointer>
+
+#include <libhomescreen.hpp>
+#include <qlibwindowmanager.h>
+
+QT_BEGIN_NAMESPACE
+class QQmlApplicationEngine;
+class AGLWindowPrivate;
+class AGLEXTRAS_EXPORT AGLWindow : public QLibWindowmanager, public LibHomeScreen
+{
+ Q_OBJECT
+
+public:
+ AGLWindow (const QString& layout, int port, QString secret);
+ void attach (QQmlApplicationEngine* engine);
+
+public slots:
+ void activate_surface (void);
+
+private:
+ friend class AGLWindowPrivate;
+ QSharedPointer<AGLWindowPrivate> d_ptr;
+};
+QT_END_NAMESPACE
+
+#endif // AGLWINDOW_H
diff --git a/src/aglextras/hmi/aglwindow_p.h b/src/aglextras/hmi/aglwindow_p.h
new file mode 100644
index 0000000..0ad6510
--- /dev/null
+++ b/src/aglextras/hmi/aglwindow_p.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ * Copyright (C) 2017 The Qt Company Ltd.
+ * Copyright (c) 2017 Panasonic 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 AGLWINDOW_P_H
+#define AGLWINDOW_P_H
+
+QT_BEGIN_NAMESPACE
+class AGLWindowPrivate
+{
+ public:
+ explicit AGLWindowPrivate (AGLWindow* window);
+ ~AGLWindowPrivate (void);
+
+ private:
+ QString layout; // id of layaout which is managed by AGL WM
+ QMetaObject::Connection loading;
+ bool binding = false;
+ friend class AGLWindow;
+};
+QT_END_NAMESPACE
+
+#endif // AGLWINDOW_P_H
diff --git a/src/aglextras/hmi/hmi.pri b/src/aglextras/hmi/hmi.pri
new file mode 100644
index 0000000..91c712d
--- /dev/null
+++ b/src/aglextras/hmi/hmi.pri
@@ -0,0 +1,9 @@
+SOURCES += \
+ $$PWD/aglapplication.cpp \
+ $$PWD/aglwindow.cpp
+
+HEADERS += \
+ $$PWD/aglapplication.h \
+ $$PWD/aglapplication_p.h \
+ $$PWD/aglwindow.h \
+ $$PWD/aglwindow_p.h
diff --git a/src/aglextras/hmi/main.cpp b/src/aglextras/hmi/main.cpp
deleted file mode 100644
index 831df41..0000000
--- a/src/aglextras/hmi/main.cpp
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * 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 <QtCore/QDebug>
-#include <QtCore/QCommandLineParser>
-#include <QtCore/QUrlQuery>
-#include <QtCore/QSettings>
-#include <QtGui/QGuiApplication>
-#include <QtQml/QQmlApplicationEngine>
-#include <QtQml/QQmlContext>
-#include <QtQuickControls2/QQuickStyle>
-#include <QQuickWindow>
-
-#include <libhomescreen/libhomescreen.hpp>
-#include "wmhandler.h"
-#include "smhandler.h"
-
-
-static LibHomeScreen* hs;
-static LibWindowmanager* wm;
-static LibSMWrapper* smw;
-static WmHandler* wmh;
-
-static std::string myname = std::string("Templete");
-
-
-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[])
-{
- QGuiApplication app(argc, argv);
- QQmlApplicationEngine engine;
- QQmlContext* context = engine.rootContext();
- QObject* root;
- QQuickWindow* window;
-
- QQuickStyle::setStyle("AGL");
-
- /*
- * Set argument and option
- */
- 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();
-
- if (positionalArguments.length() == 2) {
- /*
- * Get argument
- */
- int port = positionalArguments.takeFirst().toInt();
- QString secret = positionalArguments.takeFirst();
- std::string token = secret.toStdString();
-
-
- /*
- * Get instance
- */
- hs = new LibHomeScreen();
- wm = new LibWindowmanager();
- smw = new LibSMWrapper(port, secret);
- wmh = new WmHandler();
-
-
- /*
- * Set WindowManager
- */
- // Initialize
- if(wm->init(port, token.c_str()) != 0){
- exit(EXIT_FAILURE);
- }
-
- // Application should call requestSurface at first
- json_object *obj = json_object_new_object();
- json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str()));
- if (wm->requestSurface(obj) != 0) {
- exit(EXIT_FAILURE);
- }
-
- // Set event handlers for each event
- wm->set_event_handler(LibWindowmanager::Event_Active, [wm](json_object *object) {
- const char *label = json_object_get_string(
- json_object_object_get(object, wm->kKeyDrawingName));
- fprintf(stderr, "Surface %s got activated!\n", label);
- });
- wm->set_event_handler(LibWindowmanager::Event_Inactive, [wm](json_object *object) {
- const char *label = json_object_get_string(
- json_object_object_get(object, wm->kKeyDrawingName));
- fprintf(stderr, "Surface %s got deactivated!\n", label);
- });
- wm->set_event_handler(LibWindowmanager::Event_Visible, [wm](json_object *object) {
- const char *label = json_object_get_string(
- json_object_object_get(object, wm->kKeyDrawingName));
- fprintf(stderr, "Surface %s got visible!\n", label);
- });
- wm->set_event_handler(LibWindowmanager::Event_Invisible, [wm](json_object *object) {
- const char *label = json_object_get_string(
- json_object_object_get(object, wm->kKeyDrawingName));
- fprintf(stderr, "Surface %s got invisible!\n", label);
- });
- wm->set_event_handler(LibWindowmanager::Event_SyncDraw, [wm](json_object *object) {
- const char *label = json_object_get_string(
- json_object_object_get(object, wm->kKeyDrawingName));
- const char *area = json_object_get_string(
- json_object_object_get(object, wm->kKeyDrawingArea));
- fprintf(stderr, "Surface %s got syncDraw!\n", label);
- // Application should call LibWindowmanager::endDraw() in SyncDraw handler
- json_object *obj = json_object_new_object();
- json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str()));
- wm->endDraw(obj);
- });
- wm->set_event_handler(LibWindowmanager::Event_FlushDraw, [wm](json_object *object) {
- const char *label = json_object_get_string(
- json_object_object_get(object, wm->kKeyDrawingName));
- fprintf(stderr, "Surface %s got flushDraw!\n", label);
- });
-
- // Initialize WmHandler
- wmh->init(wm, myname.c_str());
-
-
- /*
- * Set HomeScreen
- */
- // Initialize
- hs->init(port, token.c_str());
-
- // Set event handler
- hs->set_event_handler(LibHomeScreen::Event_TapShortcut, [wm](json_object *object) {
- const char *appname = json_object_get_string(
- json_object_object_get(object, "application_name"));
- if(myname == appname) {
- qDebug("Surface %s got tapShortcut\n", appname);
- // Application should call LibWindowmanager::endDraw() in TapShortcut handler
- json_object *obj = json_object_new_object();
- json_object_object_add(obj, wm->kKeyDrawingName, json_object_new_string(app_name.c_str()));
- json_object_object_add(obj, wm->kKeyDrawingArea, json_object_new_string("normal.full"));
- wm->activateSurface(obj);
- }
- });
-
- /*
- * Set SoundManager
- */
- smw->wrapper_registerCallback(onEv, onRep);
- smw->subscribe(QString("newMainConnection"));
- smw->subscribe(QString("mainConnectionStateChanged"));
- smw->subscribe(QString("removedMainConnection"));
- smw->subscribe(QString("asyncSetSourceState"));
- smw->subscribe(QString("asyncConnect"));
-
- // Set context property for SoundManager
- context->setContextProperty("smw", smw);
-
-
- /*
- * Load qml
- */
- engine.load(QUrl(QStringLiteral("qrc:/QmlForThisApp.qml")));
-
-
- /*
- * Set slot for WindowManager and SoundManager
- */
- root = engine.rootObjects().first();
- window = qobject_cast<QQuickWindow *>(root);
-
- // Set slot for calling LibWindowmanager::activateSurface() when loading qml have completed
- QObject::connect(window, SIGNAL(frameSwapped()),
- wmh, SLOT(slotActivateSurface()));
-
- // Set slot for SoundManager
- QObject::connect(smw, SIGNAL(smEvent(QVariant, QVariant)),
- root, SLOT(slotEvent(QVariant, QVariant)));
- QObject::connect(smw, SIGNAL(smReply(QVariant)),
- root, SLOT(slotReply(QVariant)));
- }
-
- return app.exec();
-}
-
-static void onRep(struct json_object* reply_contents)
-{
- qDebug("%s is called", __FUNCTION__);
- QString str = QString(json_object_get_string(reply_contents));
- QJsonParseError error;
- QJsonDocument jdoc = QJsonDocument::fromJson(str.toUtf8(), &error);
- QJsonObject jobj = jdoc.object();
-
- smw->emit_reply(jobj);
- json_object_put(reply_contents);
-}
-
-static void onEv(const std::string& event, struct json_object* event_contents)
-{
- qDebug("%s is called", __FUNCTION__);
- 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();
- smw->emit_event(event_name, jobj);
-
- json_object_put(event_contents);
-}
-
diff --git a/src/src.pro b/src/src.pro
new file mode 100644
index 0000000..02d0ae0
--- /dev/null
+++ b/src/src.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += aglextras
diff --git a/sync.profile b/sync.profile
new file mode 100644
index 0000000..7f593f0
--- /dev/null
+++ b/sync.profile
@@ -0,0 +1,8 @@
+%modules = (
+ "QtAGLExtras" => "$basedir/src/aglextras",
+);
+%moduleheaders = (
+);
+%classnames = (
+ "aglapplication.h" => "AGLApplication"
+);
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
new file mode 100644
index 0000000..e792a61
--- /dev/null
+++ b/tests/auto/auto.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += cmake
diff --git a/tests/auto/cmake/cmake.pro b/tests/auto/cmake/cmake.pro
new file mode 100644
index 0000000..398b20e
--- /dev/null
+++ b/tests/auto/cmake/cmake.pro
@@ -0,0 +1,6 @@
+# Cause make to do nothing.
+TEMPLATE = subdirs
+
+CMAKE_QT_MODULES_UNDER_TEST = aglextras
+
+CONFIG += ctest_testcase
diff --git a/tests/tests.pro b/tests/tests.pro
new file mode 100644
index 0000000..157ef34
--- /dev/null
+++ b/tests/tests.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS += auto