diff options
author | 2023-10-11 12:08:16 +0300 | |
---|---|---|
committer | 2023-10-26 00:41:50 +0300 | |
commit | 36e2c9697e431414ae0263635f3ebf1f3c200723 (patch) | |
tree | 5a4c103039ee6e0a7f68c3e34248893f3425899a /homescreen/src/main.cpp | |
parent | 8db829a4a790e30b5dfd27b531aa8018918fde10 (diff) |
AglShellGrpcClient: Add activation with gRPC proxy
This follow-ups in footsteps of flutter-homescreen to have activation
using gRPC. Note that setting up wayland surfaces is still need to
have the agl-shell protocol available. In Qt this is managed directly
by Qt/QPA while on other toolkits this happens at a lower level
(flutter-auto or chromium CEF).
With it, create a listening thread for gRRC events in order to perform
the initial start + activate sequence.
Bug-AGL: SPEC-4912
Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Change-Id: I019d0e7944dde02c84b2841e22d3971f226d610a
Diffstat (limited to 'homescreen/src/main.cpp')
-rw-r--r-- | homescreen/src/main.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp index d0bd2c3..b004fd5 100644 --- a/homescreen/src/main.cpp +++ b/homescreen/src/main.cpp @@ -3,6 +3,7 @@ * Copyright (C) 2016, 2017 Mentor Graphics Development (Deutschland) GmbH * Copyright (c) 2017, 2018 TOYOTA MOTOR CORPORATION * Copyright (c) 2022 Konsulko Group + * Copyright (c) 2023 Collabora, Ltd. */ #include <QGuiApplication> @@ -32,6 +33,9 @@ #include "agl-shell-client-protocol.h" #include "shell.h" +#include <thread> +#include "AglShellGrpcClient.h" + #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif @@ -361,6 +365,20 @@ load_agl_shell_app(QPlatformNativeInterface *native, QQmlApplicationEngine *engi }); } +static void +run_in_thread(GrpcClient *client) +{ + grpc::Status status = client->Wait(); +} + +static void +app_status_callback(::agl_shell_ipc::AppStateResponse app_response) +{ + std::cout << " >> AppStateResponse app_id " << + app_response.app_id() << ", with state " << + app_response.state() << std::endl; +} + int main(int argc, char *argv[]) { setenv("QT_QPA_PLATFORM", "wayland", 1); @@ -416,7 +434,6 @@ int main(int argc, char *argv[]) std::shared_ptr<struct agl_shell> agl_shell{shell_data.shell, agl_shell_destroy}; - Shell *aglShell = new Shell(agl_shell, &app); // Import C++ class to QML qmlRegisterType<StatusBarModel>("HomeScreen", 1, 0, "StatusBarModel"); @@ -425,7 +442,13 @@ int main(int argc, char *argv[]) ApplicationLauncher *launcher = new ApplicationLauncher(); launcher->setCurrent(QStringLiteral("launcher")); - HomescreenHandler* homescreenHandler = new HomescreenHandler(aglShell, launcher); + GrpcClient *client = new GrpcClient(); + + // create a new thread to listner for gRPC events + std::thread th = std::thread(run_in_thread, client); + client->AppStatusState(app_status_callback); + + HomescreenHandler* homescreenHandler = new HomescreenHandler(launcher, client); shell_data.homescreenHandler = homescreenHandler; QQmlApplicationEngine engine; @@ -436,9 +459,6 @@ int main(int argc, char *argv[]) context->setContextProperty("weather", new Weather()); context->setContextProperty("bluetooth", new Bluetooth(false, context)); - // We add it here even if we don't use it - context->setContextProperty("shell", aglShell); - load_agl_shell_app(native, &engine, shell_data.shell, screen_name, is_demo_val); |