libaurum: apply smart pointer wider and extract impl out
[platform/core/uifw/aurum.git] / org.tizen.aurum-bootstrap / src / AurumServiceImpl.cc
1 #include "AurumServiceImpl.h"
2
3 #include <AccessibleWatcher.h>
4 #include "Commands/Commands.h"
5 #include "Commands/PostCommand.h"
6 #include "Commands/PreCommand.h"
7
8 #include "config.h"
9 #include <loguru.hpp>
10
11 using namespace grpc;
12 using namespace aurum;
13
14 aurumServiceImpl::aurumServiceImpl()
15 {
16     AccessibleWatcher::getInstance();
17 }
18
19 ::grpc::Status aurumServiceImpl::execute(Command* cmd)
20 {
21     std::unique_ptr<PreCommand>  proxyPreCmd  = std::make_unique<PreCommand>(cmd);
22     std::unique_ptr<PostCommand> proxyPostCmd = std::make_unique<PostCommand>(proxyPreCmd.get());
23     ::grpc::Status rst = proxyPostCmd->execute();
24     return rst;
25 }
26
27 aurumServiceImpl::~aurumServiceImpl() {}
28 ::grpc::Status aurumServiceImpl::aurumServiceImpl::sync(
29     ::grpc::ServerContext* context, const ::aurum::ReqEmpty* request,
30     ::aurum::RspEmpty* response)
31 {
32     std::unique_ptr<SyncCommand> cmd = std::make_unique<SyncCommand>(request, response);
33     return execute(cmd.get());
34 }
35 ::grpc::Status aurumServiceImpl::aurumServiceImpl::killServer(
36     ::grpc::ServerContext* context, const ::aurum::ReqEmpty* request,
37     ::aurum::RspEmpty* response)
38 {
39     std::unique_ptr<KillServerCommand> cmd = std::make_unique<KillServerCommand>(request, response);
40     return execute(cmd.get());
41 }
42 ::grpc::Status aurumServiceImpl::aurumServiceImpl::findElement(
43     ::grpc::ServerContext* context, const ::aurum::ReqFindElement* request,
44     ::aurum::RspFindElement* response)
45 {
46     std::unique_ptr<FindElementCommand> cmd = std::make_unique<FindElementCommand>(request, response);
47     return execute(cmd.get());
48 }
49
50 ::grpc::Status aurumServiceImpl::aurumServiceImpl::click(
51     ::grpc::ServerContext* context, const ::aurum::ReqClick* request,
52     ::aurum::RspClick* response)
53 {
54     std::unique_ptr<ClickCommand> cmd = ClickCommand::createCommand(request, response);
55     return execute(cmd.get());
56 }
57 ::grpc::Status aurumServiceImpl::getValue(::grpc::ServerContext*      context,
58                                           const ::aurum::ReqGetValue* request,
59                                           ::aurum::RspGetValue*       response)
60 {
61     std::unique_ptr<GetValueCommand> cmd = std::make_unique<GetValueCommand>(request, response);
62     return execute(cmd.get());
63 }
64 ::grpc::Status aurumServiceImpl::setValue(::grpc::ServerContext*      context,
65                                           const ::aurum::ReqSetValue* request,
66                                           ::aurum::RspSetValue*       response)
67 {
68     std::unique_ptr<SetValueCommand> cmd = std::make_unique<SetValueCommand>(request, response);
69     return execute(cmd.get());
70 }
71 ::grpc::Status aurumServiceImpl::getAttribute(
72     ::grpc::ServerContext* context, const ::aurum::ReqGetAttribute* request,
73     ::aurum::RspGetAttribute* response)
74 {
75     std::unique_ptr<GetAttributeCommand> cmd = GetAttributeCommand::createCommand(request, response);
76     return execute(cmd.get());
77 }
78 ::grpc::Status aurumServiceImpl::getSize(::grpc::ServerContext*     context,
79                                          const ::aurum::ReqGetSize* request,
80                                          ::aurum::RspGetSize*       response)
81 {
82     std::unique_ptr<GetSizeCommand> cmd = std::make_unique<GetSizeCommand>(request, response);
83     return execute(cmd.get());
84 }
85 ::grpc::Status aurumServiceImpl::clear(::grpc::ServerContext*   context,
86                                        const ::aurum::ReqClear* request,
87                                        ::aurum::RspClear*       response)
88 {
89     std::unique_ptr<ClearCommand> cmd = std::make_unique<ClearCommand>(request, response);
90     return execute(cmd.get());
91 }
92 ::grpc::Status aurumServiceImpl::installApp(
93     ::grpc::ServerContext*                         context,
94     ::grpc::ServerReader< ::aurum::ReqInstallApp>* request,
95     ::aurum::RspInstallApp*                        response)
96 {
97     std::unique_ptr<InstallAppCommand> cmd = std::make_unique<InstallAppCommand>(request, response);
98     return execute(cmd.get());
99 }
100 ::grpc::Status aurumServiceImpl::removeApp(::grpc::ServerContext*       context,
101                                            const ::aurum::ReqRemoveApp* request,
102                                            ::aurum::RspRemoveApp* response)
103 {
104     std::unique_ptr<RemoveAppCommand> cmd = std::make_unique<RemoveAppCommand>(request, response);
105     return execute(cmd.get());
106 }
107 ::grpc::Status aurumServiceImpl::getAppInfo(
108     ::grpc::ServerContext* context, const ::aurum::ReqGetAppInfo* request,
109     ::aurum::RspGetAppInfo* response)
110 {
111     std::unique_ptr<GetAppInfoCommand> cmd = std::make_unique<GetAppInfoCommand>(request, response);
112     return execute(cmd.get());
113 }
114 ::grpc::Status aurumServiceImpl::launchApp(::grpc::ServerContext*       context,
115                                            const ::aurum::ReqLaunchApp* request,
116                                            ::aurum::RspLaunchApp* response)
117 {
118     std::unique_ptr<LaunchAppCommand> cmd = std::make_unique<LaunchAppCommand>(request, response);
119     return execute(cmd.get());
120 }
121 ::grpc::Status aurumServiceImpl::closeApp(::grpc::ServerContext*      context,
122                                           const ::aurum::ReqCloseApp* request,
123                                           ::aurum::RspCloseApp*       response)
124 {
125     std::unique_ptr<CloseAppCommand> cmd = std::make_unique<CloseAppCommand>(request, response);
126     return execute(cmd.get());
127 }
128 ::grpc::Status aurumServiceImpl::touchDown(::grpc::ServerContext*       context,
129                                            const ::aurum::ReqTouchDown* request,
130                                            ::aurum::RspTouchDown* response)
131 {
132     std::unique_ptr<TouchDownCommand> cmd = std::make_unique<TouchDownCommand>(request, response);
133     return execute(cmd.get());
134 }
135 ::grpc::Status aurumServiceImpl::touchUp(::grpc::ServerContext*     context,
136                                          const ::aurum::ReqTouchUp* request,
137                                          ::aurum::RspTouchUp*       response)
138 {
139     std::unique_ptr<TouchUpCommand> cmd = std::make_unique<TouchUpCommand>(request, response);
140     return execute(cmd.get());
141 }
142 ::grpc::Status aurumServiceImpl::touchMove(::grpc::ServerContext*       context,
143                                            const ::aurum::ReqTouchMove* request,
144                                            ::aurum::RspTouchMove* response)
145 {
146     std::unique_ptr<TouchMoveCommand> cmd = std::make_unique<TouchMoveCommand>(request, response);
147     return execute(cmd.get());
148 }
149 ::grpc::Status aurumServiceImpl::longClick(::grpc::ServerContext*   context,
150                                            const ::aurum::ReqClick* request,
151                                            ::aurum::RspClick*       response)
152 {
153     std::unique_ptr<LongClickCommand> cmd = std::make_unique<LongClickCommand>(request, response);
154     return execute(cmd.get());
155 }
156 ::grpc::Status aurumServiceImpl::flick(::grpc::ServerContext*   context,
157                                        const ::aurum::ReqFlick* request,
158                                        ::aurum::RspFlick*       response)
159 {
160     std::unique_ptr<FlickCommand> cmd = std::make_unique<FlickCommand>(request, response);
161     return execute(cmd.get());
162 }
163 ::grpc::Status aurumServiceImpl::getDeviceTime(
164     ::grpc::ServerContext* context, const ::aurum::ReqGetDeviceTime* request,
165     ::aurum::RspGetDeviceTime* response)
166 {
167     std::unique_ptr<GetDeviceTimeCommand> cmd = std::make_unique<GetDeviceTimeCommand>(request, response);
168     return execute(cmd.get());
169 }
170 ::grpc::Status aurumServiceImpl::getLocation(
171     ::grpc::ServerContext* context, const ::aurum::ReqGetLocation* request,
172     ::aurum::RspGetLocation* response)
173 {
174     std::unique_ptr<GetLocationCommand> cmd = std::make_unique<GetLocationCommand>(request, response);
175     return execute(cmd.get());
176 }
177 ::grpc::Status aurumServiceImpl::sendKey(::grpc::ServerContext* context,
178                                          const ::aurum::ReqKey* request,
179                                          ::aurum::RspKey*       response)
180 {
181     std::unique_ptr<SendKeyCommand> cmd = std::make_unique<SendKeyCommand>(request, response);
182     return execute(cmd.get());
183 }
184 ::grpc::Status aurumServiceImpl::takeScreenshot(::grpc::ServerContext* context,
185                                                 const ::aurum::ReqTakeScreenshot* request,
186                                                 ::grpc::ServerWriter< ::aurum::RspTakeScreenshot>* writer)
187 {
188     std::unique_ptr<TakeScreenshotCommand> cmd = std::make_unique<TakeScreenshotCommand>(request, writer);
189     return execute(cmd.get());
190 }