2 * Copyright © 2022 Collabora, Ltd.
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to
9 * permit persons to whom the Software is furnished to do so, subject to
10 * the following conditions:
12 * The above copyright notice and this permission notice (including the
13 * next paragraph) shall be included in all copies or substantial
14 * portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 #define GRPC_CALLBACK_API_NONEXPERIMENTAL
32 #include <grpc/grpc.h>
33 #include <grpcpp/grpcpp.h>
34 #include <grpcpp/server.h>
35 #include <grpcpp/server_builder.h>
36 #include <grpcpp/server_context.h>
39 #include <condition_variable>
41 #include <grpcpp/ext/proto_server_reflection_plugin.h>
42 #include <grpcpp/health_check_service_interface.h>
45 #include "agl_shell.grpc.pb.h"
48 const char kDefaultGrpcServiceAddress[] = "127.0.0.1:14005";
51 class Lister : public grpc::ServerWriteReactor<::agl_shell_ipc::AppStateResponse> {
53 Lister(Shell *aglShell);
54 void OnDone() override;
55 void OnWriteDone(bool ok) override;
63 class GrpcServiceImpl final : public agl_shell_ipc::AglShellManagerService::CallbackService {
65 GrpcServiceImpl(Shell *aglShell) : m_aglShell(aglShell) {}
66 void setAglShell(Shell *_aglShell) { m_aglShell = _aglShell; }
68 grpc::ServerUnaryReactor *ActivateApp(grpc::CallbackServerContext *context,
69 const ::agl_shell_ipc::ActivateRequest* request,
70 ::agl_shell_ipc::ActivateResponse* /*response*/) override;
72 grpc::ServerUnaryReactor *DeactivateApp(grpc::CallbackServerContext *context,
73 const ::agl_shell_ipc::DeactivateRequest* request,
74 ::agl_shell_ipc::DeactivateResponse* /*response*/) override;
76 grpc::ServerUnaryReactor *SetAppFloat(grpc::CallbackServerContext *context,
77 const ::agl_shell_ipc::FloatRequest* request,
78 ::agl_shell_ipc::FloatResponse* /*response*/) override;
80 grpc::ServerUnaryReactor *SetAppSplit(grpc::CallbackServerContext *context,
81 const ::agl_shell_ipc::SplitRequest* request,
82 ::agl_shell_ipc::SplitResponse* /*response*/) override;
84 grpc::ServerUnaryReactor *GetOutputs(grpc::CallbackServerContext *context,
85 const ::agl_shell_ipc::OutputRequest* /* request */,
86 ::agl_shell_ipc::ListOutputResponse* response) override;
88 grpc::ServerUnaryReactor *SetAppNormal(grpc::CallbackServerContext *context,
89 const ::agl_shell_ipc::NormalRequest* request,
90 ::agl_shell_ipc::NormalResponse* /*response*/) override;
92 grpc::ServerUnaryReactor *SetAppFullscreen(grpc::CallbackServerContext *context,
93 const ::agl_shell_ipc::FullscreenRequest* request,
94 ::agl_shell_ipc::FullscreenResponse* /*response*/) override;
96 grpc::ServerUnaryReactor *SetAppOnOutput(grpc::CallbackServerContext *context,
97 const ::agl_shell_ipc::AppOnOutputRequest* request,
98 ::agl_shell_ipc::AppOnOutputResponse* /*response*/) override;
100 grpc::ServerUnaryReactor *SetAppPosition(grpc::CallbackServerContext *context,
101 const ::agl_shell_ipc::AppPositionRequest* request,
102 ::agl_shell_ipc::AppPositionResponse* /*response*/) override;
104 grpc::ServerUnaryReactor *SetAppScale(grpc::CallbackServerContext *context,
105 const ::agl_shell_ipc::AppScaleRequest* request,
106 ::agl_shell_ipc::AppScaleResponse* /*response*/) override;
108 grpc::ServerWriteReactor< ::agl_shell_ipc::AppStateResponse>* AppStatusState(
109 ::grpc::CallbackServerContext* /*context*/,
110 const ::agl_shell_ipc::AppStateRequest* /*request*/) override;
113 Shell *m_aglShell = nullptr;