aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--homescreen/meson.build35
-rw-r--r--homescreen/src/AglShellManager.cpp80
-rw-r--r--homescreen/src/AglShellManager.h42
-rw-r--r--homescreen/src/Worker.h7
-rw-r--r--homescreen/src/agl_shell.proto29
-rw-r--r--homescreen/src/homescreenhandler.h8
-rw-r--r--homescreen/src/main.cpp35
7 files changed, 233 insertions, 3 deletions
diff --git a/homescreen/meson.build b/homescreen/meson.build
index fc93d06..69d951e 100644
--- a/homescreen/meson.build
+++ b/homescreen/meson.build
@@ -1,5 +1,9 @@
cpp = meson.get_compiler('cpp')
-qt5_dep = dependency('qt5', modules: ['Qml', 'Quick', 'Gui'])
+qt5_dep = dependency('qt5', modules: ['Qml', 'Quick', 'Gui', 'Core'])
+grpcpp_reflection_dep = cpp.find_library('grpc++_reflection')
+protoc = find_program('protoc')
+grpc_cpp = find_program('grpc_cpp_plugin')
+
dep_wayland_client = dependency('wayland-client', version: '>= 1.20.0')
dep_qtappfw = [
dependency('qtappfw-weather'),
@@ -9,6 +13,29 @@ dep_qtappfw = [
dependency('qtappfw-applauncher')
]
+protoc_gen = generator(protoc, \
+ output : ['@BASENAME@.pb.cc', '@BASENAME@.pb.h'],
+ arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/src',
+ '--cpp_out=@BUILD_DIR@',
+ '@INPUT@'])
+
+generated_protoc_sources = protoc_gen.process('src/agl_shell.proto')
+
+grpc_gen = generator(protoc, \
+ output : ['@BASENAME@.grpc.pb.cc', '@BASENAME@.grpc.pb.h'],
+ arguments : ['--proto_path=@CURRENT_SOURCE_DIR@/src',
+ '--grpc_out=@BUILD_DIR@',
+ '--plugin=protoc-gen-grpc=' + grpc_cpp.path(),
+ '@INPUT@'])
+generated_grpc_sources = grpc_gen.process('src/agl_shell.proto')
+
+grpc_deps = [
+ dependency('protobuf'),
+ dependency('grpc'),
+ dependency('grpc++'),
+ grpcpp_reflection_dep,
+]
+
qt_defines = []
qpa_header_path = join_paths(qt5_dep.version(), 'QtGui')
qpa_header = join_paths(qpa_header_path, 'qpa/qplatformnativeinterface.h')
@@ -26,6 +53,7 @@ dir_agl_compositor_base = agl_compositor_dep.get_pkgconfig_variable('pkgdatadir'
homescreen_dep = [
qt5_dep,
+ grpc_deps,
dep_wayland_client,
dep_qtappfw,
]
@@ -83,6 +111,8 @@ homescreen_src_headers = [
'src/statusbarmodel.h',
'src/statusbarserver.h',
'src/homescreenhandler.h',
+ 'src/AglShellManager.h',
+ 'src/Worker.h',
'src/shell.h'
]
@@ -91,12 +121,15 @@ moc_files = qt5.compile_moc(headers: homescreen_src_headers,
homescreen_src = [
'src/shell.cpp',
+ 'src/AglShellManager.cpp',
'src/statusbarserver.cpp',
'src/statusbarmodel.cpp',
'src/applicationlauncher.cpp',
'src/mastervolume.cpp',
'src/homescreenhandler.cpp',
'src/main.cpp',
+ generated_protoc_sources,
+ generated_grpc_sources,
agl_shell_client_protocol_h,
agl_shell_protocol_c
]
diff --git a/homescreen/src/AglShellManager.cpp b/homescreen/src/AglShellManager.cpp
new file mode 100644
index 0000000..1bd1a8c
--- /dev/null
+++ b/homescreen/src/AglShellManager.cpp
@@ -0,0 +1,80 @@
+#include <pthread.h>
+#include <sys/file.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <algorithm>
+#include <cassert>
+#include <climits>
+#include <cstdlib>
+#include <exception>
+#include <fstream>
+#include <iostream>
+#include <set>
+#include <sstream>
+
+#include <grpc/grpc.h>
+#include <grpcpp/grpcpp.h>
+#include <grpcpp/server.h>
+#include <grpcpp/server_builder.h>
+#include <grpcpp/server_context.h>
+
+#include <grpcpp/ext/proto_server_reflection_plugin.h>
+#include <grpcpp/health_check_service_interface.h>
+
+#include "agl_shell.grpc.pb.h"
+
+#include "homescreenhandler.h"
+#include "AglShellManager.h"
+
+grpc::ServerUnaryReactor *
+GrpcServiceImpl::ActivateApp(grpc::CallbackServerContext *context,
+ const ::agl_shell_ipc::ActivateRequest* request,
+ google::protobuf::Empty* /*response*/)
+{
+ fprintf(stderr, "Calling into ActivateApp with app %s and output %s\n",
+ request->app_id().c_str(),
+ request->output_name().c_str());
+
+ HomescreenHandler::Instance()->processAppStatusEvent(QString::fromStdString(request->app_id()),
+ QString::fromUtf8("started", -1));
+
+ grpc::ServerUnaryReactor* reactor = context->DefaultReactor();
+ reactor->Finish(grpc::Status::OK);
+ return reactor;
+}
+
+grpc::ServerUnaryReactor *
+GrpcServiceImpl::DeactivateApp(grpc::CallbackServerContext *context,
+ const ::agl_shell_ipc::DeactivateRequest* request,
+ google::protobuf::Empty* /*response*/)
+{
+ // FIXME, code here
+
+ grpc::ServerUnaryReactor* reactor = context->DefaultReactor();
+ reactor->Finish(grpc::Status::OK);
+ return reactor;
+}
+
+grpc::ServerUnaryReactor *
+GrpcServiceImpl::SetAppSplit(grpc::CallbackServerContext *context,
+ const ::agl_shell_ipc::SplitRequest* request,
+ google::protobuf::Empty* /*response*/)
+{
+ // FIXME, code here
+
+ grpc::ServerUnaryReactor* reactor = context->DefaultReactor();
+ reactor->Finish(grpc::Status::OK);
+ return reactor;
+}
+
+grpc::ServerUnaryReactor *
+GrpcServiceImpl::SetAppFloat(grpc::CallbackServerContext *context,
+ const ::agl_shell_ipc::FloatRequest* request,
+ google::protobuf::Empty* /* response */)
+{
+ // FIXME, code here
+
+ grpc::ServerUnaryReactor* reactor = context->DefaultReactor();
+ reactor->Finish(grpc::Status::OK);
+ return reactor;
+}
diff --git a/homescreen/src/AglShellManager.h b/homescreen/src/AglShellManager.h
new file mode 100644
index 0000000..45e81c9
--- /dev/null
+++ b/homescreen/src/AglShellManager.h
@@ -0,0 +1,42 @@
+#include <climits>
+#include <cstdlib>
+#include <exception>
+#include <fstream>
+#include <iostream>
+#include <set>
+#include <sstream>
+
+#include <grpc/grpc.h>
+#include <grpcpp/grpcpp.h>
+#include <grpcpp/server.h>
+#include <grpcpp/server_builder.h>
+#include <grpcpp/server_context.h>
+
+#include <grpcpp/ext/proto_server_reflection_plugin.h>
+#include <grpcpp/health_check_service_interface.h>
+
+#include "agl_shell.grpc.pb.h"
+
+namespace {
+ const char kDefaultGrpcServiceAddress[] = "127.0.0.1:14004";
+}
+
+
+class GrpcServiceImpl final : public agl_shell_ipc::AglShellManagerService::CallbackService {
+
+ grpc::ServerUnaryReactor *ActivateApp(grpc::CallbackServerContext *context,
+ const ::agl_shell_ipc::ActivateRequest* request,
+ google::protobuf::Empty* /*response*/);
+
+ grpc::ServerUnaryReactor *DeactivateApp(grpc::CallbackServerContext *context,
+ const ::agl_shell_ipc::DeactivateRequest* request,
+ google::protobuf::Empty* /*response*/);
+
+ grpc::ServerUnaryReactor *SetAppSplit(grpc::CallbackServerContext *context,
+ const ::agl_shell_ipc::SplitRequest* request,
+ google::protobuf::Empty* /*response*/);
+
+ grpc::ServerUnaryReactor *SetAppFloat(grpc::CallbackServerContext *context,
+ const ::agl_shell_ipc::FloatRequest* request,
+ google::protobuf::Empty* /*response*/);
+};
diff --git a/homescreen/src/Worker.h b/homescreen/src/Worker.h
new file mode 100644
index 0000000..16ce98e
--- /dev/null
+++ b/homescreen/src/Worker.h
@@ -0,0 +1,7 @@
+#include <QThread>
+
+class WorkerThread : public QThread
+{
+ Q_OBJECT
+ void run() override;
+};
diff --git a/homescreen/src/agl_shell.proto b/homescreen/src/agl_shell.proto
new file mode 100644
index 0000000..721fac2
--- /dev/null
+++ b/homescreen/src/agl_shell.proto
@@ -0,0 +1,29 @@
+syntax = "proto3";
+import "google/protobuf/empty.proto";
+package agl_shell_ipc;
+
+service AglShellManagerService {
+ rpc ActivateApp(ActivateRequest) returns (google.protobuf.Empty) {}
+ rpc DeactivateApp(DeactivateRequest) returns (google.protobuf.Empty) {}
+ rpc SetAppSplit(SplitRequest) returns (google.protobuf.Empty) {}
+ rpc SetAppFloat(FloatRequest) returns (google.protobuf.Empty) {}
+}
+
+message ActivateRequest {
+ string app_id = 1;
+ string output_name = 2;
+}
+
+message DeactivateRequest {
+ string app_id = 1;
+}
+
+message SplitRequest {
+ string app_id = 1;
+ int32 tile_orientation = 2;
+}
+
+message FloatRequest {
+ string app_id = 1;
+}
+
diff --git a/homescreen/src/homescreenhandler.h b/homescreen/src/homescreenhandler.h
index a2baeb2..1d109cf 100644
--- a/homescreen/src/homescreenhandler.h
+++ b/homescreen/src/homescreenhandler.h
@@ -21,7 +21,13 @@ class HomescreenHandler : public QObject
{
Q_OBJECT
public:
- explicit HomescreenHandler(Shell *aglShell, ApplicationLauncher *launcher = 0, QObject *parent = 0);
+ static HomescreenHandler *Instance(Shell *aglShell = 0, ApplicationLauncher *launcher = 0)
+ {
+ static HomescreenHandler *inst = new HomescreenHandler(aglShell, launcher);
+ return inst;
+ }
+
+ explicit HomescreenHandler(Shell *aglShell = 0, ApplicationLauncher *launcher = 0, QObject *parent = 0);
~HomescreenHandler();
Q_INVOKABLE void tapShortcut(QString application_id);
diff --git a/homescreen/src/main.cpp b/homescreen/src/main.cpp
index c910727..98305c8 100644
--- a/homescreen/src/main.cpp
+++ b/homescreen/src/main.cpp
@@ -15,6 +15,7 @@
#include <QtQml/qqml.h>
#include <QQuickWindow>
#include <QTimer>
+#include <QThread>
#include <weather.h>
#include <bluetooth.h>
@@ -31,11 +32,41 @@
#include "agl-shell-client-protocol.h"
#include "shell.h"
+#include "Worker.h"
+#include "AglShellManager.h"
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
+void
+WorkerThread::run()
+{
+ // instantiante the grpc server
+ std::string server_address(kDefaultGrpcServiceAddress);
+ GrpcServiceImpl service;
+
+ grpc::EnableDefaultHealthCheckService(true);
+ grpc::reflection::InitProtoReflectionServerBuilderPlugin();
+
+ grpc::ServerBuilder builder;
+ builder.AddListeningPort(server_address, grpc::InsecureServerCredentials());
+ builder.RegisterService(&service);
+
+ std::unique_ptr<grpc::Server> server(builder.BuildAndStart());
+ fprintf(stderr, "Server listening on %s\n", server_address.c_str());
+
+ server->Wait();
+}
+
+static void
+run_grpc_server(void)
+{
+ WorkerThread *workerThread = new WorkerThread();
+ workerThread->start();
+}
+
+
struct shell_data {
struct agl_shell *shell;
HomescreenHandler *homescreenHandler;
@@ -342,7 +373,7 @@ int main(int argc, char *argv[])
ApplicationLauncher *launcher = new ApplicationLauncher();
launcher->setCurrent(QStringLiteral("launcher"));
- HomescreenHandler* homescreenHandler = new HomescreenHandler(aglShell, launcher);
+ HomescreenHandler* homescreenHandler = HomescreenHandler::Instance(aglShell, launcher);
shell_data.homescreenHandler = homescreenHandler;
QQmlApplicationEngine engine;
@@ -360,5 +391,7 @@ int main(int argc, char *argv[])
// divided now between several surfaces: panels, background.
load_agl_shell_app(native, &engine, shell_data.shell, screen_name, is_demo_val);
+ run_grpc_server();
+
return app.exec();
}