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 "service_info_profile.h"
17
18 #include "cJSON.h"
19
20 #include "distributed_device_profile_constants.h"
21 #include "macro_utils.h"
22 #include "profile_utils.h"
23
24 namespace OHOS {
25 namespace DistributedDeviceProfile {
26 namespace {
27 const std::string TAG = "ServiceInfoProfile";
28 }
29
ServiceInfoProfile()30 ServiceInfoProfile::ServiceInfoProfile()
31 {
32 }
33
~ServiceInfoProfile()34 ServiceInfoProfile::~ServiceInfoProfile()
35 {
36 }
37
GetDeviceId() const38 std::string ServiceInfoProfile::GetDeviceId() const
39 {
40 return deviceId_;
41 }
42
SetDeviceId(const std::string & deviceId)43 void ServiceInfoProfile::SetDeviceId(const std::string& deviceId)
44 {
45 deviceId_ = deviceId;
46 }
47
GetUserId() const48 int32_t ServiceInfoProfile::GetUserId() const
49 {
50 return userId_;
51 }
52
SetUserId(const int32_t userId)53 void ServiceInfoProfile::SetUserId(const int32_t userId)
54 {
55 userId_ = userId;
56 }
57
GetNetworkId() const58 std::string ServiceInfoProfile::GetNetworkId() const
59 {
60 return networkId_;
61 }
62
SetNetworkId(const std::string & networkId)63 void ServiceInfoProfile::SetNetworkId(const std::string& networkId)
64 {
65 networkId_ = networkId;
66 }
67
GetTokenId() const68 std::string ServiceInfoProfile::GetTokenId() const
69 {
70 return tokenId_;
71 }
72
SetTokenId(const std::string & tokenId)73 void ServiceInfoProfile::SetTokenId(const std::string& tokenId)
74 {
75 tokenId_ = tokenId;
76 }
77
GetServiceId() const78 int64_t ServiceInfoProfile::GetServiceId() const
79 {
80 return serviceId_;
81 }
82
SetServiceId(const int64_t serviceId)83 void ServiceInfoProfile::SetServiceId(const int64_t serviceId)
84 {
85 serviceId_ = serviceId;
86 }
87
GetServiceType() const88 std::string ServiceInfoProfile::GetServiceType() const
89 {
90 return serviceType_;
91 }
92
SetServiceType(const std::string & serviceType)93 void ServiceInfoProfile::SetServiceType(const std::string& serviceType)
94 {
95 serviceType_ = serviceType;
96 }
97
GetServiceName() const98 std::string ServiceInfoProfile::GetServiceName() const
99 {
100 return serviceName_;
101 }
102
SetServiceName(const std::string & serviceName)103 void ServiceInfoProfile::SetServiceName(const std::string& serviceName)
104 {
105 serviceName_ = serviceName;
106 }
107
GetServiceDisplayName() const108 std::string ServiceInfoProfile::GetServiceDisplayName() const
109 {
110 return serviceDisplayName_;
111 }
112
SetServiceDisplayName(const std::string & serviceDisplayName)113 void ServiceInfoProfile::SetServiceDisplayName(const std::string& serviceDisplayName)
114 {
115 serviceDisplayName_ = serviceDisplayName;
116 }
117
GetCustomData() const118 std::string ServiceInfoProfile::GetCustomData() const
119 {
120 return customData_;
121 }
122
SetCustomData(const std::string & customData)123 void ServiceInfoProfile::SetCustomData(const std::string& customData)
124 {
125 customData_ = customData;
126 }
127
GetCustomDataLen() const128 int32_t ServiceInfoProfile::GetCustomDataLen() const
129 {
130 return customDataLen_;
131 }
132
SetCustomDataLen(const int32_t customDataLen)133 void ServiceInfoProfile::SetCustomDataLen(const int32_t customDataLen)
134 {
135 customDataLen_ = customDataLen;
136 }
137
GetBundleName() const138 std::string ServiceInfoProfile::GetBundleName() const
139 {
140 return bundleName_;
141 }
142
SetBundleName(const std::string & bundleName)143 void ServiceInfoProfile::SetBundleName(const std::string& bundleName)
144 {
145 bundleName_ = bundleName;
146 }
147
GetModuleName() const148 std::string ServiceInfoProfile::GetModuleName() const
149 {
150 return moduleName_;
151 }
152
SetModuleName(const std::string & moduleName)153 void ServiceInfoProfile::SetModuleName(const std::string& moduleName)
154 {
155 moduleName_ = moduleName;
156 }
157
GetAbilityName() const158 std::string ServiceInfoProfile::GetAbilityName() const
159 {
160 return abilityName_;
161 }
162
SetAbilityName(const std::string & abilityName)163 void ServiceInfoProfile::SetAbilityName(const std::string& abilityName)
164 {
165 abilityName_ = abilityName;
166 }
167
GetAuthBoxType() const168 int32_t ServiceInfoProfile::GetAuthBoxType() const
169 {
170 return authBoxType_;
171 }
172
SetAuthBoxType(const int32_t authBoxType)173 void ServiceInfoProfile::SetAuthBoxType(const int32_t authBoxType)
174 {
175 authBoxType_ = authBoxType;
176 }
177
GetAuthType() const178 int32_t ServiceInfoProfile::GetAuthType() const
179 {
180 return authType_;
181 }
182
SetAuthType(const int32_t authType)183 void ServiceInfoProfile::SetAuthType(const int32_t authType)
184 {
185 authType_ = authType;
186 }
187
GetPinExchangeType() const188 int32_t ServiceInfoProfile::GetPinExchangeType() const
189 {
190 return pinExchangeType_;
191 }
192
SetPinExchangeType(const int32_t pinExchangeType)193 void ServiceInfoProfile::SetPinExchangeType(const int32_t pinExchangeType)
194 {
195 pinExchangeType_ = pinExchangeType;
196 }
197
GetPinCode() const198 std::string ServiceInfoProfile::GetPinCode() const
199 {
200 return pinCode_;
201 }
202
SetPinCode(const std::string & pinCode)203 void ServiceInfoProfile::SetPinCode(const std::string& pinCode)
204 {
205 pinCode_ = pinCode;
206 }
207
GetDescription() const208 std::string ServiceInfoProfile::GetDescription() const
209 {
210 return description_;
211 }
212
SetDescription(const std::string & description)213 void ServiceInfoProfile::SetDescription(const std::string& description)
214 {
215 description_ = description;
216 }
217
GetServiceDicoveryScope() const218 std::string ServiceInfoProfile::GetServiceDicoveryScope() const
219 {
220 return serviceDicoveryScope_;
221 }
222
SetServiceDicoveryScope(const std::string & serviceDicoveryScope)223 void ServiceInfoProfile::SetServiceDicoveryScope(const std::string& serviceDicoveryScope)
224 {
225 serviceDicoveryScope_ = serviceDicoveryScope;
226 }
227
GetExtraInfo() const228 std::string ServiceInfoProfile::GetExtraInfo() const
229 {
230 return extraInfo_;
231 }
232
SetExtraInfo(const std::string & extraInfo)233 void ServiceInfoProfile::SetExtraInfo(const std::string& extraInfo)
234 {
235 extraInfo_ = extraInfo;
236 }
237
Marshalling(MessageParcel & parcel) const238 bool ServiceInfoProfile::Marshalling(MessageParcel& parcel) const
239 {
240 WRITE_HELPER_RET(parcel, String, deviceId_, false);
241 WRITE_HELPER_RET(parcel, Int32, userId_, false);
242 WRITE_HELPER_RET(parcel, String, networkId_, false);
243 WRITE_HELPER_RET(parcel, String, tokenId_, false);
244 WRITE_HELPER_RET(parcel, Int64, serviceId_, false);
245 WRITE_HELPER_RET(parcel, String, serviceType_, false);
246 WRITE_HELPER_RET(parcel, String, serviceName_, false);
247 WRITE_HELPER_RET(parcel, String, serviceDisplayName_, false);
248 WRITE_HELPER_RET(parcel, String, customData_, false);
249 WRITE_HELPER_RET(parcel, Int32, customDataLen_, false);
250 WRITE_HELPER_RET(parcel, String, bundleName_, false);
251 WRITE_HELPER_RET(parcel, String, moduleName_, false);
252 WRITE_HELPER_RET(parcel, String, abilityName_, false);
253 WRITE_HELPER_RET(parcel, Int32, authBoxType_, false);
254 WRITE_HELPER_RET(parcel, Int32, authType_, false);
255 WRITE_HELPER_RET(parcel, Int32, pinExchangeType_, false);
256 WRITE_HELPER_RET(parcel, String, pinCode_, false);
257 WRITE_HELPER_RET(parcel, String, description_, false);
258 WRITE_HELPER_RET(parcel, String, serviceDicoveryScope_, false);
259 WRITE_HELPER_RET(parcel, String, extraInfo_, false);
260 return true;
261 }
262
UnMarshalling(MessageParcel & parcel)263 bool ServiceInfoProfile::UnMarshalling(MessageParcel& parcel)
264 {
265 READ_HELPER_RET(parcel, String, deviceId_, false);
266 READ_HELPER_RET(parcel, Int32, userId_, false);
267 READ_HELPER_RET(parcel, String, networkId_, false);
268 READ_HELPER_RET(parcel, String, tokenId_, false);
269 READ_HELPER_RET(parcel, Int64, serviceId_, false);
270 READ_HELPER_RET(parcel, String, serviceType_, false);
271 READ_HELPER_RET(parcel, String, serviceName_, false);
272 READ_HELPER_RET(parcel, String, serviceDisplayName_, false);
273 READ_HELPER_RET(parcel, String, customData_, false);
274 READ_HELPER_RET(parcel, Int32, customDataLen_, false);
275 READ_HELPER_RET(parcel, String, bundleName_, false);
276 READ_HELPER_RET(parcel, String, moduleName_, false);
277 READ_HELPER_RET(parcel, String, abilityName_, false);
278 READ_HELPER_RET(parcel, Int32, authBoxType_, false);
279 READ_HELPER_RET(parcel, Int32, authType_, false);
280 READ_HELPER_RET(parcel, Int32, pinExchangeType_, false);
281 READ_HELPER_RET(parcel, String, pinCode_, false);
282 READ_HELPER_RET(parcel, String, description_, false);
283 READ_HELPER_RET(parcel, String, serviceDicoveryScope_, false);
284 READ_HELPER_RET(parcel, String, extraInfo_, false);
285 return true;
286 }
287
dump() const288 std::string ServiceInfoProfile::dump() const
289 {
290 return "";
291 }
292 } // namespace DistributedDeviceProfile
293 } // namespace OHOS
294