• 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 #ifndef INTELL_VOICE_MANAGER_NAPI_H
17 #define INTELL_VOICE_MANAGER_NAPI_H
18 
19 #include <functional>
20 
21 #include "napi/native_api.h"
22 #include "napi/native_node_api.h"
23 #include "service_change_callback_napi.h"
24 #include "intell_voice_manager.h"
25 #include "intell_voice_napi_queue.h"
26 #include "intell_voice_update_callback_napi.h"
27 
28 namespace OHOS {
29 namespace IntellVoiceNapi {
30 using OHOS::IntellVoice::IntellVoiceManager;
31 
32 class IntellVoiceManagerNapi {
33 public:
34     IntellVoiceManagerNapi();
35     ~IntellVoiceManagerNapi();
36 
37     static napi_value Export(napi_env env, napi_value exports);
38 
39 private:
40     static void Destruct(napi_env env, void *nativeObject, void *finalizeHint);
41     static napi_value Construct(napi_env env, napi_callback_info info);
42 
43     static napi_value GetCapabilityInfo(napi_env env, napi_callback_info info);
44     static napi_value On(napi_env env, napi_callback_info info);
45     static napi_value Off(napi_env env, napi_callback_info info);
46 
47     static napi_value GetIntelligentVoiceManager(napi_env env, napi_callback_info info);
48     static napi_value GetIntelligentVoiceManagerWrapper(napi_env env);
49     template <typename T>
50     static napi_value CreatePropertyBase(napi_env env, T &propertyMap, napi_ref ref);
51     static napi_value RegisterCallback(napi_env env, napi_value jsThis, napi_value *args);
52     static napi_value DeregisterCallback(napi_env env, napi_value jsThis);
53 
54 private:
55     napi_env env_ = nullptr;
56     napi_ref wrapper_ = nullptr;
57     sptr<ServiceChangeCallbackNapi> serviceChangeCb_ = nullptr;
58     IntellVoiceManager *manager_ = nullptr;
59     static napi_ref serviceChangeTypeRef_;
60     static napi_ref engineTypeRef_;
61     static napi_ref sensibilityTypeRef_;
62     static napi_ref enrollEventTypeRef_;
63     static napi_ref wakeupEventTypeRef_;
64     static napi_ref errorCodeRef_;
65     static napi_ref enrollResultRef_;
66     static napi_ref uploadFileTypeRef_;
67     static napi_ref cloneResultRef_;
68     static napi_ref evaluationResultCodeRef_;
69 };
70 }  // namespace IntellVoiceNapi
71 }  // namespace OHOS
72 #endif
73