• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef CLIENT_MSG_HANDLER_H
16 #define CLIENT_MSG_HANDLER_H
17 
18 #include "if_client_msg_handler.h"
19 #include "key_event_input_subscribe_manager.h"
20 #include "msg_handler.h"
21 #include "uds_client.h"
22 #include "nocopyable.h"
23 
24 namespace OHOS {
25 namespace MMI {
26 typedef std::function<int32_t(const UDSClient&, NetPacket&)> ClientMsgFun;
27 class ClientMsgHandler : public MsgHandler<ClientMsgFun>,
28     public IfClientMsgHandler, public std::enable_shared_from_this<IfClientMsgHandler> {
29 public:
30     ClientMsgHandler();
31     DISALLOW_COPY_AND_MOVE(ClientMsgHandler);
32     virtual ~ClientMsgHandler();
33     virtual bool Init() override;
34     virtual void OnMsgHandler(const UDSClient& client, NetPacket& pkt) override;
35 
36 protected:
37     virtual int32_t OnKeyEvent(const UDSClient& client, NetPacket& pkt);
38     virtual int32_t OnKeyMonitor(const UDSClient& client, NetPacket& pkt);
39     virtual int32_t OnTouchPadMonitor(const UDSClient& client, NetPacket& pkt);
40     virtual int32_t OnPointerEvent(const UDSClient& client, NetPacket& pkt);
41     virtual int32_t OnSubscribeKeyEventCallback(const UDSClient& client, NetPacket& pkt);
42     virtual int32_t GetMultimodeInputInfo(const UDSClient& client, NetPacket& pkt);
43     virtual int32_t ReportKeyEvent(const UDSClient& client, NetPacket& pkt);
44     virtual int32_t ReportPointerEvent(const UDSClient& client, NetPacket& pkt);
45     virtual int32_t OnInputDevice(const UDSClient& client, NetPacket& pkt);
46     virtual int32_t OnInputDeviceIds(const UDSClient& client, NetPacket& pkt);
47     virtual int32_t TouchpadEventInterceptor(const UDSClient& client, NetPacket& pkt);
48     virtual int32_t KeyEventInterceptor(const UDSClient& client, NetPacket& pkt);
49 
50 private:
51     static void OnEventProcessed(int32_t eventId);
52 
53 private:
54     std::function<void(int32_t)> eventProcessedCallback_;
55 };
56 } // namespace MMI
57 } // namespace OHOS
58 #endif // CLIENT_MSG_HANDLER_H
59