1 /* 2 * Copyright (C) 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 FRAMEWORKS_INPUTMETHOD_ABILITY_INCLUDE_INPUT_METHOD_CORE_STUB_H 17 #define FRAMEWORKS_INPUTMETHOD_ABILITY_INCLUDE_INPUT_METHOD_CORE_STUB_H 18 19 #include <condition_variable> 20 #include <cstdint> 21 #include <mutex> 22 23 #include "i_input_control_channel.h" 24 #include "i_input_data_channel.h" 25 #include "i_input_method_agent.h" 26 #include "i_input_method_core.h" 27 #include "input_attribute.h" 28 #include "input_channel.h" 29 #include "iremote_broker.h" 30 #include "iremote_stub.h" 31 #include "message_handler.h" 32 #include "message_parcel.h" 33 34 namespace OHOS { 35 namespace MiscServices { 36 class InputMethodCoreStub : public IRemoteStub<IInputMethodCore> { 37 public: 38 DISALLOW_COPY_AND_MOVE(InputMethodCoreStub); 39 explicit InputMethodCoreStub(int userId); 40 virtual ~InputMethodCoreStub(); 41 int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 42 int32_t ShowKeyboard( 43 const sptr<IInputDataChannel> &inputDataChannel, bool isShowKeyboard, bool attachFlag) override; 44 int32_t HideKeyboard() override; 45 int32_t InitInputControlChannel(sptr<IInputControlChannel> &inputControlChannel, const std::string &imeId) override; 46 void StopInputService(std::string imeId) override; 47 int32_t SetSubtype(const SubProperty &property) override; 48 int32_t ClearDataChannel(const sptr<IInputDataChannel> &channel) override; 49 void SetMessageHandler(MessageHandler *msgHandler); 50 51 private: 52 int32_t userId_ = -1; 53 MessageHandler *msgHandler_; 54 void InitInputControlChannelOnRemote(MessageParcel &data, MessageParcel &reply); 55 void SetSubtypeOnRemote(MessageParcel &data, MessageParcel &reply); 56 void ShowKeyboardOnRemote(MessageParcel &data, MessageParcel &reply); 57 int32_t ClearDataChannelOnRemote(MessageParcel &data); 58 using ParcelHandler = std::function<bool(MessageParcel &)>; 59 int32_t SendMessage(int code, ParcelHandler input = nullptr); 60 }; 61 } // namespace MiscServices 62 } // namespace OHOS 63 #endif // FRAMEWORKS_INPUTMETHOD_ABILITY_INCLUDE_INPUT_METHOD_CORE_STUB_H 64