• 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 #define MLOG_TAG "Media_Cloud_Vo"
17 
18 #include "on_modify_records_photos_vo.h"
19 
20 #include <sstream>
21 
22 #include "media_itypes_utils.h"
23 
24 namespace OHOS::Media::CloudSync {
Unmarshalling(MessageParcel & parcel)25 bool OnModifyRecord::Unmarshalling(MessageParcel &parcel)
26 {
27     parcel.ReadString(this->cloudId);
28     parcel.ReadString(this->path);
29     parcel.ReadString(this->fileName);
30     parcel.ReadInt32(this->fileId);
31     parcel.ReadInt64(this->modifyTime);
32     parcel.ReadInt64(this->metaDateModified);
33     parcel.ReadInt64(this->version);
34     parcel.ReadBool(this->isSuccess);
35     int32_t copyRecordErrorType;
36     parcel.ReadInt32(copyRecordErrorType);
37     this->errorType = static_cast<ErrorType>(copyRecordErrorType);
38     parcel.ReadInt32(this->serverErrorCode);
39     IPC::ITypeMediaUtil::UnmarshallingParcelable<CloudErrorDetail>(this->errorDetails, parcel);
40     return true;
41 }
42 
Marshalling(MessageParcel & parcel) const43 bool OnModifyRecord::Marshalling(MessageParcel &parcel) const
44 {
45     parcel.WriteString(this->cloudId);
46     parcel.WriteString(this->path);
47     parcel.WriteString(this->fileName);
48     parcel.WriteInt32(this->fileId);
49     parcel.WriteInt64(this->modifyTime);
50     parcel.WriteInt64(this->metaDateModified);
51     parcel.WriteInt64(this->version);
52     parcel.WriteBool(this->isSuccess);
53     parcel.WriteInt32(static_cast<int32_t>(this->errorType));
54     parcel.WriteInt32(this->serverErrorCode);
55     IPC::ITypeMediaUtil::MarshallingParcelable<CloudErrorDetail>(this->errorDetails, parcel);
56     return true;
57 }
58 
ToString() const59 std::string OnModifyRecord::ToString() const
60 {
61     std::stringstream ss;
62     ss << "{"
63        << "\"cloudId\": \"" << cloudId << "\","
64        << "\"fileId\": \"" << fileId << "\","
65        << "\"modifyTime\": \"" << modifyTime << "\","
66        << "\"metaDateModified\": \"" << metaDateModified << "\","
67        << "\"path\": \"" << path << "\","
68        << "\"isSuccess\": \"" << std::to_string(isSuccess) << "\","
69        << "\"errorType\": \"" << static_cast<int32_t>(errorType) << "\","
70        << "\"serverErrorCode\": " << serverErrorCode << ","
71        << "[";
72     for (uint32_t i = 0; i < errorDetails.size(); ++i) {
73         ss << "{\"reason\": " << errorDetails[i].reason << "\","
74            << "\"errorCode\": " << errorDetails[i].errorCode << "\","
75            << "\"description\": " << errorDetails[i].description << "\","
76            << "\"errorPos\": " << errorDetails[i].errorPos << "\","
77            << "\"errorParam\": " << errorDetails[i].errorParam << "\","
78            << "\"detailCode\": " << errorDetails[i].detailCode << "\""
79            << "}";
80         if (i != errorDetails.size() - 1) {
81             ss << ",";
82         }
83     }
84     ss << "]}";
85     return ss.str();
86 }
87 
Unmarshalling(MessageParcel & parcel)88 bool OnModifyRecordsPhotosReqBody::Unmarshalling(MessageParcel &parcel)
89 {
90     return IPC::ITypeMediaUtil::UnmarshallingParcelable(this->records, parcel);
91 }
92 
Marshalling(MessageParcel & parcel) const93 bool OnModifyRecordsPhotosReqBody::Marshalling(MessageParcel &parcel) const
94 {
95     IPC::ITypeMediaUtil::MarshallingParcelable(this->records, parcel);
96     return true;
97 }
98 
AddModifyRecord(const OnModifyRecord & record)99 int32_t OnModifyRecordsPhotosReqBody::AddModifyRecord(const OnModifyRecord &record)
100 {
101     this->records.push_back(record);
102     return E_OK;
103 }
104 
GetModifyRecords()105 std::vector<OnModifyRecord> OnModifyRecordsPhotosReqBody::GetModifyRecords()
106 {
107     return records;
108 }
109 
ToString() const110 std::string OnModifyRecordsPhotosReqBody::ToString() const
111 {
112     std::stringstream ss;
113     return ss.str();
114 }
115 }  // namespace OHOS::Media::CloudSync