• 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 JS_SHORT_KEY_MANAGER_H
17 #define JS_SHORT_KEY_MANAGER_H
18 
19 #include "napi/native_api.h"
20 #include "input_manager.h"
21 #include "napi_constants.h"
22 #include "stream_buffer.h"
23 #include "util_napi_error.h"
24 
25 namespace OHOS {
26 namespace MMI {
27 class JsCommon {
28 public:
29     static bool TypeOf(napi_env env, napi_value value, napi_valuetype type);
30 };
31 
32 struct AsyncContext : RefBase {
33     napi_env env { nullptr };
34     napi_async_work work { nullptr };
35     napi_deferred deferred { nullptr };
36     napi_ref callback { nullptr };
37     int32_t errorCode { -1 };
38     StreamBuffer reserve;
AsyncContextAsyncContext39     explicit AsyncContext(napi_env env) : env(env) {}
40     ~AsyncContext();
41 };
42 
43 class JsShortKeyManager final {
44 public:
45     JsShortKeyManager() = default;
46     ~JsShortKeyManager() = default;
47     DISALLOW_COPY_AND_MOVE(JsShortKeyManager);
48 
49     void ResetEnv();
50     napi_value SetKeyDownDuration(napi_env env, const std::string &key, int32_t keyDownDuration,
51         napi_value handle = nullptr);
52 };
53 } // namespace MMI
54 } // namespace OHOS
55 #endif // JS_SHORT_KEY_MANAGER_H