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 SERVER_MSG_HANDLER_H 16 #define SERVER_MSG_HANDLER_H 17 #include "msg_handler.h" 18 #include "event_dispatch.h" 19 #include "nocopyable.h" 20 21 namespace OHOS { 22 namespace MMI { 23 typedef std::function<int32_t(SessionPtr sess, NetPacket& pkt)> ServerMsgFun; 24 class ServerMsgHandler : public MsgHandler<ServerMsgFun> { 25 public: 26 ServerMsgHandler(); 27 DISALLOW_COPY_AND_MOVE(ServerMsgHandler); 28 virtual ~ServerMsgHandler() override; 29 30 bool Init(UDSServer& udsServer); 31 void OnMsgHandler(SessionPtr sess, NetPacket& pkt); 32 33 protected: 34 int32_t OnVirtualKeyEvent(SessionPtr sess, NetPacket& pkt); 35 int32_t OnRegisterMsgHandler(SessionPtr sess, NetPacket& pkt); 36 int32_t OnDump(SessionPtr sess, NetPacket& pkt); 37 int32_t NewCheckReplyMessageFormClient(SessionPtr sess, NetPacket& pkt); 38 int32_t GetMultimodeInputInfo(SessionPtr sess, NetPacket& pkt); 39 int32_t OnInjectKeyEvent(SessionPtr sess, NetPacket& pkt); 40 int32_t OnInjectPointerEvent(SessionPtr sess, NetPacket& pkt); 41 int32_t OnDisplayInfo(SessionPtr sess, NetPacket& pkt); 42 int32_t OnAddInputHandler(SessionPtr sess, NetPacket& pkt); 43 int32_t OnRemoveInputHandler(SessionPtr sess, NetPacket& pkt); 44 int32_t OnMarkConsumed(SessionPtr sess, NetPacket& pkt); 45 int32_t OnInputDevice(SessionPtr sess, NetPacket& pkt); 46 int32_t OnInputDeviceIds(SessionPtr sess, NetPacket& pkt); 47 int32_t OnAddInputEventMontior(SessionPtr sess, NetPacket& pkt); 48 int32_t OnRemoveInputEventMontior(SessionPtr sess, NetPacket& pkt); 49 int32_t OnAddInputEventTouchpadMontior(SessionPtr sess, NetPacket& pkt); 50 int32_t OnRemoveInputEventTouchpadMontior(SessionPtr sess, NetPacket& pkt); 51 int32_t OnSubscribeKeyEvent(SessionPtr sess, NetPacket& pkt); 52 int32_t OnUnSubscribeKeyEvent(SessionPtr sess, NetPacket& pkt); 53 int32_t OnAddTouchpadEventFilter(SessionPtr sess, NetPacket& pkt); 54 int32_t OnRemoveTouchpadEventFilter(SessionPtr sess, NetPacket& pkt); 55 56 private: 57 UDSServer *udsServer_ = nullptr; // External references, do not delete 58 EventDispatch eventDispatch_; 59 std::shared_ptr<OHOS::MMI::KeyEvent> keyEvent_ = nullptr; 60 }; 61 } // namespace MMI 62 } // namespace OHOS 63 #endif // SERVER_MSG_HANDLER_H