1 /* 2 * Copyright (c) 2023 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 DINPUT_SOURCE_LISTENER_H 17 #define DINPUT_SOURCE_LISTENER_H 18 19 #include <cstring> 20 #include <mutex> 21 #include <set> 22 23 #include <unistd.h> 24 #include <sys/types.h> 25 26 #include "event_handler.h" 27 #include "ipublisher_listener.h" 28 #include "publisher_listener_stub.h" 29 #include "singleton.h" 30 31 #include "constants_dinput.h" 32 #include "dinput_context.h" 33 #include "dinput_source_manager_callback.h" 34 #include "dinput_source_trans_callback.h" 35 #include "distributed_input_source_manager.h" 36 37 namespace OHOS { 38 namespace DistributedHardware { 39 namespace DistributedInput { 40 class DistributedInputSourceManager; 41 class DInputSourceListener : public DInputSourceTransCallback { 42 public: 43 explicit DInputSourceListener(DistributedInputSourceManager *manager); 44 virtual ~DInputSourceListener(); 45 void OnResponseRegisterDistributedHardware(const std::string deviceId, const std::string dhId, 46 bool result) override; 47 void OnResponsePrepareRemoteInput(const std::string deviceId, bool result, const std::string &object) override; 48 void OnResponseUnprepareRemoteInput(const std::string deviceId, bool result) override; 49 void OnResponseStartRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) override; 50 void OnResponseStopRemoteInput(const std::string deviceId, const uint32_t inputTypes, bool result) override; 51 void OnResponseStartRemoteInputDhid(const std::string deviceId, const std::string &dhids, bool result) override; 52 void OnResponseStopRemoteInputDhid(const std::string deviceId, const std::string &dhids, bool result) override; 53 void OnResponseKeyState(const std::string deviceId, const std::string &dhid, const uint32_t type, 54 const uint32_t code, const uint32_t value) override; 55 void OnResponseKeyStateBatch(const std::string deviceId, const std::string &event) override; 56 void OnReceivedEventRemoteInput(const std::string deviceId, const std::string &event) override; 57 void OnResponseRelayPrepareRemoteInput(int32_t sessionId, const std::string &deviceId, bool result, 58 const std::string &object) override; 59 void OnResponseRelayUnprepareRemoteInput(int32_t sessionId, const std::string &deviceId, bool result) override; 60 61 void OnReceiveRelayPrepareResult(int32_t status, const std::string &srcId, const std::string &sinkId) override; 62 void OnReceiveRelayUnprepareResult(int32_t status, const std::string &srcId, 63 const std::string &sinkId) override; 64 void OnReceiveRelayStartDhidResult(int32_t status, const std::string &srcId, const std::string &sinkId, 65 const std::string &dhids) override; 66 void OnReceiveRelayStopDhidResult(int32_t status, const std::string &srcId, const std::string &sinkId, 67 const std::string &dhids) override; 68 void OnReceiveRelayStartTypeResult(int32_t status, const std::string &srcId, const std::string &sinkId, 69 uint32_t inputTypes) override; 70 void OnReceiveRelayStopTypeResult(int32_t status, const std::string &srcId, const std::string &sinkId, 71 uint32_t inputTypes) override; 72 void RecordEventLog(int64_t when, int32_t type, int32_t code, int32_t value, const std::string &path); 73 74 private: 75 DistributedInputSourceManager *sourceManagerObj_; 76 }; 77 } // namespace DistributedInput 78 } // namespace DistributedHardware 79 } // namespace OHOS 80 81 #endif // DINPUT_SOURCE_LISTENER_H