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_ENABLED_CALLBACK_DATA_H 17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_ENABLED_CALLBACK_DATA_H 18 19 #include "notification_constant.h" 20 #include "parcel.h" 21 22 namespace OHOS { 23 namespace Notification { 24 class EnabledNotificationCallbackData : public Parcelable { 25 public: 26 /** 27 * Default constructor used to create a EnabledNotificationCallbackData instance. 28 */ 29 EnabledNotificationCallbackData() = default; 30 31 /** 32 * A constructor used to create a EnabledNotificationCallbackData instance with the input parameters passed. 33 * @param bundle Indicates the name of the application. 34 * @param uid Indicates the uid of the application. 35 * @param enable Indicates whether the application is allowed to send or receive notification. 36 */ 37 EnabledNotificationCallbackData(std::string bundle, uid_t uid, bool enable); 38 39 /** 40 * Default deconstructor used to deconstruct. 41 */ 42 ~EnabledNotificationCallbackData() = default; 43 44 void SetBundle(const std::string bundle); 45 46 std::string GetBundle() const; 47 48 void SetUid(const uid_t uid); 49 50 uid_t GetUid() const; 51 52 void SetEnable(const bool enable); 53 54 bool GetEnable() const; 55 56 /** 57 * Returns a string representation of the object. 58 * @return a string representation of the object. 59 */ 60 std::string Dump(); 61 62 /** 63 * Marshal a object into a Parcel. 64 * @param parcel the object into the parcel 65 */ 66 virtual bool Marshalling(Parcel &parcel) const override; 67 68 /** 69 * Unmarshal object from a Parcel. 70 * @return the EnabledNotificationCallbackData 71 */ 72 static EnabledNotificationCallbackData *Unmarshalling(Parcel &parcel); 73 74 private: 75 /** 76 * Read a NotificationDoNotDisturbDate object from a Parcel. 77 * @param parcel the parcel 78 */ 79 bool ReadFromParcel(Parcel &parcel); 80 81 std::string bundle_; 82 uid_t uid_; 83 bool enable_; 84 }; 85 } // namespace Notification 86 } // namespace OHOS 87 88 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_ENABLED_CALLBACK_DATA_H