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