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 "application_defined_record_napi.h"
17 #include "audio_napi.h"
18 #include "file_napi.h"
19 #include "folder_napi.h"
20 #include "html_napi.h"
21 #include "image_napi.h"
22 #include "link_napi.h"
23 #include "logger.h"
24 #include "plain_text_napi.h"
25 #include "unified_data_channel_napi.h"
26 #include "summary_napi.h"
27 #include "system_defined_appitem_napi.h"
28 #include "system_defined_form_napi.h"
29 #include "system_defined_pixelmap_napi.h"
30 #include "system_defined_record_napi.h"
31 #include "text_napi.h"
32 #include "unified_data_napi.h"
33 #include "unified_record_napi.h"
34 #include "video_napi.h"
35
36 using namespace OHOS::UDMF;
37
38 EXTERN_C_START
Init(napi_env env,napi_value exports)39 static napi_value Init(napi_env env, napi_value exports)
40 {
41 OHOS::UDMF::UnifiedDataChannelNapi::UnifiedDataChannelInit(env, exports);
42
43 napi_status status =
44 napi_set_named_property(env, exports, "UnifiedData", OHOS::UDMF::UnifiedDataNapi::Constructor(env));
45 LOG_INFO(UDMF_KITS_NAPI, "init UnifiedData %{public}d", status);
46 status = napi_set_named_property(env, exports, "Summary", OHOS::UDMF::SummaryNapi::Constructor(env));
47 LOG_INFO(UDMF_KITS_NAPI, "init Summary %{public}d", status);
48 status = napi_set_named_property(env, exports, "UnifiedRecord", OHOS::UDMF::UnifiedRecordNapi::Constructor(env));
49 LOG_INFO(UDMF_KITS_NAPI, "init UnifiedRecord %{public}d", status);
50 status = napi_set_named_property(env, exports, "Text", OHOS::UDMF::TextNapi::Constructor(env));
51 LOG_INFO(UDMF_KITS_NAPI, "init Text %{public}d", status);
52 status = napi_set_named_property(env, exports, "PlainText", OHOS::UDMF::PlainTextNapi::Constructor(env));
53 LOG_INFO(UDMF_KITS_NAPI, "init PlainText %{public}d", status);
54 status = napi_set_named_property(env, exports, "Hyperlink", OHOS::UDMF::LinkNapi::Constructor(env));
55 LOG_INFO(UDMF_KITS_NAPI, "init Hyperlink %{public}d", status);
56 status = napi_set_named_property(env, exports, "HTML", OHOS::UDMF::HtmlNapi::Constructor(env));
57 LOG_INFO(UDMF_KITS_NAPI, "init HTML %{public}d", status);
58 status = napi_set_named_property(env, exports, "File", OHOS::UDMF::FileNapi::Constructor(env));
59 LOG_INFO(UDMF_KITS_NAPI, "init File %{public}d", status);
60 status = napi_set_named_property(env, exports, "Image", OHOS::UDMF::ImageNapi::Constructor(env));
61 LOG_INFO(UDMF_KITS_NAPI, "init Image %{public}d", status);
62 status = napi_set_named_property(env, exports, "Video", OHOS::UDMF::VideoNapi::Constructor(env));
63 LOG_INFO(UDMF_KITS_NAPI, "init Video %{public}d", status);
64 status = napi_set_named_property(env, exports, "Audio", OHOS::UDMF::AudioNapi::Constructor(env));
65 LOG_INFO(UDMF_KITS_NAPI, "init Audio %{public}d", status);
66 status = napi_set_named_property(env, exports, "Folder", OHOS::UDMF::FolderNapi::Constructor(env));
67 LOG_INFO(UDMF_KITS_NAPI, "init Folder %{public}d", status);
68 status = napi_set_named_property(
69 env, exports, "SystemDefinedRecord", OHOS::UDMF::SystemDefinedRecordNapi::Constructor(env));
70 LOG_INFO(UDMF_KITS_NAPI, "init SystemDefinedRecord %{public}d", status);
71 status = napi_set_named_property(
72 env, exports, "SystemDefinedForm", OHOS::UDMF::SystemDefinedFormNapi::Constructor(env));
73 LOG_INFO(UDMF_KITS_NAPI, "init SDForm %{public}d", status);
74 status = napi_set_named_property(
75 env, exports, "SystemDefinedAppItem", OHOS::UDMF::SystemDefinedAppItemNapi::Constructor(env));
76 LOG_INFO(UDMF_KITS_NAPI, "init SDAppItem %{public}d", status);
77 status = napi_set_named_property(
78 env, exports, "SystemDefinedPixelMap", OHOS::UDMF::SystemDefinedPixelMapNapi::Constructor(env));
79 LOG_INFO(UDMF_KITS_NAPI, "init SDPixelMap %{public}d", status);
80 status = napi_set_named_property(
81 env, exports, "ApplicationDefinedRecord", OHOS::UDMF::ApplicationDefinedRecordNapi::Constructor(env));
82 LOG_INFO(UDMF_KITS_NAPI, "init ApplicationDefinedRecord %{public}d", status);
83 return exports;
84 }
85 EXTERN_C_END
86
87 static napi_module _module = { .nm_version = 1,
88 .nm_flags = 0,
89 .nm_filename = nullptr,
90 .nm_register_func = Init,
91 .nm_modname = "data.unifiedDataChannel",
92 .nm_priv = ((void *)0),
93 .reserved = { 0 } };
94
RegisterUDMFUnifiedDataModule(void)95 extern "C" __attribute__((constructor)) void RegisterUDMFUnifiedDataModule(void)
96 {
97 napi_module_register(&_module);
98 LOG_INFO(UDMF_KITS_NAPI, "module register data.unifiedDataChannel");
99 }
100