1 /*
2  * Copyright (c) 2023 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 EXT_SPECIAL_CONTROLLER_H
17 #define EXT_SPECIAL_CONTROLLER_H
18 
19 #include "datashare_connection.h"
20 #include "datashare_operation_statement.h"
21 #include "datashare_values_bucket.h"
22 #include "uri.h"
23 
24 namespace OHOS {
25 namespace DataShare {
26 class ExtSpecialController {
27 public:
28     ExtSpecialController(std::shared_ptr<DataShareConnection> connection, const Uri &uri,
29         const sptr<IRemoteObject> &token);
30     virtual ~ExtSpecialController() = default;
31 
32     int OpenFile(const Uri &uri, const std::string &mode);
33 
34     int OpenRawFile(const Uri &uri, const std::string &mode);
35 
36     int BatchUpdate(const UpdateOperations &operations, std::vector<BatchUpdateResult> &results);
37 
38     std::string GetType(const Uri &uri);
39 
40     int BatchInsert(const Uri &uri, const std::vector<DataShareValuesBucket> &values);
41 
42     int ExecuteBatch(const std::vector<OperationStatement> &statements, ExecResultSet &result);
43 
44     int InsertExt(Uri &uri, const DataShareValuesBucket &value, std::string &result);
45 
46     Uri NormalizeUri(const Uri &uri);
47 
48     Uri DenormalizeUri(const Uri &uri);
49 
50     std::vector<std::string> GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter);
51 
52 private:
53     std::shared_ptr<DataShareConnection> connection_ = nullptr;
54     sptr<IRemoteObject> token_ = {};
55     Uri uri_ = Uri("");
56 };
57 }
58 }
59 
60 #endif // EXT_SPECIAL_CONTROLLER_H
61