• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "event_checker.h"
17 
18 namespace OHOS {
19 namespace MiscServices {
20 const std::unordered_map<EventSubscribeModule, std::unordered_set<std::string>> EventChecker::EVENT_TYPES{
21     { EventSubscribeModule::INPUT_METHOD_CONTROLLER,
22         { "insertText", "deleteLeft", "deleteRight", "sendKeyboardStatus", "sendFunctionKey", "moveCursor",
23             "handleExtendAction", "selectByRange", "selectByMovement", "getLeftTextOfCursor", "getRightTextOfCursor",
24             "getTextIndexAtCursor" } },
25     { EventSubscribeModule::INPUT_METHOD_SETTING, { "imeChange", "imeShow", "imeHide" } },
26     { EventSubscribeModule::INPUT_METHOD_ABILITY,
27         { "inputStart", "inputStop", "keyboardShow", "keyboardHide", "setCallingWindow", "setSubtype" } },
28     { EventSubscribeModule::KEYBOARD_DELEGATE, { "editorAttributeChanged", "keyDown", "keyUp", "keyEvent",
29                                                  "cursorContextChange", "selectionChange", "textChange" } },
30     { EventSubscribeModule::PANEL, { "show", "hide" } }
31 };
IsValidEventType(EventSubscribeModule module,const std::string & type)32 bool EventChecker::IsValidEventType(EventSubscribeModule module, const std::string &type)
33 {
34     auto it = EVENT_TYPES.find(module);
35     if (it == EVENT_TYPES.end()) {
36         return false;
37     }
38     return it->second.find(type) != it->second.end();
39 }
40 } // namespace MiscServices
41 } // namespace OHOS