• 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 OHOS_GLOBAL_I18N_I18N_SERVICE_ABILITY_CLIENT_H
17 #define OHOS_GLOBAL_I18N_I18N_SERVICE_ABILITY_CLIENT_H
18 
19 #include <string>
20 #include "ii18n_service_ability.h"
21 #include "i18n_types.h"
22 
23 namespace OHOS {
24 namespace Global {
25 namespace I18n {
26 /**
27  * @brief I18nServiceAbilityClient is i18n service entry class, provides i18n service entry function,
28  * such as SetSystemLanguage.
29  */
30 class I18nServiceAbilityClient {
31 public:
32     /**
33      * @brief I18n service entry for setting system language.
34      *
35      * @param language language tag to set.
36      * @return I18nErrorCode Return SUCCESS indicates that the setting was successful.
37      */
38     static I18nErrorCode SetSystemLanguage(const std::string &language);
39 
40     /**
41      * @brief I18n service entry for setting system region.
42      *
43      * @param region region tag to set.
44      * @return I18nErrorCode Return SUCCESS indicates that the setting was successful.
45      */
46     static I18nErrorCode SetSystemRegion(const std::string &region);
47 
48     /**
49      * @brief I18n service entry for setting system locale.
50      *
51      * @param locale locale tag to set.
52      * @return I18nErrorCode Return SUCCESS indicates that the setting was successful.
53      */
54     static I18nErrorCode SetSystemLocale(const std::string &locale);
55 
56     /**
57      * @brief I18n service entry for setting the system to use 12 or 24-hour clock.
58      *
59      * @param flag When flag is true, the system adopts 24-hour clock;
60      * When flag is false, the system adopts 12-hour clock; When flag is empty string, the system adopts
61      * system locale default behavior.
62      * @return I18nErrorCode Return SUCCESS indicates that the setting was successful.
63      */
64     static I18nErrorCode Set24HourClock(const std::string &flag);
65 
66     /**
67      * @brief I18n service entry for setting whether the system uses local numbers.
68      *
69      * @param flag When flag is True, the system adopts local digit;
70      * When flag is False, the system doesn't adopt local digit;
71      * @return I18nErrorCode Return SUCCESS indicates that the setting was successful.
72      */
73     static I18nErrorCode SetUsingLocalDigit(bool flag);
74 
75     /**
76      * @brief I18n service entry for add system preferred language.
77      *
78      * @param language preferred language tag to add.
79      * @param index preferred language'index to add.
80      * @return I18nErrorCode Return SUCCESS indicates that the setting was successful.
81      */
82     static I18nErrorCode AddPreferredLanguage(const std::string &language, int32_t index);
83 
84     /**
85      * @brief I18n service entry for remove system preferred language.
86      *
87      * @param index preferred language's index to remove.
88      * @return I18nErrorCode Return SUCCESS indicates that the setting was successful.
89      */
90     static I18nErrorCode RemovePreferredLanguage(int32_t index);
91 
92     /**
93      * @brief Verify the libphonenumber upgrade file.
94      *
95      * @return corresponding file descriptor {metadataFd, geocodingFd}.
96      */
97     static std::pair<int, int> VerifyLibphonenumberUpdate();
98 
99 private:
100     /**
101      * @brief Get the proxy of i18n service to access service.
102      *
103      * @param err Indicates whether the acquisition was successful.
104      * @return sptr<II18nServiceAbility> I18n service proxy.
105      */
106     static sptr<II18nServiceAbility> GetProxy(I18nErrorCode &err);
107 };
108 } // namespace I18n
109 } // namespace Global
110 } // namespace OHOS
111 #endif // OHOS_GLOBAL_I18N_I18N_SERVICE_ABILITY_CLIENT_H