• 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 #include "notification_normal_content.h"
17 #include "ans_log_wrapper.h"
18 
19 namespace OHOS {
20 namespace Notification {
Dump()21 std::string NotificationNormalContent::Dump()
22 {
23     return "NotificationNormalContent{ " + NotificationBasicContent::Dump() + " }";
24 }
25 
ToJson(nlohmann::json & jsonObject) const26 bool NotificationNormalContent::ToJson(nlohmann::json &jsonObject) const
27 {
28     return NotificationBasicContent::ToJson(jsonObject);
29 }
30 
FromJson(const nlohmann::json & jsonObject)31 NotificationNormalContent *NotificationNormalContent::FromJson(const nlohmann::json &jsonObject)
32 {
33     if (jsonObject.is_null() or !jsonObject.is_object()) {
34         ANS_LOGE("Invalid JSON object");
35         return nullptr;
36     }
37 
38     auto pContent = new (std::nothrow) NotificationNormalContent();
39     if (pContent == nullptr) {
40         ANS_LOGE("Failed to create normalContent instance");
41         return nullptr;
42     }
43 
44     pContent->ReadFromJson(jsonObject);
45 
46     return pContent;
47 }
48 
Marshalling(Parcel & parcel) const49 bool NotificationNormalContent::Marshalling(Parcel &parcel) const
50 {
51     return NotificationBasicContent::Marshalling(parcel);
52 }
53 
Unmarshalling(Parcel & parcel)54 NotificationNormalContent *NotificationNormalContent::Unmarshalling(Parcel &parcel)
55 {
56     auto pContent = new (std::nothrow) NotificationNormalContent();
57     if ((pContent != nullptr) && !pContent->ReadFromParcel(parcel)) {
58         delete pContent;
59         pContent = nullptr;
60     }
61 
62     return pContent;
63 }
64 }  // namespace Notification
65 }  // namespace OHOS
66