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_Service"
17
18 #include "cloud_media_photo_service_processor.h"
19
20 #include "cloud_media_sync_utils.h"
21 #include "cloud_media_file_utils.h"
22 #include "photos_po.h"
23 #include "photos_dto.h"
24 #include "media_log.h"
25
26 namespace OHOS::Media::CloudSync {
Parse(const PhotosPo & photosPo)27 PhotosDto CloudMediaPhotoServiceProcessor::Parse(const PhotosPo &photosPo)
28 {
29 PhotosDto photosDto;
30 photosDto.data = photosPo.data.value_or("");
31 photosDto.size = photosPo.size.value_or(0);
32 photosDto.dateModified = photosPo.dateModified.value_or(0);
33 photosDto.dirty = photosPo.dirty.value_or(0);
34 photosDto.dateTrashed = photosPo.dateTrashed.value_or(0);
35 photosDto.position = photosPo.position.value_or(0);
36 photosDto.cloudId = photosPo.cloudId.value_or("");
37 photosDto.cloudVersion = photosPo.cloudVersion.value_or(0);
38 photosDto.fileId = photosPo.fileId.value_or(0);
39 photosDto.relativePath = photosPo.relativePath.value_or("");
40 photosDto.dateAdded = photosPo.dateAdded.value_or(0);
41 photosDto.ownerAlbumId = photosPo.ownerAlbumId.value_or(0);
42 photosDto.metaDateModified = photosPo.metaDateModified.value_or(0);
43 photosDto.syncStatus = photosPo.syncStatus.value_or(0);
44 photosDto.thumbStatus = photosPo.thumbStatus.value_or(0);
45 photosDto.displayName = photosPo.displayName.value_or("");
46 photosDto.orientation = photosPo.orientation.value_or(0);
47 photosDto.subtype = photosPo.subtype.value_or(0);
48 photosDto.movingPhotoEffectMode = photosPo.movingPhotoEffectMode.value_or(0);
49 photosDto.originalSubtype = photosPo.originalSubtype.value_or(0);
50 photosDto.sourcePath = photosPo.sourcePath.value_or("");
51 photosDto.mimeType = photosPo.mimeType.value_or("");
52 photosDto.mediaType = photosPo.mediaType.value_or(0);
53 CloudMediaSyncUtils::FillPhotosDto(photosDto, photosDto.data, photosDto.orientation,
54 photosPo.exifRotate.value_or(0), photosDto.thumbStatus);
55 CloudMediaFileUtils::GetParentPathAndFilename(photosDto.data, photosDto.path, photosDto.fileName);
56 MEDIA_DEBUG_LOG("photosDto: %{public}s", photosDto.ToString().c_str());
57 return photosDto;
58 }
59
GetPhotosDtos(const std::vector<PhotosPo> & photosPos)60 std::vector<PhotosDto> CloudMediaPhotoServiceProcessor::GetPhotosDtos(const std::vector<PhotosPo> &photosPos)
61 {
62 std::vector<PhotosDto> photosDtoList;
63 for (auto &photosPo : photosPos) {
64 photosDtoList.emplace_back(this->Parse(photosPo));
65 }
66 return photosDtoList;
67 }
68 } // namespace OHOS::Media::CloudSync