• 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_file_dirty_vo.h"
19 
20 #include <sstream>
21 
22 #include "media_itypes_utils.h"
23 
24 namespace OHOS::Media::CloudSync {
Unmarshalling(MessageParcel & parcel)25 bool OnFileDirtyRecord::Unmarshalling(MessageParcel &parcel)
26 {
27     parcel.ReadString(this->cloudId);
28     parcel.ReadInt32(this->fileId);
29     parcel.ReadInt32(this->rotation);
30     parcel.ReadInt32(this->fileType);
31     parcel.ReadInt64(this->size);
32     parcel.ReadInt64(this->metaDateModified);
33     parcel.ReadInt64(this->createTime);
34     parcel.ReadInt64(this->modifyTime);
35     parcel.ReadString(this->path);
36     parcel.ReadString(this->fileName);
37     parcel.ReadString(this->sourcePath);
38     parcel.ReadInt64(this->version);
39     parcel.ReadInt32(this->serverErrorCode);
40     parcel.ReadBool(this->isSuccess);
41     IPC::ITypeMediaUtil::UnmarshallingParcelable<CloudErrorDetail>(this->errorDetails, parcel);
42     int32_t copyRecordErrorType;
43     parcel.ReadInt32(copyRecordErrorType);
44     this->errorType = static_cast<ErrorType>(copyRecordErrorType);
45     return true;
46 }
47 
Marshalling(MessageParcel & parcel) const48 bool OnFileDirtyRecord::Marshalling(MessageParcel &parcel) const
49 {
50     parcel.WriteString(this->cloudId);
51     parcel.WriteInt32(this->fileId);
52     parcel.WriteInt32(this->rotation);
53     parcel.WriteInt32(this->fileType);
54     parcel.WriteInt64(this->size);
55     parcel.WriteInt64(this->metaDateModified);
56     parcel.WriteInt64(this->createTime);
57     parcel.WriteInt64(this->modifyTime);
58     parcel.WriteString(this->path);
59     parcel.WriteString(this->fileName);
60     parcel.WriteString(this->sourcePath);
61     parcel.WriteInt64(this->version);
62     parcel.WriteInt32(this->serverErrorCode);
63     parcel.WriteBool(this->isSuccess);
64     IPC::ITypeMediaUtil::MarshallingParcelable<CloudErrorDetail>(this->errorDetails, parcel);
65     parcel.WriteInt32(static_cast<int32_t>(this->errorType));
66     return true;
67 }
68 
ToString() const69 std::string OnFileDirtyRecord::ToString() const
70 {
71     std::stringstream ss;
72     ss << "{"
73        << "\"cloudId\": \"" << cloudId << "\","
74        << "\"fileId\": \"" << fileId << "\","
75        << "\"rotation\": \"" << rotation << "\","
76        << "\"fileType\": \"" << fileType << "\","
77        << "\"size\": \"" << size << "\","
78        << "\"path\": \"" << path << "\","
79        << "\"createTime\": \"" << createTime << "\","
80        << "\"modifyTime\": \"" << modifyTime << "\","
81        << "\"version\": \"" << version << "\","
82        << "\"serverErrorCode\": \"" << serverErrorCode << "\","
83        << "\"isSuccess\": \"" << isSuccess << "\","
84        << "\"errorType\": \"" << static_cast<int32_t>(errorType) << "\","
85        << "\"errorDetails\": \"[";
86     for (uint32_t i = 0; i < errorDetails.size(); ++i) {
87         if (i != errorDetails.size() - 1) {
88             ss << errorDetails[i].ToString() << ",";
89             continue;
90         }
91         ss << errorDetails[i].ToString();
92     }
93     ss << "]}";
94     return ss.str();
95 }
96 
Unmarshalling(MessageParcel & parcel)97 bool OnFileDirtyRecordsReqBody::Unmarshalling(MessageParcel &parcel)
98 {
99     return IPC::ITypeMediaUtil::UnmarshallingParcelable(this->records, parcel);
100 }
101 
Marshalling(MessageParcel & parcel) const102 bool OnFileDirtyRecordsReqBody::Marshalling(MessageParcel &parcel) const
103 {
104     IPC::ITypeMediaUtil::MarshallingParcelable(this->records, parcel);
105     return true;
106 }
107 
AddRecord(const OnFileDirtyRecord & record)108 int32_t OnFileDirtyRecordsReqBody::AddRecord(const OnFileDirtyRecord &record)
109 {
110     this->records.push_back(record);
111     return E_OK;
112 }
113 
ToString() const114 std::string OnFileDirtyRecordsReqBody::ToString() const
115 {
116     std::stringstream ss;
117     ss << "{\"records\":[";
118     for (uint32_t i = 0; i < records.size(); ++i) {
119         if (i != records.size() - 1) {
120             ss << records[i].ToString() << ",";
121             continue;
122         }
123         ss << records[i].ToString();
124     }
125     ss << "]}";
126     return ss.str();
127 }
128 }  // namespace OHOS::Media::CloudSync