• 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_DTO"
17 
18 #include "cloud_media_pull_data_dto.h"
19 
20 #include <sstream>
21 
22 namespace OHOS::Media::CloudSync {
GetBasicInfo(std::stringstream & ss) const23 void CloudMediaPullDataDto::GetBasicInfo(std::stringstream &ss) const
24 {
25     ss << "\"cloudId\": \"" << cloudId << "\","
26        << "\"basicIsDelete\": " << std::to_string(basicIsDelete) << ","
27        << "\"basicSize\": " << basicSize << ","
28        << "\"basicMimeType\": \"" << basicMimeType << "\","
29        << "\"basicDeviceName\": \"" << basicDeviceName << "\","
30        << "\"basicEditedTime\": " << basicEditedTime << ","
31        << "\"basicCreatedTime\": " << basicCreatedTime << ","
32        << "\"dateTaken\": " << dateTaken << ","
33        << "\"basicIsFavorite\": " << basicIsFavorite << ","
34        << "\"basicIsRecycle\": " << basicIsRecycle << ","
35        << "\"basicRecycledTime\": " << basicRecycledTime << ","
36        << "\"basicDescription\": \"" << basicDescription << "\","
37        << "\"basicFileType\": " << basicFileType << ","
38        << "\"basicCloudVersion\": " << basicCloudVersion << ","
39        << "\"hasAttributes\": " << std::to_string(hasAttributes) << ","
40        << "\"attributesMediaType\": " << attributesMediaType << ","
41        << "\"duration\": " << duration << ","
42        << "\"attributesHidden\": " << attributesHidden << ","
43        << "\"attributesHiddenTime\": " << attributesHiddenTime << ","
44        << "\"attributesRelativePath\": \"" << attributesRelativePath << "\","
45        << "\"attributesVirtualPath\": \"" << attributesVirtualPath << "\","
46        << "\"attributesMetaDateModified\": " << attributesMetaDateModified << ","
47        << "\"attributesSubtype\": " << attributesSubtype << ",";
48 }
GetAttributesInfo(std::stringstream & ss) const49 void CloudMediaPullDataDto::GetAttributesInfo(std::stringstream &ss) const
50 {
51     ss << "\"attributesBurstCoverLevel\": " << attributesBurstCoverLevel << ","
52        << "\"attributesBurstKey\": \"" << attributesBurstKey << "\","
53        << "\"attributesDateYear\": \"" << attributesDateYear << "\","
54        << "\"attributesDateMonth\": \"" << attributesDateMonth << "\","
55        << "\"attributesDateDay\": \"" << attributesDateDay << "\","
56        << "\"attributesShootingMode\": \"" << attributesShootingMode << "\","
57        << "\"attributesShootingModeTag\": \"" << attributesShootingModeTag << "\","
58        << "\"attributesDynamicRangeType\": " << attributesDynamicRangeType << ","
59        << "\"attributesFrontCamera\": " << attributesFrontCamera << ","
60        << "\"attributesEditTime\": " << attributesEditTime << ","
61        << "\"attributesOriginalSubtype\": " << attributesOriginalSubtype << ","
62        << "\"attributesCoverPosition\": " << attributesCoverPosition << ","
63        << "\"attributesIsRectificationCover\": " << attributesIsRectificationCover << ","
64        << "\"exifRotate\": " << exifRotate << ","
65        << "\"attributesMovingPhotoEffectMode\": " << attributesMovingPhotoEffectMode << ","
66        << "\"attributesSupportedWatermarkType\": " << attributesSupportedWatermarkType << ","
67        << "\"attributesStrongAssociation\": " << attributesStrongAssociation << ","
68        << "\"attributesFileId\": " << attributesFileId << ","
69        << "\"attributesEditedTimeMs\": " << attributesEditedTimeMs << ","
70        << "\"attributesFixVersion\": " << attributesFixVersion << ","
71        << "\"attributesEditDataCamera\": \"" << attributesEditDataCamera << "\",";
72 }
GetPropertiesInfo(std::stringstream & ss) const73 void CloudMediaPullDataDto::GetPropertiesInfo(std::stringstream &ss) const
74 {
75     ss << "\"hasProperties\": " << std::to_string(hasProperties) << ","
76        << "\"propertiesRotate\": " << propertiesRotate << ","
77        << "\"propertiesHeight\": " << propertiesHeight << ","
78        << "\"propertiesWidth\": " << propertiesWidth << ","
79        << "\"propertiesFirstUpdateTime\": \"" << propertiesFirstUpdateTime << "\","
80        << "\"propertiesDetailTime\": \"" << propertiesDetailTime << "\","
81        << "\"localFileId\": " << localFileId << ","
82        << "\"localPath\": \"" << localPath << "\","
83        << "\"localSize\": " << localSize << ","
84        << "\"lcdSize\": " << lcdSize << ","
85        << "\"thmSize\": " << thmSize << ","
86        << "\"localMediaType\": " << localMediaType << ","
87        << "\"localDateAdded\": \"" << localDateAdded << "\","
88        << "\"localDateModified\": \"" << localDateModified << "\","
89        << "\"localDirty\": " << localDirty << ","
90        << "\"localPosition\": " << localPosition << ","
91        << "\"localOwnerAlbumId\": \"" << localOwnerAlbumId << "\","
92        << "\"localOrientation\": " << localOrientation << ","
93        << "\"localThumbState\": " << localThumbState;
94 }
GetCloudInfo(std::stringstream & ss) const95 void CloudMediaPullDataDto::GetCloudInfo(std::stringstream &ss) const
96 {
97     ss << "\"attributesCloudId\": \"" << attributesCloudId << "\","
98        << "\"attributesOriginCloudId\": \"" << attributesOriginCloudId << "\",";
99 }
GetAlbumIds(std::stringstream & ss) const100 void CloudMediaPullDataDto::GetAlbumIds(std::stringstream &ss) const
101 {
102     ss << "[";
103     for (uint32_t i = 0; i < attributesSrcAlbumIds.size(); ++i) {
104         if (i != attributesSrcAlbumIds.size() - 1) {
105             ss << "\"" << attributesSrcAlbumIds[i] << "\",";
106             continue;
107         }
108         ss << "\"" << attributesSrcAlbumIds[i] << "\"";
109     }
110     ss << "],";
111 }
ToString() const112 std::string CloudMediaPullDataDto::ToString() const
113 {
114     std::stringstream ss;
115     ss << "{";
116     this->GetBasicInfo(ss);
117     this->GetAttributesInfo(ss);
118     this->GetPropertiesInfo(ss);
119     this->GetCloudInfo(ss);
120     this->GetAlbumIds(ss);
121     ss << "}";
122     return ss.str();
123 }
124 }  // namespace OHOS::Media::CloudSync