1 /* 2 * Copyright (c) 2023 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_BADGE_NUMBER_CALLBACK_DATA_H 17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_BADGE_NUMBER_CALLBACK_DATA_H 18 19 #include "notification_constant.h" 20 #include "parcel.h" 21 22 namespace OHOS { 23 namespace Notification { 24 class BadgeNumberCallbackData : public Parcelable { 25 public: 26 /** 27 * Default constructor used to create a BadgeNumberCallbackData instance. 28 */ 29 BadgeNumberCallbackData() = default; 30 31 /** 32 * A constructor used to create a BadgeNumberCallbackData 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 badgeNumber badge number. 36 */ 37 BadgeNumberCallbackData(const std::string &bundle, int32_t uid, int32_t badgeNumber); 38 39 /** 40 * A constructor used to create a BadgeNumberCallbackData instance with the input parameters passed. 41 * @param bundle Indicates the name of the application. 42 * @param appInstanceKey Indicates the application instance key. 43 * @param uid Indicates the uid of the application. 44 * @param badgeNumber badge number. 45 * @param instanceKey application instance key. 46 */ 47 BadgeNumberCallbackData(const std::string &bundle, const std::string &appInstanceKey_, int32_t uid, 48 int32_t badgeNumber, int32_t instanceKey = 0); 49 50 /** 51 * Default deconstructor used to deconstruct. 52 */ 53 ~BadgeNumberCallbackData() = default; 54 55 void SetBundle(const std::string &bundle); 56 57 std::string GetBundle() const; 58 59 void SetUid(int32_t uid); 60 61 int32_t GetUid() const; 62 63 void SetBadgeNumber(int32_t badgeNumber); 64 65 int32_t GetBadgeNumber() const; 66 67 void SetInstanceKey(int32_t key); 68 69 int32_t GetInstanceKey() const; 70 71 void SetAppInstanceKey(const std::string &key); 72 73 std::string GetAppInstanceKey() const; 74 75 /** 76 * Returns a string representation of the BadgeNumberCallbackData object. 77 */ 78 std::string Dump(); 79 80 /** 81 * Marshal a object into a Parcel. 82 * @param parcel the object into the parcel 83 */ 84 bool Marshalling(Parcel &parcel) const override; 85 86 /** 87 * Unmarshal object from a Parcel. 88 * @return the BadgeNumberCallbackData 89 */ 90 static BadgeNumberCallbackData *Unmarshalling(Parcel &parcel); 91 92 private: 93 bool ReadFromParcel(Parcel &parcel); 94 95 std::string bundle_; 96 std::string appInstanceKey_; 97 int32_t uid_; 98 int32_t badgeNumber_; 99 int32_t instanceKey_; 100 }; 101 } // namespace Notification 102 } // namespace OHOS 103 104 #endif // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_BADGE_NUMBER_CALLBACK_DATA_H