1 /* 2 * Copyright (c) 2020-2021 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 16 #ifndef GRAPHIC_LITE_IMS_CLIENT_PROXY_H 17 #define GRAPHIC_LITE_IMS_CLIENT_PROXY_H 18 19 #include <iproxy_client.h> 20 #include "ipc_skeleton.h" 21 #include "gfx_utils/input_event_info.h" 22 23 namespace OHOS { 24 class InputEventListenerProxy { 25 public: 26 static InputEventListenerProxy* GetInstance(); 27 28 class RawEventListener { 29 public: RawEventListener()30 RawEventListener() : alwaysInvoke_(false) {} ~RawEventListener()31 virtual ~RawEventListener() {} 32 33 /** 34 * @brief Change always-invoke state to enable. 35 */ EnableAlwaysInvoke(bool alwaysInvoke)36 void EnableAlwaysInvoke(bool alwaysInvoke) 37 { 38 alwaysInvoke_ = alwaysInvoke; 39 } 40 41 /** 42 * @brief Verify always-invoke state. 43 */ IsAlwaysInvoke()44 bool IsAlwaysInvoke() 45 { 46 return alwaysInvoke_; 47 } 48 49 /** 50 * @brief Do something when raw event comes. 51 */ 52 virtual void OnRawEvent(const RawEvent& event) = 0; 53 54 protected: 55 bool alwaysInvoke_; 56 }; 57 58 /** 59 * @brief Regist input event lisener. 60 */ 61 bool RegisterInputEventListener(RawEventListener* listener); 62 63 /** 64 * @brief Unegist input event lisener. 65 */ 66 bool UnregisterInputEventListener(); 67 68 private: InputEventListenerProxy()69 InputEventListenerProxy() : proxy_(nullptr) {} 70 ~InputEventListenerProxy(); 71 72 bool GetIClientProxy(); 73 static int32_t ReceiveMsgHandler(uint32_t code, IpcIo* io, IpcIo* reply, MessageOption option); 74 75 IClientProxy* proxy_; 76 static RawEventListener* listener_; 77 78 InputEventListenerProxy(const InputEventListenerProxy&) = delete; 79 InputEventListenerProxy& operator=(const InputEventListenerProxy&) = delete; 80 InputEventListenerProxy(InputEventListenerProxy&&) = delete; 81 InputEventListenerProxy& operator=(InputEventListenerProxy&&) = delete; 82 }; 83 } // namespace OHOS 84 #endif 85