• 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_BASIC_CONTENT_H
17 #define BASE_NOTIFICATION_ANS_STANDARD_KITS_NATIVE_INCLUDE_NOTIFICATION_BASIC_CONTENT_H
18 
19 #include "notification_json_convert.h"
20 #include "parcel.h"
21 
22 namespace OHOS {
23 namespace Notification {
24 class NotificationBasicContent : public Parcelable, public NotificationJsonConvertionBase {
25 public:
26     /**
27      * Default deconstructor used to deconstruct.
28      */
29     virtual ~NotificationBasicContent();
30 
31     /**
32      * Sets the additional text to be included in a notification.
33      * The additional text is mainly a supplement to the notification text set by calling setText(std::string).
34      * The font of the additional text is smaller than the notification text and is displayed in a separate line.
35      * @param text Indicates the additional text to be included.
36      */
37     virtual void SetAdditionalText(const std::string &additionalText);
38 
39     /**
40      * Obtains the additional text of a notification specified by calling setAdditionalText(std::string).
41      * @return the additional text of the notification.
42      */
43     virtual std::string GetAdditionalText() const;
44 
45     /**
46      * Sets the text to be included in a notification.
47      * @param text Indicates the text to be included.
48      */
49     virtual void SetText(const std::string &text);
50 
51     /**
52      * Obtains the text of a notification specified by calling setText(std::string).
53      * @return the text of the notification.
54      */
55     virtual std::string GetText() const;
56 
57     /**
58      * Sets the title of a notification.
59      * @param title Indicates the title of the notification.
60      */
61     virtual void SetTitle(const std::string &title);
62 
63     /**
64      * Obtains the title of a notification specified by calling the setTitle(std::string) method.
65      * @return the title of the notification.
66      */
67     virtual std::string GetTitle() const;
68 
69     /**
70      * Returns a string representation of the object.
71      * @return a string representation of the object.
72      */
73     virtual std::string Dump();
74 
75     /**
76      * Converts a NotificationBasicContent object into a Json.
77      * @param jsonObject Indicates the Json object.
78      */
79     virtual bool ToJson(nlohmann::json &jsonObject) const override;
80 
81     /**
82      * Marshal a object into a Parcel.
83      * @param parcel the object into the parcel
84      */
85     virtual bool Marshalling(Parcel &parcel) const override;
86 
87 protected:
88     /**
89      * Default constructor.
90      */
91     NotificationBasicContent() = default;
92 
93     /**
94      * Read data from a Parcel.
95      * @param parcel the parcel
96      * @return true if read success; returns false otherwise.
97      */
98     virtual bool ReadFromParcel(Parcel &parcel);
99 
100     /**
101      * Creates a NotificationBasicContent object from a Json.
102      * @param jsonObject Indicates the Json object.
103      */
104     void ReadFromJson(const nlohmann::json &jsonObject);
105 
106 protected:
107     std::string text_ {};
108     std::string title_ {};
109     std::string additionalText_ {};
110 };
111 }  // namespace Notification
112 }  // namespace OHOS
113 
114 #endif  // BASE_NOTIFICATION_ANS_STANDARD_KITS_NATIVE_INCLUDE_NOTIFICATION_BASIC_CONTENT_H
115