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