1 /* 2 * Copyright (C) 2021-2022 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 WIFI_NAPI_P2P_H_ 17 #define WIFI_NAPI_P2P_H_ 18 19 #include "wifi_napi_utils.h" 20 #include "wifi_p2p.h" 21 22 namespace OHOS { 23 namespace Wifi { 24 napi_value GetP2pLinkedInfo(napi_env env, napi_callback_info info); 25 napi_value GetCurrentGroup(napi_env env, napi_callback_info info); 26 napi_value GetP2pDevices(napi_env env, napi_callback_info info); 27 napi_value GetP2pLocalDevice(napi_env env, napi_callback_info info); 28 napi_value GetP2pGroups(napi_env env, napi_callback_info info); 29 napi_value CreateGroup(napi_env env, napi_callback_info info); 30 napi_value RemoveGroup(napi_env env, napi_callback_info info); 31 napi_value P2pConnect(napi_env env, napi_callback_info info); 32 napi_value P2pCancelConnect(napi_env env, napi_callback_info info); 33 napi_value StartDiscoverDevices(napi_env env, napi_callback_info info); 34 napi_value StopDiscoverDevices(napi_env env, napi_callback_info info); 35 napi_value DeletePersistentGroup(napi_env env, napi_callback_info info); 36 napi_value SetDeviceName(napi_env env, napi_callback_info info); 37 38 class P2pLocalDeviceAsyncContext : public AsyncContext { 39 public: 40 WifiP2pDevice deviceInfo; 41 42 P2pLocalDeviceAsyncContext(napi_env env, napi_async_work work = nullptr, napi_deferred deferred = nullptr) AsyncContext(env,work,deferred)43 : AsyncContext(env, work, deferred) {} 44 45 P2pLocalDeviceAsyncContext() = delete; 46 ~P2pLocalDeviceAsyncContext()47 ~P2pLocalDeviceAsyncContext() override {} 48 }; 49 50 class QueryP2pDeviceAsyncContext : public AsyncContext { 51 public: 52 std::vector<WifiP2pDevice> vecP2pDevices; 53 54 QueryP2pDeviceAsyncContext(napi_env env, napi_async_work work = nullptr, napi_deferred deferred = nullptr) AsyncContext(env,work,deferred)55 : AsyncContext(env, work, deferred) {} 56 57 QueryP2pDeviceAsyncContext() = delete; 58 ~QueryP2pDeviceAsyncContext()59 ~QueryP2pDeviceAsyncContext() override {} 60 }; 61 62 class P2pLinkedInfoAsyncContext : public AsyncContext { 63 public: 64 WifiP2pLinkedInfo linkedInfo; 65 66 P2pLinkedInfoAsyncContext(napi_env env, napi_async_work work = nullptr, napi_deferred deferred = nullptr) AsyncContext(env,work,deferred)67 : AsyncContext(env, work, deferred) {} 68 69 P2pLinkedInfoAsyncContext() = delete; 70 ~P2pLinkedInfoAsyncContext()71 ~P2pLinkedInfoAsyncContext() override {} 72 }; 73 74 class P2pGroupInfoAsyncContext : public AsyncContext { 75 public: 76 WifiP2pGroupInfo groupInfo; 77 78 P2pGroupInfoAsyncContext(napi_env env, napi_async_work work = nullptr, napi_deferred deferred = nullptr) AsyncContext(env,work,deferred)79 : AsyncContext(env, work, deferred) {} 80 81 P2pGroupInfoAsyncContext() = delete; 82 ~P2pGroupInfoAsyncContext()83 ~P2pGroupInfoAsyncContext() override {} 84 }; 85 86 class P2pGroupInfoListAsyncContext : public AsyncContext { 87 public: 88 std::vector<WifiP2pGroupInfo> vecGroupInfoList; 89 90 P2pGroupInfoListAsyncContext(napi_env env, napi_async_work work = nullptr, 91 napi_deferred deferred = nullptr) AsyncContext(env,work,deferred)92 : AsyncContext(env, work, deferred) {} 93 94 P2pGroupInfoListAsyncContext() = delete; 95 ~P2pGroupInfoListAsyncContext()96 ~P2pGroupInfoListAsyncContext() override {} 97 }; 98 } // namespace Wifi 99 } // namespace OHOS 100 101 #endif 102