• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 INTERFACES_INNERKITS_NATIVE_INCLUDE_MEDIA_LIBRARY_HANDLER_H_
17 #define INTERFACES_INNERKITS_NATIVE_INCLUDE_MEDIA_LIBRARY_HANDLER_H_
18 
19 #include "datashare_helper.h"
20 #include "media_file_uri.h"
21 
22 extern "C" {
23 /**
24  * @brief convert the file uri to mnt path
25  *
26  * @param uris which need to convert
27  * @param results to save the converted uris
28  * @since 1.0
29  * @version 1.0
30  */
31 EXPORT void ConvertFileUriToMntPath(const std::vector<std::string> &uris, std::vector<std::string> &results);
32 }
33 
34 namespace OHOS {
35 namespace Media {
36 using namespace std;
37 using namespace OHOS::DataShare;
38 
39 class MediaLibraryHandler {
40 public:
41     EXPORT MediaLibraryHandler() = default;
42     EXPORT virtual ~MediaLibraryHandler() = default;
43 
44     /**
45      * @brief Returns the Media Library Handler Instance
46      *
47      * @return Returns the Media Library Handler Instance
48      * @since 1.0
49      * @version 1.0
50      */
51     EXPORT static MediaLibraryHandler *GetMediaLibraryHandler();
52 
53     /**
54      * @brief Initializes the environment for Media Library Handler
55      *
56      * @since 1.0
57      * @version 1.0
58      */
59     EXPORT void InitMediaLibraryHandler();
60 
61     /**
62      * @brief get file path from uri
63      *
64      * @param uris which need to convert
65      * @param dataUris to save the converted uris
66      * @return errorcode
67      * @since 1.0
68      * @version 1.0
69      */
70     EXPORT int32_t GetDataUris(const vector<string> &uris, vector<string> &dataUris);
71 
72     sptr<IRemoteObject> InitToken();
73     int32_t ProcessResultSet(shared_ptr<DataShareResultSet> &resultSet,
74         vector<string> &dataUris, vector<string> &fileIds);
75     int32_t CheckResultSet(shared_ptr<DataShareResultSet> &resultSet, int32_t &row);
76 private:
77     static shared_ptr<DataShare::DataShareHelper> sDataShareHelper_;
78     static sptr<IRemoteObject> token_;
79 };
80 } // namespace Media
81 } // namespace OHOS
82 
83 #endif  // INTERFACES_INNERKITS_NATIVE_INCLUDE_MEDIA_LIBRARY_HANDLER_H_
84