• 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_fetch_photos_vo.h"
19 
20 #include <sstream>
21 
22 #include "media_itypes_utils.h"
23 
24 namespace OHOS::Media::CloudSync {
MarshallingBasicInfo(Parcel & parcel) const25 bool OnFetchPhotosVo::MarshallingBasicInfo(Parcel &parcel) const
26 {
27     parcel.WriteString(this->cloudId);
28     parcel.WriteString(this->fileName);
29     parcel.WriteString(this->fileSourcePath);
30     parcel.WriteString(this->mimeType);
31     parcel.WriteString(this->firstVisitTime);
32     parcel.WriteString(this->detailTime);
33     parcel.WriteString(this->frontCamera);
34     parcel.WriteString(this->editDataCamera);
35     parcel.WriteString(this->title);
36     parcel.WriteString(this->relativePath);
37     parcel.WriteString(this->virtualPath);
38     parcel.WriteString(this->dateYear);
39     parcel.WriteString(this->dateMonth);
40     parcel.WriteString(this->dateDay);
41     parcel.WriteString(this->shootingMode);
42     parcel.WriteString(this->shootingModeTag);
43     parcel.WriteString(this->burstKey);
44     parcel.WriteString(this->localPath);
45     parcel.WriteDouble(this->latitude);
46     parcel.WriteDouble(this->longitude);
47     parcel.WriteString(this->description);
48     parcel.WriteString(this->source);
49     return true;
50 }
51 
MarshallingAttributesInfo(Parcel & parcel) const52 bool OnFetchPhotosVo::MarshallingAttributesInfo(Parcel &parcel) const
53 {
54     parcel.WriteInt32(this->fileId);
55     parcel.WriteInt32(this->mediaType);
56     parcel.WriteInt32(this->fileType);
57     parcel.WriteInt32(this->rotation);
58     parcel.WriteInt32(this->photoHeight);
59     parcel.WriteInt32(this->photoWidth);
60     parcel.WriteInt32(this->duration);
61     parcel.WriteInt32(this->hidden);
62     parcel.WriteInt32(this->burstCoverLevel);
63     parcel.WriteInt32(this->subtype);
64     parcel.WriteInt32(this->originalSubtype);
65     parcel.WriteInt32(this->dynamicRangeType);
66     parcel.WriteInt32(this->movingPhotoEffectMode);
67     parcel.WriteInt32(this->supportedWatermarkType);
68     parcel.WriteInt32(this->strongAssociation);
69     parcel.WriteInt64(this->fixVersion);
70     parcel.WriteInt64(this->version);
71     parcel.WriteInt64(this->size);
72     parcel.WriteInt64(this->lcdSize);
73     parcel.WriteInt64(this->thmSize);
74     parcel.WriteInt64(this->createTime);
75     parcel.WriteInt64(this->metaDateModified);
76     parcel.WriteInt64(this->dualEditTime);
77     parcel.WriteInt64(this->editTime);
78     parcel.WriteInt64(this->editedTimeMs);
79     parcel.WriteInt64(this->recycledTime);
80     parcel.WriteInt64(this->hiddenTime);
81     parcel.WriteInt64(this->coverPosition);
82     parcel.WriteInt32(this->isRectificationCover);
83     parcel.WriteInt32(this->exifRotate);
84     parcel.WriteBool(this->isDelete);
85     return true;
86 }
87 
ReadBasicInfo(Parcel & parcel)88 bool OnFetchPhotosVo::ReadBasicInfo(Parcel &parcel)
89 {
90     parcel.ReadString(this->cloudId);
91     parcel.ReadString(this->fileName);
92     parcel.ReadString(this->fileSourcePath);
93     parcel.ReadString(this->mimeType);
94     parcel.ReadString(this->firstVisitTime);
95     parcel.ReadString(this->detailTime);
96     parcel.ReadString(this->frontCamera);
97     parcel.ReadString(this->editDataCamera);
98     parcel.ReadString(this->title);
99     parcel.ReadString(this->relativePath);
100     parcel.ReadString(this->virtualPath);
101     parcel.ReadString(this->dateYear);
102     parcel.ReadString(this->dateMonth);
103     parcel.ReadString(this->dateDay);
104     parcel.ReadString(this->shootingMode);
105     parcel.ReadString(this->shootingModeTag);
106     parcel.ReadString(this->burstKey);
107     parcel.ReadString(this->localPath);
108     parcel.ReadDouble(this->latitude);
109     parcel.ReadDouble(this->longitude);
110     parcel.ReadString(this->description);
111     parcel.ReadString(this->source);
112     return true;
113 }
114 
ReadAttributesInfo(Parcel & parcel)115 bool OnFetchPhotosVo::ReadAttributesInfo(Parcel &parcel)
116 {
117     parcel.ReadInt32(this->fileId);
118     parcel.ReadInt32(this->mediaType);
119     parcel.ReadInt32(this->fileType);
120     parcel.ReadInt32(this->rotation);
121     parcel.ReadInt32(this->photoHeight);
122     parcel.ReadInt32(this->photoWidth);
123     parcel.ReadInt32(this->duration);
124     parcel.ReadInt32(this->hidden);
125     parcel.ReadInt32(this->burstCoverLevel);
126     parcel.ReadInt32(this->subtype);
127     parcel.ReadInt32(this->originalSubtype);
128     parcel.ReadInt32(this->dynamicRangeType);
129     parcel.ReadInt32(this->movingPhotoEffectMode);
130     parcel.ReadInt32(this->supportedWatermarkType);
131     parcel.ReadInt32(this->strongAssociation);
132     parcel.ReadInt64(this->fixVersion);
133     parcel.ReadInt64(this->version);
134     parcel.ReadInt64(this->size);
135     parcel.ReadInt64(this->lcdSize);
136     parcel.ReadInt64(this->thmSize);
137     parcel.ReadInt64(this->createTime);
138     parcel.ReadInt64(this->metaDateModified);
139     parcel.ReadInt64(this->dualEditTime);
140     parcel.ReadInt64(this->editTime);
141     parcel.ReadInt64(this->editedTimeMs);
142     parcel.ReadInt64(this->recycledTime);
143     parcel.ReadInt64(this->hiddenTime);
144     parcel.ReadInt64(this->coverPosition);
145     parcel.ReadInt32(this->isRectificationCover);
146     parcel.ReadInt32(this->exifRotate);
147     parcel.ReadBool(this->isDelete);
148     return true;
149 }
150 
Unmarshalling(MessageParcel & parcel)151 bool OnFetchPhotosVo::Unmarshalling(MessageParcel &parcel)
152 {
153     this->ReadBasicInfo(parcel);
154     this->ReadAttributesInfo(parcel);
155     parcel.ReadBool(this->hasAttributes);
156     parcel.ReadBool(this->hasproperties);
157     parcel.ReadBool(this->isFavorite);
158     parcel.ReadBool(this->isRecycle);
159     IPC::ITypeMediaUtil::Unmarshalling<std::string>(this->sourceAlbumIds, parcel);
160     return true;
161 }
162 
Marshalling(MessageParcel & parcel) const163 bool OnFetchPhotosVo::Marshalling(MessageParcel &parcel) const
164 {
165     this->MarshallingBasicInfo(parcel);
166     this->MarshallingAttributesInfo(parcel);
167     parcel.WriteBool(this->hasAttributes);
168     parcel.WriteBool(this->hasproperties);
169     parcel.WriteBool(this->isFavorite);
170     parcel.WriteBool(this->isRecycle);
171     IPC::ITypeMediaUtil::Marshalling<std::string>(this->sourceAlbumIds, parcel);
172     return true;
173 }
174 
GetBasicInfo(std::stringstream & ss) const175 void OnFetchPhotosVo::GetBasicInfo(std::stringstream &ss) const
176 {
177     ss << "\"cloudId\": \"" << cloudId << "\","
178        << "\"mimeType\": \"" << mimeType << "\","
179        << "\"firstVisitTime\": \"" << firstVisitTime << "\","
180        << "\"detailTime\": \"" << detailTime << "\","
181        << "\"frontCamera\": \"" << frontCamera << "\","
182        << "\"editDataCamera\": \"" << editDataCamera << "\","
183        << "\"relativePath\": \"" << relativePath << "\","
184        << "\"virtualPath\": \"" << virtualPath << "\","
185        << "\"dateYear\": \"" << dateYear << "\","
186        << "\"dateMonth\": \"" << dateMonth << "\","
187        << "\"dateDay\": \"" << dateDay << "\","
188        << "\"shootingMode\": \"" << shootingMode << "\","
189        << "\"shootingModeTag\": \"" << shootingModeTag << "\","
190        << "\"burstKey\": \"" << burstKey << "\","
191        << "\"fileId\": \"" << fileId << "\","
192        << "\"mediaType\": \"" << mediaType << "\","
193        << "\"fileType\": \"" << fileType << "\","
194        << "\"rotation\": \"" << rotation << "\","
195        << "\"fixVersion\": \"" << fixVersion << "\","
196        << "\"photoHeight\": \"" << photoHeight << "\","
197        << "\"photoWidth\": \"" << photoWidth << "\","
198        << "\"duration\": \"" << duration << "\","
199        << "\"hidden\": \"" << hidden << "\",";
200     return;
201 }
202 
GetAttributesInfo(std::stringstream & ss) const203 void OnFetchPhotosVo::GetAttributesInfo(std::stringstream &ss) const
204 {
205     ss << "\"burstCoverLevel\": \"" << burstCoverLevel << "\","
206        << "\"subtype\": \"" << subtype << "\","
207        << "\"originalSubtype\": \"" << originalSubtype << "\","
208        << "\"dynamicRangeType\": \"" << dynamicRangeType << "\","
209        << "\"movingPhotoEffectMode\": \"" << movingPhotoEffectMode << "\","
210        << "\"version\": \"" << version << "\","
211        << "\"size\": \"" << size << "\","
212        << "\"lcdSize\": \"" << lcdSize << "\","
213        << "\"thmSize\": \"" << thmSize << "\","
214        << "\"createTime\": \"" << createTime << "\","
215        << "\"metaDateModified\": \"" << metaDateModified << "\","
216        << "\"dualEditTime\": \"" << dualEditTime << "\","
217        << "\"editTime\": \"" << editTime << "\","
218        << "\"editedTimeMs\": \"" << editedTimeMs << "\","
219        << "\"recycledTime\": \"" << recycledTime << "\","
220        << "\"hiddenTime\": \"" << hiddenTime << "\","
221        << "\"coverPosition\": \"" << coverPosition << "\","
222        << "\"isRectificationCover\": \"" << isRectificationCover << "\","
223        << "\"exifRotate\": \"" << exifRotate << "\","
224        << "\"isDelete\": \"" << isDelete << "\","
225        << "\"hasAttributes\": \"" << hasAttributes << "\","
226        << "\"hasproperties\": \"" << hasproperties << "\","
227        << "\"isFavorite\": \"" << isFavorite << "\","
228        << "\"isRecycle\": \"" << isRecycle << "\","
229        << "\"description\": \"" << description << "\","
230        << "\"DeviceName\": \"" << source << "\",";
231     return;
232 }
233 
ToString() const234 std::string OnFetchPhotosVo::ToString() const
235 {
236     std::stringstream ss;
237     ss << "{";
238     this->GetBasicInfo(ss);
239     this->GetAttributesInfo(ss);
240     ss << "AlbumIds:[";
241     for (uint32_t i = 0; i < sourceAlbumIds.size(); i++) {
242         if (i != sourceAlbumIds.size() - 1) {
243             ss << "\"" << sourceAlbumIds[i] << "\",";
244             continue;
245         }
246         ss << "\"" << sourceAlbumIds[i] << "\"";
247     }
248     ss << "]}";
249     return ss.str();
250 }
251 }  // namespace OHOS::Media::CloudSync