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 uid Indicates the uid of the application.
43      * @param badgeNumber badge number.
44      * @param badgeNumber application instance key.
45      */
46     BadgeNumberCallbackData(const std::string &bundle, int32_t uid, int32_t badgeNumber, int32_t instanceKey);
47 
48     /**
49      * Default deconstructor used to deconstruct.
50      */
51     ~BadgeNumberCallbackData() = default;
52 
53     void SetBundle(const std::string &bundle);
54 
55     std::string GetBundle() const;
56 
57     void SetUid(int32_t uid);
58 
59     int32_t GetUid() const;
60 
61     void SetBadgeNumber(int32_t badgeNumber);
62 
63     int32_t GetBadgeNumber() const;
64 
65     void SetInstanceKey(int32_t key);
66 
67     int32_t GetInstanceKey() const;
68 
69     /**
70      * Returns a string representation of the BadgeNumberCallbackData object.
71      */
72     std::string Dump();
73 
74     /**
75      * Marshal a object into a Parcel.
76      * @param parcel the object into the parcel
77      */
78     bool Marshalling(Parcel &parcel) const override;
79 
80     /**
81      * Unmarshal object from a Parcel.
82      * @return the BadgeNumberCallbackData
83      */
84     static BadgeNumberCallbackData *Unmarshalling(Parcel &parcel);
85 
86 private:
87     bool ReadFromParcel(Parcel &parcel);
88 
89     std::string bundle_;
90     int32_t uid_;
91     int32_t badgeNumber_;
92     int32_t instanceKey_;
93 };
94 }  // namespace Notification
95 }  // namespace OHOS
96 
97 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_BADGE_NUMBER_CALLBACK_DATA_H