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