• 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_DISTRIBUTED_OPTIONS_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_DISTRIBUTED_OPTIONS_H
18 
19 #include "notification_json_convert.h"
20 #include "parcel.h"
21 
22 namespace OHOS {
23 namespace Notification {
24 class NotificationDistributedOptions : public Parcelable, public NotificationJsonConvertionBase {
25 public:
26     NotificationDistributedOptions() = default;
27 
28     /**
29      * @brief Constructor used to create a NotificationDistributedOptions instance.
30      *
31      * @param distribute Specifies whether a notification is distributed.
32      * @param dvsDisplay Indicates the devices that support display.
33      * @param dvsOperate Indicates the devices that support operate.
34      */
35     NotificationDistributedOptions(
36         bool distribute, const std::vector<std::string> &dvsDisplay, const std::vector<std::string> &dvsOperate);
37 
38     ~NotificationDistributedOptions() = default;
39 
40     /**
41      * @brief Sets whether a notification is distributed.
42      *
43      * @param distribute Specifies whether a notification is distributed.
44      */
45     void SetDistributed(bool distribute);
46 
47     /**
48      * @brief Checks whether a notification is distributed.
49      *
50      * @return Returns true if the notification is distributed; returns false otherwise.
51      */
52     bool IsDistributed() const;
53 
54     /**
55      * @brief Sets devices that support display.
56      *
57      * @param devices Indicates the devices that support display.
58      */
59     void SetDevicesSupportDisplay(const std::vector<std::string> &devices);
60 
61     /**
62      * @brief Obtains the devices that support display.
63      *
64      * @return Returns the devices that support display.
65      */
66     std::vector<std::string> GetDevicesSupportDisplay() const;
67 
68     /**
69      * @brief Sets devices that support operate.
70      *
71      * @param devices Indicates the devices that support operate.
72      */
73     void SetDevicesSupportOperate(const std::vector<std::string> &devices);
74 
75     /**
76      * @brief Obtains the devices that support operate.
77      *
78      * @return Returns the devices that support operate.
79      */
80     std::vector<std::string> GetDevicesSupportOperate() const;
81 
82     /**
83      * @brief Returns a string representation of the object.
84      *
85      * @return Returns a string representation of the object.
86      */
87     std::string Dump();
88 
89     /**
90      * @brief Converts a NotificationDistributedOptions object into a Json.
91      *
92      * @param jsonObject Indicates the Json object.
93      * @return Returns true if succeed; returns false otherwise.
94      */
95     bool ToJson(nlohmann::json &jsonObject) const override;
96 
97     /**
98      * @brief Creates a NotificationDistributedOptions object from a Json.
99      *
100      * @param jsonObject Indicates the Json object.
101      * @return Returns the NotificationDistributedOptions.
102      */
103     static NotificationDistributedOptions *FromJson(const nlohmann::json &jsonObject);
104 
105     /**
106      * @brief Marshal a object into a Parcel.
107      *
108      * @param parcel Indicates the object into the parcel.
109      * @return Returns true if succeed; returns false otherwise.
110      */
111     virtual bool Marshalling(Parcel &parcel) const override;
112 
113     /**
114      * @brief Unmarshal object from a Parcel.
115      *
116      * @param parcel Indicates the parcel object.
117      * @return Returns the NotificationDistributedOptions object.
118      */
119     static NotificationDistributedOptions *Unmarshalling(Parcel &parcel);
120 
121 private:
122     /**
123      * @brief Read a NotificationDistributedOptions object from a Parcel.
124      *
125      * @param parcel Indicates the parcel object.
126      * @return Returns true if succeed; returns false otherwise.
127      */
128     bool ReadFromParcel(Parcel &parcel);
129 
130 private:
131     bool isDistributed_ {true};
132     std::vector<std::string> devicesSupportDisplay_ {};
133     std::vector<std::string> devicesSupportOperate_ {};
134 };
135 }  // namespace Notification
136 }  // namespace OHOS
137 
138 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_NOTIFICATION_DISTRIBUTED_OPTIONS_H