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_PROXY_H
17#define OHOS_GLOBAL_I18N_I18N_SERVICE_ABILITY_PROXY_H
18
19#include "ii18n_service_ability.h"
20#include "iremote_broker.h"
21#include "iremote_proxy.h"
22
23namespace OHOS {
24namespace Global {
25namespace I18n {
26/**
27 * @brief I18n Service Proxy class which responsible for initiating service requests.
28 */
29class I18nServiceAbilityProxy : public IRemoteProxy<II18nServiceAbility> {
30public:
31    explicit I18nServiceAbilityProxy(const sptr<IRemoteObject> &impl);
32    ~I18nServiceAbilityProxy() = default;
33
34    /**
35     * @brief Initiating set system language request to i18n service.
36     *
37     * @param language language tag to set.
38     * @return I18nErrorCode Return SUCCESS indicates that the request was successful.
39     */
40    I18nErrorCode SetSystemLanguage(const std::string &language);
41
42    /**
43     * @brief Initiating set system region request to i18n service.
44     *
45     * @param region region tag to set.
46     * @return I18nErrorCode Return SUCCESS indicates that the request was successful.
47     */
48    I18nErrorCode SetSystemRegion(const std::string &region);
49
50    /**
51     * @brief Initiating set system locale request to i18n service.
52     *
53     * @param locale locale tag to set.
54     * @return I18nErrorCode Return SUCCESS indicates that the request was successful.
55     */
56    I18nErrorCode SetSystemLocale(const std::string &locale);
57
58    /**
59     * @brief Initiating set system 12 or 24-hour clock request to i18n service.
60     *
61     * @param flag When flag is true, the system adopts 24-hour clock;
62     * When flag is false, the system adopts 12-hour clock; When flag is empty string, the system adopts
63     * system locale default behavior.
64     * @return I18nErrorCode Return SUCCESS indicates that the request was successful.
65     */
66    I18nErrorCode Set24HourClock(const std::string &flag);
67
68    /**
69     * @brief Initiating set system digit request to i18n service.
70     *
71     * @param flag When flag is True, request to adopt local digit;
72     * When flag is False, request to adopt arbic digit;
73     * @return I18nErrorCode Return SUCCESS indicates that the request was successful.
74     */
75    I18nErrorCode SetUsingLocalDigit(bool flag);
76
77    /**
78     * @brief Initiating add system preferred language request to i18n service.
79     *
80     * @param language preferred language tag to set.
81     * @param index Indicats added preferred language index.
82     * @return I18nErrorCode Return SUCCESS indicates that the request was successful.
83     */
84    I18nErrorCode AddPreferredLanguage(const std::string &language, int32_t index);
85
86    /**
87     * @brief Initiating remove system preferred language request to i18n service.
88     *
89     * @param index Indicats removed preferred language index.
90     * @return I18nErrorCode Return SUCCESS indicates that the request was successful.
91     */
92    I18nErrorCode RemovePreferredLanguage(int32_t index);
93
94private:
95    static I18nErrorCode ProcessReply(int32_t reply);
96    static inline BrokerDelegator<I18nServiceAbilityProxy> delegator_;
97};
98} // namespace I18n
99} // namespace Global
100} // namespace OHOS
101#endif // OHOS_GLOBAL_I18N_I18N_SERVICE_ABILITY_PROXY_H