• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_operation_info.h"
17 
18 #include "ans_log_wrapper.h"
19 #include "message_user.h"                         // for MessageUser
20 #include "nlohmann/json.hpp"                      // for json, basic_json<>:...
21 #include "notification_json_convert.h"            // for NotificationJsonCon...
22 #include "parcel.h"                               // for Parcel
23 #include "uri.h"                                  // for Uri
24 
25 namespace OHOS {
26 namespace Notification {
27 
GetActionName() const28 std::string NotificationOperationInfo::GetActionName() const
29 {
30     return actionName_;
31 }
32 
SetActionName(const std::string & actionName)33 void NotificationOperationInfo::SetActionName(const std::string& actionName)
34 {
35     actionName_ = actionName;
36 }
37 
GetUserInput() const38 std::string NotificationOperationInfo::GetUserInput() const
39 {
40     return userInput_;
41 }
42 
SetUserInput(const std::string & userInput)43 void NotificationOperationInfo::SetUserInput(const std::string& userInput)
44 {
45     userInput_ = userInput;
46 }
47 
GetHashCode() const48 std::string NotificationOperationInfo::GetHashCode() const
49 {
50     return hashCode_;
51 }
52 
SetHashCode(const std::string & hashCode)53 void NotificationOperationInfo::SetHashCode(const std::string& hashCode)
54 {
55     hashCode_ = hashCode;
56 }
57 
GetEventId() const58 std::string NotificationOperationInfo::GetEventId() const
59 {
60     return eventId_;
61 }
62 
SetEventId(const std::string & eventId)63 void NotificationOperationInfo::SetEventId(const std::string& eventId)
64 {
65     eventId_ = eventId;
66 }
67 
GetOperationType() const68 OperationType NotificationOperationInfo::GetOperationType() const
69 {
70     return operationType_;
71 }
72 
SetOperationType(const OperationType & operationType)73 void NotificationOperationInfo::SetOperationType(const OperationType& operationType)
74 {
75     operationType_ = operationType;
76 }
77 
Dump()78 std::string NotificationOperationInfo::Dump()
79 {
80     return "NotificationOperationInfo{ "
81         "hashCode = " + hashCode_ +
82         ", eventId = " + eventId_ +
83         ", actionName = " + actionName_ +
84         ", operationType = " + std::to_string(static_cast<int32_t>(operationType_)) +
85         " }";
86 }
87 
Marshalling(Parcel & parcel) const88 bool NotificationOperationInfo::Marshalling(Parcel &parcel) const
89 {
90     if (!parcel.WriteString(actionName_)) {
91         ANS_LOGE("Failed to write action name");
92         return false;
93     }
94 
95     if (!parcel.WriteString(userInput_)) {
96         ANS_LOGE("Failed to write user input");
97         return false;
98     }
99 
100     if (!parcel.WriteString(hashCode_)) {
101         ANS_LOGE("Failed to write user input");
102         return false;
103     }
104 
105     if (!parcel.WriteString(eventId_)) {
106         ANS_LOGE("Failed to write user input");
107         return false;
108     }
109 
110     if (!parcel.WriteInt32(static_cast<int32_t>(operationType_))) {
111         ANS_LOGE("Failed to write user input");
112         return false;
113     }
114 
115     return true;
116 }
117 
ReadFromParcel(Parcel & parcel)118 bool NotificationOperationInfo::ReadFromParcel(Parcel &parcel)
119 {
120     if (!parcel.ReadString(actionName_)) {
121         ANS_LOGE("Failed to read action name");
122         return false;
123     }
124 
125     if (!parcel.ReadString(userInput_)) {
126         ANS_LOGE("Failed to read user input");
127         return false;
128     }
129 
130     if (!parcel.ReadString(hashCode_)) {
131         ANS_LOGE("Failed to read action name");
132         return false;
133     }
134 
135     if (!parcel.ReadString(eventId_)) {
136         ANS_LOGE("Failed to read user input");
137         return false;
138     }
139 
140     operationType_ = static_cast<OperationType>(parcel.ReadInt32());
141 
142     return true;
143 }
144 
Unmarshalling(Parcel & parcel)145 NotificationOperationInfo *NotificationOperationInfo::Unmarshalling(Parcel &parcel)
146 {
147     auto operationInfo = new (std::nothrow) NotificationOperationInfo();
148     if (operationInfo && !operationInfo->ReadFromParcel(parcel)) {
149         delete operationInfo;
150         operationInfo = nullptr;
151     }
152 
153     return operationInfo;
154 }
155 
156 }  // namespace Notification
157 }  // namespace OHOS
158