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 #include "vpn_connection.h"
17
18 #include "destroy_context.h"
19 #include "module_template.h"
20 #include "prepare_context.h"
21 #include "protect_context.h"
22 #include "setup_context.h"
23 #include "vpn_async_work.h"
24 #include "vpn_monitor.h"
25
26 namespace OHOS {
27 namespace NetManagerStandard {
28 namespace VpnConnection {
Prepare(napi_env env,napi_callback_info info)29 napi_value Prepare(napi_env env, napi_callback_info info)
30 {
31 return ModuleTemplate::Interface<PrepareContext>(env, info, PREPARE, nullptr, VpnAsyncWork::ExecPrepare,
32 VpnAsyncWork::PrepareCallback);
33 }
34
SetUp(napi_env env,napi_callback_info info)35 napi_value SetUp(napi_env env, napi_callback_info info)
36 {
37 return ModuleTemplate::Interface<SetUpContext>(env, info, SET_UP, nullptr, VpnAsyncWork::ExecSetUp,
38 VpnAsyncWork::SetUpCallback);
39 }
40
Protect(napi_env env,napi_callback_info info)41 napi_value Protect(napi_env env, napi_callback_info info)
42 {
43 return ModuleTemplate::Interface<ProtectContext>(env, info, PROTECT, nullptr, VpnAsyncWork::ExecProtect,
44 VpnAsyncWork::ProtectCallback);
45 }
46
Destroy(napi_env env,napi_callback_info info)47 napi_value Destroy(napi_env env, napi_callback_info info)
48 {
49 return ModuleTemplate::Interface<DestroyContext>(env, info, DESTROY, nullptr, VpnAsyncWork::ExecDestroy,
50 VpnAsyncWork::DestroyCallback);
51 }
52
On(napi_env env,napi_callback_info info)53 napi_value On(napi_env env, napi_callback_info info)
54 {
55 return VpnMonitor::GetInstance().On(env, info);
56 }
57
Off(napi_env env,napi_callback_info info)58 napi_value Off(napi_env env, napi_callback_info info)
59 {
60 return VpnMonitor::GetInstance().Off(env, info);
61 }
62 } // namespace VpnConnection
63 } // namespace NetManagerStandard
64 } // namespace OHOS