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_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_PROGRESS_H
17 #define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_PROGRESS_H
18 
19 #include "notification_json_convert.h"
20 #include "parcel.h"
21 #include <cstdint>
22 
23 namespace OHOS {
24 namespace Notification {
25 class NotificationProgress : public Parcelable, public NotificationJsonConvertionBase {
26 public:
27     NotificationProgress() = default;
28     ~NotificationProgress() = default;
29 
30     /**
31      * @brief Obtains the text to be displayed as the content of this message.
32      *
33      * @return Returns the message content.
34      */
35     int32_t GetMaxValue() const;
36 
37     void SetMaxValue(int32_t maxValue);
38 
39     /**
40      * @brief Obtains the time when this message arrived.
41      *
42      * @return Returns the time when this message arrived.
43      */
44     int32_t GetCurrentValue() const;
45 
46     void SetCurrentValue(int32_t curValue);
47 
48     /**
49      * @brief Obtains the sender of this message.
50      *
51      * @return Returns the message sender.
52      */
53     bool GetIsPercentage() const;
54 
55     void SetIsPercentage(bool isPercentage);
56 
57     /**
58      * @brief Returns a string representation of the object.
59      *
60      * @return Returns a string representation of the object.
61      */
62     std::string Dump();
63 
64     /**
65      * @brief Converts a NotificationConversationalMessage object into a Json.
66      *
67      * @param jsonObject Indicates the Json object.
68      * @return Returns true if succeed; returns false otherwise.
69      */
70     bool ToJson(nlohmann::json &jsonObject) const override;
71 
72     /**
73      * @brief Creates a NotificationConversationalMessage object from a Json.
74      *
75      * @param jsonObject Indicates the Json object.
76      * @return Returns the NotificationConversationalMessage.
77      */
78     static NotificationProgress *FromJson(const nlohmann::json &jsonObject);
79 
80     /**
81      * @brief Marshal a object into a Parcel.
82      *
83      * @param parcel Indicates the object into the parcel.
84      * @return Returns true if succeed; returns false otherwise.
85      */
86     virtual bool Marshalling(Parcel &parcel) const override;
87 
88     /**
89      * @brief Unmarshal object from a Parcel.
90      *
91      * @param parcel Indicates the parcel object.
92      * @return Returns the NotificationConversationalMessage.
93      */
94     static NotificationProgress *Unmarshalling(Parcel &parcel);
95 
96 private:
97     /**
98      * @brief Read a NotificationConversationalMessage object from a Parcel.
99      *
100      * @param parcel Indicates the parcel object.
101      * @return Returns true if succeed; returns false otherwise.
102      */
103     bool ReadFromParcel(Parcel &parcel);
104 
105 private:
106     int32_t maxValue_ {0};
107     int32_t currentValue_ {0};
108     bool isPercentage_ {true};
109 };
110 }  // namespace Notification
111 }  // namespace OHOS
112 
113 #endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_PROGRESS_H