• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_KITS_NATIVE_INCLUDE_NOTIFICATION_BUNDLE_OPTION_H
17 #define BASE_NOTIFICATION_ANS_STANDARD_KITS_NATIVE_INCLUDE_NOTIFICATION_BUNDLE_OPTION_H
18 
19 #include "parcel.h"
20 
21 namespace OHOS {
22 namespace Notification {
23 class NotificationBundleOption : public Parcelable {
24 public:
25     /**
26      * A default constructor used to create a NotificationBundleOption instance.
27      */
28     NotificationBundleOption() = default;
29 
30     /**
31      * A constructor used to create a NotificationBundleOption instance based on the creator bundle name and uid.
32      * @param bundleName Indicates the creator bundle name.
33      * @param uid Indicates the creator uid.
34      */
35     NotificationBundleOption(const std::string &bundleName, const int32_t uid);
36 
37     /**
38      * Default deconstructor used to deconstruct.
39      */
40     virtual ~NotificationBundleOption();
41 
42     /**
43      * Sets the creator bundle name.
44      * @param bundleName Indicates the creator bundle name.
45      */
46     void SetBundleName(const std::string &bundleName);
47 
48     /**
49      * Obtains the creator bundle name.
50      * @return the creator bundle name.
51      */
52     std::string GetBundleName() const;
53 
54     /**
55      * Sets the creator uid.
56      * @param uid Indicates the creator uid.
57      */
58     void SetUid(const int32_t uid);
59 
60     /**
61      * Obtains the creator uid.
62      * @return the creator uid.
63      */
64     int32_t GetUid() const;
65 
66     /**
67      * Returns a string representation of the object.
68      * @return a string representation of the object.
69      */
70     std::string Dump();
71 
72     /**
73      * Marshal a object into a Parcel.
74      * @param parcel the object into the parcel
75      */
76     virtual bool Marshalling(Parcel &parcel) const override;
77 
78     /**
79      * Unmarshal object from a Parcel.
80      * @return the NotificationBundleOption
81      */
82     static NotificationBundleOption *Unmarshalling(Parcel &parcel);
83 
84 private:
85     /**
86      * Read data from a Parcel.
87      * @param parcel the parcel
88      * @return true if read success; returns false otherwise.
89      */
90     bool ReadFromParcel(Parcel &parcel);
91 
92 private:
93     std::string bundleName_ {};
94     int32_t uid_ {};
95 };
96 }  // namespace Notification
97 }  // namespace OHOS
98 
99 #endif  // BASE_NOTIFICATION_ANS_STANDARD_KITS_NATIVE_INCLUDE_NOTIFICATION_CONTENT_H
100