19596a2c1Sopenharmony_ci/*
29596a2c1Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
39596a2c1Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
49596a2c1Sopenharmony_ci * you may not use this file except in compliance with the License.
59596a2c1Sopenharmony_ci * You may obtain a copy of the License at
69596a2c1Sopenharmony_ci *
79596a2c1Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
89596a2c1Sopenharmony_ci *
99596a2c1Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
109596a2c1Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
119596a2c1Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
129596a2c1Sopenharmony_ci * See the License for the specific language governing permissions and
139596a2c1Sopenharmony_ci * limitations under the License.
149596a2c1Sopenharmony_ci */
159596a2c1Sopenharmony_ci#ifndef OHOS_GLOBAL_I18N_MULTI_USERS_H
169596a2c1Sopenharmony_ci#define OHOS_GLOBAL_I18N_MULTI_USERS_H
179596a2c1Sopenharmony_ci
189596a2c1Sopenharmony_ci#include <string>
199596a2c1Sopenharmony_ci#include "i18n_types.h"
209596a2c1Sopenharmony_ci#include "preferences.h"
219596a2c1Sopenharmony_ci#include "preferences_helper.h"
229596a2c1Sopenharmony_ci
239596a2c1Sopenharmony_cinamespace OHOS {
249596a2c1Sopenharmony_cinamespace Global {
259596a2c1Sopenharmony_cinamespace I18n {
269596a2c1Sopenharmony_ciclass MultiUsers {
279596a2c1Sopenharmony_cipublic:
289596a2c1Sopenharmony_ci    static void InitMultiUser();
299596a2c1Sopenharmony_ci    static void SwitchUser(const std::string& curLocalId);
309596a2c1Sopenharmony_ci    static void AddUser(const std::string& localId);
319596a2c1Sopenharmony_ci    static void RemoveUser(const std::string& localId);
329596a2c1Sopenharmony_ci    static I18nErrorCode SaveLanguage(const std::string& localId, const std::string& language);
339596a2c1Sopenharmony_ci    static I18nErrorCode SaveLocale(const std::string& localId, const std::string& locale);
349596a2c1Sopenharmony_ci    static I18nErrorCode SaveIs24Hour(const std::string& localId, const std::string& is24Hour);
359596a2c1Sopenharmony_ci
369596a2c1Sopenharmony_ciprivate:
379596a2c1Sopenharmony_ci    static I18nErrorCode SaveGlobalParam(const std::string& localId);
389596a2c1Sopenharmony_ci    static I18nErrorCode LoadGlobalParam(const std::string& localId);
399596a2c1Sopenharmony_ci    static I18nErrorCode GetForegroundLocalId(std::string& localId);
409596a2c1Sopenharmony_ci    static I18nErrorCode RemoveGlobalParam(const std::string& localId);
419596a2c1Sopenharmony_ci    static std::string ReadMultiUsersParameter(const std::string& paramKey, const std::string& localId);
429596a2c1Sopenharmony_ci    static I18nErrorCode WriteMultiUsersParameter(const std::string& paramKey, const std::string& paramValue,
439596a2c1Sopenharmony_ci        const std::string& localId, bool isDel);
449596a2c1Sopenharmony_ci    static bool IsValidLocalId(const std::string& localId);
459596a2c1Sopenharmony_ci    static void InitPreferences();
469596a2c1Sopenharmony_ci    static std::string GetParamFromPreferences(const std::string& paramKey);
479596a2c1Sopenharmony_ci    static I18nErrorCode SetParamFromPreferences(const std::string& paramKey, const std::string& paramValue);
489596a2c1Sopenharmony_ci
499596a2c1Sopenharmony_ci    static const std::string MULTI_USERS_LANGUAGE_KEY;
509596a2c1Sopenharmony_ci    static const std::string MULTI_USERS_LOCALE_KEY;
519596a2c1Sopenharmony_ci    static const std::string MULTI_USERS_HOUR_KEY;
529596a2c1Sopenharmony_ci    static const std::string INIT_KEY;
539596a2c1Sopenharmony_ci    static const std::string PREFERENCE_PATH;
549596a2c1Sopenharmony_ci    static const int32_t DEFAULT_LOCAL_ID;
559596a2c1Sopenharmony_ci    static const int CONFIG_LEN;
569596a2c1Sopenharmony_ci    static std::shared_ptr<NativePreferences::Preferences> preferences;
579596a2c1Sopenharmony_ci};
589596a2c1Sopenharmony_ci} // namespace I18n
599596a2c1Sopenharmony_ci} // namespace Global
609596a2c1Sopenharmony_ci} // namespace OHOS
619596a2c1Sopenharmony_ci#endif