196279301Sopenharmony_ci/*
296279301Sopenharmony_ci * Copyright (c) 2022-2024 Huawei Device Co., Ltd.
396279301Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
496279301Sopenharmony_ci * you may not use this file except in compliance with the License.
596279301Sopenharmony_ci * You may obtain a copy of the License at
696279301Sopenharmony_ci *
796279301Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
896279301Sopenharmony_ci *
996279301Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1096279301Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1196279301Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1296279301Sopenharmony_ci * See the License for the specific language governing permissions and
1396279301Sopenharmony_ci * limitations under the License.
1496279301Sopenharmony_ci */
1596279301Sopenharmony_ci
1696279301Sopenharmony_ci#ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_FLAGS_H
1796279301Sopenharmony_ci#define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_FLAGS_H
1896279301Sopenharmony_ci
1996279301Sopenharmony_ci#include <memory>
2096279301Sopenharmony_ci#include "parcel.h"
2196279301Sopenharmony_ci
2296279301Sopenharmony_ci#include "notification_constant.h"
2396279301Sopenharmony_ci#include "notification_json_convert.h"
2496279301Sopenharmony_ci
2596279301Sopenharmony_cinamespace OHOS {
2696279301Sopenharmony_cinamespace Notification {
2796279301Sopenharmony_ciclass NotificationFlags : public Parcelable, public NotificationJsonConvertionBase {
2896279301Sopenharmony_cipublic:
2996279301Sopenharmony_ci    /**
3096279301Sopenharmony_ci     * Default constructor used to create an empty NotificationFlags instance.
3196279301Sopenharmony_ci     */
3296279301Sopenharmony_ci    NotificationFlags() = default;
3396279301Sopenharmony_ci
3496279301Sopenharmony_ci    /**
3596279301Sopenharmony_ci     * Default deconstructor used to deconstruct.
3696279301Sopenharmony_ci     */
3796279301Sopenharmony_ci    ~NotificationFlags() = default;
3896279301Sopenharmony_ci
3996279301Sopenharmony_ci    /**
4096279301Sopenharmony_ci     * Sets the notification whether enable sound.
4196279301Sopenharmony_ci     * @param soundEnabled whether enable sound.
4296279301Sopenharmony_ci     */
4396279301Sopenharmony_ci    void SetSoundEnabled(NotificationConstant::FlagStatus soundEnabled);
4496279301Sopenharmony_ci
4596279301Sopenharmony_ci    /**
4696279301Sopenharmony_ci     * Checks whether enable sound.
4796279301Sopenharmony_ci     * @return sound enable.
4896279301Sopenharmony_ci     */
4996279301Sopenharmony_ci    NotificationConstant::FlagStatus IsSoundEnabled() const;
5096279301Sopenharmony_ci
5196279301Sopenharmony_ci    /**
5296279301Sopenharmony_ci     * Sets the notification whether enable vibration.
5396279301Sopenharmony_ci     * @param vibrationEnabled whether enable vibration.
5496279301Sopenharmony_ci     */
5596279301Sopenharmony_ci    void SetVibrationEnabled(NotificationConstant::FlagStatus vibrationEnabled);
5696279301Sopenharmony_ci
5796279301Sopenharmony_ci    /**
5896279301Sopenharmony_ci     * Checks whether enable vibration.
5996279301Sopenharmony_ci     * @return vibration enable.
6096279301Sopenharmony_ci     */
6196279301Sopenharmony_ci    NotificationConstant::FlagStatus IsVibrationEnabled() const;
6296279301Sopenharmony_ci
6396279301Sopenharmony_ci    /**
6496279301Sopenharmony_ci     * Get reminder flags.
6596279301Sopenharmony_ci     * @return reminder flags.
6696279301Sopenharmony_ci     */
6796279301Sopenharmony_ci    uint32_t GetReminderFlags();
6896279301Sopenharmony_ci
6996279301Sopenharmony_ci    /**
7096279301Sopenharmony_ci     * Sets the notification whether enable lock screen.
7196279301Sopenharmony_ci     * @param visblenessEnabled whether enable lock screen.
7296279301Sopenharmony_ci     */
7396279301Sopenharmony_ci    void SetLockScreenVisblenessEnabled(bool visblenessEnabled);
7496279301Sopenharmony_ci
7596279301Sopenharmony_ci    /**
7696279301Sopenharmony_ci     * Checks whether enable lock screen.
7796279301Sopenharmony_ci     * @return lock screen enable.
7896279301Sopenharmony_ci     */
7996279301Sopenharmony_ci    bool IsLockScreenVisblenessEnabled();
8096279301Sopenharmony_ci
8196279301Sopenharmony_ci    /**
8296279301Sopenharmony_ci     * Sets the notification whether enable banner.
8396279301Sopenharmony_ci     * @param bannerEnabled whether enable banner.
8496279301Sopenharmony_ci     */
8596279301Sopenharmony_ci    void SetBannerEnabled(bool bannerEnabled);
8696279301Sopenharmony_ci
8796279301Sopenharmony_ci    /**
8896279301Sopenharmony_ci     * Checks whether enable banner.
8996279301Sopenharmony_ci     * @return banner enable.
9096279301Sopenharmony_ci     */
9196279301Sopenharmony_ci    bool IsBannerEnabled();
9296279301Sopenharmony_ci
9396279301Sopenharmony_ci    /**
9496279301Sopenharmony_ci     * Sets the notification whether light screen.
9596279301Sopenharmony_ci     * @param lightScreenEnabled whether light screen.
9696279301Sopenharmony_ci     */
9796279301Sopenharmony_ci    void SetLightScreenEnabled(bool lightScreenEnabled);
9896279301Sopenharmony_ci
9996279301Sopenharmony_ci    /**
10096279301Sopenharmony_ci     * Checks whether enable light screen.
10196279301Sopenharmony_ci     * @return light screen enable.
10296279301Sopenharmony_ci     */
10396279301Sopenharmony_ci    bool IsLightScreenEnabled();
10496279301Sopenharmony_ci
10596279301Sopenharmony_ci    /**
10696279301Sopenharmony_ci     * Sets the notification whether status icon.
10796279301Sopenharmony_ci     * @param statusIconEnabled whether status icon.
10896279301Sopenharmony_ci     */
10996279301Sopenharmony_ci    void SetStatusIconEnabled(bool statusIconEnabled);
11096279301Sopenharmony_ci
11196279301Sopenharmony_ci    /**
11296279301Sopenharmony_ci     * Checks whether enable status icon.
11396279301Sopenharmony_ci     * @return status icon enable.
11496279301Sopenharmony_ci     */
11596279301Sopenharmony_ci    bool IsStatusIconEnabled();
11696279301Sopenharmony_ci
11796279301Sopenharmony_ci    /**
11896279301Sopenharmony_ci     * Returns a string representation of the object.
11996279301Sopenharmony_ci     * @return a string representation of the object.
12096279301Sopenharmony_ci     */
12196279301Sopenharmony_ci    std::string Dump();
12296279301Sopenharmony_ci
12396279301Sopenharmony_ci    /**
12496279301Sopenharmony_ci     * Converts a NotificationFlags object into a Json.
12596279301Sopenharmony_ci     * @param jsonObject Indicates the Json object.
12696279301Sopenharmony_ci     */
12796279301Sopenharmony_ci    bool ToJson(nlohmann::json &jsonObject) const override;
12896279301Sopenharmony_ci
12996279301Sopenharmony_ci    /**
13096279301Sopenharmony_ci     * Creates a NotificationFlags object from a Json.
13196279301Sopenharmony_ci     * @param jsonObject Indicates the Json object.
13296279301Sopenharmony_ci     * @return the NotificationFlags.
13396279301Sopenharmony_ci     */
13496279301Sopenharmony_ci    static NotificationFlags *FromJson(const nlohmann::json &jsonObject);
13596279301Sopenharmony_ci
13696279301Sopenharmony_ci    /**
13796279301Sopenharmony_ci     * Marshal a object into a Parcel.
13896279301Sopenharmony_ci     * @param parcel the object into the parcel
13996279301Sopenharmony_ci     */
14096279301Sopenharmony_ci    virtual bool Marshalling(Parcel &parcel) const override;
14196279301Sopenharmony_ci
14296279301Sopenharmony_ci    /**
14396279301Sopenharmony_ci     * Unmarshal object from a Parcel.
14496279301Sopenharmony_ci     * @return the NotificationFlags
14596279301Sopenharmony_ci     */
14696279301Sopenharmony_ci    static NotificationFlags *Unmarshalling(Parcel &parcel);
14796279301Sopenharmony_ci
14896279301Sopenharmony_ci    static bool GetReminderFlagsByString(
14996279301Sopenharmony_ci        const std::string &strReminderFlags, std::shared_ptr<NotificationFlags> &reminderFlags);
15096279301Sopenharmony_ci
15196279301Sopenharmony_ci    static bool ValidCharReminderFlag(const char &charReminderFlag, const int32_t &seq);
15296279301Sopenharmony_ci
15396279301Sopenharmony_ciprivate:
15496279301Sopenharmony_ci    /**
15596279301Sopenharmony_ci     * Read a NotificationFlags object from a Parcel.
15696279301Sopenharmony_ci     * @param parcel the parcel
15796279301Sopenharmony_ci     */
15896279301Sopenharmony_ci    bool ReadFromParcel(Parcel &parcel);
15996279301Sopenharmony_ci
16096279301Sopenharmony_ciprivate:
16196279301Sopenharmony_ci    NotificationConstant::FlagStatus soundEnabled_ {NotificationConstant::FlagStatus::NONE};
16296279301Sopenharmony_ci    NotificationConstant::FlagStatus vibrationEnabled_ {NotificationConstant::FlagStatus::NONE};
16396279301Sopenharmony_ci    uint32_t reminderFlags_ = 0;
16496279301Sopenharmony_ci
16596279301Sopenharmony_ci    static constexpr char CHAR_REMIND_DISABLE = '0';
16696279301Sopenharmony_ci    static constexpr char CHAR_REMIND_ENABLE = '1';
16796279301Sopenharmony_ci    static constexpr char CHAR_FLAG_STATUS_CLOSE = '2';
16896279301Sopenharmony_ci    static constexpr int32_t SOUND_ENABLED_SEQ = 5;
16996279301Sopenharmony_ci    static constexpr int32_t LOCK_SCREEN_VISIBLENESS_ENABLED_SEQ = 4;
17096279301Sopenharmony_ci    static constexpr int32_t BANNER_ENABLED_SEQ = 3;
17196279301Sopenharmony_ci    static constexpr int32_t LIGHT_SCREEN_ENABLED_SEQ = 2;
17296279301Sopenharmony_ci    static constexpr int32_t VIBRATION_ENABLED_SEQ = 1;
17396279301Sopenharmony_ci    static constexpr int32_t ICON_ENABLED_SEQ = 0;
17496279301Sopenharmony_ci};
17596279301Sopenharmony_ci}  // namespace Notification
17696279301Sopenharmony_ci}  // namespace OHOS
17796279301Sopenharmony_ci
17896279301Sopenharmony_ci#endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_FLAGS_H
17996279301Sopenharmony_ci
180