summaryrefslogtreecommitdiffstats
path: root/homescreen/src
diff options
context:
space:
mode:
Diffstat (limited to 'homescreen/src')
-rw-r--r--homescreen/src/applicationlauncher.cpp2
-rw-r--r--homescreen/src/hmi-debug.h79
-rw-r--r--homescreen/src/homescreenhandler.cpp86
-rw-r--r--homescreen/src/homescreenhandler.h4
-rw-r--r--homescreen/src/main.cpp172
5 files changed, 85 insertions, 258 deletions
diff --git a/homescreen/src/applicationlauncher.cpp b/homescreen/src/applicationlauncher.cpp
index 6bb0729..48560e6 100644
--- a/homescreen/src/applicationlauncher.cpp
+++ b/homescreen/src/applicationlauncher.cpp
@@ -20,8 +20,6 @@
#include "applicationlauncher.h"
-#include "hmi-debug.h"
-
ApplicationLauncher::ApplicationLauncher(QObject *parent)
: QObject(parent)
, m_launching(false)
diff --git a/homescreen/src/hmi-debug.h b/homescreen/src/hmi-debug.h
deleted file mode 100644
index 47ae1f7..0000000
--- a/homescreen/src/hmi-debug.h
+++ /dev/null
@@ -1,79 +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.
- */
-
-#ifndef __HMI_DEBUG_H__
-#define __HMI_DEBUG_H__
-
-#include <time.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-
-enum LOG_LEVEL{
- LOG_LEVEL_NONE = 0,
- LOG_LEVEL_ERROR,
- LOG_LEVEL_WARNING,
- LOG_LEVEL_NOTICE,
- LOG_LEVEL_INFO,
- LOG_LEVEL_DEBUG,
- LOG_LEVEL_MAX = LOG_LEVEL_DEBUG
-};
-
-#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
-
-#define HMI_ERROR(prefix, args,...) _HMI_LOG(LOG_LEVEL_ERROR, __FILENAME__, __FUNCTION__, __LINE__, prefix, args, ##__VA_ARGS__)
-#define HMI_WARNING(prefix, args,...) _HMI_LOG(LOG_LEVEL_WARNING, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
-#define HMI_NOTICE(prefix, args,...) _HMI_LOG(LOG_LEVEL_NOTICE, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
-#define HMI_INFO(prefix, args,...) _HMI_LOG(LOG_LEVEL_INFO, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
-#define HMI_DEBUG(prefix, args,...) _HMI_LOG(LOG_LEVEL_DEBUG, __FILENAME__, __FUNCTION__,__LINE__, prefix, args,##__VA_ARGS__)
-
-static char ERROR_FLAG[6][20] = {"NONE", "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG"};
-
-static void _HMI_LOG(enum LOG_LEVEL level, const char* file, const char* func, const int line, const char* prefix, const char* log, ...)
-{
- char *message;
- struct timespec tp;
- uint32_t time;
- va_list args;
- int ret;
- const int log_level = (getenv("USE_HMI_DEBUG") == NULL) ? LOG_LEVEL_ERROR : atoi(getenv("USE_HMI_DEBUG"));
-
- if(log_level < level) {
- return;
- }
-
- va_start(args, log);
- if (vasprintf(&message, log, args) < 0) {
- fprintf(stderr, "Warning: message is NULL\n");
- vfprintf(stderr, log, args);
- fprintf(stderr, "\n");
- message = NULL;
- }
-
- clock_gettime(CLOCK_REALTIME, &tp);
- time = (tp.tv_sec * 1000000L) + (tp.tv_nsec / 1000);
- if (tp.tv_nsec % 1000 >= 500) {
- time++;
- }
-
- fprintf(stderr, "[%10.3f] [%s %s] [%s, %s(), Line:%d] >>> %s \n", time / 1000.0, prefix, ERROR_FLAG[level], file, func, line, message);
-
- va_end(args);
- free(message);
-}
-
-#endif //__HMI_DEBUG_H__
diff --git a/homescreen/src/homescreenhandler.cpp b/homescreen/src/homescreenhandler.cpp
index e31f122..6d7941e 100644
--- a/homescreen/src/homescreenhandler.cpp
+++ b/homescreen/src/homescreenhandler.cpp
@@ -18,71 +18,24 @@
#include <QFileInfo>
#include "homescreenhandler.h"
#include <functional>
-#include "hmi-debug.h"
#include <qpa/qplatformnativeinterface.h>
void* HomescreenHandler::myThis = 0;
HomescreenHandler::HomescreenHandler(Shell *_aglShell, ApplicationLauncher *launcher, QObject *parent) :
- QObject(parent),
- aglShell(_aglShell)
+ QObject(parent),
+ aglShell(_aglShell)
{
- mp_launcher = launcher;
+ mp_launcher = launcher;
}
HomescreenHandler::~HomescreenHandler()
{
- if (mp_hs != NULL) {
- delete mp_hs;
- }
}
-void HomescreenHandler::init(int port, const char *token)
+void HomescreenHandler::init()
{
- mp_hs = new LibHomeScreen();
- mp_hs->init(port, token);
-
- myThis = this;
-
-
- mp_hs->registerCallback(nullptr, HomescreenHandler::onRep_static);
-
- mp_hs->set_event_handler(LibHomeScreen::Event_OnScreenMessage, [this](json_object *object){
- const char *display_message = json_object_get_string(
- json_object_object_get(object, "display_message"));
- HMI_DEBUG("HomeScreen","set_event_handler Event_OnScreenMessage display_message = %s", display_message);
- });
-
- // should be handled in the top panel
- mp_hs->set_event_handler(LibHomeScreen::Event_ShowNotification,[this](json_object *object){
- json_object *p_obj = json_object_object_get(object, "parameter");
- const char *icon = json_object_get_string(
- json_object_object_get(p_obj, "icon"));
- const char *text = json_object_get_string(
- json_object_object_get(p_obj, "text"));
- const char *app_id = json_object_get_string(
- json_object_object_get(p_obj, "caller"));
- HMI_DEBUG("HomeScreen","Event_ShowNotification icon=%s, text=%s, caller=%s", icon, text, app_id);
- QFileInfo icon_file(icon);
- QString icon_path;
- if (icon_file.isFile() && icon_file.exists()) {
- icon_path = QString(QLatin1String(icon));
- } else {
- icon_path = "./images/Utility_Logo_Grey-01.svg";
- }
-
- emit showNotification(QString(QLatin1String(app_id)), icon_path, QString(QLatin1String(text)));
- });
-
- // should be handled in the bottom panel
- mp_hs->set_event_handler(LibHomeScreen::Event_ShowInformation,[this](json_object *object){
- json_object *p_obj = json_object_object_get(object, "parameter");
- const char *info = json_object_get_string(
- json_object_object_get(p_obj, "info"));
-
- emit showInformation(QString(QLatin1String(info)));
- });
}
static struct wl_output *
@@ -94,19 +47,11 @@ getWlOutput(QPlatformNativeInterface *native, QScreen *screen)
void HomescreenHandler::tapShortcut(QString application_id)
{
- HMI_DEBUG("HomeScreen","tapShortcut %s", application_id.toStdString().c_str());
-
- struct json_object* j_json = json_object_new_object();
- struct json_object* value;
-
struct agl_shell *agl_shell = aglShell->shell.get();
QPlatformNativeInterface *native = qApp->platformNativeInterface();
struct wl_output *output = getWlOutput(native, qApp->screens().first());
- value = json_object_new_string("normal.full");
- json_object_object_add(j_json, "area", value);
-
- mp_hs->showWindow(application_id.toStdString().c_str(), j_json);
+ // start the application here, or do in the WM!
// this works (and it is redundant the first time), due to the default
// policy engine installed which actives the application, when starting
@@ -114,6 +59,7 @@ void HomescreenHandler::tapShortcut(QString application_id)
// require calling 'agl_shell_activate_app'
agl_shell_activate_app(agl_shell, application_id.toStdString().c_str(), output);
+ // keep this for having animations working
if (mp_launcher) {
mp_launcher->setCurrent(application_id);
}
@@ -121,30 +67,22 @@ void HomescreenHandler::tapShortcut(QString application_id)
void HomescreenHandler::onRep_static(struct json_object* reply_contents)
{
- static_cast<HomescreenHandler*>(HomescreenHandler::myThis)->onRep(reply_contents);
+ (void) reply_contents;
}
void HomescreenHandler::onEv_static(const string& event, struct json_object* event_contents)
{
- static_cast<HomescreenHandler*>(HomescreenHandler::myThis)->onEv(event, event_contents);
+ (void) event;
+ (void) event_contents;
}
void HomescreenHandler::onRep(struct json_object* reply_contents)
{
- const char* str = json_object_to_json_string(reply_contents);
- HMI_DEBUG("HomeScreen","HomeScreen onReply %s", str);
+ (void) reply_contents;
}
void HomescreenHandler::onEv(const string& event, struct json_object* event_contents)
{
- const char* str = json_object_to_json_string(event_contents);
- HMI_DEBUG("HomeScreen","HomeScreen onEv %s, contents: %s", event.c_str(), str);
-
- if (event.compare("homescreen/on_screen_message") == 0) {
- struct json_object *json_data = json_object_object_get(event_contents, "data");
- struct json_object *json_display_message = json_object_object_get(json_data, "display_message");
- const char* display_message = json_object_get_string(json_display_message);
-
- HMI_DEBUG("HomeScreen","display_message = %s", display_message);
- }
+ (void) event;
+ (void) event_contents;
}
diff --git a/homescreen/src/homescreenhandler.h b/homescreen/src/homescreenhandler.h
index 790c4fd..9cdccba 100644
--- a/homescreen/src/homescreenhandler.h
+++ b/homescreen/src/homescreenhandler.h
@@ -19,7 +19,6 @@
#include <QObject>
-#include <libhomescreen.hpp>
#include "applicationlauncher.h"
#include "shell.h"
@@ -34,7 +33,7 @@ public:
explicit HomescreenHandler(Shell *aglShell, ApplicationLauncher *launcher = 0, QObject *parent = 0);
~HomescreenHandler();
- void init(int port, const char* token);
+ void init();
Q_INVOKABLE void tapShortcut(QString application_id);
@@ -49,7 +48,6 @@ signals:
void showNotification(QString application_id, QString icon_path, QString text);
void showInformation(QString info);
private:
- LibHomeScreen *mp_hs;
ApplicationLauncher *mp_launcher;
Shell *aglShell;
};
diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp
index 376644f..98f6c93 100644
--- a/homescreen/src/main.cpp
+++ b/homescreen/src/main.cpp
@@ -26,14 +26,13 @@
#include <QQuickWindow>
#include <QTimer>
-#include <weather.h>
-#include <bluetooth.h>
+//#include <weather.h>
+//#include <bluetooth.h>
#include "applicationlauncher.h"
-#include "statusbarmodel.h"
-#include "mastervolume.h"
+//#include "statusbarmodel.h"
+//#include "mastervolume.h"
#include "homescreenhandler.h"
-#include "hmi-debug.h"
-#include "chromecontroller.h"
+//#include "chromecontroller.h"
#include <qpa/qplatformnativeinterface.h>
#include <wayland-client.h>
@@ -137,7 +136,7 @@ find_screen(const char *screen_name)
static void
load_agl_shell_app(QPlatformNativeInterface *native,
QQmlApplicationEngine *engine,
- struct agl_shell *agl_shell, QUrl &bindingAddress,
+ struct agl_shell *agl_shell,
const char *screen_name, bool is_demo)
{
struct wl_surface *bg, *top, *bottom;
@@ -184,11 +183,11 @@ load_agl_shell_app(QPlatformNativeInterface *native,
/* engine.rootObjects() works only if we had a load() */
- StatusBarModel *statusBar = qobj_top->findChild<StatusBarModel *>("statusBar");
- if (statusBar) {
- qDebug() << "got statusBar objectname, doing init()";
- statusBar->init(bindingAddress, engine->rootContext());
- }
+ //StatusBarModel *statusBar = qobj_top->findChild<StatusBarModel *>("statusBar");
+ //if (statusBar) {
+ // qDebug() << "got statusBar objectname, doing init()";
+ // statusBar->init(bindingAddress, engine->rootContext());
+ //}
agl_shell_set_panel(agl_shell, top, output, AGL_SHELL_EDGE_TOP);
agl_shell_set_panel(agl_shell, bottom, output, AGL_SHELL_EDGE_BOTTOM);
@@ -205,92 +204,65 @@ load_agl_shell_app(QPlatformNativeInterface *native,
int main(int argc, char *argv[])
{
- setenv("QT_QPA_PLATFORM", "wayland", 1);
- QGuiApplication a(argc, argv);
- const char *screen_name;
- bool is_demo_val = false;
-
- QPlatformNativeInterface *native = qApp->platformNativeInterface();
- struct agl_shell *agl_shell = nullptr;
- screen_name = getenv("HOMESCREEN_START_SCREEN");
-
- const char *is_demo = getenv("HOMESCREEN_DEMO_CI");
- if (is_demo && strcmp(is_demo, "1") == 0)
- is_demo_val = true;
-
- QCoreApplication::setOrganizationDomain("LinuxFoundation");
- QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
- QCoreApplication::setApplicationName("HomeScreen");
- QCoreApplication::setApplicationVersion("0.7.0");
- /* we need to have an app_id */
- a.setDesktopFileName("homescreen");
-
- QCommandLineParser parser;
- parser.addPositionalArgument("port", a.translate("main", "port for binding"));
- parser.addPositionalArgument("secret", a.translate("main", "secret for binding"));
- parser.addHelpOption();
- parser.addVersionOption();
- parser.process(a);
- QStringList positionalArguments = parser.positionalArguments();
-
- int port = 1700;
- QString token = "wm";
- QString graphic_role = "homescreen"; // defined in layers.json in Window Manager
-
- if (positionalArguments.length() == 2) {
- port = positionalArguments.takeFirst().toInt();
- token = positionalArguments.takeFirst();
- }
-
- HMI_DEBUG("HomeScreen","port = %d, token = %s", port, token.toStdString().c_str());
-
- agl_shell = register_agl_shell(native);
- if (!agl_shell) {
- fprintf(stderr, "agl_shell extension is not advertised. "
- "Are you sure that agl-compositor is running?\n");
- exit(EXIT_FAILURE);
- }
-
- std::shared_ptr<struct agl_shell> shell{agl_shell, agl_shell_destroy};
- Shell *aglShell = new Shell(shell, &a);
-
- // import C++ class to QML
- qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel");
- qmlRegisterType<MasterVolume>("MasterVolume", 1, 0, "MasterVolume");
- qmlRegisterUncreatableType<ChromeController>("SpeechChrome", 1, 0, "SpeechChromeController",
- QLatin1String("SpeechChromeController is uncreatable."));
-
- ApplicationLauncher *launcher = new ApplicationLauncher();
- launcher->setCurrent(QStringLiteral("launcher"));
- HomescreenHandler* homescreenHandler = new HomescreenHandler(aglShell, launcher);
- homescreenHandler->init(port, token.toStdString().c_str());
-
- QUrl bindingAddress;
- 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);
-
- QQmlApplicationEngine engine;
- QQmlContext *context = engine.rootContext();
- context->setContextProperty("bindingAddress", bindingAddress);
-
- context->setContextProperty("homescreenHandler", homescreenHandler);
- context->setContextProperty("launcher", launcher);
- context->setContextProperty("weather", new Weather(bindingAddress));
- context->setContextProperty("bluetooth", new Bluetooth(bindingAddress, context));
- context->setContextProperty("speechChromeController", new ChromeController(bindingAddress, &engine));
- // we add it here even if we don't use it
- context->setContextProperty("shell", aglShell);
-
- /* instead of loading main.qml we load one-by-one each of the QMLs,
- * divided now between several surfaces: panels, background.
- */
- load_agl_shell_app(native, &engine, agl_shell, bindingAddress, screen_name, is_demo_val);
-
- return a.exec();
+ // keep this as we're not going not going to have the appfw
+ setenv("QT_QPA_PLATFORM", "wayland", 1);
+
+ QGuiApplication a(argc, argv);
+ const char *screen_name;
+ bool is_demo_val = false;
+
+ QPlatformNativeInterface *native = qApp->platformNativeInterface();
+ struct agl_shell *agl_shell = nullptr;
+ screen_name = getenv("HOMESCREEN_START_SCREEN");
+
+ // could be removed only for CI
+ const char *is_demo = getenv("HOMESCREEN_DEMO_CI");
+ if (is_demo && strcmp(is_demo, "1") == 0)
+ is_demo_val = true;
+
+ QCoreApplication::setOrganizationDomain("LinuxFoundation");
+ QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
+ QCoreApplication::setApplicationName("HomeScreen");
+ QCoreApplication::setApplicationVersion("0.7.0");
+
+ // we need to have an app_id
+ a.setDesktopFileName("homescreen");
+
+ agl_shell = register_agl_shell(native);
+ if (!agl_shell) {
+ fprintf(stderr, "agl_shell extension is not advertised. "
+ "Are you sure that agl-compositor is running?\n");
+ exit(EXIT_FAILURE);
+ }
+
+ std::shared_ptr<struct agl_shell> shell{agl_shell, agl_shell_destroy};
+ Shell *aglShell = new Shell(shell, &a);
+
+ // import C++ class to QML
+ //qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel");
+ //qmlRegisterType<MasterVolume>("MasterVolume", 1, 0, "MasterVolume");
+ //qmlRegisterUncreatableType<ChromeController>("SpeechChrome", 1, 0, "SpeechChromeController", QLatin1String("SpeechChromeController is uncreatable."));
+
+ ApplicationLauncher *launcher = new ApplicationLauncher();
+ launcher->setCurrent(QStringLiteral("launcher"));
+ HomescreenHandler* homescreenHandler = new HomescreenHandler(aglShell, launcher);
+ homescreenHandler->init();
+
+ QQmlApplicationEngine engine;
+ QQmlContext *context = engine.rootContext();
+
+ context->setContextProperty("homescreenHandler", homescreenHandler);
+ context->setContextProperty("launcher", launcher);
+ //context->setContextProperty("weather", new Weather(bindingAddress));
+ //context->setContextProperty("bluetooth", new Bluetooth(bindingAddress, context));
+ //context->setContextProperty("speechChromeController", new ChromeController(bindingAddress, &engine));
+
+ // we add it here even if we don't use it
+ context->setContextProperty("shell", aglShell);
+
+ /* instead of loading main.qml we load one-by-one each of the QMLs,
+ * divided now between several surfaces: panels, background. */
+ load_agl_shell_app(native, &engine, agl_shell, screen_name, is_demo_val);
+
+ return a.exec();
}