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 #include "native_module_ohos_medialibrary.h"
16 #include "napi/native_node_api.h"
17 extern const char _binary_photoaccesshelperinf_js_start[];
18 extern const char _binary_photoaccesshelperinf_js_end[];
19 extern const char _binary_photoaccesshelperinf_abc_start[];
20 extern const char _binary_photoaccesshelperinf_abc_end[];
21
22 namespace OHOS {
23 namespace Media {
24 /*
25 * Function registering all props and functions of userfilemanager module
26 */
PhotoAccessHelperExport(napi_env env,napi_value exports)27 static napi_value PhotoAccessHelperExport(napi_env env, napi_value exports)
28 {
29 MediaLibraryNapi::PhotoAccessHelperInit(env, exports);
30 FetchFileResultNapi::PhotoAccessHelperInit(env, exports);
31 FileAssetNapi::PhotoAccessHelperInit(env, exports);
32 AlbumNapi::PhotoAccessHelperInit(env, exports);
33 PhotoAlbumNapi::PhotoAccessInit(env, exports);
34 return exports;
35 }
36
NAPI_file_photoAccessHelper_GetJSCode(const char ** buf,int * bufLen)37 extern "C" __attribute__((visibility("default"))) void NAPI_file_photoAccessHelper_GetJSCode(const char** buf,
38 int* bufLen)
39 {
40 if (buf != nullptr) {
41 *buf = _binary_photoaccesshelperinf_js_start;
42 }
43
44 if (bufLen != nullptr) {
45 *bufLen = _binary_photoaccesshelperinf_js_end - _binary_photoaccesshelperinf_js_start;
46 }
47 }
48
NAPI_file_photoAccessHelper_GetABCCode(const char ** buf,int * bufLen)49 extern "C" __attribute__((visibility("default"))) void NAPI_file_photoAccessHelper_GetABCCode(const char** buf,
50 int* bufLen)
51 {
52 if (buf != nullptr) {
53 *buf = _binary_photoaccesshelperinf_abc_start;
54 }
55
56 if (bufLen != nullptr) {
57 *bufLen = _binary_photoaccesshelperinf_abc_end - _binary_photoaccesshelperinf_abc_start;
58 }
59 }
60
61 /*
62 * module define
63 */
64 static napi_module g_photoAccessHelperModule = {
65 .nm_version = 1,
66 .nm_flags = 0,
67 .nm_filename = nullptr,
68 .nm_register_func = PhotoAccessHelperExport,
69 .nm_modname = "file.photoAccessHelper",
70 .nm_priv = reinterpret_cast<void *>(0),
71 .reserved = {0}
72 };
73
74 /*
75 * module register
76 */
RegisterPhotoAccessHelper(void)77 extern "C" __attribute__((constructor)) void RegisterPhotoAccessHelper(void)
78 {
79 napi_module_register(&g_photoAccessHelperModule);
80 }
81 } // namespace Media
82 } // namespace OHOS