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_MEDIA_ASSETS_RDB_OPERATIONS_H 17 #define OHOS_MEDIA_ASSETS_RDB_OPERATIONS_H 18 19 #include <stdint.h> 20 #include <string> 21 #include <mutex> 22 #include <map> 23 24 #include "rdb_predicates.h" 25 #include "medialibrary_rdb_transaction.h" 26 #include "file_asset.h" 27 #include "medialibrary_operation.h" 28 #include "datashare_values_bucket.h" 29 #include "datashare_predicates.h" 30 #include "query_cloud_enhancement_task_state_dto.h" 31 #include "datashare_result_set.h" 32 33 namespace OHOS::Media { 34 35 class MediaAssetsRdbOperations { 36 public: 37 MediaAssetsRdbOperations(); 38 ~MediaAssetsRdbOperations() = default; 39 int32_t RemoveFormInfo(const std::string& formId); 40 int32_t RemoveGalleryFormInfo(const std::string& formId); 41 int32_t SaveFormInfo(const std::string& formId, const std::string& uri); 42 int32_t SaveGalleryFormInfo(const std::vector<std::string>& formIds, 43 const std::vector<std::string>& fileUris); 44 int32_t RevertToOrigin(const int32_t &fileId); 45 46 void QueryAssetsUri(const std::vector<std::string> &fileIds, std::vector<std::string> &uris); 47 48 bool QueryAlbumIdIfExists(const std::string& albumId); 49 bool QueryFileIdIfExists(const std::string& fileId); 50 bool QueryFormIdIfExists(const std::string& formId); 51 int32_t CommitEditInsert(const std::string& editData, int32_t fileId); 52 int32_t QueryEnhancementTaskState(const std::string& photoUri, QueryCloudEnhancementTaskStateDto& dto); 53 static void DeleteFromVisionTables(const std::string& fileId); 54 55 int32_t GrantPhotoUriPermission(MediaLibraryCommand &cmd); 56 int32_t GrantPhotoUrisPermission( 57 MediaLibraryCommand &cmd, const std::vector<DataShare::DataShareValuesBucket> &values); 58 int32_t CancelPhotoUriPermission(NativeRdb::RdbPredicates &rdbPredicate); 59 int32_t StartThumbnailCreationTask(NativeRdb::RdbPredicates &rdbPredicate, int32_t requestId); 60 int32_t StopThumbnailCreationTask(int32_t requestId); 61 int32_t CancelPhotoUrisPermissionInner(MediaLibraryCommand &cmd, 62 const DataShare::DataSharePredicates &values); 63 int32_t CheckPhotoUriPermissionInner(MediaLibraryCommand &cmd, const DataShare::DataSharePredicates &predicates, 64 const std::vector<std::string> &columns, std::vector<std::string> &outFileIds, 65 std::vector<int32_t> &permissionTypes); 66 int32_t GrantPhotoUrisPermissionInner( 67 MediaLibraryCommand &cmd, const std::vector<DataShare::DataShareValuesBucket> &values); 68 std::shared_ptr<DataShare::DataShareResultSet> GetUrisByOldUrisInner(MediaLibraryCommand &cmd, 69 const DataShare::DataSharePredicates &predicates, const std::vector<std::string> &columns); 70 71 private: 72 static std::shared_ptr<FileAsset> GetFileAssetFromDb(const std::string &column, const std::string &value, 73 OperationObject oprnObject, const std::vector<std::string> &columns = {}, const std::string &networkId = ""); 74 static std::mutex facardMutex_; 75 }; 76 77 } // namespace OHOS::Media 78 #endif // OHOS_MEDIA_ASSETS_RDB_OPERATIONS_H