aboutsummaryrefslogtreecommitdiffstats
path: root/launcher/src
diff options
context:
space:
mode:
Diffstat (limited to 'launcher/src')
-rw-r--r--launcher/src/appinfo.cpp50
-rw-r--r--launcher/src/appinfo.h12
-rw-r--r--launcher/src/homescreenhandler.cpp181
-rw-r--r--launcher/src/homescreenhandler.h15
-rw-r--r--launcher/src/main.cpp36
-rw-r--r--launcher/src/shell-desktop.cpp109
-rw-r--r--launcher/src/shell-desktop.h102
7 files changed, 10 insertions, 495 deletions
diff --git a/launcher/src/appinfo.cpp b/launcher/src/appinfo.cpp
index 78c48ed..b669845 100644
--- a/launcher/src/appinfo.cpp
+++ b/launcher/src/appinfo.cpp
@@ -27,32 +27,18 @@ public:
Private(const Private &other);
QString id;
- QString version;
- int width;
- int height;
QString name;
- QString description;
- QString shortname;
- QString author;
QString iconPath;
};
AppInfo::Private::Private()
- : width(-1)
- , height(-1)
{
}
AppInfo::Private::Private(const Private &other)
: QSharedData(other)
, id(other.id)
- , version(other.version)
- , width(other.width)
- , height(other.height)
, name(other.name)
- , description(other.description)
- , shortname(other.shortname)
- , author(other.author)
, iconPath(other.iconPath)
{
}
@@ -90,41 +76,11 @@ QString AppInfo::id() const
return d->id;
}
-QString AppInfo::version() const
-{
- return d->version;
-}
-
-int AppInfo::width() const
-{
- return d->width;
-}
-
-int AppInfo::height() const
-{
- return d->height;
-}
-
QString AppInfo::name() const
{
return d->name;
}
-QString AppInfo::description() const
-{
- return d->description;
-}
-
-QString AppInfo::shortname() const
-{
- return d->shortname;
-}
-
-QString AppInfo::author() const
-{
- return d->author;
-}
-
QString AppInfo::iconPath() const
{
return d->iconPath;
@@ -133,12 +89,6 @@ QString AppInfo::iconPath() const
void AppInfo::read(const QJsonObject &json)
{
d->id = json["id"].toString();
- d->version = json["version"].toString();
- d->width = json["width"].toInt();
- d->height = json["height"].toInt();
d->name = json["name"].toString();
- d->description = json["description"].toString();
- d->shortname = json["shortname"].toString();
- d->author = json["author"].toString();
d->iconPath = json["iconPath"].toString();
}
diff --git a/launcher/src/appinfo.h b/launcher/src/appinfo.h
index e1b97e6..1d1953d 100644
--- a/launcher/src/appinfo.h
+++ b/launcher/src/appinfo.h
@@ -26,13 +26,7 @@ class AppInfo
{
Q_GADGET
Q_PROPERTY(QString id READ id)
- Q_PROPERTY(QString version READ version)
- Q_PROPERTY(int width READ width)
- Q_PROPERTY(int height READ height)
Q_PROPERTY(QString name READ name)
- Q_PROPERTY(QString description READ description)
- Q_PROPERTY(QString shortname READ shortname)
- Q_PROPERTY(QString author READ author)
Q_PROPERTY(QString iconPath READ iconPath)
public:
AppInfo();
@@ -43,13 +37,7 @@ public:
void swap(AppInfo &other) { qSwap(d, other.d); }
QString id() const;
- QString version() const;
- int width() const;
- int height() const;
QString name() const;
- QString description() const;
- QString shortname() const;
- QString author() const;
QString iconPath() const;
void read(const QJsonObject &json);
diff --git a/launcher/src/homescreenhandler.cpp b/launcher/src/homescreenhandler.cpp
index 4d98414..811daa0 100644
--- a/launcher/src/homescreenhandler.cpp
+++ b/launcher/src/homescreenhandler.cpp
@@ -15,74 +15,9 @@
* limitations under the License.
*/
-#include <QFileInfo>
#include "homescreenhandler.h"
-#include <functional>
#include "hmi-debug.h"
-#include <QGuiApplication>
-#include <wayland-client.h>
-#include <qpa/qplatformnativeinterface.h>
-
-#include "shell-desktop.h"
-
-void* HomescreenHandler::myThis = 0;
-
-static struct wl_output *
-getWlOutput(QPlatformNativeInterface *native, QScreen *screen)
-{
- void *output = native->nativeResourceForScreen("output", screen);
- return static_cast<struct ::wl_output*>(output);
-}
-
-static void
-global_add(void *data, struct wl_registry *reg, uint32_t name,
- const char *interface, uint32_t version)
-{
- struct agl_shell_desktop **shell =
- static_cast<struct agl_shell_desktop **>(data);
-
- if (strcmp(interface, agl_shell_desktop_interface.name) == 0) {
- *shell = static_cast<struct agl_shell_desktop *>(
- wl_registry_bind(reg, name, &agl_shell_desktop_interface, version)
- );
- }
-}
-
-static void
-global_remove(void *data, struct wl_registry *reg, uint32_t id)
-{
- (void) data;
- (void) reg;
- (void) id;
-}
-
-static const struct wl_registry_listener registry_listener = {
- global_add,
- global_remove,
-};
-
-
-static struct agl_shell_desktop *
-register_agl_shell_desktop(void)
-{
- struct wl_display *wl;
- struct wl_registry *registry;
- struct agl_shell_desktop *shell = nullptr;
-
- QPlatformNativeInterface *native = qApp->platformNativeInterface();
-
- wl = static_cast<struct wl_display *>(native->nativeResourceForIntegration("display"));
- registry = wl_display_get_registry(wl);
-
- wl_registry_add_listener(registry, &registry_listener, &shell);
- // Roundtrip to get all globals advertised by the compositor
- wl_display_roundtrip(wl);
- wl_registry_destroy(registry);
-
- return shell;
-}
-
HomescreenHandler::HomescreenHandler(QObject *parent) : QObject(parent)
{
}
@@ -91,124 +26,22 @@ HomescreenHandler::~HomescreenHandler()
{
}
-void HomescreenHandler::init(int port, const char *token, QString myname)
-{
- myThis = this;
- m_myname = myname;
-
- mp_hs = new LibHomeScreen();
- mp_hs->init(port, token);
- mp_hs->registerCallback(nullptr, HomescreenHandler::onRep_static);
-
- struct agl_shell_desktop *agl_shell = register_agl_shell_desktop();
- 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_desktop> shell{agl_shell, agl_shell_desktop_destroy};
- this->aglShell = new Shell(shell, nullptr);
-
- mp_hs->set_event_handler(LibHomeScreen::Event_AppListChanged,[this](json_object *object){
- HMI_DEBUG("Launcher","laucher: appListChanged [%s]\n", json_object_to_json_string(object));
-
- struct json_object *obj_param, *obj_oper, *obj_data;
- if(json_object_object_get_ex(object, "parameter", &obj_param)
- && json_object_object_get_ex(obj_param, "operation", &obj_oper)
- && json_object_object_get_ex(obj_param, "data", &obj_data)) {
- QString oper = json_object_get_string(obj_oper);
- if(oper == "uninstall") {
- /* { "application_id": "launcher",
- * "type": "application-list-changed",
- * "parameter":{
- * "operation": "uninstall",
- * "data": "onstestapp@0.1"
- * }
- * } */
- QString id = json_object_get_string(obj_data);
- QStringList info;
- // icon, name, id
- info << "" << "" << id;
- emit appListUpdate(info);
- }
- else if(oper == "install") {
- /* { "application_id": "launcher",
- * "type": "application-list-changed",
- * "parameter": {
- * "operation": "install",
- * "data": {
- * "description":"This is a demo onstestapp application",
- * "name": "onstestapp",
- * "shortname": "",
- * "id": "onstestapp@0.1",
- * "version": "0.1",
- * "author": "Qt",
- * "author-email": "",
- * "width": "",
- * "height": "",
- * "icon": "\/var\/local\/lib\/afm\/applications\/onstestapp\/0.1\/icon.svg",
- * "http-port": 31022
- * }
- * }
- * } */
- struct json_object *obj_icon, *obj_name, *obj_id;
- if(json_object_object_get_ex(obj_data, "icon", &obj_icon)
- && json_object_object_get_ex(obj_data, "name", &obj_name)
- && json_object_object_get_ex(obj_data, "id", &obj_id)) {
- QString icon = json_object_get_string(obj_icon);
- QString name = json_object_get_string(obj_name);
- QString id = json_object_get_string(obj_id);
- QStringList info;
- // icon, name, id
- info << icon << name << id;
- emit appListUpdate(info);
- }
- }
- else {
- HMI_ERROR("Launcher","error operation.\n");
- }
- }
- });
-}
-
void HomescreenHandler::tapShortcut(QString application_id, QString output_name)
{
HMI_DEBUG("Launcher","tapShortcut %s", application_id.toStdString().c_str());
- struct json_object* j_json = json_object_new_object();
- struct json_object* value;
- 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);
- if (output_name.isEmpty())
- aglShell->activate_app(nullptr, application_id, nullptr);
- else
- aglShell->activate_app_by_screen(output_name, application_id, nullptr);
-}
-
-void HomescreenHandler::onRep_static(struct json_object* reply_contents)
-{
- static_cast<HomescreenHandler*>(HomescreenHandler::myThis)->onRep(reply_contents);
}
void HomescreenHandler::onRep(struct json_object* reply_contents)
{
- HMI_DEBUG("launcher","HomeScreen onReply %s", json_object_to_json_string(reply_contents));
- struct json_object *obj_res, *obj_verb;
- if(json_object_object_get_ex(reply_contents, "response", &obj_res)
- && json_object_object_get_ex(obj_res, "verb", &obj_verb)
- && !strcasecmp("getRunnables", json_object_get_string(obj_verb))) {
- struct json_object *obj_data;
- if(json_object_object_get_ex(obj_res, "data", &obj_data)) {
- HMI_DEBUG("launcher","HomescreenHandler emit initAppList");
- QString data = json_object_to_json_string(obj_data);
- emit initAppList(data);
- }
- }
+ if (reply_contents) {
+ QString data = json_object_to_json_string(reply_contents);
+ HMI_DEBUG("Launcher", "doing an emit initAppList()");
+ emit initAppList(data);
+ } else {
+ HMI_DEBUG("Launcher", "reply contents is invalid!");
+ }
}
void HomescreenHandler::getRunnables(void)
{
- mp_hs->getRunnables();
}
diff --git a/launcher/src/homescreenhandler.h b/launcher/src/homescreenhandler.h
index 471a663..c5d46b4 100644
--- a/launcher/src/homescreenhandler.h
+++ b/launcher/src/homescreenhandler.h
@@ -19,10 +19,11 @@
#define HOMESCREENHANDLER_H
#include <QObject>
-#include <libhomescreen.hpp>
+#include <QString>
+#include <QStringList>
#include <string>
-#include "shell-desktop.h"
+#include <json.h>
using namespace std;
@@ -33,24 +34,14 @@ public:
explicit HomescreenHandler(QObject *parent = 0);
~HomescreenHandler();
- void init(int port, const char* token, QString myname);
-
Q_INVOKABLE void tapShortcut(QString application_id, QString output_name);
Q_INVOKABLE void getRunnables(void);
void onRep(struct json_object* reply_contents);
- static void* myThis;
- static void onRep_static(struct json_object* reply_contents);
-
signals:
void initAppList(QString data);
void appListUpdate(QStringList info);
-
-private:
- LibHomeScreen *mp_hs;
- Shell *aglShell;
- QString m_myname;
};
#endif // HOMESCREENHANDLER_H
diff --git a/launcher/src/main.cpp b/launcher/src/main.cpp
index 22e600e..563e883 100644
--- a/launcher/src/main.cpp
+++ b/launcher/src/main.cpp
@@ -28,55 +28,19 @@
#include "applicationmodel.h"
#include "appinfo.h"
#include "homescreenhandler.h"
-#include "hmi-debug.h"
-#include "shell-desktop.h"
int main(int argc, char *argv[])
{
QString myname = QString("launcher");
QGuiApplication a(argc, argv);
- //QCoreApplication::setOrganizationDomain("LinuxFoundation");
- //QCoreApplication::setOrganizationName("AutomotiveGradeLinux");
- //QCoreApplication::setApplicationName(myname);
- //QCoreApplication::setApplicationVersion("0.1.0");
-
// necessary to identify correctly by app_id
a.setDesktopFileName(myname);
- 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";
-
- if (positionalArguments.length() == 2) {
- port = positionalArguments.takeFirst().toInt();
- token = positionalArguments.takeFirst();
- }
-
- HMI_DEBUG("launcher","port = %d, token = %s", port, token.toStdString().c_str());
-
// import C++ class to QML
qmlRegisterType<ApplicationModel>("AppModel", 1, 0, "ApplicationModel");
HomescreenHandler* homescreenHandler = new HomescreenHandler();
- homescreenHandler->init(port, token.toStdString().c_str(), myname);
-
- 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);
// mail.qml loading
QQmlApplicationEngine engine;
diff --git a/launcher/src/shell-desktop.cpp b/launcher/src/shell-desktop.cpp
deleted file mode 100644
index 8b78f6f..0000000
--- a/launcher/src/shell-desktop.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2020 Collabora Ltd.
- *
- * 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 <QGuiApplication>
-#include <QDebug>
-#include "shell-desktop.h"
-#include <qpa/qplatformnativeinterface.h>
-#include <stdio.h>
-
-static struct wl_output *
-getWlOutput(QScreen *screen)
-{
- QPlatformNativeInterface *native = qApp->platformNativeInterface();
- void *output = native->nativeResourceForScreen("output", screen);
- return static_cast<struct ::wl_output*>(output);
-}
-
-void
-Shell::activate_app(QWindow *win, const QString &app_id,
- const QString &app_data)
-{
- QScreen *screen = nullptr;
- struct wl_output *output;
-
- if (!win || !win->screen()) {
- screen = qApp->screens().first();
- } else {
- screen = win->screen();
- }
-
- if (!screen)
- return;
-
- output = getWlOutput(screen);
- qDebug() << "will activate app: " << app_id;
- agl_shell_desktop_activate_app(this->shell.get(),
- app_id.toStdString().c_str(),
- app_data.toStdString().c_str(), output);
-}
-
-void
-Shell::activate_app_by_screen(const QString &screen_name, const QString &app_id,
- const QString &app_data)
-{
- QScreen *qscreen_to_put = nullptr;
- for (auto &ss: qApp->screens()) {
- if (ss->name() == screen_name) {
- qscreen_to_put = ss;
- break;
- }
- }
-
- /* use the primary one */
- if (!qscreen_to_put) {
- qscreen_to_put = qApp->screens().first();
- }
-
- struct wl_output *output = getWlOutput(qscreen_to_put);
- qDebug() << "will activate app: " << app_id << " on output " <<
- qscreen_to_put->name();
- agl_shell_desktop_activate_app(this->shell.get(),
- app_id.toStdString().c_str(),
- app_data.toStdString().c_str(), output);
-}
-
-void
-Shell::deactivate_app(const QString &app_id)
-{
- agl_shell_desktop_deactivate_app(this->shell.get(),
- app_id.toStdString().c_str());
-}
-
-void
-Shell::set_window_props(QWindow *win, const QString &app_id,
- uint32_t props, int x, int y, int bx, int by,
- int bwidth, int bheight)
-{
- QScreen *screen = nullptr;
- struct wl_output *output;
-
- if (!win || !win->screen()) {
- screen = qApp->screens().first();
- } else {
- screen = win->screen();
- }
-
- if (!screen) {
- return;
- }
-
- output = getWlOutput(screen);
- agl_shell_desktop_set_app_property(this->shell.get(),
- app_id.toStdString().c_str(),
- props, x, y, bx, by,
- bwidth, bheight, output);
-}
diff --git a/launcher/src/shell-desktop.h b/launcher/src/shell-desktop.h
deleted file mode 100644
index fbd053b..0000000
--- a/launcher/src/shell-desktop.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2020 Collabora Ltd.
- *
- * 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 SHELLDESKTOP_H
-#define SHELLDESKTOP_H
-
-#include <QObject>
-#include <QString>
-#include <QScreen>
-#include <QWindow>
-#include <QDebug>
-#include <memory>
-
-
-#include "wayland-agl-shell-desktop-client-protocol.h"
-
-static void
-application_id_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
- const char *app_id);
-static void
-application_state_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
- const char *app_id, const char *app_data,
- uint32_t app_state, uint32_t app_role);
-
-static const struct agl_shell_desktop_listener agl_shell_desktop_listener = {
- application_id_event,
- application_state_event,
-};
-
-class Shell : public QObject
-{
-Q_OBJECT
-
-public:
- std::shared_ptr<struct agl_shell_desktop> shell;
- Shell(std::shared_ptr<struct agl_shell_desktop> shell, QObject *parent = nullptr) :
- QObject(parent), shell(shell)
- {
- struct agl_shell_desktop *agl_shell_desktop = shell.get();
- agl_shell_desktop_add_listener(agl_shell_desktop,
- &agl_shell_desktop_listener, this);
- }
-
-public slots: // calls out of qml into CPP
- void activate_app(QWindow *win, const QString &app_id, const QString &app_data);
- void activate_app_by_screen(const QString &screen_name,
- const QString &app_id,
- const QString &app_data);
- void deactivate_app(const QString &app_id);
- void set_window_props(QWindow *win, const QString &app_id,
- uint32_t props, int x, int y, int bx, int by,
- int bwidth, int bheight);
-};
-
-static void
-application_id_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
- const char *app_id)
-{
- Shell *aglShell = static_cast<Shell *>(data);
- (void) agl_shell_desktop;
-
- qInfo() << "app_id: " << app_id;
-
- // this ain't necessary in case the default policy API will activate
- // applications by default (when they are started) but if that is not
- // the case we can use this event handler to activate the application
- // as this event is sent when the application is created (when the app
- // surface is created that is); note this event is sent when launcher
- // binds to the interface for each application present, besides being
- // adevertised when the application surface is created; so the
- // following will need some kind of filtering to avoid mass activation
- //QString qstr_app_id = QString::fromUtf8(app_id, -1);
- //aglShell->activate_app(nullptr, qstr_app_id, nullptr);
-}
-
-static void
-application_state_event(void *data, struct agl_shell_desktop *agl_shell_desktop,
- const char *app_id, const char *app_data,
- uint32_t app_state, uint32_t app_role)
-{
- (void) data;
- (void) agl_shell_desktop;
- (void) app_id;
- (void) app_data;
- (void) app_state;
- (void) app_role;
-}
-
-#endif // SHELLDESKTOP_H