aboutsummaryrefslogtreecommitdiffstats
path: root/homescreen/src
diff options
context:
space:
mode:
Diffstat (limited to 'homescreen/src')
-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
6 files changed, 199 insertions, 2 deletions
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();
}