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