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 FM_IMMS_PROJECT_INPUTMETHODSETTING_H 17 #define FM_IMMS_PROJECT_INPUTMETHODSETTING_H 18 #include <map> 19 #include <vector> 20 #include "string.h" 21 #include "global.h" 22 #include "parcel.h" 23 24 namespace OHOS { 25 namespace MiscServices { 26 class InputMethodSetting { 27 public: 28 29 const static std::u16string CURRENT_INPUT_METHOD_TAG; // default IME 30 const static std::u16string ENABLED_INPUT_METHODS_TAG; // enabled IME list 31 const static std::u16string CURRENT_KEYBOARD_TYPE_TAG; // default keyboard type 32 const static std::u16string CURRENT_SYS_KEYBOARD_TYPE_TAG; // default keyboard type for security IME 33 const static std::u16string SYSTEM_LOCALE_TAG; // locale list supported in the system 34 35 InputMethodSetting(); 36 ~InputMethodSetting(); 37 InputMethodSetting(const InputMethodSetting& inputMethodSetting); 38 InputMethodSetting& operator =(const InputMethodSetting& inputMethodSetting); 39 40 void SetValue(const std::u16string& key, const std::u16string& value); 41 std::u16string GetValue(const std::u16string& key) const; 42 43 std::u16string GetCurrentInputMethod() const; 44 void SetCurrentInputMethod(const std::u16string& imeId); 45 46 std::vector<std::u16string> GetEnabledInputMethodList(); 47 bool AddEnabledInputMethod(const std::u16string& imeId, const std::vector<int32_t>& types); 48 bool RemoveEnabledInputMethod(const std::u16string& imdId); 49 50 std::vector<int32_t> GetEnabledKeyboardTypes(const std::u16string& imeId); 51 int32_t GetCurrentKeyboardType(); 52 void SetCurrentKeyboardType(int32_t type); 53 int32_t GetCurrentSysKeyboardType(); 54 void SetCurrentSysKeyboardType(int32_t type); 55 void ClearData(); 56 bool FindKey(const std::u16string& key) const; 57 58 private: 59 std::map<std::u16string, std::u16string> setting; 60 const char16_t DELIM_IME = ':'; 61 const char16_t DELIM_KBD_TYPE = ';'; 62 std::vector<std::u16string> Split(const std::u16string& str, char16_t delim); 63 std::u16string BuildString(const std::vector<std::u16string>& vector, char16_t delim); 64 }; 65 } 66 } 67 #endif // FM_IMMS_PROJECT_INPUTMETHODSETTING_H 68