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 #include "cloud_enhancement_task_state_napi.h"
17 #include "cloud_enhancement_napi.h"
18 #include "cloud_media_asset_manager_napi.h"
19 #include "cloud_media_asset_status_napi.h"
20 #include "highlight_album_napi.h"
21 #include "media_album_change_request_napi.h"
22 #include "media_asset_change_request_napi.h"
23 #include "media_asset_edit_data_napi.h"
24 #include "media_asset_manager_napi.h"
25 #include "media_assets_change_request_napi.h"
26 #include "napi/native_node_api.h"
27 #include "native_module_ohos_medialibrary.h"
28 #include "photo_proxy_napi.h"
29
30 extern const char _binary_photoaccesshelperinf_js_start[];
31 extern const char _binary_photoaccesshelperinf_js_end[];
32 extern const char _binary_photoaccesshelperinf_abc_start[];
33 extern const char _binary_photoaccesshelperinf_abc_end[];
34
35 namespace OHOS {
36 namespace Media {
37 /*
38 * Function registering all props and functions of userfilemanager module
39 */
PhotoAccessHelperExport(napi_env env,napi_value exports)40 static napi_value PhotoAccessHelperExport(napi_env env, napi_value exports)
41 {
42 MediaLibraryNapi::PhotoAccessHelperInit(env, exports);
43 FetchFileResultNapi::PhotoAccessHelperInit(env, exports);
44 FileAssetNapi::PhotoAccessHelperInit(env, exports);
45 AlbumNapi::PhotoAccessHelperInit(env, exports);
46 PhotoAlbumNapi::PhotoAccessInit(env, exports);
47 HighlightAlbumNapi::Init(env, exports);
48 MediaAssetEditDataNapi::Init(env, exports);
49 MediaAssetChangeRequestNapi::Init(env, exports);
50 MediaAssetsChangeRequestNapi::Init(env, exports);
51 MediaAlbumChangeRequestNapi::Init(env, exports);
52 MediaAssetManagerNapi::Init(env, exports);
53 MovingPhotoNapi::Init(env, exports);
54 PhotoProxyNapi::Init(env, exports);
55 CloudEnhancementNapi::Init(env, exports);
56 CloudEnhancementTaskStateNapi::Init(env, exports);
57 CloudMediaAssetManagerNapi::Init(env, exports);
58 CloudMediaAssetStatusNapi::Init(env, exports);
59 return exports;
60 }
61
NAPI_file_photoAccessHelper_GetJSCode(const char ** buf,int * bufLen)62 extern "C" __attribute__((visibility("default"))) void NAPI_file_photoAccessHelper_GetJSCode(const char** buf,
63 int* bufLen)
64 {
65 if (buf != nullptr) {
66 *buf = _binary_photoaccesshelperinf_js_start;
67 }
68
69 if (bufLen != nullptr) {
70 *bufLen = _binary_photoaccesshelperinf_js_end - _binary_photoaccesshelperinf_js_start;
71 }
72 }
73
NAPI_file_photoAccessHelper_GetABCCode(const char ** buf,int * bufLen)74 extern "C" __attribute__((visibility("default"))) void NAPI_file_photoAccessHelper_GetABCCode(const char** buf,
75 int* bufLen)
76 {
77 if (buf != nullptr) {
78 *buf = _binary_photoaccesshelperinf_abc_start;
79 }
80
81 if (bufLen != nullptr) {
82 *bufLen = _binary_photoaccesshelperinf_abc_end - _binary_photoaccesshelperinf_abc_start;
83 }
84 }
85
86 /*
87 * module define
88 */
89 static napi_module g_photoAccessHelperModule = {
90 .nm_version = 1,
91 .nm_flags = 0,
92 .nm_filename = nullptr,
93 .nm_register_func = PhotoAccessHelperExport,
94 .nm_modname = "file.photoAccessHelper",
95 .nm_priv = reinterpret_cast<void *>(0),
96 .reserved = {0}
97 };
98
99 /*
100 * module register
101 */
RegisterPhotoAccessHelper(void)102 extern "C" __attribute__((constructor)) void RegisterPhotoAccessHelper(void)
103 {
104 napi_module_register(&g_photoAccessHelperModule);
105 }
106 } // namespace Media
107 } // namespace OHOS