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 JS_SHORT_KEY_CONTEXT_H
17 #define JS_SHORT_KEY_CONTEXT_H
18 #include "js_short_key_manager.h"
19 
20 namespace OHOS {
21 namespace MMI {
22 class JsShortKeyContext {
23 public:
24     JsShortKeyContext();
25     DISALLOW_COPY_AND_MOVE(JsShortKeyContext);
26     ~JsShortKeyContext() = default;
27     static napi_value Export(napi_env env, napi_value exports);
28     std::shared_ptr<JsShortKeyManager> GetJsShortKeyMgr() const;
29     static napi_value SetKeyDownDuration(napi_env env, napi_callback_info info);
30 
31 private:
32     static napi_value GetNapiInt32(napi_env env, int32_t code);
33     static napi_value EnumClassConstructor(napi_env env, napi_callback_info info);
34     static napi_value CreateInstance(napi_env env);
35     static JsShortKeyContext* GetInstance(napi_env env);
36     static napi_value CreateJsObject(napi_env env, napi_callback_info info);
37     std::shared_ptr<JsShortKeyManager> mgr_ { nullptr };
38     napi_ref contextRef_ { nullptr };
39 };
40 } // namespace MMI
41 } // namespace OHOS
42 #endif // JS_SHORT_KEY_CONTEXT_H