• 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 #include "input_data_channel_proxy.h"
17 #include "global.h"
18 #include "ipc_types.h"
19 #include "message_option.h"
20 #include "message_parcel.h"
21 
22 namespace OHOS {
23 namespace MiscServices {
InputDataChannelProxy(const sptr<IRemoteObject> & object)24     InputDataChannelProxy::InputDataChannelProxy(const sptr<IRemoteObject> &object)
25         : IRemoteProxy<IInputDataChannel>(object)
26     {
27     }
28 
InsertText(const std::u16string & text)29     int32_t InputDataChannelProxy::InsertText(const std::u16string& text)
30     {
31         IMSA_HILOGI("InputDataChannelProxy::InsertText");
32         MessageParcel data;
33         MessageParcel reply;
34         MessageOption option;
35         data.WriteInterfaceToken(GetDescriptor());
36         data.WriteString16(text);
37 
38         auto ret = Remote()->SendRequest(INSERT_TEXT, data, reply, option);
39         if (ret != NO_ERROR) {
40             return ErrorCode::ERROR_REMOTE_IME_DIED;
41         }
42         auto result = reply.ReadInt32();
43         return result;
44     }
45 
DeleteForward(int32_t length)46     int32_t InputDataChannelProxy::DeleteForward(int32_t length)
47     {
48         IMSA_HILOGI("InputDataChannelProxy::DeleteForward");
49         MessageParcel data;
50         MessageParcel reply;
51         MessageOption option;
52         data.WriteInterfaceToken(GetDescriptor());
53         data.WriteInt32(length);
54 
55         auto ret = Remote()->SendRequest(DELETE_FORWARD, data, reply, option);
56         if (ret != NO_ERROR) {
57             return ErrorCode::ERROR_REMOTE_IME_DIED;
58         }
59         auto result = reply.ReadInt32();
60         return result;
61     }
62 
DeleteBackward(int32_t length)63     int32_t InputDataChannelProxy::DeleteBackward(int32_t length)
64     {
65         IMSA_HILOGI("InputDataChannelProxy::DeleteBackward");
66         MessageParcel data;
67         MessageParcel reply;
68         MessageOption option;
69         data.WriteInterfaceToken(GetDescriptor());
70         data.WriteInt32(length);
71 
72         auto ret = Remote()->SendRequest(DELETE_BACKWARD, data, reply, option);
73         if (ret != NO_ERROR) {
74             return ErrorCode::ERROR_REMOTE_IME_DIED;
75         }
76         auto result = reply.ReadInt32();
77         return result;
78     }
79 
80 
GetTextBeforeCursor(int32_t number,std::u16string & text)81     int32_t InputDataChannelProxy::GetTextBeforeCursor(int32_t number, std::u16string &text)
82     {
83         IMSA_HILOGI("InputDataChannelProxy::GetTextBeforeCursor");
84         MessageParcel data;
85         MessageParcel reply;
86         MessageOption option;
87         data.WriteInterfaceToken(GetDescriptor());
88         data.WriteInt32(number);
89 
90         Remote()->SendRequest(GET_TEXT_BEFORE_CURSOR, data, reply, option);
91         int32_t err = reply.ReadInt32();
92         text = reply.ReadString16();
93         return err;
94     }
95 
GetTextAfterCursor(int32_t number,std::u16string & text)96     int32_t InputDataChannelProxy::GetTextAfterCursor(int32_t number, std::u16string &text)
97     {
98         IMSA_HILOGI("InputDataChannelProxy::GetTextAfterCursor");
99         MessageParcel data;
100         MessageParcel reply;
101         MessageOption option;
102         data.WriteInterfaceToken(GetDescriptor());
103         data.WriteInt32(number);
104 
105         Remote()->SendRequest(GET_TEXT_AFTER_CURSOR, data, reply, option);
106         int32_t err = reply.ReadInt32();
107         text = reply.ReadString16();
108         return err;
109     }
110 
SendKeyboardStatus(int32_t status)111     void InputDataChannelProxy::SendKeyboardStatus(int32_t status)
112     {
113         IMSA_HILOGI("InputDataChannelProxy::SendKeyboardStatus");
114         MessageParcel data;
115         MessageParcel reply;
116         MessageOption option;
117         data.WriteInterfaceToken(GetDescriptor());
118         data.WriteInt32(status);
119 
120         Remote()->SendRequest(SEND_KEYBOARD_STATUS, data, reply, option);
121     }
122 
SendFunctionKey(int32_t funcKey)123     int32_t InputDataChannelProxy::SendFunctionKey(int32_t funcKey)
124     {
125         IMSA_HILOGI("InputDataChannelProxy::SendFunctionKey");
126         MessageParcel data;
127         MessageParcel reply;
128         MessageOption option;
129         data.WriteInterfaceToken(GetDescriptor());
130         data.WriteInt32(funcKey);
131 
132         Remote()->SendRequest(SEND_FUNCTION_KEY, data, reply, option);
133         auto result = reply.ReadInt32();
134         return result;
135     }
136 
MoveCursor(int32_t keyCode)137     int32_t InputDataChannelProxy::MoveCursor(int32_t keyCode)
138     {
139         IMSA_HILOGI("InputDataChannelProxy::MoveCursor");
140 
141         MessageParcel data;
142         MessageParcel reply;
143         MessageOption option;
144         data.WriteInterfaceToken(GetDescriptor());
145         data.WriteInt32(keyCode);
146 
147         Remote()->SendRequest(MOVE_CURSOR, data, reply, option);
148         auto result = reply.ReadInt32();
149         return result;
150     }
151 
GetEnterKeyType(int32_t & keyType)152     int32_t InputDataChannelProxy::GetEnterKeyType(int32_t &keyType)
153     {
154         IMSA_HILOGI("InputDataChannelProxy::GetEnterKeyType");
155         MessageParcel data;
156         MessageParcel reply;
157         MessageOption option;
158         data.WriteInterfaceToken(GetDescriptor());
159 
160         Remote()->SendRequest(GET_ENTER_KEY_TYPE, data, reply, option);
161         auto result = reply.ReadInt32();
162         keyType = reply.ReadInt32();
163         return result;
164     }
165 
GetInputPattern(int32_t & inputPattern)166     int32_t InputDataChannelProxy::GetInputPattern(int32_t &inputPattern)
167     {
168         IMSA_HILOGI("InputDataChannelProxy::GetInputPattern");
169         MessageParcel data;
170         MessageParcel reply;
171         MessageOption option;
172         data.WriteInterfaceToken(GetDescriptor());
173 
174         Remote()->SendRequest(GET_INPUT_PATTERN, data, reply, option);
175         auto result = reply.ReadInt32();
176         inputPattern = reply.ReadInt32();
177         return result;
178     }
179 
HandleSetSelection(int32_t start,int32_t end)180     void InputDataChannelProxy::HandleSetSelection(int32_t start, int32_t end)
181     {
182         IMSA_HILOGI("InputDataChannelProxy::HandleSetSelection");
183         MessageParcel data;
184         MessageParcel reply;
185         MessageOption option;
186         data.WriteInterfaceToken(GetDescriptor());
187         data.WriteInt32(start);
188         data.WriteInt32(end);
189 
190         Remote()->SendRequest(HANDLE_SET_SELECTION, data, reply, option);
191     }
192 
HandleExtendAction(int32_t action)193     void InputDataChannelProxy::HandleExtendAction(int32_t action)
194     {
195         IMSA_HILOGI("InputDataChannelProxy::HandleExtendAction");
196         MessageParcel data;
197         MessageParcel reply;
198         MessageOption option;
199         data.WriteInterfaceToken(GetDescriptor());
200         data.WriteInt32(action);
201 
202         Remote()->SendRequest(HANDLE_EXTEND_ACTION, data, reply, option);
203     }
204 
HandleSelect(int32_t keyCode,int32_t cursorMoveSkip)205     void InputDataChannelProxy::HandleSelect(int32_t keyCode, int32_t cursorMoveSkip)
206     {
207         IMSA_HILOGI("InputDataChannelProxy::HandleSelect");
208         MessageParcel data;
209         MessageParcel reply;
210         MessageOption option;
211         data.WriteInterfaceToken(GetDescriptor());
212         data.WriteInt32(keyCode);
213         data.WriteInt32(cursorMoveSkip);
214 
215         Remote()->SendRequest(HANDLE_SELECT, data, reply, option);
216     }
217 
NotifyGetOperationCompletion()218     void InputDataChannelProxy::NotifyGetOperationCompletion()
219     {
220     }
221 } // namespace MiscServices
222 } // namespace OHOS
223