1 /*
2  * Copyright (C) 2021-2022 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_MEDIALIBRARY_ALBUM_OPERATIONS_H
17 #define OHOS_MEDIALIBRARY_ALBUM_OPERATIONS_H
18 
19 #include <memory>
20 #include <securec.h>
21 #include <string>
22 
23 #include "abs_shared_result_set.h"
24 #include "datashare_predicates.h"
25 #include "datashare_values_bucket.h"
26 #include "medialibrary_command.h"
27 #include "native_album_asset.h"
28 #include "rdb_predicates.h"
29 #include "rdb_result_set_bridge.h"
30 #include "vision_column.h"
31 #include "medialibrary_async_worker.h"
32 
33 namespace OHOS {
34 namespace Media {
35 constexpr int32_t NULL_REFERENCE_ALBUM_ID = -1;
36 struct MergeAlbumInfo {
37     int albumId;
38     std::string groupTag;
39     int count;
40     int isMe;
41     std::string coverUri;
42     int userDisplayLevel;
43     int userOperation;
44     int rank;
45     int renameOperation;
46     std::string albumName;
47     uint8_t isCoverSatisfied;
48     std::string tagId;
49 };
50 class MediaLibraryAlbumOperations {
51 public:
52     static int32_t CreateAlbumOperation(MediaLibraryCommand &cmd);
53     static int32_t ModifyAlbumOperation(MediaLibraryCommand &cmd);
54     static shared_ptr<NativeRdb::ResultSet> QueryAlbumOperation(MediaLibraryCommand &cmd,
55         const std::vector<std::string> &columns);
56 
57     static int32_t HandlePhotoAlbumOperations(MediaLibraryCommand &cmd);
58     static std::shared_ptr<NativeRdb::ResultSet> QueryPhotoAlbum(MediaLibraryCommand &cmd,
59         const std::vector<std::string> &columns);
60     static int32_t DeletePhotoAlbum(NativeRdb::RdbPredicates &predicates);
61     static int32_t AddPhotoAssets(const vector<DataShare::DataShareValuesBucket> &values);
62     static int32_t HandlePhotoAlbum(const OperationType &opType, const NativeRdb::ValuesBucket &values,
63         const DataShare::DataSharePredicates &predicates, std::shared_ptr<int> countPtr = nullptr);
64     static int32_t HandleAnalysisPhotoAlbum(const OperationType &opType, const NativeRdb::ValuesBucket &values,
65         const DataShare::DataSharePredicates &predicates, std::shared_ptr<int> countPtr = nullptr);
66     static std::shared_ptr<NativeRdb::ResultSet> QueryPortraitAlbum(MediaLibraryCommand &cmd,
67         const std::vector<std::string> &columns);
68     static void DealwithNoAlbumAssets(const std::vector<std::string> &whereArgs);
69 };
70 } // namespace Media
71 } // namespace OHOS
72 #endif // OHOS_MEDIALIBRARY_ALBUM_OPERATIONS_H
73