• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_FLAGS_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_FLAGS_H
18 
19 #include <memory>
20 #include "parcel.h"
21 
22 #include "notification_constant.h"
23 #include "notification_json_convert.h"
24 
25 namespace OHOS {
26 namespace Notification {
27 class NotificationFlags : public Parcelable, public NotificationJsonConvertionBase {
28 public:
29     /**
30      * Default constructor used to create an empty NotificationFlags instance.
31      */
32     NotificationFlags() = default;
33 
34     /**
35      * Default deconstructor used to deconstruct.
36      */
37     ~NotificationFlags() = default;
38 
39     /**
40      * Sets the notification whether enable sound.
41      * @param soundEnabled whether enable sound.
42      */
43     void SetSoundEnabled(NotificationConstant::FlagStatus soundEnabled);
44 
45     /**
46      * Checks whether enable sound.
47      * @return sound enable.
48      */
49     NotificationConstant::FlagStatus IsSoundEnabled() const;
50 
51     /**
52      * Sets the notification whether enable vibration.
53      * @param vibrationEnabled whether enable vibration.
54      */
55     void SetVibrationEnabled(NotificationConstant::FlagStatus vibrationEnabled);
56 
57     /**
58      * Checks whether enable vibration.
59      * @return vibration enable.
60      */
61     NotificationConstant::FlagStatus IsVibrationEnabled() const;
62 
63     /**
64      * Returns a string representation of the object.
65      * @return a string representation of the object.
66      */
67     std::string Dump();
68 
69     /**
70      * Converts a NotificationFlags object into a Json.
71      * @param jsonObject Indicates the Json object.
72      */
73     bool ToJson(nlohmann::json &jsonObject) const override;
74 
75     /**
76      * Creates a NotificationFlags object from a Json.
77      * @param jsonObject Indicates the Json object.
78      * @return the NotificationFlags.
79      */
80     static NotificationFlags *FromJson(const nlohmann::json &jsonObject);
81 
82     /**
83      * Marshal a object into a Parcel.
84      * @param parcel the object into the parcel
85      */
86     virtual bool Marshalling(Parcel &parcel) const override;
87 
88     /**
89      * Unmarshal object from a Parcel.
90      * @return the NotificationFlags
91      */
92     static NotificationFlags *Unmarshalling(Parcel &parcel);
93 
94 private:
95     /**
96      * Read a NotificationFlags object from a Parcel.
97      * @param parcel the parcel
98      */
99     bool ReadFromParcel(Parcel &parcel);
100 
101 private:
102     NotificationConstant::FlagStatus soundEnabled_ {NotificationConstant::FlagStatus::NONE};
103     NotificationConstant::FlagStatus vibrationEnabled_ {NotificationConstant::FlagStatus::NONE};
104 };
105 }  // namespace Notification
106 }  // namespace OHOS
107 
108 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_FLAGS_H
109 
110