1 /*
2  * Copyright (C) 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_BUNDLEPERMM_OPERATIONS_H
17 #define OHOS_MEDIALIBRARY_BUNDLEPERMM_OPERATIONS_H
18 
19 #include <vector>
20 
21 #include "datashare_values_bucket.h"
22 #include "medialibrary_command.h"
23 #include "values_bucket.h"
24 #include "medialibrary_rdb_transaction.h"
25 
26 namespace OHOS {
27 namespace Media {
28 #define EXPORT __attribute__ ((visibility ("default")))
29 using namespace OHOS::DataShare;
30 class UriPermissionOperations {
31 public:
32     EXPORT static int32_t GetUriPermissionMode(const std::string &fileId, const std::string &bundleName,
33         int32_t tableType, std::string &mode);
34     EXPORT static int32_t CheckUriPermission(const std::string &fileUri, std::string mode);
35     EXPORT static int32_t HandleUriPermOperations(MediaLibraryCommand &cmd);
36     EXPORT static int32_t HandleUriPermInsert(MediaLibraryCommand &cmd);
37     EXPORT static int32_t InsertBundlePermission(const int32_t &fileId, const std::string &bundleName,
38         const std::string &mode, const std::string &tableName);
39     EXPORT static int32_t DeleteBundlePermission(const std::string &fileId, const std::string &bundleName,
40         const std::string &tableName);
41 
42     EXPORT static int32_t UpdateOperation(MediaLibraryCommand &cmd,
43         std::shared_ptr<TransactionOperations> trans = nullptr);
44     EXPORT static int32_t InsertOperation(MediaLibraryCommand &cmd);
45     EXPORT static int32_t BatchInsertOperation(MediaLibraryCommand &cmd,
46         const std::vector<NativeRdb::ValuesBucket> &values,
47         std::shared_ptr<TransactionOperations> trans = nullptr);
48     EXPORT static int32_t DeleteOperation(MediaLibraryCommand &cmd);
49     EXPORT static int32_t GrantUriPermission(MediaLibraryCommand &cmd,
50         const std::vector<DataShareValuesBucket> &values);
51     EXPORT static void DeleteAllTemporaryAsync();
52 };
53 } // Media
54 } // OHOS
55 #endif // OHOS_MEDIALIBRARY_BUNDLEPERMM_OPERATIONS_H