• 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 ASSET_NAPI_COMMON_H
17 #define ASSET_NAPI_COMMON_H
18 
19 #include <vector>
20 
21 #include "napi/native_api.h"
22 #include "napi/native_node_api.h"
23 
24 #include "asset_type.h"
25 
26 namespace OHOS {
27 namespace Security {
28 namespace Asset {
29 
30 #define UPDATE_ARGS_NUM 2
31 
32 typedef struct AsyncContext {
33     // common
34     napi_async_work work = nullptr;
35     napi_deferred deferred = nullptr;
36 
37     // input
38     std::vector<Asset_Attr> attrs;
39     std::vector<Asset_Attr> updateAttrs;
40 
41     // output
42     int32_t result = 0;
43     Asset_Blob challenge = { 0 };
44     Asset_ResultSet resultSet = { 0 };
45 } AsyncContext;
46 
47 napi_value NapiEntry(napi_env env, napi_callback_info info, const char *funcName, napi_async_execute_callback execute,
48     size_t expectArgNum = 1);
49 
50 } // Asset
51 } // Security
52 } // OHOS
53 
54 #endif // ASSET_NAPI_COMMON_H