• 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 #ifndef SERVICES_INCLUDE_IME_INFO_ENQUIRER_H
17 #define SERVICES_INCLUDE_IME_INFO_ENQUIRER_H
18 
19 #include <memory>
20 #include <mutex>
21 #include <string>
22 #include <vector>
23 
24 #include "input_method_property.h"
25 #include "input_method_status.h"
26 
27 namespace OHOS {
28 namespace MiscServices {
29 struct ImeNativeCfg {
30     std::string imeId;
31     std::string bundleName;
32     std::string subName;
33     std::string extName;
34 };
35 
36 class ImeInfoInquirer {
37 public:
38     static ImeInfoInquirer &GetInstance();
39     std::shared_ptr<ImeInfo> GetDefaultImeInfo(int32_t userId);
40     std::shared_ptr<Property> GetCurrentInputMethod(int32_t userId);
41     std::shared_ptr<Property> GetDefaultImeCfgProp();
42     void SetFullImeInfo(bool isReturnOk, const FullImeInfo &imeInfo);
43     void SetFullImeInfo(bool isReturnOk, const std::vector<FullImeInfo> &imeInfos);
44     void SetFullImeInfo(bool isReturnOk, const std::vector<std::pair<int32_t, std::vector<FullImeInfo>>> &fullImeInfos);
45     int32_t QueryFullImeInfo(std::vector<std::pair<int32_t, std::vector<FullImeInfo>>> &fullImeInfos) const;
46     int32_t QueryFullImeInfo(int32_t userId, std::vector<FullImeInfo> &imeInfos) const;
47     int32_t GetFullImeInfo(int32_t userId, const std::string &bundleName, FullImeInfo &imeInfo) const;
48     static bool GetImeAppId(int32_t userId, const std::string &bundleName, std::string &appId);
49     static bool GetImeVersionCode(int32_t userId, const std::string &bundleName, uint32_t &versionCode);
50     ImeNativeCfg GetDefaultIme();
51 private:
52     static std::shared_ptr<ImeInfo> defaultIme_;
53     static std::shared_ptr<Property> currentIme_;
54     static std::shared_ptr<Property> defaultImeProperty_;
55     bool isQueryAllFullImeInfosOk_ { false };
56     std::vector<std::pair<int32_t, std::vector<FullImeInfo>>> allFullImeInfos_;
57     bool isQueryFullImeInfosOk_ { false };
58     std::vector<FullImeInfo> fullImeInfos_;
59     bool isGetFullImeInfoOk_ { false };
60     FullImeInfo fullImeInfo_;
61 };
62 } // namespace MiscServices
63 } // namespace OHOS
64 #endif // SERVICES_INCLUDE_IME_INFO_ENQUIRER_H
65