• 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 #ifndef OHOS_CLOUD_MEDIA_SYNC_UTILS_H
17 #define OHOS_CLOUD_MEDIA_SYNC_UTILS_H
18 
19 #include <string>
20 #include <vector>
21 
22 #include "photo_album_po.h"
23 #include "photos_dto.h"
24 #include "photos_po.h"
25 #include "cloud_media_dao_const.h"
26 #include "cloud_media_pull_data_dto.h"
27 
28 namespace OHOS::Media::CloudSync {
29 #define EXPORT __attribute__ ((visibility ("default")))
30 using namespace OHOS::Media::ORM;
31 class EXPORT CloudMediaSyncUtils {
32 public:
33     CloudMediaSyncUtils();
34     ~CloudMediaSyncUtils();
35 
36     static std::string GetLocalPath(const std::string &filePath);
37     static bool IsLocalDirty(int32_t dirty, bool isDelete);
38     static bool FileIsLocal(const int32_t position);
39     static std::string GetCloudPath(const std::string &path, const std::string &prefixCloud);
40     static std::string GetThumbParentPath(const std::string &path, const std::string &prefixCloud);
41     static void RemoveThmParentPath(const std::string &path, const std::string &prefixCloud);
42     static void RemoveEditDataParentPath(const std::string &path, const std::string &prefixCloud);
43     static void RemoveMetaDataPath(const std::string &path, const std::string &prefixCloud);
44     static void InvalidVideoCache(const std::string &localPath);
45     static void RemoveMovingPhoto(const std::string &localPath);
46     static void RemoveEditDataPath(const std::string &localPath);
47     static uint32_t GenerateCloudIdWithHash(PhotoAlbumPo &record);
48     static int32_t FillPhotosDto(PhotosDto &photosDto, const std::string &path, const int32_t &orientation,
49         const int32_t exifRotate, const int32_t &thumbState);
50     static int32_t FillPhotosDto(PhotosDto &photosDto, const CloudMediaPullDataDto &data);
51     static std::string GetLpathFromSourcePath(const std::string &sourcePath);
52     static std::string GetLpath(const CloudMediaPullDataDto &pullData);
53     static std::string GetMovingPhotoExtraDataDir(const std::string &localPath);
54     static std::string GetMovingPhotoExtraDataPath(const std::string &localPath);
55     static std::string GetEditDataDir(const std::string &localPath);
56     static std::string GetEditDataPath(const std::string &localPath);
57     static std::string GetMovingPhotoVideoPath(const std::string &localPath);
58     static std::string GetMovingPhotoTmpPath(const std::string &localPath);
59     static std::string GetEditDataSourcePath(const std::string& photoPath);
60     static std::string GetSourceMovingPhotoImagePath(const std::string& photoPath);
61     static std::string GetSourceMovingPhotoVideoPath(const std::string& photoPath);
62     static bool IsMovingPhoto(const PhotosPo &photosPo);
63     static bool IsGraffiti(const PhotosPo &photosPo);
64     static bool IsLivePhoto(const PhotosPo &photosPo);
65     static int32_t UpdateModifyTime(const std::string &localPath, int64_t localMtime);
66     static bool IsUserAlbumPath(const std::string &lpath);
67     static bool CanUpdateExifRotateOnly(int32_t mediaType, int32_t oldExifRotate, int32_t newExifRotate);
68     static int32_t GetExifRotate(int32_t mediaType, const std::string &path);
69 };
70 } // namespace OHOS::Media::CloudSync
71 #endif // OHOS_CLOUD_MEDIA_SYNC_UTILS_H
72