1 /* 2 * Copyright (c) 2023-2024 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 OHOS_DP_IPC_SERIALIZATION_UTILS_H 17 #define OHOS_DP_IPC_SERIALIZATION_UTILS_H 18 19 #include <map> 20 #include <string> 21 #include <vector> 22 23 #include "message_parcel.h" 24 #include "parcel.h" 25 26 #include "access_control_profile.h" 27 #include "accessee.h" 28 #include "accesser.h" 29 #include "characteristic_profile.h" 30 #include "device_icon_info.h" 31 #include "device_profile.h" 32 #include "distributed_device_profile_constants.h" 33 #include "distributed_device_profile_errors.h" 34 #include "distributed_device_profile_log.h" 35 #include "dp_subscribe_info.h" 36 #include "product_info.h" 37 #include "service_info_profile.h" 38 #include "service_profile.h" 39 #include "trust_device_profile.h" 40 #include "trusted_device_info.h" 41 42 namespace OHOS { 43 namespace DistributedDeviceProfile { 44 class IpcUtils { 45 public: 46 static bool Marshalling(MessageParcel& parcel, const std::vector<TrustDeviceProfile>& trustDeviceProfiles); 47 static bool Marshalling(MessageParcel& parcel, const std::vector<AccessControlProfile>& aclProfiles); 48 static bool Marshalling(MessageParcel& parcel, const std::vector<DeviceProfile>& deviceProfiles); 49 static bool Marshalling(MessageParcel& parcel, const std::vector<ServiceProfile>& serviceProfiles); 50 static bool Marshalling(MessageParcel& parcel, const std::vector<CharacteristicProfile>& charProfiles); 51 static bool Marshalling(MessageParcel& parcel, const std::vector<std::string>& strings); 52 static bool Marshalling(MessageParcel& parcel, const std::vector<int32_t>& params); 53 static bool Marshalling(MessageParcel& parcel, const std::vector<uint8_t>& params); 54 static bool Marshalling(MessageParcel& parcel, const std::map<std::string, std::string>& params); 55 static bool Marshalling(MessageParcel& parcel, const std::map<std::string, 56 OHOS::DistributedDeviceProfile::SubscribeInfo>& listenerMap); 57 static bool Marshalling(MessageParcel& parcel, const std::unordered_set<ProfileChangeType>& changeTypes); 58 static bool Marshalling(MessageParcel& parcel, const std::vector<TrustedDeviceInfo>& deviceInfos); 59 static bool Marshalling(MessageParcel& parcel, const std::vector<DeviceIconInfo>& deviceIconInfos); 60 static bool Marshalling(MessageParcel& parcel, const std::vector<ProductInfo>& productInfos); 61 static bool Marshalling(MessageParcel& parcel, const std::vector<ServiceInfoProfile>& serviceInfoProfiles); 62 static bool UnMarshalling(MessageParcel& parcel, std::vector<ServiceInfoProfile>& serviceInfoProfiles); 63 static bool UnMarshalling(MessageParcel& parcel, std::vector<ProductInfo>& productInfos); 64 static bool UnMarshalling(MessageParcel& parcel, std::vector<DeviceIconInfo>& deviceIconInfos); 65 static bool UnMarshalling(MessageParcel& parcel, std::vector<TrustDeviceProfile>& trustDeviceProfiles); 66 static bool UnMarshalling(MessageParcel& parcel, std::vector<AccessControlProfile>& aclProfiles); 67 static bool UnMarshalling(MessageParcel& parcel, std::vector<DeviceProfile>& deviceProfiles); 68 static bool UnMarshalling(MessageParcel& parcel, std::vector<ServiceProfile>& serviceProfiles); 69 static bool UnMarshalling(MessageParcel& parcel, std::vector<CharacteristicProfile>& charProfiles); 70 static bool UnMarshalling(MessageParcel& parcel, std::vector<std::string>& strings); 71 static bool UnMarshalling(MessageParcel& parcel, std::vector<int32_t>& params); 72 static bool UnMarshalling(MessageParcel& parcel, std::vector<uint8_t>& params); 73 static bool UnMarshalling(MessageParcel& parcel, std::map<std::string, std::string>& params); 74 static bool UnMarshalling(MessageParcel& parcel, std::map<std::string, 75 OHOS::DistributedDeviceProfile::SubscribeInfo>& listenerMap); 76 static bool UnMarshalling(MessageParcel& parcel, std::unordered_set<ProfileChangeType>& changeTypes); 77 static bool UnMarshalling(MessageParcel& parcel, std::vector<TrustedDeviceInfo>& deviceInfos); 78 }; 79 } // namespace DistributedDeviceProfile 80 } // namespace OHOS 81 #endif // OHOS_DP_IPC_SERIALIZATION_UTILS_H 82